@lynx-js/react 0.129.3 → 0.129.4
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 +16 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -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/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/lynx/performance.test.ts +1 -0
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +1 -0
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +10 -15
- package/runtime/__test__/element-template/native/reload.test.ts +4 -7
- 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/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 +3 -4
- 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 +32 -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 +1 -0
- 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/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 +1 -1
- package/runtime/__test__/snapshot/lifecycle/transfer.mts.test.jsx +194 -0
- package/runtime/__test__/snapshot/lifecycle/transfer.test.jsx +210 -0
- package/runtime/__test__/snapshot/list.test.jsx +109 -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 +5 -0
- package/runtime/__test__/snapshot/utils/globals.js +1 -0
- package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +22 -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/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/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/{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-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.js +1 -1
- 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-hook.js +1 -1
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +1 -1
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +173 -85
- package/runtime/lib/element-template/background/hydrate.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/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/native/index.js +2 -2
- package/runtime/lib/element-template/native/index.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 +0 -4
- 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 +42 -119
- 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 +2 -2
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +1 -6
- 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 +1 -0
- 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 +1 -1
- 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 +1 -1
- 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/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 +15 -0
- package/runtime/lib/snapshot/transfer.js +343 -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/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 +2 -4
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js +42 -44
- 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/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/{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/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 +1 -1
- package/runtime/src/element-template/background/attr-slots.ts +2 -2
- package/runtime/src/element-template/background/commit-hook.ts +1 -1
- package/runtime/src/element-template/background/destroy.ts +1 -1
- package/runtime/src/element-template/background/hydrate.ts +229 -119
- package/runtime/src/element-template/background/instance.ts +82 -82
- 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/native/index.ts +2 -2
- package/runtime/src/element-template/native/patch-listener.ts +6 -7
- package/runtime/src/element-template/native/reload-main-thread.ts +0 -4
- 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 +59 -163
- 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 +3 -2
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +1 -6
- 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 +2 -0
- 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 +1 -1
- 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 +1 -1
- package/runtime/src/snapshot/list/list.ts +12 -3
- 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 +379 -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/observers.ts +9 -1
- package/runtime/src/worklet-runtime/bindings/types.ts +1 -0
- package/runtime/src/worklet-runtime/delayWorkletEvent.ts +49 -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/workletRef.ts +63 -62
- package/runtime/src/worklet-runtime/workletRuntime.ts +10 -10
- package/testing-library/.turbo/turbo-build.log +10 -10
- 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__/list.test.jsx +52 -0
- package/testing-library/src/__tests__/worklet.test.jsx +81 -0
- 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 +64 -64
- 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 +0 -19
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +85 -85
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +213 -192
- 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/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/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/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/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/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/src/{shared → core}/attribute-name.ts +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { createElement, render } from 'preact';
|
|
5
|
+
import { getReloadVersion } from '../core/reload-version.js';
|
|
6
|
+
import { __root, enableTransferMode, warnRootRenderOnTransferPage } from '../root.js';
|
|
7
|
+
import { CHILDREN, PARENT } from '../shared/render-constants.js';
|
|
8
|
+
import { genCommitTaskId, replaceCommitHook } from './lifecycle/patch/commit.js';
|
|
9
|
+
import { updateMainThread } from './lifecycle/patch/updateMainThread.js';
|
|
10
|
+
import { __pendingListUpdates } from './list/pendingListUpdates.js';
|
|
11
|
+
import { enablePublishEvent } from './lynx/tt.js';
|
|
12
|
+
import { hydrate as hydrateMainThread } from './renderToOpcodes/hydrate.js';
|
|
13
|
+
import { render as renderFirstFrame } from './renderToOpcodes/index.js';
|
|
14
|
+
import { BackgroundSnapshotInstance, hydrate } from './snapshot/backgroundSnapshot.js';
|
|
15
|
+
import { __page, __pageId, setupPage } from './snapshot/definition.js';
|
|
16
|
+
import { SnapshotInstance } from './snapshot/snapshot.js';
|
|
17
|
+
import { snapshotInstanceManager } from './snapshot/snapshotInstanceManager.js';
|
|
18
|
+
function forgetIds(node) {
|
|
19
|
+
snapshotInstanceManager.values.delete(node.__id);
|
|
20
|
+
node.childNodes.forEach(child => forgetIds(child));
|
|
21
|
+
}
|
|
22
|
+
const providers = new Map();
|
|
23
|
+
let initialized = false;
|
|
24
|
+
function initialize() {
|
|
25
|
+
const mts = typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__;
|
|
26
|
+
const instances = new Map();
|
|
27
|
+
const frames = new Map();
|
|
28
|
+
const disposed = new Set();
|
|
29
|
+
const owners = new WeakMap();
|
|
30
|
+
const removers = [];
|
|
31
|
+
const pendingCreates = [];
|
|
32
|
+
let pageReady = !mts;
|
|
33
|
+
let active;
|
|
34
|
+
function send(type, data) {
|
|
35
|
+
const target = mts ? lynx.getJSContext() : lynx.getCoreContext();
|
|
36
|
+
target.dispatchEvent({ type, data: JSON.stringify(data) });
|
|
37
|
+
}
|
|
38
|
+
function listen(target, type, listener) {
|
|
39
|
+
const callback = (event) => {
|
|
40
|
+
try {
|
|
41
|
+
listener((typeof event.data === 'string' ? JSON.parse(event.data) : event.data));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
lynx.reportError(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
target.addEventListener(type, callback);
|
|
48
|
+
removers.push(() => target.removeEventListener(type, callback));
|
|
49
|
+
}
|
|
50
|
+
function withInstance(instance, fn) {
|
|
51
|
+
const previous = active;
|
|
52
|
+
active = instance;
|
|
53
|
+
try {
|
|
54
|
+
return fn();
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
active = previous;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function findOwner(vnode) {
|
|
61
|
+
if (active)
|
|
62
|
+
return active;
|
|
63
|
+
for (let node = vnode; node; node = node[PARENT]) {
|
|
64
|
+
const owner = owners.get(node);
|
|
65
|
+
if (owner)
|
|
66
|
+
return owner;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function renderBackground(instance) {
|
|
71
|
+
const container = instance.background;
|
|
72
|
+
withInstance(instance, () => render(createElement(instance.Component, instance.props), container));
|
|
73
|
+
const vnode = container[CHILDREN];
|
|
74
|
+
if (vnode)
|
|
75
|
+
owners.set(vnode, instance);
|
|
76
|
+
}
|
|
77
|
+
/** Renders the first frame; later frames take over the elements of the previous one, like a template reload. */
|
|
78
|
+
function renderMain(instance) {
|
|
79
|
+
const previous = instance.main;
|
|
80
|
+
const root = new SnapshotInstance('root');
|
|
81
|
+
if (!previous) {
|
|
82
|
+
root.__elements = [instance.element];
|
|
83
|
+
root.__element_root = instance.element;
|
|
84
|
+
instance.main = root;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
withInstance(instance, () => {
|
|
88
|
+
renderFirstFrame(createElement(instance.Component, instance.props), undefined, root);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (previous)
|
|
93
|
+
forgetIds(root);
|
|
94
|
+
dispose(instance.init);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
if (previous) {
|
|
98
|
+
hydrateMainThread(previous, root, { skipUnRef: true });
|
|
99
|
+
forgetIds(previous);
|
|
100
|
+
instance.main = root;
|
|
101
|
+
}
|
|
102
|
+
__pendingListUpdates.flush();
|
|
103
|
+
__FlushElementTree(__page, {});
|
|
104
|
+
send('__TransferFirstFrame', { transferId: instance.init.transferId, snapshot: JSON.stringify(root) });
|
|
105
|
+
}
|
|
106
|
+
/** Releases the commits of an instance that will never be applied. */
|
|
107
|
+
function release(instance) {
|
|
108
|
+
instance.inFlight?.finish();
|
|
109
|
+
instance.inFlight = undefined;
|
|
110
|
+
instance.queue.forEach(item => item.finish());
|
|
111
|
+
instance.queue.length = 0;
|
|
112
|
+
}
|
|
113
|
+
function pump(instance) {
|
|
114
|
+
if (instance.inFlight || instance.phase === 'disposed')
|
|
115
|
+
return;
|
|
116
|
+
instance.inFlight = instance.queue.shift();
|
|
117
|
+
if (instance.inFlight)
|
|
118
|
+
send('__TransferCommit', instance.inFlight.packet);
|
|
119
|
+
}
|
|
120
|
+
function enqueue(instance, kind, patchList, patchOptions, finish) {
|
|
121
|
+
const packet = {
|
|
122
|
+
transferId: instance.init.transferId,
|
|
123
|
+
version: instance.version,
|
|
124
|
+
seq: ++instance.seq,
|
|
125
|
+
kind,
|
|
126
|
+
patchList,
|
|
127
|
+
patchOptions,
|
|
128
|
+
};
|
|
129
|
+
instance.queue.push({ packet, finish });
|
|
130
|
+
pump(instance);
|
|
131
|
+
}
|
|
132
|
+
function acceptFrame(frame) {
|
|
133
|
+
if (disposed.has(frame.transferId))
|
|
134
|
+
return;
|
|
135
|
+
const instance = instances.get(frame.transferId);
|
|
136
|
+
if (!instance) {
|
|
137
|
+
frames.set(frame.transferId, frame);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (instance.phase !== 'waiting')
|
|
141
|
+
return;
|
|
142
|
+
instance.phase = 'hydrating';
|
|
143
|
+
const serialized = JSON.parse(frame.snapshot);
|
|
144
|
+
const snapshotPatch = withInstance(instance, () => hydrate(serialized, instance.background));
|
|
145
|
+
enqueue(instance, 'hydrate', { patchList: [{ id: genCommitTaskId(), snapshotPatch }] }, { reloadVersion: getReloadVersion(), isHydration: true }, () => {
|
|
146
|
+
if (instance.phase === 'hydrating')
|
|
147
|
+
instance.phase = 'live';
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function create(init) {
|
|
151
|
+
if (disposed.has(init.transferId) || instances.has(init.transferId))
|
|
152
|
+
return;
|
|
153
|
+
if (!pageReady) {
|
|
154
|
+
pendingCreates.push(init);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const provider = providers.get(init.componentName);
|
|
158
|
+
if (!provider)
|
|
159
|
+
throw new Error(`Unknown transfer component: ${init.componentName}`);
|
|
160
|
+
const instance = {
|
|
161
|
+
init,
|
|
162
|
+
Component: provider({ transferId: init.transferId }),
|
|
163
|
+
props: init.initialProps,
|
|
164
|
+
phase: 'waiting',
|
|
165
|
+
version: 0,
|
|
166
|
+
seq: 0,
|
|
167
|
+
queue: [],
|
|
168
|
+
};
|
|
169
|
+
instances.set(init.transferId, instance);
|
|
170
|
+
if (mts) {
|
|
171
|
+
const element = instance.element = __CreateElement('transfer-view', __pageId);
|
|
172
|
+
__SetAttribute(element, 'transfer-id', init.transferId);
|
|
173
|
+
__AppendElement(__page, element);
|
|
174
|
+
send('__CreateTransfer', init);
|
|
175
|
+
renderMain(instance);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
instance.background = new BackgroundSnapshotInstance('root');
|
|
179
|
+
renderBackground(instance);
|
|
180
|
+
const frame = frames.get(init.transferId);
|
|
181
|
+
if (frame) {
|
|
182
|
+
frames.delete(init.transferId);
|
|
183
|
+
acceptFrame(frame);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Re-renders both threads with the new props and re-syncs the first frame, like a template reload. */
|
|
188
|
+
function setProps(update) {
|
|
189
|
+
const pending = pendingCreates.find(init => init.transferId === update.transferId);
|
|
190
|
+
if (pending) {
|
|
191
|
+
pending.initialProps = update.props;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const instance = instances.get(update.transferId);
|
|
195
|
+
if (!instance)
|
|
196
|
+
return;
|
|
197
|
+
instance.props = update.props;
|
|
198
|
+
instance.version++;
|
|
199
|
+
instance.seq = 0;
|
|
200
|
+
if (mts) {
|
|
201
|
+
send('__SetTransferProps', update);
|
|
202
|
+
renderMain(instance);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// Remount like a template reload: state resets and commits wait for the new first frame.
|
|
206
|
+
instance.phase = 'waiting';
|
|
207
|
+
release(instance);
|
|
208
|
+
withInstance(instance, () => render(null, instance.background));
|
|
209
|
+
renderBackground(instance);
|
|
210
|
+
}
|
|
211
|
+
function dispose(scope, notify = true) {
|
|
212
|
+
if (disposed.has(scope.transferId))
|
|
213
|
+
return;
|
|
214
|
+
disposed.add(scope.transferId);
|
|
215
|
+
frames.delete(scope.transferId);
|
|
216
|
+
const instance = instances.get(scope.transferId);
|
|
217
|
+
if (instance) {
|
|
218
|
+
instance.phase = 'disposed';
|
|
219
|
+
release(instance);
|
|
220
|
+
if (instance.main) {
|
|
221
|
+
forgetIds(instance.main);
|
|
222
|
+
instance.main.removeChildren();
|
|
223
|
+
__RemoveElement(__page, instance.element);
|
|
224
|
+
__FlushElementTree(__page, {});
|
|
225
|
+
}
|
|
226
|
+
else if (instance.background) {
|
|
227
|
+
withInstance(instance, () => render(null, instance.background));
|
|
228
|
+
instance.background.tearDown();
|
|
229
|
+
}
|
|
230
|
+
instances.delete(scope.transferId);
|
|
231
|
+
}
|
|
232
|
+
if (notify)
|
|
233
|
+
send(mts ? '__DestroyTransfer' : '__TransferDisposed', { transferId: scope.transferId });
|
|
234
|
+
}
|
|
235
|
+
// Business code may call `root.render` before registering; the page root never renders on transfer pages.
|
|
236
|
+
if (__root.__jsx !== undefined) {
|
|
237
|
+
warnRootRenderOnTransferPage();
|
|
238
|
+
__root.__jsx = undefined;
|
|
239
|
+
if (!mts)
|
|
240
|
+
render(null, __root);
|
|
241
|
+
}
|
|
242
|
+
enableTransferMode();
|
|
243
|
+
if (mts) {
|
|
244
|
+
listen(lynx.getEngine(), '__RenderPage', ([initData]) => {
|
|
245
|
+
lynx.__initData = initData ?? {};
|
|
246
|
+
setupPage(__CreatePage('0', 0));
|
|
247
|
+
__root.ensureElements();
|
|
248
|
+
__FlushElementTree(__page, {});
|
|
249
|
+
pageReady = true;
|
|
250
|
+
pendingCreates.splice(0).forEach(init => {
|
|
251
|
+
try {
|
|
252
|
+
create(init);
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
lynx.reportError(error);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
const native = lynx.getNative();
|
|
260
|
+
listen(native, '__CreateTransfer', create);
|
|
261
|
+
listen(native, '__SetTransferProps', setProps);
|
|
262
|
+
listen(native, '__DestroyTransfer', scope => dispose(scope));
|
|
263
|
+
listen(lynx.getJSContext(), '__TransferCommit', packet => {
|
|
264
|
+
const instance = instances.get(packet.transferId);
|
|
265
|
+
// Commits rendered before a props update belong to a replaced first frame.
|
|
266
|
+
if (instance && packet.version !== instance.version)
|
|
267
|
+
return;
|
|
268
|
+
let status = 'disposed';
|
|
269
|
+
if (instance && instance.phase !== 'disposed') {
|
|
270
|
+
try {
|
|
271
|
+
if (packet.seq !== instance.seq + 1)
|
|
272
|
+
throw new Error('Transfer commit sequence mismatch');
|
|
273
|
+
updateMainThread({ data: JSON.stringify(packet.patchList), patchOptions: packet.patchOptions });
|
|
274
|
+
instance.seq = packet.seq;
|
|
275
|
+
status = 'applied';
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
status = 'failed';
|
|
279
|
+
lynx.reportError(error);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const { transferId, version, seq } = packet;
|
|
283
|
+
send('__TransferCommitResult', { transferId, version, seq, status });
|
|
284
|
+
});
|
|
285
|
+
listen(lynx.getJSContext(), '__TransferDisposed', scope => dispose(scope, false));
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
// Background commits belong to transfer instances and travel through scoped events.
|
|
289
|
+
replaceCommitHook((vnode, patchList, patchOptions, finish) => {
|
|
290
|
+
const instance = findOwner(vnode);
|
|
291
|
+
if (!instance) {
|
|
292
|
+
finish();
|
|
293
|
+
lynx.reportError(new Error('Commit rendered outside a transfer instance'));
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (instance.phase === 'waiting' || instance.phase === 'disposed') {
|
|
297
|
+
finish();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
enqueue(instance, 'update', patchList, { ...patchOptions, reloadVersion: getReloadVersion() }, finish);
|
|
301
|
+
});
|
|
302
|
+
// Events of hydrated instances dispatch directly; earlier events have no handler and are dropped.
|
|
303
|
+
enablePublishEvent();
|
|
304
|
+
const core = lynx.getCoreContext();
|
|
305
|
+
listen(core, '__CreateTransfer', create);
|
|
306
|
+
listen(core, '__TransferFirstFrame', acceptFrame);
|
|
307
|
+
listen(core, '__SetTransferProps', setProps);
|
|
308
|
+
listen(core, '__DestroyTransfer', scope => dispose(scope, false));
|
|
309
|
+
listen(core, '__TransferCommitResult', result => {
|
|
310
|
+
const instance = instances.get(result.transferId);
|
|
311
|
+
const item = instance?.inFlight;
|
|
312
|
+
if (!instance || !item || item.packet.version !== result.version || item.packet.seq !== result.seq)
|
|
313
|
+
return;
|
|
314
|
+
instance.inFlight = undefined;
|
|
315
|
+
item.finish();
|
|
316
|
+
if (result.status === 'applied')
|
|
317
|
+
pump(instance);
|
|
318
|
+
else
|
|
319
|
+
dispose(instance.init);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
listen(lynx.getNative(), '__DestroyLifetime', () => {
|
|
323
|
+
instances.forEach(instance => dispose(instance.init, false));
|
|
324
|
+
removers.splice(0).forEach(remove => remove());
|
|
325
|
+
if (!mts)
|
|
326
|
+
replaceCommitHook();
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Registers components that native hosts render as independent transfer instances.
|
|
331
|
+
* Registering the first component turns the page into a transfer page, where `root.render` is ignored.
|
|
332
|
+
* @experimental
|
|
333
|
+
*/
|
|
334
|
+
export const TransferRegistry = {
|
|
335
|
+
registerComponent(componentName, provider) {
|
|
336
|
+
providers.set(componentName, provider);
|
|
337
|
+
if (!initialized) {
|
|
338
|
+
initialized = true;
|
|
339
|
+
initialize();
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
//# sourceMappingURL=transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../src/snapshot/transfer.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,0BAA0B,C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AC,IAAI,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,mBAAmB,EAAE,GAAG,EAAE;QACjD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7D,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG;YAAE,iBAAiB,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,iBAAiB,CAAC,aAAqB,EAAE,QAA2B;QAClE,SAAS,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,IAAI,CAAC;YACnB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;CACF,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 { createElement, render } from 'preact';\nimport type { ComponentType, ContainerNode, VNode } from 'preact';\n\nimport { getReloadVersion } from '../core/reload-version.js';\nimport { __root, enableTransferMode, warnRootRenderOnTransferPage } from '../root.js';\nimport { CHILDREN, PARENT } from '../shared/render-constants.js';\nimport { genCommitTaskId, replaceCommitHook } from './lifecycle/patch/commit.js';\nimport type { PatchList, PatchOptions } from './lifecycle/patch/commit.js';\nimport { updateMainThread } from './lifecycle/patch/updateMainThread.js';\nimport { __pendingListUpdates } from './list/pendingListUpdates.js';\nimport { enablePublishEvent } from './lynx/tt.js';\nimport { hydrate as hydrateMainThread } from './renderToOpcodes/hydrate.js';\nimport { render as renderFirstFrame } from './renderToOpcodes/index.js';\nimport { BackgroundSnapshotInstance, hydrate } from './snapshot/backgroundSnapshot.js';\nimport { __page, __pageId, setupPage } from './snapshot/definition.js';\nimport { SnapshotInstance } from './snapshot/snapshot.js';\nimport { snapshotInstanceManager } from './snapshot/snapshotInstanceManager.js';\nimport type { SerializedSnapshotInstance } from './snapshot/types.js';\n\ntype TransferProps = Record<string, unknown>;\ninterface Scope {\n transferId: string;\n}\ntype CreateTransferEvent = Scope & { componentName: string; initialProps: TransferProps };\ntype SetTransferPropsEvent = Scope & { props: TransferProps };\ntype TransferFirstFrame = Scope & { snapshot: string };\ntype TransferCommit = Scope & {\n version: number;\n seq: number;\n kind: 'hydrate' | 'update';\n patchList: PatchList;\n patchOptions: PatchOptions;\n};\ntype TransferCommitResult = Scope & { version: number; seq: number; status: 'applied' | 'disposed' | 'failed' };\ntype ComponentProvider = (scope: Scope) => ComponentType<TransferProps>;\n\ninterface Pending {\n packet: TransferCommit;\n finish: () => void;\n}\ninterface Instance {\n init: CreateTransferEvent;\n Component: ComponentType<TransferProps>;\n props: TransferProps;\n phase: 'waiting' | 'hydrating' | 'live' | 'disposed';\n /** Counts props updates; each one re-syncs the first frame and restarts `seq`. */\n version: number;\n seq: number;\n main?: SnapshotInstance;\n element?: FiberElement;\n background?: BackgroundSnapshotInstance;\n queue: Pending[];\n inFlight?: Pending | undefined;\n}\ninterface EventTarget {\n addEventListener(type: string, listener: (event: { data: unknown }) => void): void;\n removeEventListener(type: string, listener: (event: { data: unknown }) => void): void;\n}\n\nfunction forgetIds(node: SnapshotInstance): void {\n snapshotInstanceManager.values.delete(node.__id);\n node.childNodes.forEach(child => forgetIds(child));\n}\n\nconst providers = new Map<string, ComponentProvider>();\nlet initialized = false;\n\nfunction initialize(): void {\n const mts = typeof __MAIN_THREAD__ !== 'undefined' && __MAIN_THREAD__;\n const instances = new Map<string, Instance>();\n const frames = new Map<string, TransferFirstFrame>();\n const disposed = new Set<string>();\n const owners = new WeakMap<object, Instance>();\n const removers: (() => void)[] = [];\n const pendingCreates: CreateTransferEvent[] = [];\n let pageReady = !mts;\n let active: Instance | undefined;\n\n function send(type: string, data: unknown) {\n const target = mts ? lynx.getJSContext() : lynx.getCoreContext();\n target.dispatchEvent({ type, data: JSON.stringify(data) });\n }\n function listen<T>(target: EventTarget, type: string, listener: (data: T) => void) {\n const callback = (event: { data: unknown }) => {\n try {\n listener((typeof event.data === 'string' ? JSON.parse(event.data) : event.data) as T);\n } catch (error) {\n lynx.reportError(error as Error);\n }\n };\n target.addEventListener(type, callback);\n removers.push(() => target.removeEventListener(type, callback));\n }\n function withInstance<T>(instance: Instance, fn: () => T): T {\n const previous = active;\n active = instance;\n try {\n return fn();\n } finally {\n active = previous;\n }\n }\n function findOwner(vnode: VNode): Instance | undefined {\n if (active) return active;\n for (let node: VNode | undefined = vnode; node; node = (node as unknown as Record<string, VNode>)[PARENT]) {\n const owner = owners.get(node);\n if (owner) return owner;\n }\n return undefined;\n }\n\n function renderBackground(instance: Instance) {\n const container = instance.background as unknown as ContainerNode;\n withInstance(instance, () => render(createElement(instance.Component, instance.props), container));\n const vnode = (container as unknown as Record<string, object | undefined>)[CHILDREN];\n if (vnode) owners.set(vnode, instance);\n }\n /** Renders the first frame; later frames take over the elements of the previous one, like a template reload. */\n function renderMain(instance: Instance) {\n const previous = instance.main;\n const root = new SnapshotInstance('root');\n if (!previous) {\n root.__elements = [instance.element!];\n root.__element_root = instance.element;\n instance.main = root;\n }\n try {\n withInstance(instance, () => {\n renderFirstFrame(createElement(instance.Component, instance.props), undefined, root);\n });\n } catch (error) {\n if (previous) forgetIds(root);\n dispose(instance.init);\n throw error;\n }\n if (previous) {\n hydrateMainThread(previous, root, { skipUnRef: true });\n forgetIds(previous);\n instance.main = root;\n }\n __pendingListUpdates.flush();\n __FlushElementTree(__page, {});\n send('__TransferFirstFrame', { transferId: instance.init.transferId, snapshot: JSON.stringify(root) });\n }\n /** Releases the commits of an instance that will never be applied. */\n function release(instance: Instance) {\n instance.inFlight?.finish();\n instance.inFlight = undefined;\n instance.queue.forEach(item => item.finish());\n instance.queue.length = 0;\n }\n function pump(instance: Instance) {\n if (instance.inFlight || instance.phase === 'disposed') return;\n instance.inFlight = instance.queue.shift();\n if (instance.inFlight) send('__TransferCommit', instance.inFlight.packet);\n }\n function enqueue(\n instance: Instance,\n kind: TransferCommit['kind'],\n patchList: PatchList,\n patchOptions: PatchOptions,\n finish: () => void,\n ) {\n const packet = {\n transferId: instance.init.transferId,\n version: instance.version,\n seq: ++instance.seq,\n kind,\n patchList,\n patchOptions,\n };\n instance.queue.push({ packet, finish });\n pump(instance);\n }\n function acceptFrame(frame: TransferFirstFrame) {\n if (disposed.has(frame.transferId)) return;\n const instance = instances.get(frame.transferId);\n if (!instance) {\n frames.set(frame.transferId, frame);\n return;\n }\n if (instance.phase !== 'waiting') return;\n instance.phase = 'hydrating';\n const serialized = JSON.parse(frame.snapshot) as SerializedSnapshotInstance;\n const snapshotPatch = withInstance(instance, () => hydrate(serialized, instance.background!));\n enqueue(\n instance,\n 'hydrate',\n { patchList: [{ id: genCommitTaskId(), snapshotPatch }] },\n { reloadVersion: getReloadVersion(), isHydration: true },\n () => {\n if (instance.phase === 'hydrating') instance.phase = 'live';\n },\n );\n }\n\n function create(init: CreateTransferEvent) {\n if (disposed.has(init.transferId) || instances.has(init.transferId)) return;\n if (!pageReady) {\n pendingCreates.push(init);\n return;\n }\n const provider = providers.get(init.componentName);\n if (!provider) throw new Error(`Unknown transfer component: ${init.componentName}`);\n const instance: Instance = {\n init,\n Component: provider({ transferId: init.transferId }),\n props: init.initialProps,\n phase: 'waiting',\n version: 0,\n seq: 0,\n queue: [],\n };\n instances.set(init.transferId, instance);\n if (mts) {\n const element = instance.element = __CreateElement('transfer-view', __pageId);\n __SetAttribute(element, 'transfer-id', init.transferId);\n __AppendElement(__page, element);\n send('__CreateTransfer', init);\n renderMain(instance);\n } else {\n instance.background = new BackgroundSnapshotInstance('root');\n renderBackground(instance);\n const frame = frames.get(init.transferId);\n if (frame) {\n frames.delete(init.transferId);\n acceptFrame(frame);\n }\n }\n }\n /** Re-renders both threads with the new props and re-syncs the first frame, like a template reload. */\n function setProps(update: SetTransferPropsEvent) {\n const pending = pendingCreates.find(init => init.transferId === update.transferId);\n if (pending) {\n pending.initialProps = update.props;\n return;\n }\n const instance = instances.get(update.transferId);\n if (!instance) return;\n instance.props = update.props;\n instance.version++;\n instance.seq = 0;\n if (mts) {\n send('__SetTransferProps', update);\n renderMain(instance);\n return;\n }\n // Remount like a template reload: state resets and commits wait for the new first frame.\n instance.phase = 'waiting';\n release(instance);\n withInstance(instance, () => render(null, instance.background as unknown as ContainerNode));\n renderBackground(instance);\n }\n function dispose(scope: Scope, notify = true) {\n if (disposed.has(scope.transferId)) return;\n disposed.add(scope.transferId);\n frames.delete(scope.transferId);\n const instance = instances.get(scope.transferId);\n if (instance) {\n instance.phase = 'disposed';\n release(instance);\n if (instance.main) {\n forgetIds(instance.main);\n instance.main.removeChildren();\n __RemoveElement(__page, instance.element!);\n __FlushElementTree(__page, {});\n } else if (instance.background) {\n withInstance(instance, () => render(null, instance.background as unknown as ContainerNode));\n instance.background.tearDown();\n }\n instances.delete(scope.transferId);\n }\n if (notify) send(mts ? '__DestroyTransfer' : '__TransferDisposed', { transferId: scope.transferId });\n }\n\n // Business code may call `root.render` before registering; the page root never renders on transfer pages.\n if (__root.__jsx !== undefined) {\n warnRootRenderOnTransferPage();\n __root.__jsx = undefined;\n if (!mts) render(null, __root as unknown as ContainerNode);\n }\n enableTransferMode();\n\n if (mts) {\n listen<[Record<string, unknown>?]>(lynx.getEngine(), '__RenderPage', ([initData]) => {\n lynx.__initData = initData ?? {};\n setupPage(__CreatePage('0', 0));\n (__root as SnapshotInstance).ensureElements();\n __FlushElementTree(__page, {});\n pageReady = true;\n pendingCreates.splice(0).forEach(init => {\n try {\n create(init);\n } catch (error) {\n lynx.reportError(error as Error);\n }\n });\n });\n const native = lynx.getNative();\n listen(native, '__CreateTransfer', create);\n listen(native, '__SetTransferProps', setProps);\n listen<Scope>(native, '__DestroyTransfer', scope => dispose(scope));\n listen<TransferCommit>(lynx.getJSContext(), '__TransferCommit', packet => {\n const instance = instances.get(packet.transferId);\n // Commits rendered before a props update belong to a replaced first frame.\n if (instance && packet.version !== instance.version) return;\n let status: TransferCommitResult['status'] = 'disposed';\n if (instance && instance.phase !== 'disposed') {\n try {\n if (packet.seq !== instance.seq + 1) throw new Error('Transfer commit sequence mismatch');\n updateMainThread({ data: JSON.stringify(packet.patchList), patchOptions: packet.patchOptions });\n instance.seq = packet.seq;\n status = 'applied';\n } catch (error) {\n status = 'failed';\n lynx.reportError(error as Error);\n }\n }\n const { transferId, version, seq } = packet;\n send('__TransferCommitResult', { transferId, version, seq, status });\n });\n listen<Scope>(lynx.getJSContext(), '__TransferDisposed', scope => dispose(scope, false));\n } else {\n // Background commits belong to transfer instances and travel through scoped events.\n replaceCommitHook((vnode, patchList, patchOptions, finish) => {\n const instance = findOwner(vnode);\n if (!instance) {\n finish();\n lynx.reportError(new Error('Commit rendered outside a transfer instance'));\n return;\n }\n if (instance.phase === 'waiting' || instance.phase === 'disposed') {\n finish();\n return;\n }\n enqueue(instance, 'update', patchList, { ...patchOptions, reloadVersion: getReloadVersion() }, finish);\n });\n // Events of hydrated instances dispatch directly; earlier events have no handler and are dropped.\n enablePublishEvent();\n const core = lynx.getCoreContext();\n listen(core, '__CreateTransfer', create);\n listen(core, '__TransferFirstFrame', acceptFrame);\n listen(core, '__SetTransferProps', setProps);\n listen<Scope>(core, '__DestroyTransfer', scope => dispose(scope, false));\n listen<TransferCommitResult>(core, '__TransferCommitResult', result => {\n const instance = instances.get(result.transferId);\n const item = instance?.inFlight;\n if (!instance || !item || item.packet.version !== result.version || item.packet.seq !== result.seq) return;\n instance.inFlight = undefined;\n item.finish();\n if (result.status === 'applied') pump(instance);\n else dispose(instance.init);\n });\n }\n\n listen(lynx.getNative(), '__DestroyLifetime', () => {\n instances.forEach(instance => dispose(instance.init, false));\n removers.splice(0).forEach(remove => remove());\n if (!mts) replaceCommitHook();\n });\n}\n\n/**\n * Registers components that native hosts render as independent transfer instances.\n * Registering the first component turns the page into a transfer page, where `root.render` is ignored.\n * @experimental\n */\nexport const TransferRegistry = {\n registerComponent(componentName: string, provider: ComponentProvider): void {\n providers.set(componentName, provider);\n if (!initialized) {\n initialized = true;\n initialize();\n }\n },\n};\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { clearMtsConfigCacheForTesting, isMtsEnabled } from '../../core/mts-capability.js';
|
|
5
|
-
import { isSdkVersionGt } from '../../
|
|
5
|
+
import { isSdkVersionGt } from '../../shared/version.js';
|
|
6
6
|
let runOnBackgroundEnabled;
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionality.js","sourceRoot":"","sources":["../../../src/snapshot/worklet/functionality.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"functionality.js","sourceRoot":"","sources":["../../../src/snapshot/worklet/functionality.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,IAAI,sBAA2C,CAAC;AAEhD;;GAEG;AACH,SAAS,wBAAwB;IAC/B,OAAO,sBAAsB,KAAK,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,0BAA0B;IACjC,6BAA6B,EAAE,CAAC;IAChC,sBAAsB,GAAG,SAAS,CAAC;AACrC,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,CAAC","sourcesContent":["// Copyright 2024 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 { clearMtsConfigCacheForTesting, isMtsEnabled } from '../../core/mts-capability.js';\nimport { isSdkVersionGt } from '../../shared/version.js';\n\nlet runOnBackgroundEnabled: boolean | undefined;\n\n/**\n * @internal\n */\nfunction isRunOnBackgroundEnabled(): boolean {\n return runOnBackgroundEnabled ??= isSdkVersionGt(2, 15);\n}\n\nfunction clearConfigCacheForTesting(): void {\n clearMtsConfigCacheForTesting();\n runOnBackgroundEnabled = undefined;\n}\n\nexport { isMtsEnabled, isRunOnBackgroundEnabled, clearConfigCacheForTesting };\n"]}
|