Conversation
0c66110 to
369feb9
Compare
80d8c65 to
c35c2ac
Compare
This adds patching (2-phase diffing) to miso. This allows patch objects to be transferred elsewhere for rendering (in the case of miso native this is required). This includes transferring event listener initialization, component mounting / unmounting, and render tree diffing. This patch abstract `VTree` over the underlying `DOMRef`. In the Haskell runtime it will be represented as a pure identifier (`NodeId` which holds the pure identifier `number`). Patch application includes an `Environment` that holds a `Node` mapping for each `Component`. This mapping is used to faciliate modifications to the tree in O(1) time. - [x] Abstract `VTree` and `Context` over `T` in `dom.ts`, tests, etc. - [x] Add `patch.ts` and additional types for runtime patching - [ ] Add `nodeId` to each `VTree` node - [ ] Test patch accumulation and patch application for `applyPatch` - [ ] Ensure `NodeId` can be used with event delegation
- Generalizes `delegate` to `delegate<T>`, `undelegate<T>`, `dispatch`, etc. - Add `removeEventListener` - Add `context/dom.ts` - cast `EventTarget` as `DOMRef` in `context`
…respectively. - `setDrawingContext` now expects `globalThis[name].eventContext` and `globalThis[name].drawingContext` to be defined. - Define `flush` on top-level `miso` object. - `context` -> `drawingContext`, etc. Update tests to reflect this. - Drop `.querySelectorAll()`. - Update `Miso.Internal.FFI` to split out `getContext` into `getDrawingContext`, etc. - Put `ts/index.ts` into `tsconfig.lib.json` - Mock out patch.ts context.
- Add tag for vtext to satisfy TypeScript typechecker
- [x] Use `setProp`, avoid circular import issues - [x] Add `mountComponent`, `unmountComponent`, `modelHydration` stubs - [x] Drop event handling patches (will go into Component) - [x] Refactor `globalThis.miso`
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.
This adds patching (2-phase diffing) to
miso's JS library (meant for use inmiso-lynx). This allows patch objects to be transferred elsewhere for rendering (in the case ofmiso-lynxthis is required, since it uses preact). This includes transferring event listener initialization, delegation of background events, component mounting / unmounting, and render tree diffing between threads via a Web Worker (or other) all using a well-defined protocol.This patch abstracts
VTreeover the underlyingDOMRef(or any otherNodefor that matter). In the case ofmiso-lynx, the Haskell runtime will hold a pure identifier,NodeIdof typenumber, and the main thread runtime will hold references to the native device views.Patch application includes an
Environmentthat holds aNodeIdmapping for eachNode. This mapping is used to facilitate modifications to the tree in O(1) time.This is PR 1/2 (the second occurring in
miso-lynx) which will allow us to consume native components from iOS, Android, Harmony devices, etc. and to rely on thereact-lynxplugin for code splitting.VTreeandContextoverTindom.ts, tests, etc.patch.tsand additional types for runtime patchinghydrate.tstoDOMRefContextintoHydrationContextandDrawingContextnodeIdto eachVTreenode (done increateElementon BTS side)applyPatchTransfer JSON'ifiedmodelso read-only state is present for main thread eventsEnsureNodeIdcan be used with event delegationTesteval()of exported functions from Haskell for main thread eventsIncorporate main thread events inComponent(enable via flag w/CPP)EDIT: We will split this up into 3 PRs, one for Patches (done here), Component mounting / unmounting, and finally splitting up event delegation. This is step 1/3.