@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
|
@@ -2,6 +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
|
|
|
5
|
+
import { flushElementTemplate } from './flush.js';
|
|
5
6
|
import { reloadMainThread } from './reload-main-thread.js';
|
|
6
7
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
7
8
|
import { createElementTemplatePage, setupPage } from '../runtime/page/page.js';
|
|
@@ -38,15 +39,11 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
applyUpdatePageData(data, options);
|
|
41
|
-
|
|
42
|
+
flushElementTemplate(options);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function updateGlobalProps(_data: unknown, options?: UpdatePageOption): void {
|
|
45
|
-
|
|
46
|
-
__FlushElementTree(undefined, options);
|
|
47
|
-
} else {
|
|
48
|
-
__FlushElementTree();
|
|
49
|
-
}
|
|
46
|
+
flushElementTemplate(options);
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
6
|
+
import { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
6
7
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
8
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
7
9
|
import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
8
10
|
import { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
9
11
|
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
@@ -33,12 +35,18 @@ export function destroyElementTemplateMainThreadRuntime(): void {
|
|
|
33
35
|
didPatchListenerResetThrow = true;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
resetElementTemplateRefInitValueListener();
|
|
39
|
+
|
|
36
40
|
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
37
41
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
38
42
|
destroyAllElementTemplateListStates();
|
|
39
43
|
elementTemplateRegistry.clear();
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
try {
|
|
45
|
+
clearMainThreadDynamicAttrState();
|
|
46
|
+
} finally {
|
|
47
|
+
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
48
|
+
resetTemplateId();
|
|
49
|
+
}
|
|
42
50
|
|
|
43
51
|
if (didPatchListenerResetThrow) {
|
|
44
52
|
throw patchListenerResetError;
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
flushDelayedRunOnBackgroundFunctions,
|
|
9
9
|
runRunOnMainThreadTask,
|
|
10
10
|
setEomShouldFlushElementTree,
|
|
11
|
-
updateWorkletRefInitValueChanges,
|
|
12
11
|
} from '@lynx-js/react/worklet-runtime/bindings';
|
|
13
12
|
|
|
14
13
|
import { markTiming, setPipeline } from '../../core/performance.js';
|
|
@@ -18,6 +17,7 @@ import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant
|
|
|
18
17
|
import type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';
|
|
19
18
|
import type { ElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
20
19
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
20
|
+
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
21
21
|
|
|
22
22
|
let listener:
|
|
23
23
|
| ((event: Pick<ElementTemplateUpdateEvent, 'data'>) => void)
|
|
@@ -39,83 +39,83 @@ export function installElementTemplatePatchListener(): void {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
setPipeline(pipelineOptions);
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
try {
|
|
43
|
+
markTiming('mtsRenderStart');
|
|
44
|
+
markTiming('parseChangesStart');
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const payload = JSON.parse(event.data.payload) as ElementTemplateUpdateCommitContext;
|
|
47
|
+
markTiming('parseChangesEnd');
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (shouldProfilePatch) {
|
|
58
|
-
lynx.performance.profileEnd();
|
|
49
|
+
if (
|
|
50
|
+
typeof patchOptions.reloadVersion === 'number'
|
|
51
|
+
&& patchOptions.reloadVersion < getReloadVersion()
|
|
52
|
+
) {
|
|
53
|
+
markTiming('mtsRenderEnd');
|
|
54
|
+
if (shouldProfilePatch) {
|
|
55
|
+
lynx.performance.profileEnd();
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
59
58
|
}
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (hasOps) {
|
|
68
|
-
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
69
|
-
console.alog?.(
|
|
70
|
-
'[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
71
|
-
+ JSON.stringify(
|
|
72
|
-
{
|
|
73
|
-
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
74
|
-
flushOptions,
|
|
75
|
-
flowIds,
|
|
76
|
-
},
|
|
77
|
-
null,
|
|
78
|
-
2,
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
markTiming('patchChangesStart');
|
|
60
|
+
const hasOps = payload.ops.length > 0;
|
|
61
|
+
const flushOptions = payload.flushOptions;
|
|
62
|
+
const isHydration = payload.isHydration === true;
|
|
63
|
+
const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;
|
|
83
64
|
try {
|
|
84
|
-
|
|
65
|
+
if (hasOps) {
|
|
66
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
67
|
+
console.alog?.(
|
|
68
|
+
'[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
69
|
+
+ JSON.stringify(
|
|
70
|
+
{
|
|
71
|
+
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
72
|
+
flushOptions,
|
|
73
|
+
flowIds,
|
|
74
|
+
},
|
|
75
|
+
null,
|
|
76
|
+
2,
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
markTiming('patchChangesStart');
|
|
81
|
+
try {
|
|
82
|
+
applyElementTemplateUpdateCommands(payload.ops, isHydration);
|
|
83
|
+
} finally {
|
|
84
|
+
markTiming('patchChangesEnd');
|
|
85
|
+
markTiming('mtsRenderEnd');
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
markTiming('mtsRenderEnd');
|
|
89
|
+
}
|
|
90
|
+
applyPendingMainThreadRefAttachments();
|
|
85
91
|
} finally {
|
|
86
|
-
markTiming('patchChangesEnd');
|
|
87
|
-
markTiming('mtsRenderEnd');
|
|
88
92
|
if (isHydration) {
|
|
89
93
|
flushDelayedRunOnBackgroundFunctions();
|
|
90
94
|
clearFirstScreenMainThreadRefs();
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
for (const data of delayedRunOnMainThreadData) {
|
|
104
|
-
try {
|
|
105
|
-
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
lynx.reportError(error as Error);
|
|
97
|
+
if (delayedRunOnMainThreadData?.length) {
|
|
98
|
+
setEomShouldFlushElementTree(false);
|
|
99
|
+
try {
|
|
100
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
101
|
+
try {
|
|
102
|
+
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
lynx.reportError(error as Error);
|
|
105
|
+
}
|
|
108
106
|
}
|
|
107
|
+
} finally {
|
|
108
|
+
setEomShouldFlushElementTree(true);
|
|
109
109
|
}
|
|
110
|
-
} finally {
|
|
111
|
-
setEomShouldFlushElementTree(true);
|
|
112
110
|
}
|
|
113
|
-
}
|
|
114
111
|
|
|
115
|
-
|
|
112
|
+
__FlushElementTree(undefined, flushOptions);
|
|
116
113
|
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
if (shouldProfilePatch) {
|
|
115
|
+
lynx.performance.profileEnd();
|
|
116
|
+
}
|
|
117
|
+
} finally {
|
|
118
|
+
setPipeline(undefined);
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
import type { ComponentChild, ContainerNode } from 'preact';
|
|
6
6
|
import { render } from 'preact';
|
|
7
7
|
|
|
8
|
+
import { canReEvalBackgroundEntry, reEvalBackgroundEntry } from '../../core/entry-reload.js';
|
|
8
9
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
9
10
|
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
11
|
+
import { resetElementTemplateCommitState } from '../background/commit-hook.js';
|
|
10
12
|
import { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
11
13
|
import { setupBackgroundElementTemplateDocument } from '../background/document.js';
|
|
12
14
|
import { installElementTemplateHydrationListener } from '../background/hydration-listener.js';
|
|
@@ -15,7 +17,17 @@ import { profileEnd, profileStart } from '../debug/profile.js';
|
|
|
15
17
|
import { resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
16
18
|
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
17
19
|
|
|
18
|
-
export function reloadBackground(updateData: unknown): void {
|
|
20
|
+
export function reloadBackground(updateData: unknown, options?: Record<string, unknown>): void {
|
|
21
|
+
if (canReEvalBackgroundEntry()) {
|
|
22
|
+
reEvalBackgroundEntry(updateData as Record<string, unknown>, options, () => {
|
|
23
|
+
// The unmount of the old tree must not reach the new entry.
|
|
24
|
+
resetElementTemplateCommitState();
|
|
25
|
+
// A queued `updateGlobalProps` callback must not render it again.
|
|
26
|
+
__root.__jsx = undefined;
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
20
32
|
profileStart('ReactLynx::reloadBackground');
|
|
21
33
|
}
|
|
@@ -2,13 +2,20 @@
|
|
|
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 { flushElementTemplate } from './flush.js';
|
|
6
|
+
import { onMtsDestruction } from './mts-destroy.js';
|
|
7
|
+
import {
|
|
8
|
+
canReEvalMainThreadEntry,
|
|
9
|
+
installMainThreadReloadCompleter,
|
|
10
|
+
reEvalMainThreadEntry,
|
|
11
|
+
} from '../../core/entry-reload.js';
|
|
5
12
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
13
|
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
7
14
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
8
15
|
import { ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';
|
|
9
16
|
import type { SerializedEtNode, SerializedPageRoot } from '../protocol/types.js';
|
|
10
17
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
11
|
-
import { __page } from '../runtime/page/page.js';
|
|
18
|
+
import { __page, setupPage } from '../runtime/page/page.js';
|
|
12
19
|
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
13
20
|
import { renderMainThread } from '../runtime/render/render-main-thread.js';
|
|
14
21
|
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
@@ -25,7 +32,6 @@ export function reloadMainThread(data: unknown, options: UpdatePageOption): void
|
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
try {
|
|
28
|
-
increaseReloadVersion();
|
|
29
35
|
applyUpdatePageData(data, options);
|
|
30
36
|
|
|
31
37
|
destroyAllElementTemplateListStates();
|
|
@@ -42,16 +48,26 @@ export function reloadMainThread(data: unknown, options: UpdatePageOption): void
|
|
|
42
48
|
}
|
|
43
49
|
deleteMainThreadDynamicAttrStateForSubtree(removedHandleIds);
|
|
44
50
|
}
|
|
51
|
+
if (canReEvalMainThreadEntry()) {
|
|
52
|
+
onMtsDestruction();
|
|
53
|
+
increaseReloadVersion();
|
|
54
|
+
reEvalMainThreadEntry<MainThreadReloadHandoff>({ page: __page, options });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
45
57
|
elementTemplateRegistry.clear();
|
|
46
58
|
clearMainThreadDynamicAttrState();
|
|
47
59
|
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
48
60
|
resetTemplateId();
|
|
49
61
|
|
|
62
|
+
// Ref cleanup still belongs to the old page. Advance only before rendering
|
|
63
|
+
// the new tree so calls queued by old ref/unmount callbacks remain stale.
|
|
64
|
+
increaseReloadVersion();
|
|
65
|
+
|
|
50
66
|
const oldRoot = __root;
|
|
51
67
|
setRoot({ __jsx: oldRoot.__jsx });
|
|
52
68
|
renderMainThread();
|
|
53
69
|
|
|
54
|
-
|
|
70
|
+
flushElementTemplate(options);
|
|
55
71
|
} finally {
|
|
56
72
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
57
73
|
profileEnd();
|
|
@@ -59,6 +75,19 @@ export function reloadMainThread(data: unknown, options: UpdatePageOption): void
|
|
|
59
75
|
}
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
interface MainThreadReloadHandoff {
|
|
79
|
+
page: ElementTemplateHandle;
|
|
80
|
+
options: UpdatePageOption;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function completeMainThreadReload({ page, options }: MainThreadReloadHandoff): void {
|
|
84
|
+
setupPage(page);
|
|
85
|
+
renderMainThread();
|
|
86
|
+
__FlushElementTree(undefined, options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
installMainThreadReloadCompleter(completeMainThreadReload);
|
|
90
|
+
|
|
62
91
|
function collectSerializedSubtreeHandleIds(
|
|
63
92
|
node: SerializedEtNode,
|
|
64
93
|
handleIds: number[],
|
|
@@ -6,7 +6,6 @@ import type { RunWorkletCtxData } from '@lynx-js/react/worklet-runtime/bindings'
|
|
|
6
6
|
|
|
7
7
|
import { ElementTemplateUpdateOps } from './opcodes.js';
|
|
8
8
|
import { ELEMENT_TEMPLATE_PAGE_HANDLE_ID, ELEMENT_TEMPLATE_PAGE_TYPE } from './page.js';
|
|
9
|
-
import type { MainThreadRefInitValuePatch } from '../../worklet-runtime/bindings/types.js';
|
|
10
9
|
|
|
11
10
|
export type SerializableValue =
|
|
12
11
|
| string
|
|
@@ -200,20 +199,7 @@ export type ElementTemplateUpdateCommand =
|
|
|
200
199
|
export type ElementTemplateUpdateCommandStream = ElementTemplateUpdateCommand[number][];
|
|
201
200
|
|
|
202
201
|
export interface ElementTemplateFlushOptions {
|
|
203
|
-
// triggerLayout?: boolean;
|
|
204
|
-
// operationID?: any;
|
|
205
|
-
// __lynx_timing_flag?: string;
|
|
206
|
-
// nativeUpdateDataOrder?: number;
|
|
207
|
-
// elementID?: number;
|
|
208
|
-
// listID?: number;
|
|
209
|
-
// listReuseNotification?: {
|
|
210
|
-
// listElement: FiberElement;
|
|
211
|
-
// itemKey: string;
|
|
212
|
-
// };
|
|
213
202
|
pipelineOptions?: PipelineOptions;
|
|
214
|
-
// elementIDs?: number[];
|
|
215
|
-
// operationIDs?: any[];
|
|
216
|
-
// asyncFlush?: boolean;
|
|
217
203
|
triggerDataUpdated?: boolean;
|
|
218
204
|
emptyPatch?: boolean;
|
|
219
205
|
}
|
|
@@ -225,5 +211,4 @@ export interface ElementTemplateUpdateCommitContext {
|
|
|
225
211
|
isHydration?: boolean | undefined;
|
|
226
212
|
reloadVersion?: number | undefined;
|
|
227
213
|
delayedRunOnMainThreadData?: RunWorkletCtxData[] | undefined;
|
|
228
|
-
mainThreadRefInitValuePatch?: MainThreadRefInitValuePatch | undefined;
|
|
229
214
|
}
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
} from './list/list.js';
|
|
17
17
|
import type { ETListFlushResult, ETListUpdateItem } from './list/list.js';
|
|
18
18
|
import { insertElementTemplateSubtree } from './template/handle.js';
|
|
19
|
+
import { retainMainThreadBackgroundFunctionCtx } from './template/main-thread-background-function.js';
|
|
20
|
+
import type { MTEventNativeWrapper } from './template/main-thread-event-ctx.js';
|
|
19
21
|
import { elementTemplateRegistry } from './template/registry.js';
|
|
20
22
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from './template/typed-attributes.js';
|
|
21
23
|
import { ElementTemplateUpdateOps } from '../protocol/opcodes.js';
|
|
@@ -138,6 +140,9 @@ export function applyElementTemplateUpdateCommands(
|
|
|
138
140
|
if (!nativeRef) {
|
|
139
141
|
continue;
|
|
140
142
|
}
|
|
143
|
+
if (value != null) {
|
|
144
|
+
retainMainThreadBackgroundFunctionCtx((value as unknown as MTEventNativeWrapper).value);
|
|
145
|
+
}
|
|
141
146
|
__SetAttributeOfElementTemplate(nativeRef, attrSlotIndex, value);
|
|
142
147
|
updateMainThreadEventAttrSlot(targetId, attrSlotIndex, value, isHydration);
|
|
143
148
|
break;
|
|
@@ -40,7 +40,7 @@ const assign = /* @__PURE__ */ Object.assign;
|
|
|
40
40
|
// Global state for the current render pass
|
|
41
41
|
export let beforeDiff: ((vnode: unknown) => void) | undefined;
|
|
42
42
|
export let beforeDiff2: ((vnode: unknown, context: Record<string, unknown>) => void) | undefined;
|
|
43
|
-
let afterDiff, renderHook,
|
|
43
|
+
let afterDiff, renderHook, unmountHook;
|
|
44
44
|
|
|
45
45
|
export function renderWithHooks(
|
|
46
46
|
vnode: unknown,
|
|
@@ -62,7 +62,7 @@ export function renderWithHooks(
|
|
|
62
62
|
beforeDiff2 = options[DIFF2];
|
|
63
63
|
afterDiff = options[DIFFED];
|
|
64
64
|
renderHook = options[RENDER];
|
|
65
|
-
|
|
65
|
+
unmountHook = options.unmount;
|
|
66
66
|
|
|
67
67
|
const parent = h(Fragment, null);
|
|
68
68
|
parent[CHILDREN] = [vnode];
|
|
@@ -141,7 +141,7 @@ function renderClassComponent(vnode, context, globalContext) {
|
|
|
141
141
|
export function cleanupVNode(vnode: unknown): void {
|
|
142
142
|
if (afterDiff) afterDiff(vnode);
|
|
143
143
|
vnode[PARENT] = undefined;
|
|
144
|
-
if (
|
|
144
|
+
if (unmountHook) unmountHook(vnode);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export function renderComponentVNode(
|
|
@@ -16,6 +16,7 @@ import { flushInitialElementTemplateListUpdates } from '../list/list.js';
|
|
|
16
16
|
import { __page } from '../page/page.js';
|
|
17
17
|
import { __root } from '../page/root-instance.js';
|
|
18
18
|
import { insertElementTemplateSubtree } from '../template/handle.js';
|
|
19
|
+
import { applyPendingMainThreadRefAttachments } from '../template/main-thread-dynamic-attr-state.js';
|
|
19
20
|
import { getElementTemplateNativeRef } from '../template/registry.js';
|
|
20
21
|
import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
|
|
21
22
|
|
|
@@ -48,6 +49,7 @@ function renderMainThread(): void {
|
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
flushInitialListUpdates();
|
|
52
|
+
applyPendingMainThreadRefAttachments();
|
|
51
53
|
} finally {
|
|
52
54
|
profileEnd();
|
|
53
55
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
runOnBackground,
|
|
12
12
|
} from '../../../core/background-function/run-on-background.js';
|
|
13
13
|
import { resetFunctionCallReturnListener } from '../../../core/thread-function-call/return-value.js';
|
|
14
|
-
import { isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
|
|
14
|
+
import { JsFunctionLifecycleManager, isRunOnBackgroundEnabled } from '../../../worklet-runtime/jsFunctionLifecycle.js';
|
|
15
15
|
|
|
16
16
|
type BackgroundFunctionCtx = Parameters<typeof registerBackgroundFunctionCtx>[0];
|
|
17
17
|
type RetainableMainThreadCtx = Parameters<typeof retainWorkletCtx>[0];
|
|
@@ -33,6 +33,8 @@ export function registerMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroun
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// Track the input before Native takes ownership. If Native rejects it, collection
|
|
37
|
+
// must still release its already-registered background execution; slot state commits later.
|
|
36
38
|
export function retainMainThreadBackgroundFunctionCtx(ctx: MainThreadBackgroundFunctionCtx): void {
|
|
37
39
|
retainWorkletCtx(ctx as RetainableMainThreadCtx);
|
|
38
40
|
}
|
|
@@ -43,6 +45,11 @@ export function resetElementTemplateBackgroundFunctionRuntime(): void {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
export function resetElementTemplateMainThreadBackgroundFunctionRuntime(): void {
|
|
48
|
+
const manager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;
|
|
49
|
+
if (manager) {
|
|
50
|
+
manager.dispose();
|
|
51
|
+
globalThis.lynxWorkletImpl._jsFunctionLifecycleManager = new JsFunctionLifecycleManager();
|
|
52
|
+
}
|
|
46
53
|
clearDelayedRunOnBackgroundFunctions();
|
|
47
54
|
resetFunctionCallReturnListener();
|
|
48
55
|
}
|
|
@@ -20,7 +20,16 @@ type MainThreadDynamicAttrStateMap<T> = Map<number, Map<number, T>>;
|
|
|
20
20
|
|
|
21
21
|
const mtEventAttrState: MainThreadDynamicAttrStateMap<MTEventCtx> = new Map();
|
|
22
22
|
const mtRefAttrState: MainThreadDynamicAttrStateMap<MTRefValue> = new Map();
|
|
23
|
-
const
|
|
23
|
+
const attachedMTRefHandleIds = new Set<number>();
|
|
24
|
+
|
|
25
|
+
interface PendingMTRefAttachment {
|
|
26
|
+
handleId: number;
|
|
27
|
+
attrSlotIndex: number;
|
|
28
|
+
value: MTRefValue;
|
|
29
|
+
nativeRef: ElementTemplateHandle;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let pendingMTRefAttachments: PendingMTRefAttachment[] = [];
|
|
24
33
|
|
|
25
34
|
export interface MainThreadDynamicAttrSubtreeHandle {
|
|
26
35
|
uid: number;
|
|
@@ -63,7 +72,6 @@ function setSlotState<T>(
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
function setMTEventSlotState(handleId: number, attrSlotIndex: number, nativeHeldValue: MTEventCtx): void {
|
|
66
|
-
retainMainThreadBackgroundFunctionCtx(nativeHeldValue);
|
|
67
75
|
setSlotState(mtEventAttrState, handleId, attrSlotIndex, nativeHeldValue);
|
|
68
76
|
}
|
|
69
77
|
|
|
@@ -89,6 +97,9 @@ export function prepareMainThreadDynamicAttrSlotsForNative(
|
|
|
89
97
|
}
|
|
90
98
|
let nativeSlots: SerializableValue[] | undefined;
|
|
91
99
|
for (const [attrSlotIndex, kind] of slotKinds) {
|
|
100
|
+
if (kind === 'mt-event' && attributeSlots[attrSlotIndex] != null) {
|
|
101
|
+
retainMainThreadBackgroundFunctionCtx((attributeSlots[attrSlotIndex] as MTEventNativeWrapper).value);
|
|
102
|
+
}
|
|
92
103
|
if (kind !== 'mt-ref') {
|
|
93
104
|
continue;
|
|
94
105
|
}
|
|
@@ -99,14 +110,18 @@ export function prepareMainThreadDynamicAttrSlotsForNative(
|
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
export function clearMainThreadDynamicAttrState(): void {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
try {
|
|
114
|
+
for (const [handleId, handleState] of mtRefAttrState) {
|
|
115
|
+
if (attachedMTRefHandleIds.has(handleId)) {
|
|
116
|
+
cleanupMTRefHandleState(handleState);
|
|
117
|
+
}
|
|
105
118
|
}
|
|
119
|
+
} finally {
|
|
120
|
+
mtEventAttrState.clear();
|
|
121
|
+
mtRefAttrState.clear();
|
|
122
|
+
attachedMTRefHandleIds.clear();
|
|
123
|
+
pendingMTRefAttachments = [];
|
|
106
124
|
}
|
|
107
|
-
mtEventAttrState.clear();
|
|
108
|
-
mtRefAttrState.clear();
|
|
109
|
-
materializedMTRefHandleIds.clear();
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
export function getMainThreadDynamicAttrState(
|
|
@@ -171,15 +186,15 @@ export function updateMainThreadRefAttrSlot(
|
|
|
171
186
|
isHydration = false,
|
|
172
187
|
): void {
|
|
173
188
|
const previousState = mtRefAttrState.get(handleId)?.get(attrSlotIndex);
|
|
174
|
-
const
|
|
189
|
+
const isAttached = attachedMTRefHandleIds.has(handleId);
|
|
175
190
|
if (value == null) {
|
|
176
|
-
if (previousState &&
|
|
191
|
+
if (previousState && isAttached) {
|
|
177
192
|
cleanupMTRefValue(previousState);
|
|
178
193
|
}
|
|
179
194
|
deleteSlotState(mtRefAttrState, handleId, attrSlotIndex);
|
|
180
195
|
return;
|
|
181
196
|
}
|
|
182
|
-
if (previousState &&
|
|
197
|
+
if (previousState && isAttached) {
|
|
183
198
|
cleanupMTRefValue(previousState);
|
|
184
199
|
}
|
|
185
200
|
const nextValue = (value as MTRefNativeWrapper).value;
|
|
@@ -187,8 +202,8 @@ export function updateMainThreadRefAttrSlot(
|
|
|
187
202
|
if (isHydration) {
|
|
188
203
|
hydrateMTRefValue(nextValue, previousState);
|
|
189
204
|
}
|
|
190
|
-
if (
|
|
191
|
-
|
|
205
|
+
if (isAttached) {
|
|
206
|
+
pendingMTRefAttachments.push({ handleId, attrSlotIndex, value: nextValue, nativeRef });
|
|
192
207
|
}
|
|
193
208
|
}
|
|
194
209
|
|
|
@@ -197,17 +212,32 @@ export function attachMainThreadDynamicAttrRefsForSubtree(
|
|
|
197
212
|
): void {
|
|
198
213
|
for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {
|
|
199
214
|
const handle = handles[handleIndex]!;
|
|
200
|
-
if (
|
|
215
|
+
if (attachedMTRefHandleIds.has(handle.uid)) {
|
|
201
216
|
continue;
|
|
202
217
|
}
|
|
203
|
-
|
|
218
|
+
attachedMTRefHandleIds.add(handle.uid);
|
|
204
219
|
const handleState = mtRefAttrState.get(handle.uid);
|
|
205
220
|
if (!handleState) {
|
|
206
221
|
continue;
|
|
207
222
|
}
|
|
208
|
-
for (const value of handleState
|
|
209
|
-
|
|
223
|
+
for (const [attrSlotIndex, value] of handleState) {
|
|
224
|
+
pendingMTRefAttachments.push({ handleId: handle.uid, attrSlotIndex, value, nativeRef: handle.ref });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Consume one queue snapshot, matching Snapshot's ref delivery boundary.
|
|
230
|
+
export function applyPendingMainThreadRefAttachments(): void {
|
|
231
|
+
const pending = pendingMTRefAttachments;
|
|
232
|
+
pendingMTRefAttachments = [];
|
|
233
|
+
for (const { handleId, attrSlotIndex, value, nativeRef } of pending) {
|
|
234
|
+
const element = __GetElementByAttrSlot(nativeRef, attrSlotIndex);
|
|
235
|
+
if (!element) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
`ElementTemplate main-thread:ref target ${handleId}:${attrSlotIndex} could not be materialized.`,
|
|
238
|
+
);
|
|
210
239
|
}
|
|
240
|
+
attachMTRefValue(value, element);
|
|
211
241
|
}
|
|
212
242
|
}
|
|
213
243
|
|
|
@@ -216,10 +246,10 @@ export function detachMainThreadDynamicAttrRefsForSubtree(
|
|
|
216
246
|
): void {
|
|
217
247
|
for (let handleIndex = 0; handleIndex < handles.length; handleIndex += 1) {
|
|
218
248
|
const handleId = handles[handleIndex]!.uid;
|
|
219
|
-
if (!
|
|
249
|
+
if (!attachedMTRefHandleIds.has(handleId)) {
|
|
220
250
|
continue;
|
|
221
251
|
}
|
|
222
|
-
|
|
252
|
+
attachedMTRefHandleIds.delete(handleId);
|
|
223
253
|
const handleState = mtRefAttrState.get(handleId);
|
|
224
254
|
if (handleState) {
|
|
225
255
|
cleanupMTRefHandleState(handleState);
|
|
@@ -232,10 +262,10 @@ export function deleteMainThreadDynamicAttrStateForSubtree(
|
|
|
232
262
|
): void {
|
|
233
263
|
for (const handleId of handleIds) {
|
|
234
264
|
const handleState = mtRefAttrState.get(handleId);
|
|
235
|
-
if (handleState &&
|
|
265
|
+
if (handleState && attachedMTRefHandleIds.has(handleId)) {
|
|
236
266
|
cleanupMTRefHandleState(handleState);
|
|
237
267
|
}
|
|
238
|
-
|
|
268
|
+
attachedMTRefHandleIds.delete(handleId);
|
|
239
269
|
mtEventAttrState.delete(handleId);
|
|
240
270
|
mtRefAttrState.delete(handleId);
|
|
241
271
|
}
|
|
@@ -41,10 +41,10 @@ export function hydrateMTRefValue(
|
|
|
41
41
|
|
|
42
42
|
export function attachMTRefValue(
|
|
43
43
|
value: MTRefValue,
|
|
44
|
-
nativeRef:
|
|
44
|
+
nativeRef: ElementRef,
|
|
45
45
|
): void {
|
|
46
46
|
if (isMainThreadRef(value)) {
|
|
47
|
-
updateWorkletRef(value, nativeRef
|
|
47
|
+
updateWorkletRef(value, nativeRef);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
value._unmount = runWorkletCtx(
|
|
@@ -37,6 +37,12 @@ declare global {
|
|
|
37
37
|
// explicit flush options. It is not an Element Template handle.
|
|
38
38
|
function __FlushElementTree(element: undefined, options: FlushOptions): void;
|
|
39
39
|
|
|
40
|
+
// Materializes the instance on demand; parent mounting and layout may still be pending.
|
|
41
|
+
function __GetElementByAttrSlot(
|
|
42
|
+
templateInstance: ElementTemplateHandle,
|
|
43
|
+
attrSlotIndex: number,
|
|
44
|
+
): ElementRef | null;
|
|
45
|
+
|
|
40
46
|
function __CreateElementTemplate(
|
|
41
47
|
templateKey: string,
|
|
42
48
|
bundleUrl: string | null | undefined,
|
package/runtime/src/internal.ts
CHANGED
|
@@ -98,8 +98,8 @@ export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory
|
|
|
98
98
|
export { loadLazyBundle } from './core/lynx/lazy-bundle.js';
|
|
99
99
|
|
|
100
100
|
export { createBackgroundFunctionHandle as transformToWorklet } from './core/background-function/handle.js';
|
|
101
|
-
export { registerWorkletOnBackground } from './snapshot/worklet/hmr.js';
|
|
102
101
|
|
|
102
|
+
export { loadWorkletRuntime } from '@lynx-js/react/worklet-runtime/bindings';
|
|
103
103
|
export { captureMainThreadObject } from './core/capture-main-thread-object.js';
|
|
104
104
|
|
|
105
105
|
if (__DEV__) {
|