Carry files and drag data transfers in event payloads - #26
Merged
Conversation
`form-data` gains `files: list<own<file>>`, and drag events move from the
`mouse` family to `drag-data { mouse, transfer: option<own<data-transfer>> }`.
Both new types are host resources, for reasons the DOM dictates: a File's
contents are only readable asynchronously (so `file.read` returns a
`stream<u8>`, the shape `eval` already uses), and a DataTransfer's setters
mean something only against the live object during `dragstart`, while
protected mode hides `getData` outside `dragstart`/`drop` — a snapshot
would have to fake both. This is what dioxus-web's users already see.
Guest: `WitFile` / `WitDataTransfer` back dioxus-html's `NativeFileData`
and `NativeDataTransfer` one to one. Owned handles are lifted out of the
payload once at `WitEventData` construction, since dioxus may convert the
same dispatch more than once and a handle moves only once. `byte_stream`
is `unfold` over chunked reads, yielding a final chunk that arrives with
`Dropped`; the `Send` bounds are satisfied the way dioxus-web satisfies
them, by assertion on a single-threaded target.
Host: `HostFile` wraps a `File` (metadata as bigint where the WIT says
u64; `read` returns `File.stream()`), `HostDataTransfer` wraps the live
DataTransfer and reports refused setters as `ComponentException`. Both
register under the `events` import beside `DomEvent`; instances nested in
a payload passed to `handle-event` register on the way through, as the
contract says.
The other families that still dispatch as `empty` — clipboard, media,
selection, toggle — carry nothing because dioxus-html's own data types
for them expose no accessors; there is nothing to add.
lannbot
enabled auto-merge
September 5, 2026 13:37
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes the last event-payload gap against dioxus-web.
WIT (
interface events):form-data.files: list<own<file>>; newpayload.drag(drag-data { mouse, transfer: option<own<data-transfer>> })replacing the mouse-family reuse for drag names;resource file(name/size/last-modified/content-type,read() -> stream<u8>);resource data-transfermirroringNativeDataTransferone to one.Both are resources rather than snapshots because the DOM makes them so: File contents read asynchronously; DataTransfer setters only work live during
dragstart, and protected mode hidesgetDataoutsidedragstart/drop.Guest:
WitFile/WitDataTransfer; handles lifted once atWitEventDataconstruction (dioxus may convert a dispatch more than once);byte_streamviaunfoldover chunked reads; Send bounds asserted as dioxus-web does.Host:
HostFile(readreturnsFile.stream(), verified end-to-end through the runtime),HostDataTransfer(refused setters →ComponentException), registered undereventswithDomEvent.Tests: unit tests for both classes and the payload shapes; platform-probe fixture gains a file input and a drop target — e2e asserts
read_stringandbyte_streamagree on a realFile, and that a guestset_dataindragstartis read back ondrop. 151 deno tests; fulljustgate set passes.Clipboard/media/selection/toggle remain
empty: dioxus-html's data types for them have no accessors.Automerge armed (merge commit).