@lynx-js/react 0.129.3 → 0.129.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -2
- package/refresh/.turbo/turbo-build.log +3 -3
- package/refresh/dist/index.js +113 -20
- package/refresh/rslib.config.ts +13 -3
- package/refresh/src/index.ts +100 -0
- package/refresh/src/self.ts +38 -0
- package/runtime/__test__/{snapshot → core}/attribute-name.test.ts +1 -1
- package/runtime/__test__/core/background-function.test.ts +37 -0
- package/runtime/__test__/{shared → core}/component-stack.test.ts +4 -4
- package/runtime/__test__/core/lynx/env.test.ts +146 -0
- package/runtime/__test__/core/ref.test.ts +218 -1
- package/runtime/__test__/core/sync-effect-flush.test.ts +58 -0
- package/runtime/__test__/element-template/debug/alog.test.ts +20 -12
- package/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx +15 -34
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt +2 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt +6 -1
- package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.move-before-child → children.reconciles-raw-text-slots}/case.tsx +1 -1
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/output.txt +1 -0
- package/runtime/__test__/element-template/fixtures/list/mts/index.tsx +185 -0
- package/runtime/__test__/element-template/fixtures/page/render-page/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/case.tsx +2 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/ops.txt +1 -0
- package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/ops.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/child-siblings/papi.txt +10 -5
- package/runtime/__test__/element-template/fixtures/render/component/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/component-slot-content/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/papi.txt +2 -1
- package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/native-log.txt +2 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/native-log.txt +3 -0
- package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/native-log.txt +1 -0
- package/runtime/__test__/element-template/fixtures/render/mapped-view-children/papi.txt +14 -7
- package/runtime/__test__/element-template/fixtures/render/mixed-children/papi.txt +8 -4
- package/runtime/__test__/element-template/fixtures/render/multiple-text/papi.txt +38 -19
- package/runtime/__test__/element-template/fixtures/render/nested-templates/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/react-example/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/papi.txt +6 -3
- package/runtime/__test__/element-template/fixtures/render/template-dedupe/papi.txt +10 -5
- package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +47 -4
- package/runtime/__test__/element-template/lynx/performance.test.ts +1 -0
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +1 -0
- package/runtime/__test__/element-template/native/index.test.ts +9 -9
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +65 -17
- package/runtime/__test__/element-template/native/reload.test.ts +19 -12
- package/runtime/__test__/element-template/runtime/background/adapter/background-adapter.et.test.tsx +0 -32
- package/runtime/__test__/element-template/runtime/background/commit-context.test.ts +0 -14
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +10 -0
- package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +22 -0
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +197 -252
- package/runtime/__test__/element-template/runtime/background/instance.test.ts +277 -126
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +1 -1
- package/runtime/__test__/element-template/runtime/background/passive-update-depth.test.tsx +496 -0
- package/runtime/__test__/element-template/runtime/background/render/preact.test.tsx +16 -22
- package/runtime/__test__/element-template/runtime/background/root-render.test.tsx +5 -3
- package/runtime/__test__/element-template/runtime/background/suspense.test.tsx +2 -0
- package/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +1 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +4 -5
- package/runtime/__test__/element-template/runtime/list/list-mts-compiled.test.ts +525 -0
- package/runtime/__test__/element-template/runtime/page/compiled-fixtures.test.tsx +2 -0
- package/runtime/__test__/element-template/runtime/page/root-instance.test.ts +2 -14
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +425 -1032
- package/runtime/__test__/element-template/runtime/patch/patch-listener-alog.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/event.test.ts +0 -20
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +2 -1
- package/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts +1 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/ref.test.ts +65 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +12 -4
- package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +2 -5
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +56 -121
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +18 -17
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +5 -4
- package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -0
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +1 -60
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +65 -89
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +8 -6
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +34 -6
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.test.tsx +20 -12
- package/runtime/__test__/element-template/test-utils/debug/updateRunner.ts +2 -28
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.test.ts +14 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.ts +1 -57
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +29 -13
- package/runtime/__test__/element-template/vitest.config.ts +2 -1
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +98 -77
- package/runtime/__test__/snapshot/debug/passive-update-depth.test.jsx +549 -0
- package/runtime/__test__/snapshot/debug/profile.test.jsx +147 -26
- package/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx +3 -3
- package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +138 -1
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +55 -1
- package/runtime/__test__/snapshot/lifecycle/transfer.mts.test.jsx +286 -0
- package/runtime/__test__/snapshot/lifecycle/transfer.test.jsx +415 -0
- package/runtime/__test__/snapshot/list.test.jsx +109 -0
- package/runtime/__test__/snapshot/lynx/suspense.test.jsx +48 -0
- package/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx +2 -2
- package/runtime/__test__/snapshot/ref.test.jsx +124 -1
- package/runtime/__test__/snapshot/utils/envManager.ts +7 -0
- package/runtime/__test__/snapshot/utils/globals.js +1 -0
- package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +43 -11
- package/runtime/__test__/worklet-runtime/hydrate.test.js +1 -0
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +24 -16
- package/runtime/__test__/worklet-runtime/lifecycle.test.js +297 -0
- package/runtime/__test__/worklet-runtime/profile.test.js +12 -6
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +188 -0
- package/runtime/__test__/worklet-runtime/workletRef.test.js +16 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +53 -1
- package/runtime/lazy/element-template-internal.js +1 -0
- package/runtime/lazy/internal.js +1 -0
- package/runtime/lib/core/attribute-name.js.map +1 -0
- package/runtime/lib/core/background-function/run-on-background.js +7 -7
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/compat/componentIs.d.ts +1 -0
- package/runtime/lib/core/compat/componentIs.js +20 -0
- package/runtime/lib/core/compat/componentIs.js.map +1 -0
- package/runtime/lib/{shared → core}/component-stack.js +1 -1
- package/runtime/lib/core/component-stack.js.map +1 -0
- package/runtime/lib/core/deep-equal.d.ts +1 -0
- package/runtime/lib/core/deep-equal.js +31 -0
- package/runtime/lib/core/deep-equal.js.map +1 -0
- package/runtime/lib/core/hooks/mainThreadImpl.js +1 -1
- package/runtime/lib/core/hooks/mainThreadImpl.js.map +1 -1
- package/runtime/lib/core/lynx/env.d.ts +1 -0
- package/runtime/lib/{element-template → core}/lynx/env.js +3 -2
- package/runtime/lib/core/lynx/env.js.map +1 -0
- package/runtime/lib/core/lynx-page-data.js +1 -1
- package/runtime/lib/core/lynx-page-data.js.map +1 -1
- package/runtime/lib/core/mts-capability.js +1 -1
- package/runtime/lib/core/mts-capability.js.map +1 -1
- package/runtime/lib/core/performance.js +2 -1
- package/runtime/lib/core/performance.js.map +1 -1
- package/runtime/lib/core/ref.d.ts +1 -2
- package/runtime/lib/core/ref.js +60 -9
- package/runtime/lib/core/ref.js.map +1 -1
- package/runtime/lib/core/sync-effect-flush.d.ts +9 -0
- package/runtime/lib/core/sync-effect-flush.js +31 -0
- package/runtime/lib/core/sync-effect-flush.js.map +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.d.ts +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +5 -2
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.d.ts +1 -0
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-event.d.ts +6 -0
- package/runtime/lib/element-template/background/commit-event.js +36 -0
- package/runtime/lib/element-template/background/commit-event.js.map +1 -0
- package/runtime/lib/element-template/background/commit-hook.js +4 -24
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +2 -2
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +174 -87
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +5 -25
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/background/instance.d.ts +7 -10
- package/runtime/lib/element-template/background/instance.js +65 -58
- package/runtime/lib/element-template/background/instance.js.map +1 -1
- package/runtime/lib/element-template/{runtime/template → background}/main-thread-function.js +4 -4
- package/runtime/lib/element-template/background/main-thread-function.js.map +1 -0
- package/runtime/lib/element-template/background/render-scope.js +2 -1
- package/runtime/lib/element-template/background/render-scope.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +1 -10
- package/runtime/lib/element-template/debug/alog.js +1 -16
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/debug/profile.js +1 -1
- package/runtime/lib/element-template/debug/profile.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +1 -1
- package/runtime/lib/element-template/index.js +1 -1
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.js +3 -0
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +4 -4
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.d.ts +2 -1
- package/runtime/lib/element-template/native/mts-destroy.js +15 -4
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +4 -8
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +2 -6
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/ref.d.ts +2 -1
- package/runtime/lib/element-template/prop-adapters/ref.js +4 -4
- package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +1 -1
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +0 -2
- package/runtime/lib/element-template/protocol/opcodes.js +0 -2
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +8 -30
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/list.d.ts +14 -54
- package/runtime/lib/element-template/runtime/list/list.js +82 -546
- package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
- package/runtime/lib/element-template/runtime/list/platform-info.d.ts +2 -0
- package/runtime/lib/element-template/runtime/list/platform-info.js +26 -0
- package/runtime/lib/element-template/runtime/list/platform-info.js.map +1 -0
- package/runtime/lib/element-template/runtime/patch.js +44 -128
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +1 -1
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js +24 -21
- package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.d.ts +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +3 -6
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-direct.js +21 -20
- package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +0 -13
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +8 -0
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/handle.d.ts +3 -3
- package/runtime/lib/element-template/runtime/template/handle.js +3 -3
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -8
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +2 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +44 -28
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.d.ts +2 -0
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +8 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -0
- package/runtime/lib/internal.js +5 -10
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.js +6 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +4 -4
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.d.ts +5 -1
- package/runtime/lib/root.js +12 -1
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/shared/microtask.d.ts +1 -0
- package/runtime/lib/shared/microtask.js +28 -0
- package/runtime/lib/shared/microtask.js.map +1 -0
- package/runtime/lib/shared/utils.d.ts +8 -0
- package/runtime/lib/shared/utils.js +27 -0
- package/runtime/lib/shared/utils.js.map +1 -0
- package/runtime/lib/{worklet-runtime/utils → shared}/version.d.ts +1 -0
- package/runtime/lib/{worklet-runtime/utils → shared}/version.js +4 -2
- package/runtime/lib/shared/version.js.map +1 -0
- package/runtime/lib/snapshot/alog/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +28 -63
- package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +2 -2
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js +2 -1
- package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/commit.d.ts +7 -2
- package/runtime/lib/snapshot/lifecycle/patch/commit.js +11 -6
- package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +2 -2
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +12 -3
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/lynx/env.js +2 -32
- package/runtime/lib/snapshot/lynx/env.js.map +1 -1
- package/runtime/lib/snapshot/lynx/tt.d.ts +3 -1
- package/runtime/lib/snapshot/lynx/tt.js +7 -3
- package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js +1 -1
- package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/ref.d.ts +1 -0
- package/runtime/lib/snapshot/snapshot/ref.js +2 -2
- package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js +1 -1
- package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/spread.js +3 -2
- package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/transfer.d.ts +21 -0
- package/runtime/lib/snapshot/transfer.js +486 -0
- package/runtime/lib/snapshot/transfer.js.map +1 -0
- package/runtime/lib/snapshot/worklet/functionality.js +1 -1
- package/runtime/lib/snapshot/worklet/functionality.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/api/element.js +1 -1
- package/runtime/lib/worklet-runtime/api/element.js.map +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js +1 -1
- package/runtime/lib/worklet-runtime/api/lynxApi.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -2
- package/runtime/lib/worklet-runtime/bindings/bindings.js +11 -1
- package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/lifecycle.d.ts +19 -0
- package/runtime/lib/worklet-runtime/bindings/lifecycle.js +49 -0
- package/runtime/lib/worklet-runtime/bindings/lifecycle.js.map +1 -0
- package/runtime/lib/worklet-runtime/bindings/observers.js +9 -1
- package/runtime/lib/worklet-runtime/bindings/observers.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
- package/runtime/lib/worklet-runtime/delayWorkletEvent.d.ts +3 -5
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js +49 -43
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js.map +1 -1
- package/runtime/lib/worklet-runtime/global.d.ts +1 -2
- package/runtime/lib/worklet-runtime/global.js.map +1 -1
- package/runtime/lib/worklet-runtime/hydrate.js +2 -32
- package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
- package/runtime/lib/worklet-runtime/run-on-background/index.d.ts +28 -0
- package/runtime/lib/worklet-runtime/run-on-background/index.js +103 -0
- package/runtime/lib/worklet-runtime/run-on-background/index.js.map +1 -0
- package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.d.ts → run-on-background/lifecycle.d.ts} +2 -2
- package/runtime/lib/worklet-runtime/{jsFunctionLifecycle.js → run-on-background/lifecycle.js} +12 -9
- package/runtime/lib/worklet-runtime/run-on-background/lifecycle.js.map +1 -0
- package/runtime/lib/worklet-runtime/utils/profile.js +1 -3
- package/runtime/lib/worklet-runtime/utils/profile.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRef.js +51 -54
- package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +5 -6
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/src/core/background-function/run-on-background.ts +7 -7
- package/runtime/src/core/compat/componentIs.ts +32 -0
- package/runtime/src/{shared → core}/component-stack.ts +1 -1
- package/runtime/src/core/deep-equal.ts +33 -0
- package/runtime/src/core/hooks/mainThreadImpl.ts +1 -1
- package/runtime/src/{element-template → core}/lynx/env.ts +6 -4
- package/runtime/src/core/lynx-page-data.ts +1 -1
- package/runtime/src/core/mts-capability.ts +1 -1
- package/runtime/src/core/performance.ts +2 -1
- package/runtime/src/core/ref.ts +92 -15
- package/runtime/src/core/sync-effect-flush.ts +30 -0
- package/runtime/src/core/thread-function-call/main-thread.ts +6 -2
- package/runtime/src/element-template/background/attr-slots.ts +2 -2
- package/runtime/src/element-template/background/commit-event.ts +52 -0
- package/runtime/src/element-template/background/commit-hook.ts +5 -32
- package/runtime/src/element-template/background/destroy.ts +2 -2
- package/runtime/src/element-template/background/hydrate.ts +234 -122
- package/runtime/src/element-template/background/hydration-listener.ts +7 -32
- package/runtime/src/element-template/background/instance.ts +82 -82
- package/runtime/src/element-template/{runtime/template → background}/main-thread-function.ts +4 -7
- package/runtime/src/element-template/background/render-scope.ts +2 -1
- package/runtime/src/element-template/debug/alog.ts +2 -30
- package/runtime/src/element-template/debug/profile.ts +1 -1
- package/runtime/src/element-template/index.ts +1 -1
- package/runtime/src/element-template/internal.ts +4 -0
- package/runtime/src/element-template/native/index.ts +4 -4
- package/runtime/src/element-template/native/mts-destroy.ts +21 -4
- package/runtime/src/element-template/native/patch-listener.ts +6 -7
- package/runtime/src/element-template/native/reload-main-thread.ts +2 -6
- package/runtime/src/element-template/prop-adapters/ref.ts +12 -5
- package/runtime/src/element-template/prop-adapters/spread.ts +1 -1
- package/runtime/src/element-template/protocol/opcodes.ts +0 -2
- package/runtime/src/element-template/protocol/types.ts +10 -38
- package/runtime/src/element-template/runtime/list/list.ts +115 -744
- package/runtime/src/element-template/runtime/list/platform-info.ts +31 -0
- package/runtime/src/element-template/runtime/patch.ts +78 -197
- package/runtime/src/element-template/runtime/render/create-rendered-host.ts +27 -31
- package/runtime/src/element-template/runtime/render/render-components.ts +2 -5
- package/runtime/src/element-template/runtime/render/render-direct.ts +19 -18
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +0 -14
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +9 -0
- package/runtime/src/element-template/runtime/template/handle.ts +5 -2
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +9 -8
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +44 -30
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +17 -1
- package/runtime/src/element-template/types.d.ts +6 -22
- package/runtime/src/internal.ts +6 -13
- package/runtime/src/lynx-api.ts +6 -1
- package/runtime/src/lynx.ts +4 -4
- package/runtime/src/root.ts +17 -1
- package/runtime/src/shared/microtask.ts +26 -0
- package/runtime/src/shared/utils.ts +37 -0
- package/runtime/src/{worklet-runtime/utils → shared}/version.ts +6 -4
- package/runtime/src/snapshot/alog/render.ts +1 -1
- package/runtime/src/snapshot/debug/profileHooks.ts +31 -92
- package/runtime/src/snapshot/lifecycle/destroy.ts +2 -2
- package/runtime/src/snapshot/lifecycle/isRendering.ts +2 -1
- package/runtime/src/snapshot/lifecycle/patch/commit.ts +28 -7
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +1 -1
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +5 -2
- package/runtime/src/snapshot/lifecycle/reload.ts +3 -4
- package/runtime/src/snapshot/list/list.ts +12 -3
- package/runtime/src/snapshot/lynx/env.ts +3 -43
- package/runtime/src/snapshot/lynx/tt.ts +8 -3
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +1 -1
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/snapshot/snapshot/platformInfo.ts +1 -1
- package/runtime/src/snapshot/snapshot/ref.ts +7 -4
- package/runtime/src/snapshot/snapshot/snapshot.ts +1 -1
- package/runtime/src/snapshot/snapshot/spread.ts +3 -2
- package/runtime/src/snapshot/transfer.ts +535 -0
- package/runtime/src/snapshot/worklet/functionality.ts +1 -1
- package/runtime/src/worklet-runtime/api/element.ts +1 -1
- package/runtime/src/worklet-runtime/api/lynxApi.ts +1 -1
- package/runtime/src/worklet-runtime/bindings/bindings.ts +12 -0
- package/runtime/src/worklet-runtime/bindings/lifecycle.ts +51 -0
- package/runtime/src/worklet-runtime/bindings/observers.ts +9 -1
- package/runtime/src/worklet-runtime/bindings/types.ts +1 -0
- package/runtime/src/worklet-runtime/delayWorkletEvent.ts +57 -54
- package/runtime/src/worklet-runtime/global.ts +1 -2
- package/runtime/src/worklet-runtime/hydrate.ts +2 -35
- package/runtime/src/worklet-runtime/run-on-background/index.ts +145 -0
- package/runtime/src/worklet-runtime/{jsFunctionLifecycle.ts → run-on-background/lifecycle.ts} +11 -9
- package/runtime/src/worklet-runtime/utils/profile.ts +1 -3
- package/runtime/src/worklet-runtime/workletRef.ts +63 -62
- package/runtime/src/worklet-runtime/workletRuntime.ts +10 -10
- package/runtime/types/internal-preact.d.ts +2 -0
- package/runtime/vitest.config.ts +0 -1
- package/testing-library/.turbo/turbo-build.log +11 -11
- package/testing-library/dist/pure.js +7 -4
- package/testing-library/dist/setupFiles/common/runtime-setup.js +3 -1
- package/testing-library/dist/setupFiles/inner/rstest.js +1 -1
- package/testing-library/dist/setupFiles/inner/vitest.js +1 -1
- package/testing-library/src/__tests__/events.test.jsx +1 -1
- package/testing-library/src/__tests__/list.test.jsx +52 -0
- package/testing-library/src/__tests__/worklet.test.jsx +81 -0
- package/testing-library/src/fire-event.ts +1 -1
- package/testing-library/src/pure.jsx +5 -2
- package/testing-library/src/setupFiles/common/runtime-setup.js +2 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +45 -44
- package/transform/__test__/fixture.spec.js +1 -1
- package/transform/cjs/browser.cjs +11 -0
- package/transform/crates/swc_plugin_compat/lib.rs +20 -2
- package/transform/crates/swc_plugin_compat/napi.rs +7 -0
- package/transform/crates/swc_plugin_dynamic_import/lib.rs +15 -4
- package/transform/crates/swc_plugin_element_template/attr_name.rs +0 -3
- package/transform/crates/swc_plugin_element_template/extractor.rs +0 -8
- package/transform/crates/swc_plugin_element_template/lib.rs +12 -1
- package/transform/crates/swc_plugin_element_template/tests/element_template.rs +19 -45
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +35 -19
- package/transform/crates/swc_plugin_worklet/lib.rs +11 -7
- package/transform/dist/wasm.cjs +1 -1
- package/transform/rspack-napi/lib/index.js +1 -4
- package/transform/rspack-napi/lib/index.js.map +1 -1
- package/transform/rspack-napi/src/index.ts +1 -4
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/src/lib.rs +394 -27
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +415 -107
- package/transform/swc-plugin-reactlynx/src/lib.rs +99 -22
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +29 -339
- package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt +0 -10
- package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx +0 -5
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/case.ts +0 -11
- package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/output.txt +0 -1
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/case.ts +0 -23
- package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/output.txt +0 -6
- package/runtime/__test__/element-template/lynx/env.test.ts +0 -242
- package/runtime/__test__/element-template/runtime/page/authored-page.test.ts +0 -35
- package/runtime/__test__/element-template/runtime/patch/update-fixture-helper.test.tsx +0 -40
- package/runtime/__test__/snapshot/lynx-data-processors.test.ts +0 -3
- package/runtime/lib/element-template/lynx/env.d.ts +0 -1
- package/runtime/lib/element-template/lynx/env.js.map +0 -1
- package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +0 -1
- package/runtime/lib/shared/attribute-name.js.map +0 -1
- package/runtime/lib/shared/component-stack.js.map +0 -1
- package/runtime/lib/snapshot/alog/index.d.ts +0 -1
- package/runtime/lib/snapshot/alog/index.js +0 -8
- package/runtime/lib/snapshot/alog/index.js.map +0 -1
- package/runtime/lib/snapshot/compat/componentIs.d.ts +0 -4
- package/runtime/lib/snapshot/compat/componentIs.js +0 -20
- package/runtime/lib/snapshot/compat/componentIs.js.map +0 -1
- package/runtime/lib/utils.d.ts +0 -19
- package/runtime/lib/utils.js +0 -119
- package/runtime/lib/utils.js.map +0 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.d.ts +0 -13
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +0 -29
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +0 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +0 -1
- package/runtime/lib/worklet-runtime/utils/version.js.map +0 -1
- package/runtime/src/snapshot/alog/index.ts +0 -8
- package/runtime/src/snapshot/compat/componentIs.ts +0 -30
- package/runtime/src/utils.ts +0 -134
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +0 -53
- /package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.raw-text-key-branches → children.reconciles-raw-text-slots}/output.txt +0 -0
- /package/runtime/__test__/element-template/runtime/{template → background}/main-thread-function.test.ts +0 -0
- /package/runtime/lib/{shared → core}/attribute-name.d.ts +0 -0
- /package/runtime/lib/{shared → core}/attribute-name.js +0 -0
- /package/runtime/lib/{shared → core}/component-stack.d.ts +0 -0
- /package/runtime/lib/element-template/{runtime/template → background}/main-thread-function.d.ts +0 -0
- /package/runtime/src/{shared → core}/attribute-name.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,IAAI,SAAS,GAAG,KAAK,CA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,KAAK,EAAE,WAAW,EAAE,EAAE;QAC3D,IAAI,cAAc,EAAE,CAAC;YACnB,+BAA+B,EAAE,CAAC;YAClC,IAAI,CAAC;gBACH,8BAA8B,EAAE,CAAC;YACnC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,kCAAkC,CAChC,0CAA0C,EAAE,EAC5C,8BAA8B,EAAE,CACjC,CAAC;gBACF,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,cAAc,IAAI,CAAC,WAAW,IAAI,cAAc,EAAE,EAAE,CAAC;YACvD,2EAA2E;YAC3E,2EAA2E;YAC3E,gBAAgB,EAAE,CAAC;QACrB,CAAC;aAAM,IACL,cAAc,IAAI,WAAW;eAC1B,CACD,mBAAmB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;mBAC/B,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC;mBAChD,cAAc,EAAE;mBAChB,0BAA0B,CAAC,MAAM,GAAG,CAAC,CACzC,EACD,CAAC;YACD,iCAAiC,EAAE,CAAC;QACtC,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { options } from 'preact';\n\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport type { BackgroundElementTemplateInstance } from './instance.js';\nimport { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';\nimport { COMMIT } from '../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../utils.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';\nimport { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';\nimport { createElementTemplateUpdateEvent } from '../protocol/update-event.js';\n\nlet installed = false;\nlet previousCommit: typeof options[typeof COMMIT];\nlet hasHydrated = false;\nconst scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set<ReturnType<typeof setTimeout>>();\n\nexport function markElementTemplateHydrated(): void {\n hasHydrated = true;\n}\n\nexport function isElementTemplateHydrated(): boolean {\n return hasHydrated;\n}\n\nexport function resetElementTemplateCommitState(): void {\n hasHydrated = false;\n resetElementTemplateRenderScope();\n resetGlobalCommitContext();\n}\n\nexport function scheduleElementTemplateRemovedSubtreeCleanup(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n): void {\n if (removedSubtreesAwaitingTeardown.length === 0) {\n return;\n }\n const timer = setTimeout(() => {\n scheduledRemovedSubtreeCleanupTimers.delete(timer);\n for (const root of removedSubtreesAwaitingTeardown) {\n root.releaseDetachedSubtreeFromManager();\n }\n }, 10000);\n scheduledRemovedSubtreeCleanupTimers.add(timer);\n}\n\nexport function cancelElementTemplateRemovedSubtreeCleanup(): void {\n for (const timer of scheduledRemovedSubtreeCleanupTimers) {\n clearTimeout(timer);\n }\n scheduledRemovedSubtreeCleanupTimers.clear();\n}\n\nfunction cleanupFailedElementTemplateCommit(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n delayedRunOnMainThreadPayload: readonly { resolveId: number }[] | undefined,\n): void {\n if (delayedRunOnMainThreadPayload) {\n dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));\n }\n clearPendingRefs();\n resetGlobalCommitContext();\n setPipeline(undefined);\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nfunction flushElementTemplateCommitChanges(): void {\n const hasNativeOps = globalCommitContext.ops.length > 0;\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const hasUpdatePayload = hasNativeOps\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasDelayedRunOnMainThread;\n const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];\n if (hasUpdatePayload) {\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n if (globalPipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;\n }\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n\n if (!hasNativeOps && !hasDelayedRunOnMainThread) {\n globalCommitContext.flushOptions.emptyPatch = true;\n }\n\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n\n let updateEvent: ReturnType<typeof createElementTemplateUpdateEvent>;\n try {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate BTS -> MTS update:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),\n flushOptions: globalCommitContext.flushOptions,\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,\n },\n null,\n 2,\n ),\n );\n }\n\n updateEvent = createElementTemplateUpdateEvent({\n ops: globalCommitContext.ops,\n flushOptions: globalCommitContext.flushOptions,\n reloadVersion: getReloadVersion(),\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,\n });\n } catch (error) {\n cleanupFailedElementTemplateCommit(removedSubtreesAwaitingTeardown, delayedRunOnMainThreadPayload);\n throw error;\n }\n\n lynx.getCoreContext().dispatchEvent(updateEvent);\n }\n // When native ops exist, patch first so a newly attached ref observes the\n // committed native state. Ref-only commits still flush through this path.\n flushPendingRefs();\n resetGlobalCommitContext();\n // Match Snapshot's cleanup boundary: start the delayed teardown only\n // after the bridge dispatch, so background JS objects are not torn down\n // before main-thread detach observes the same commit.\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nexport function installElementTemplateCommitHook(): void {\n if (installed) {\n return;\n }\n installed = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {\n if (__BACKGROUND__) {\n clearElementTemplateRenderScope();\n try {\n sendMTRefInitValueToMainThread();\n } catch (error) {\n cleanupFailedElementTemplateCommit(\n takeRemovedSubtreesForPostDispatchTeardown(),\n takeDelayedRunOnMainThreadData(),\n );\n throw error;\n }\n }\n\n if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {\n // User effects can run before ET hydrate arrives, so ordinary refs must be\n // attached on the background commit even though native UI ops are delayed.\n flushPendingRefs();\n } else if (\n __BACKGROUND__ && hasHydrated\n && (\n globalCommitContext.ops.length > 0\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasPendingRefs()\n || delayedRunOnMainThreadData.length > 0\n )\n ) {\n flushElementTemplateCommitChanges();\n }\n\n originalCommit?.(vnode, commitQueue);\n });\n}\n\n/**\n * Restores the commit option replaced by\n * {@link installElementTemplateCommitHook} so tests can clean up the global\n * Preact `options` object. Assumes the matching install was the most recent\n * commit-option replacement; the snapshot and ElementTemplate runtimes are\n * separate entrypoints and never install their commit hooks in the same\n * context.\n */\nexport function uninstallElementTemplateCommitHookForTesting(): void {\n if (!installed) {\n return;\n }\n installed = false;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mCAAmC,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AAE9G,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,C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CAAC;YACD,iCAAiC,EAAE,CAAC;QACtC,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { options } from 'preact';\n\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport { dropDelayedRunOnMainThreadReturnIds, packElementTemplateCommitUpdateEvent } from './commit-event.js';\nimport type { BackgroundElementTemplateInstance } from './instance.js';\nimport { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { COMMIT } from '../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../shared/utils.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';\nimport { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';\n\nlet installed = false;\nlet previousCommit: typeof options[typeof COMMIT];\nlet hasHydrated = false;\nconst scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set<ReturnType<typeof setTimeout>>();\n\nexport function markElementTemplateHydrated(): void {\n hasHydrated = true;\n}\n\nexport function isElementTemplateHydrated(): boolean {\n return hasHydrated;\n}\n\nexport function resetElementTemplateCommitState(): void {\n hasHydrated = false;\n resetElementTemplateRenderScope();\n resetGlobalCommitContext();\n}\n\nexport function scheduleElementTemplateRemovedSubtreeCleanup(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n): void {\n if (removedSubtreesAwaitingTeardown.length === 0) {\n return;\n }\n const timer = setTimeout(() => {\n scheduledRemovedSubtreeCleanupTimers.delete(timer);\n for (const root of removedSubtreesAwaitingTeardown) {\n root.releaseDetachedSubtreeFromManager();\n }\n }, 10000);\n scheduledRemovedSubtreeCleanupTimers.add(timer);\n}\n\nexport function cancelElementTemplateRemovedSubtreeCleanup(): void {\n for (const timer of scheduledRemovedSubtreeCleanupTimers) {\n clearTimeout(timer);\n }\n scheduledRemovedSubtreeCleanupTimers.clear();\n}\n\nfunction cleanupFailedElementTemplateCommit(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n delayedRunOnMainThreadPayload: readonly { resolveId: number }[] | undefined,\n): void {\n dropDelayedRunOnMainThreadReturnIds(delayedRunOnMainThreadPayload);\n clearPendingRefs();\n resetGlobalCommitContext();\n setPipeline(undefined);\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nfunction flushElementTemplateCommitChanges(): void {\n const hasNativeOps = globalCommitContext.ops.length > 0;\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const hasUpdatePayload = hasNativeOps\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasDelayedRunOnMainThread;\n const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];\n if (hasUpdatePayload) {\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n if (globalPipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;\n }\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n\n if (!hasNativeOps && !hasDelayedRunOnMainThread) {\n globalCommitContext.flushOptions.emptyPatch = true;\n }\n\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n\n let updateEvent: ReturnType<typeof packElementTemplateCommitUpdateEvent>;\n try {\n updateEvent = packElementTemplateCommitUpdateEvent(delayedRunOnMainThreadPayload);\n } catch (error) {\n cleanupFailedElementTemplateCommit(removedSubtreesAwaitingTeardown, delayedRunOnMainThreadPayload);\n throw error;\n }\n\n lynx.getCoreContext().dispatchEvent(updateEvent);\n }\n // When native ops exist, patch first so a newly attached ref observes the\n // committed native state. Ref-only commits still flush through this path.\n flushPendingRefs();\n resetGlobalCommitContext();\n // Match Snapshot's cleanup boundary: start the delayed teardown only\n // after the bridge dispatch, so background JS objects are not torn down\n // before main-thread detach observes the same commit.\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nexport function installElementTemplateCommitHook(): void {\n if (installed) {\n return;\n }\n installed = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {\n if (__BACKGROUND__) {\n clearElementTemplateRenderScope();\n try {\n sendMTRefInitValueToMainThread();\n } catch (error) {\n cleanupFailedElementTemplateCommit(\n takeRemovedSubtreesForPostDispatchTeardown(),\n takeDelayedRunOnMainThreadData(),\n );\n throw error;\n }\n }\n\n if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {\n // User effects can run before ET hydrate arrives, so ordinary refs must be\n // attached on the background commit even though native UI ops are delayed.\n flushPendingRefs();\n } else if (\n __BACKGROUND__ && hasHydrated\n && (\n globalCommitContext.ops.length > 0\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasPendingRefs()\n || delayedRunOnMainThreadData.length > 0\n )\n ) {\n flushElementTemplateCommitChanges();\n }\n\n originalCommit?.(vnode, commitQueue);\n });\n}\n\n/**\n * Restores the commit option replaced by\n * {@link installElementTemplateCommitHook} so tests can clean up the global\n * Preact `options` object. Assumes the matching install was the most recent\n * commit-option replacement; the snapshot and ElementTemplate runtimes are\n * separate entrypoints and never install their commit hooks in the same\n * context.\n */\nexport function uninstallElementTemplateCommitHookForTesting(): void {\n if (!installed) {\n return;\n }\n installed = false;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { render } from 'preact';
|
|
2
2
|
import { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';
|
|
3
3
|
import { resetElementTemplateHydrationListener } from './hydration-listener.js';
|
|
4
|
+
import { resetElementTemplateMainThreadFunctionRuntime } from './main-thread-function.js';
|
|
4
5
|
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
5
|
-
import { withSyncEffectFlush } from '../../
|
|
6
|
+
import { withSyncEffectFlush } from '../../core/sync-effect-flush.js';
|
|
6
7
|
import { clearEventState } from '../prop-adapters/event.js';
|
|
7
8
|
import { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';
|
|
8
9
|
import { __root } from '../runtime/page/root-instance.js';
|
|
9
10
|
import { resetElementTemplateBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
10
|
-
import { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/template/main-thread-function.js';
|
|
11
11
|
export function destroyElementTemplateBackgroundRuntime() {
|
|
12
12
|
resetElementTemplateHydrationListener();
|
|
13
13
|
cancelElementTemplateRemovedSubtreeCleanup();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../../src/element-template/background/destroy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,0CAA0C,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,6CAA6C,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,6CAA6C,EAAE,MAAM,wDAAwD,CAAC;AAEvH,MAAM,UAAU,uCAAuC;IACrD,qCAAqC,EAAE,CAAC;IACxC,0CAA0C,EAAE,CAAC;IAC7C,+BAA+B,EAAE,CAAC;IAElC,IAAI,CAAC;QACH,mBAAmB,CAAC,GAAG,EAAE;YACvB,MAAM,CAAC,IAAI,EAAE,MAAkC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,gFAAgF;QAChF,4DAA4D;QAC5D,gBAAgB,EAAE,CAAC;IACrB,CAAC;YAAS,CAAC;QACT,+BAA+B,EAAE,CAAC;QAClC,6CAA6C,EAAE,CAAC;QAChD,6CAA6C,EAAE,CAAC;QAChD,eAAe,EAAE,CAAC;QAClB,aAAa,EAAE,CAAC;QAChB,wCAAwC,CAAC,KAAK,EAAE,CAAC;IACnD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport type { ContainerNode } from 'preact';\nimport { render } from 'preact';\n\nimport { cancelElementTemplateRemovedSubtreeCleanup, resetElementTemplateCommitState } from './commit-hook.js';\nimport { resetElementTemplateHydrationListener } from './hydration-listener.js';\nimport { resetElementTemplateMainThreadFunctionRuntime } from './main-thread-function.js';\nimport { backgroundElementTemplateInstanceManager } from './manager.js';\nimport { withSyncEffectFlush } from '../../core/sync-effect-flush.js';\nimport { clearEventState } from '../prop-adapters/event.js';\nimport { clearRefState, flushPendingRefs } from '../prop-adapters/ref.js';\nimport { __root } from '../runtime/page/root-instance.js';\nimport { resetElementTemplateBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\n\nexport function destroyElementTemplateBackgroundRuntime(): void {\n resetElementTemplateHydrationListener();\n cancelElementTemplateRemovedSubtreeCleanup();\n resetElementTemplateCommitState();\n\n try {\n withSyncEffectFlush(() => {\n render(null, __root as unknown as ContainerNode);\n });\n // Run user cleanup before dropping the backend side tables; after clearRefState\n // the raw ref ownership needed to detach callbacks is gone.\n flushPendingRefs();\n } finally {\n resetElementTemplateCommitState();\n resetElementTemplateBackgroundFunctionRuntime();\n resetElementTemplateMainThreadFunctionRuntime();\n clearEventState();\n clearRefState();\n backgroundElementTemplateInstanceManager.clear();\n }\n}\n"]}
|
|
@@ -5,21 +5,16 @@ import { getAttributeSlotUpdateOp } from './attr-slots.js';
|
|
|
5
5
|
import { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } from './commit-context.js';
|
|
6
6
|
import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, BackgroundListElementTemplateInstance, collectMainThreadRefSubtreeHandleIds, getContainingListItem, toUpdateTypedListItemCommand, } from './instance.js';
|
|
7
7
|
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
8
|
+
import { isDirectOrDeepEqual } from '../../core/deep-equal.js';
|
|
8
9
|
import { isMainThreadFunction } from '../../core/main-thread-function.js';
|
|
9
|
-
import { isDirectOrDeepEqual } from '../../utils.js';
|
|
10
10
|
import { hydrationMap } from '../hydration-map.js';
|
|
11
11
|
import { isGestureSlotValue } from '../prop-adapters/gesture.js';
|
|
12
12
|
import { isMainThreadEventPropKey, isSpreadRecord } from '../prop-adapters/spread.js';
|
|
13
13
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
14
14
|
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';
|
|
15
|
-
import { elementTemplateIdentityKey, parseElementTemplateType } from '../protocol/template-type.js';
|
|
15
|
+
import { MAIN_BUNDLE_URL_SENTINEL, elementTemplateIdentityKey, parseElementTemplateType, } from '../protocol/template-type.js';
|
|
16
16
|
import { getMainThreadDynamicAttrSlotKinds } from '../runtime/template/attr-slot-plan.js';
|
|
17
17
|
import { isMTEventNativeWrapper } from '../runtime/template/main-thread-event-ctx.js';
|
|
18
|
-
const MAIN_BUNDLE_URL_SENTINEL = '__Card__';
|
|
19
|
-
const COMPONENT_AT_INDEX_ATTR = 'component-at-index';
|
|
20
|
-
const COMPONENT_AT_INDEXES_ATTR = 'component-at-indexes';
|
|
21
|
-
const ENQUEUE_COMPONENT_ATTR = 'enqueue-component';
|
|
22
|
-
const UPDATE_LIST_INFO_ATTR = 'update-list-info';
|
|
23
18
|
export function hydrateRootChildrenIntoContext(serializedChildren, root) {
|
|
24
19
|
try {
|
|
25
20
|
return hydrateChildListIntoContext(ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, serializedChildren, root.childNodes);
|
|
@@ -27,8 +22,10 @@ export function hydrateRootChildrenIntoContext(serializedChildren, root) {
|
|
|
27
22
|
finally {
|
|
28
23
|
// Template identities only need caching for this synchronous hydration pass.
|
|
29
24
|
backgroundHydrateKeys.clear();
|
|
25
|
+
hydratedListItemsNeedingSubtreeSync.clear();
|
|
30
26
|
}
|
|
31
27
|
}
|
|
28
|
+
const hydratedListItemsNeedingSubtreeSync = new Set();
|
|
32
29
|
function isSerializedCompiledNode(serialized) {
|
|
33
30
|
return typeof serialized.templateKey === 'string';
|
|
34
31
|
}
|
|
@@ -94,6 +91,8 @@ function hydrateInstance(serialized, instance) {
|
|
|
94
91
|
lynx.reportError(new Error(`ElementTemplate hydrate does not support serialized typed node '${serialized.tag}'.`));
|
|
95
92
|
return false;
|
|
96
93
|
}
|
|
94
|
+
// Match List items separately, then reuse the shared structural patch
|
|
95
|
+
// emitter.
|
|
97
96
|
return hydrateListInstance(serialized, instance);
|
|
98
97
|
}
|
|
99
98
|
function hydrateCompiledInstance(serialized, instance) {
|
|
@@ -150,54 +149,174 @@ function normalizeSerializedBundleUrl(bundleUrl) {
|
|
|
150
149
|
return bundleUrl === undefined || bundleUrl === MAIN_BUNDLE_URL_SENTINEL ? null : bundleUrl;
|
|
151
150
|
}
|
|
152
151
|
function getSerializedTypedListChildren(serialized) {
|
|
153
|
-
|
|
152
|
+
// Native List stores logical items in childSlots[0].
|
|
153
|
+
// A missing or empty slot 0 represents an empty List.
|
|
154
|
+
return serialized.childSlots?.[0] ?? [];
|
|
155
|
+
}
|
|
156
|
+
function getSerializedListItemPlatformInfo(serialized) {
|
|
157
|
+
const options = serialized.options;
|
|
158
|
+
if (!options || !('__listItemPlatformInfo' in options)) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
const platformInfo = options['__listItemPlatformInfo'];
|
|
162
|
+
// Require an attribute object for platform info.
|
|
163
|
+
if (platformInfo == null
|
|
164
|
+
|| typeof platformInfo !== 'object'
|
|
165
|
+
|| Array.isArray(platformInfo)) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
// Reuse the ET serializable attribute type and preserve the original object.
|
|
169
|
+
return platformInfo;
|
|
170
|
+
}
|
|
171
|
+
function getListItemHydrateKey(platformInfo) {
|
|
172
|
+
const itemKey = platformInfo?.['item-key'];
|
|
173
|
+
// Nullish item keys use the unkeyed group. Empty strings are valid keys.
|
|
174
|
+
// Normalize provided keys to strings to preserve RL3's object-key grouping.
|
|
175
|
+
return itemKey == null ? undefined : String(itemKey);
|
|
154
176
|
}
|
|
155
177
|
function hydrateListInstance(serialized, instance) {
|
|
156
|
-
|
|
157
|
-
lynx.reportError(new Error('ElementTemplate hydrate typed list does not support childSlots.'));
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
const listChildren = getSerializedTypedListChildren(serialized);
|
|
161
|
-
if (__DEV__ && !Array.isArray(listChildren)) {
|
|
162
|
-
lynx.reportError(new Error('ElementTemplate hydrate typed list requires options.listChildren.'));
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
178
|
+
const serializedChildren = getSerializedTypedListChildren(serialized);
|
|
165
179
|
const backgroundChildren = instance.childNodes;
|
|
180
|
+
if (__DEV__) {
|
|
181
|
+
// Both sides store logical List items in slot 0.
|
|
182
|
+
const hasUnsupportedSerializedSlot = serialized.childSlots?.some((children, slotIndex) => slotIndex !== 0 && (children?.length ?? 0) > 0);
|
|
183
|
+
// A child's __slotIndex identifies its logical slot.
|
|
184
|
+
const hasUnsupportedBackgroundSlot = backgroundChildren.some(child => child.__slotIndex !== 0);
|
|
185
|
+
if (hasUnsupportedSerializedSlot || hasUnsupportedBackgroundSlot) {
|
|
186
|
+
lynx.reportError(new Error('ElementTemplate hydrate typed list only supports logical slot 0.'));
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
166
190
|
const handleId = serialized.uid;
|
|
167
191
|
if (!bindHydrationHandleId(instance, handleId, serialized.tag)) {
|
|
168
192
|
return false;
|
|
169
193
|
}
|
|
170
194
|
instance.prepareAttributeSlotsForHydration();
|
|
171
|
-
hydrateAttributeSlots(serialized.tag, handleId, [
|
|
172
|
-
|
|
195
|
+
hydrateAttributeSlots(serialized.tag, handleId, [serialized.attributes ?? null], instance.attributeSlots);
|
|
196
|
+
// The List UID and attributes are hydrated before this empty-children fast
|
|
197
|
+
// path.
|
|
198
|
+
if (serializedChildren.length === 0 && backgroundChildren.length === 0) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
// Hydrate matched items recursively and preserve insertion, removal, and move
|
|
202
|
+
// distinctions.
|
|
203
|
+
const listDiff = hydrateMatchingListChildrenAndDiff(handleId, serializedChildren, backgroundChildren);
|
|
173
204
|
if (listDiff === null) {
|
|
174
205
|
return false;
|
|
175
206
|
}
|
|
176
|
-
|
|
207
|
+
// Reuse child-slot structural commands so native records List changes in slot
|
|
208
|
+
// 0.
|
|
209
|
+
if (!emitHydrateChildrenDiff(handleId, 0, serializedChildren, listDiff)) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
for (let index = 0; index < backgroundChildren.length; index += 1) {
|
|
213
|
+
const child = backgroundChildren[index];
|
|
214
|
+
if (!hydratedListItemsNeedingSubtreeSync.delete(child)) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
globalCommitContext.ops.push(ElementTemplateUpdateOps.updateTypedListItem, handleId, toUpdateTypedListItemCommand(child, false));
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
177
220
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
|
|
221
|
+
function hydrateMatchingListChildrenAndDiff(listHandleId, serializedChildren, backgroundChildren) {
|
|
222
|
+
const result = {
|
|
223
|
+
insertions: {},
|
|
224
|
+
insertionCount: 0,
|
|
225
|
+
removals: [],
|
|
226
|
+
moves: {},
|
|
227
|
+
};
|
|
228
|
+
// Explicit item-key values are unique on each side, so each key maps to one
|
|
229
|
+
// old node.
|
|
230
|
+
const serializedByItemKey = new Map();
|
|
231
|
+
// Group unkeyed nodes by template identity.
|
|
232
|
+
// Preserve their old order and consume candidates with a per-template cursor.
|
|
233
|
+
const serializedByTemplateKey = new Map();
|
|
234
|
+
// Track old positions to detect moves.
|
|
235
|
+
// Remove matched records so the remaining entries identify deleted nodes.
|
|
236
|
+
const remainingOldIndices = new Map();
|
|
237
|
+
for (let oldIndex = 0; oldIndex < serializedChildren.length; oldIndex++) {
|
|
238
|
+
const serialized = serializedChildren[oldIndex];
|
|
239
|
+
const itemKey = getListItemHydrateKey(getSerializedListItemPlatformInfo(serialized));
|
|
240
|
+
remainingOldIndices.set(serialized, oldIndex);
|
|
241
|
+
if (itemKey !== undefined) {
|
|
242
|
+
// Index keyed nodes for matching by item-key.
|
|
243
|
+
serializedByItemKey.set(itemKey, serialized);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
// Queue unkeyed nodes by normalized template identity.
|
|
247
|
+
const templateKey = getSerializedNodeHydrateKey(serialized);
|
|
248
|
+
let group = serializedByTemplateKey.get(templateKey);
|
|
249
|
+
if (group === undefined) {
|
|
250
|
+
group = { nodes: [], cursor: 0 };
|
|
251
|
+
serializedByTemplateKey.set(templateKey, group);
|
|
252
|
+
}
|
|
253
|
+
group.nodes.push(serialized);
|
|
181
254
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
255
|
+
let lastPlacedIndex = 0;
|
|
256
|
+
for (let newIndex = 0; newIndex < backgroundChildren.length; newIndex++) {
|
|
257
|
+
const instance = backgroundChildren[newIndex];
|
|
258
|
+
const itemKey = getListItemHydrateKey(instance.getListItemPlatformInfo());
|
|
259
|
+
const templateKey = getBackgroundNodeHydrateKey(instance.type);
|
|
260
|
+
let serialized;
|
|
261
|
+
if (itemKey === undefined) {
|
|
262
|
+
const group = serializedByTemplateKey.get(templateKey);
|
|
263
|
+
serialized = group?.nodes[group.cursor];
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
serialized = serializedByItemKey.get(itemKey);
|
|
267
|
+
}
|
|
268
|
+
if (serialized === undefined || getSerializedNodeHydrateKey(serialized) !== templateKey) {
|
|
269
|
+
// Record an insertion when no compatible candidate exists.
|
|
270
|
+
result.insertions[newIndex] = instance;
|
|
271
|
+
result.insertionCount += 1;
|
|
272
|
+
// Keep the old candidate pending removal.
|
|
195
273
|
continue;
|
|
196
274
|
}
|
|
197
|
-
|
|
198
|
-
|
|
275
|
+
if (!hydrateInstance(serialized, instance)) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
// The item now uses its native UID.
|
|
279
|
+
// Emit updateTypedListItem when platform info changes.
|
|
280
|
+
hydrateListItemPlatformInfo(listHandleId, serialized, instance);
|
|
281
|
+
// Remove the matched node from the pending-removal map.
|
|
282
|
+
const oldIndex = remainingOldIndices.get(serialized);
|
|
283
|
+
remainingOldIndices.delete(serialized);
|
|
284
|
+
if (itemKey === undefined) {
|
|
285
|
+
serializedByTemplateKey.get(templateKey).cursor += 1;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
serializedByItemKey.delete(itemKey);
|
|
289
|
+
}
|
|
290
|
+
if (oldIndex < lastPlacedIndex) {
|
|
291
|
+
// Record a move for the retained item.
|
|
292
|
+
result.moves[oldIndex] = {
|
|
293
|
+
toIndex: newIndex,
|
|
294
|
+
instance,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
lastPlacedIndex = oldIndex;
|
|
299
|
+
}
|
|
199
300
|
}
|
|
200
|
-
|
|
301
|
+
// Remove the old nodes left unmatched.
|
|
302
|
+
// The Map preserves old order, so remaining indexes are already sorted.
|
|
303
|
+
for (const oldIndex of remainingOldIndices.values()) {
|
|
304
|
+
result.removals.push(oldIndex);
|
|
305
|
+
}
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
function hydrateListItemPlatformInfo(listHandleId, serialized, instance) {
|
|
309
|
+
const before = getSerializedListItemPlatformInfo(serialized) ?? {};
|
|
310
|
+
const after = instance.getListItemPlatformInfo();
|
|
311
|
+
if (isDirectOrDeepEqual(before, after)) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
globalCommitContext.ops.push(ElementTemplateUpdateOps.updateTypedListItem, listHandleId, {
|
|
315
|
+
__etHandleRef: serialized.uid,
|
|
316
|
+
type: instance.type,
|
|
317
|
+
platformInfo: after,
|
|
318
|
+
subtreeHandleIds: null,
|
|
319
|
+
});
|
|
201
320
|
}
|
|
202
321
|
function hydrateChildListIntoContext(targetHandleId, slotId, serializedChildren, backgroundChildren) {
|
|
203
322
|
if (backgroundChildren.length === 0) {
|
|
@@ -235,6 +354,11 @@ function hydrateChildListIntoContext(targetHandleId, slotId, serializedChildren,
|
|
|
235
354
|
}
|
|
236
355
|
// Hydrate emits patches directly here. Replaying against serialized order
|
|
237
356
|
// keeps insert targets in the main-thread slot without reshaping background.
|
|
357
|
+
return emitHydrateChildrenDiff(targetHandleId, slotId, serializedChildren, listDiff);
|
|
358
|
+
}
|
|
359
|
+
function emitHydrateChildrenDiff(targetHandleId, slotId, serializedChildren, listDiff) {
|
|
360
|
+
// serializedChildren supplies the old order and insertion anchors.
|
|
361
|
+
// listDiff describes the target changes.
|
|
238
362
|
const removalIndexes = new Set(listDiff.removals);
|
|
239
363
|
const { insertions, moves } = listDiff;
|
|
240
364
|
const movesWaitingForInsertionPoint = new Map();
|
|
@@ -268,9 +392,14 @@ function hydrateChildListIntoContext(targetHandleId, slotId, serializedChildren,
|
|
|
268
392
|
}
|
|
269
393
|
else if (insertions[newIndex] !== undefined) {
|
|
270
394
|
const insertedChild = insertions[newIndex];
|
|
395
|
+
const containingListItem = getContainingListItem(insertedChild);
|
|
396
|
+
const subtreeHandleIds = collectMainThreadRefSubtreeHandleIds(insertedChild);
|
|
271
397
|
keepCurrentSerializedChild = true;
|
|
272
398
|
emitCreateSubtree(insertedChild);
|
|
273
|
-
globalCommitContext.ops.push(ElementTemplateUpdateOps.insertNode, targetHandleId, slotId, insertedChild.instanceId, beforeChildId,
|
|
399
|
+
globalCommitContext.ops.push(ElementTemplateUpdateOps.insertNode, targetHandleId, slotId, insertedChild.instanceId, beforeChildId, containingListItem ? null : subtreeHandleIds);
|
|
400
|
+
if (containingListItem && subtreeHandleIds !== null) {
|
|
401
|
+
hydratedListItemsNeedingSubtreeSync.add(containingListItem);
|
|
402
|
+
}
|
|
274
403
|
insertOrMovePatchesWaitingForInsertionPoint -= 1;
|
|
275
404
|
}
|
|
276
405
|
newIndex += 1;
|
|
@@ -321,15 +450,14 @@ function collectRemovableSerializedSubtreeHandleIdsInto(serialized, handles) {
|
|
|
321
450
|
return false;
|
|
322
451
|
}
|
|
323
452
|
const serializedList = serialized;
|
|
324
|
-
|
|
325
|
-
|
|
453
|
+
// Collect all logical item UIDs from slot 0 when removing a List or its
|
|
454
|
+
// ancestor.
|
|
455
|
+
if (__DEV__
|
|
456
|
+
&& serializedList.childSlots?.some((children, slotIndex) => slotIndex !== 0 && (children?.length ?? 0) > 0)) {
|
|
457
|
+
lynx.reportError(new Error('ElementTemplate hydrate typed list only supports logical slot 0.'));
|
|
326
458
|
return false;
|
|
327
459
|
}
|
|
328
460
|
const listChildren = getSerializedTypedListChildren(serializedList);
|
|
329
|
-
if (__DEV__ && !Array.isArray(listChildren)) {
|
|
330
|
-
lynx.reportError(new Error('ElementTemplate hydrate typed list requires options.listChildren.'));
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
461
|
for (const child of listChildren) {
|
|
334
462
|
if (!collectRemovableSerializedSubtreeHandleIdsInto(child, handles)) {
|
|
335
463
|
return false;
|
|
@@ -348,47 +476,6 @@ function getRemovableSerializedHandleId(serialized) {
|
|
|
348
476
|
}
|
|
349
477
|
return handleId;
|
|
350
478
|
}
|
|
351
|
-
function emitHydrateTypedListReconciliation(instance, serializedChildren, backgroundChildren, listDiff) {
|
|
352
|
-
const movedOldIndexes = Object.keys(listDiff.moves).map(Number);
|
|
353
|
-
const removalIndexes = listDiff.removals.concat(movedOldIndexes).sort((a, b) => a - b);
|
|
354
|
-
for (let index = 0; index < removalIndexes.length; index += 1) {
|
|
355
|
-
const oldIndex = removalIndexes[index];
|
|
356
|
-
const serialized = serializedChildren[oldIndex];
|
|
357
|
-
let itemId;
|
|
358
|
-
const removedSubtreeHandleIds = [];
|
|
359
|
-
if (listDiff.moves[oldIndex] === undefined) {
|
|
360
|
-
if (!collectRemovableSerializedSubtreeHandleIdsInto(serialized, removedSubtreeHandleIds)) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
itemId = removedSubtreeHandleIds[0];
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
itemId = serialized.uid;
|
|
367
|
-
}
|
|
368
|
-
globalCommitContext.ops.push(ElementTemplateUpdateOps.removeTypedListItem, instance.instanceId, itemId, removedSubtreeHandleIds);
|
|
369
|
-
}
|
|
370
|
-
const insertedIndexes = Object.keys(listDiff.insertions).map(Number);
|
|
371
|
-
let movedToIndexes = null;
|
|
372
|
-
for (let index = 0; index < movedOldIndexes.length; index += 1) {
|
|
373
|
-
const toIndex = listDiff.moves[movedOldIndexes[index]].toIndex;
|
|
374
|
-
insertedIndexes.push(toIndex);
|
|
375
|
-
(movedToIndexes ??= new Set()).add(toIndex);
|
|
376
|
-
}
|
|
377
|
-
insertedIndexes.sort((a, b) => b - a);
|
|
378
|
-
for (let index = 0; index < insertedIndexes.length; index += 1) {
|
|
379
|
-
const insertedIndex = insertedIndexes[index];
|
|
380
|
-
const child = backgroundChildren[insertedIndex];
|
|
381
|
-
emitCreateSubtree(child);
|
|
382
|
-
globalCommitContext.ops.push(ElementTemplateUpdateOps.insertTypedListItem, instance.instanceId, toUpdateTypedListItemCommand(child), backgroundChildren[insertedIndex + 1]?.instanceId ?? 0);
|
|
383
|
-
}
|
|
384
|
-
for (let index = 0; index < backgroundChildren.length; index += 1) {
|
|
385
|
-
if (listDiff.insertions[index] || movedToIndexes?.has(index)) {
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
globalCommitContext.ops.push(ElementTemplateUpdateOps.updateTypedListItem, instance.instanceId, toUpdateTypedListItemCommand(backgroundChildren[index]));
|
|
389
|
-
}
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
479
|
function emitCreateSubtree(node) {
|
|
393
480
|
// Linked-list walk: slot grouping would be discarded since we recurse into
|
|
394
481
|
// every child regardless of slot. `emitCreate` does its own single-walk
|