@lynx-js/react 0.129.2 → 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 +24 -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/compat/export.test.jsx +8 -2
- 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/initEntry.test.js +12 -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/compat/index.d.ts +17 -1
- package/runtime/compat/index.js +3 -2
- package/runtime/lazy/compat.js +1 -0
- package/runtime/lazy/internal.js +1 -0
- package/runtime/lib/core/attribute-name.js.map +1 -0
- package/runtime/lib/core/background-function/run-on-background.js +7 -7
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/{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/shared/version.js +15 -0
- 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/shared/version.ts +16 -0
- 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 +88 -201
- 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 +129 -156
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +282 -149
- 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 +0 -10
- 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/src/worklet-runtime/utils/version.ts +0 -11
- /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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/element-template/debug/profile.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SA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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 { Component, options } from 'preact';\nimport type { ComponentClass, VNode } from 'preact';\n\nimport type { TraceOption } from '@lynx-js/types';\n\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport {\n BITS,\n COMMIT,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DIFF2,\n DIFFED,\n NEXT_STATE,\n RENDER,\n} from '../../shared/render-constants.js';\nimport { getDisplayName } from '../../utils.js';\nimport { globalCommitContext } from '../background/commit-context.js';\n\nlet installed = false;\n\nexport { profileEnd, profileStart };\n\nexport function initProfileHook(): void {\n if (installed) {\n return;\n }\n // early-exit if required profiling APIs are unavailable\n let p;\n /* v8 ignore start */\n if (\n !(p = lynx.performance)\n || typeof p.profileStart !== 'function'\n || typeof p.profileEnd !== 'function'\n || typeof p.profileMark !== 'function'\n || typeof p.profileFlowId !== 'function'\n ) {\n return;\n }\n /* v8 ignore stop */\n installed = true;\n\n const profileStart = p.profileStart.bind(p);\n const profileEnd = p.profileEnd.bind(p);\n const profileMark = p.profileMark.bind(p);\n const profileFlowId = p.profileFlowId.bind(p);\n\n // for each setState call, we will add a profiling trace and\n // attach a flowId to the component instance.\n // This allows us to trace the flow of its diffing, committing and patching.\n {\n const sFlowID = Symbol('FLOW_ID');\n type PatchedComponent = Component & { [sFlowID]?: number };\n\n if (__BACKGROUND__) {\n function buildSetStateProfileMarkArgs(\n currentState: Record<string, unknown>,\n nextState: Record<string, unknown>,\n ): Record<string, string> {\n const EMPTY_OBJ = {};\n\n currentState ??= EMPTY_OBJ;\n nextState ??= EMPTY_OBJ;\n\n return {\n 'current state keys': JSON.stringify(Object.keys(currentState)),\n 'next state keys': JSON.stringify(Object.keys(nextState)),\n 'changed (shallow diff) state keys': JSON.stringify(\n // the setState is in assign manner, we assume nextState is a superset of currentState\n Object.keys(nextState).filter(\n key => currentState[key] !== nextState[key],\n ),\n ),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldSetState = Component.prototype.setState;\n Component.prototype.setState = function(this: PatchedComponent & { [NEXT_STATE]: unknown }, state, callback) {\n oldSetState?.call(this, state, callback);\n\n if (this[BITS] & COMPONENT_DIRTY) {\n profileMark('ReactLynx::setState', {\n flowId: this[sFlowID] ??= profileFlowId(),\n args: buildSetStateProfileMarkArgs(\n this.state as Record<string, unknown>,\n this[NEXT_STATE] as Record<string, unknown>,\n ),\n });\n }\n };\n }\n\n // These hot callbacks have fixed signatures; avoid collecting and spreading\n // an argument array for every host and component visited.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiff2 = options[DIFF2];\n options[DIFF2] = (vnode, oldVNode) => {\n // We only add profiling trace for Component\n if (typeof vnode.type === 'function') {\n const profileOptions: TraceOption = {};\n\n if (__BACKGROUND__) {\n const c = oldVNode?.[COMPONENT] as PatchedComponent | undefined;\n if (c) {\n const flowId = c[sFlowID];\n delete c[sFlowID];\n if (flowId) {\n const flowIds = globalCommitContext.flowIds\n ?? (globalCommitContext.flowIds = []);\n flowIds.push(flowId);\n profileOptions.flowId = flowId;\n }\n }\n }\n\n profileStart(\n `ReactLynx::diff::${/* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass)}`,\n profileOptions,\n );\n }\n /* v8 ignore next */\n oldDiff2?.(vnode, oldVNode);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiffed = options[DIFFED];\n options[DIFFED] = vnode => {\n if (typeof vnode.type === 'function') {\n profileEnd(); // for options[DIFF]\n }\n oldDiffed?.(vnode);\n };\n\n if (__BACKGROUND__) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldCommit = options[COMMIT];\n options[COMMIT] = (vnode, commitQueue) => {\n const globalFlowIds = globalCommitContext.flowIds;\n const commitProfileOptions = globalFlowIds && globalFlowIds.length > 0\n ? { flowId: globalFlowIds[0], flowIds: [...globalFlowIds] }\n : {};\n\n profileStart('ReactLynx::commit', commitProfileOptions);\n /* v8 ignore next */\n oldCommit?.(vnode, commitQueue);\n profileEnd();\n delete globalCommitContext.flowIds;\n };\n }\n }\n\n // Profile the user-provided `render`.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldRender = options[RENDER];\n options[RENDER] = (vnode: VNode) => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalRender = vnode[COMPONENT]!.render;\n vnode[COMPONENT]!.render = function render(this, props, state, context) {\n profileStart(`ReactLynx::render::${/* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass)}`);\n try {\n return originalRender.call(this, props, state, context);\n } finally {\n profileEnd();\n vnode[COMPONENT]!.render = originalRender;\n }\n };\n oldRender?.(vnode);\n };\n\n if (__BACKGROUND__) {\n const sPatchLength = Symbol('PATCH_LENGTH');\n\n type PatchedVNode = VNode & { [sPatchLength]?: number };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiff = options[DIFF];\n options[DIFF] = (vnode: PatchedVNode) => {\n if (typeof vnode.type === 'function') {\n vnode[sPatchLength] = globalCommitContext.ops.length;\n }\n oldDiff?.(vnode);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldPatchDiffed = options[DIFFED];\n options[DIFFED] = (vnode: PatchedVNode) => {\n if (typeof vnode.type === 'function') {\n if (vnode[sPatchLength] === globalCommitContext.ops.length) {\n // \"NoPatch\" is a conventional name in Lynx\n profileMark('ReactLynx::diffFinishNoPatch', {\n args: {\n componentName: /* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass),\n },\n });\n }\n delete vnode[sPatchLength];\n }\n oldPatchDiffed?.(vnode);\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../../src/element-template/debug/profile.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAK5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,M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CAAC;QACH,CAAC,CAAC;QACF,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QAI5C,6DAA6D;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAmB,EAAE,EAAE;YACtC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrC,KAAK,CAAC,YAAY,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC;YACvD,CAAC;YACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,6DAA6D;QAC7D,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAmB,EAAE,EAAE;YACxC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;oBAC3D,2CAA2C;oBAC3C,WAAW,CAAC,8BAA8B,EAAE;wBAC1C,IAAI,EAAE;4BACJ,aAAa,EAAE,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,IAAsB,CAAC;yBAC9E;qBACF,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC;YAC7B,CAAC;YACD,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC;AACH,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.\nimport { Component, options } from 'preact';\nimport type { ComponentClass, VNode } from 'preact';\n\nimport type { TraceOption } from '@lynx-js/types';\n\nimport { profileEnd, profileStart } from '../../shared/profile.js';\nimport {\n BITS,\n COMMIT,\n COMPONENT,\n COMPONENT_DIRTY,\n DIFF,\n DIFF2,\n DIFFED,\n NEXT_STATE,\n RENDER,\n} from '../../shared/render-constants.js';\nimport { getDisplayName } from '../../shared/utils.js';\nimport { globalCommitContext } from '../background/commit-context.js';\n\nlet installed = false;\n\nexport { profileEnd, profileStart };\n\nexport function initProfileHook(): void {\n if (installed) {\n return;\n }\n // early-exit if required profiling APIs are unavailable\n let p;\n /* v8 ignore start */\n if (\n !(p = lynx.performance)\n || typeof p.profileStart !== 'function'\n || typeof p.profileEnd !== 'function'\n || typeof p.profileMark !== 'function'\n || typeof p.profileFlowId !== 'function'\n ) {\n return;\n }\n /* v8 ignore stop */\n installed = true;\n\n const profileStart = p.profileStart.bind(p);\n const profileEnd = p.profileEnd.bind(p);\n const profileMark = p.profileMark.bind(p);\n const profileFlowId = p.profileFlowId.bind(p);\n\n // for each setState call, we will add a profiling trace and\n // attach a flowId to the component instance.\n // This allows us to trace the flow of its diffing, committing and patching.\n {\n const sFlowID = Symbol('FLOW_ID');\n type PatchedComponent = Component & { [sFlowID]?: number };\n\n if (__BACKGROUND__) {\n function buildSetStateProfileMarkArgs(\n currentState: Record<string, unknown>,\n nextState: Record<string, unknown>,\n ): Record<string, string> {\n const EMPTY_OBJ = {};\n\n currentState ??= EMPTY_OBJ;\n nextState ??= EMPTY_OBJ;\n\n return {\n 'current state keys': JSON.stringify(Object.keys(currentState)),\n 'next state keys': JSON.stringify(Object.keys(nextState)),\n 'changed (shallow diff) state keys': JSON.stringify(\n // the setState is in assign manner, we assume nextState is a superset of currentState\n Object.keys(nextState).filter(\n key => currentState[key] !== nextState[key],\n ),\n ),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldSetState = Component.prototype.setState;\n Component.prototype.setState = function(this: PatchedComponent & { [NEXT_STATE]: unknown }, state, callback) {\n oldSetState?.call(this, state, callback);\n\n if (this[BITS] & COMPONENT_DIRTY) {\n profileMark('ReactLynx::setState', {\n flowId: this[sFlowID] ??= profileFlowId(),\n args: buildSetStateProfileMarkArgs(\n this.state as Record<string, unknown>,\n this[NEXT_STATE] as Record<string, unknown>,\n ),\n });\n }\n };\n }\n\n // These hot callbacks have fixed signatures; avoid collecting and spreading\n // an argument array for every host and component visited.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiff2 = options[DIFF2];\n options[DIFF2] = (vnode, oldVNode) => {\n // We only add profiling trace for Component\n if (typeof vnode.type === 'function') {\n const profileOptions: TraceOption = {};\n\n if (__BACKGROUND__) {\n const c = oldVNode?.[COMPONENT] as PatchedComponent | undefined;\n if (c) {\n const flowId = c[sFlowID];\n delete c[sFlowID];\n if (flowId) {\n const flowIds = globalCommitContext.flowIds\n ?? (globalCommitContext.flowIds = []);\n flowIds.push(flowId);\n profileOptions.flowId = flowId;\n }\n }\n }\n\n profileStart(\n `ReactLynx::diff::${/* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass)}`,\n profileOptions,\n );\n }\n /* v8 ignore next */\n oldDiff2?.(vnode, oldVNode);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiffed = options[DIFFED];\n options[DIFFED] = vnode => {\n if (typeof vnode.type === 'function') {\n profileEnd(); // for options[DIFF]\n }\n oldDiffed?.(vnode);\n };\n\n if (__BACKGROUND__) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldCommit = options[COMMIT];\n options[COMMIT] = (vnode, commitQueue) => {\n const globalFlowIds = globalCommitContext.flowIds;\n const commitProfileOptions = globalFlowIds && globalFlowIds.length > 0\n ? { flowId: globalFlowIds[0], flowIds: [...globalFlowIds] }\n : {};\n\n profileStart('ReactLynx::commit', commitProfileOptions);\n /* v8 ignore next */\n oldCommit?.(vnode, commitQueue);\n profileEnd();\n delete globalCommitContext.flowIds;\n };\n }\n }\n\n // Profile the user-provided `render`.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldRender = options[RENDER];\n options[RENDER] = (vnode: VNode) => {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalRender = vnode[COMPONENT]!.render;\n vnode[COMPONENT]!.render = function render(this, props, state, context) {\n profileStart(`ReactLynx::render::${/* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass)}`);\n try {\n return originalRender.call(this, props, state, context);\n } finally {\n profileEnd();\n vnode[COMPONENT]!.render = originalRender;\n }\n };\n oldRender?.(vnode);\n };\n\n if (__BACKGROUND__) {\n const sPatchLength = Symbol('PATCH_LENGTH');\n\n type PatchedVNode = VNode & { [sPatchLength]?: number };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldDiff = options[DIFF];\n options[DIFF] = (vnode: PatchedVNode) => {\n if (typeof vnode.type === 'function') {\n vnode[sPatchLength] = globalCommitContext.ops.length;\n }\n oldDiff?.(vnode);\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldPatchDiffed = options[DIFFED];\n options[DIFFED] = (vnode: PatchedVNode) => {\n if (typeof vnode.type === 'function') {\n if (vnode[sPatchLength] === globalCommitContext.ops.length) {\n // \"NoPatch\" is a conventional name in Lynx\n profileMark('ReactLynx::diffFinishNoPatch', {\n args: {\n componentName: /* #__INLINE__ */ getDisplayName(vnode.type as ComponentClass),\n },\n });\n }\n delete vnode[sPatchLength];\n }\n oldPatchDiffed?.(vnode);\n };\n }\n}\n"]}
|
|
@@ -8,12 +8,12 @@ import { injectCalledByNative } from './main-thread-api.js';
|
|
|
8
8
|
import { installOnMtsDestruction } from './mts-destroy.js';
|
|
9
9
|
import { installElementTemplatePatchListener } from './patch-listener.js';
|
|
10
10
|
import { reloadBackground } from './reload-background.js';
|
|
11
|
+
import { setupComponentStack } from '../../core/component-stack.js';
|
|
11
12
|
import { runWithForceRootRender } from '../../core/forceRootRender.js';
|
|
12
13
|
import { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';
|
|
13
14
|
import { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';
|
|
14
15
|
import { updateCardData } from '../../core/lynx-update-data.js';
|
|
15
|
-
import {
|
|
16
|
-
import { lynxQueueMicrotask } from '../../utils.js';
|
|
16
|
+
import { lynxQueueMicrotask } from '../../shared/microtask.js';
|
|
17
17
|
import { installElementTemplateCommitHook } from '../background/commit-hook.js';
|
|
18
18
|
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
19
19
|
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,sBAA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;QAC1C,sCAAsC,EAAE,CAAC;QACzC,uCAAuC,EAAE,CAAC;QAC1C,yBAAyB,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAC1D,IAAI,CAAC,MAAM,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,CAAC,cAAc,GAAG,cAAc,CAAC;QAC9C,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC;QAC7C,sCAAsC,EAAE,CAAC;QACzC,gCAAgC,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;YACvC,aAAa,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;gBAC7C,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,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.\nimport '@lynx-js/react/hooks';\nimport type { ComponentChild, ContainerNode, VNode } from 'preact';\nimport { options, render } from 'preact';\n\nimport { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';\nimport { injectCalledByNative } from './main-thread-api.js';\nimport { installOnMtsDestruction } from './mts-destroy.js';\nimport { installElementTemplatePatchListener } from './patch-listener.js';\nimport { reloadBackground } from './reload-background.js';\nimport { setupComponentStack } from '../../core/component-stack.js';\nimport { runWithForceRootRender } from '../../core/forceRootRender.js';\nimport { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';\nimport { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';\nimport { updateCardData } from '../../core/lynx-update-data.js';\nimport { lynxQueueMicrotask } from '../../shared/microtask.js';\nimport { installElementTemplateCommitHook } from '../background/commit-hook.js';\nimport { setupBackgroundElementTemplateDocument } from '../background/document.js';\nimport { installElementTemplateHydrationListener } from '../background/hydration-listener.js';\nimport { BackgroundPageRootInstance } from '../background/instance.js';\nimport { installElementTemplateRenderScopeHooks } from '../background/render-scope.js';\nimport { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';\nimport { initProfileHook } from '../debug/profile.js';\nimport { setupLynxEnv } from '../lynx/env.js';\nimport { initTimingAPI } from '../lynx/performance.js';\nimport { installElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';\nimport { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\n\nfunction forceRootRender(): void {\n runWithForceRootRender({\n getRootVNode: () => __root.__jsx,\n setRootVNode: (vnode: VNode) => {\n // @ts-expect-error: __root.__jsx is a Preact VNode during background force render.\n __root.__jsx = vnode;\n },\n render: () => {\n render(__root.__jsx as ComponentChild, __root as unknown as ContainerNode);\n },\n });\n}\n\nconst updateGlobalPropsOptions = {\n forceRerender: forceRootRender,\n};\n\nfunction updateGlobalProps(newData: Record<string, any>): void {\n updateGlobalPropsCore(newData, updateGlobalPropsOptions);\n}\n\nfunction init(): void {\n if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {\n initElementTemplatePAPICallAlog();\n }\n\n if (__MAIN_THREAD__) {\n installMainThreadHooks();\n injectCalledByNative();\n installElementTemplateRefInitValueListener();\n installElementTemplatePatchListener();\n installOnMtsDestruction();\n if (__PROFILE__) {\n initProfileHook();\n }\n }\n\n if (__BACKGROUND__) {\n if (__DEV__) {\n setupComponentStack();\n }\n options.requestAnimationFrame = lynxQueueMicrotask;\n console.log('experimental_useElementTemplate:', __USE_ELEMENT_TEMPLATE__);\n setRoot(new BackgroundPageRootInstance());\n setupBackgroundElementTemplateDocument();\n installElementTemplateHydrationListener();\n resetEventStateForRuntime();\n lynx.getApp().callDestroyLifetimeFun = callDestroyLifetimeFun;\n lynx.getApp().publishEvent = publishEvent;\n lynx.getApp().publicComponentEvent = publicComponentEvent;\n lynx.getApp().updateGlobalProps = updateGlobalProps;\n lynx.getApp().updateCardData = updateCardData;\n lynx.getApp().onAppReload = reloadBackground;\n installElementTemplateRenderScopeHooks();\n installElementTemplateCommitHook();\n if (process.env['NODE_ENV'] !== 'test') {\n initTimingAPI();\n if (lynx.performance?.isProfileRecording?.()) {\n initProfileHook();\n }\n }\n }\n\n setupLynxEnv();\n}\n\ninit();\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
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
|
-
import { clearFirstScreenMainThreadRefs, flushDelayedRunOnBackgroundFunctions, runRunOnMainThreadTask,
|
|
4
|
+
import { clearFirstScreenMainThreadRefs, flushDelayedRunOnBackgroundFunctions, runRunOnMainThreadTask, } from '@lynx-js/react/worklet-runtime/bindings';
|
|
5
5
|
import { markTiming, setPipeline } from '../../core/performance.js';
|
|
6
6
|
import { getReloadVersion } from '../../core/reload-version.js';
|
|
7
7
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
8
8
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
9
9
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
10
|
-
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
10
|
+
import { applyPendingMainThreadRefAttachments, runWithEomFlushSuppressed, } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
11
11
|
let listener;
|
|
12
12
|
export function installElementTemplatePatchListener() {
|
|
13
13
|
resetElementTemplatePatchListener();
|
|
@@ -72,8 +72,7 @@ export function installElementTemplatePatchListener() {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
if (delayedRunOnMainThreadData?.length) {
|
|
75
|
-
|
|
76
|
-
try {
|
|
75
|
+
runWithEomFlushSuppressed(() => {
|
|
77
76
|
for (const data of delayedRunOnMainThreadData) {
|
|
78
77
|
try {
|
|
79
78
|
runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
|
|
@@ -82,10 +81,7 @@ export function installElementTemplatePatchListener() {
|
|
|
82
81
|
lynx.reportError(error);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
setEomShouldFlushElementTree(true);
|
|
88
|
-
}
|
|
84
|
+
});
|
|
89
85
|
}
|
|
90
86
|
__FlushElementTree(undefined, flushOptions);
|
|
91
87
|
if (shouldProfilePatch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,M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C,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;wBAC1F,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,CAAC;wBACnC,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;YAED,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YAE5C,IAAI,kBAAkB,EAAE,CAAC;gBACvB,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,YAAY,EAAE,CAAC,gBAAgB,CAClC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,EAAE,CAAC,mBAAmB,CACrC,gCAAgC,CAAC,MAAM,EACvC,QAAQ,CACT,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,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 type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport {\n clearFirstScreenMainThreadRefs,\n flushDelayedRunOnBackgroundFunctions,\n runRunOnMainThreadTask,\n} from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { markTiming, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';\nimport type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';\nimport type { ElementTemplateUpdateEvent } from '../protocol/update-event.js';\nimport { applyElementTemplateUpdateCommands } from '../runtime/patch.js';\nimport {\n applyPendingMainThreadRefAttachments,\n runWithEomFlushSuppressed,\n} from '../runtime/template/main-thread-dynamic-attr-state.js';\n\nlet listener:\n | ((event: Pick<ElementTemplateUpdateEvent, 'data'>) => void)\n | undefined;\n\nexport function installElementTemplatePatchListener(): void {\n resetElementTemplatePatchListener();\n\n listener = (event: Pick<ElementTemplateUpdateEvent, 'data'>) => {\n const { patchOptions } = event.data;\n const { flowIds, pipelineOptions } = patchOptions;\n const shouldProfilePatch = !!flowIds\n && typeof lynx.performance?.profileStart === 'function'\n && typeof lynx.performance?.profileEnd === 'function';\n if (shouldProfilePatch) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n setPipeline(pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n\n const payload = JSON.parse(event.data.payload) as ElementTemplateUpdateCommitContext;\n markTiming('parseChangesEnd');\n\n if (\n typeof patchOptions.reloadVersion === 'number'\n && patchOptions.reloadVersion < getReloadVersion()\n ) {\n markTiming('mtsRenderEnd');\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n return;\n }\n\n const hasOps = payload.ops.length > 0;\n const flushOptions = payload.flushOptions;\n const isHydration = payload.isHydration === true;\n const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;\n try {\n if (hasOps) {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate main-thread patch:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(payload.ops),\n flushOptions,\n flowIds,\n },\n null,\n 2,\n ),\n );\n }\n markTiming('patchChangesStart');\n try {\n applyElementTemplateUpdateCommands(payload.ops, isHydration);\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n }\n } else {\n markTiming('mtsRenderEnd');\n }\n applyPendingMainThreadRefAttachments(isHydration);\n } finally {\n if (isHydration) {\n flushDelayedRunOnBackgroundFunctions();\n clearFirstScreenMainThreadRefs();\n }\n }\n if (delayedRunOnMainThreadData?.length) {\n runWithEomFlushSuppressed(() => {\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n } catch (error) {\n lynx.reportError(error as Error);\n }\n }\n });\n }\n\n __FlushElementTree(undefined, flushOptions);\n\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n };\n\n lynx.getJSContext().addEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n}\n\nexport function resetElementTemplatePatchListener(): void {\n if (listener) {\n lynx.getJSContext().removeEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n }\n listener = undefined;\n}\n"]}
|
|
@@ -97,9 +97,5 @@ function collectSerializedSubtreeHandleIds(node, handleIds) {
|
|
|
97
97
|
collectSerializedSubtreeHandleIds(child, handleIds);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
const listChildren = node.options?.listChildren;
|
|
101
|
-
for (const child of listChildren ?? []) {
|
|
102
|
-
collectSerializedSubtreeHandleIds(child, handleIds);
|
|
103
|
-
}
|
|
104
100
|
}
|
|
105
101
|
//# sourceMappingURL=reload-main-thread.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM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C,gBAAgB,EAAE,CAAC;QAEnB,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;YACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC;AAOD,MAAM,UAAU,wBAAwB,CAAC,EAAE,IAAI,EAAE,OAAO,EAA2B;IACjF,SAAS,CAAC,IAAI,CAAC,CAAC;IAChB,gBAAgB,EAAE,CAAC;IACnB,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,gCAAgC,CAAC,wBAAwB,CAAC,CAAC;AAE3D,SAAS,iCAAiC,CACxC,IAAsB,EACtB,SAAmB;IAEnB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAa,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YAC/B,iCAAiC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;
|
|
1
|
+
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,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I,WAAW,EAAE,CAAC;YACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;AACH,CAAC;AAOD,MAAM,UAAU,wBAAwB,CAAC,EAAE,IAAI,EAAE,OAAO,EAA2B;IACjF,SAAS,CAAC,IAAI,CAAC,CAAC;IAChB,gBAAgB,EAAE,CAAC;IACnB,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,gCAAgC,CAAC,wBAAwB,CAAC,CAAC;AAE3D,SAAS,iCAAiC,CACxC,IAAsB,EACtB,SAAmB;IAEnB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAa,CAAC,CAAC;IACnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YAC/B,iCAAiC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { flushElementTemplate } from './flush.js';\nimport { onMtsDestruction } from './mts-destroy.js';\nimport {\n canReEvalMainThreadEntry,\n installMainThreadReloadCompleter,\n reEvalMainThreadEntry,\n} from '../../core/entry-reload.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { increaseReloadVersion } from '../../core/reload-version.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';\nimport type { SerializedEtNode, SerializedPageRoot } from '../protocol/types.js';\nimport { destroyAllElementTemplateListStates } from '../runtime/list/list.js';\nimport { __page, setupPage } from '../runtime/page/page.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\nimport { renderMainThread } from '../runtime/render/render-main-thread.js';\nimport { resetTemplateId } from '../runtime/template/handle.js';\nimport { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\nimport {\n clearMainThreadDynamicAttrState,\n deleteMainThreadDynamicAttrStateForSubtree,\n} from '../runtime/template/main-thread-dynamic-attr-state.js';\nimport { elementTemplateRegistry } from '../runtime/template/registry.js';\n\nexport function reloadMainThread(data: unknown, options: UpdatePageOption): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadMainThread');\n }\n\n try {\n applyUpdatePageData(data, options);\n\n destroyAllElementTemplateListStates();\n // TODO: Replace this cleanup-only serialization with a direct page-children\n // or clear-slot PAPI once native exposes one.\n const page = __SerializeElementTemplate(__page) as SerializedPageRoot;\n let cleanupError: unknown;\n let didCleanupThrow = false;\n for (const root of page.childSlots?.[ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX] ?? []) {\n const rootRef = elementTemplateRegistry.get(root.uid)!;\n __RemoveNodeFromElementTemplate(__page, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, rootRef);\n const removedHandleIds: number[] = [];\n collectSerializedSubtreeHandleIds(root, removedHandleIds);\n for (const handleId of removedHandleIds) {\n elementTemplateRegistry.delete(handleId);\n }\n try {\n deleteMainThreadDynamicAttrStateForSubtree(removedHandleIds);\n } catch (error) {\n if (!didCleanupThrow) {\n cleanupError = error;\n didCleanupThrow = true;\n }\n }\n }\n if (canReEvalMainThreadEntry()) {\n try {\n onMtsDestruction();\n } finally {\n increaseReloadVersion();\n }\n if (didCleanupThrow) {\n throw cleanupError;\n }\n reEvalMainThreadEntry<MainThreadReloadHandoff>({ page: __page, options });\n return;\n }\n elementTemplateRegistry.clear();\n try {\n clearMainThreadDynamicAttrState();\n } finally {\n resetElementTemplateMainThreadBackgroundFunctionRuntime();\n resetTemplateId();\n // Ref cleanup still belongs to the old page. Advance only before rendering\n // the new tree so calls queued by old ref/unmount callbacks remain stale.\n increaseReloadVersion();\n }\n if (didCleanupThrow) {\n throw cleanupError;\n }\n\n const oldRoot = __root;\n setRoot({ __jsx: oldRoot.__jsx });\n renderMainThread();\n\n flushElementTemplate(options);\n } finally {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n}\n\ninterface MainThreadReloadHandoff {\n page: ElementTemplateHandle;\n options: UpdatePageOption;\n}\n\nexport function completeMainThreadReload({ page, options }: MainThreadReloadHandoff): void {\n setupPage(page);\n renderMainThread();\n __FlushElementTree(undefined, options);\n}\n\ninstallMainThreadReloadCompleter(completeMainThreadReload);\n\nfunction collectSerializedSubtreeHandleIds(\n node: SerializedEtNode,\n handleIds: number[],\n): void {\n handleIds.push(node.uid as number);\n for (const slot of node.childSlots ?? []) {\n for (const child of slot ?? []) {\n collectSerializedSubtreeHandleIds(child, handleIds);\n }\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ export declare function clearDelayedRefUiOps(): void;
|
|
|
8
8
|
export declare class ElementTemplateRefProxy extends SelectorRefProxy<ElementTemplateRefProxy> {
|
|
9
9
|
private readonly handleId;
|
|
10
10
|
private readonly attrSlotIndex;
|
|
11
|
-
constructor(handleId: number, attrSlotIndex: number);
|
|
11
|
+
constructor(handleId: number, attrSlotIndex: number, templateType?: string);
|
|
12
12
|
protected createProxyTarget(): ElementTemplateRefProxy;
|
|
13
13
|
protected runOrDelay(task: () => void): void;
|
|
14
14
|
get selector(): string;
|
|
@@ -21,6 +21,7 @@ export declare function prepareRefAttrSlot(handleId: number, attrSlotIndex: numb
|
|
|
21
21
|
export declare function prepareSpreadRefAttrValue(handleId: number, attrSlotIndex: number, value: unknown): SerializableValue | null | undefined;
|
|
22
22
|
export declare function queueRefAttrUpdate(oldValue: unknown, newValue: unknown, instance: {
|
|
23
23
|
readonly instanceId: number;
|
|
24
|
+
readonly type?: string;
|
|
24
25
|
}, attrSlotIndex: number): void;
|
|
25
26
|
export declare function flushPendingRefs(): void;
|
|
26
27
|
export declare function clearPendingRefs(): void;
|
|
@@ -34,11 +34,11 @@ export function clearDelayedRefUiOps() {
|
|
|
34
34
|
export class ElementTemplateRefProxy extends SelectorRefProxy {
|
|
35
35
|
handleId;
|
|
36
36
|
attrSlotIndex;
|
|
37
|
-
constructor(handleId, attrSlotIndex) {
|
|
37
|
+
constructor(handleId, attrSlotIndex, templateType) {
|
|
38
38
|
super();
|
|
39
39
|
this.handleId = handleId;
|
|
40
40
|
this.attrSlotIndex = attrSlotIndex;
|
|
41
|
-
return this.createProxy();
|
|
41
|
+
return this.createProxy(templateType);
|
|
42
42
|
}
|
|
43
43
|
createProxyTarget() {
|
|
44
44
|
return new ElementTemplateRefProxy(this.handleId, this.attrSlotIndex);
|
|
@@ -87,10 +87,10 @@ export function prepareSpreadRefAttrValue(handleId, attrSlotIndex, value) {
|
|
|
87
87
|
export function queueRefAttrUpdate(oldValue, newValue, instance, attrSlotIndex) {
|
|
88
88
|
const oldRef = getRefFromValue(oldValue);
|
|
89
89
|
const newRef = getRefFromValue(newValue);
|
|
90
|
-
refEffectQueue.queue(oldRef, newRef, instance, attrSlotIndex, [instance.instanceId, attrSlotIndex]);
|
|
90
|
+
refEffectQueue.queue(oldRef, newRef, instance, attrSlotIndex, [instance.instanceId, attrSlotIndex, instance.type]);
|
|
91
91
|
}
|
|
92
92
|
export function flushPendingRefs() {
|
|
93
|
-
refEffectQueue.flush(([handleId, attrSlotIndex]) => new ElementTemplateRefProxy(handleId, attrSlotIndex));
|
|
93
|
+
refEffectQueue.flush(([handleId, attrSlotIndex, templateType]) => new ElementTemplateRefProxy(handleId, attrSlotIndex, templateType));
|
|
94
94
|
}
|
|
95
95
|
export function clearPendingRefs() {
|
|
96
96
|
refEffectQueue.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/ref.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,sBAAsB,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B,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,CAAC,UAAU,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,gBAAgB,EAAE,CAAC;IACnB,YAAY,CAAC,KAAK,EAAE,CAAC;IACrB,oBAAoB,EAAE,CAAC;IACvB,mBAAmB,GAAG,IAAI,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { OrdinaryRefEffectQueue, SelectorRefProxy, normalizeRefValue } from '../../core/ref.js';\nimport type { OrdinaryRef, RefProxyForwardedMethods } from '../../core/ref.js';\nimport { hydrationMap } from '../hydration-map.js';\nimport type { SerializableValue } from '../protocol/types.js';\n\nexport type EtRef = OrdinaryRef<ElementTemplateRefProxy>;\n\ntype RefToken = [\n handleId: number,\n attrSlotIndex: number,\n templateType: string | undefined,\n];\n\nconst refEffectQueue = /*#__PURE__*/ new OrdinaryRefEffectQueue<ElementTemplateRefProxy, RefToken>();\nconst delayedRefUiOps: (() => void)[] = [];\nlet shouldDelayRefUiOps = true;\n\nfunction resolveRefHandleId(handleId: number): number {\n // The proxy may have been handed to user code before hydrate; resolve the id\n // at execution time so the same object follows the hydrated native handle.\n return hydrationMap.get(handleId) ?? handleId;\n}\n\nfunction runOrDelayRefUiOp(task: () => void): void {\n if (!shouldDelayRefUiOps) {\n task();\n return;\n }\n delayedRefUiOps.push(task);\n}\n\nexport function getRefValue(handleId: number, attrSlotIndex: number): string {\n return `${handleId}-${attrSlotIndex}`;\n}\n\nexport function flushDelayedRefUiOps(): void {\n const tasks = delayedRefUiOps.splice(0);\n shouldDelayRefUiOps = false;\n\n for (const task of tasks) {\n task();\n }\n}\n\nexport function clearDelayedRefUiOps(): void {\n delayedRefUiOps.length = 0;\n}\n\nexport class ElementTemplateRefProxy extends SelectorRefProxy<ElementTemplateRefProxy> {\n constructor(\n private readonly handleId: number,\n private readonly attrSlotIndex: number,\n templateType?: string,\n ) {\n super();\n return this.createProxy(templateType);\n }\n\n protected createProxyTarget(): ElementTemplateRefProxy {\n return new ElementTemplateRefProxy(this.handleId, this.attrSlotIndex);\n }\n\n protected runOrDelay(task: () => void): void {\n runOrDelayRefUiOp(task);\n }\n\n get selector(): string {\n return `[ref=${getRefValue(resolveRefHandleId(this.handleId), this.attrSlotIndex)}]`;\n }\n}\n\nexport interface ElementTemplateRefProxy extends RefProxyForwardedMethods<ElementTemplateRefProxy> {}\n\nexport function getRefFromValue(value: unknown): EtRef | null {\n return normalizeRefValue<ElementTemplateRefProxy>(value) ?? null;\n}\n\nfunction hasOwnRef(value: unknown): value is { ref?: unknown } {\n return value !== null\n && typeof value === 'object'\n && !Array.isArray(value)\n && Object.prototype.hasOwnProperty.call(value, 'ref');\n}\n\nexport function getSpreadRefFromValue(value: unknown): EtRef | null | undefined {\n if (!hasOwnRef(value)) {\n return undefined;\n }\n return getRefFromValue(value.ref);\n}\n\nexport function prepareRefAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n if (__LEPUS__ && value === 1) {\n // The LEPUS transform cannot carry the background ref callback/object into\n // first-screen create, so direct refs arrive here as an internal presence\n // marker. Background JS still validates the real user ref before attaching.\n return getRefValue(handleId, attrSlotIndex);\n }\n if (getRefFromValue(value) === null) {\n return null;\n }\n return getRefValue(handleId, attrSlotIndex);\n}\n\nexport function prepareSpreadRefAttrValue(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null | undefined {\n const ref = getSpreadRefFromValue(value);\n if (ref === undefined) {\n return undefined;\n }\n return ref === null ? null : getRefValue(handleId, attrSlotIndex);\n}\n\nexport function queueRefAttrUpdate(\n oldValue: unknown,\n newValue: unknown,\n instance: { readonly instanceId: number; readonly type?: string },\n attrSlotIndex: number,\n): void {\n const oldRef = getRefFromValue(oldValue);\n const newRef = getRefFromValue(newValue);\n refEffectQueue.queue(oldRef, newRef, instance, attrSlotIndex, [instance.instanceId, attrSlotIndex, instance.type]);\n}\n\nexport function flushPendingRefs(): void {\n refEffectQueue.flush(([handleId, attrSlotIndex, templateType]) =>\n new ElementTemplateRefProxy(handleId, attrSlotIndex, templateType)\n );\n}\n\nexport function clearPendingRefs(): void {\n refEffectQueue.clear();\n}\n\nexport function hasPendingRefs(): boolean {\n return refEffectQueue.hasPending();\n}\n\nexport function clearRefState(): void {\n clearPendingRefs();\n hydrationMap.clear();\n clearDelayedRefUiOps();\n shouldDelayRefUiOps = true;\n}\n"]}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { getEventValue } from './event-value.js';
|
|
5
5
|
import { isGestureSlotValue, prepareGestureForNative } from './gesture.js';
|
|
6
6
|
import { prepareSpreadRefAttrValue } from './ref.js';
|
|
7
|
+
import { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../core/attribute-name.js';
|
|
7
8
|
import { isMainThreadFunction } from '../../core/main-thread-function.js';
|
|
8
|
-
import { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../shared/attribute-name.js';
|
|
9
9
|
import { prepareMTEventCtxForNative } from '../runtime/template/main-thread-event-ctx.js';
|
|
10
10
|
import { prepareMTRefForNative } from '../runtime/template/main-thread-ref-ctx.js';
|
|
11
11
|
const MAIN_THREAD_NAMESPACE_PREFIX = 'main-thread:';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/spread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,oBA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IAEd,OAAO,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { getEventValue } from './event-value.js';\nimport { isGestureSlotValue, prepareGestureForNative } from './gesture.js';\nimport { prepareSpreadRefAttrValue } from './ref.js';\nimport { isMainThreadFunction } from '../../core/main-thread-function.js';\nimport { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../shared/attribute-name.js';\nimport type { SerializableValue } from '../protocol/types.js';\nimport type { EtAttrAdapterContext } from '../runtime/template/attr-slot-plan.js';\nimport { prepareMTEventCtxForNative } from '../runtime/template/main-thread-event-ctx.js';\nimport { prepareMTRefForNative } from '../runtime/template/main-thread-ref-ctx.js';\n\nconst MAIN_THREAD_NAMESPACE_PREFIX = 'main-thread:';\n\n// Keep per-key raw callback/ref provenance outside the wire value so in-place\n// mutation of a caller-reused spread object cannot alias historical raw values.\nconst spreadRawSources = new WeakMap<Record<string, unknown>, Record<string, unknown>>();\n\nexport function isSpreadRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nexport function hasOwnSpreadKey(record: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(record, key);\n}\n\nexport function isMainThreadEventPropKey(key: string): boolean {\n return key.startsWith(MAIN_THREAD_NAMESPACE_PREFIX)\n && isEventPropKey(key.slice(MAIN_THREAD_NAMESPACE_PREFIX.length));\n}\n\nfunction prepareSpreadAttrSlotImpl(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n allowMainThreadCapabilities: boolean,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n if (value === false || !isSpreadRecord(value)) {\n return null;\n }\n\n const prevPreparedSlot = context?.previousPreparedSlots?.[attrSlotIndex];\n const prevPreparedRecord = isSpreadRecord(prevPreparedSlot) ? prevPreparedSlot : undefined;\n const prevRawSources = prevPreparedRecord ? spreadRawSources.get(prevPreparedRecord) : undefined;\n\n const prepared: Record<string, SerializableValue> = {};\n let rawSources: Record<string, unknown> | undefined;\n\n for (const key in value) {\n const spreadValue = value[key];\n if (key === '__spread' || key === '__self' || key === '__source') {\n continue;\n }\n\n if (key === 'class' || key === 'className') {\n prepared['class'] = (spreadValue ?? '') as SerializableValue;\n continue;\n }\n\n if (key === 'ref') {\n const refValue = prepareSpreadRefAttrValue(handleId, attrSlotIndex, value);\n if (refValue !== undefined) {\n prepared['ref'] = refValue;\n }\n continue;\n }\n\n if (allowMainThreadCapabilities) {\n if (key === 'main-thread:ref') {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n const preparedRef = prepareMTRefForNative(\n spreadValue,\n prevPreparedRecord?.[key],\n prevRawSources?.[key],\n );\n prepared[key] = preparedRef;\n if (preparedRef !== null) {\n (rawSources ??= Object.create(null) as Record<string, unknown>)[key] = spreadValue;\n }\n continue;\n }\n\n if (key === 'main-thread:gesture') {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n const prevGesture = prevPreparedRecord && hasOwnSpreadKey(prevPreparedRecord, key)\n ? prevPreparedRecord[key]\n : undefined;\n prepared[key] = prepareGestureForNative(\n spreadValue,\n isGestureSlotValue(prevGesture) ? prevGesture : undefined,\n ) as unknown as SerializableValue;\n continue;\n }\n\n if (isMainThreadEventPropKey(key)) {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n if (spreadValue === null || spreadValue === undefined || spreadValue === false) {\n prepared[key] = null;\n continue;\n }\n if (!isMainThreadFunction(spreadValue)) {\n if (__DEV__) {\n lynx.reportError(\n new Error(\n `ElementTemplate main-thread event slot ${handleId}:${attrSlotIndex} (${key}) expects a worklet ctx object.`,\n ),\n );\n }\n prepared[key] = null;\n continue;\n }\n prepared[key] = prepareMTEventCtxForNative(\n spreadValue,\n prevPreparedRecord?.[key],\n prevRawSources?.[key],\n );\n (rawSources ??= Object.create(null) as Record<string, unknown>)[key] = spreadValue;\n continue;\n }\n }\n\n const transformedKey = transformAttrName(key);\n if (isEventPropKey(transformedKey)) {\n prepared[transformedKey] = spreadValue === null || spreadValue === undefined || spreadValue === false\n ? null\n : getEventValue(handleId, attrSlotIndex, key);\n continue;\n }\n\n if (\n spreadValue === undefined\n || transformedKey.endsWith(':ref')\n || transformedKey.endsWith(':gesture')\n || isNamespacedEventPropKey(key)\n || typeof spreadValue === 'function'\n ) {\n continue;\n }\n\n prepared[transformedKey] = spreadValue as SerializableValue;\n }\n\n if (rawSources) {\n spreadRawSources.set(prepared, rawSources);\n }\n\n return prepared;\n}\n\nexport function prepareSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n return prepareSpreadAttrSlotImpl(handleId, attrSlotIndex, value, true, context);\n}\n\nexport function prepareTypedSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n return prepareSpreadAttrSlotImpl(handleId, attrSlotIndex, value, false);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"spread.js","sourceRoot":"","sources":["../../../src/element-template/prop-adapters/spread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C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AAS;YACX,CAAC;QACH,CAAC;QAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,cAAc,CAAC,GAAG,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,KAAK;gBACnG,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;YAChD,SAAS;QACX,CAAC;QAED,IACE,WAAW,KAAK,SAAS;eACtB,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC;eAC/B,cAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;eACnC,wBAAwB,CAAC,GAAG,CAAC;eAC7B,OAAO,WAAW,KAAK,UAAU,EACpC,CAAC;YACD,SAAS;QACX,CAAC;QAED,QAAQ,CAAC,cAAc,CAAC,GAAG,WAAgC,CAAC;IAC9D,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,aAAqB,EACrB,KAAc,EACd,OAA8B;IAE9B,OAAO,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAgB,EAChB,aAAqB,EACrB,KAAc;IAEd,OAAO,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { getEventValue } from './event-value.js';\nimport { isGestureSlotValue, prepareGestureForNative } from './gesture.js';\nimport { prepareSpreadRefAttrValue } from './ref.js';\nimport { isEventPropKey, isNamespacedEventPropKey, transformAttrName } from '../../core/attribute-name.js';\nimport { isMainThreadFunction } from '../../core/main-thread-function.js';\nimport type { SerializableValue } from '../protocol/types.js';\nimport type { EtAttrAdapterContext } from '../runtime/template/attr-slot-plan.js';\nimport { prepareMTEventCtxForNative } from '../runtime/template/main-thread-event-ctx.js';\nimport { prepareMTRefForNative } from '../runtime/template/main-thread-ref-ctx.js';\n\nconst MAIN_THREAD_NAMESPACE_PREFIX = 'main-thread:';\n\n// Keep per-key raw callback/ref provenance outside the wire value so in-place\n// mutation of a caller-reused spread object cannot alias historical raw values.\nconst spreadRawSources = new WeakMap<Record<string, unknown>, Record<string, unknown>>();\n\nexport function isSpreadRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nexport function hasOwnSpreadKey(record: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(record, key);\n}\n\nexport function isMainThreadEventPropKey(key: string): boolean {\n return key.startsWith(MAIN_THREAD_NAMESPACE_PREFIX)\n && isEventPropKey(key.slice(MAIN_THREAD_NAMESPACE_PREFIX.length));\n}\n\nfunction prepareSpreadAttrSlotImpl(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n allowMainThreadCapabilities: boolean,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n if (value === false || !isSpreadRecord(value)) {\n return null;\n }\n\n const prevPreparedSlot = context?.previousPreparedSlots?.[attrSlotIndex];\n const prevPreparedRecord = isSpreadRecord(prevPreparedSlot) ? prevPreparedSlot : undefined;\n const prevRawSources = prevPreparedRecord ? spreadRawSources.get(prevPreparedRecord) : undefined;\n\n const prepared: Record<string, SerializableValue> = {};\n let rawSources: Record<string, unknown> | undefined;\n\n for (const key in value) {\n const spreadValue = value[key];\n if (key === '__spread' || key === '__self' || key === '__source') {\n continue;\n }\n\n if (key === 'class' || key === 'className') {\n prepared['class'] = (spreadValue ?? '') as SerializableValue;\n continue;\n }\n\n if (key === 'ref') {\n const refValue = prepareSpreadRefAttrValue(handleId, attrSlotIndex, value);\n if (refValue !== undefined) {\n prepared['ref'] = refValue;\n }\n continue;\n }\n\n if (allowMainThreadCapabilities) {\n if (key === 'main-thread:ref') {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n const preparedRef = prepareMTRefForNative(\n spreadValue,\n prevPreparedRecord?.[key],\n prevRawSources?.[key],\n );\n prepared[key] = preparedRef;\n if (preparedRef !== null) {\n (rawSources ??= Object.create(null) as Record<string, unknown>)[key] = spreadValue;\n }\n continue;\n }\n\n if (key === 'main-thread:gesture') {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n const prevGesture = prevPreparedRecord && hasOwnSpreadKey(prevPreparedRecord, key)\n ? prevPreparedRecord[key]\n : undefined;\n prepared[key] = prepareGestureForNative(\n spreadValue,\n isGestureSlotValue(prevGesture) ? prevGesture : undefined,\n ) as unknown as SerializableValue;\n continue;\n }\n\n if (isMainThreadEventPropKey(key)) {\n if (!hasOwnSpreadKey(value, key)) {\n continue;\n }\n if (spreadValue === null || spreadValue === undefined || spreadValue === false) {\n prepared[key] = null;\n continue;\n }\n if (!isMainThreadFunction(spreadValue)) {\n if (__DEV__) {\n lynx.reportError(\n new Error(\n `ElementTemplate main-thread event slot ${handleId}:${attrSlotIndex} (${key}) expects a worklet ctx object.`,\n ),\n );\n }\n prepared[key] = null;\n continue;\n }\n prepared[key] = prepareMTEventCtxForNative(\n spreadValue,\n prevPreparedRecord?.[key],\n prevRawSources?.[key],\n );\n (rawSources ??= Object.create(null) as Record<string, unknown>)[key] = spreadValue;\n continue;\n }\n }\n\n const transformedKey = transformAttrName(key);\n if (isEventPropKey(transformedKey)) {\n prepared[transformedKey] = spreadValue === null || spreadValue === undefined || spreadValue === false\n ? null\n : getEventValue(handleId, attrSlotIndex, key);\n continue;\n }\n\n if (\n spreadValue === undefined\n || transformedKey.endsWith(':ref')\n || transformedKey.endsWith(':gesture')\n || isNamespacedEventPropKey(key)\n || typeof spreadValue === 'function'\n ) {\n continue;\n }\n\n prepared[transformedKey] = spreadValue as SerializableValue;\n }\n\n if (rawSources) {\n spreadRawSources.set(prepared, rawSources);\n }\n\n return prepared;\n}\n\nexport function prepareSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n context?: EtAttrAdapterContext,\n): SerializableValue | null {\n return prepareSpreadAttrSlotImpl(handleId, attrSlotIndex, value, true, context);\n}\n\nexport function prepareTypedSpreadAttrSlot(\n handleId: number,\n attrSlotIndex: number,\n value: unknown,\n): SerializableValue | null {\n return prepareSpreadAttrSlotImpl(handleId, attrSlotIndex, value, false);\n}\n"]}
|
|
@@ -4,8 +4,6 @@ export declare const ElementTemplateUpdateOps: {
|
|
|
4
4
|
readonly insertNode: 3;
|
|
5
5
|
readonly removeNode: 4;
|
|
6
6
|
readonly createTypedElement: 5;
|
|
7
|
-
readonly insertTypedListItem: 6;
|
|
8
|
-
readonly removeTypedListItem: 7;
|
|
9
7
|
readonly updateTypedListItem: 8;
|
|
10
8
|
readonly setMainThreadEvent: 9;
|
|
11
9
|
readonly setMainThreadRef: 10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/element-template/protocol/opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,kBAAkB,EAAE,CAAC;IACrB,mBAAmB,EAAE,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"opcodes.js","sourceRoot":"","sources":["../../../src/element-template/protocol/opcodes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,cAAc,EAAE,CAAC;IACjB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,kBAAkB,EAAE,CAAC;IACrB,mBAAmB,EAAE,CAAC;IACtB,kBAAkB,EAAE,CAAC;IACrB,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,EAAE;CACN,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const ElementTemplateUpdateOps = {\n createTemplate: 1,\n setAttribute: 2,\n insertNode: 3,\n removeNode: 4,\n createTypedElement: 5,\n updateTypedListItem: 8,\n setMainThreadEvent: 9,\n setMainThreadRef: 10,\n setGesture: 11,\n} as const;\n\nexport type ElementTemplateUpdateOp = typeof ElementTemplateUpdateOps[keyof typeof ElementTemplateUpdateOps];\n"]}
|
|
@@ -22,20 +22,11 @@ export interface ElementTemplateHandleRefCommandValue {
|
|
|
22
22
|
}
|
|
23
23
|
export interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {
|
|
24
24
|
type: string;
|
|
25
|
-
platformInfo: Record<string, SerializableValue
|
|
26
|
-
subtreeHandleIds: number[];
|
|
25
|
+
platformInfo: Record<string, SerializableValue> | null;
|
|
26
|
+
subtreeHandleIds: number[] | null;
|
|
27
27
|
}
|
|
28
28
|
export type RuntimeOptionsCommand = Record<string, SerializableValue>;
|
|
29
|
-
export interface TypedListOptionsCommand extends RuntimeOptionsCommand {
|
|
30
|
-
listChildren: UpdateTypedListItemCommand[];
|
|
31
|
-
}
|
|
32
|
-
export interface RuntimeTypedListOptions {
|
|
33
|
-
listChildren: ElementTemplateHandle[];
|
|
34
|
-
}
|
|
35
29
|
export type SerializedRuntimeOptions = Record<string, SerializableValue>;
|
|
36
|
-
export interface SerializedTypedListOptions {
|
|
37
|
-
listChildren: SerializedEtNode[];
|
|
38
|
-
}
|
|
39
30
|
export interface SerializedEtNodeBase {
|
|
40
31
|
attributeSlots?: SerializableValue[] | null;
|
|
41
32
|
childSlots?: SerializedEtNodeChildSlots | null;
|
|
@@ -51,10 +42,8 @@ export interface SerializedTypedNode extends SerializedEtNodeBase {
|
|
|
51
42
|
tag: string;
|
|
52
43
|
attributes?: TypedElementAttributesCommand | null;
|
|
53
44
|
}
|
|
54
|
-
export interface SerializedTypedListNode extends
|
|
45
|
+
export interface SerializedTypedListNode extends SerializedTypedNode {
|
|
55
46
|
tag: 'list';
|
|
56
|
-
attributes?: TypedElementAttributesCommand | null;
|
|
57
|
-
options?: SerializedTypedListOptions | null;
|
|
58
47
|
}
|
|
59
48
|
export type SerializedEtNode = SerializedCompiledNode | SerializedTypedNode | SerializedTypedListNode;
|
|
60
49
|
export interface SerializedPageRoot extends SerializedTypedNode {
|
|
@@ -71,7 +60,8 @@ export type CreateTemplateCommand = [
|
|
|
71
60
|
templateKey: string,
|
|
72
61
|
bundleUrl: string | null | undefined,
|
|
73
62
|
attributeSlots: SerializableValue[] | null | undefined,
|
|
74
|
-
childSlots: ElementTemplateHandleSlotsCommand | null | undefined
|
|
63
|
+
childSlots: ElementTemplateHandleSlotsCommand | null | undefined,
|
|
64
|
+
options: RuntimeOptionsCommand | null
|
|
75
65
|
];
|
|
76
66
|
export type SetAttributeCommand = [
|
|
77
67
|
typeof ElementTemplateUpdateOps.setAttribute,
|
|
@@ -118,26 +108,14 @@ export type CreateTypedElementCommand = [
|
|
|
118
108
|
type: string,
|
|
119
109
|
attributes: TypedElementAttributesCommand | null | undefined,
|
|
120
110
|
childSlots: ElementTemplateHandleSlotsCommand | null | undefined,
|
|
121
|
-
options: RuntimeOptionsCommand |
|
|
122
|
-
];
|
|
123
|
-
export type InsertTypedListItemCommand = [
|
|
124
|
-
typeof ElementTemplateUpdateOps.insertTypedListItem,
|
|
125
|
-
listHandleId: number,
|
|
126
|
-
item: UpdateTypedListItemCommand,
|
|
127
|
-
beforeHandleId: number
|
|
128
|
-
];
|
|
129
|
-
export type RemoveTypedListItemCommand = [
|
|
130
|
-
typeof ElementTemplateUpdateOps.removeTypedListItem,
|
|
131
|
-
listHandleId: number,
|
|
132
|
-
itemHandleId: number,
|
|
133
|
-
removedSubtreeHandleIds: number[]
|
|
111
|
+
options: RuntimeOptionsCommand | null | undefined
|
|
134
112
|
];
|
|
135
|
-
export type
|
|
113
|
+
export type UpdateTypedListItemPatchCommand = [
|
|
136
114
|
typeof ElementTemplateUpdateOps.updateTypedListItem,
|
|
137
115
|
listHandleId: number,
|
|
138
116
|
item: UpdateTypedListItemCommand
|
|
139
117
|
];
|
|
140
|
-
export type ElementTemplateUpdateCommand = CreateTemplateCommand | SetAttributeCommand | SetMainThreadEventCommand | SetMainThreadRefCommand | SetGestureCommand | InsertNodeCommand | RemoveNodeCommand | CreateTypedElementCommand |
|
|
118
|
+
export type ElementTemplateUpdateCommand = CreateTemplateCommand | SetAttributeCommand | SetMainThreadEventCommand | SetMainThreadRefCommand | SetGestureCommand | InsertNodeCommand | RemoveNodeCommand | CreateTypedElementCommand | UpdateTypedListItemPatchCommand;
|
|
141
119
|
export type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];
|
|
142
120
|
export interface ElementTemplateFlushOptions {
|
|
143
121
|
pipelineOptions?: PipelineOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/element-template/protocol/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright 2025 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 type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { ElementTemplateUpdateOps } from './opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from './page.js';\n\nexport type SerializableValue =\n | string\n | number\n | boolean\n | null\n | SerializableValue[]\n | { [key: string]: SerializableValue };\n\nexport type RuntimeOptionValue =\n | SerializableValue\n | FiberElement\n | RuntimeOptionValue[]\n | { [key: string]: RuntimeOptionValue };\n\nexport type RuntimeOptions = Record<string, RuntimeOptionValue>;\n\nexport type RuntimeAttributeSlotValue =\n | SerializableValue\n | ((...args: unknown[]) => unknown)\n | RuntimeAttributeSlotValue[]\n | { [key: string]: RuntimeAttributeSlotValue };\n\nexport type RuntimeTypedElementAttributes = Record<string, RuntimeAttributeSlotValue>;\n\nexport type TypedElementAttributesCommand = Record<string, SerializableValue>;\n\nexport type RuntimeChildSlots = Array<ElementTemplateHandle[] | null | undefined>;\n\nexport type ElementTemplateHandleSlotsCommand = Array<number[] | null | undefined>;\n\nexport type SerializedEtNodeChildSlots = Array<SerializedEtNode[] | null | undefined>;\n\nexport interface ElementTemplateHandleRefCommandValue {\n __etHandleRef: number;\n [key: string]: SerializableValue;\n}\n\nexport interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {\n type: string;\n platformInfo: Record<string, SerializableValue
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/element-template/protocol/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright 2025 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 type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { ElementTemplateUpdateOps } from './opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from './page.js';\n\nexport type SerializableValue =\n | string\n | number\n | boolean\n | null\n | SerializableValue[]\n | { [key: string]: SerializableValue };\n\nexport type RuntimeOptionValue =\n | SerializableValue\n | FiberElement\n | RuntimeOptionValue[]\n | { [key: string]: RuntimeOptionValue };\n\nexport type RuntimeOptions = Record<string, RuntimeOptionValue>;\n\nexport type RuntimeAttributeSlotValue =\n | SerializableValue\n | ((...args: unknown[]) => unknown)\n | RuntimeAttributeSlotValue[]\n | { [key: string]: RuntimeAttributeSlotValue };\n\nexport type RuntimeTypedElementAttributes = Record<string, RuntimeAttributeSlotValue>;\n\nexport type TypedElementAttributesCommand = Record<string, SerializableValue>;\n\nexport type RuntimeChildSlots = Array<ElementTemplateHandle[] | null | undefined>;\n\nexport type ElementTemplateHandleSlotsCommand = Array<number[] | null | undefined>;\n\nexport type SerializedEtNodeChildSlots = Array<SerializedEtNode[] | null | undefined>;\n\nexport interface ElementTemplateHandleRefCommandValue {\n __etHandleRef: number;\n [key: string]: SerializableValue;\n}\n\nexport interface UpdateTypedListItemCommand extends ElementTemplateHandleRefCommandValue {\n type: string;\n platformInfo: Record<string, SerializableValue> | null;\n subtreeHandleIds: number[] | null;\n}\n\nexport type RuntimeOptionsCommand = Record<string, SerializableValue>;\n\nexport type SerializedRuntimeOptions = Record<string, SerializableValue>;\n\nexport interface SerializedEtNodeBase {\n attributeSlots?: SerializableValue[] | null;\n childSlots?: SerializedEtNodeChildSlots | null;\n uid: number;\n options?: SerializedRuntimeOptions | null;\n}\n\nexport interface SerializedCompiledNode extends SerializedEtNodeBase {\n templateKey: string;\n bundleUrl?: string;\n attributeSlots?: SerializableValue[] | null;\n}\n\nexport interface SerializedTypedNode extends SerializedEtNodeBase {\n // Native __SerializeElementTemplate returns typed hosts as { tag, attributes }.\n tag: string;\n attributes?: TypedElementAttributesCommand | null;\n}\n\n// Logical List items are stored in childSlots[0].\n// Options use the same format as other typed nodes.\nexport interface SerializedTypedListNode extends SerializedTypedNode {\n tag: 'list';\n}\n\nexport type SerializedEtNode = SerializedCompiledNode | SerializedTypedNode | SerializedTypedListNode;\n\nexport interface SerializedPageRoot extends SerializedTypedNode {\n tag: typeof ELEMENT_TEMPLATE_PAGE_TYPE;\n uid: typeof ELEMENT_TEMPLATE_PAGE_HANDLE_ID;\n}\n\nexport interface ElementTemplateHydrateCommitContext {\n page: SerializedPageRoot;\n reloadVersion: number;\n}\n\nexport type CreateTemplateCommand = [\n typeof ElementTemplateUpdateOps.createTemplate,\n handleId: number,\n templateKey: string,\n bundleUrl: string | null | undefined,\n attributeSlots: SerializableValue[] | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n // Use null when no options are needed to keep the flat command's arity fixed.\n options: RuntimeOptionsCommand | null,\n];\n\nexport type SetAttributeCommand = [\n typeof ElementTemplateUpdateOps.setAttribute,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadEventCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadEvent,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetGestureCommand = [\n typeof ElementTemplateUpdateOps.setGesture,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type SetMainThreadRefCommand = [\n typeof ElementTemplateUpdateOps.setMainThreadRef,\n targetHandleId: number,\n attrSlotIndex: number,\n value: SerializableValue | null,\n];\n\nexport type InsertNodeCommand = [\n typeof ElementTemplateUpdateOps.insertNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n referenceHandleId: number,\n attachedSubtreeHandleIds: number[] | null,\n];\n\nexport type RemoveNodeCommand = [\n typeof ElementTemplateUpdateOps.removeNode,\n targetHandleId: number,\n childSlotIndex: number,\n childHandleId: number,\n removedSubtreeHandleIds: number[],\n];\n\nexport type CreateTypedElementCommand = [\n typeof ElementTemplateUpdateOps.createTypedElement,\n handleId: number,\n type: string,\n attributes: TypedElementAttributesCommand | null | undefined,\n childSlots: ElementTemplateHandleSlotsCommand | null | undefined,\n options: RuntimeOptionsCommand | null | undefined,\n];\n\nexport type UpdateTypedListItemPatchCommand = [\n typeof ElementTemplateUpdateOps.updateTypedListItem,\n listHandleId: number,\n item: UpdateTypedListItemCommand,\n];\n\nexport type ElementTemplateUpdateCommand =\n | CreateTemplateCommand\n | SetAttributeCommand\n | SetMainThreadEventCommand\n | SetMainThreadRefCommand\n | SetGestureCommand\n | InsertNodeCommand\n | RemoveNodeCommand\n | CreateTypedElementCommand\n | UpdateTypedListItemPatchCommand;\n\n// Commands are transported as a flat stream to match the native update payload.\n// Tuple aliases above define each opcode's shape; this item union preserves the\n// existing flat buffer ergonomics while making command contracts explicit.\nexport type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];\n\nexport interface ElementTemplateFlushOptions {\n pipelineOptions?: PipelineOptions;\n triggerDataUpdated?: boolean;\n emptyPatch?: boolean;\n}\n\nexport interface ElementTemplateUpdateCommitContext {\n ops: ElementTemplateUpdateCommandStream;\n flushOptions: ElementTemplateFlushOptions;\n flowIds?: number[] | undefined;\n isHydration?: boolean | undefined;\n reloadVersion?: number | undefined;\n delayedRunOnMainThreadData?: RunWorkletCtxData[] | undefined;\n}\n"]}
|