@lynx-js/react 0.129.3 → 0.129.5
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 +38 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -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/lynx/env.test.ts +146 -0
- 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/imports/suspense-lazy.test.ts +47 -4
- 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/index.test.ts +9 -9
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +65 -17
- package/runtime/__test__/element-template/native/reload.test.ts +19 -12
- 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/main-thread-function/compiled-fixtures.test.tsx +1 -1
- 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 +4 -5
- 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 +65 -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 +2 -1
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +98 -77
- package/runtime/__test__/snapshot/debug/passive-update-depth.test.jsx +549 -0
- package/runtime/__test__/snapshot/debug/profile.test.jsx +147 -26
- 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 +55 -1
- package/runtime/__test__/snapshot/lifecycle/transfer.mts.test.jsx +286 -0
- package/runtime/__test__/snapshot/lifecycle/transfer.test.jsx +415 -0
- package/runtime/__test__/snapshot/list.test.jsx +109 -0
- package/runtime/__test__/snapshot/lynx/suspense.test.jsx +48 -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 +7 -0
- package/runtime/__test__/snapshot/utils/globals.js +1 -0
- package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +43 -11
- package/runtime/__test__/worklet-runtime/hydrate.test.js +1 -0
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +24 -16
- package/runtime/__test__/worklet-runtime/lifecycle.test.js +297 -0
- package/runtime/__test__/worklet-runtime/profile.test.js +12 -6
- package/runtime/__test__/worklet-runtime/runOnBackground.test.js +188 -0
- package/runtime/__test__/worklet-runtime/workletRef.test.js +16 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +53 -1
- package/runtime/lazy/element-template-internal.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/core/compat/componentIs.d.ts +1 -0
- package/runtime/lib/core/compat/componentIs.js +20 -0
- package/runtime/lib/core/compat/componentIs.js.map +1 -0
- 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/env.d.ts +1 -0
- package/runtime/lib/{element-template → core}/lynx/env.js +3 -2
- package/runtime/lib/core/lynx/env.js.map +1 -0
- 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.d.ts +1 -0
- package/runtime/lib/core/thread-function-call/main-thread.js +5 -2
- 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-event.d.ts +6 -0
- package/runtime/lib/element-template/background/commit-event.js +36 -0
- package/runtime/lib/element-template/background/commit-event.js.map +1 -0
- package/runtime/lib/element-template/background/commit-hook.js +4 -24
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +2 -2
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +174 -87
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +5 -25
- package/runtime/lib/element-template/background/hydration-listener.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/{runtime/template → background}/main-thread-function.js +4 -4
- package/runtime/lib/element-template/background/main-thread-function.js.map +1 -0
- 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/index.d.ts +1 -1
- package/runtime/lib/element-template/index.js +1 -1
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.js +3 -0
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/native/index.js +4 -4
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.d.ts +2 -1
- package/runtime/lib/element-template/native/mts-destroy.js +15 -4
- package/runtime/lib/element-template/native/mts-destroy.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 +2 -6
- 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 +44 -128
- 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 +3 -3
- package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.d.ts +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -8
- 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 +5 -10
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.js +6 -1
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/lynx.js +4 -4
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/root.d.ts +5 -1
- package/runtime/lib/root.js +12 -1
- package/runtime/lib/root.js.map +1 -1
- package/runtime/lib/shared/microtask.d.ts +1 -0
- package/runtime/lib/shared/microtask.js +28 -0
- package/runtime/lib/shared/microtask.js.map +1 -0
- package/runtime/lib/shared/utils.d.ts +8 -0
- package/runtime/lib/shared/utils.js +27 -0
- package/runtime/lib/shared/utils.js.map +1 -0
- package/runtime/lib/{worklet-runtime/utils → shared}/version.d.ts +1 -0
- package/runtime/lib/{worklet-runtime/utils → shared}/version.js +4 -2
- package/runtime/lib/shared/version.js.map +1 -0
- package/runtime/lib/snapshot/alog/render.js +1 -1
- package/runtime/lib/snapshot/alog/render.js.map +1 -1
- package/runtime/lib/snapshot/debug/profileHooks.js +28 -63
- 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 +3 -3
- 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/env.js +2 -32
- package/runtime/lib/snapshot/lynx/env.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 +21 -0
- package/runtime/lib/snapshot/transfer.js +486 -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/lifecycle.d.ts +19 -0
- package/runtime/lib/worklet-runtime/bindings/lifecycle.js +49 -0
- package/runtime/lib/worklet-runtime/bindings/lifecycle.js.map +1 -0
- 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 +3 -5
- package/runtime/lib/worklet-runtime/delayWorkletEvent.js +49 -43
- 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/utils/profile.js +1 -3
- package/runtime/lib/worklet-runtime/utils/profile.js.map +1 -1
- 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/core/compat/componentIs.ts +32 -0
- 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/{element-template → core}/lynx/env.ts +6 -4
- 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 +6 -2
- package/runtime/src/element-template/background/attr-slots.ts +2 -2
- package/runtime/src/element-template/background/commit-event.ts +52 -0
- package/runtime/src/element-template/background/commit-hook.ts +5 -32
- package/runtime/src/element-template/background/destroy.ts +2 -2
- package/runtime/src/element-template/background/hydrate.ts +234 -122
- package/runtime/src/element-template/background/hydration-listener.ts +7 -32
- package/runtime/src/element-template/background/instance.ts +82 -82
- package/runtime/src/element-template/{runtime/template → background}/main-thread-function.ts +4 -7
- 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/index.ts +1 -1
- package/runtime/src/element-template/internal.ts +4 -0
- package/runtime/src/element-template/native/index.ts +4 -4
- package/runtime/src/element-template/native/mts-destroy.ts +21 -4
- package/runtime/src/element-template/native/patch-listener.ts +6 -7
- package/runtime/src/element-template/native/reload-main-thread.ts +2 -6
- 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 +78 -197
- 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 +5 -2
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +9 -8
- 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 +6 -13
- package/runtime/src/lynx-api.ts +6 -1
- package/runtime/src/lynx.ts +4 -4
- package/runtime/src/root.ts +17 -1
- package/runtime/src/shared/microtask.ts +26 -0
- package/runtime/src/shared/utils.ts +37 -0
- package/runtime/src/{worklet-runtime/utils → shared}/version.ts +6 -4
- package/runtime/src/snapshot/alog/render.ts +1 -1
- package/runtime/src/snapshot/debug/profileHooks.ts +31 -92
- 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 +3 -4
- package/runtime/src/snapshot/list/list.ts +12 -3
- package/runtime/src/snapshot/lynx/env.ts +3 -43
- 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 +535 -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/lifecycle.ts +51 -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 +57 -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/utils/profile.ts +1 -3
- package/runtime/src/worklet-runtime/workletRef.ts +63 -62
- package/runtime/src/worklet-runtime/workletRuntime.ts +10 -10
- package/runtime/types/internal-preact.d.ts +2 -0
- package/runtime/vitest.config.ts +0 -1
- package/testing-library/.turbo/turbo-build.log +11 -11
- 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__/events.test.jsx +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/fire-event.ts +1 -1
- 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 +45 -44
- package/transform/__test__/fixture.spec.js +1 -1
- package/transform/cjs/browser.cjs +11 -0
- package/transform/crates/swc_plugin_compat/lib.rs +20 -2
- package/transform/crates/swc_plugin_compat/napi.rs +7 -0
- package/transform/crates/swc_plugin_dynamic_import/lib.rs +15 -4
- package/transform/crates/swc_plugin_element_template/attr_name.rs +0 -3
- package/transform/crates/swc_plugin_element_template/extractor.rs +0 -8
- package/transform/crates/swc_plugin_element_template/lib.rs +12 -1
- 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 +35 -19
- package/transform/crates/swc_plugin_worklet/lib.rs +11 -7
- package/transform/dist/wasm.cjs +1 -1
- package/transform/rspack-napi/lib/index.js +1 -4
- package/transform/rspack-napi/lib/index.js.map +1 -1
- package/transform/rspack-napi/src/index.ts +1 -4
- package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
- package/transform/src/lib.rs +394 -27
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +415 -107
- package/transform/swc-plugin-reactlynx/src/lib.rs +99 -22
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +29 -339
- package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
- 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/lynx/env.test.ts +0 -242
- 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/element-template/lynx/env.d.ts +0 -1
- package/runtime/lib/element-template/lynx/env.js.map +0 -1
- package/runtime/lib/element-template/runtime/template/main-thread-function.js.map +0 -1
- 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/snapshot/compat/componentIs.d.ts +0 -4
- package/runtime/lib/snapshot/compat/componentIs.js +0 -20
- package/runtime/lib/snapshot/compat/componentIs.js.map +0 -1
- package/runtime/lib/utils.d.ts +0 -19
- package/runtime/lib/utils.js +0 -119
- package/runtime/lib/utils.js.map +0 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.d.ts +0 -13
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +0 -29
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +0 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +0 -1
- package/runtime/lib/worklet-runtime/utils/version.js.map +0 -1
- package/runtime/src/snapshot/alog/index.ts +0 -8
- package/runtime/src/snapshot/compat/componentIs.ts +0 -30
- package/runtime/src/utils.ts +0 -134
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +0 -53
- /package/runtime/__test__/element-template/fixtures/background/hydrate/{coverage.raw-text-key-branches → children.reconciles-raw-text-slots}/output.txt +0 -0
- /package/runtime/__test__/element-template/runtime/{template → background}/main-thread-function.test.ts +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/lib/element-template/{runtime/template → background}/main-thread-function.d.ts +0 -0
- /package/runtime/src/{shared → core}/attribute-name.ts +0 -0
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { Animation } from './animation/animation.js';
|
|
5
5
|
import { KeyframeEffect } from './animation/effect.js';
|
|
6
|
+
import { isSdkVersionGt } from '../../shared/version.js';
|
|
6
7
|
import { mainThreadFlushLoopMark, mainThreadFlushLoopOnFlushMicrotask, mainThreadFlushLoopReport, } from '../utils/mainThreadFlushLoopGuard.js';
|
|
7
|
-
import { isSdkVersionGt } from '../utils/version.js';
|
|
8
8
|
let willFlush = false;
|
|
9
9
|
let shouldFlush = true;
|
|
10
10
|
export function setShouldFlush(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/worklet-runtime/api/element.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,uBAAuB,EACvB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../../src/worklet-runtime/api/element.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,uBAAuB,EACvB,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,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KAAK,CAAC;oBACpB,yBAAyB,CAAC,KAAK,CAAC,CAAC;oBACjC,OAAO;gBACT,CAAC;YACH,CAAC;YACD,kBAAkB,EAAE,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { Animation } from './animation/animation.js';\nimport { KeyframeEffect } from './animation/effect.js';\nimport { isSdkVersionGt } from '../../shared/version.js';\nimport {\n mainThreadFlushLoopMark,\n mainThreadFlushLoopOnFlushMicrotask,\n mainThreadFlushLoopReport,\n} from '../utils/mainThreadFlushLoopGuard.js';\n\nlet willFlush = false;\nlet shouldFlush = true;\n\nexport function setShouldFlush(value: boolean): void {\n shouldFlush = value;\n}\n\nexport class Element {\n // @ts-expect-error set in constructor\n private readonly element: ElementNode;\n\n constructor(element: ElementNode) {\n // In Lynx versions prior to and including 2.15,\n // a crash occurs when printing or transferring refCounted across threads.\n // Bypass this problem by hiding the element object.\n Object.defineProperty(this, 'element', {\n get() {\n return element;\n },\n });\n }\n\n public setAttribute(name: string, value: unknown): void {\n /* v8 ignore next 3 */\n if (__DEV__) {\n mainThreadFlushLoopMark(`element:setAttribute ${name}`);\n }\n __SetAttribute(this.element, name, value);\n this.flushElementTree();\n }\n\n public setStyleProperty(name: string, value: string): void {\n /* v8 ignore next 3 */\n if (__DEV__) {\n mainThreadFlushLoopMark(`element:setStyleProperty ${name}`);\n }\n __AddInlineStyle(this.element, name, value);\n this.flushElementTree();\n }\n\n public setStyleProperties(styles: Record<string, string>): void {\n /* v8 ignore next 5 */\n if (__DEV__) {\n mainThreadFlushLoopMark(\n `element:setStyleProperties keys=${Object.keys(styles).length}`,\n );\n }\n for (const key in styles) {\n __AddInlineStyle(this.element, key, styles[key]!);\n }\n this.flushElementTree();\n }\n\n public getAttribute(attributeName: string): unknown {\n return __GetAttributeByName(this.element, attributeName);\n }\n\n public getAttributeNames(): string[] {\n return __GetAttributeNames(this.element);\n }\n\n public querySelector(selector: string): Element | null {\n const ref = __QuerySelector(this.element, selector, {});\n return ref ? new Element(ref) : null;\n }\n\n public querySelectorAll(selector: string): Element[] {\n return __QuerySelectorAll(this.element, selector, {}).map((element) => {\n return new Element(element);\n });\n }\n\n public getComputedStyleProperty(key: string): string {\n if (!isSdkVersionGt(3, 4)) {\n throw new Error(\n 'getComputedStyleProperty requires Lynx sdk version 3.5',\n );\n }\n\n if (!key) {\n throw new Error('getComputedStyleProperty: key is required');\n }\n return __GetComputedStyleByKey(this.element, key);\n }\n\n public animate(\n keyframes: Record<string, number | string>[],\n options?: number | Record<string, number | string>,\n ): Animation {\n const normalizedOptions = typeof options === 'number' ? { duration: options } : options ?? {};\n return new Animation(new KeyframeEffect(this, keyframes, normalizedOptions));\n }\n\n public invoke(\n methodName: string,\n params?: Record<string, unknown>,\n ): Promise<unknown> {\n /* v8 ignore next 3 */\n if (__DEV__) {\n mainThreadFlushLoopMark(`element:invoke ${methodName}`);\n }\n return new Promise((resolve, reject) => {\n __InvokeUIMethod(\n this.element,\n methodName,\n params ?? {},\n (res: { code: number; data: unknown }) => {\n if (res.code === 0) {\n resolve(res.data);\n } else {\n reject(new Error('UI method invoke: ' + JSON.stringify(res)));\n }\n },\n );\n this.flushElementTree();\n });\n }\n\n private flushElementTree() {\n if (willFlush || !shouldFlush) {\n return;\n }\n willFlush = true;\n void Promise.resolve().then(() => {\n willFlush = false;\n if (__DEV__) {\n mainThreadFlushLoopMark('render');\n const error = mainThreadFlushLoopOnFlushMicrotask();\n if (error) {\n // Stop scheduling further flushes so we can surface the error.\n // This is DEV-only behavior guarded internally by the dev guard.\n shouldFlush = false;\n mainThreadFlushLoopReport(error);\n return;\n }\n }\n __FlushElementTree();\n });\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { querySelector, querySelectorAll } from './lepusQuerySelector.js';
|
|
5
|
-
import { isSdkVersionGt } from '
|
|
5
|
+
import { isSdkVersionGt } from '../../shared/version.js';
|
|
6
6
|
function initApiEnv() {
|
|
7
7
|
// @ts-expect-error type
|
|
8
8
|
lynx.querySelector = querySelector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lynxApi.js","sourceRoot":"","sources":["../../../src/worklet-runtime/api/lynxApi.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"lynxApi.js","sourceRoot":"","sources":["../../../src/worklet-runtime/api/lynxApi.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,SAAS,UAAU;IACjB,wBAAwB;IACxB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACnC,wBAAwB;IACxB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IACzC,wBAAwB;IACxB,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,UAAyD,CAAC;IACvF,wBAAwB;IACxB,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAA0D,CAAC;IACzF,wBAAwB;IACxB,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,YAAyC,CAAC;IACzE,yGAAyG;IACzG,wBAAwB;IACxB,UAAU,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,iBAAiB,CAA8B,CAAC;IAEvG,CAAC;QACC,wBAAwB;QACxB,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAyD,CAAC;QAC7F,wBAAwB;QACxB,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAC,qBAAqB,GAAG,CAC9D,QAAoB,EACpB,EAAE;YACF,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;YACJ,CAAC;YACD,OAAO,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAmD,CAAC;AAC7F,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { querySelector, querySelectorAll } from './lepusQuerySelector.js';\nimport { isSdkVersionGt } from '../../shared/version.js';\n\nfunction initApiEnv(): void {\n // @ts-expect-error type\n lynx.querySelector = querySelector;\n // @ts-expect-error type\n lynx.querySelectorAll = querySelectorAll;\n // @ts-expect-error type\n globalThis.setTimeout = lynx.setTimeout as (cb: () => void, timeout: number) => number;\n // @ts-expect-error type\n globalThis.setInterval = lynx.setInterval as (cb: () => void, timeout: number) => number;\n // @ts-expect-error type\n globalThis.clearTimeout = lynx.clearTimeout as (timeout: number) => void;\n // In lynx 2.14 `clearInterval` is mistakenly spelled as `clearTimeInterval`. This is fixed in lynx 2.15.\n // @ts-expect-error type\n globalThis.clearInterval = (lynx.clearInterval ?? lynx.clearTimeInterval) as (timeout: number) => void;\n\n {\n // @ts-expect-error type\n const requestAnimationFrame = lynx.requestAnimationFrame as (callback: () => void) => number;\n // @ts-expect-error type\n lynx.requestAnimationFrame = globalThis.requestAnimationFrame = (\n callback: () => void,\n ) => {\n if (!isSdkVersionGt(2, 15)) {\n throw new Error(\n 'requestAnimationFrame in main thread script requires Lynx sdk version 2.16',\n );\n }\n return requestAnimationFrame(callback);\n };\n }\n\n // @ts-expect-error type\n globalThis.cancelAnimationFrame = lynx.cancelAnimationFrame as (requestId: number) => void;\n}\n\nexport { initApiEnv };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClosureValueType, MainThreadRefInitValuePatch, Worklet } from './types.js';
|
|
1
|
+
import type { ClosureValueType, JsFnHandle, MainThreadRefInitValuePatch, Worklet } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Executes the worklet ctx.
|
|
4
4
|
* @param worklet - The Worklet ctx to run.
|
|
@@ -15,4 +15,5 @@ declare function updateWorkletRefInitValueChanges(patch?: MainThreadRefInitValue
|
|
|
15
15
|
* Releases the temporary negative-ID MainThreadRefs after hydration handoff.
|
|
16
16
|
*/
|
|
17
17
|
declare function clearFirstScreenMainThreadRefs(): void;
|
|
18
|
-
|
|
18
|
+
declare function shouldDelayRunOnBackground(fnObj: JsFnHandle): boolean;
|
|
19
|
+
export { runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, clearFirstScreenMainThreadRefs, registerMainThreadObjectType, registerWorklet, shouldDelayRunOnBackground, delayRunOnBackground, setEomShouldFlushElementTree, runRunOnMainThreadTask, };
|
|
@@ -51,6 +51,16 @@ function clearFirstScreenMainThreadRefs() {
|
|
|
51
51
|
function registerWorklet(type, id, worklet) {
|
|
52
52
|
globalThis.registerWorklet(type, id, worklet);
|
|
53
53
|
}
|
|
54
|
+
function shouldDelayRunOnBackground(fnObj) {
|
|
55
|
+
if (fnObj._isFirstScreen) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (fnObj._hydratedEpoch === undefined) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const delayImpl = globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl;
|
|
62
|
+
return Boolean(delayImpl && !delayImpl.hasHydrated && fnObj._hydratedEpoch !== delayImpl.epoch);
|
|
63
|
+
}
|
|
54
64
|
/**
|
|
55
65
|
* Delay a runOnBackground after hydration.
|
|
56
66
|
*
|
|
@@ -75,5 +85,5 @@ function setEomShouldFlushElementTree(value) {
|
|
|
75
85
|
function runRunOnMainThreadTask(task, params, resolveId) {
|
|
76
86
|
globalThis.lynxWorkletImpl?._runRunOnMainThreadTask(task, params, resolveId);
|
|
77
87
|
}
|
|
78
|
-
export { runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, clearFirstScreenMainThreadRefs, registerMainThreadObjectType, registerWorklet, delayRunOnBackground, setEomShouldFlushElementTree, runRunOnMainThreadTask, };
|
|
88
|
+
export { runWorkletCtx, updateWorkletRef, updateWorkletRefInitValueChanges, clearFirstScreenMainThreadRefs, registerMainThreadObjectType, registerWorklet, shouldDelayRunOnBackground, delayRunOnBackground, setEomShouldFlushElementTree, runRunOnMainThreadTask, };
|
|
79
89
|
//# sourceMappingURL=bindings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/bindings.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAK1D;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAAgB,EAAE,MAA0B;IACjE,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,UAAmC,EAAE,OAA2B;IACxF,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED;;;;GAIG;AACH,SAAS,gCAAgC,CACvC,KAAmC;IAEnC,IAAI,KAAK,EAAE,CAAC;QACV,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,4BAA4B,CACnC,IAAY,EACZ,MAAqD;IAErD,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,SAAS,8BAA8B;IACrC,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,6BAA6B,EAAE,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAY,EAAE,EAAU,EAAE,OAAwC;IACzF,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAiB,EAAE,EAA0C;IACzF,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,KAAc;IAClD,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,IAAa,EAAE,MAA0B,EAAE,SAAiB;IAC1F,UAAU,CAAC,eAAe,EAAE,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/E,CAAC;AAED,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gCAAgC,EAChC,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType, JsFnHandle, MainThreadRefInitValuePatch, Worklet, WorkletRefImpl } from './types.js';\nimport type { Element } from '../api/element.js';\n\n/**\n * Executes the worklet ctx.\n * @param worklet - The Worklet ctx to run.\n * @param params - An array as parameters of the worklet run.\n */\nfunction runWorkletCtx(worklet: Worklet, params: ClosureValueType[]): unknown {\n return globalThis.runWorklet?.(worklet, params);\n}\n\n/**\n * Save an element to a `WorkletRef`.\n *\n * @param workletRef - The `WorkletRef` to be updated.\n * @param element - The element.\n * @internal\n */\nfunction updateWorkletRef(workletRef: WorkletRefImpl<Element>, element: ElementNode | null): void {\n globalThis.lynxWorkletImpl?._refImpl.updateWorkletRef(workletRef, element);\n}\n\n/**\n * Update the initial value of the `WorkletRef`.\n *\n * @param patch - An array containing the index and new value of the worklet value.\n */\nfunction updateWorkletRefInitValueChanges(\n patch?: MainThreadRefInitValuePatch,\n): void {\n if (patch) {\n globalThis.lynxWorkletImpl?._refImpl.updateWorkletRefInitValueChanges(patch);\n }\n}\n\n/**\n * Register a definition for an opaque main-thread object type.\n *\n * @internal\n */\nfunction registerMainThreadObjectType(\n type: string,\n create: ((initialValue: unknown) => object) | Worklet,\n): void {\n globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(type, create);\n}\n\n/**\n * Releases the temporary negative-ID MainThreadRefs after hydration handoff.\n */\nfunction clearFirstScreenMainThreadRefs(): void {\n globalThis.lynxWorkletImpl?._refImpl.clearFirstScreenWorkletRefMap();\n}\n\n/**\n * Register a worklet.\n *\n * @internal\n */\nfunction registerWorklet(type: string, id: string, worklet: (...args: unknown[]) => unknown): void {\n globalThis.registerWorklet(type, id, worklet);\n}\n\n/**\n * Delay a runOnBackground after hydration.\n *\n * @internal\n */\nfunction delayRunOnBackground(fnObj: JsFnHandle, fn: (fnId: number, execId: number) => void): void {\n globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl.delayRunOnBackground(fnObj, fn);\n}\n\n/**\n * Set whether EOM operations should flush the element tree.\n *\n * @internal\n */\nfunction setEomShouldFlushElementTree(value: boolean) {\n globalThis.lynxWorkletImpl?._eomImpl.setShouldFlush(value);\n}\n\n/**\n * Runs a task on the main thread.\n *\n * @internal\n */\nfunction runRunOnMainThreadTask(task: Worklet, params: ClosureValueType[], resolveId: number): void {\n globalThis.lynxWorkletImpl?._runRunOnMainThreadTask(task, params, resolveId);\n}\n\nexport {\n runWorkletCtx,\n updateWorkletRef,\n updateWorkletRefInitValueChanges,\n clearFirstScreenMainThreadRefs,\n registerMainThreadObjectType,\n registerWorklet,\n delayRunOnBackground,\n setEomShouldFlushElementTree,\n runRunOnMainThreadTask,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/bindings.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAK1D;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAAgB,EAAE,MAA0B;IACjE,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,UAAmC,EAAE,OAA2B;IACxF,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED;;;;GAIG;AACH,SAAS,gCAAgC,CACvC,KAAmC;IAEnC,IAAI,KAAK,EAAE,CAAC;QACV,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,4BAA4B,CACnC,IAAY,EACZ,MAAqD;IAErD,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,SAAS,8BAA8B;IACrC,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,6BAA6B,EAAE,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAY,EAAE,EAAU,EAAE,OAAwC;IACzF,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAiB;IACnD,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC;IACxE,OAAO,OAAO,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,WAAW,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAClG,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAiB,EAAE,EAA0C;IACzF,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,SAAS,4BAA4B,CAAC,KAAc;IAClD,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,IAAa,EAAE,MAA0B,EAAE,SAAiB;IAC1F,UAAU,CAAC,eAAe,EAAE,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/E,CAAC;AAED,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gCAAgC,EAChC,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,sBAAsB,GACvB,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ClosureValueType, JsFnHandle, MainThreadRefInitValuePatch, Worklet, WorkletRefImpl } from './types.js';\nimport type { Element } from '../api/element.js';\n\n/**\n * Executes the worklet ctx.\n * @param worklet - The Worklet ctx to run.\n * @param params - An array as parameters of the worklet run.\n */\nfunction runWorkletCtx(worklet: Worklet, params: ClosureValueType[]): unknown {\n return globalThis.runWorklet?.(worklet, params);\n}\n\n/**\n * Save an element to a `WorkletRef`.\n *\n * @param workletRef - The `WorkletRef` to be updated.\n * @param element - The element.\n * @internal\n */\nfunction updateWorkletRef(workletRef: WorkletRefImpl<Element>, element: ElementNode | null): void {\n globalThis.lynxWorkletImpl?._refImpl.updateWorkletRef(workletRef, element);\n}\n\n/**\n * Update the initial value of the `WorkletRef`.\n *\n * @param patch - An array containing the index and new value of the worklet value.\n */\nfunction updateWorkletRefInitValueChanges(\n patch?: MainThreadRefInitValuePatch,\n): void {\n if (patch) {\n globalThis.lynxWorkletImpl?._refImpl.updateWorkletRefInitValueChanges(patch);\n }\n}\n\n/**\n * Register a definition for an opaque main-thread object type.\n *\n * @internal\n */\nfunction registerMainThreadObjectType(\n type: string,\n create: ((initialValue: unknown) => object) | Worklet,\n): void {\n globalThis.lynxWorkletImpl._refImpl.registerMainThreadObjectType(type, create);\n}\n\n/**\n * Releases the temporary negative-ID MainThreadRefs after hydration handoff.\n */\nfunction clearFirstScreenMainThreadRefs(): void {\n globalThis.lynxWorkletImpl?._refImpl.clearFirstScreenWorkletRefMap();\n}\n\n/**\n * Register a worklet.\n *\n * @internal\n */\nfunction registerWorklet(type: string, id: string, worklet: (...args: unknown[]) => unknown): void {\n globalThis.registerWorklet(type, id, worklet);\n}\n\nfunction shouldDelayRunOnBackground(fnObj: JsFnHandle): boolean {\n if (fnObj._isFirstScreen) {\n return true;\n }\n if (fnObj._hydratedEpoch === undefined) {\n return false;\n }\n const delayImpl = globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl;\n return Boolean(delayImpl && !delayImpl.hasHydrated && fnObj._hydratedEpoch !== delayImpl.epoch);\n}\n\n/**\n * Delay a runOnBackground after hydration.\n *\n * @internal\n */\nfunction delayRunOnBackground(fnObj: JsFnHandle, fn: (fnId: number, execId: number) => void): void {\n globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl.delayRunOnBackground(fnObj, fn);\n}\n\n/**\n * Set whether EOM operations should flush the element tree.\n *\n * @internal\n */\nfunction setEomShouldFlushElementTree(value: boolean) {\n globalThis.lynxWorkletImpl?._eomImpl.setShouldFlush(value);\n}\n\n/**\n * Runs a task on the main thread.\n *\n * @internal\n */\nfunction runRunOnMainThreadTask(task: Worklet, params: ClosureValueType[], resolveId: number): void {\n globalThis.lynxWorkletImpl?._runRunOnMainThreadTask(task, params, resolveId);\n}\n\nexport {\n runWorkletCtx,\n updateWorkletRef,\n updateWorkletRefInitValueChanges,\n clearFirstScreenMainThreadRefs,\n registerMainThreadObjectType,\n registerWorklet,\n shouldDelayRunOnBackground,\n delayRunOnBackground,\n setEomShouldFlushElementTree,\n runRunOnMainThreadTask,\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retires the current page's worklet-runtime state for an in-place reload or
|
|
3
|
+
* entry re-evaluation on the same main-thread VM.
|
|
4
|
+
*
|
|
5
|
+
* Preserves VM-scoped registrations (`_workletMap`, MainThreadObject
|
|
6
|
+
* definitions, realized object brands, and positive-ID ref entries), while
|
|
7
|
+
* advancing the `runOnBackground` epoch, recreating the lifecycle manager for
|
|
8
|
+
* the next page, and dropping any aborted first-screen refs or queued legacy
|
|
9
|
+
* worklet events.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resetWorkletRuntimeForReload(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Disposes worklet-runtime state for terminal main-thread destruction
|
|
14
|
+
* (`__DestroyLifetime`).
|
|
15
|
+
*
|
|
16
|
+
* Unlike {@link resetWorkletRuntimeForReload}, this retires the lifecycle
|
|
17
|
+
* manager without allocating a replacement instance.
|
|
18
|
+
*/
|
|
19
|
+
export declare function disposeWorkletRuntime(): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
function clearPendingWorkletRuntimeState(impl) {
|
|
5
|
+
impl._runOnBackgroundDelayImpl?.clearDelayedBackgroundFunctions?.();
|
|
6
|
+
impl._refImpl?.clearFirstScreenWorkletRefMap?.();
|
|
7
|
+
impl._eventDelayImpl?.clearDelayedWorklets?.(true);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Retires the current page's worklet-runtime state for an in-place reload or
|
|
11
|
+
* entry re-evaluation on the same main-thread VM.
|
|
12
|
+
*
|
|
13
|
+
* Preserves VM-scoped registrations (`_workletMap`, MainThreadObject
|
|
14
|
+
* definitions, realized object brands, and positive-ID ref entries), while
|
|
15
|
+
* advancing the `runOnBackground` epoch, recreating the lifecycle manager for
|
|
16
|
+
* the next page, and dropping any aborted first-screen refs or queued legacy
|
|
17
|
+
* worklet events.
|
|
18
|
+
*/
|
|
19
|
+
export function resetWorkletRuntimeForReload() {
|
|
20
|
+
const impl = globalThis.lynxWorkletImpl;
|
|
21
|
+
if (!impl) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const manager = impl._jsFunctionLifecycleManager;
|
|
25
|
+
if (manager?.recreate) {
|
|
26
|
+
impl._jsFunctionLifecycleManager = manager.recreate();
|
|
27
|
+
}
|
|
28
|
+
clearPendingWorkletRuntimeState(impl);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Disposes worklet-runtime state for terminal main-thread destruction
|
|
32
|
+
* (`__DestroyLifetime`).
|
|
33
|
+
*
|
|
34
|
+
* Unlike {@link resetWorkletRuntimeForReload}, this retires the lifecycle
|
|
35
|
+
* manager without allocating a replacement instance.
|
|
36
|
+
*/
|
|
37
|
+
export function disposeWorkletRuntime() {
|
|
38
|
+
const impl = globalThis.lynxWorkletImpl;
|
|
39
|
+
if (!impl) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const manager = impl._jsFunctionLifecycleManager;
|
|
43
|
+
if (manager) {
|
|
44
|
+
manager.dispose?.();
|
|
45
|
+
delete impl._jsFunctionLifecycleManager;
|
|
46
|
+
}
|
|
47
|
+
clearPendingWorkletRuntimeState(impl);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/lifecycle.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,SAAS,+BAA+B,CAAC,IAAuC;IAC9E,IAAI,CAAC,yBAAyB,EAAE,+BAA+B,EAAE,EAAE,CAAC;IACpE,IAAI,CAAC,QAAQ,EAAE,6BAA6B,EAAE,EAAE,CAAC;IACjD,IAAI,CAAC,eAAe,EAAE,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,CAAC;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,2BAA2B,CAAC;IACjD,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,2BAA2B,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxD,CAAC;IACD,+BAA+B,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,CAAC;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,2BAA2B,CAAC;IACjD,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC1C,CAAC;IACD,+BAA+B,CAAC,IAAI,CAAC,CAAC;AACxC,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\nfunction clearPendingWorkletRuntimeState(impl: typeof globalThis.lynxWorkletImpl): void {\n impl._runOnBackgroundDelayImpl?.clearDelayedBackgroundFunctions?.();\n impl._refImpl?.clearFirstScreenWorkletRefMap?.();\n impl._eventDelayImpl?.clearDelayedWorklets?.(true);\n}\n\n/**\n * Retires the current page's worklet-runtime state for an in-place reload or\n * entry re-evaluation on the same main-thread VM.\n *\n * Preserves VM-scoped registrations (`_workletMap`, MainThreadObject\n * definitions, realized object brands, and positive-ID ref entries), while\n * advancing the `runOnBackground` epoch, recreating the lifecycle manager for\n * the next page, and dropping any aborted first-screen refs or queued legacy\n * worklet events.\n */\nexport function resetWorkletRuntimeForReload(): void {\n const impl = globalThis.lynxWorkletImpl;\n if (!impl) {\n return;\n }\n const manager = impl._jsFunctionLifecycleManager;\n if (manager?.recreate) {\n impl._jsFunctionLifecycleManager = manager.recreate();\n }\n clearPendingWorkletRuntimeState(impl);\n}\n\n/**\n * Disposes worklet-runtime state for terminal main-thread destruction\n * (`__DestroyLifetime`).\n *\n * Unlike {@link resetWorkletRuntimeForReload}, this retires the lifecycle\n * manager without allocating a replacement instance.\n */\nexport function disposeWorkletRuntime(): void {\n const impl = globalThis.lynxWorkletImpl;\n if (!impl) {\n return;\n }\n const manager = impl._jsFunctionLifecycleManager;\n if (manager) {\n manager.dispose?.();\n delete impl._jsFunctionLifecycleManager;\n }\n clearPendingWorkletRuntimeState(impl);\n}\n"]}
|
|
@@ -35,7 +35,15 @@ export function flushDelayedRunOnBackgroundFunctions() {
|
|
|
35
35
|
globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl?.runDelayedBackgroundFunctions?.();
|
|
36
36
|
}
|
|
37
37
|
export function clearDelayedRunOnBackgroundFunctions() {
|
|
38
|
-
globalThis.lynxWorkletImpl
|
|
38
|
+
const impl = globalThis.lynxWorkletImpl;
|
|
39
|
+
if (!impl) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const manager = impl._jsFunctionLifecycleManager;
|
|
43
|
+
if (manager?.recreate) {
|
|
44
|
+
impl._jsFunctionLifecycleManager = manager.recreate();
|
|
45
|
+
}
|
|
46
|
+
impl._runOnBackgroundDelayImpl?.clearDelayedBackgroundFunctions?.();
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
41
49
|
* This must be called when the hydration is finished.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observers.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/observers.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAG/D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,UAAmB;IACrE,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAgB,EAChB,UAAsC,EACtC,aAAsB,EACtB,OAAoB;IAEpB,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;QAChC,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;IACD,mDAAmD;IACnD,IAAI,aAAa,EAAE,CAAC;QAClB,UAAU,CAAC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,MAAM,U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B,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oCAAoC;IAClD,UAAU,CAAC,eAAe,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,EAAE,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,oCAAoC;IAClD,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,CAAC;IACxC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,2BAA2B,CAAC;IACjD,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,2BAA2B,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,CAAC,yBAAyB,EAAE,+BAA+B,EAAE,EAAE,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,6BAA6B,EAAE,CAAC;IACtF,8BAA8B,EAAE,CAAC;IACjC,mDAAmD;IACnD,UAAU,CAAC,eAAe,EAAE,eAAe,CAAC,oBAAoB,EAAE,CAAC;AACrE,CAAC","sourcesContent":["// Copyright 2025 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { clearFirstScreenMainThreadRefs } from './bindings.js';\nimport type { Worklet } from './types.js';\n\n/**\n * Hydrates a new worklet ctx from the first-screen ctx without requiring a\n * native Element. Backends compose their own replay semantics around this.\n */\nexport function hydrateWorkletCtx(worklet: Worklet, oldWorklet: Worklet): void {\n globalThis.lynxWorkletImpl?._hydrateCtx(worklet, oldWorklet);\n}\n\n/**\n * This function must be called when a worklet context is updated.\n *\n * @param worklet - The worklet to be updated\n * @param oldWorklet - The old worklet context\n * @param isFirstScreen - Whether it is before the hydration is finished\n * @param element - The element\n */\nexport function onWorkletCtxUpdate(\n worklet: Worklet,\n oldWorklet: Worklet | null | undefined,\n isFirstScreen: boolean,\n element: ElementNode,\n): void {\n if (isFirstScreen && oldWorklet) {\n hydrateWorkletCtx(worklet, oldWorklet);\n }\n // For old version dynamic component compatibility.\n if (isFirstScreen) {\n globalThis.lynxWorkletImpl?._eventDelayImpl.runDelayedWorklet(worklet, element);\n }\n}\n\nexport function retainWorkletCtx(worklet: Worklet): void {\n if (worklet._execId !== undefined) {\n globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager?.addRef(worklet._execId, worklet);\n }\n}\n\nexport function flushDelayedRunOnBackgroundFunctions(): void {\n globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl?.runDelayedBackgroundFunctions?.();\n}\n\nexport function clearDelayedRunOnBackgroundFunctions(): void {\n const impl = globalThis.lynxWorkletImpl;\n if (!impl) {\n return;\n }\n const manager = impl._jsFunctionLifecycleManager;\n if (manager?.recreate) {\n impl._jsFunctionLifecycleManager = manager.recreate();\n }\n impl._runOnBackgroundDelayImpl?.clearDelayedBackgroundFunctions?.();\n}\n\n/**\n * This must be called when the hydration is finished.\n */\nexport function onHydrationFinished(): void {\n globalThis.lynxWorkletImpl?._runOnBackgroundDelayImpl.runDelayedBackgroundFunctions();\n clearFirstScreenMainThreadRefs();\n // For old version dynamic component compatibility.\n globalThis.lynxWorkletImpl?._eventDelayImpl.clearDelayedWorklets();\n}\n"]}
|
|
@@ -34,6 +34,7 @@ export interface JsFnHandle {
|
|
|
34
34
|
_execId?: number;
|
|
35
35
|
_error?: string;
|
|
36
36
|
_isFirstScreen?: boolean;
|
|
37
|
+
_hydratedEpoch?: number;
|
|
37
38
|
/**
|
|
38
39
|
* Stores an array of indexes of runOnBackground tasks that should be processed with a delay.
|
|
39
40
|
* This is used before hydration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/worklet-runtime/bindings/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAsE1D,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,6DAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { Element } from '../api/element.js';\n\nexport type { Element };\n\nexport type WorkletRefId = number;\n\nexport interface WorkletRefImpl<T> {\n _wvid: WorkletRefId;\n _initValue: T;\n _type?: string;\n _lifecycleObserver?: unknown;\n current?: T;\n}\n\nexport interface WorkletRef<T> {\n _wvid: WorkletRefId;\n current: T;\n\n [key: string]: unknown;\n}\n\nexport type ClosureValueType =\n | null\n | undefined\n | string\n | boolean\n | number\n | object;\n\nexport type MainThreadRefInitValuePatch = (\n | [id: number, value: unknown]\n | [id: number, value: unknown, type: string]\n)[];\n\nexport interface Worklet {\n _wkltId: string;\n _workletType?: string;\n _c?: Record<string, ClosureValueType>;\n _execId?: number;\n _jsFn?: Record<string, string>;\n _unmount?: () => void;\n [key: string]: ClosureValueType;\n\n // for pre-0.99 compatibility\n _lepusWorkletHash?: string;\n}\n\n/**\n * @public\n */\nexport interface JsFnHandle {\n _jsFnId?: number;\n _fn?: (...args: unknown[]) => unknown;\n _execId?: number;\n _error?: string;\n _isFirstScreen?: boolean;\n _hydratedEpoch?: number;\n /**\n * Stores an array of indexes of runOnBackground tasks that should be processed with a delay.\n * This is used before hydration.\n */\n _delayIndices?: number[];\n}\n\nexport interface EventCtx {\n _eventReturnResult?: number;\n}\n\nexport enum RunWorkletSource {\n NONE = 0,\n EVENT = 1,\n GESTURE = 2,\n}\n\nexport interface RunWorkletOptions {\n source: RunWorkletSource;\n}\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { ClosureValueType, Worklet } from './bindings/types.js';
|
|
2
2
|
interface EventDelayImpl {
|
|
3
3
|
_delayedWorkletParamsMap: Map<string, ClosureValueType[][]>;
|
|
4
|
+
delayExecUntilJsReady(hash: string, params: ClosureValueType[]): void;
|
|
4
5
|
runDelayedWorklet(worklet: Worklet, element: ElementNode): void;
|
|
5
|
-
clearDelayedWorklets(): void;
|
|
6
|
+
clearDelayedWorklets(cancelScheduled?: boolean): void;
|
|
6
7
|
}
|
|
7
8
|
declare function initEventDelay(): EventDelayImpl;
|
|
8
|
-
|
|
9
|
-
declare function runDelayedWorklet(worklet: Worklet, element: ElementNode): void;
|
|
10
|
-
declare function clearDelayedWorklets(): void;
|
|
11
|
-
export { type EventDelayImpl, initEventDelay, delayExecUntilJsReady, runDelayedWorklet, clearDelayedWorklets };
|
|
9
|
+
export { type EventDelayImpl, initEventDelay };
|
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
import { profile } from './utils/profile.js';
|
|
2
|
-
let impl;
|
|
3
2
|
function initEventDelay() {
|
|
4
|
-
|
|
3
|
+
let generation = 0;
|
|
4
|
+
const instance = {
|
|
5
5
|
_delayedWorkletParamsMap: new Map(),
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
6
|
+
delayExecUntilJsReady(hash, params) {
|
|
7
|
+
profile('delayExecUntilJsReady: ' + hash, () => {
|
|
8
|
+
const map = instance._delayedWorkletParamsMap;
|
|
9
|
+
const paramVec = map.get(hash);
|
|
10
|
+
if (paramVec) {
|
|
11
|
+
paramVec.push(params);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
map.set(hash, [params]);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
runDelayedWorklet(worklet, element) {
|
|
19
|
+
profile('commitDelayedWorklet', () => {
|
|
20
|
+
const paramsVec = instance._delayedWorkletParamsMap.get(worklet._wkltId);
|
|
21
|
+
if (paramsVec === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const scheduledGeneration = generation;
|
|
25
|
+
const leftParamsVec = [];
|
|
26
|
+
paramsVec.forEach((params) => {
|
|
27
|
+
const firstParam = params[0];
|
|
28
|
+
if (firstParam?.currentTarget?.elementRefptr === element) {
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
if (scheduledGeneration !== generation) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
profile('runDelayedWorklet', () => {
|
|
34
|
+
runWorklet(worklet, params);
|
|
35
|
+
});
|
|
36
|
+
}, 0);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
leftParamsVec.push(params);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
instance._delayedWorkletParamsMap.set(worklet._wkltId, leftParamsVec);
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
clearDelayedWorklets(cancelScheduled) {
|
|
46
|
+
if (cancelScheduled) {
|
|
47
|
+
generation++;
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
impl._delayedWorkletParamsMap.set(worklet._wkltId, leftParamsVec);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function clearDelayedWorklets() {
|
|
46
|
-
impl._delayedWorkletParamsMap.clear();
|
|
49
|
+
instance._delayedWorkletParamsMap.clear();
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return instance;
|
|
47
53
|
}
|
|
48
|
-
export { initEventDelay
|
|
54
|
+
export { initEventDelay };
|
|
49
55
|
//# sourceMappingURL=delayWorkletEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delayWorkletEvent.js","sourceRoot":"","sources":["../../src/worklet-runtime/delayWorkletEvent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"delayWorkletEvent.js","sourceRoot":"","sources":["../../src/worklet-runtime/delayWorkletEvent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,SAAS,cAAc;IACrB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,QAAQ,GAAmB;QAC/B,wBAAwB,EAAE,IAAI,GAAG,EAAE;QACnC,qBAAqB,CACnB,IAAY,EACZ,MAA0B;YAE1B,OAAO,CAAC,yBAAyB,GAAG,IAAI,EAAE,GAAG,EAAE;gBAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,wBAAwB,CAAC;gBAC9C,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxB,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,iBAAiB,CAAC,OAAgB,EAAE,OAAoB;YACtD,OAAO,CAAC,sBAAsB,EAAE,GAAG,EAAE;gBACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CACrD,OAAO,CAAC,OAAO,CAChB,CAAC;gBACF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;oBAC5B,OAAO;gBACT,CAAC;gBACD,MAAM,mBAAmB,GAAG,UAAU,CAAC;gBACvC,MAAM,aAAa,GAAyB,EAAE,CAAC;gBAC/C,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAoE,CAAC;oBAChG,IAAI,UAAU,EAAE,aAAa,EAAE,aAAa,KAAK,OAAO,EAAE,CAAC;wBACzD,UAAU,CAAC,GAAG,EAAE;4BACd,IAAI,mBAAmB,KAAK,UAAU,EAAE,CAAC;gCACvC,OAAO;4BACT,CAAC;4BACD,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE;gCAChC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;4BAC9B,CAAC,CAAC,CAAC;wBACL,CAAC,EAAE,CAAC,CAAC,CAAC;oBACR,CAAC;yBAAM,CAAC;wBACN,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC7B,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CACnC,OAAO,CAAC,OAAO,EACf,aAAa,CACd,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QACD,oBAAoB,CAAC,eAAyB;YAC5C,IAAI,eAAe,EAAE,CAAC;gBACpB,UAAU,EAAE,CAAC;YACf,CAAC;YACD,QAAQ,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAC5C,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAuB,cAAc,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport type { ClosureValueType, Worklet } from './bindings/types.js';\nimport { profile } from './utils/profile.js';\n\ninterface EventDelayImpl {\n _delayedWorkletParamsMap: Map<string, ClosureValueType[][]>;\n delayExecUntilJsReady(hash: string, params: ClosureValueType[]): void;\n runDelayedWorklet(worklet: Worklet, element: ElementNode): void;\n clearDelayedWorklets(cancelScheduled?: boolean): void;\n}\n\nfunction initEventDelay(): EventDelayImpl {\n let generation = 0;\n const instance: EventDelayImpl = {\n _delayedWorkletParamsMap: new Map(),\n delayExecUntilJsReady(\n hash: string,\n params: ClosureValueType[],\n ): void {\n profile('delayExecUntilJsReady: ' + hash, () => {\n const map = instance._delayedWorkletParamsMap;\n const paramVec = map.get(hash);\n if (paramVec) {\n paramVec.push(params);\n } else {\n map.set(hash, [params]);\n }\n });\n },\n runDelayedWorklet(worklet: Worklet, element: ElementNode): void {\n profile('commitDelayedWorklet', () => {\n const paramsVec = instance._delayedWorkletParamsMap.get(\n worklet._wkltId,\n );\n if (paramsVec === undefined) {\n return;\n }\n const scheduledGeneration = generation;\n const leftParamsVec: ClosureValueType[][] = [];\n paramsVec.forEach((params) => {\n const firstParam = params[0] as { currentTarget?: { elementRefptr?: ElementNode } } | undefined;\n if (firstParam?.currentTarget?.elementRefptr === element) {\n setTimeout(() => {\n if (scheduledGeneration !== generation) {\n return;\n }\n profile('runDelayedWorklet', () => {\n runWorklet(worklet, params);\n });\n }, 0);\n } else {\n leftParamsVec.push(params);\n }\n });\n instance._delayedWorkletParamsMap.set(\n worklet._wkltId,\n leftParamsVec,\n );\n });\n },\n clearDelayedWorklets(cancelScheduled?: boolean): void {\n if (cancelScheduled) {\n generation++;\n }\n instance._delayedWorkletParamsMap.clear();\n },\n };\n return instance;\n}\n\nexport { type EventDelayImpl, initEventDelay };\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ClosureValueType, Worklet } from './bindings/types.js';
|
|
2
|
-
import type { RunOnBackgroundDelayImpl } from './delayRunOnBackground.js';
|
|
3
2
|
import type { EventDelayImpl } from './delayWorkletEvent.js';
|
|
4
3
|
import type { EomImpl } from './eomImpl.js';
|
|
5
|
-
import type { JsFunctionLifecycleManager } from './
|
|
4
|
+
import type { JsFunctionLifecycleManager, RunOnBackgroundDelayImpl } from './run-on-background/index.js';
|
|
6
5
|
import type { RefImpl } from './workletRef.js';
|
|
7
6
|
declare global {
|
|
8
7
|
var lynxWorkletImpl: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/worklet-runtime/global.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport type { ClosureValueType, Worklet } from './bindings/types.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/worklet-runtime/global.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport type { ClosureValueType, Worklet } from './bindings/types.js';\nimport type { EventDelayImpl } from './delayWorkletEvent.js';\nimport type { EomImpl } from './eomImpl.js';\nimport type { JsFunctionLifecycleManager, RunOnBackgroundDelayImpl } from './run-on-background/index.js';\nimport type { RefImpl } from './workletRef.js';\n\ndeclare global {\n var lynxWorkletImpl: {\n _workletMap: Record<string, (...args: unknown[]) => unknown>;\n _jsFunctionLifecycleManager?: JsFunctionLifecycleManager;\n // for pre-0.99 compatibility\n _eventDelayImpl: EventDelayImpl;\n _refImpl: RefImpl;\n _runOnBackgroundDelayImpl: RunOnBackgroundDelayImpl;\n _hydrateCtx: (worklet: Worklet, firstScreenWorklet: Worklet) => void;\n _eomImpl: EomImpl;\n _runRunOnMainThreadTask: (task: Worklet, params: ClosureValueType[], resolveId: number) => void;\n };\n\n function runWorklet(ctx: Worklet, params: ClosureValueType[]): unknown;\n\n function registerWorklet(type: string, id: string, worklet: (...args: unknown[]) => unknown): void;\n function registerWorkletInternal(type: string, id: string, worklet: (...args: unknown[]) => unknown): void;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { hydrateJsFnHandles } from './run-on-background/index.js';
|
|
4
5
|
import { profile } from './utils/profile.js';
|
|
5
6
|
import { hydrateWorkletValue, isHydratedWorkletValue } from './workletRef.js';
|
|
6
7
|
/**
|
|
@@ -38,7 +39,7 @@ function hydrateCtxImpl(ctx, firstScreenCtx, execId) {
|
|
|
38
39
|
hydrateMainThreadRef(ctxObj[key], firstScreenCtxObj);
|
|
39
40
|
}
|
|
40
41
|
else if (key === '_jsFn') {
|
|
41
|
-
|
|
42
|
+
hydrateJsFnHandles(ctxObj[key], firstScreenCtxObj[key], execId);
|
|
42
43
|
}
|
|
43
44
|
else {
|
|
44
45
|
const firstScreenValue = typeof firstScreenCtxObj[key] === 'function'
|
|
@@ -75,35 +76,4 @@ function hydrateWorkletValueHandle(handle, value) {
|
|
|
75
76
|
}
|
|
76
77
|
hydrateWorkletValue(handle, value);
|
|
77
78
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Hydrates delayed `runOnBackground` tasks.
|
|
80
|
-
* This function ensures that any `runOnBackground` calls that were delayed
|
|
81
|
-
* during the first-screen rendering are correctly associated with their
|
|
82
|
-
* respective JavaScript function handles in the hydrated Worklet context.
|
|
83
|
-
*/
|
|
84
|
-
function hydrateDelayRunOnBackgroundTasks(fnObjs, // example: {"_jsFn1":{"_jsFnId":1}}
|
|
85
|
-
firstScreenFnObjs, // example: {"_jsFn1":{"_isFirstScreen":true,"_delayIndices":[0]}}
|
|
86
|
-
execId) {
|
|
87
|
-
for (const fnName in fnObjs) {
|
|
88
|
-
const fnObj = fnObjs[fnName];
|
|
89
|
-
const firstScreenFnObj = firstScreenFnObjs[fnName];
|
|
90
|
-
if (!firstScreenFnObj?._delayIndices) {
|
|
91
|
-
if (firstScreenFnObj) {
|
|
92
|
-
firstScreenFnObj._isFirstScreen = false;
|
|
93
|
-
firstScreenFnObj._execId = execId;
|
|
94
|
-
Object.assign(firstScreenFnObj, fnObj);
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
for (const index of firstScreenFnObj._delayIndices) {
|
|
99
|
-
const details = lynxWorkletImpl._runOnBackgroundDelayImpl
|
|
100
|
-
.delayedBackgroundFunctionArray[index];
|
|
101
|
-
if (!details) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
fnObj._execId = execId;
|
|
105
|
-
details.jsFnHandle = fnObj;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
79
|
//# sourceMappingURL=hydrate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate.js","sourceRoot":"","sources":["../../src/worklet-runtime/hydrate.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAU1D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY,EAAE,cAAuB;IAC9D,OAAO,CAAC,YAAY,EAAE,GAAG,EAAE;QACzB,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,OAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CACrB,GAAqB,EACrB,cAAgC,EAChC,MAAc;IAEd,IACE,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,cAAc;WAC/C,OAAO,cAAc,KAAK,QAAQ;QACrC,OAAO;IAET,MAAM,MAAM,GAAG,GAAuC,C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AC5C,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAC3B,KAAmB,EACnB,KAA8B;IAE9B,IAAI,YAAY,IAAI,KAAK,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IACD,eAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,KAA4B,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAChC,MAA+B,EAC/B,KAAuB;IAEvB,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,6DAA6D;QAC7D,OAAO;IACT,CAAC;IACD,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type {\n ClosureValueType,\n JsFnHandle,\n Worklet,\n WorkletRef,\n WorkletRefId,\n WorkletRefImpl,\n} from './bindings/index.js';\nimport { hydrateJsFnHandles } from './run-on-background/index.js';\nimport { profile } from './utils/profile.js';\nimport { hydrateWorkletValue, isHydratedWorkletValue } from './workletRef.js';\n\n/**\n * Hydrates a Worklet context with data from a first-screen Worklet context.\n * This process is typically used to run all delayed `runOnBackground` functions\n * and initialize `WorkletRef` values modified before hydration.\n *\n * @param ctx The target Worklet context to be hydrated.\n * @param firstScreenCtx The Worklet context from the first screen rendering,\n * containing the data to hydrate with.\n */\nexport function hydrateCtx(ctx: Worklet, firstScreenCtx: Worklet): void {\n profile('hydrateCtx', () => {\n hydrateCtxImpl(ctx, firstScreenCtx, ctx._execId!);\n });\n}\n\nfunction hydrateCtxImpl(\n ctx: ClosureValueType,\n firstScreenCtx: ClosureValueType,\n execId: number,\n): void {\n if (\n !ctx || typeof ctx !== 'object' || !firstScreenCtx\n || typeof firstScreenCtx !== 'object'\n ) return;\n\n const ctxObj = ctx as Record<string, ClosureValueType>;\n const firstScreenCtxObj = firstScreenCtx as Record<string, ClosureValueType>;\n\n if (ctxObj['_wkltId'] && ctxObj['_wkltId'] !== firstScreenCtxObj['_wkltId']) {\n return;\n }\n\n // Typed handles (including `_type: 'main-thread'` mutable cells) hydrate\n // atomically without walking their initialization payload. Untyped legacy\n // refs continue through the existing `_wvid` path below.\n if (isTypedWorkletRefDescriptor(ctxObj)) {\n hydrateWorkletValueHandle(ctxObj, firstScreenCtxObj);\n return;\n }\n for (const key in ctx) {\n if (key === '_wvid') {\n hydrateMainThreadRef(\n ctxObj[key] as WorkletRefId,\n firstScreenCtxObj as unknown as WorkletRefImpl<unknown>,\n );\n } else if (key === '_jsFn') {\n hydrateJsFnHandles(\n ctxObj[key] as Record<string, JsFnHandle>,\n firstScreenCtxObj[key] as Record<string, JsFnHandle>,\n execId,\n );\n } else {\n const firstScreenValue = typeof firstScreenCtxObj[key] === 'function'\n ? (firstScreenCtxObj[key] as { boundCtx?: object }).boundCtx as ClosureValueType\n : firstScreenCtxObj[key];\n hydrateCtxImpl(ctxObj[key], firstScreenValue, execId);\n }\n }\n}\n\nfunction isTypedWorkletRefDescriptor(\n value: object,\n): value is WorkletRefImpl<unknown> {\n const descriptor = value as Partial<WorkletRefImpl<unknown>>;\n return typeof descriptor._wvid === 'number'\n && typeof descriptor._type === 'string';\n}\n\n/**\n * Hydrates a WorkletRef on the main thread.\n * This maps the positive-ID background handle to the target realized during\n * first-screen rendering, while leaving an unused first-screen handle alone.\n */\nfunction hydrateMainThreadRef(\n refId: WorkletRefId,\n value: WorkletRefImpl<unknown>,\n): void {\n if ('_initValue' in value) {\n return;\n }\n lynxWorkletImpl!._refImpl._workletRefMap[refId] = value as WorkletRef<unknown>;\n}\n\n/**\n * Hydrates a typed worklet handle on the main thread.\n * The target is the object or mutable cell realized from the matching first-screen handle.\n */\nfunction hydrateWorkletValueHandle(\n handle: WorkletRefImpl<unknown>,\n value: ClosureValueType,\n): void {\n if (!isHydratedWorkletValue(value)) {\n // The handle was not accessed during first-screen rendering.\n return;\n }\n hydrateWorkletValue(handle, value);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JsFunctionLifecycleManager } from './lifecycle.js';
|
|
2
|
+
import type { JsFnHandle, Worklet } from '../bindings/types.js';
|
|
3
|
+
interface Details {
|
|
4
|
+
task: (fnId: number, execId: number) => void;
|
|
5
|
+
jsFnHandle?: JsFnHandle;
|
|
6
|
+
}
|
|
7
|
+
interface RunOnBackgroundDelayImpl {
|
|
8
|
+
delayedBackgroundFunctionArray: Array<Details | undefined>;
|
|
9
|
+
epoch: number;
|
|
10
|
+
hasHydrated: boolean;
|
|
11
|
+
clearDelayedBackgroundFunctions(): void;
|
|
12
|
+
delayRunOnBackground(fnObj: JsFnHandle, fn: (fnId: number, execId: number) => void): void;
|
|
13
|
+
runDelayedBackgroundFunctions(): void;
|
|
14
|
+
}
|
|
15
|
+
declare function initRunOnBackgroundDelay(): RunOnBackgroundDelayImpl;
|
|
16
|
+
/**
|
|
17
|
+
* Hydrates first-screen `JsFnHandle` placeholders and associates any queued
|
|
18
|
+
* pre-hydration `runOnBackground` tasks with their hydrated handles.
|
|
19
|
+
*/
|
|
20
|
+
declare function hydrateJsFnHandles(fnObjs: Record<string, JsFnHandle>, // example: {"_jsFn1":{"_jsFnId":1}}
|
|
21
|
+
firstScreenFnObjs: Record<string, JsFnHandle>, // example: {"_jsFn1":{"_isFirstScreen":true,"_delayIndices":[0]}}
|
|
22
|
+
execId: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Binds and retains a captured `JsFnHandle` during worklet context transformation,
|
|
25
|
+
* skipping handles from retired reload epochs and preserving prebound `_execId`s.
|
|
26
|
+
*/
|
|
27
|
+
declare function bindCapturedJsFnHandle(handle: JsFnHandle, rootCtx: Worklet): void;
|
|
28
|
+
export { type RunOnBackgroundDelayImpl, JsFunctionLifecycleManager, initRunOnBackgroundDelay, hydrateJsFnHandles, bindCapturedJsFnHandle, };
|