@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
|
@@ -4917,6 +4917,115 @@ describe('destroy list after element transfer', () => {
|
|
|
4917
4917
|
});
|
|
4918
4918
|
});
|
|
4919
4919
|
|
|
4920
|
+
describe('nested list element ownership after outer row reuse', () => {
|
|
4921
|
+
function createRows() {
|
|
4922
|
+
const listSnapshot = __SNAPSHOT__(<list>{HOLE}</list>);
|
|
4923
|
+
const rowSnapshot = __SNAPSHOT__(<list-item item-key={HOLE} reuse-identifier='row'>{HOLE}</list-item>);
|
|
4924
|
+
const cellSnapshot = __SNAPSHOT__(
|
|
4925
|
+
<list-item item-key={HOLE}>
|
|
4926
|
+
<raw-text text={HOLE} />
|
|
4927
|
+
</list-item>,
|
|
4928
|
+
);
|
|
4929
|
+
const outer = new SnapshotInstance(listSnapshot);
|
|
4930
|
+
const rows = [0, 1].map((index) => {
|
|
4931
|
+
const row = new SnapshotInstance(rowSnapshot);
|
|
4932
|
+
row.setAttribute(0, { 'item-key': `row-${index}` });
|
|
4933
|
+
const inner = new SnapshotInstance(listSnapshot);
|
|
4934
|
+
const cell = new SnapshotInstance(cellSnapshot);
|
|
4935
|
+
cell.setAttribute(0, { 'item-key': `cell-${index}` });
|
|
4936
|
+
cell.setAttribute(1, `cell-${index}`);
|
|
4937
|
+
inner.insertBefore(cell);
|
|
4938
|
+
row.insertBefore(inner);
|
|
4939
|
+
outer.insertBefore(row);
|
|
4940
|
+
return { inner, cell };
|
|
4941
|
+
});
|
|
4942
|
+
outer.ensureElements();
|
|
4943
|
+
return { outerList: outer.__element_root, row0: rows[0], row1: rows[1] };
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
const show = (list, index) => elementTree.triggerComponentAtIndex(list, index);
|
|
4947
|
+
const recycle = (list, sign) => elementTree.triggerEnqueueComponent(list, sign);
|
|
4948
|
+
const text = (element) => __GetAttributeByName(element.children[0], 'text');
|
|
4949
|
+
|
|
4950
|
+
it('redirects the old recycle-pool entry to the copy that keeps the old element', () => {
|
|
4951
|
+
const { outerList, row0, row1 } = createRows();
|
|
4952
|
+
const cell0Instance = row0.cell;
|
|
4953
|
+
const oldRowSign = show(outerList, 0);
|
|
4954
|
+
const oldInnerList = row0.inner.__element_root;
|
|
4955
|
+
const oldCellSign = show(oldInnerList, 0);
|
|
4956
|
+
const oldCellElement = cell0Instance.__element_root;
|
|
4957
|
+
expect(text(oldCellElement)).toBe('cell-0');
|
|
4958
|
+
|
|
4959
|
+
recycle(outerList, oldRowSign);
|
|
4960
|
+
expect(show(outerList, 1)).toBe(oldRowSign);
|
|
4961
|
+
expect(row1.inner.__element_root).toBe(oldInnerList);
|
|
4962
|
+
recycle(oldInnerList, oldCellSign);
|
|
4963
|
+
const oldCellPool = gRecycleMap[__GetElementUniqueID(oldInnerList)].get(cell0Instance.type);
|
|
4964
|
+
expect(oldCellPool.get(oldCellSign)).toBe(cell0Instance);
|
|
4965
|
+
expect(cell0Instance.__element_root).toBe(oldCellElement);
|
|
4966
|
+
|
|
4967
|
+
expect(show(outerList, 0)).not.toBe(oldRowSign);
|
|
4968
|
+
expect(row0.inner.__element_root).not.toBe(oldInnerList);
|
|
4969
|
+
const newCellSign = show(row0.inner.__element_root, 0);
|
|
4970
|
+
const newCellElement = cell0Instance.__element_root;
|
|
4971
|
+
expect(newCellSign).toBe(__GetElementUniqueID(newCellElement));
|
|
4972
|
+
expect(newCellSign).not.toBe(oldCellSign);
|
|
4973
|
+
expect(newCellElement).not.toBe(oldCellElement);
|
|
4974
|
+
expect(text(newCellElement)).toBe('cell-0');
|
|
4975
|
+
|
|
4976
|
+
const recycledCellInstance = oldCellPool.get(oldCellSign);
|
|
4977
|
+
expect(
|
|
4978
|
+
recycledCellInstance === cell0Instance,
|
|
4979
|
+
'the old recycle-pool entry must stop pointing at the logical cell that now owns a new element',
|
|
4980
|
+
).toBe(false);
|
|
4981
|
+
expect(recycledCellInstance.__element_root).toBe(oldCellElement);
|
|
4982
|
+
expect(cell0Instance.__element_root).toBe(newCellElement);
|
|
4983
|
+
|
|
4984
|
+
expect(show(oldInnerList, 0)).toBe(oldCellSign);
|
|
4985
|
+
expect(row1.cell.__element_root).toBe(oldCellElement);
|
|
4986
|
+
expect(text(oldCellElement)).toBe('cell-1');
|
|
4987
|
+
expect(cell0Instance.__element_root).toBe(newCellElement);
|
|
4988
|
+
expect(text(newCellElement)).toBe('cell-0');
|
|
4989
|
+
});
|
|
4990
|
+
|
|
4991
|
+
it('uses the redirected sign-map entry when the old cell is enqueued after element transfer', () => {
|
|
4992
|
+
const { outerList, row0, row1 } = createRows();
|
|
4993
|
+
const cell0Instance = row0.cell;
|
|
4994
|
+
const oldRowSign = show(outerList, 0);
|
|
4995
|
+
const oldInnerList = row0.inner.__element_root;
|
|
4996
|
+
const oldCellSign = show(oldInnerList, 0);
|
|
4997
|
+
const oldCellElement = cell0Instance.__element_root;
|
|
4998
|
+
const oldSignMap = gSignMap[__GetElementUniqueID(oldInnerList)];
|
|
4999
|
+
expect(oldSignMap.get(oldCellSign)).toBe(cell0Instance);
|
|
5000
|
+
|
|
5001
|
+
recycle(outerList, oldRowSign);
|
|
5002
|
+
expect(show(outerList, 1)).toBe(oldRowSign);
|
|
5003
|
+
expect(row1.inner.__element_root).toBe(oldInnerList);
|
|
5004
|
+
expect(show(outerList, 0)).not.toBe(oldRowSign);
|
|
5005
|
+
const newCellSign = show(row0.inner.__element_root, 0);
|
|
5006
|
+
const newCellElement = cell0Instance.__element_root;
|
|
5007
|
+
expect(newCellSign).toBe(__GetElementUniqueID(newCellElement));
|
|
5008
|
+
expect(newCellSign).not.toBe(oldCellSign);
|
|
5009
|
+
|
|
5010
|
+
const transferredCellInstance = oldSignMap.get(oldCellSign);
|
|
5011
|
+
expect(
|
|
5012
|
+
transferredCellInstance === cell0Instance,
|
|
5013
|
+
'a delayed enqueue must find the copy holding the old element in the old sign map',
|
|
5014
|
+
).toBe(false);
|
|
5015
|
+
expect(transferredCellInstance.__element_root).toBe(oldCellElement);
|
|
5016
|
+
expect(cell0Instance.__element_root).toBe(newCellElement);
|
|
5017
|
+
|
|
5018
|
+
recycle(oldInnerList, oldCellSign);
|
|
5019
|
+
const recycledInstances = [...gRecycleMap[__GetElementUniqueID(oldInnerList)].values()]
|
|
5020
|
+
.flatMap(pool => [...pool.values()]);
|
|
5021
|
+
expect(recycledInstances).toContain(transferredCellInstance);
|
|
5022
|
+
expect(recycledInstances).not.toContain(cell0Instance);
|
|
5023
|
+
expect(transferredCellInstance.__element_root).toBe(oldCellElement);
|
|
5024
|
+
expect(cell0Instance.__element_root).toBe(newCellElement);
|
|
5025
|
+
expect(text(newCellElement)).toBe('cell-0');
|
|
5026
|
+
});
|
|
5027
|
+
});
|
|
5028
|
+
|
|
4920
5029
|
describe('list worklet ref lifecycle', () => {
|
|
4921
5030
|
it('unrefs worklet refs when a list child is logically removed', () => {
|
|
4922
5031
|
const listSnapshot = __SNAPSHOT__(<list>{HOLE}</list>);
|
|
@@ -13,7 +13,7 @@ describe('lynxQueueMicrotask', () => {
|
|
|
13
13
|
const mockFn = vi.fn();
|
|
14
14
|
vi.stubGlobal('lynx', { queueMicrotask: vi.fn(fn => Promise.resolve().then(fn)) });
|
|
15
15
|
|
|
16
|
-
const { lynxQueueMicrotask } = await import('../../src/
|
|
16
|
+
const { lynxQueueMicrotask } = await import('../../src/shared/microtask');
|
|
17
17
|
lynxQueueMicrotask(mockFn);
|
|
18
18
|
|
|
19
19
|
expect(lynx.queueMicrotask).toHaveBeenCalled();
|
|
@@ -27,7 +27,7 @@ describe('lynxQueueMicrotask', () => {
|
|
|
27
27
|
const mockFn = vi.fn();
|
|
28
28
|
vi.stubGlobal('lynx', {});
|
|
29
29
|
|
|
30
|
-
const { lynxQueueMicrotask } = await import('../../src/
|
|
30
|
+
const { lynxQueueMicrotask } = await import('../../src/shared/microtask');
|
|
31
31
|
lynxQueueMicrotask(mockFn);
|
|
32
32
|
|
|
33
33
|
expect(mockFn).not.toHaveBeenCalled();
|
|
@@ -8,8 +8,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vite
|
|
|
8
8
|
|
|
9
9
|
import { RefProxy, runDelayedUiOps, shouldDelayUiOps } from '../../src/snapshot/lifecycle/ref/delay';
|
|
10
10
|
import { destroyBackground } from '../../src/snapshot/lifecycle/destroy';
|
|
11
|
+
import { reloadBackground } from '../../src/snapshot/lifecycle/reload';
|
|
11
12
|
|
|
12
|
-
import { Component, createRef, useState } from '../../src/index';
|
|
13
|
+
import { Component, createPortal, createRef, useState } from '../../src/index';
|
|
13
14
|
import { clearCommitTaskId, replaceCommitHook } from '../../src/snapshot/lifecycle/patch/commit';
|
|
14
15
|
import { injectUpdateMainThread } from '../../src/snapshot/lifecycle/patch/updateMainThread';
|
|
15
16
|
import { __pendingListUpdates } from '../../src/snapshot/list/pendingListUpdates';
|
|
@@ -1661,6 +1662,7 @@ describe('ui operations', () => {
|
|
|
1661
1662
|
"invoke",
|
|
1662
1663
|
[
|
|
1663
1664
|
{
|
|
1665
|
+
"fail": [Function],
|
|
1664
1666
|
"method": "boundingClientRect",
|
|
1665
1667
|
},
|
|
1666
1668
|
],
|
|
@@ -1904,6 +1906,7 @@ describe('ui operations', () => {
|
|
|
1904
1906
|
"invoke",
|
|
1905
1907
|
[
|
|
1906
1908
|
{
|
|
1909
|
+
"fail": [Function],
|
|
1907
1910
|
"method": "boundingClientRect",
|
|
1908
1911
|
},
|
|
1909
1912
|
],
|
|
@@ -1970,6 +1973,7 @@ describe('ui operations', () => {
|
|
|
1970
1973
|
"invoke",
|
|
1971
1974
|
[
|
|
1972
1975
|
{
|
|
1976
|
+
"fail": [Function],
|
|
1973
1977
|
"method": "boundingClientRect",
|
|
1974
1978
|
},
|
|
1975
1979
|
],
|
|
@@ -2396,3 +2400,122 @@ describe('runDelayedUiOps helper', () => {
|
|
|
2396
2400
|
expect(invoke).not.toHaveBeenCalled();
|
|
2397
2401
|
});
|
|
2398
2402
|
});
|
|
2403
|
+
|
|
2404
|
+
describe('Snapshot ref selector error diagnostics', () => {
|
|
2405
|
+
it('enriches lookup failures on invoke while passing fields/path through and warning when fail is omitted in __DEV__', () => {
|
|
2406
|
+
const invokeQueue = [];
|
|
2407
|
+
const fieldsQueue = [];
|
|
2408
|
+
const pathQueue = [];
|
|
2409
|
+
const originalDev = globalThis.__DEV__;
|
|
2410
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
2411
|
+
const reportErrorSpy = vi.spyOn(lynx, 'reportError').mockImplementation(() => {});
|
|
2412
|
+
|
|
2413
|
+
vi.spyOn(lynx, 'createSelectorQuery').mockImplementation(() => ({
|
|
2414
|
+
select(selector) {
|
|
2415
|
+
return {
|
|
2416
|
+
invoke(options) {
|
|
2417
|
+
return {
|
|
2418
|
+
exec() {
|
|
2419
|
+
invokeQueue.push({ selector, options });
|
|
2420
|
+
},
|
|
2421
|
+
};
|
|
2422
|
+
},
|
|
2423
|
+
fields(fields, cb) {
|
|
2424
|
+
return {
|
|
2425
|
+
exec() {
|
|
2426
|
+
fieldsQueue.push({ selector, fields, cb });
|
|
2427
|
+
},
|
|
2428
|
+
};
|
|
2429
|
+
},
|
|
2430
|
+
path(cb) {
|
|
2431
|
+
return {
|
|
2432
|
+
exec() {
|
|
2433
|
+
pathQueue.push({ selector, cb });
|
|
2434
|
+
},
|
|
2435
|
+
};
|
|
2436
|
+
},
|
|
2437
|
+
};
|
|
2438
|
+
},
|
|
2439
|
+
}));
|
|
2440
|
+
|
|
2441
|
+
const dispatchInvoke = (proxy, method, res) => {
|
|
2442
|
+
const fail = vi.fn();
|
|
2443
|
+
proxy.invoke({ method, fail }).exec();
|
|
2444
|
+
const req = invokeQueue.shift();
|
|
2445
|
+
req.options.fail(
|
|
2446
|
+
res === undefined
|
|
2447
|
+
? { code: 2, data: `no node found for selector '${req.selector}'` }
|
|
2448
|
+
: res,
|
|
2449
|
+
);
|
|
2450
|
+
return fail.mock.calls[0][0];
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
try {
|
|
2454
|
+
globalThis.__DEV__ = false;
|
|
2455
|
+
|
|
2456
|
+
const boxRef = createRef();
|
|
2457
|
+
function App() {
|
|
2458
|
+
return (
|
|
2459
|
+
<view>
|
|
2460
|
+
<view ref={boxRef} />
|
|
2461
|
+
</view>
|
|
2462
|
+
);
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
__root.__jsx = <App />;
|
|
2466
|
+
renderPage();
|
|
2467
|
+
globalEnvManager.switchToBackground();
|
|
2468
|
+
render(<App />, __root);
|
|
2469
|
+
lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
|
|
2470
|
+
globalThis.__OnLifecycleEvent.mockClear();
|
|
2471
|
+
|
|
2472
|
+
const activeBoxNode = boxRef.current;
|
|
2473
|
+
|
|
2474
|
+
expect(dispatchInvoke(activeBoxNode, 'boundingClientRect').data).toMatch(
|
|
2475
|
+
/^no node found for selector '\[react-ref--?\d+-0\]' \[ReactLynx ref: invoke\(boundingClientRect\), __snapshot_[^\]]+\]$/,
|
|
2476
|
+
);
|
|
2477
|
+
const methodNotFound = { code: 3, data: 'method not found' };
|
|
2478
|
+
expect(dispatchInvoke(activeBoxNode, 'boundingClientRect', methodNotFound)).toBe(methodNotFound);
|
|
2479
|
+
expect(dispatchInvoke(activeBoxNode, 'boundingClientRect', null)).toBeNull();
|
|
2480
|
+
|
|
2481
|
+
// Omitted fail in production passes options through untouched; fields & path callbacks pass through untouched
|
|
2482
|
+
const rawOptions = { method: 'boundingClientRect' };
|
|
2483
|
+
activeBoxNode.invoke(rawOptions).exec();
|
|
2484
|
+
expect(invokeQueue.shift().options).toBe(rawOptions);
|
|
2485
|
+
|
|
2486
|
+
const fieldsCb = vi.fn();
|
|
2487
|
+
activeBoxNode.fields({ id: true }, fieldsCb).exec();
|
|
2488
|
+
expect(fieldsQueue.shift().cb).toBe(fieldsCb);
|
|
2489
|
+
|
|
2490
|
+
const pathCb = vi.fn();
|
|
2491
|
+
activeBoxNode.path(pathCb).exec();
|
|
2492
|
+
expect(pathQueue.shift().cb).toBe(pathCb);
|
|
2493
|
+
|
|
2494
|
+
globalThis.__DEV__ = true;
|
|
2495
|
+
expect(dispatchInvoke(activeBoxNode, 'focus').data).toContain('ReactLynx ref exec() call stack');
|
|
2496
|
+
|
|
2497
|
+
activeBoxNode.invoke({ method: 'boundingClientRect' }).exec();
|
|
2498
|
+
const omittedReq = invokeQueue.shift();
|
|
2499
|
+
omittedReq.options.fail({
|
|
2500
|
+
code: 2,
|
|
2501
|
+
data: `no node found for selector '${omittedReq.selector}'`,
|
|
2502
|
+
});
|
|
2503
|
+
expect(warnSpy).toHaveBeenCalledTimes(1);
|
|
2504
|
+
expect(warnSpy.mock.calls[0][0]).toMatch(
|
|
2505
|
+
/\[ReactLynx ref: invoke\(boundingClientRect\), __snapshot_[^\]]+\]/,
|
|
2506
|
+
);
|
|
2507
|
+
expect(warnSpy.mock.calls[0][0]).toContain('ReactLynx ref exec() call stack');
|
|
2508
|
+
expect(reportErrorSpy).toHaveBeenCalledTimes(1);
|
|
2509
|
+
expect(reportErrorSpy.mock.calls[0][0].name).toBe('INVOKE_ERROR');
|
|
2510
|
+
globalThis.__DEV__ = false;
|
|
2511
|
+
|
|
2512
|
+
expect(dispatchInvoke(new RefProxy([999999, 1]), 'focus').data).toBe(
|
|
2513
|
+
`no node found for selector '[react-ref-999999-1]' [ReactLynx ref: invoke(focus)]`,
|
|
2514
|
+
);
|
|
2515
|
+
} finally {
|
|
2516
|
+
warnSpy.mockRestore();
|
|
2517
|
+
reportErrorSpy.mockRestore();
|
|
2518
|
+
globalThis.__DEV__ = originalDev;
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
});
|
|
@@ -100,6 +100,11 @@ export class EnvManager {
|
|
|
100
100
|
// `renderPage` no longer resets the first-screen state (it is initialized once
|
|
101
101
|
// at module load), so reset it here for test isolation across tests.
|
|
102
102
|
resetFirstScreenSyncState();
|
|
103
|
+
const workletImpl = this.target.lynxWorkletImpl;
|
|
104
|
+
if (workletImpl?._jsFunctionLifecycleManager?.recreate) {
|
|
105
|
+
workletImpl._jsFunctionLifecycleManager = workletImpl._jsFunctionLifecycleManager.recreate();
|
|
106
|
+
}
|
|
107
|
+
workletImpl?._runOnBackgroundDelayImpl?.clearDelayedBackgroundFunctions?.();
|
|
103
108
|
getJSModule('GlobalEventEmitter')?.clear();
|
|
104
109
|
this.switchToBackground();
|
|
105
110
|
this.switchToMainThread();
|
|
@@ -211,6 +211,7 @@ afterEach((context) => {
|
|
|
211
211
|
'preact/debug',
|
|
212
212
|
'should remove event listener when throw in cleanup',
|
|
213
213
|
'should not throw if error - instead it will render an empty page',
|
|
214
|
+
'rolls back a creation whose first frame throws',
|
|
214
215
|
];
|
|
215
216
|
if (skippedTasks.some(task => context.task.name.includes(task))) {
|
|
216
217
|
return;
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
clearDelayedWorklets,
|
|
8
|
-
delayExecUntilJsReady,
|
|
9
|
-
runDelayedWorklet,
|
|
10
|
-
} from '../../src/worklet-runtime/delayWorkletEvent';
|
|
6
|
+
import { initEventDelay } from '../../src/worklet-runtime/delayWorkletEvent';
|
|
11
7
|
import { updateWorkletRefInitValueChanges } from '../../src/worklet-runtime/workletRef';
|
|
12
8
|
import { initWorklet } from '../../src/worklet-runtime/workletRuntime';
|
|
13
9
|
|
|
@@ -42,11 +38,11 @@ describe('DelayWorkletEvent', () => {
|
|
|
42
38
|
elementRefptr: 'element2',
|
|
43
39
|
},
|
|
44
40
|
};
|
|
45
|
-
delayExecUntilJsReady('1', [event, 1]);
|
|
41
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.delayExecUntilJsReady('1', [event, 1]);
|
|
46
42
|
globalThis.runWorklet({
|
|
47
43
|
_lepusWorkletHash: '1',
|
|
48
44
|
}, [event, 2]);
|
|
49
|
-
delayExecUntilJsReady('1', [event2, 3]);
|
|
45
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.delayExecUntilJsReady('1', [event2, 3]);
|
|
50
46
|
|
|
51
47
|
let worklet = {
|
|
52
48
|
_c: {
|
|
@@ -58,7 +54,7 @@ describe('DelayWorkletEvent', () => {
|
|
|
58
54
|
};
|
|
59
55
|
|
|
60
56
|
updateWorkletRefInitValueChanges([[178, 333]]);
|
|
61
|
-
runDelayedWorklet(worklet, 'element');
|
|
57
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.runDelayedWorklet(worklet, 'element');
|
|
62
58
|
vi.runAllTimers();
|
|
63
59
|
expect(fn).toBeCalledTimes(2);
|
|
64
60
|
expect(fn).toHaveBeenNthCalledWith(1, expect.anything(), 1);
|
|
@@ -74,16 +70,31 @@ describe('DelayWorkletEvent', () => {
|
|
|
74
70
|
elementRefptr: 'element',
|
|
75
71
|
},
|
|
76
72
|
};
|
|
77
|
-
delayExecUntilJsReady('1', [event]);
|
|
73
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.delayExecUntilJsReady('1', [event]);
|
|
78
74
|
|
|
79
|
-
clearDelayedWorklets();
|
|
75
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.clearDelayedWorklets();
|
|
80
76
|
|
|
81
77
|
let worklet = {
|
|
82
78
|
_wkltId: '1',
|
|
83
79
|
};
|
|
84
80
|
|
|
85
|
-
runDelayedWorklet(worklet, 'element');
|
|
81
|
+
globalThis.lynxWorkletImpl._eventDelayImpl.runDelayedWorklet(worklet, 'element');
|
|
86
82
|
vi.runAllTimers();
|
|
87
83
|
expect(fn).not.toBeCalled();
|
|
88
84
|
});
|
|
85
|
+
|
|
86
|
+
it('keeps state isolated per EventDelayImpl instance', () => {
|
|
87
|
+
const fn = vi.fn();
|
|
88
|
+
globalThis.registerWorklet('main-thread', '1', fn);
|
|
89
|
+
const first = initEventDelay();
|
|
90
|
+
const second = initEventDelay();
|
|
91
|
+
const event = { currentTarget: { elementRefptr: 'element' } };
|
|
92
|
+
|
|
93
|
+
first.delayExecUntilJsReady('1', [event, 'first']);
|
|
94
|
+
second.clearDelayedWorklets();
|
|
95
|
+
|
|
96
|
+
first.runDelayedWorklet({ _wkltId: '1' }, 'element');
|
|
97
|
+
vi.runAllTimers();
|
|
98
|
+
expect(fn).toHaveBeenCalledExactlyOnceWith(expect.anything(), 'first');
|
|
99
|
+
});
|
|
89
100
|
});
|
|
@@ -61,9 +61,11 @@ describe('worklet-runtime init entry', () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('initializes the main-thread runtime through the public entry', async () => {
|
|
64
|
+
globalThis.lynx.SystemInfo = { lynxSdkVersion: '2.15' };
|
|
64
65
|
const { registerWorklet } = await import('@lynx-js/react/worklet-runtime/init');
|
|
65
66
|
|
|
66
67
|
expect(globalThis.lynxWorkletImpl).toBeDefined();
|
|
68
|
+
expect(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager).toBeDefined();
|
|
67
69
|
expect(globalThis.registerWorklet).toBeTypeOf('function');
|
|
68
70
|
expect(globalThis.registerWorkletInternal).toBeTypeOf('function');
|
|
69
71
|
expect(globalThis.runWorklet).toBeTypeOf('function');
|
|
@@ -75,6 +77,16 @@ describe('worklet-runtime init entry', () => {
|
|
|
75
77
|
expect(globalThis.runWorklet({ _wkltId: 'cold-entry' }, [41])).toBe(42);
|
|
76
78
|
});
|
|
77
79
|
|
|
80
|
+
it('uses host SystemInfo when initialized before the global alias', async () => {
|
|
81
|
+
delete globalThis.SystemInfo;
|
|
82
|
+
globalThis.lynx.SystemInfo = { lynxSdkVersion: '2.16' };
|
|
83
|
+
|
|
84
|
+
await import('@lynx-js/react/worklet-runtime/init');
|
|
85
|
+
|
|
86
|
+
expect(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager).toBeDefined();
|
|
87
|
+
expect('SystemInfo' in globalThis).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
78
90
|
it('preserves runtime state when the init entry is evaluated again', async () => {
|
|
79
91
|
const initialEntry = await import('@lynx-js/react/worklet-runtime/init');
|
|
80
92
|
expect(initialEntry.registerWorklet).toBe(globalThis.registerWorkletInternal);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
|
|
6
|
-
import { JsFunctionLifecycleManager } from '../../src/worklet-runtime/
|
|
6
|
+
import { JsFunctionLifecycleManager } from '../../src/worklet-runtime/run-on-background/lifecycle';
|
|
7
7
|
|
|
8
8
|
let events = [];
|
|
9
9
|
beforeEach(() => {
|
|
@@ -21,12 +21,7 @@ describe('jsFunctionLifecycle', () => {
|
|
|
21
21
|
const manager = new JsFunctionLifecycleManager();
|
|
22
22
|
manager.addRef(3, {});
|
|
23
23
|
manager.fire();
|
|
24
|
-
expect(events[
|
|
25
|
-
{
|
|
26
|
-
"data": [],
|
|
27
|
-
"type": "Lynx.Worklet.releaseBackgroundWorkletCtx",
|
|
28
|
-
}
|
|
29
|
-
`);
|
|
24
|
+
expect(events).toEqual([]);
|
|
30
25
|
});
|
|
31
26
|
|
|
32
27
|
it('should add and remove', () => {
|
|
@@ -50,14 +45,8 @@ describe('jsFunctionLifecycle', () => {
|
|
|
50
45
|
manager.addRef(3, {});
|
|
51
46
|
manager.removeRef(3);
|
|
52
47
|
manager.fire();
|
|
53
|
-
expect(events[
|
|
54
|
-
{
|
|
55
|
-
"data": [],
|
|
56
|
-
"type": "Lynx.Worklet.releaseBackgroundWorkletCtx",
|
|
57
|
-
}
|
|
58
|
-
`);
|
|
48
|
+
expect(events).toEqual([]);
|
|
59
49
|
|
|
60
|
-
events = [];
|
|
61
50
|
manager.removeRef(3);
|
|
62
51
|
manager.fire();
|
|
63
52
|
expect(events[0]).toMatchInlineSnapshot(`
|
|
@@ -105,11 +94,30 @@ describe('jsFunctionLifecycle', () => {
|
|
|
105
94
|
const previous = new JsFunctionLifecycleManager();
|
|
106
95
|
previous.addRef(3, {});
|
|
107
96
|
previous.removeRef(3);
|
|
108
|
-
previous.
|
|
109
|
-
const current = new JsFunctionLifecycleManager();
|
|
97
|
+
const current = previous.recreate();
|
|
110
98
|
current.addRef(3, {});
|
|
111
99
|
previous.fire();
|
|
112
100
|
expect(events).toEqual([]);
|
|
113
101
|
expect(current.execIdRefCount.get(3)).toBe(1);
|
|
114
102
|
});
|
|
103
|
+
|
|
104
|
+
it('cancels pending release when addRef re-retains an execId before fire()', async () => {
|
|
105
|
+
const manager = new JsFunctionLifecycleManager();
|
|
106
|
+
manager.addRef(3, {});
|
|
107
|
+
manager.removeRef(3);
|
|
108
|
+
manager.addRef(3, {});
|
|
109
|
+
|
|
110
|
+
await Promise.resolve();
|
|
111
|
+
expect(events).toEqual([]);
|
|
112
|
+
expect(manager.execIdRefCount.get(3)).toBe(1);
|
|
113
|
+
|
|
114
|
+
manager.removeRef(3);
|
|
115
|
+
await Promise.resolve();
|
|
116
|
+
expect(events).toEqual([
|
|
117
|
+
{
|
|
118
|
+
data: [3],
|
|
119
|
+
type: 'Lynx.Worklet.releaseBackgroundWorkletCtx',
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
});
|
|
115
123
|
});
|