-
Notifications
You must be signed in to change notification settings - Fork 529
tsunami -- handle onSubmit and onChange for file inputs #2541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2025, Command Line Inc. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import base64 from "base64-js"; | ||
|
|
||
| export function base64ToString(b64: string): string { | ||
| if (b64 == null) { | ||
| return null; | ||
| } | ||
| if (b64 == "") { | ||
| return ""; | ||
| } | ||
| const stringBytes = base64.toByteArray(b64); | ||
| return new TextDecoder().decode(stringBytes); | ||
| } | ||
|
|
||
| export function stringToBase64(input: string): string { | ||
| const stringBytes = new TextEncoder().encode(input); | ||
| return base64.fromByteArray(stringBytes); | ||
| } | ||
|
|
||
| export function base64ToArray(b64: string): Uint8Array<ArrayBufferLike> { | ||
| const cleanB64 = b64.replace(/\s+/g, ""); | ||
| return base64.toByteArray(cleanB64); | ||
| } | ||
|
|
||
| export function base64ToArrayBuffer(b64: string): ArrayBuffer { | ||
| const cleanB64 = b64.replace(/\s+/g, ""); | ||
| const u8 = base64.toByteArray(cleanB64); // Uint8Array<ArrayBufferLike> | ||
| // Force a plain ArrayBuffer slice (no SharedArrayBuffer, no offset issues) | ||
| return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength) as ArrayBuffer; | ||
| } | ||
|
|
||
| export function arrayBufferToBase64(buffer: ArrayBuffer): string { | ||
| const u8 = new Uint8Array(buffer); | ||
| return base64.fromByteArray(u8); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore deterministic ordering for async form/file events
Line 724 introduces an async branch that only pushes the event after
fileToVDomFileDataresolves. Because each handler now resolves independently, a later (smaller) file can finish first, enter the batch, and triggerqueueUpdatebefore an earlier (larger) file has finished reading. The backend will then observe the events out of chronological order, breaking correctness for workflows that depend on deterministic sequencing of changes/submits. Please serialize these asynchronous annotations so they flush tobatchedEventsin the exact order the handlers fire.Apply this diff to chain async work per event:
if (needsAsync) { - asyncAnnotateEvent(vdomEvent, propName, e) - .then(() => { - this.batchedEvents.push(vdomEvent); - this.queueUpdate(true, "event"); - }) - .catch((err) => { - console.error("Error processing event:", err); - }); + this.pendingAsyncEventChain = this.pendingAsyncEventChain + .then(async () => { + await asyncAnnotateEvent(vdomEvent, propName, e); + this.batchedEvents.push(vdomEvent); + this.queueUpdate(true, "event"); + }) + .catch((err) => { + console.error("Error processing event:", err); + });And add the supporting field in the class body:
🤖 Prompt for AI Agents