@lynx-js/react 0.128.0 → 0.129.1
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 +34 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/entry-re-eval.test.ts +161 -0
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- package/runtime/__test__/core/reload-scoped-dual-thread-communication.test.ts +129 -0
- package/runtime/__test__/core/thread-function-call.test.ts +1 -0
- package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +2 -0
- package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
- package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
- package/runtime/__test__/element-template/native/index.test.ts +8 -0
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/main-thread-ref-init-value.test.ts +100 -0
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +83 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +104 -0
- package/runtime/__test__/element-template/native/reload.test.ts +79 -1
- package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +104 -47
- package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +7 -1
- package/runtime/__test__/element-template/runtime/background/re-eval-reload.test.ts +69 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
- package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +31 -5
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +214 -10
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
- package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +2 -0
- package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +121 -26
- package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +89 -2
- package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +5 -0
- package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
- package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
- package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
- package/runtime/__test__/shared/component-stack.test.ts +211 -0
- package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
- package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
- package/runtime/__test__/snapshot/lifecycle/re-eval-reload.test.jsx +114 -0
- package/runtime/__test__/snapshot/lifecycle/reload-background-function.test.jsx +169 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-background.test.jsx +63 -0
- package/runtime/__test__/snapshot/lifecycle/reload-delayed-main-thread.test.jsx +103 -0
- package/runtime/__test__/snapshot/lifecycle.test.jsx +61 -1
- package/runtime/__test__/snapshot/lynx/lazy-effect-scheduling.test.jsx +105 -0
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
- package/runtime/__test__/snapshot/ssr.test.jsx +2 -2
- package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +6 -11
- package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +1 -1
- package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +24 -1
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +27 -1
- package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
- package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +46 -0
- package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +3 -3
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
- package/runtime/lazy/element-template-internal.js +0 -1
- package/runtime/lazy/internal.js +1 -1
- package/runtime/lazy/jsx-dev-runtime.js +1 -1
- package/runtime/lazy/jsx-runtime.js +1 -1
- package/runtime/lazy/legacy-react-runtime.js +1 -1
- package/runtime/lazy/react-lepus.js +1 -1
- package/runtime/lazy/react.js +1 -1
- package/runtime/lib/core/background-function/exec-map.d.ts +2 -0
- package/runtime/lib/core/background-function/exec-map.js +7 -0
- package/runtime/lib/core/background-function/exec-map.js.map +1 -1
- package/runtime/lib/core/background-function/run-on-background.js +15 -16
- package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
- package/runtime/lib/core/capture-main-thread-object.js +2 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- package/runtime/lib/core/card-lifetime.d.ts +5 -0
- package/runtime/lib/core/card-lifetime.js +17 -0
- package/runtime/lib/core/card-lifetime.js.map +1 -0
- package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
- package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
- package/runtime/lib/core/entry-reload.d.ts +7 -0
- package/runtime/lib/core/entry-reload.js +49 -0
- package/runtime/lib/core/entry-reload.js.map +1 -0
- package/runtime/lib/core/lynx/lazy-bundle.js +5 -2
- package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
- package/runtime/lib/core/lynx-data-processors.js +3 -0
- package/runtime/lib/core/lynx-data-processors.js.map +1 -1
- package/runtime/lib/core/main-thread-ref-id.js +4 -4
- package/runtime/lib/core/main-thread-ref-id.js.map +1 -1
- package/runtime/lib/core/reload-scoped-event.d.ts +5 -0
- package/runtime/lib/core/reload-scoped-event.js +26 -0
- package/runtime/lib/core/reload-scoped-event.js.map +1 -0
- package/runtime/lib/core/reload-version.js +4 -3
- package/runtime/lib/core/reload-version.js.map +1 -1
- package/runtime/lib/core/runtime-destroy.d.ts +2 -0
- package/runtime/lib/core/runtime-destroy.js +10 -1
- package/runtime/lib/core/runtime-destroy.js.map +1 -1
- package/runtime/lib/core/thread-function-call/main-thread.js +5 -4
- package/runtime/lib/core/thread-function-call/main-thread.js.map +1 -1
- package/runtime/lib/core/thread-function-call/return-value.js +6 -5
- package/runtime/lib/core/thread-function-call/return-value.js.map +1 -1
- package/runtime/lib/document.js +0 -5
- package/runtime/lib/document.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +24 -22
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/hydration-listener.js +2 -6
- package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
- package/runtime/lib/element-template/client/root.d.ts +1 -1
- package/runtime/lib/element-template/client/root.js.map +1 -1
- package/runtime/lib/element-template/index.d.ts +2 -2
- package/runtime/lib/element-template/index.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -1
- package/runtime/lib/element-template/internal.js +0 -13
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/lynx/env.js.map +1 -1
- package/runtime/lib/element-template/main-thread-ref-init-value.d.ts +3 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js +38 -0
- package/runtime/lib/element-template/main-thread-ref-init-value.js.map +1 -0
- package/runtime/lib/element-template/native/flush.d.ts +1 -0
- package/runtime/lib/element-template/native/flush.js +9 -0
- package/runtime/lib/element-template/native/flush.js.map +1 -0
- package/runtime/lib/element-template/native/index.js +2 -0
- package/runtime/lib/element-template/native/index.js.map +1 -1
- package/runtime/lib/element-template/native/main-thread-api.js +3 -7
- package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
- package/runtime/lib/element-template/native/mts-destroy.js +10 -2
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +58 -54
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.d.ts +1 -1
- package/runtime/lib/element-template/native/reload-background.js +12 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.d.ts +6 -0
- package/runtime/lib/element-template/native/reload-main-thread.js +20 -3
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.d.ts +2 -1
- package/runtime/lib/element-template/protocol/lifecycle-constant.js +1 -0
- package/runtime/lib/element-template/protocol/lifecycle-constant.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +0 -2
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
- package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +4 -0
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
- package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
- package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
- package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
- 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 +1 -0
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +41 -21
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/internal.d.ts +1 -1
- package/runtime/lib/internal.js +1 -1
- package/runtime/lib/internal.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +2 -125
- package/runtime/lib/lynx-api.js.map +1 -1
- package/runtime/lib/shared/component-stack.d.ts +0 -4
- package/runtime/lib/shared/component-stack.js +21 -5
- package/runtime/lib/shared/component-stack.js.map +1 -1
- package/runtime/lib/shared/index-map.d.ts +4 -1
- package/runtime/lib/shared/index-map.js +5 -2
- package/runtime/lib/shared/index-map.js.map +1 -1
- package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
- package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js +6 -0
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +6 -2
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +21 -18
- package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
- package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
- package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/reload.d.ts +9 -2
- package/runtime/lib/snapshot/lifecycle/reload.js +29 -8
- package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
- package/runtime/lib/snapshot/list/list.js +3 -2
- package/runtime/lib/snapshot/list/list.js.map +1 -1
- package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
- package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
- package/runtime/lib/snapshot/lynx/calledByNative.js +14 -11
- package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
- package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
- package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
- package/runtime/lib/snapshot/renderToOpcodes/opcodes.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/list.js +2 -1
- package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +4 -2
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +11 -11
- package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +1 -0
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +6 -1
- package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ctx.d.ts +1 -1
- package/runtime/lib/snapshot/worklet/ctx.js +6 -1
- package/runtime/lib/snapshot/worklet/ctx.js.map +1 -1
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js +6 -0
- package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
- package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
- package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js +3 -1
- package/runtime/lib/worklet-runtime/delayRunOnBackground.js.map +1 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +8 -1
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
- package/runtime/lib/worklet-runtime/listeners.js +2 -2
- package/runtime/lib/worklet-runtime/listeners.js.map +1 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js +3 -1
- package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -1
- package/runtime/lib/worklet-runtime/runOnMainThread.js +4 -3
- package/runtime/lib/worklet-runtime/runOnMainThread.js.map +1 -1
- package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
- package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
- package/runtime/package.json +2 -3
- package/runtime/src/core/background-function/exec-map.ts +9 -0
- package/runtime/src/core/background-function/run-on-background.ts +14 -16
- package/runtime/src/core/capture-main-thread-object.ts +2 -1
- package/runtime/src/core/card-lifetime.ts +18 -0
- package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
- package/runtime/src/core/entry-reload.ts +63 -0
- package/runtime/src/core/lynx/lazy-bundle.ts +5 -2
- package/runtime/src/core/lynx-data-processors.ts +124 -1
- package/runtime/src/core/main-thread-ref-id.ts +5 -4
- package/runtime/src/core/reload-scoped-event.ts +35 -0
- package/runtime/src/core/reload-version.ts +5 -3
- package/runtime/src/core/runtime-destroy.ts +12 -1
- package/runtime/src/core/thread-function-call/main-thread.ts +4 -4
- package/runtime/src/core/thread-function-call/return-value.ts +6 -5
- package/runtime/src/document.ts +0 -6
- package/runtime/src/element-template/background/commit-hook.ts +32 -23
- package/runtime/src/element-template/background/hydration-listener.ts +2 -6
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +0 -20
- package/runtime/src/element-template/lynx/env.ts +1 -1
- package/runtime/src/element-template/main-thread-ref-init-value.ts +44 -0
- package/runtime/src/element-template/native/flush.ts +10 -0
- package/runtime/src/element-template/native/index.ts +2 -0
- package/runtime/src/element-template/native/main-thread-api.ts +3 -6
- package/runtime/src/element-template/native/mts-destroy.ts +10 -2
- package/runtime/src/element-template/native/patch-listener.ts +62 -62
- package/runtime/src/element-template/native/reload-background.ts +13 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +32 -3
- package/runtime/src/element-template/protocol/lifecycle-constant.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +0 -15
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +5 -0
- package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
- package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
- package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +51 -21
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +2 -2
- package/runtime/src/element-template/types.d.ts +6 -0
- package/runtime/src/internal.ts +1 -1
- package/runtime/src/lynx-api.ts +2 -124
- package/runtime/src/shared/component-stack.ts +22 -5
- package/runtime/src/shared/index-map.ts +3 -2
- package/runtime/src/snapshot/lifecycle/destroy.ts +7 -0
- package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +26 -19
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
- package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
- package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
- package/runtime/src/snapshot/lifecycle/reload.ts +47 -11
- package/runtime/src/snapshot/list/list.ts +9 -2
- package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
- package/runtime/src/snapshot/lynx/calledByNative.ts +14 -13
- package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
- package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
- package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
- package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
- package/runtime/src/snapshot/snapshot/list.ts +5 -1
- package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +19 -12
- package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +10 -1
- package/runtime/src/snapshot/worklet/ctx.ts +10 -1
- package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +6 -0
- package/runtime/src/worklet-runtime/README.md +33 -0
- package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
- package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
- package/runtime/src/worklet-runtime/delayRunOnBackground.ts +3 -1
- package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +8 -1
- package/runtime/src/worklet-runtime/listeners.ts +4 -7
- package/runtime/src/worklet-runtime/mainThreadObject.ts +2 -1
- package/runtime/src/worklet-runtime/runOnMainThread.ts +4 -3
- package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
- package/runtime/types/types.d.ts +3 -1
- package/runtime/vitest.config.ts +0 -2
- package/testing-library/.turbo/turbo-build.log +7 -7
- package/testing-library/src/__tests__/act.test.jsx +0 -7
- package/testing-library/src/__tests__/alog.test.jsx +12 -54
- package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
- package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
- package/testing-library/src/__tests__/worklet.test.jsx +59 -5
- package/transform/.turbo/turbo-build$colon$wasm.log +63 -136
- package/transform/__test__/defines.spec.js +137 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_worklet/definition_imports.rs +97 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +56 -48
- package/transform/crates/swc_plugin_worklet/lib.rs +400 -595
- package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +6 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +9 -0
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +12 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +3 -1
- package/transform/package.json +0 -1
- package/transform/src/lib.rs +173 -12
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +105 -32
- package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +193 -194
- package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
- package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
- package/runtime/lib/snapshot/worklet/hmr.js +0 -28
- package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
- package/runtime/src/snapshot/worklet/hmr.ts +0 -34
- /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
- /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
|
@@ -17,26 +17,6 @@ export interface ListUpdateInfo {
|
|
|
17
17
|
onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// class ListUpdateInfoDiffing implements ListUpdateInfo {
|
|
21
|
-
// private oldChildNodes: SnapshotInstance[];
|
|
22
|
-
// constructor(private list: SnapshotInstance) {
|
|
23
|
-
// this.oldChildNodes = list.childNodes;
|
|
24
|
-
// }
|
|
25
|
-
// flush(): void {
|
|
26
|
-
// Object.defineProperty(SnapshotInstance.prototype, "key", {
|
|
27
|
-
// get: function () {
|
|
28
|
-
// return this.values[0]["item-key"];
|
|
29
|
-
// },
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
|
-
// }
|
|
33
|
-
// onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance | undefined): void {}
|
|
34
|
-
// onRemoveChild(child: SnapshotInstance): void {}
|
|
35
|
-
// onSetAttribute(child: SnapshotInstance, attr: any): void {
|
|
36
|
-
// throw new Error("Method not implemented.");
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
20
|
interface InsertAction {
|
|
41
21
|
position: number;
|
|
42
22
|
type: string;
|
|
@@ -58,30 +38,14 @@ interface ListOperations {
|
|
|
58
38
|
export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
59
39
|
constructor(private list: SnapshotInstance) {
|
|
60
40
|
this.oldChildNodes = list.childNodes;
|
|
61
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
62
41
|
}
|
|
63
42
|
|
|
64
|
-
// private __commitAndReset() {
|
|
65
|
-
// (this.__pendingAttributes ??= []).push(this.__toAttribute());
|
|
66
|
-
// this.oldChildNodes = this.list.childNodes;
|
|
67
|
-
// this.oldChildNodesSet = new Set(this.oldChildNodes);
|
|
68
|
-
// this.removeChild1.clear();
|
|
69
|
-
// this.removeChild2.clear();
|
|
70
|
-
// this.insertBefore.clear();
|
|
71
|
-
// this.appendChild.length = 0;
|
|
72
|
-
// this.platformInfoUpdate.clear();
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
43
|
flush(): undefined | number {
|
|
76
44
|
if (!this.list.__elements) {
|
|
77
45
|
return undefined;
|
|
78
46
|
}
|
|
79
47
|
const elementIndex = this.list.__snapshot_def.slot[0]![1];
|
|
80
48
|
const listElement = this.list.__elements[elementIndex]!;
|
|
81
|
-
// this.__pendingAttributes?.forEach(pendingAttribute => {
|
|
82
|
-
// __SetAttribute(listElement, "update-list-info", pendingAttribute);
|
|
83
|
-
// __FlushElementTree(listElement);
|
|
84
|
-
// });
|
|
85
49
|
const updateListInfo = this.__toAttribute();
|
|
86
50
|
|
|
87
51
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -132,7 +96,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
132
96
|
}
|
|
133
97
|
|
|
134
98
|
private oldChildNodes: SnapshotInstance[];
|
|
135
|
-
// private oldChildNodesSet: Set<SnapshotInstance>;
|
|
136
99
|
private removeChild = new Set<SnapshotInstance>();
|
|
137
100
|
private insertBefore = new Map<SnapshotInstance, SnapshotInstance[]>(); // insert V before K
|
|
138
101
|
private appendChild = [] as SnapshotInstance[];
|
|
@@ -140,15 +103,9 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
140
103
|
|
|
141
104
|
onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void {
|
|
142
105
|
if (newNode.parentNode) {
|
|
143
|
-
// if (!this.oldChildNodesSet.has(newNode)) {
|
|
144
|
-
// this.__commitAndReset();
|
|
145
|
-
// }
|
|
146
106
|
this.removeChild.add(newNode);
|
|
147
107
|
}
|
|
148
108
|
if (existingNode) {
|
|
149
|
-
// if (!this.oldChildNodesSet.has(existingNode)) {
|
|
150
|
-
// this.__commitAndReset();
|
|
151
|
-
// }
|
|
152
109
|
const newChildren = this.insertBefore.get(existingNode) ?? [];
|
|
153
110
|
newChildren.push(newNode);
|
|
154
111
|
this.insertBefore.set(existingNode, newChildren);
|
|
@@ -158,9 +115,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
158
115
|
}
|
|
159
116
|
|
|
160
117
|
onRemoveChild(child: SnapshotInstance): void {
|
|
161
|
-
// if (!this.oldChildNodesSet.has(child)) {
|
|
162
|
-
// this.__commitAndReset();
|
|
163
|
-
// }
|
|
164
118
|
this.removeChild.add(child);
|
|
165
119
|
}
|
|
166
120
|
|
|
@@ -254,12 +208,6 @@ export class ListUpdateInfoRecording implements ListUpdateInfo {
|
|
|
254
208
|
}
|
|
255
209
|
|
|
256
210
|
toJSON(): [ListOperations] {
|
|
257
|
-
// if (this.__pendingAttributes) {
|
|
258
|
-
// return [...this.__pendingAttributes, this.__toAttribute()];
|
|
259
|
-
// } else {
|
|
260
|
-
// return [this.__toAttribute()];
|
|
261
|
-
// }
|
|
262
|
-
|
|
263
211
|
return [this.__toAttribute()] as const;
|
|
264
212
|
}
|
|
265
213
|
}
|
|
@@ -6,8 +6,7 @@ import { markTiming, setPipeline } from '../../core/performance.js';
|
|
|
6
6
|
import { __root, setRoot } from '../../root.js';
|
|
7
7
|
import { LifecycleConstant } from '../lifecycle/constant.js';
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
isFirstScreenSynced,
|
|
9
|
+
firstScreenSync,
|
|
11
10
|
onFirstScreenSyncReady,
|
|
12
11
|
onFirstScreenTreeReady,
|
|
13
12
|
resetFirstScreenSyncState,
|
|
@@ -126,7 +125,7 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
126
125
|
applyUpdatePageData(data, options);
|
|
127
126
|
|
|
128
127
|
const flushOptions = options ?? {};
|
|
129
|
-
if (!
|
|
128
|
+
if (!firstScreenSync.isSynced) {
|
|
130
129
|
if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
|
|
131
130
|
// a `markFirstScreenSyncReady` call during the re-render below must not
|
|
132
131
|
// sync the half-rendered tree; it is deferred to `onFirstScreenTreeReady`
|
|
@@ -139,7 +138,7 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
139
138
|
|
|
140
139
|
setPipeline(options?.pipelineOptions);
|
|
141
140
|
markTiming('updateDiffVdomStart');
|
|
142
|
-
{
|
|
141
|
+
try {
|
|
143
142
|
__pendingListUpdates.clearAttachedLists();
|
|
144
143
|
renderMainThread();
|
|
145
144
|
// As said by codename `firstScreenEventIdSwap`, this swap will only be used for event remap,
|
|
@@ -147,23 +146,25 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
147
146
|
hydrate(
|
|
148
147
|
oldRoot as SnapshotInstance,
|
|
149
148
|
__root as SnapshotInstance,
|
|
150
|
-
{ skipUnRef: true, swap:
|
|
149
|
+
{ skipUnRef: true, swap: firstScreenSync.eventIdSwap },
|
|
151
150
|
);
|
|
152
151
|
|
|
153
152
|
// always call this before `__FlushElementTree`
|
|
154
153
|
__pendingListUpdates.flush();
|
|
155
154
|
applyRefQueue();
|
|
156
|
-
}
|
|
157
155
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
if (__FIRST_SCREEN_SYNC_TIMING__ === 'manual') {
|
|
157
|
+
onFirstScreenTreeReady();
|
|
158
|
+
}
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
flushOptions.triggerDataUpdated = true;
|
|
161
|
+
markTiming('updateDiffVdomEnd');
|
|
164
162
|
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
if (typeof lepusng_gc === 'function') {
|
|
164
|
+
lepusng_gc();
|
|
165
|
+
}
|
|
166
|
+
} finally {
|
|
167
|
+
setPipeline(undefined);
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -99,64 +99,6 @@ export function diffArrayLepus<A extends Typed, B extends Typed>(
|
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// export function diffIterableLepus<A extends Typed, B extends Typed>(
|
|
103
|
-
// before: A[],
|
|
104
|
-
// after: Iterable<B>,
|
|
105
|
-
// isSameType: (a: A, b: B) => boolean,
|
|
106
|
-
// onDiffChildren: (a: A, b: B) => void
|
|
107
|
-
// ): DiffResult<B> {
|
|
108
|
-
// let returnResult = EMPTY_DIFF_RESULT as DiffResult<B>;
|
|
109
|
-
// let lastPlacedIndex = 0;
|
|
110
|
-
// const result: DiffResult<B> = {
|
|
111
|
-
// $$diff: true,
|
|
112
|
-
// i: {},
|
|
113
|
-
// r: [],
|
|
114
|
-
// m: {},
|
|
115
|
-
// };
|
|
116
|
-
// const beforeMap: Record<string, Set<[A, number]>> = {};
|
|
117
|
-
|
|
118
|
-
// for (let i = 0; i < before.length; i++) {
|
|
119
|
-
// let node = before[i];
|
|
120
|
-
// (beforeMap[node.type] ??= new Set()).add([node, i]);
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
// let i = 0;
|
|
124
|
-
// for (const afterNode of after) {
|
|
125
|
-
// const beforeNodes = beforeMap[afterNode.type];
|
|
126
|
-
// let beforeNode: [A, number];
|
|
127
|
-
|
|
128
|
-
// if (beforeNodes && (([beforeNode] = beforeNodes), beforeNode) && isSameType(beforeNode[0], afterNode)) {
|
|
129
|
-
// // Reuse old node
|
|
130
|
-
// beforeNodes.delete(beforeNode);
|
|
131
|
-
|
|
132
|
-
// const oldIndex = beforeNode[1];
|
|
133
|
-
// onDiffChildren(beforeNode[0], afterNode);
|
|
134
|
-
// if (oldIndex < lastPlacedIndex) {
|
|
135
|
-
// result.m[oldIndex] = i;
|
|
136
|
-
// returnResult = result;
|
|
137
|
-
// i++;
|
|
138
|
-
// continue;
|
|
139
|
-
// } else {
|
|
140
|
-
// lastPlacedIndex = oldIndex;
|
|
141
|
-
// }
|
|
142
|
-
// } else {
|
|
143
|
-
// // Create new node
|
|
144
|
-
// result.i[i] = afterNode;
|
|
145
|
-
// returnResult = result;
|
|
146
|
-
// }
|
|
147
|
-
// i++;
|
|
148
|
-
// }
|
|
149
|
-
// // delete
|
|
150
|
-
// for (const k in beforeMap) {
|
|
151
|
-
// for (const [, i] of beforeMap[k]) {
|
|
152
|
-
// result.r.push(i);
|
|
153
|
-
// returnResult = result;
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
|
|
157
|
-
// return result;
|
|
158
|
-
// }
|
|
159
|
-
|
|
160
102
|
export function diffArrayAction<T, K>(
|
|
161
103
|
before: T[],
|
|
162
104
|
diffResult: DiffResult<K>,
|
|
@@ -39,7 +39,7 @@ const isArray = /* @__PURE__ */ Array.isArray;
|
|
|
39
39
|
const assign = /* @__PURE__ */ Object.assign;
|
|
40
40
|
|
|
41
41
|
// Global state for the current render pass
|
|
42
|
-
let beforeDiff, beforeDiff2, afterDiff, renderHook,
|
|
42
|
+
let beforeDiff, beforeDiff2, afterDiff, renderHook, unmountHook;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Render Preact JSX + Components to an HTML string.
|
|
@@ -60,7 +60,7 @@ export function renderToString(vnode: any, context: any, into: SnapshotInstance)
|
|
|
60
60
|
beforeDiff2 = options[DIFF2];
|
|
61
61
|
afterDiff = options[DIFFED];
|
|
62
62
|
renderHook = options[RENDER];
|
|
63
|
-
|
|
63
|
+
unmountHook = options.unmount;
|
|
64
64
|
|
|
65
65
|
const parent = h(Fragment, null);
|
|
66
66
|
parent[CHILDREN] = [vnode];
|
|
@@ -194,7 +194,7 @@ function _renderToString(
|
|
|
194
194
|
opcodes,
|
|
195
195
|
/* v8 ignore start */
|
|
196
196
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
197
|
-
/* v8 ignore
|
|
197
|
+
/* v8 ignore stop */
|
|
198
198
|
into,
|
|
199
199
|
);
|
|
200
200
|
}
|
|
@@ -282,7 +282,7 @@ function _renderToString(
|
|
|
282
282
|
opcodes,
|
|
283
283
|
/* v8 ignore start */
|
|
284
284
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
285
|
-
/* v8 ignore
|
|
285
|
+
/* v8 ignore stop */
|
|
286
286
|
into,
|
|
287
287
|
);
|
|
288
288
|
} catch (e) {
|
|
@@ -312,7 +312,7 @@ function _renderToString(
|
|
|
312
312
|
opcodes,
|
|
313
313
|
/* v8 ignore start */
|
|
314
314
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
315
|
-
/* v8 ignore
|
|
315
|
+
/* v8 ignore stop */
|
|
316
316
|
into,
|
|
317
317
|
);
|
|
318
318
|
}
|
|
@@ -323,7 +323,7 @@ function _renderToString(
|
|
|
323
323
|
if (afterDiff) afterDiff(vnode);
|
|
324
324
|
vnode[PARENT] = undefined;
|
|
325
325
|
|
|
326
|
-
if (
|
|
326
|
+
if (unmountHook) unmountHook(vnode);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
return;
|
|
@@ -406,14 +406,14 @@ function _renderToString(
|
|
|
406
406
|
opcodes,
|
|
407
407
|
/* v8 ignore start */
|
|
408
408
|
__ENABLE_SSR__ ? opcodes.length : 0,
|
|
409
|
-
/* v8 ignore
|
|
409
|
+
/* v8 ignore stop */
|
|
410
410
|
vnode,
|
|
411
411
|
);
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
if (afterDiff) afterDiff(vnode);
|
|
415
415
|
vnode[PARENT] = undefined;
|
|
416
|
-
if (
|
|
416
|
+
if (unmountHook) unmountHook(vnode);
|
|
417
417
|
|
|
418
418
|
if (__ENABLE_SSR__) {
|
|
419
419
|
opcodes.push(__OpEnd);
|
|
@@ -97,60 +97,3 @@ export function ssrHydrateByOpcodes(
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
// export function renderOpcodesInto(opcodes: any[], into: SnapshotInstance): void {
|
|
102
|
-
// let top: SnapshotInstance = into;
|
|
103
|
-
// const stack: SnapshotInstance[] = [into];
|
|
104
|
-
// for (let i = 0; i < opcodes.length;) {
|
|
105
|
-
// const opcode = opcodes[i];
|
|
106
|
-
// switch (opcode) {
|
|
107
|
-
// case OpcodeBegin: {
|
|
108
|
-
// const p = top;
|
|
109
|
-
// top = opcodes[i + 1];
|
|
110
|
-
// // @ts-ignore
|
|
111
|
-
// if (top.__parent) {
|
|
112
|
-
// // already inserted
|
|
113
|
-
// top = new SnapshotInstance(top.type);
|
|
114
|
-
// opcodes[i + 1] = top;
|
|
115
|
-
// }
|
|
116
|
-
// p.insertBefore(top);
|
|
117
|
-
// stack.push(top);
|
|
118
|
-
|
|
119
|
-
// i += 2;
|
|
120
|
-
// break;
|
|
121
|
-
// }
|
|
122
|
-
// case OpcodeEnd: {
|
|
123
|
-
// // @ts-ignore
|
|
124
|
-
// top[CHILDREN] = undefined;
|
|
125
|
-
|
|
126
|
-
// stack.pop();
|
|
127
|
-
// const p = stack[stack.length - 1];
|
|
128
|
-
// top = p!;
|
|
129
|
-
|
|
130
|
-
// i += 1;
|
|
131
|
-
// break;
|
|
132
|
-
// }
|
|
133
|
-
// case OpcodeAttr: {
|
|
134
|
-
// const key = opcodes[i + 1];
|
|
135
|
-
// const value = opcodes[i + 2];
|
|
136
|
-
// top.setAttribute(key, value);
|
|
137
|
-
|
|
138
|
-
// i += 3;
|
|
139
|
-
// break;
|
|
140
|
-
// }
|
|
141
|
-
// case OpcodeText: {
|
|
142
|
-
// const text = opcodes[i + 1];
|
|
143
|
-
// const s = new SnapshotInstance(null as unknown as string);
|
|
144
|
-
// if (__ENABLE_SSR__) {
|
|
145
|
-
// // We need store the just created SnapshotInstance, or it will be lost when we leave the function
|
|
146
|
-
// opcodes[i + 1] = [s, text];
|
|
147
|
-
// }
|
|
148
|
-
// s.setAttribute(0, text);
|
|
149
|
-
// top.insertBefore(s);
|
|
150
|
-
|
|
151
|
-
// i += 2;
|
|
152
|
-
// break;
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// }
|
|
@@ -28,7 +28,7 @@ import { globalPipelineOptions } from '../../core/performance.js';
|
|
|
28
28
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
29
29
|
import { isDirectOrDeepEqual } from '../../utils.js';
|
|
30
30
|
import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';
|
|
31
|
-
import { prepareGestureForCommit } from '../gesture/
|
|
31
|
+
import { prepareGestureForCommit } from '../gesture/processGestureBackground.js';
|
|
32
32
|
import type { GestureKind } from '../gesture/types.js';
|
|
33
33
|
import { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';
|
|
34
34
|
import {
|
|
@@ -2,11 +2,15 @@
|
|
|
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
|
|
|
5
|
+
import { cardLifetime } from '../../core/card-lifetime.js';
|
|
5
6
|
import { componentAtIndexFactory, enqueueComponentFactory, gRecycleMap, gSignMap } from '../list/list.js';
|
|
6
7
|
import { hydrate } from '../renderToOpcodes/hydrate.js';
|
|
7
8
|
import type { SnapshotInstance } from '../snapshot/snapshot.js';
|
|
8
9
|
|
|
9
|
-
const destroyLifetimeHandlerMap = /*#__PURE__*/
|
|
10
|
+
const destroyLifetimeHandlerMap = /*#__PURE__*/ cardLifetime(
|
|
11
|
+
'listDestroyLifetimeHandlerMap',
|
|
12
|
+
() => new Map<number, () => void>(),
|
|
13
|
+
);
|
|
10
14
|
|
|
11
15
|
export function snapshotCreateList(
|
|
12
16
|
pageId: number,
|
|
@@ -3,20 +3,27 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import type { SnapshotInstance } from './snapshot.js';
|
|
6
|
+
import { cardLifetime } from '../../core/card-lifetime.js';
|
|
6
7
|
import { clearSnapshotVNodeSource } from '../debug/vnodeSource.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
interface SnapshotInstanceManager {
|
|
9
10
|
nextId: number;
|
|
10
11
|
values: Map<number, SnapshotInstance>;
|
|
11
12
|
clear(): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function clear(this: SnapshotInstanceManager): void {
|
|
16
|
+
// not resetting `nextId` to prevent id collision
|
|
17
|
+
this.values.clear();
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
clearSnapshotVNodeSource();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const snapshotInstanceManager: SnapshotInstanceManager = /*#__PURE__*/ cardLifetime(
|
|
24
|
+
'snapshotInstanceManager',
|
|
25
|
+
() => ({ nextId: 0, values: new Map<number, SnapshotInstance>(), clear }),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Rebound so that it clears the debug state of the current entry.
|
|
29
|
+
snapshotInstanceManager.clear = clear;
|
|
@@ -2,7 +2,11 @@
|
|
|
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
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createRunOnMainThread,
|
|
7
|
+
takeDelayedRunOnMainThreadData,
|
|
8
|
+
} from '../../../core/thread-function-call/main-thread.js';
|
|
9
|
+
import { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';
|
|
6
10
|
import { isRendering } from '../../lifecycle/isRendering.js';
|
|
7
11
|
import { __globalSnapshotPatch } from '../../lifecycle/patch/snapshotPatch.js';
|
|
8
12
|
|
|
@@ -37,3 +41,8 @@ export function runOnMainThread<R, Fn extends (...args: any[]) => R>(
|
|
|
37
41
|
): (...args: Parameters<Fn>) => Promise<R> {
|
|
38
42
|
return runOnMainThreadImpl(fn);
|
|
39
43
|
}
|
|
44
|
+
|
|
45
|
+
export function resetSnapshotMainThreadFunctionRuntime(): void {
|
|
46
|
+
takeDelayedRunOnMainThreadData();
|
|
47
|
+
resetFunctionCallReturnListener();
|
|
48
|
+
}
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
import type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';
|
|
5
5
|
|
|
6
6
|
import { isMtsEnabled, isRunOnBackgroundEnabled } from './functionality.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
registerBackgroundFunctionCtx,
|
|
9
|
+
resetBackgroundFunctionRuntime,
|
|
10
|
+
} from '../../core/background-function/run-on-background.js';
|
|
11
|
+
import { resetFunctionCallReturnListener } from '../../core/thread-function-call/return-value.js';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* @internal
|
|
@@ -20,3 +24,8 @@ export function onPostWorkletCtx(afterValue: Worklet | null): Worklet | null {
|
|
|
20
24
|
registerBackgroundFunctionCtx(afterValue);
|
|
21
25
|
return afterValue;
|
|
22
26
|
}
|
|
27
|
+
|
|
28
|
+
export function resetSnapshotBackgroundFunctionRuntime(): void {
|
|
29
|
+
resetBackgroundFunctionRuntime();
|
|
30
|
+
resetFunctionCallReturnListener();
|
|
31
|
+
}
|
|
@@ -12,6 +12,9 @@ function updateMTRefInitValue({ data }: { data: string }): void {
|
|
|
12
12
|
// This update ignores reloadVersion check.
|
|
13
13
|
// MainThreadRefs created before reloadTemplate may still be referenced by user in some cases after reloadTemplate.
|
|
14
14
|
const patch = JSON.parse(data) as MainThreadRefInitValuePatch;
|
|
15
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
16
|
+
console.alog?.('[ReactLynxDebug] Snapshot MTS updateMTRefInitValue:\n' + data);
|
|
17
|
+
}
|
|
15
18
|
updateWorkletRefInitValueChanges(patch);
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -26,5 +29,8 @@ export function sendMTRefInitValueToMainThread(): void {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
const data = JSON.stringify(patch);
|
|
32
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
33
|
+
console.alog?.('[ReactLynxDebug] Snapshot BTS -> MTS sendMTRefInitValue:\n' + data);
|
|
34
|
+
}
|
|
29
35
|
lynx.getNativeApp().callLepusMethod(LifecycleConstant.updateMTRefInitValue, { data });
|
|
30
36
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Element Template worklet identity
|
|
2
|
+
|
|
3
|
+
Element Template Native storage must preserve the original JavaScript worklet
|
|
4
|
+
context in declared main-thread event slots, as Snapshot does. Native may snapshot
|
|
5
|
+
the event wrapper and ordinary attribute data, but it must retain the wrapper's
|
|
6
|
+
`value` as a live MTS object. Background element preparation must exclude live
|
|
7
|
+
event and gesture values from both its task input and prepared result.
|
|
8
|
+
|
|
9
|
+
`runWorklet` transforms the context delivered by Native directly. The original
|
|
10
|
+
context and its captured callback objects remain ordinary JavaScript objects
|
|
11
|
+
accepted by `FinalizationRegistry.register`; no context identifier or reverse
|
|
12
|
+
lookup is needed. This runtime requires the corresponding Native storage behavior.
|
|
13
|
+
Older ET Native implementations that deep-copy worklet contexts are unsupported by
|
|
14
|
+
this integration.
|
|
15
|
+
|
|
16
|
+
Track a background input before calling Native. If Native rejects it, collecting
|
|
17
|
+
that input must still release its already-registered background execution. Only
|
|
18
|
+
Native success commits the slot's strong reference and hydration handoff;
|
|
19
|
+
committing does not register the context again. Removal drops the slot's reference.
|
|
20
|
+
Escaped callbacks follow the existing Snapshot capture and GC behavior.
|
|
21
|
+
|
|
22
|
+
Retire the previous lifecycle manager to stop old finalizers from sending release
|
|
23
|
+
events into the new runtime. Native event ingress must reject detached old
|
|
24
|
+
bindings so they cannot dispatch into a replacement runtime; `runWorklet` does not
|
|
25
|
+
reject contexts based on the lifecycle manager that originally retained them.
|
|
26
|
+
Snapshot observers continue to track references through the same lifecycle manager.
|
|
27
|
+
|
|
28
|
+
This integration keeps Snapshot's existing callback transformation, first-screen
|
|
29
|
+
hydration, and delayed-call replay semantics. It does not add per-binding callback
|
|
30
|
+
materialization, shared-capture isolation, or a new delayed queue representation.
|
|
31
|
+
Shared first-screen context mutation and escaped-callback lifetime limitations
|
|
32
|
+
that also occur in Snapshot remain unchanged. Registration atomicity and
|
|
33
|
+
consumed-queue cleanup remain unchanged.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
|
|
5
|
+
import '../global.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Loads the legacy main-thread worklet chunk or reuses an initialized runtime.
|
|
9
|
+
* @param __schema - The dynamic component entry for loading the Lepus chunk.
|
|
10
|
+
* @returns Whether the worklet runtime was loaded and initialized successfully.
|
|
11
|
+
*/
|
|
12
|
+
function loadWorkletRuntime(__schema?: string): boolean {
|
|
13
|
+
if (typeof __LoadLepusChunk === 'undefined') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (globalThis.lynxWorkletImpl) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return __LoadLepusChunk('worklet-runtime', {
|
|
20
|
+
dynamicComponentEntry: __schema,
|
|
21
|
+
chunkType: 0,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { loadWorkletRuntime };
|
|
@@ -36,7 +36,9 @@ function delayRunOnBackground(fnObj: JsFnHandle, task: (fnId: number, execId: nu
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function clearDelayedBackgroundFunctions(): void {
|
|
39
|
-
|
|
39
|
+
// PrimJS can keep truncated array storage alive; drop the consumed queue so
|
|
40
|
+
// its tasks and hydrated handles stop retaining their background executions.
|
|
41
|
+
impl!.delayedBackgroundFunctionArray = [];
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
function runDelayedBackgroundFunctions(): void {
|
|
@@ -16,6 +16,7 @@ class JsFunctionLifecycleManager {
|
|
|
16
16
|
private execIdSetToFire = new Set<number>();
|
|
17
17
|
private retainedObjects = new WeakSet<object>();
|
|
18
18
|
private willFire = false;
|
|
19
|
+
private active = true;
|
|
19
20
|
private registry: FinalizationRegistry<number>;
|
|
20
21
|
|
|
21
22
|
constructor() {
|
|
@@ -26,12 +27,13 @@ class JsFunctionLifecycleManager {
|
|
|
26
27
|
if (this.retainedObjects.has(objToRef)) {
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
30
|
+
// A failed engine registration must leave the target eligible for a retry.
|
|
31
|
+
this.registry.register(objToRef, execId);
|
|
29
32
|
this.retainedObjects.add(objToRef);
|
|
30
33
|
this.execIdRefCount.set(
|
|
31
34
|
execId,
|
|
32
35
|
(this.execIdRefCount.get(execId) ?? 0) + 1,
|
|
33
36
|
);
|
|
34
|
-
this.registry.register(objToRef, execId);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
removeRef(execId: number): void {
|
|
@@ -50,7 +52,12 @@ class JsFunctionLifecycleManager {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
dispose(): void {
|
|
56
|
+
this.active = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
fire(): void {
|
|
60
|
+
if (!this.active) return;
|
|
54
61
|
profile('JsFunctionLifecycleManager.fire', () => {
|
|
55
62
|
lynx.getJSContext().dispatchEvent({
|
|
56
63
|
type: WorkletEvents.releaseBackgroundWorkletCtx,
|
|
@@ -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 { addReloadScopedEventListener } from '../core/reload-scoped-event.js';
|
|
4
5
|
import { WorkletEvents } from './bindings/events.js';
|
|
5
6
|
import type { ReleaseWorkletRefData, RunWorkletCtxData } from './bindings/events.js';
|
|
6
7
|
import type { ClosureValueType } from './bindings/types.js';
|
|
@@ -10,13 +11,9 @@ import { removeValueFromWorkletRefMap } from './workletRef.js';
|
|
|
10
11
|
|
|
11
12
|
function initEventListeners(): void {
|
|
12
13
|
const jsContext = lynx.getJSContext();
|
|
13
|
-
jsContext.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const data = JSON.parse(event.data as string) as RunWorkletCtxData;
|
|
17
|
-
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
18
|
-
},
|
|
19
|
-
);
|
|
14
|
+
addReloadScopedEventListener(jsContext, WorkletEvents.runWorkletCtx, (data: RunWorkletCtxData) => {
|
|
15
|
+
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
16
|
+
});
|
|
20
17
|
jsContext.addEventListener(
|
|
21
18
|
WorkletEvents.releaseWorkletRef,
|
|
22
19
|
(event: Event) => {
|
|
@@ -33,8 +33,9 @@ function registerMainThreadObjectType(
|
|
|
33
33
|
`Conflicting MainThreadObject registration for type "${type}". A type key must always use the same create function.`,
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
return;
|
|
36
|
+
if (registered.create === create) return;
|
|
37
37
|
}
|
|
38
|
+
// A re-evaluated module brings a factory bound to its own module state.
|
|
38
39
|
mainThreadObjectDefinitions.set(type, { create });
|
|
39
40
|
}
|
|
40
41
|
|