@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
|
@@ -5,12 +5,13 @@ import { getAttributeSlotUpdateOp, prepareAttributeSlots as prepareRawAttributeS
|
|
|
5
5
|
import { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } from './commit-context.js';
|
|
6
6
|
import { isElementTemplateHydrated } from './commit-hook.js';
|
|
7
7
|
import { backgroundElementTemplateInstanceManager } from './manager.js';
|
|
8
|
-
import { isDirectOrDeepEqual } from '../../
|
|
8
|
+
import { isDirectOrDeepEqual } from '../../core/deep-equal.js';
|
|
9
9
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
10
10
|
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from '../protocol/page.js';
|
|
11
11
|
import { parseElementTemplateType } from '../protocol/template-type.js';
|
|
12
|
+
import { filterListItemPlatformInfoFromSpread } from '../runtime/list/platform-info.js';
|
|
12
13
|
import { hasMainThreadRefAttrSlot } from '../runtime/template/attr-slot-plan.js';
|
|
13
|
-
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, TYPED_ELEMENT_ATTR_PLAN } from '../runtime/template/typed-attributes.js';
|
|
14
|
+
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, TYPED_ELEMENT_ATTR_PLAN, TYPED_LIST_ATTR_PLAN, } from '../runtime/template/typed-attributes.js';
|
|
14
15
|
function pushOp(...items) {
|
|
15
16
|
globalCommitContext.ops.push(...items);
|
|
16
17
|
}
|
|
@@ -104,7 +105,11 @@ export class BackgroundElementTemplateInstance {
|
|
|
104
105
|
child = child.nextSibling;
|
|
105
106
|
}
|
|
106
107
|
const nativeTemplate = parseElementTemplateType(this.type);
|
|
107
|
-
|
|
108
|
+
// Pass List item platform info to native with the create command for
|
|
109
|
+
// serialization and List diffing.
|
|
110
|
+
pushOp(ElementTemplateUpdateOps.createTemplate, this.instanceId, nativeTemplate.templateKey, nativeTemplate.bundleUrl, this.attributeSlots, serializedSlots, this.listItemPlatformInfo === undefined
|
|
111
|
+
? null
|
|
112
|
+
: { __listItemPlatformInfo: this.listItemPlatformInfo });
|
|
108
113
|
this.isMaterializedOnMainThread = true;
|
|
109
114
|
}
|
|
110
115
|
needsMainThreadCreate() {
|
|
@@ -201,7 +206,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
201
206
|
appendChild(child) {
|
|
202
207
|
this.insertBefore(child, null);
|
|
203
208
|
}
|
|
204
|
-
insertBefore(child, beforeChild
|
|
209
|
+
insertBefore(child, beforeChild) {
|
|
205
210
|
if (beforeChild === child) {
|
|
206
211
|
throw new Error('Cannot insert a node before itself');
|
|
207
212
|
}
|
|
@@ -210,7 +215,13 @@ export class BackgroundElementTemplateInstance {
|
|
|
210
215
|
}
|
|
211
216
|
const previousParent = child.parent;
|
|
212
217
|
if (previousParent) {
|
|
218
|
+
const shouldRecordOldListRemove = previousParent !== this
|
|
219
|
+
&& previousParent instanceof BackgroundListElementTemplateInstance
|
|
220
|
+
&& previousParent.canEmitUpdatePatch();
|
|
213
221
|
previousParent.removeChild(child, true);
|
|
222
|
+
if (shouldRecordOldListRemove) {
|
|
223
|
+
pushOp(ElementTemplateUpdateOps.removeNode, previousParent.instanceId, 0, child.instanceId, EMPTY_REMOVED_SUBTREE_HANDLE_IDS);
|
|
224
|
+
}
|
|
214
225
|
}
|
|
215
226
|
child.parent = this;
|
|
216
227
|
if (beforeChild) {
|
|
@@ -235,7 +246,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
235
246
|
this.lastChild = child;
|
|
236
247
|
child.nextSibling = null;
|
|
237
248
|
}
|
|
238
|
-
if (
|
|
249
|
+
if (!this.canEmitUpdatePatch()) {
|
|
239
250
|
return;
|
|
240
251
|
}
|
|
241
252
|
const beforeId = (beforeChild && beforeChild.__slotIndex === child.__slotIndex) ? beforeChild.instanceId : 0;
|
|
@@ -246,7 +257,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
246
257
|
if (movedMainThreadRefHandleIds !== null
|
|
247
258
|
&& containingListItem
|
|
248
259
|
&& previousParent !== this) {
|
|
249
|
-
notifyListItemSubtreeUpdated(containingListItem);
|
|
260
|
+
notifyListItemSubtreeUpdated(containingListItem, false);
|
|
250
261
|
}
|
|
251
262
|
}
|
|
252
263
|
removeChild(child, silent) {
|
|
@@ -281,7 +292,7 @@ export class BackgroundElementTemplateInstance {
|
|
|
281
292
|
if (canEmitUpdatePatch
|
|
282
293
|
&& containingListItem
|
|
283
294
|
&& collectMainThreadRefSubtreeHandleIds(child) !== null) {
|
|
284
|
-
notifyListItemSubtreeUpdated(containingListItem);
|
|
295
|
+
notifyListItemSubtreeUpdated(containingListItem, false);
|
|
285
296
|
}
|
|
286
297
|
}
|
|
287
298
|
tearDown() {
|
|
@@ -352,10 +363,12 @@ export class BackgroundElementTemplateInstance {
|
|
|
352
363
|
}
|
|
353
364
|
else if (key === '__listItemPlatformInfo') {
|
|
354
365
|
const previous = this.getListItemPlatformInfo();
|
|
355
|
-
|
|
356
|
-
|
|
366
|
+
this.listItemPlatformInfo = value == null
|
|
367
|
+
? undefined
|
|
368
|
+
: filterListItemPlatformInfoFromSpread(value);
|
|
369
|
+
const next = this.getListItemPlatformInfo();
|
|
357
370
|
if (!isDirectOrDeepEqual(previous, next)) {
|
|
358
|
-
notifyListItemSubtreeUpdated(this);
|
|
371
|
+
notifyListItemSubtreeUpdated(this, true);
|
|
359
372
|
}
|
|
360
373
|
}
|
|
361
374
|
else if (key === 'attributeSlots' && Array.isArray(value)) {
|
|
@@ -430,9 +443,9 @@ export function getContainingListItem(instance) {
|
|
|
430
443
|
}
|
|
431
444
|
return undefined;
|
|
432
445
|
}
|
|
433
|
-
function notifyListItemSubtreeUpdated(listItem) {
|
|
446
|
+
function notifyListItemSubtreeUpdated(listItem, isUpdatePlatformInfo) {
|
|
434
447
|
if (listItem.parent instanceof BackgroundListElementTemplateInstance) {
|
|
435
|
-
listItem.parent.
|
|
448
|
+
listItem.parent.emitTypedListItemUpdate(listItem, isUpdatePlatformInfo);
|
|
436
449
|
}
|
|
437
450
|
}
|
|
438
451
|
export class BackgroundTypedElementTemplateInstance extends BackgroundElementTemplateInstance {
|
|
@@ -503,67 +516,56 @@ export class BackgroundListElementTemplateInstance extends BackgroundTypedElemen
|
|
|
503
516
|
constructor() {
|
|
504
517
|
super('list');
|
|
505
518
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
listChildren.push(toUpdateTypedListItemCommand(child));
|
|
511
|
-
child = child.nextSibling;
|
|
519
|
+
emitCreate() {
|
|
520
|
+
// Skip creation and candidate initialization for an existing List.
|
|
521
|
+
if (this.isMaterializedOnMainThread) {
|
|
522
|
+
return;
|
|
512
523
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (!silent) {
|
|
521
|
-
if (previousParent instanceof BackgroundListElementTemplateInstance) {
|
|
522
|
-
previousParent.emitTypedListItemRemove(child, EMPTY_REMOVED_SUBTREE_HANDLE_IDS);
|
|
523
|
-
}
|
|
524
|
-
this.emitTypedListItemInsert(child, beforeChild);
|
|
524
|
+
// The base class emits the List create command with the initial item UIDs
|
|
525
|
+
// in childSlots.
|
|
526
|
+
super.emitCreate();
|
|
527
|
+
// Queue initial ref candidates after the List create command has been
|
|
528
|
+
// emitted.
|
|
529
|
+
if (!this.isMaterializedOnMainThread) {
|
|
530
|
+
return;
|
|
525
531
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
? collectElementTemplateSubtreeHandleIds(child)
|
|
533
|
-
: EMPTY_REMOVED_SUBTREE_HANDLE_IDS;
|
|
534
|
-
this.cleanupDetachedChildForLifetimeRemoval(child, canEmitUpdatePatch);
|
|
535
|
-
this.emitTypedListItemRemove(child, removedSubtreeHandleIds);
|
|
532
|
+
let item = this.firstChild;
|
|
533
|
+
while (item) {
|
|
534
|
+
// Collect main-thread ref candidates separately for each direct item.
|
|
535
|
+
// Passing false sends only ref candidates and leaves platformInfo null.
|
|
536
|
+
pushOp(ElementTemplateUpdateOps.updateTypedListItem, this.instanceId, toUpdateTypedListItemCommand(item, false));
|
|
537
|
+
item = item.nextSibling;
|
|
536
538
|
}
|
|
537
539
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
emitTypedListItemInsert(child, beforeChild) {
|
|
542
|
-
if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
child.emitMainThreadCreateIfNeeded();
|
|
546
|
-
pushOp(ElementTemplateUpdateOps.insertTypedListItem, this.instanceId, toUpdateTypedListItemCommand(child), beforeChild?.instanceId ?? 0);
|
|
540
|
+
getAttributeSlotPlan() {
|
|
541
|
+
return TYPED_LIST_ATTR_PLAN;
|
|
547
542
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
543
|
+
getChildSlotsForCreate() {
|
|
544
|
+
const childSlots = [];
|
|
545
|
+
let child = this.firstChild;
|
|
546
|
+
while (child) {
|
|
547
|
+
// Group child UIDs by their logical slot.
|
|
548
|
+
// Direct List children belong to slot 0, which MTS validates.
|
|
549
|
+
(childSlots[child.__slotIndex] ??= []).push(child.instanceId);
|
|
550
|
+
child = child.nextSibling;
|
|
551
551
|
}
|
|
552
|
-
|
|
552
|
+
return childSlots;
|
|
553
553
|
}
|
|
554
|
-
emitTypedListItemUpdate(child) {
|
|
554
|
+
emitTypedListItemUpdate(child, isUpdatePlatformInfo) {
|
|
555
555
|
if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
pushOp(ElementTemplateUpdateOps.updateTypedListItem, this.instanceId, toUpdateTypedListItemCommand(child));
|
|
558
|
+
pushOp(ElementTemplateUpdateOps.updateTypedListItem, this.instanceId, toUpdateTypedListItemCommand(child, isUpdatePlatformInfo));
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
export function toUpdateTypedListItemCommand(child) {
|
|
561
|
+
export function toUpdateTypedListItemCommand(child, isUpdatePlatformInfo) {
|
|
562
562
|
return {
|
|
563
563
|
__etHandleRef: child.instanceId,
|
|
564
564
|
type: child.type,
|
|
565
|
-
platformInfo: child.getListItemPlatformInfo(),
|
|
566
|
-
subtreeHandleIds:
|
|
565
|
+
platformInfo: isUpdatePlatformInfo ? child.getListItemPlatformInfo() : null,
|
|
566
|
+
subtreeHandleIds: isUpdatePlatformInfo
|
|
567
|
+
? null
|
|
568
|
+
: collectMainThreadRefSubtreeHandleIds(child) ?? [],
|
|
567
569
|
};
|
|
568
570
|
}
|
|
569
571
|
export function collectElementTemplateSubtreeHandleIds(root) {
|
|
@@ -579,6 +581,11 @@ function collectMainThreadRefSubtreeHandleIdsImpl(instance, handles) {
|
|
|
579
581
|
handles ??= [];
|
|
580
582
|
handles.push(instance.instanceId);
|
|
581
583
|
}
|
|
584
|
+
// The List's own ref is collected above. Item refs follow their own
|
|
585
|
+
// materialization and binding lifecycle.
|
|
586
|
+
if (instance instanceof BackgroundListElementTemplateInstance) {
|
|
587
|
+
return handles;
|
|
588
|
+
}
|
|
582
589
|
let child = instance.firstChild;
|
|
583
590
|
while (child) {
|
|
584
591
|
handles = collectMainThreadRefSubtreeHandleIdsImpl(child, handles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../src/element-template/background/instance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,wBAAwB,EACxB,qBAAqB,IAAI,wBAAwB,EACjD,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,yCAAyC,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,+BA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K,CAAC,IAAI,EAAE;KACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sCAAsC,CACpD,IAAuC;IAEvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,0CAA0C,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,IAAuC;IAEvC,OAAO,wCAAwC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,wCAAwC,CAC/C,QAA2C,EAC3C,OAAwB;IAExB,IAAI,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC;IAChC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,wCAAwC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnE,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,0CAA0C,CACjD,QAA2C,EAC3C,OAAiB;IAEjB,IAAI,QAAQ,CAAC,UAAU,KAAK,+BAA+B,EAAE,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC;IAChC,OAAO,KAAK,EAAE,CAAC;QACb,0CAA0C,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,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.\n\nimport {\n getAttributeSlotUpdateOp,\n prepareAttributeSlots as prepareRawAttributeSlots,\n queueRefAttributeSlotUpdates,\n} from './attr-slots.js';\nimport { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } from './commit-context.js';\nimport { isElementTemplateHydrated } from './commit-hook.js';\nimport { backgroundElementTemplateInstanceManager } from './manager.js';\nimport { isDirectOrDeepEqual } from '../../utils.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from '../protocol/page.js';\nimport { parseElementTemplateType } from '../protocol/template-type.js';\nimport type {\n ElementTemplateHandleSlotsCommand,\n ElementTemplateUpdateCommandStream,\n RuntimeOptionsCommand,\n SerializableValue,\n TypedElementAttributesCommand,\n TypedListOptionsCommand,\n UpdateTypedListItemCommand,\n} from '../protocol/types.js';\nimport type { AuthoredPageAttributes } from '../runtime/page/authored-page.js';\nimport { hasMainThreadRefAttrSlot } from '../runtime/template/attr-slot-plan.js';\nimport type { EtAttrPlan } from '../runtime/template/attr-slot-plan.js';\nimport { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, TYPED_ELEMENT_ATTR_PLAN } from '../runtime/template/typed-attributes.js';\n\nfunction pushOp(...items: ElementTemplateUpdateCommandStream): void {\n globalCommitContext.ops.push(...items);\n}\n\nexport const BUILTIN_RAW_TEXT_TEMPLATE_KEY = '_et_builtin_raw_text';\n\nfunction isBuiltinRawTextTemplateKey(type: string): boolean {\n return type === BUILTIN_RAW_TEXT_TEMPLATE_KEY;\n}\n\nfunction stringifyRawTextValue(value: SerializableValue | undefined): string {\n if (typeof value === 'string') {\n return value;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n return '';\n}\n\nconst EMPTY_LIST_ITEM_PLATFORM_INFO: Record<string, SerializableValue> = {};\nconst EMPTY_REMOVED_SUBTREE_HANDLE_IDS: number[] = [];\n\nexport class BackgroundElementTemplateInstance {\n public instanceId: number = 0; // Assigned by manager\n public type: string;\n\n public parent: BackgroundElementTemplateInstance | null = null;\n public firstChild: BackgroundElementTemplateInstance | null = null;\n public lastChild: BackgroundElementTemplateInstance | null = null;\n public nextSibling: BackgroundElementTemplateInstance | null = null;\n public previousSibling: BackgroundElementTemplateInstance | null = null;\n\n public __slotIndex: number = 0;\n\n // Shadow State for Hydration\n public attributeSlots: SerializableValue[];\n private rawAttributeSlots: readonly unknown[] | undefined;\n protected isMaterializedOnMainThread = false;\n private listItemPlatformInfo: Record<string, SerializableValue> | undefined;\n\n get parentNode(): BackgroundElementTemplateInstance | null {\n return this.parent;\n }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n get childNodes(): BackgroundElementTemplateInstance[] {\n const nodes: BackgroundElementTemplateInstance[] = [];\n let child = this.firstChild;\n while (child) {\n nodes.push(child);\n child = child.nextSibling;\n }\n return nodes;\n }\n\n get childSlots(): BackgroundElementTemplateInstance[][] {\n const childSlots: BackgroundElementTemplateInstance[][] = [];\n let child = this.firstChild;\n while (child) {\n (childSlots[child.__slotIndex] ??= []).push(child);\n child = child.nextSibling;\n }\n return childSlots;\n }\n\n public nodeType: number;\n\n constructor(\n type: string,\n initialAttributeSlots?: SerializableValue[],\n ) {\n this.type = type;\n this.nodeType = isBuiltinRawTextTemplateKey(type) ? 3 : 1;\n backgroundElementTemplateInstanceManager.register(this);\n if (initialAttributeSlots) {\n const preparedSlots = prepareRawAttributeSlots(this.type, this.instanceId, initialAttributeSlots);\n this.attributeSlots = preparedSlots;\n if (preparedSlots !== initialAttributeSlots) {\n this.rawAttributeSlots = initialAttributeSlots;\n }\n } else {\n this.attributeSlots = [];\n }\n }\n\n emitCreate(): void {\n if (this.isMaterializedOnMainThread) {\n return;\n }\n if (__DEV__ && this.instanceId === ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));\n return;\n }\n this.restoreManagerRegistration();\n\n // Walk the linked-list children once to build the slot-indexed handle list\n // for the createTemplate op. Going via `this.childSlots` would allocate\n // the full `Instance[][]` intermediate just to throw it away here.\n const serializedSlots: ElementTemplateHandleSlotsCommand = [];\n let child = this.firstChild;\n while (child) {\n (serializedSlots[child.__slotIndex] ??= []).push(child.instanceId);\n child = child.nextSibling;\n }\n const nativeTemplate = parseElementTemplateType(this.type);\n\n pushOp(\n ElementTemplateUpdateOps.createTemplate,\n this.instanceId,\n nativeTemplate.templateKey,\n nativeTemplate.bundleUrl,\n this.attributeSlots,\n serializedSlots,\n );\n this.isMaterializedOnMainThread = true;\n }\n\n private needsMainThreadCreate(): boolean {\n return this.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID && !this.isMaterializedOnMainThread;\n }\n\n protected getAttributeSlotPlan(): EtAttrPlan | undefined {\n return undefined;\n }\n\n private markSubtreeDetachedFromMainThread(): void {\n if (this.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n this.isMaterializedOnMainThread = false;\n }\n let child = this.firstChild;\n while (child) {\n child.markSubtreeDetachedFromMainThread();\n child = child.nextSibling;\n }\n }\n\n releaseDetachedSubtreeFromManager(): void {\n if (this.parent !== null || this.isMaterializedOnMainThread) {\n return;\n }\n this.releaseSubtreeFromManager();\n }\n\n private restoreManagerRegistration(): void {\n const instances = backgroundElementTemplateInstanceManager.values;\n const existing = instances.get(this.instanceId);\n if (existing === this) {\n return;\n }\n if (existing) {\n throw new Error(`ElementTemplate handleId ${this.instanceId} is already bound.`);\n }\n instances.set(this.instanceId, this);\n }\n\n private releaseSubtreeFromManager(): void {\n const instances = backgroundElementTemplateInstanceManager.values;\n if (instances.get(this.instanceId) === this) {\n instances.delete(this.instanceId);\n }\n let child = this.firstChild;\n while (child) {\n child.releaseSubtreeFromManager();\n child = child.nextSibling;\n }\n }\n\n emitMainThreadCreateIfNeeded(): void {\n if (!this.needsMainThreadCreate()) {\n return;\n }\n // New descendants materialize at their own insert boundary, and lifetime\n // removal clears this flag recursively before a subtree is reattached.\n let child = this.firstChild;\n while (child) {\n child.emitMainThreadCreateIfNeeded();\n child = child.nextSibling;\n }\n // An unmaterialized subtree may receive attr updates before it is inserted;\n // prepare here so its materializing insert attaches the latest ref value.\n this.prepareAttributeSlotsForNative();\n this.emitCreate();\n }\n\n protected canEmitUpdatePatch(): boolean {\n return isElementTemplateHydrated() && !this.needsMainThreadCreate();\n }\n\n protected cleanupDetachedChildForLifetimeRemoval(\n child: BackgroundElementTemplateInstance,\n canEmitUpdatePatch: boolean,\n ): void {\n if (canEmitUpdatePatch) {\n child.markSubtreeDetachedFromMainThread();\n // The removed JS object graph may outlive the detach until GC, so keep\n // it pending and tear it down on the Snapshot-aligned delayed boundary.\n markRemovedSubtreeForPostDispatchTeardown(child);\n child.queueRefCleanupForSubtree();\n return;\n }\n\n // Mirrors `shouldQueueRefEffects` in `setAttribute`: pre-hydration\n // commits and post-hydration materialized children publish their refs\n // to user effects. Post-hydration unmaterialized children defer attach\n // to `emitCreate`, which never fires for a subtree torn down before\n // insert — so cleaning up there would emit a spurious detach.\n const refAttachWasPublished = !isElementTemplateHydrated()\n || !child.needsMainThreadCreate();\n if (refAttachWasPublished) {\n // Run before any tearDown below: `tearDown` clears `rawAttributeSlots`,\n // which `queueRefCleanupForSubtree` walks to enqueue the detach.\n child.queueRefCleanupForSubtree();\n }\n if (child.needsMainThreadCreate()) {\n // An unmaterialized subtree has no main-thread registry entry, so it\n // can be released from the background manager without delayed cleanup.\n child.tearDown();\n }\n }\n\n // DOM API for Preact\n appendChild(child: BackgroundElementTemplateInstance): void {\n this.insertBefore(child, null);\n }\n\n insertBefore(\n child: BackgroundElementTemplateInstance,\n beforeChild: BackgroundElementTemplateInstance | null,\n silent?: boolean,\n ): void {\n if (beforeChild === child) {\n throw new Error('Cannot insert a node before itself');\n }\n if (beforeChild && beforeChild.parent !== this) {\n throw new Error('Reference node is not a child of this parent');\n }\n\n const previousParent = child.parent;\n if (previousParent) {\n previousParent.removeChild(child, true);\n }\n\n child.parent = this;\n\n if (beforeChild) {\n child.nextSibling = beforeChild;\n child.previousSibling = beforeChild.previousSibling;\n\n if (beforeChild.previousSibling) {\n beforeChild.previousSibling.nextSibling = child;\n } else {\n this.firstChild = child;\n }\n beforeChild.previousSibling = child;\n } else {\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.previousSibling = this.lastChild;\n } else {\n this.firstChild = child;\n }\n this.lastChild = child;\n child.nextSibling = null;\n }\n\n if (silent || !this.canEmitUpdatePatch()) {\n return;\n }\n\n const beforeId = (beforeChild && beforeChild.__slotIndex === child.__slotIndex) ? beforeChild.instanceId : 0;\n const containingListItem = getContainingListItem(child);\n const movedMainThreadRefHandleIds = collectMainThreadRefSubtreeHandleIds(child);\n child.emitMainThreadCreateIfNeeded();\n pushOp(\n ElementTemplateUpdateOps.insertNode,\n this.instanceId,\n child.__slotIndex,\n child.instanceId,\n beforeId,\n containingListItem ? null : movedMainThreadRefHandleIds,\n );\n if (\n movedMainThreadRefHandleIds !== null\n && containingListItem\n && previousParent !== this\n ) {\n notifyListItemSubtreeUpdated(containingListItem);\n }\n }\n\n removeChild(child: BackgroundElementTemplateInstance, silent?: boolean): void {\n if (child.parent !== this) {\n throw new Error('Node is not a child of this parent');\n }\n\n const containingListItem = getContainingListItem(child);\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n } else {\n this.firstChild = child.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n } else {\n this.lastChild = child.previousSibling;\n }\n\n child.parent = null;\n child.nextSibling = null;\n child.previousSibling = null;\n\n const slotId = child.__slotIndex;\n if (silent) {\n return;\n }\n const canEmitUpdatePatch = this.canEmitUpdatePatch();\n if (canEmitUpdatePatch) {\n pushOp(\n ElementTemplateUpdateOps.removeNode,\n this.instanceId,\n slotId,\n child.instanceId,\n collectElementTemplateSubtreeHandleIds(child),\n );\n }\n this.cleanupDetachedChildForLifetimeRemoval(child, canEmitUpdatePatch);\n if (\n canEmitUpdatePatch\n && containingListItem\n && collectMainThreadRefSubtreeHandleIds(child) !== null\n ) {\n notifyListItemSubtreeUpdated(containingListItem);\n }\n }\n\n tearDown(): void {\n // Recursively tear down children first\n let child = this.firstChild;\n while (child) {\n const next = child.nextSibling;\n child.tearDown();\n child = next;\n }\n\n // Clear references\n this.parent = null;\n this.firstChild = null;\n this.lastChild = null;\n this.previousSibling = null;\n this.nextSibling = null;\n\n this.attributeSlots = [];\n this.rawAttributeSlots = undefined;\n\n // Remove from manager\n if (backgroundElementTemplateInstanceManager.values.get(this.instanceId) === this) {\n backgroundElementTemplateInstanceManager.values.delete(this.instanceId);\n }\n }\n\n queueRefCleanupForSubtree(): void {\n if (this.rawAttributeSlots) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n this.rawAttributeSlots,\n undefined,\n this.getAttributeSlotPlan(),\n );\n }\n\n let child = this.firstChild;\n while (child) {\n child.queueRefCleanupForSubtree();\n child = child.nextSibling;\n }\n }\n\n getRawAttributeSlot(attrSlotIndex: number): unknown {\n return this.rawAttributeSlots?.[attrSlotIndex] ?? this.attributeSlots[attrSlotIndex];\n }\n\n markMaterializedByHydration(): void {\n // Hydration has already registered the stable handle through updateId.\n // Future updates must not emit create for this existing main-thread template.\n this.isMaterializedOnMainThread = true;\n }\n\n prepareAttributeSlotsForNative(options?: { publishRefEffects?: boolean }): void {\n if (!this.rawAttributeSlots) {\n return;\n }\n this.attributeSlots = prepareRawAttributeSlots(\n this.type,\n this.instanceId,\n this.rawAttributeSlots,\n {\n previousPreparedSlots: this.attributeSlots,\n previousRawSlots: this.rawAttributeSlots,\n attributePlan: this.getAttributeSlotPlan(),\n },\n );\n if (options?.publishRefEffects ?? true) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n undefined,\n this.rawAttributeSlots,\n this.getAttributeSlotPlan(),\n );\n }\n }\n\n prepareAttributeSlotsForHydration(): void {\n if (!this.rawAttributeSlots) {\n return;\n }\n // Hydrate only rebinds the selector marker to the stable handle. The ref was\n // already made visible to user effects on the pre-hydration commit path.\n this.prepareAttributeSlotsForNative({\n publishRefEffects: false,\n });\n }\n\n setAttribute(key: string, value: unknown): void {\n if (isBuiltinRawTextTemplateKey(this.type) && (key === '0' || key === 'data')) {\n this.text = String(value);\n } else if (key === '__listItemPlatformInfo') {\n const previous = this.getListItemPlatformInfo();\n const next = value as Record<string, SerializableValue>;\n this.listItemPlatformInfo = next;\n if (!isDirectOrDeepEqual(previous, next)) {\n notifyListItemSubtreeUpdated(this);\n }\n } else if (key === 'attributeSlots' && Array.isArray(value)) {\n const previousSlots = this.attributeSlots;\n const previousRawSlots = this.rawAttributeSlots ?? previousSlots;\n const isHydrated = isElementTemplateHydrated();\n const canEmitUpdatePatch = this.canEmitUpdatePatch();\n // Pre-hydration commits must expose refs to effects, while post-hydration\n // unmaterialized nodes defer ref attach to create emission to avoid dupes.\n const shouldQueueRefEffects = !isHydrated || canEmitUpdatePatch;\n const nextSlots = prepareRawAttributeSlots(\n this.type,\n this.instanceId,\n value,\n {\n previousPreparedSlots: previousSlots,\n previousRawSlots,\n attributePlan: this.getAttributeSlotPlan(),\n },\n );\n if (shouldQueueRefEffects) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n previousRawSlots,\n value,\n this.getAttributeSlotPlan(),\n );\n }\n this.rawAttributeSlots = nextSlots === value ? undefined : value;\n this.attributeSlots = nextSlots;\n if (!canEmitUpdatePatch) {\n return;\n }\n const maxLength = Math.max(previousSlots.length, nextSlots.length);\n for (let slotIndex = 0; slotIndex < maxLength; slotIndex += 1) {\n const previousValue = previousSlots[slotIndex];\n const nextValue = nextSlots[slotIndex];\n if (isDirectOrDeepEqual(previousValue, nextValue)) {\n continue;\n }\n pushOp(\n getAttributeSlotUpdateOp(this.type, slotIndex),\n this.instanceId,\n slotIndex,\n nextValue ?? null,\n );\n }\n }\n }\n\n get text(): string {\n return stringifyRawTextValue(this.attributeSlots[0]);\n }\n set text(value: string) {\n if (!isBuiltinRawTextTemplateKey(this.type)) {\n return;\n }\n const text = String(value);\n if (this.attributeSlots[0] === text) {\n return;\n }\n this.rawAttributeSlots = undefined;\n this.attributeSlots = [text];\n if (!this.canEmitUpdatePatch()) {\n return;\n }\n pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, 0, text);\n }\n\n get data(): string {\n return this.text;\n }\n set data(value: string) {\n this.text = value;\n }\n\n getListItemPlatformInfo(): Record<string, SerializableValue> {\n return this.listItemPlatformInfo ?? EMPTY_LIST_ITEM_PLATFORM_INFO;\n }\n}\n\nexport function getContainingListItem(\n instance: BackgroundElementTemplateInstance,\n): BackgroundElementTemplateInstance | undefined {\n let child: BackgroundElementTemplateInstance = instance;\n let parent = child.parent;\n while (parent) {\n if (parent instanceof BackgroundListElementTemplateInstance) {\n return child;\n }\n child = parent;\n parent = child.parent;\n }\n return undefined;\n}\n\nfunction notifyListItemSubtreeUpdated(\n listItem: BackgroundElementTemplateInstance,\n): void {\n if (listItem.parent instanceof BackgroundListElementTemplateInstance) {\n listItem.parent.notifyLogicalChildUpdated(listItem);\n }\n}\n\nexport class BackgroundTypedElementTemplateInstance extends BackgroundElementTemplateInstance {\n constructor(type: string) {\n super(type);\n this.attributeSlots = [null];\n }\n\n override emitCreate(): void {\n if (this.isMaterializedOnMainThread) {\n return;\n }\n if (__DEV__ && this.instanceId === ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));\n return;\n }\n\n pushOp(\n ElementTemplateUpdateOps.createTypedElement,\n this.instanceId,\n this.type,\n this.getTypedAttributesForCreate(),\n this.getChildSlotsForCreate(),\n this.getRuntimeOptionsForCreate(),\n );\n this.isMaterializedOnMainThread = true;\n }\n\n override setAttribute(key: string, value: unknown): void {\n if (key !== 'attributes') {\n super.setAttribute(key, value);\n return;\n }\n super.setAttribute('attributeSlots', [value]);\n }\n\n protected getTypedAttributesForCreate(): TypedElementAttributesCommand | null {\n return this.attributeSlots[TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX] as TypedElementAttributesCommand | null;\n }\n\n protected override getAttributeSlotPlan(): EtAttrPlan {\n return TYPED_ELEMENT_ATTR_PLAN;\n }\n\n protected getChildSlotsForCreate(): ElementTemplateHandleSlotsCommand | null {\n return null;\n }\n\n protected getRuntimeOptionsForCreate(): RuntimeOptionsCommand | null {\n return null;\n }\n}\n\nexport class BackgroundPageRootInstance extends BackgroundTypedElementTemplateInstance {\n // Preact may render a keyed replacement before running the old Page's cleanup.\n // Only the current helper lifetime may clear the shared root attributes.\n private authoredPageLifetime: object | undefined;\n\n constructor() {\n super(ELEMENT_TEMPLATE_PAGE_TYPE);\n backgroundElementTemplateInstanceManager.registerPageRoot(this);\n this.isMaterializedOnMainThread = true;\n }\n\n setAuthoredPageAttributes(\n lifetime: object,\n attributes: AuthoredPageAttributes,\n ): void {\n this.authoredPageLifetime = lifetime;\n this.setAttribute('attributes', attributes);\n }\n\n clearAuthoredPageAttributes(lifetime: object): void {\n if (this.authoredPageLifetime !== lifetime) {\n return;\n }\n this.authoredPageLifetime = undefined;\n this.setAttribute('attributes', null);\n }\n\n reconcileAuthoredPageAttributesOnHydration(\n mainThreadAttributes: TypedElementAttributesCommand | null,\n ): void {\n const backgroundAttributes = this.attributeSlots[TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX] as\n | TypedElementAttributesCommand\n | null;\n if (isDirectOrDeepEqual(mainThreadAttributes, backgroundAttributes)) {\n return;\n }\n pushOp(\n ElementTemplateUpdateOps.setAttribute,\n this.instanceId,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n backgroundAttributes,\n );\n }\n}\n\nexport class BackgroundListElementTemplateInstance extends BackgroundTypedElementTemplateInstance {\n constructor() {\n super('list');\n }\n\n protected override getRuntimeOptionsForCreate(): TypedListOptionsCommand {\n const listChildren: UpdateTypedListItemCommand[] = [];\n let child = this.firstChild;\n while (child) {\n listChildren.push(toUpdateTypedListItemCommand(child));\n child = child.nextSibling;\n }\n return {\n listChildren,\n };\n }\n\n override insertBefore(\n child: BackgroundElementTemplateInstance,\n beforeChild: BackgroundElementTemplateInstance | null,\n silent?: boolean,\n ): void {\n const previousParent = child.parent;\n super.insertBefore(child, beforeChild, true);\n if (!silent) {\n if (previousParent instanceof BackgroundListElementTemplateInstance) {\n previousParent.emitTypedListItemRemove(child, EMPTY_REMOVED_SUBTREE_HANDLE_IDS);\n }\n this.emitTypedListItemInsert(child, beforeChild);\n }\n }\n\n override removeChild(child: BackgroundElementTemplateInstance, silent?: boolean): void {\n super.removeChild(child, true);\n if (!silent) {\n const canEmitUpdatePatch = this.canEmitUpdatePatch();\n const removedSubtreeHandleIds = canEmitUpdatePatch\n ? collectElementTemplateSubtreeHandleIds(child)\n : EMPTY_REMOVED_SUBTREE_HANDLE_IDS;\n this.cleanupDetachedChildForLifetimeRemoval(child, canEmitUpdatePatch);\n this.emitTypedListItemRemove(child, removedSubtreeHandleIds);\n }\n }\n\n notifyLogicalChildUpdated(child: BackgroundElementTemplateInstance): void {\n this.emitTypedListItemUpdate(child);\n }\n\n private emitTypedListItemInsert(\n child: BackgroundElementTemplateInstance,\n beforeChild: BackgroundElementTemplateInstance | null,\n ): void {\n if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {\n return;\n }\n\n child.emitMainThreadCreateIfNeeded();\n pushOp(\n ElementTemplateUpdateOps.insertTypedListItem,\n this.instanceId,\n toUpdateTypedListItemCommand(child),\n beforeChild?.instanceId ?? 0,\n );\n }\n\n private emitTypedListItemRemove(\n child: BackgroundElementTemplateInstance,\n removedSubtreeHandleIds: number[],\n ): void {\n if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {\n return;\n }\n\n pushOp(\n ElementTemplateUpdateOps.removeTypedListItem,\n this.instanceId,\n child.instanceId,\n removedSubtreeHandleIds,\n );\n }\n\n private emitTypedListItemUpdate(child: BackgroundElementTemplateInstance): void {\n if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {\n return;\n }\n\n pushOp(\n ElementTemplateUpdateOps.updateTypedListItem,\n this.instanceId,\n toUpdateTypedListItemCommand(child),\n );\n }\n}\n\nexport function toUpdateTypedListItemCommand(\n child: BackgroundElementTemplateInstance,\n): UpdateTypedListItemCommand {\n return {\n __etHandleRef: child.instanceId,\n type: child.type,\n platformInfo: child.getListItemPlatformInfo(),\n subtreeHandleIds: collectMainThreadRefSubtreeHandleIds(child) ?? [],\n };\n}\n\nexport function collectElementTemplateSubtreeHandleIds(\n root: BackgroundElementTemplateInstance,\n): number[] {\n const handles: number[] = [];\n collectElementTemplateSubtreeHandleIdsImpl(root, handles);\n return handles;\n}\n\nexport function collectMainThreadRefSubtreeHandleIds(\n root: BackgroundElementTemplateInstance,\n): number[] | null {\n return collectMainThreadRefSubtreeHandleIdsImpl(root, null);\n}\n\nfunction collectMainThreadRefSubtreeHandleIdsImpl(\n instance: BackgroundElementTemplateInstance,\n handles: number[] | null,\n): number[] | null {\n if (hasMainThreadRefAttrSlot(instance.type)) {\n handles ??= [];\n handles.push(instance.instanceId);\n }\n let child = instance.firstChild;\n while (child) {\n handles = collectMainThreadRefSubtreeHandleIdsImpl(child, handles);\n child = child.nextSibling;\n }\n return handles;\n}\n\nfunction collectElementTemplateSubtreeHandleIdsImpl(\n instance: BackgroundElementTemplateInstance,\n handles: number[],\n): void {\n if (instance.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n handles.push(instance.instanceId);\n }\n let child = instance.firstChild;\n while (child) {\n collectElementTemplateSubtreeHandleIdsImpl(child, handles);\n child = child.nextSibling;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../src/element-template/background/instance.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,wBAAwB,EACxB,qBAAqB,IAAI,wBAAwB,EACjD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I,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC;IAChC,OAAO,KAAK,EAAE,CAAC;QACb,0CAA0C,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,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.\n\nimport {\n getAttributeSlotUpdateOp,\n prepareAttributeSlots as prepareRawAttributeSlots,\n queueRefAttributeSlotUpdates,\n} from './attr-slots.js';\nimport { globalCommitContext, markRemovedSubtreeForPostDispatchTeardown } from './commit-context.js';\nimport { isElementTemplateHydrated } from './commit-hook.js';\nimport { backgroundElementTemplateInstanceManager } from './manager.js';\nimport { isDirectOrDeepEqual } from '../../core/deep-equal.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from '../protocol/page.js';\nimport { parseElementTemplateType } from '../protocol/template-type.js';\nimport type {\n ElementTemplateHandleSlotsCommand,\n ElementTemplateUpdateCommandStream,\n RuntimeOptionsCommand,\n SerializableValue,\n TypedElementAttributesCommand,\n UpdateTypedListItemCommand,\n} from '../protocol/types.js';\nimport { filterListItemPlatformInfoFromSpread } from '../runtime/list/platform-info.js';\nimport type { AuthoredPageAttributes } from '../runtime/page/authored-page.js';\nimport { hasMainThreadRefAttrSlot } from '../runtime/template/attr-slot-plan.js';\nimport type { EtAttrPlan } from '../runtime/template/attr-slot-plan.js';\nimport {\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n TYPED_ELEMENT_ATTR_PLAN,\n TYPED_LIST_ATTR_PLAN,\n} from '../runtime/template/typed-attributes.js';\n\nfunction pushOp(...items: ElementTemplateUpdateCommandStream): void {\n globalCommitContext.ops.push(...items);\n}\n\nexport const BUILTIN_RAW_TEXT_TEMPLATE_KEY = '_et_builtin_raw_text';\n\nfunction isBuiltinRawTextTemplateKey(type: string): boolean {\n return type === BUILTIN_RAW_TEXT_TEMPLATE_KEY;\n}\n\nfunction stringifyRawTextValue(value: SerializableValue | undefined): string {\n if (typeof value === 'string') {\n return value;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n return '';\n}\n\nconst EMPTY_LIST_ITEM_PLATFORM_INFO: Record<string, SerializableValue> = {};\nconst EMPTY_REMOVED_SUBTREE_HANDLE_IDS: number[] = [];\n\nexport class BackgroundElementTemplateInstance {\n public instanceId: number = 0; // Assigned by manager\n public type: string;\n\n public parent: BackgroundElementTemplateInstance | null = null;\n public firstChild: BackgroundElementTemplateInstance | null = null;\n public lastChild: BackgroundElementTemplateInstance | null = null;\n public nextSibling: BackgroundElementTemplateInstance | null = null;\n public previousSibling: BackgroundElementTemplateInstance | null = null;\n\n public __slotIndex: number = 0;\n\n // Shadow State for Hydration\n public attributeSlots: SerializableValue[];\n private rawAttributeSlots: readonly unknown[] | undefined;\n protected isMaterializedOnMainThread = false;\n private listItemPlatformInfo: Record<string, SerializableValue> | undefined;\n\n get parentNode(): BackgroundElementTemplateInstance | null {\n return this.parent;\n }\n\n // Preact 11's `removeNode` calls `node.remove()` instead of\n // `parentNode.removeChild(node)`.\n remove(): void {\n this.parentNode?.removeChild(this);\n }\n\n get childNodes(): BackgroundElementTemplateInstance[] {\n const nodes: BackgroundElementTemplateInstance[] = [];\n let child = this.firstChild;\n while (child) {\n nodes.push(child);\n child = child.nextSibling;\n }\n return nodes;\n }\n\n get childSlots(): BackgroundElementTemplateInstance[][] {\n const childSlots: BackgroundElementTemplateInstance[][] = [];\n let child = this.firstChild;\n while (child) {\n (childSlots[child.__slotIndex] ??= []).push(child);\n child = child.nextSibling;\n }\n return childSlots;\n }\n\n public nodeType: number;\n\n constructor(\n type: string,\n initialAttributeSlots?: SerializableValue[],\n ) {\n this.type = type;\n this.nodeType = isBuiltinRawTextTemplateKey(type) ? 3 : 1;\n backgroundElementTemplateInstanceManager.register(this);\n if (initialAttributeSlots) {\n const preparedSlots = prepareRawAttributeSlots(this.type, this.instanceId, initialAttributeSlots);\n this.attributeSlots = preparedSlots;\n if (preparedSlots !== initialAttributeSlots) {\n this.rawAttributeSlots = initialAttributeSlots;\n }\n } else {\n this.attributeSlots = [];\n }\n }\n\n emitCreate(): void {\n if (this.isMaterializedOnMainThread) {\n return;\n }\n if (__DEV__ && this.instanceId === ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));\n return;\n }\n this.restoreManagerRegistration();\n\n // Walk the linked-list children once to build the slot-indexed handle list\n // for the createTemplate op. Going via `this.childSlots` would allocate\n // the full `Instance[][]` intermediate just to throw it away here.\n const serializedSlots: ElementTemplateHandleSlotsCommand = [];\n let child = this.firstChild;\n while (child) {\n (serializedSlots[child.__slotIndex] ??= []).push(child.instanceId);\n child = child.nextSibling;\n }\n const nativeTemplate = parseElementTemplateType(this.type);\n\n // Pass List item platform info to native with the create command for\n // serialization and List diffing.\n pushOp(\n ElementTemplateUpdateOps.createTemplate,\n this.instanceId,\n nativeTemplate.templateKey,\n nativeTemplate.bundleUrl,\n this.attributeSlots,\n serializedSlots,\n this.listItemPlatformInfo === undefined\n ? null\n : { __listItemPlatformInfo: this.listItemPlatformInfo },\n );\n this.isMaterializedOnMainThread = true;\n }\n\n private needsMainThreadCreate(): boolean {\n return this.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID && !this.isMaterializedOnMainThread;\n }\n\n protected getAttributeSlotPlan(): EtAttrPlan | undefined {\n return undefined;\n }\n\n private markSubtreeDetachedFromMainThread(): void {\n if (this.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n this.isMaterializedOnMainThread = false;\n }\n let child = this.firstChild;\n while (child) {\n child.markSubtreeDetachedFromMainThread();\n child = child.nextSibling;\n }\n }\n\n releaseDetachedSubtreeFromManager(): void {\n if (this.parent !== null || this.isMaterializedOnMainThread) {\n return;\n }\n this.releaseSubtreeFromManager();\n }\n\n private restoreManagerRegistration(): void {\n const instances = backgroundElementTemplateInstanceManager.values;\n const existing = instances.get(this.instanceId);\n if (existing === this) {\n return;\n }\n if (existing) {\n throw new Error(`ElementTemplate handleId ${this.instanceId} is already bound.`);\n }\n instances.set(this.instanceId, this);\n }\n\n private releaseSubtreeFromManager(): void {\n const instances = backgroundElementTemplateInstanceManager.values;\n if (instances.get(this.instanceId) === this) {\n instances.delete(this.instanceId);\n }\n let child = this.firstChild;\n while (child) {\n child.releaseSubtreeFromManager();\n child = child.nextSibling;\n }\n }\n\n emitMainThreadCreateIfNeeded(): void {\n if (!this.needsMainThreadCreate()) {\n return;\n }\n // New descendants materialize at their own insert boundary, and lifetime\n // removal clears this flag recursively before a subtree is reattached.\n let child = this.firstChild;\n while (child) {\n child.emitMainThreadCreateIfNeeded();\n child = child.nextSibling;\n }\n // An unmaterialized subtree may receive attr updates before it is inserted;\n // prepare here so its materializing insert attaches the latest ref value.\n this.prepareAttributeSlotsForNative();\n this.emitCreate();\n }\n\n protected canEmitUpdatePatch(): boolean {\n return isElementTemplateHydrated() && !this.needsMainThreadCreate();\n }\n\n protected cleanupDetachedChildForLifetimeRemoval(\n child: BackgroundElementTemplateInstance,\n canEmitUpdatePatch: boolean,\n ): void {\n if (canEmitUpdatePatch) {\n child.markSubtreeDetachedFromMainThread();\n // The removed JS object graph may outlive the detach until GC, so keep\n // it pending and tear it down on the Snapshot-aligned delayed boundary.\n markRemovedSubtreeForPostDispatchTeardown(child);\n child.queueRefCleanupForSubtree();\n return;\n }\n\n // Mirrors `shouldQueueRefEffects` in `setAttribute`: pre-hydration\n // commits and post-hydration materialized children publish their refs\n // to user effects. Post-hydration unmaterialized children defer attach\n // to `emitCreate`, which never fires for a subtree torn down before\n // insert — so cleaning up there would emit a spurious detach.\n const refAttachWasPublished = !isElementTemplateHydrated()\n || !child.needsMainThreadCreate();\n if (refAttachWasPublished) {\n // Run before any tearDown below: `tearDown` clears `rawAttributeSlots`,\n // which `queueRefCleanupForSubtree` walks to enqueue the detach.\n child.queueRefCleanupForSubtree();\n }\n if (child.needsMainThreadCreate()) {\n // An unmaterialized subtree has no main-thread registry entry, so it\n // can be released from the background manager without delayed cleanup.\n child.tearDown();\n }\n }\n\n // DOM API for Preact\n appendChild(child: BackgroundElementTemplateInstance): void {\n this.insertBefore(child, null);\n }\n\n insertBefore(\n child: BackgroundElementTemplateInstance,\n beforeChild: BackgroundElementTemplateInstance | null,\n ): void {\n if (beforeChild === child) {\n throw new Error('Cannot insert a node before itself');\n }\n if (beforeChild && beforeChild.parent !== this) {\n throw new Error('Reference node is not a child of this parent');\n }\n\n const previousParent = child.parent;\n if (previousParent) {\n const shouldRecordOldListRemove = previousParent !== this\n && previousParent instanceof BackgroundListElementTemplateInstance\n && previousParent.canEmitUpdatePatch();\n previousParent.removeChild(child, true);\n if (shouldRecordOldListRemove) {\n pushOp(\n ElementTemplateUpdateOps.removeNode,\n previousParent.instanceId,\n 0,\n child.instanceId,\n EMPTY_REMOVED_SUBTREE_HANDLE_IDS,\n );\n }\n }\n\n child.parent = this;\n\n if (beforeChild) {\n child.nextSibling = beforeChild;\n child.previousSibling = beforeChild.previousSibling;\n\n if (beforeChild.previousSibling) {\n beforeChild.previousSibling.nextSibling = child;\n } else {\n this.firstChild = child;\n }\n beforeChild.previousSibling = child;\n } else {\n if (this.lastChild) {\n this.lastChild.nextSibling = child;\n child.previousSibling = this.lastChild;\n } else {\n this.firstChild = child;\n }\n this.lastChild = child;\n child.nextSibling = null;\n }\n\n if (!this.canEmitUpdatePatch()) {\n return;\n }\n\n const beforeId = (beforeChild && beforeChild.__slotIndex === child.__slotIndex) ? beforeChild.instanceId : 0;\n const containingListItem = getContainingListItem(child);\n const movedMainThreadRefHandleIds = collectMainThreadRefSubtreeHandleIds(child);\n child.emitMainThreadCreateIfNeeded();\n pushOp(\n ElementTemplateUpdateOps.insertNode,\n this.instanceId,\n child.__slotIndex,\n child.instanceId,\n beforeId,\n containingListItem ? null : movedMainThreadRefHandleIds,\n );\n if (\n movedMainThreadRefHandleIds !== null\n && containingListItem\n && previousParent !== this\n ) {\n notifyListItemSubtreeUpdated(containingListItem, false);\n }\n }\n\n removeChild(child: BackgroundElementTemplateInstance, silent?: boolean): void {\n if (child.parent !== this) {\n throw new Error('Node is not a child of this parent');\n }\n\n const containingListItem = getContainingListItem(child);\n\n if (child.previousSibling) {\n child.previousSibling.nextSibling = child.nextSibling;\n } else {\n this.firstChild = child.nextSibling;\n }\n\n if (child.nextSibling) {\n child.nextSibling.previousSibling = child.previousSibling;\n } else {\n this.lastChild = child.previousSibling;\n }\n\n child.parent = null;\n child.nextSibling = null;\n child.previousSibling = null;\n\n const slotId = child.__slotIndex;\n if (silent) {\n return;\n }\n const canEmitUpdatePatch = this.canEmitUpdatePatch();\n if (canEmitUpdatePatch) {\n pushOp(\n ElementTemplateUpdateOps.removeNode,\n this.instanceId,\n slotId,\n child.instanceId,\n collectElementTemplateSubtreeHandleIds(child),\n );\n }\n this.cleanupDetachedChildForLifetimeRemoval(child, canEmitUpdatePatch);\n if (\n canEmitUpdatePatch\n && containingListItem\n && collectMainThreadRefSubtreeHandleIds(child) !== null\n ) {\n notifyListItemSubtreeUpdated(containingListItem, false);\n }\n }\n\n tearDown(): void {\n // Recursively tear down children first\n let child = this.firstChild;\n while (child) {\n const next = child.nextSibling;\n child.tearDown();\n child = next;\n }\n\n // Clear references\n this.parent = null;\n this.firstChild = null;\n this.lastChild = null;\n this.previousSibling = null;\n this.nextSibling = null;\n\n this.attributeSlots = [];\n this.rawAttributeSlots = undefined;\n\n // Remove from manager\n if (backgroundElementTemplateInstanceManager.values.get(this.instanceId) === this) {\n backgroundElementTemplateInstanceManager.values.delete(this.instanceId);\n }\n }\n\n queueRefCleanupForSubtree(): void {\n if (this.rawAttributeSlots) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n this.rawAttributeSlots,\n undefined,\n this.getAttributeSlotPlan(),\n );\n }\n\n let child = this.firstChild;\n while (child) {\n child.queueRefCleanupForSubtree();\n child = child.nextSibling;\n }\n }\n\n getRawAttributeSlot(attrSlotIndex: number): unknown {\n return this.rawAttributeSlots?.[attrSlotIndex] ?? this.attributeSlots[attrSlotIndex];\n }\n\n markMaterializedByHydration(): void {\n // Hydration has already registered the stable handle through updateId.\n // Future updates must not emit create for this existing main-thread template.\n this.isMaterializedOnMainThread = true;\n }\n\n prepareAttributeSlotsForNative(options?: { publishRefEffects?: boolean }): void {\n if (!this.rawAttributeSlots) {\n return;\n }\n this.attributeSlots = prepareRawAttributeSlots(\n this.type,\n this.instanceId,\n this.rawAttributeSlots,\n {\n previousPreparedSlots: this.attributeSlots,\n previousRawSlots: this.rawAttributeSlots,\n attributePlan: this.getAttributeSlotPlan(),\n },\n );\n if (options?.publishRefEffects ?? true) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n undefined,\n this.rawAttributeSlots,\n this.getAttributeSlotPlan(),\n );\n }\n }\n\n prepareAttributeSlotsForHydration(): void {\n if (!this.rawAttributeSlots) {\n return;\n }\n // Hydrate only rebinds the selector marker to the stable handle. The ref was\n // already made visible to user effects on the pre-hydration commit path.\n this.prepareAttributeSlotsForNative({\n publishRefEffects: false,\n });\n }\n\n setAttribute(key: string, value: unknown): void {\n if (isBuiltinRawTextTemplateKey(this.type) && (key === '0' || key === 'data')) {\n this.text = String(value);\n } else if (key === '__listItemPlatformInfo') {\n const previous = this.getListItemPlatformInfo();\n this.listItemPlatformInfo = value == null\n ? undefined\n : filterListItemPlatformInfoFromSpread(\n value as Record<string, SerializableValue>,\n );\n const next = this.getListItemPlatformInfo();\n if (!isDirectOrDeepEqual(previous, next)) {\n notifyListItemSubtreeUpdated(this, true);\n }\n } else if (key === 'attributeSlots' && Array.isArray(value)) {\n const previousSlots = this.attributeSlots;\n const previousRawSlots = this.rawAttributeSlots ?? previousSlots;\n const isHydrated = isElementTemplateHydrated();\n const canEmitUpdatePatch = this.canEmitUpdatePatch();\n // Pre-hydration commits must expose refs to effects, while post-hydration\n // unmaterialized nodes defer ref attach to create emission to avoid dupes.\n const shouldQueueRefEffects = !isHydrated || canEmitUpdatePatch;\n const nextSlots = prepareRawAttributeSlots(\n this.type,\n this.instanceId,\n value,\n {\n previousPreparedSlots: previousSlots,\n previousRawSlots,\n attributePlan: this.getAttributeSlotPlan(),\n },\n );\n if (shouldQueueRefEffects) {\n queueRefAttributeSlotUpdates(\n this.type,\n this,\n previousRawSlots,\n value,\n this.getAttributeSlotPlan(),\n );\n }\n this.rawAttributeSlots = nextSlots === value ? undefined : value;\n this.attributeSlots = nextSlots;\n if (!canEmitUpdatePatch) {\n return;\n }\n const maxLength = Math.max(previousSlots.length, nextSlots.length);\n for (let slotIndex = 0; slotIndex < maxLength; slotIndex += 1) {\n const previousValue = previousSlots[slotIndex];\n const nextValue = nextSlots[slotIndex];\n if (isDirectOrDeepEqual(previousValue, nextValue)) {\n continue;\n }\n pushOp(\n getAttributeSlotUpdateOp(this.type, slotIndex),\n this.instanceId,\n slotIndex,\n nextValue ?? null,\n );\n }\n }\n }\n\n get text(): string {\n return stringifyRawTextValue(this.attributeSlots[0]);\n }\n set text(value: string) {\n if (!isBuiltinRawTextTemplateKey(this.type)) {\n return;\n }\n const text = String(value);\n if (this.attributeSlots[0] === text) {\n return;\n }\n this.rawAttributeSlots = undefined;\n this.attributeSlots = [text];\n if (!this.canEmitUpdatePatch()) {\n return;\n }\n pushOp(ElementTemplateUpdateOps.setAttribute, this.instanceId, 0, text);\n }\n\n get data(): string {\n return this.text;\n }\n set data(value: string) {\n this.text = value;\n }\n\n getListItemPlatformInfo(): Record<string, SerializableValue> {\n return this.listItemPlatformInfo ?? EMPTY_LIST_ITEM_PLATFORM_INFO;\n }\n}\n\nexport function getContainingListItem(\n instance: BackgroundElementTemplateInstance,\n): BackgroundElementTemplateInstance | undefined {\n let child: BackgroundElementTemplateInstance = instance;\n let parent = child.parent;\n while (parent) {\n if (parent instanceof BackgroundListElementTemplateInstance) {\n return child;\n }\n child = parent;\n parent = child.parent;\n }\n return undefined;\n}\n\nfunction notifyListItemSubtreeUpdated(\n listItem: BackgroundElementTemplateInstance,\n isUpdatePlatformInfo: boolean,\n): void {\n if (listItem.parent instanceof BackgroundListElementTemplateInstance) {\n listItem.parent.emitTypedListItemUpdate(listItem, isUpdatePlatformInfo);\n }\n}\n\nexport class BackgroundTypedElementTemplateInstance extends BackgroundElementTemplateInstance {\n constructor(type: string) {\n super(type);\n this.attributeSlots = [null];\n }\n\n override emitCreate(): void {\n if (this.isMaterializedOnMainThread) {\n return;\n }\n if (__DEV__ && this.instanceId === ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n lynx.reportError(new Error('ElementTemplate patch has illegal handleId 0.'));\n return;\n }\n\n pushOp(\n ElementTemplateUpdateOps.createTypedElement,\n this.instanceId,\n this.type,\n this.getTypedAttributesForCreate(),\n this.getChildSlotsForCreate(),\n this.getRuntimeOptionsForCreate(),\n );\n this.isMaterializedOnMainThread = true;\n }\n\n override setAttribute(key: string, value: unknown): void {\n if (key !== 'attributes') {\n super.setAttribute(key, value);\n return;\n }\n super.setAttribute('attributeSlots', [value]);\n }\n\n protected getTypedAttributesForCreate(): TypedElementAttributesCommand | null {\n return this.attributeSlots[TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX] as TypedElementAttributesCommand | null;\n }\n\n protected override getAttributeSlotPlan(): EtAttrPlan {\n return TYPED_ELEMENT_ATTR_PLAN;\n }\n\n protected getChildSlotsForCreate(): ElementTemplateHandleSlotsCommand | null {\n return null;\n }\n\n protected getRuntimeOptionsForCreate(): RuntimeOptionsCommand | null {\n return null;\n }\n}\n\nexport class BackgroundPageRootInstance extends BackgroundTypedElementTemplateInstance {\n // Preact may render a keyed replacement before running the old Page's cleanup.\n // Only the current helper lifetime may clear the shared root attributes.\n private authoredPageLifetime: object | undefined;\n\n constructor() {\n super(ELEMENT_TEMPLATE_PAGE_TYPE);\n backgroundElementTemplateInstanceManager.registerPageRoot(this);\n this.isMaterializedOnMainThread = true;\n }\n\n setAuthoredPageAttributes(\n lifetime: object,\n attributes: AuthoredPageAttributes,\n ): void {\n this.authoredPageLifetime = lifetime;\n this.setAttribute('attributes', attributes);\n }\n\n clearAuthoredPageAttributes(lifetime: object): void {\n if (this.authoredPageLifetime !== lifetime) {\n return;\n }\n this.authoredPageLifetime = undefined;\n this.setAttribute('attributes', null);\n }\n\n reconcileAuthoredPageAttributesOnHydration(\n mainThreadAttributes: TypedElementAttributesCommand | null,\n ): void {\n const backgroundAttributes = this.attributeSlots[TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX] as\n | TypedElementAttributesCommand\n | null;\n if (isDirectOrDeepEqual(mainThreadAttributes, backgroundAttributes)) {\n return;\n }\n pushOp(\n ElementTemplateUpdateOps.setAttribute,\n this.instanceId,\n TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX,\n backgroundAttributes,\n );\n }\n}\n\nexport class BackgroundListElementTemplateInstance extends BackgroundTypedElementTemplateInstance {\n constructor() {\n super('list');\n }\n\n override emitCreate(): void {\n // Skip creation and candidate initialization for an existing List.\n if (this.isMaterializedOnMainThread) {\n return;\n }\n // The base class emits the List create command with the initial item UIDs\n // in childSlots.\n super.emitCreate();\n // Queue initial ref candidates after the List create command has been\n // emitted.\n if (!this.isMaterializedOnMainThread) {\n return;\n }\n let item = this.firstChild;\n while (item) {\n // Collect main-thread ref candidates separately for each direct item.\n // Passing false sends only ref candidates and leaves platformInfo null.\n pushOp(\n ElementTemplateUpdateOps.updateTypedListItem,\n this.instanceId,\n toUpdateTypedListItemCommand(item, false),\n );\n item = item.nextSibling;\n }\n }\n\n protected override getAttributeSlotPlan(): EtAttrPlan {\n return TYPED_LIST_ATTR_PLAN;\n }\n\n protected override getChildSlotsForCreate(): ElementTemplateHandleSlotsCommand {\n const childSlots: ElementTemplateHandleSlotsCommand = [];\n let child = this.firstChild;\n while (child) {\n // Group child UIDs by their logical slot.\n // Direct List children belong to slot 0, which MTS validates.\n (childSlots[child.__slotIndex] ??= []).push(child.instanceId);\n child = child.nextSibling;\n }\n return childSlots;\n }\n\n emitTypedListItemUpdate(child: BackgroundElementTemplateInstance, isUpdatePlatformInfo: boolean): void {\n if (!isElementTemplateHydrated() || !this.isMaterializedOnMainThread) {\n return;\n }\n pushOp(\n ElementTemplateUpdateOps.updateTypedListItem,\n this.instanceId,\n toUpdateTypedListItemCommand(child, isUpdatePlatformInfo),\n );\n }\n}\n\nexport function toUpdateTypedListItemCommand(\n child: BackgroundElementTemplateInstance,\n isUpdatePlatformInfo: boolean,\n): UpdateTypedListItemCommand {\n return {\n __etHandleRef: child.instanceId,\n type: child.type,\n platformInfo: isUpdatePlatformInfo ? child.getListItemPlatformInfo() : null,\n subtreeHandleIds: isUpdatePlatformInfo\n ? null\n : collectMainThreadRefSubtreeHandleIds(child) ?? [],\n };\n}\n\nexport function collectElementTemplateSubtreeHandleIds(\n root: BackgroundElementTemplateInstance,\n): number[] {\n const handles: number[] = [];\n collectElementTemplateSubtreeHandleIdsImpl(root, handles);\n return handles;\n}\n\nexport function collectMainThreadRefSubtreeHandleIds(\n root: BackgroundElementTemplateInstance,\n): number[] | null {\n return collectMainThreadRefSubtreeHandleIdsImpl(root, null);\n}\n\nfunction collectMainThreadRefSubtreeHandleIdsImpl(\n instance: BackgroundElementTemplateInstance,\n handles: number[] | null,\n): number[] | null {\n if (hasMainThreadRefAttrSlot(instance.type)) {\n handles ??= [];\n handles.push(instance.instanceId);\n }\n\n // The List's own ref is collected above. Item refs follow their own\n // materialization and binding lifecycle.\n if (instance instanceof BackgroundListElementTemplateInstance) {\n return handles;\n }\n\n let child = instance.firstChild;\n while (child) {\n handles = collectMainThreadRefSubtreeHandleIdsImpl(child, handles);\n child = child.nextSibling;\n }\n return handles;\n}\n\nfunction collectElementTemplateSubtreeHandleIdsImpl(\n instance: BackgroundElementTemplateInstance,\n handles: number[],\n): void {\n if (instance.instanceId !== ELEMENT_TEMPLATE_PAGE_HANDLE_ID) {\n handles.push(instance.instanceId);\n }\n let child = instance.firstChild;\n while (child) {\n collectElementTemplateSubtreeHandleIdsImpl(child, handles);\n child = child.nextSibling;\n }\n}\n"]}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { options } from 'preact';
|
|
5
|
+
import { lynxQueueMicrotask } from '../../shared/microtask.js';
|
|
5
6
|
import { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';
|
|
6
|
-
import { hook
|
|
7
|
+
import { hook } from '../../shared/utils.js';
|
|
7
8
|
let installed = false;
|
|
8
9
|
let elementTemplateRendering = false;
|
|
9
10
|
let renderGeneration = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-scope.js","sourceRoot":"","sources":["../../../src/element-template/background/render-scope.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"render-scope.js","sourceRoot":"","sources":["../../../src/element-template/background/render-scope.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,wBAAwB,GAAG,KAAK,CAAC;AACrC,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,UAAU,0BAA0B;IACxC,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,wBAAwB,GAAG,KAAK,CAAC;IACjC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,+BAA+B,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,sCAAsC;IACpD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IACD,SAAS,GAAG,IAAI,CAAC;IAEjB,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,kBAAkB,CAAsB,GAAuC,EAAE,GAAG,IAAO;IAClG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACf,IAAI,cAAc,EAAE,CAAC;QACnB,0BAA0B,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B;IACjC,wBAAwB,GAAG,IAAI,CAAC;IAChC,MAAM,UAAU,GAAG,EAAE,gBAAgB,CAAC;IACtC,kBAAkB,CAAC,GAAG,EAAE;QACtB,IAAI,UAAU,KAAK,gBAAgB,EAAE,CAAC;YACpC,wBAAwB,GAAG,KAAK,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { options } from 'preact';\n\nimport { lynxQueueMicrotask } from '../../shared/microtask.js';\nimport { RENDER_COMPONENT, ROOT } from '../../shared/render-constants.js';\nimport { hook } from '../../shared/utils.js';\n\nlet installed = false;\nlet elementTemplateRendering = false;\nlet renderGeneration = 0;\n\nexport function isElementTemplateRendering(): boolean {\n return elementTemplateRendering;\n}\n\nexport function clearElementTemplateRenderScope(): void {\n elementTemplateRendering = false;\n renderGeneration++;\n}\n\nexport function resetElementTemplateRenderScope(): void {\n clearElementTemplateRenderScope();\n}\n\nexport function installElementTemplateRenderScopeHooks(): void {\n if (installed) {\n return;\n }\n installed = true;\n\n hook(options, RENDER_COMPONENT, onPreactRenderHook);\n hook(options, ROOT, onPreactRenderHook);\n}\n\nfunction onPreactRenderHook<T extends unknown[]>(old: ((...args: T) => void) | undefined, ...args: T): void {\n old?.(...args);\n if (__BACKGROUND__) {\n markPreactRenderInProgress();\n }\n}\n\nfunction markPreactRenderInProgress(): void {\n elementTemplateRendering = true;\n const generation = ++renderGeneration;\n lynxQueueMicrotask(() => {\n if (generation === renderGeneration) {\n elementTemplateRendering = false;\n }\n });\n}\n"]}
|
|
@@ -7,6 +7,7 @@ export type FormattedElementTemplateUpdateCommand = {
|
|
|
7
7
|
bundleUrl: string | null | undefined;
|
|
8
8
|
attributeSlots: unknown;
|
|
9
9
|
childSlots: unknown;
|
|
10
|
+
options: unknown;
|
|
10
11
|
} | {
|
|
11
12
|
op: 'createTypedElement';
|
|
12
13
|
handleId: number;
|
|
@@ -24,16 +25,6 @@ export type FormattedElementTemplateUpdateCommand = {
|
|
|
24
25
|
targetId: number;
|
|
25
26
|
attrSlotIndex: number;
|
|
26
27
|
value: unknown;
|
|
27
|
-
} | {
|
|
28
|
-
op: 'insertTypedListItem';
|
|
29
|
-
targetId: number;
|
|
30
|
-
item: unknown;
|
|
31
|
-
beforeId: number;
|
|
32
|
-
} | {
|
|
33
|
-
op: 'removeTypedListItem';
|
|
34
|
-
targetId: number;
|
|
35
|
-
itemId: number;
|
|
36
|
-
removedSubtreeHandleIds: number[];
|
|
37
28
|
} | {
|
|
38
29
|
op: 'updateTypedListItem';
|
|
39
30
|
targetId: number;
|
|
@@ -19,6 +19,7 @@ export function formatElementTemplateUpdateCommands(stream) {
|
|
|
19
19
|
bundleUrl: stream[index++],
|
|
20
20
|
attributeSlots: stream[index++],
|
|
21
21
|
childSlots: stream[index++],
|
|
22
|
+
options: stream[index++],
|
|
22
23
|
});
|
|
23
24
|
break;
|
|
24
25
|
}
|
|
@@ -54,22 +55,6 @@ export function formatElementTemplateUpdateCommands(stream) {
|
|
|
54
55
|
options: stream[index++],
|
|
55
56
|
});
|
|
56
57
|
break;
|
|
57
|
-
case ElementTemplateUpdateOps.insertTypedListItem:
|
|
58
|
-
result.push({
|
|
59
|
-
op: 'insertTypedListItem',
|
|
60
|
-
targetId: stream[index++],
|
|
61
|
-
item: stream[index++],
|
|
62
|
-
beforeId: stream[index++],
|
|
63
|
-
});
|
|
64
|
-
break;
|
|
65
|
-
case ElementTemplateUpdateOps.removeTypedListItem:
|
|
66
|
-
result.push({
|
|
67
|
-
op: 'removeTypedListItem',
|
|
68
|
-
targetId: stream[index++],
|
|
69
|
-
itemId: stream[index++],
|
|
70
|
-
removedSubtreeHandleIds: stream[index++],
|
|
71
|
-
});
|
|
72
|
-
break;
|
|
73
58
|
case ElementTemplateUpdateOps.updateTypedListItem:
|
|
74
59
|
result.push({
|
|
75
60
|
op: 'updateTypedListItem',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alog.js","sourceRoot":"","sources":["../../../src/element-template/debug/alog.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAwElE,MAAM,UAAU,mCAAmC,CACjD,MAAsD;IAEtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAA4C,EAAE,CAAC;IAC3D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;Q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GAAG,QAAQ,CAAC,UAAU,CAAC;IAChC,OAAO,KAAK,EAAE,CAAC;QACb,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;IAC5B,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 type { BackgroundElementTemplateInstance } from '../background/instance.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateOp } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';\n\nexport type FormattedElementTemplateUpdateCommand =\n | {\n op: 'createTemplate';\n handleId: number;\n templateKey: string;\n bundleUrl: string | null | undefined;\n attributeSlots: unknown;\n childSlots: unknown;\n }\n | {\n op: 'createTypedElement';\n handleId: number;\n type: string;\n attributes: unknown;\n childSlots: unknown;\n options: unknown;\n }\n | {\n op: 'setAttribute';\n targetId: number;\n attrSlotIndex: number;\n value: unknown;\n }\n | {\n op: 'setMainThreadEvent' | 'setMainThreadRef' | 'setGesture';\n targetId: number;\n attrSlotIndex: number;\n value: unknown;\n }\n | {\n op: 'insertTypedListItem';\n targetId: number;\n item: unknown;\n beforeId: number;\n }\n | {\n op: 'removeTypedListItem';\n targetId: number;\n itemId: number;\n removedSubtreeHandleIds: number[];\n }\n | {\n op: 'updateTypedListItem';\n targetId: number;\n item: unknown;\n }\n | {\n op: 'insertNode';\n targetId: number;\n childSlotIndex: number;\n childId: number;\n referenceId: number;\n attachedSubtreeHandleIds: number[] | null;\n }\n | {\n op: 'removeNode';\n targetId: number;\n childSlotIndex: number;\n childId: number;\n removedSubtreeHandleIds: number[];\n }\n | {\n op: 'unknown';\n opcode: unknown;\n index: number;\n remaining: unknown[];\n };\n\nexport function formatElementTemplateUpdateCommands(\n stream: ElementTemplateUpdateCommandStream | undefined,\n): FormattedElementTemplateUpdateCommand[] {\n if (!Array.isArray(stream)) {\n return [];\n }\n\n const result: FormattedElementTemplateUpdateCommand[] = [];\n for (let index = 0; index < stream.length;) {\n const opIndex = index;\n const op = stream[index++] as ElementTemplateUpdateOp;\n\n switch (op) {\n case ElementTemplateUpdateOps.createTemplate: {\n result.push({\n op: 'createTemplate',\n handleId: stream[index++] as number,\n templateKey: stream[index++] as string,\n bundleUrl: stream[index++] as string | null | undefined,\n attributeSlots: stream[index++],\n childSlots: stream[index++],\n });\n break;\n }\n\n case ElementTemplateUpdateOps.setAttribute:\n result.push({\n op: 'setAttribute',\n targetId: stream[index++] as number,\n attrSlotIndex: stream[index++] as number,\n value: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.setMainThreadEvent:\n case ElementTemplateUpdateOps.setMainThreadRef:\n case ElementTemplateUpdateOps.setGesture:\n result.push({\n op: op === ElementTemplateUpdateOps.setMainThreadEvent\n ? 'setMainThreadEvent'\n : (op === ElementTemplateUpdateOps.setMainThreadRef\n ? 'setMainThreadRef'\n : 'setGesture'),\n targetId: stream[index++] as number,\n attrSlotIndex: stream[index++] as number,\n value: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.createTypedElement:\n result.push({\n op: 'createTypedElement',\n handleId: stream[index++] as number,\n type: stream[index++] as string,\n attributes: stream[index++],\n childSlots: stream[index++],\n options: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.insertTypedListItem:\n result.push({\n op: 'insertTypedListItem',\n targetId: stream[index++] as number,\n item: stream[index++],\n beforeId: stream[index++] as number,\n });\n break;\n\n case ElementTemplateUpdateOps.removeTypedListItem:\n result.push({\n op: 'removeTypedListItem',\n targetId: stream[index++] as number,\n itemId: stream[index++] as number,\n removedSubtreeHandleIds: stream[index++] as number[],\n });\n break;\n\n case ElementTemplateUpdateOps.updateTypedListItem:\n result.push({\n op: 'updateTypedListItem',\n targetId: stream[index++] as number,\n item: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.insertNode:\n result.push({\n op: 'insertNode',\n targetId: stream[index++] as number,\n childSlotIndex: stream[index++] as number,\n childId: stream[index++] as number,\n referenceId: stream[index++] as number,\n attachedSubtreeHandleIds: stream[index++] as number[] | null,\n });\n break;\n\n case ElementTemplateUpdateOps.removeNode:\n result.push({\n op: 'removeNode',\n targetId: stream[index++] as number,\n childSlotIndex: stream[index++] as number,\n childId: stream[index++] as number,\n removedSubtreeHandleIds: stream[index++] as number[],\n });\n break;\n\n default:\n result.push({\n op: 'unknown',\n opcode: op,\n index: opIndex,\n remaining: stream.slice(index),\n });\n index = stream.length;\n break;\n }\n }\n return result;\n}\n\nexport function printElementTemplateTreeToString(\n root: BackgroundElementTemplateInstance | null | undefined,\n): string {\n if (!root) {\n return '<empty>';\n }\n\n const lines: string[] = [];\n appendInstance(lines, root, 0);\n return lines.join('\\n');\n}\n\nfunction appendInstance(\n lines: string[],\n instance: BackgroundElementTemplateInstance,\n depth: number,\n): void {\n const indent = ' '.repeat(depth);\n const type = instance.type ?? '<unknown>';\n const instanceId = instance.instanceId ?? '<unknown>';\n lines.push(`${indent}${type}#${instanceId}`);\n\n if (Array.isArray(instance.attributeSlots) && instance.attributeSlots.length > 0) {\n lines.push(`${indent} attributeSlots: ${JSON.stringify(instance.attributeSlots)}`);\n }\n\n const childSlots = Array.isArray(instance.childSlots) ? instance.childSlots : [];\n for (let slotIndex = 0; slotIndex < childSlots.length; slotIndex += 1) {\n const children = childSlots[slotIndex];\n if (!children || children.length === 0) {\n continue;\n }\n lines.push(\n `${indent} childSlots[${slotIndex}]: [${children.map(child => child.instanceId).join(', ')}]`,\n );\n }\n\n let child = instance.firstChild;\n while (child) {\n appendInstance(lines, child, depth + 1);\n child = child.nextSibling;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"alog.js","sourceRoot":"","sources":["../../../src/element-template/debug/alog.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG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,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 type { BackgroundElementTemplateInstance } from '../background/instance.js';\nimport { ElementTemplateUpdateOps } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateOp } from '../protocol/opcodes.js';\nimport type { ElementTemplateUpdateCommandStream } from '../protocol/types.js';\n\nexport type FormattedElementTemplateUpdateCommand =\n | {\n op: 'createTemplate';\n handleId: number;\n templateKey: string;\n bundleUrl: string | null | undefined;\n attributeSlots: unknown;\n childSlots: unknown;\n options: unknown;\n }\n | {\n op: 'createTypedElement';\n handleId: number;\n type: string;\n attributes: unknown;\n childSlots: unknown;\n options: unknown;\n }\n | {\n op: 'setAttribute';\n targetId: number;\n attrSlotIndex: number;\n value: unknown;\n }\n | {\n op: 'setMainThreadEvent' | 'setMainThreadRef' | 'setGesture';\n targetId: number;\n attrSlotIndex: number;\n value: unknown;\n }\n | {\n op: 'updateTypedListItem';\n targetId: number;\n item: unknown;\n }\n | {\n op: 'insertNode';\n targetId: number;\n childSlotIndex: number;\n childId: number;\n referenceId: number;\n attachedSubtreeHandleIds: number[] | null;\n }\n | {\n op: 'removeNode';\n targetId: number;\n childSlotIndex: number;\n childId: number;\n removedSubtreeHandleIds: number[];\n }\n | {\n op: 'unknown';\n opcode: unknown;\n index: number;\n remaining: unknown[];\n };\n\nexport function formatElementTemplateUpdateCommands(\n stream: ElementTemplateUpdateCommandStream | undefined,\n): FormattedElementTemplateUpdateCommand[] {\n if (!Array.isArray(stream)) {\n return [];\n }\n\n const result: FormattedElementTemplateUpdateCommand[] = [];\n for (let index = 0; index < stream.length;) {\n const opIndex = index;\n const op = stream[index++] as ElementTemplateUpdateOp;\n\n switch (op) {\n case ElementTemplateUpdateOps.createTemplate: {\n result.push({\n op: 'createTemplate',\n handleId: stream[index++] as number,\n templateKey: stream[index++] as string,\n bundleUrl: stream[index++] as string | null | undefined,\n attributeSlots: stream[index++],\n childSlots: stream[index++],\n options: stream[index++],\n });\n break;\n }\n\n case ElementTemplateUpdateOps.setAttribute:\n result.push({\n op: 'setAttribute',\n targetId: stream[index++] as number,\n attrSlotIndex: stream[index++] as number,\n value: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.setMainThreadEvent:\n case ElementTemplateUpdateOps.setMainThreadRef:\n case ElementTemplateUpdateOps.setGesture:\n result.push({\n op: op === ElementTemplateUpdateOps.setMainThreadEvent\n ? 'setMainThreadEvent'\n : (op === ElementTemplateUpdateOps.setMainThreadRef\n ? 'setMainThreadRef'\n : 'setGesture'),\n targetId: stream[index++] as number,\n attrSlotIndex: stream[index++] as number,\n value: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.createTypedElement:\n result.push({\n op: 'createTypedElement',\n handleId: stream[index++] as number,\n type: stream[index++] as string,\n attributes: stream[index++],\n childSlots: stream[index++],\n options: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.updateTypedListItem:\n result.push({\n op: 'updateTypedListItem',\n targetId: stream[index++] as number,\n item: stream[index++],\n });\n break;\n\n case ElementTemplateUpdateOps.insertNode:\n result.push({\n op: 'insertNode',\n targetId: stream[index++] as number,\n childSlotIndex: stream[index++] as number,\n childId: stream[index++] as number,\n referenceId: stream[index++] as number,\n attachedSubtreeHandleIds: stream[index++] as number[] | null,\n });\n break;\n\n case ElementTemplateUpdateOps.removeNode:\n result.push({\n op: 'removeNode',\n targetId: stream[index++] as number,\n childSlotIndex: stream[index++] as number,\n childId: stream[index++] as number,\n removedSubtreeHandleIds: stream[index++] as number[],\n });\n break;\n\n default:\n result.push({\n op: 'unknown',\n opcode: op,\n index: opIndex,\n remaining: stream.slice(index),\n });\n index = stream.length;\n break;\n }\n }\n return result;\n}\n\nexport function printElementTemplateTreeToString(\n root: BackgroundElementTemplateInstance | null | undefined,\n): string {\n if (!root) {\n return '<empty>';\n }\n\n const lines: string[] = [];\n appendInstance(lines, root, 0);\n return lines.join('\\n');\n}\n\nfunction appendInstance(\n lines: string[],\n instance: BackgroundElementTemplateInstance,\n depth: number,\n): void {\n const indent = ' '.repeat(depth);\n const type = instance.type ?? '<unknown>';\n const instanceId = instance.instanceId ?? '<unknown>';\n lines.push(`${indent}${type}#${instanceId}`);\n\n if (Array.isArray(instance.attributeSlots) && instance.attributeSlots.length > 0) {\n lines.push(`${indent} attributeSlots: ${JSON.stringify(instance.attributeSlots)}`);\n }\n\n const childSlots = Array.isArray(instance.childSlots) ? instance.childSlots : [];\n for (let slotIndex = 0; slotIndex < childSlots.length; slotIndex += 1) {\n const children = childSlots[slotIndex];\n if (!children || children.length === 0) {\n continue;\n }\n lines.push(\n `${indent} childSlots[${slotIndex}]: [${children.map(child => child.instanceId).join(', ')}]`,\n );\n }\n\n let child = instance.firstChild;\n while (child) {\n appendInstance(lines, child, depth + 1);\n child = child.nextSibling;\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Component, options } from 'preact';
|
|
5
5
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
6
6
|
import { BITS, COMMIT, COMPONENT, COMPONENT_DIRTY, DIFF, DIFF2, DIFFED, NEXT_STATE, RENDER, } from '../../shared/render-constants.js';
|
|
7
|
-
import { getDisplayName } from '../../utils.js';
|
|
7
|
+
import { getDisplayName } from '../../shared/utils.js';
|
|
8
8
|
import { globalCommitContext } from '../background/commit-context.js';
|
|
9
9
|
let installed = false;
|
|
10
10
|
export { profileEnd, profileStart };
|