@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
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } from './commit-context.js';
|
|
11
11
|
import { isElementTemplateHydrated } from './commit-hook.js';
|
|
12
12
|
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
13
|
-
import { isDirectOrDeepEqual } from '../../
|
|
13
|
+
import { isDirectOrDeepEqual } from '../../core/deep-equal.js';
|
|
14
14
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
15
15
|
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from '../protocol/page.js';
|
|
16
16
|
import { parseElementTemplateType } from '../protocol/template-type.js';
|
|
@@ -20,13 +20,17 @@ import type {
|
|
|
20
20
|
RuntimeOptionsCommand,
|
|
21
21
|
SerializableValue,
|
|
22
22
|
TypedElementAttributesCommand,
|
|
23
|
-
TypedListOptionsCommand,
|
|
24
23
|
UpdateTypedListItemCommand,
|
|
25
24
|
} from '../protocol/types.js';
|
|
25
|
+
import { filterListItemPlatformInfoFromSpread } from '../runtime/list/platform-info.js';
|
|
26
26
|
import type { AuthoredPageAttributes } from '../runtime/page/authored-page.js';
|
|
27
27
|
import { hasMainThreadRefAttrSlot } from '../runtime/template/attr-slot-plan.js';
|
|
28
28
|
import type { EtAttrPlan } from '../runtime/template/attr-slot-plan.js';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,
|
|
31
|
+
TYPED_ELEMENT_ATTR_PLAN,
|
|
32
|
+
TYPED_LIST_ATTR_PLAN,
|
|
33
|
+
} from '../runtime/template/typed-attributes.js';
|
|
30
34
|
|
|
31
35
|
function pushOp(...items: ElementTemplateUpdateCommandStream): void {
|
|
32
36
|
globalCommitContext.ops.push(...items);
|
|
@@ -140,6 +144,8 @@ export class BackgroundElementTemplateInstance {
|
|
|
140
144
|
}
|
|
141
145
|
const nativeTemplate = parseElementTemplateType(this.type);
|
|
142
146
|
|
|
147
|
+
// Pass List item platform info to native with the create command for
|
|
148
|
+
// serialization and List diffing.
|
|
143
149
|
pushOp(
|
|
144
150
|
ElementTemplateUpdateOps.createTemplate,
|
|
145
151
|
this.instanceId,
|
|
@@ -147,6 +153,9 @@ export class BackgroundElementTemplateInstance {
|
|
|
147
153
|
nativeTemplate.bundleUrl,
|
|
148
154
|
this.attributeSlots,
|
|
149
155
|
serializedSlots,
|
|
156
|
+
this.listItemPlatformInfo === undefined
|
|
157
|
+
? null
|
|
158
|
+
: { __listItemPlatformInfo: this.listItemPlatformInfo },
|
|
150
159
|
);
|
|
151
160
|
this.isMaterializedOnMainThread = true;
|
|
152
161
|
}
|
|
@@ -262,7 +271,6 @@ export class BackgroundElementTemplateInstance {
|
|
|
262
271
|
insertBefore(
|
|
263
272
|
child: BackgroundElementTemplateInstance,
|
|
264
273
|
beforeChild: BackgroundElementTemplateInstance | null,
|
|
265
|
-
silent?: boolean,
|
|
266
274
|
): void {
|
|
267
275
|
if (beforeChild === child) {
|
|
268
276
|
throw new Error('Cannot insert a node before itself');
|
|
@@ -273,7 +281,19 @@ export class BackgroundElementTemplateInstance {
|
|
|
273
281
|
|
|
274
282
|
const previousParent = child.parent;
|
|
275
283
|
if (previousParent) {
|
|
284
|
+
const shouldRecordOldListRemove = previousParent !== this
|
|
285
|
+
&& previousParent instanceof BackgroundListElementTemplateInstance
|
|
286
|
+
&& previousParent.canEmitUpdatePatch();
|
|
276
287
|
previousParent.removeChild(child, true);
|
|
288
|
+
if (shouldRecordOldListRemove) {
|
|
289
|
+
pushOp(
|
|
290
|
+
ElementTemplateUpdateOps.removeNode,
|
|
291
|
+
previousParent.instanceId,
|
|
292
|
+
0,
|
|
293
|
+
child.instanceId,
|
|
294
|
+
EMPTY_REMOVED_SUBTREE_HANDLE_IDS,
|
|
295
|
+
);
|
|
296
|
+
}
|
|
277
297
|
}
|
|
278
298
|
|
|
279
299
|
child.parent = this;
|
|
@@ -299,7 +319,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
299
319
|
child.nextSibling = null;
|
|
300
320
|
}
|
|
301
321
|
|
|
302
|
-
if (
|
|
322
|
+
if (!this.canEmitUpdatePatch()) {
|
|
303
323
|
return;
|
|
304
324
|
}
|
|
305
325
|
|
|
@@ -320,7 +340,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
320
340
|
&& containingListItem
|
|
321
341
|
&& previousParent !== this
|
|
322
342
|
) {
|
|
323
|
-
notifyListItemSubtreeUpdated(containingListItem);
|
|
343
|
+
notifyListItemSubtreeUpdated(containingListItem, false);
|
|
324
344
|
}
|
|
325
345
|
}
|
|
326
346
|
|
|
@@ -367,7 +387,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
367
387
|
&& containingListItem
|
|
368
388
|
&& collectMainThreadRefSubtreeHandleIds(child) !== null
|
|
369
389
|
) {
|
|
370
|
-
notifyListItemSubtreeUpdated(containingListItem);
|
|
390
|
+
notifyListItemSubtreeUpdated(containingListItem, false);
|
|
371
391
|
}
|
|
372
392
|
}
|
|
373
393
|
|
|
@@ -465,10 +485,14 @@ export class BackgroundElementTemplateInstance {
|
|
|
465
485
|
this.text = String(value);
|
|
466
486
|
} else if (key === '__listItemPlatformInfo') {
|
|
467
487
|
const previous = this.getListItemPlatformInfo();
|
|
468
|
-
|
|
469
|
-
|
|
488
|
+
this.listItemPlatformInfo = value == null
|
|
489
|
+
? undefined
|
|
490
|
+
: filterListItemPlatformInfoFromSpread(
|
|
491
|
+
value as Record<string, SerializableValue>,
|
|
492
|
+
);
|
|
493
|
+
const next = this.getListItemPlatformInfo();
|
|
470
494
|
if (!isDirectOrDeepEqual(previous, next)) {
|
|
471
|
-
notifyListItemSubtreeUpdated(this);
|
|
495
|
+
notifyListItemSubtreeUpdated(this, true);
|
|
472
496
|
}
|
|
473
497
|
} else if (key === 'attributeSlots' && Array.isArray(value)) {
|
|
474
498
|
const previousSlots = this.attributeSlots;
|
|
@@ -567,9 +591,10 @@ export function getContainingListItem(
|
|
|
567
591
|
|
|
568
592
|
function notifyListItemSubtreeUpdated(
|
|
569
593
|
listItem: BackgroundElementTemplateInstance,
|
|
594
|
+
isUpdatePlatformInfo: boolean,
|
|
570
595
|
): void {
|
|
571
596
|
if (listItem.parent instanceof BackgroundListElementTemplateInstance) {
|
|
572
|
-
listItem.parent.
|
|
597
|
+
listItem.parent.emitTypedListItemUpdate(listItem, isUpdatePlatformInfo);
|
|
573
598
|
}
|
|
574
599
|
}
|
|
575
600
|
|
|
@@ -674,103 +699,71 @@ export class BackgroundListElementTemplateInstance extends BackgroundTypedElemen
|
|
|
674
699
|
super('list');
|
|
675
700
|
}
|
|
676
701
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
listChildren.push(toUpdateTypedListItemCommand(child));
|
|
682
|
-
child = child.nextSibling;
|
|
702
|
+
override emitCreate(): void {
|
|
703
|
+
// Skip creation and candidate initialization for an existing List.
|
|
704
|
+
if (this.isMaterializedOnMainThread) {
|
|
705
|
+
return;
|
|
683
706
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
beforeChild: BackgroundElementTemplateInstance | null,
|
|
692
|
-
silent?: boolean,
|
|
693
|
-
): void {
|
|
694
|
-
const previousParent = child.parent;
|
|
695
|
-
super.insertBefore(child, beforeChild, true);
|
|
696
|
-
if (!silent) {
|
|
697
|
-
if (previousParent instanceof BackgroundListElementTemplateInstance) {
|
|
698
|
-
previousParent.emitTypedListItemRemove(child, EMPTY_REMOVED_SUBTREE_HANDLE_IDS);
|
|
699
|
-
}
|
|
700
|
-
this.emitTypedListItemInsert(child, beforeChild);
|
|
707
|
+
// The base class emits the List create command with the initial item UIDs
|
|
708
|
+
// in childSlots.
|
|
709
|
+
super.emitCreate();
|
|
710
|
+
// Queue initial ref candidates after the List create command has been
|
|
711
|
+
// emitted.
|
|
712
|
+
if (!this.isMaterializedOnMainThread) {
|
|
713
|
+
return;
|
|
701
714
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
this.emitTypedListItemRemove(child, removedSubtreeHandleIds);
|
|
715
|
+
let item = this.firstChild;
|
|
716
|
+
while (item) {
|
|
717
|
+
// Collect main-thread ref candidates separately for each direct item.
|
|
718
|
+
// Passing false sends only ref candidates and leaves platformInfo null.
|
|
719
|
+
pushOp(
|
|
720
|
+
ElementTemplateUpdateOps.updateTypedListItem,
|
|
721
|
+
this.instanceId,
|
|
722
|
+
toUpdateTypedListItemCommand(item, false),
|
|
723
|
+
);
|
|
724
|
+
item = item.nextSibling;
|
|
713
725
|
}
|
|
714
726
|
}
|
|
715
727
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
private emitTypedListItemInsert(
|
|
721
|
-
child: BackgroundElementTemplateInstance,
|
|
722
|
-
beforeChild: BackgroundElementTemplateInstance | null,
|
|
723
|
-
): void {
|
|
724
|
-
if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
child.emitMainThreadCreateIfNeeded();
|
|
729
|
-
pushOp(
|
|
730
|
-
ElementTemplateUpdateOps.insertTypedListItem,
|
|
731
|
-
this.instanceId,
|
|
732
|
-
toUpdateTypedListItemCommand(child),
|
|
733
|
-
beforeChild?.instanceId ?? 0,
|
|
734
|
-
);
|
|
728
|
+
protected override getAttributeSlotPlan(): EtAttrPlan {
|
|
729
|
+
return TYPED_LIST_ATTR_PLAN;
|
|
735
730
|
}
|
|
736
731
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
732
|
+
protected override getChildSlotsForCreate(): ElementTemplateHandleSlotsCommand {
|
|
733
|
+
const childSlots: ElementTemplateHandleSlotsCommand = [];
|
|
734
|
+
let child = this.firstChild;
|
|
735
|
+
while (child) {
|
|
736
|
+
// Group child UIDs by their logical slot.
|
|
737
|
+
// Direct List children belong to slot 0, which MTS validates.
|
|
738
|
+
(childSlots[child.__slotIndex] ??= []).push(child.instanceId);
|
|
739
|
+
child = child.nextSibling;
|
|
743
740
|
}
|
|
744
|
-
|
|
745
|
-
pushOp(
|
|
746
|
-
ElementTemplateUpdateOps.removeTypedListItem,
|
|
747
|
-
this.instanceId,
|
|
748
|
-
child.instanceId,
|
|
749
|
-
removedSubtreeHandleIds,
|
|
750
|
-
);
|
|
741
|
+
return childSlots;
|
|
751
742
|
}
|
|
752
743
|
|
|
753
|
-
|
|
744
|
+
emitTypedListItemUpdate(child: BackgroundElementTemplateInstance, isUpdatePlatformInfo: boolean): void {
|
|
754
745
|
if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {
|
|
755
746
|
return;
|
|
756
747
|
}
|
|
757
|
-
|
|
758
748
|
pushOp(
|
|
759
749
|
ElementTemplateUpdateOps.updateTypedListItem,
|
|
760
750
|
this.instanceId,
|
|
761
|
-
toUpdateTypedListItemCommand(child),
|
|
751
|
+
toUpdateTypedListItemCommand(child, isUpdatePlatformInfo),
|
|
762
752
|
);
|
|
763
753
|
}
|
|
764
754
|
}
|
|
765
755
|
|
|
766
756
|
export function toUpdateTypedListItemCommand(
|
|
767
757
|
child: BackgroundElementTemplateInstance,
|
|
758
|
+
isUpdatePlatformInfo: boolean,
|
|
768
759
|
): UpdateTypedListItemCommand {
|
|
769
760
|
return {
|
|
770
761
|
__etHandleRef: child.instanceId,
|
|
771
762
|
type: child.type,
|
|
772
|
-
platformInfo: child.getListItemPlatformInfo(),
|
|
773
|
-
subtreeHandleIds:
|
|
763
|
+
platformInfo: isUpdatePlatformInfo ? child.getListItemPlatformInfo() : null,
|
|
764
|
+
subtreeHandleIds: isUpdatePlatformInfo
|
|
765
|
+
? null
|
|
766
|
+
: collectMainThreadRefSubtreeHandleIds(child) ?? [],
|
|
774
767
|
};
|
|
775
768
|
}
|
|
776
769
|
|
|
@@ -796,6 +789,13 @@ function collectMainThreadRefSubtreeHandleIdsImpl(
|
|
|
796
789
|
handles ??= [];
|
|
797
790
|
handles.push(instance.instanceId);
|
|
798
791
|
}
|
|
792
|
+
|
|
793
|
+
// The List's own ref is collected above. Item refs follow their own
|
|
794
|
+
// materialization and binding lifecycle.
|
|
795
|
+
if (instance instanceof BackgroundListElementTemplateInstance) {
|
|
796
|
+
return handles;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
799
|
let child = instance.firstChild;
|
|
800
800
|
while (child) {
|
|
801
801
|
handles = collectMainThreadRefSubtreeHandleIdsImpl(child, handles);
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { options } from 'preact';
|
|
6
6
|
|
|
7
|
+
import { lynxQueueMicrotask } from '../../shared/microtask.js';
|
|
7
8
|
import { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';
|
|
8
|
-
import { hook
|
|
9
|
+
import { hook } from '../../shared/utils.js';
|
|
9
10
|
|
|
10
11
|
let installed = false;
|
|
11
12
|
let elementTemplateRendering = false;
|
|
@@ -15,6 +15,7 @@ export type FormattedElementTemplateUpdateCommand =
|
|
|
15
15
|
bundleUrl: string | null | undefined;
|
|
16
16
|
attributeSlots: unknown;
|
|
17
17
|
childSlots: unknown;
|
|
18
|
+
options: unknown;
|
|
18
19
|
}
|
|
19
20
|
| {
|
|
20
21
|
op: 'createTypedElement';
|
|
@@ -36,18 +37,6 @@ export type FormattedElementTemplateUpdateCommand =
|
|
|
36
37
|
attrSlotIndex: number;
|
|
37
38
|
value: unknown;
|
|
38
39
|
}
|
|
39
|
-
| {
|
|
40
|
-
op: 'insertTypedListItem';
|
|
41
|
-
targetId: number;
|
|
42
|
-
item: unknown;
|
|
43
|
-
beforeId: number;
|
|
44
|
-
}
|
|
45
|
-
| {
|
|
46
|
-
op: 'removeTypedListItem';
|
|
47
|
-
targetId: number;
|
|
48
|
-
itemId: number;
|
|
49
|
-
removedSubtreeHandleIds: number[];
|
|
50
|
-
}
|
|
51
40
|
| {
|
|
52
41
|
op: 'updateTypedListItem';
|
|
53
42
|
targetId: number;
|
|
@@ -96,6 +85,7 @@ export function formatElementTemplateUpdateCommands(
|
|
|
96
85
|
bundleUrl: stream[index++] as string | null | undefined,
|
|
97
86
|
attributeSlots: stream[index++],
|
|
98
87
|
childSlots: stream[index++],
|
|
88
|
+
options: stream[index++],
|
|
99
89
|
});
|
|
100
90
|
break;
|
|
101
91
|
}
|
|
@@ -135,24 +125,6 @@ export function formatElementTemplateUpdateCommands(
|
|
|
135
125
|
});
|
|
136
126
|
break;
|
|
137
127
|
|
|
138
|
-
case ElementTemplateUpdateOps.insertTypedListItem:
|
|
139
|
-
result.push({
|
|
140
|
-
op: 'insertTypedListItem',
|
|
141
|
-
targetId: stream[index++] as number,
|
|
142
|
-
item: stream[index++],
|
|
143
|
-
beforeId: stream[index++] as number,
|
|
144
|
-
});
|
|
145
|
-
break;
|
|
146
|
-
|
|
147
|
-
case ElementTemplateUpdateOps.removeTypedListItem:
|
|
148
|
-
result.push({
|
|
149
|
-
op: 'removeTypedListItem',
|
|
150
|
-
targetId: stream[index++] as number,
|
|
151
|
-
itemId: stream[index++] as number,
|
|
152
|
-
removedSubtreeHandleIds: stream[index++] as number[],
|
|
153
|
-
});
|
|
154
|
-
break;
|
|
155
|
-
|
|
156
128
|
case ElementTemplateUpdateOps.updateTypedListItem:
|
|
157
129
|
result.push({
|
|
158
130
|
op: 'updateTypedListItem',
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
NEXT_STATE,
|
|
19
19
|
RENDER,
|
|
20
20
|
} from '../../shared/render-constants.js';
|
|
21
|
-
import { getDisplayName } from '../../utils.js';
|
|
21
|
+
import { getDisplayName } from '../../shared/utils.js';
|
|
22
22
|
import { globalCommitContext } from '../background/commit-context.js';
|
|
23
23
|
|
|
24
24
|
let installed = false;
|
|
@@ -10,12 +10,12 @@ import { injectCalledByNative } from './main-thread-api.js';
|
|
|
10
10
|
import { installOnMtsDestruction } from './mts-destroy.js';
|
|
11
11
|
import { installElementTemplatePatchListener } from './patch-listener.js';
|
|
12
12
|
import { reloadBackground } from './reload-background.js';
|
|
13
|
+
import { setupComponentStack } from '../../core/component-stack.js';
|
|
13
14
|
import { runWithForceRootRender } from '../../core/forceRootRender.js';
|
|
14
15
|
import { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';
|
|
15
16
|
import { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';
|
|
16
17
|
import { updateCardData } from '../../core/lynx-update-data.js';
|
|
17
|
-
import {
|
|
18
|
-
import { lynxQueueMicrotask } from '../../utils.js';
|
|
18
|
+
import { lynxQueueMicrotask } from '../../shared/microtask.js';
|
|
19
19
|
import { installElementTemplateCommitHook } from '../background/commit-hook.js';
|
|
20
20
|
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
21
21
|
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
clearFirstScreenMainThreadRefs,
|
|
8
8
|
flushDelayedRunOnBackgroundFunctions,
|
|
9
9
|
runRunOnMainThreadTask,
|
|
10
|
-
setEomShouldFlushElementTree,
|
|
11
10
|
} from '@lynx-js/react/worklet-runtime/bindings';
|
|
12
11
|
|
|
13
12
|
import { markTiming, setPipeline } from '../../core/performance.js';
|
|
@@ -17,7 +16,10 @@ import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant
|
|
|
17
16
|
import type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';
|
|
18
17
|
import type { ElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
19
18
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
20
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
applyPendingMainThreadRefAttachments,
|
|
21
|
+
runWithEomFlushSuppressed,
|
|
22
|
+
} from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
21
23
|
|
|
22
24
|
let listener:
|
|
23
25
|
| ((event: Pick<ElementTemplateUpdateEvent, 'data'>) => void)
|
|
@@ -95,8 +97,7 @@ export function installElementTemplatePatchListener(): void {
|
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
if (delayedRunOnMainThreadData?.length) {
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
+
runWithEomFlushSuppressed(() => {
|
|
100
101
|
for (const data of delayedRunOnMainThreadData) {
|
|
101
102
|
try {
|
|
102
103
|
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
@@ -104,9 +105,7 @@ export function installElementTemplatePatchListener(): void {
|
|
|
104
105
|
lynx.reportError(error as Error);
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
}
|
|
108
|
-
setEomShouldFlushElementTree(true);
|
|
109
|
-
}
|
|
108
|
+
});
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
__FlushElementTree(undefined, flushOptions);
|
|
@@ -118,8 +118,4 @@ function collectSerializedSubtreeHandleIds(
|
|
|
118
118
|
collectSerializedSubtreeHandleIds(child, handleIds);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
const listChildren = (node as { options?: { listChildren?: SerializedEtNode[] } }).options?.listChildren;
|
|
122
|
-
for (const child of listChildren ?? []) {
|
|
123
|
-
collectSerializedSubtreeHandleIds(child, handleIds);
|
|
124
|
-
}
|
|
125
121
|
}
|
|
@@ -9,7 +9,11 @@ import type { SerializableValue } from '../protocol/types.js';
|
|
|
9
9
|
|
|
10
10
|
export type EtRef = OrdinaryRef<ElementTemplateRefProxy>;
|
|
11
11
|
|
|
12
|
-
type RefToken = [
|
|
12
|
+
type RefToken = [
|
|
13
|
+
handleId: number,
|
|
14
|
+
attrSlotIndex: number,
|
|
15
|
+
templateType: string | undefined,
|
|
16
|
+
];
|
|
13
17
|
|
|
14
18
|
const refEffectQueue = /*#__PURE__*/ new OrdinaryRefEffectQueue<ElementTemplateRefProxy, RefToken>();
|
|
15
19
|
const delayedRefUiOps: (() => void)[] = [];
|
|
@@ -50,9 +54,10 @@ export class ElementTemplateRefProxy extends SelectorRefProxy<ElementTemplateRef
|
|
|
50
54
|
constructor(
|
|
51
55
|
private readonly handleId: number,
|
|
52
56
|
private readonly attrSlotIndex: number,
|
|
57
|
+
templateType?: string,
|
|
53
58
|
) {
|
|
54
59
|
super();
|
|
55
|
-
return this.createProxy();
|
|
60
|
+
return this.createProxy(templateType);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
protected createProxyTarget(): ElementTemplateRefProxy {
|
|
@@ -120,16 +125,18 @@ export function prepareSpreadRefAttrValue(
|
|
|
120
125
|
export function queueRefAttrUpdate(
|
|
121
126
|
oldValue: unknown,
|
|
122
127
|
newValue: unknown,
|
|
123
|
-
instance: { readonly instanceId: number },
|
|
128
|
+
instance: { readonly instanceId: number; readonly type?: string },
|
|
124
129
|
attrSlotIndex: number,
|
|
125
130
|
): void {
|
|
126
131
|
const oldRef = getRefFromValue(oldValue);
|
|
127
132
|
const newRef = getRefFromValue(newValue);
|
|
128
|
-
refEffectQueue.queue(oldRef, newRef, instance, attrSlotIndex, [instance.instanceId, attrSlotIndex]);
|
|
133
|
+
refEffectQueue.queue(oldRef, newRef, instance, attrSlotIndex, [instance.instanceId, attrSlotIndex, instance.type]);
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
export function flushPendingRefs(): void {
|
|
132
|
-
refEffectQueue.flush(([handleId, attrSlotIndex]) =>
|
|
137
|
+
refEffectQueue.flush(([handleId, attrSlotIndex, templateType]) =>
|
|
138
|
+
new ElementTemplateRefProxy(handleId, attrSlotIndex, templateType)
|
|
139
|
+
);
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
export function clearPendingRefs(): void {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { getEventValue } from './event-value.js';
|
|
6
6
|
import { isGestureSlotValue, prepareGestureForNative } from './gesture.js';
|
|
7
7
|
import { prepareSpreadRefAttrValue } from './ref.js';
|
|
8
|
+
import { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../core/attribute-name.js';
|
|
8
9
|
import { isMainThreadFunction } from '../../core/main-thread-function.js';
|
|
9
|
-
import { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../shared/attribute-name.js';
|
|
10
10
|
import type { SerializableValue } from '../protocol/types.js';
|
|
11
11
|
import type { EtAttrAdapterContext } from '../runtime/template/attr-slot-plan.js';
|
|
12
12
|
import { prepareMTEventCtxForNative } from '../runtime/template/main-thread-event-ctx.js';
|
|
@@ -46,28 +46,14 @@ export interface ElementTemplateHandleRefCommandValue {
|
|
|
46
46
|
|
|
47
47
|
export interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {
|
|
48
48
|
type: string;
|
|
49
|
-
platformInfo: Record<string, SerializableValue
|
|
50
|
-
subtreeHandleIds: number[];
|
|
49
|
+
platformInfo: Record<string, SerializableValue> | null;
|
|
50
|
+
subtreeHandleIds: number[] | null;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export type RuntimeOptionsCommand = Record<string, SerializableValue>;
|
|
54
54
|
|
|
55
|
-
// Deferred typed-list create carries logical item records here. Its future
|
|
56
|
-
// main-thread consumer resolves these refs into the list-specific runtime carrier.
|
|
57
|
-
export interface TypedListOptionsCommand extends RuntimeOptionsCommand {
|
|
58
|
-
listChildren: UpdateTypedListItemCommand[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface RuntimeTypedListOptions {
|
|
62
|
-
listChildren: ElementTemplateHandle[];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
55
|
export type SerializedRuntimeOptions = Record<string, SerializableValue>;
|
|
66
56
|
|
|
67
|
-
export interface SerializedTypedListOptions {
|
|
68
|
-
listChildren: SerializedEtNode[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
57
|
export interface SerializedEtNodeBase {
|
|
72
58
|
attributeSlots?: SerializableValue[] | null;
|
|
73
59
|
childSlots?: SerializedEtNodeChildSlots | null;
|
|
@@ -87,10 +73,10 @@ export interface SerializedTypedNode extends SerializedEtNodeBase {
|
|
|
87
73
|
attributes?: TypedElementAttributesCommand | null;
|
|
88
74
|
}
|
|
89
75
|
|
|
90
|
-
|
|
76
|
+
// Logical List items are stored in childSlots[0].
|
|
77
|
+
// Options use the same format as other typed nodes.
|
|
78
|
+
export interface SerializedTypedListNode extends SerializedTypedNode {
|
|
91
79
|
tag: 'list';
|
|
92
|
-
attributes?: TypedElementAttributesCommand | null;
|
|
93
|
-
options?: SerializedTypedListOptions | null;
|
|
94
80
|
}
|
|
95
81
|
|
|
96
82
|
export type SerializedEtNode = SerializedCompiledNode | SerializedTypedNode | SerializedTypedListNode;
|
|
@@ -112,6 +98,8 @@ export type CreateTemplateCommand = [
|
|
|
112
98
|
bundleUrl: string | null | undefined,
|
|
113
99
|
attributeSlots: SerializableValue[] | null | undefined,
|
|
114
100
|
childSlots: ElementTemplateHandleSlotsCommand | null | undefined,
|
|
101
|
+
// Use null when no options are needed to keep the flat command's arity fixed.
|
|
102
|
+
options: RuntimeOptionsCommand | null,
|
|
115
103
|
];
|
|
116
104
|
|
|
117
105
|
export type SetAttributeCommand = [
|
|
@@ -165,24 +153,10 @@ export type CreateTypedElementCommand = [
|
|
|
165
153
|
type: string,
|
|
166
154
|
attributes: TypedElementAttributesCommand | null | undefined,
|
|
167
155
|
childSlots: ElementTemplateHandleSlotsCommand | null | undefined,
|
|
168
|
-
options: RuntimeOptionsCommand |
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
export type InsertTypedListItemCommand = [
|
|
172
|
-
typeof ElementTemplateUpdateOps.insertTypedListItem,
|
|
173
|
-
listHandleId: number,
|
|
174
|
-
item: UpdateTypedListItemCommand,
|
|
175
|
-
beforeHandleId: number,
|
|
176
|
-
];
|
|
177
|
-
|
|
178
|
-
export type RemoveTypedListItemCommand = [
|
|
179
|
-
typeof ElementTemplateUpdateOps.removeTypedListItem,
|
|
180
|
-
listHandleId: number,
|
|
181
|
-
itemHandleId: number,
|
|
182
|
-
removedSubtreeHandleIds: number[],
|
|
156
|
+
options: RuntimeOptionsCommand | null | undefined,
|
|
183
157
|
];
|
|
184
158
|
|
|
185
|
-
export type
|
|
159
|
+
export type UpdateTypedListItemPatchCommand = [
|
|
186
160
|
typeof ElementTemplateUpdateOps.updateTypedListItem,
|
|
187
161
|
listHandleId: number,
|
|
188
162
|
item: UpdateTypedListItemCommand,
|
|
@@ -197,9 +171,7 @@ export type ElementTemplateUpdateCommand =
|
|
|
197
171
|
| InsertNodeCommand
|
|
198
172
|
| RemoveNodeCommand
|
|
199
173
|
| CreateTypedElementCommand
|
|
200
|
-
|
|
|
201
|
-
| RemoveTypedListItemCommand
|
|
202
|
-
| UpdateTypedListItemInfoCommand;
|
|
174
|
+
| UpdateTypedListItemPatchCommand;
|
|
203
175
|
|
|
204
176
|
// Commands are transported as a flat stream to match the native update payload.
|
|
205
177
|
// Tuple aliases above define each opcode's shape; this item union preserves the
|