@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
|
@@ -62,7 +62,10 @@ export const makeSyncThen = function<T>(result: T): Promise<T>['then'] {
|
|
|
62
62
|
// );
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// The Lynx Promise polyfill shares resolved promises for primitive values.
|
|
66
|
+
// Own this promise before replacing `then`, or an undefined callback
|
|
67
|
+
// result would make unrelated Promise.resolve().then(...) calls synchronous.
|
|
68
|
+
const p = new Promise<TR1>(resolve => resolve(ret));
|
|
66
69
|
|
|
67
70
|
const then = makeSyncThen(ret as TR1);
|
|
68
71
|
p.then = then as Promise<Awaited<TR1>>['then'];
|
|
@@ -330,7 +333,7 @@ export const loadLazyBundle: <
|
|
|
330
333
|
})();
|
|
331
334
|
|
|
332
335
|
function withSyncResolvers<T>() {
|
|
333
|
-
'background
|
|
336
|
+
'background only';
|
|
334
337
|
|
|
335
338
|
const resolver: {
|
|
336
339
|
result: T | null;
|
|
@@ -1,9 +1,132 @@
|
|
|
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 type { DataProcessorDefinition, InitData, InitDataRaw } from '../lynx-api.js';
|
|
5
4
|
import { profileEnd, profileStart } from '../shared/profile.js';
|
|
6
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The interface you can extends so that the `defaultDataProcessor` parameter can be customized
|
|
8
|
+
*
|
|
9
|
+
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*
|
|
13
|
+
* @group Types
|
|
14
|
+
*/
|
|
15
|
+
export interface InitDataRaw {}
|
|
16
|
+
/**
|
|
17
|
+
* The interface you can extends so that the `defaultDataProcessor` returning value can be customized
|
|
18
|
+
*
|
|
19
|
+
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*
|
|
23
|
+
* @group Types
|
|
24
|
+
*/
|
|
25
|
+
export interface InitData {}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The data processors that registered with {@link Lynx.registerDataProcessors}.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* Extending `dataProcessors` interface
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import type { DataProcessors as WellKnownDataProcessors } from '@lynx-js/react';
|
|
36
|
+
*
|
|
37
|
+
* declare module '@lynx-js/react' {
|
|
38
|
+
* interface DataProcessors extends WellKnownDataProcessors {
|
|
39
|
+
* foo(bar: string): number;
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Then you can use `lynx.registerDataProcessors` with types.
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* lynx.registerDataProcessors({
|
|
48
|
+
* dataProcessors: {
|
|
49
|
+
* foo(bar) {
|
|
50
|
+
* return 1;
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*
|
|
58
|
+
* @group Types
|
|
59
|
+
*/
|
|
60
|
+
export interface DataProcessors {
|
|
61
|
+
/**
|
|
62
|
+
* Optional processor to override screen metrics used by the app
|
|
63
|
+
*
|
|
64
|
+
* @param metrics - The physical screen dimensions in pixels
|
|
65
|
+
*
|
|
66
|
+
* @returns New screen dimensions to be used by the app
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* lynx.registerDataProcessors({
|
|
72
|
+
* dataProcessors: {
|
|
73
|
+
* getScreenMetricsOverride: (metrics) => {
|
|
74
|
+
* // Force a specific aspect ratio
|
|
75
|
+
* return {
|
|
76
|
+
* width: metrics.width,
|
|
77
|
+
* height: metrics.width * (16/9)
|
|
78
|
+
* };
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
getScreenMetricsOverride?(metrics: {
|
|
85
|
+
/**
|
|
86
|
+
* The physical pixel width of the screen
|
|
87
|
+
*/
|
|
88
|
+
width: number;
|
|
89
|
+
/**
|
|
90
|
+
* The physical pixel height of the screen
|
|
91
|
+
*/
|
|
92
|
+
height: number;
|
|
93
|
+
}): { width: number; height: number };
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Custom unknown data processors.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
*
|
|
100
|
+
* You may extends the `DataProcessors` interface for better TypeScript types. See {@link DataProcessors}.
|
|
101
|
+
*/
|
|
102
|
+
[processorName: string]: (...args: any[]) => any;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Definition of DataProcessor(s)
|
|
107
|
+
* @public
|
|
108
|
+
*
|
|
109
|
+
* @group Types
|
|
110
|
+
*/
|
|
111
|
+
export interface DataProcessorDefinition {
|
|
112
|
+
/**
|
|
113
|
+
* You can custom input and output type of `defaultDataProcessor` by extends {@link InitDataRaw} and {@link InitData}
|
|
114
|
+
*
|
|
115
|
+
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
116
|
+
*
|
|
117
|
+
* @param rawInitData - initData passed from native code
|
|
118
|
+
* @returns
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
defaultDataProcessor?: (rawInitData: InitDataRaw) => InitData;
|
|
122
|
+
/**
|
|
123
|
+
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
dataProcessors?: DataProcessors;
|
|
128
|
+
}
|
|
129
|
+
|
|
7
130
|
// `true` only while the default data processor is running. `defaultDataProcessor` is
|
|
8
131
|
// invoked by the native side as a separate call *before* `renderPage` / `updatePage`,
|
|
9
132
|
// so a `markFirstScreenSyncReady()` made inside it must not sync the *previous* tree
|
|
@@ -2,15 +2,16 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
import { cardLifetime } from './card-lifetime.js';
|
|
6
|
+
|
|
7
|
+
const lastId = /*#__PURE__*/ cardLifetime('mainThreadRefId', () => ({ bg: 0, mt: 0 }));
|
|
7
8
|
|
|
8
9
|
/** @internal */
|
|
9
10
|
export function allocateMainThreadRefId(): number {
|
|
10
|
-
return __JS__ ? ++
|
|
11
|
+
return __JS__ ? ++lastId.bg : --lastId.mt;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/** @internal */
|
|
14
15
|
export function clearMainThreadRefIdsForTesting(): void {
|
|
15
|
-
|
|
16
|
+
lastId.bg = lastId.mt = 0;
|
|
16
17
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { getReloadVersion } from './reload-version.js';
|
|
6
|
+
|
|
7
|
+
interface ReloadScope {
|
|
8
|
+
reloadVersion?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function dispatchReloadScopedEvent(context: RuntimeProxy, event: { type: string; data: object }): void {
|
|
12
|
+
context.dispatchEvent({
|
|
13
|
+
type: event.type,
|
|
14
|
+
data: JSON.stringify({ ...event.data, reloadVersion: getReloadVersion() }),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Deliver parsed payloads only while their page is current. Return cleanup for
|
|
19
|
+
// the actual registered wrapper, so callers need no listener identity registry.
|
|
20
|
+
export function addReloadScopedEventListener<T>(
|
|
21
|
+
context: RuntimeProxy,
|
|
22
|
+
type: string,
|
|
23
|
+
listener: (data: T) => void,
|
|
24
|
+
): () => void {
|
|
25
|
+
const handle = (event: RuntimeProxy.Event): void => {
|
|
26
|
+
const data = JSON.parse(event.data as string) as T & ReloadScope;
|
|
27
|
+
// Unversioned events belong to the initial page only.
|
|
28
|
+
if ((data.reloadVersion ?? 0) !== getReloadVersion()) return;
|
|
29
|
+
listener(data);
|
|
30
|
+
};
|
|
31
|
+
context.addEventListener(type, handle);
|
|
32
|
+
return () => {
|
|
33
|
+
context.removeEventListener(type, handle);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -2,12 +2,14 @@
|
|
|
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
|
-
|
|
5
|
+
import { cardLifetime } from './card-lifetime.js';
|
|
6
|
+
|
|
7
|
+
const state = /*#__PURE__*/ cardLifetime('reloadVersion', () => ({ value: 0 }));
|
|
6
8
|
|
|
7
9
|
export function getReloadVersion(): number {
|
|
8
|
-
return
|
|
10
|
+
return state.value;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export function increaseReloadVersion(): number {
|
|
12
|
-
return ++
|
|
14
|
+
return ++state.value;
|
|
13
15
|
}
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
type DestroyTask = () => void;
|
|
6
6
|
|
|
7
7
|
const destroyTasks = new Set<DestroyTask>();
|
|
8
|
+
let destroyed = false;
|
|
9
|
+
|
|
10
|
+
// Calls from a retired entry stay pending: settling them would run its continuations.
|
|
11
|
+
export function isRuntimeDestroyed(): boolean {
|
|
12
|
+
return destroyed;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function destroyRuntime(): void {
|
|
16
|
+
destroyed = true;
|
|
17
|
+
runDestroyTasks();
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
export function registerDestroyTask(task: DestroyTask): () => void {
|
|
10
21
|
destroyTasks.add(task);
|
|
@@ -15,8 +26,8 @@ export function registerDestroyTask(task: DestroyTask): () => void {
|
|
|
15
26
|
|
|
16
27
|
export function runDestroyTasks(): void {
|
|
17
28
|
const tasks = Array.from(destroyTasks);
|
|
29
|
+
destroyTasks.clear();
|
|
18
30
|
for (const task of tasks) {
|
|
19
31
|
task();
|
|
20
32
|
}
|
|
21
|
-
destroyTasks.clear();
|
|
22
33
|
}
|
|
@@ -10,6 +10,8 @@ import type { Worklet } from '../../worklet-runtime/bindings/types.js';
|
|
|
10
10
|
import { registerBackgroundFunctionCtx } from '../background-function/run-on-background.js';
|
|
11
11
|
import { isMainThreadFunction } from '../main-thread-function.js';
|
|
12
12
|
import { isMtsEnabled } from '../mts-capability.js';
|
|
13
|
+
import { dispatchReloadScopedEvent } from '../reload-scoped-event.js';
|
|
14
|
+
import { isRuntimeDestroyed } from '../runtime-destroy.js';
|
|
13
15
|
|
|
14
16
|
interface RunOnMainThreadOptions {
|
|
15
17
|
shouldDispatchRunOnMainThreadDirectly: () => boolean;
|
|
@@ -44,6 +46,7 @@ export function createRunOnMainThread(
|
|
|
44
46
|
}
|
|
45
47
|
return async (...params: Parameters<Fn>): Promise<R> => {
|
|
46
48
|
return new Promise((resolve) => {
|
|
49
|
+
if (isRuntimeDestroyed()) return;
|
|
47
50
|
const worklet = fn as unknown as Worklet;
|
|
48
51
|
prepareMainThreadFunctionCtx(worklet);
|
|
49
52
|
const data = {
|
|
@@ -74,8 +77,5 @@ function prepareMainThreadFunctionCtx(worklet: unknown): void {
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
function dispatchRunOnMainThreadEvent(data: RunWorkletCtxData): void {
|
|
77
|
-
lynx.getCoreContext().
|
|
78
|
-
type: WorkletEvents.runWorkletCtx,
|
|
79
|
-
data: JSON.stringify(data),
|
|
80
|
-
});
|
|
80
|
+
dispatchReloadScopedEvent(lynx.getCoreContext(), { type: WorkletEvents.runWorkletCtx, data });
|
|
81
81
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import { IndexMap } from '../../shared/index-map.js';
|
|
6
6
|
import { WorkletEvents } from '../../worklet-runtime/bindings/events.js';
|
|
7
7
|
import type { RunWorkletCtxRetData } from '../../worklet-runtime/bindings/events.js';
|
|
8
|
+
import { cardLifetime } from '../card-lifetime.js';
|
|
9
|
+
import { addReloadScopedEventListener } from '../reload-scoped-event.js';
|
|
8
10
|
import { registerDestroyTask } from '../runtime-destroy.js';
|
|
9
11
|
|
|
10
12
|
let resolveMap: IndexMap<(value: any) => void> | undefined;
|
|
@@ -14,11 +16,11 @@ let unregisterReturnValueCleanup: (() => void) | undefined;
|
|
|
14
16
|
function initReturnValueListener(): void {
|
|
15
17
|
const context: RuntimeProxy = __JS__ ? lynx.getCoreContext() : lynx.getJSContext();
|
|
16
18
|
|
|
17
|
-
resolveMap = new IndexMap();
|
|
18
|
-
context
|
|
19
|
+
resolveMap = new IndexMap(cardLifetime('functionCallId', () => ({ lastIndex: 0 })));
|
|
20
|
+
const removeListener = addReloadScopedEventListener(context, WorkletEvents.FunctionCallRet, onFunctionCallRet);
|
|
19
21
|
|
|
20
22
|
cleanupReturnValueListener = () => {
|
|
21
|
-
|
|
23
|
+
removeListener();
|
|
22
24
|
resolveMap = undefined;
|
|
23
25
|
cleanupReturnValueListener = undefined;
|
|
24
26
|
};
|
|
@@ -62,8 +64,7 @@ export function dropFunctionCallReturnIds(resolveIds: readonly number[]): void {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
function onFunctionCallRet(
|
|
66
|
-
const data = JSON.parse(event.data as string) as RunWorkletCtxRetData;
|
|
67
|
+
function onFunctionCallRet(data: RunWorkletCtxRetData): void {
|
|
67
68
|
const map = resolveMap;
|
|
68
69
|
if (!map) {
|
|
69
70
|
return;
|
package/runtime/src/document.ts
CHANGED
|
@@ -77,10 +77,4 @@ function setupDocument(_document: SnapshotDocumentAdapter = document): void {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// if (__JS__) {
|
|
81
|
-
// setupBackgroundDocument();
|
|
82
|
-
// } else if (__LEPUS__) {
|
|
83
|
-
// setupDocument();
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
80
|
export { document, setupBackgroundDocument, setupDocument };
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from './commit-context.js';
|
|
12
12
|
import type { BackgroundElementTemplateInstance } from './instance.js';
|
|
13
13
|
import { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';
|
|
14
|
-
import { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';
|
|
15
14
|
import { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';
|
|
16
15
|
import { getReloadVersion } from '../../core/reload-version.js';
|
|
17
16
|
import {
|
|
@@ -21,9 +20,9 @@ import {
|
|
|
21
20
|
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
22
21
|
import { COMMIT } from '../../shared/render-constants.js';
|
|
23
22
|
import { hook, isEmptyObject } from '../../utils.js';
|
|
24
|
-
import type { MainThreadRefInitValuePatch } from '../../worklet-runtime/bindings/types.js';
|
|
25
23
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
26
24
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
25
|
+
import { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';
|
|
27
26
|
import { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';
|
|
28
27
|
import { createElementTemplateUpdateEvent } from '../protocol/update-event.js';
|
|
29
28
|
|
|
@@ -68,14 +67,25 @@ export function cancelElementTemplateRemovedSubtreeCleanup(): void {
|
|
|
68
67
|
scheduledRemovedSubtreeCleanupTimers.clear();
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
function
|
|
70
|
+
function cleanupFailedElementTemplateCommit(
|
|
71
|
+
removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],
|
|
72
|
+
delayedRunOnMainThreadPayload: readonly { resolveId: number }[] | undefined,
|
|
73
|
+
): void {
|
|
74
|
+
if (delayedRunOnMainThreadPayload) {
|
|
75
|
+
dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));
|
|
76
|
+
}
|
|
77
|
+
clearPendingRefs();
|
|
78
|
+
resetGlobalCommitContext();
|
|
79
|
+
setPipeline(undefined);
|
|
80
|
+
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function flushElementTemplateCommitChanges(): void {
|
|
72
84
|
const hasNativeOps = globalCommitContext.ops.length > 0;
|
|
73
85
|
const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;
|
|
74
|
-
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
75
86
|
const hasUpdatePayload = hasNativeOps
|
|
76
87
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
77
|
-
|| hasDelayedRunOnMainThread
|
|
78
|
-
|| hasMainThreadRefInitValuePatch;
|
|
88
|
+
|| hasDelayedRunOnMainThread;
|
|
79
89
|
const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];
|
|
80
90
|
if (hasUpdatePayload) {
|
|
81
91
|
markTimingLegacy('updateDiffVdomEnd');
|
|
@@ -115,7 +125,6 @@ function flushElementTemplateCommitChanges(mainThreadRefInitValuePatch: MainThre
|
|
|
115
125
|
flushOptions: globalCommitContext.flushOptions,
|
|
116
126
|
flowIds: globalCommitContext.flowIds,
|
|
117
127
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
118
|
-
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
119
128
|
},
|
|
120
129
|
null,
|
|
121
130
|
2,
|
|
@@ -129,17 +138,9 @@ function flushElementTemplateCommitChanges(mainThreadRefInitValuePatch: MainThre
|
|
|
129
138
|
reloadVersion: getReloadVersion(),
|
|
130
139
|
flowIds: globalCommitContext.flowIds,
|
|
131
140
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
132
|
-
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
133
|
-
? mainThreadRefInitValuePatch
|
|
134
|
-
: undefined,
|
|
135
141
|
});
|
|
136
142
|
} catch (error) {
|
|
137
|
-
|
|
138
|
-
dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));
|
|
139
|
-
}
|
|
140
|
-
clearPendingRefs();
|
|
141
|
-
resetGlobalCommitContext();
|
|
142
|
-
scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);
|
|
143
|
+
cleanupFailedElementTemplateCommit(removedSubtreesAwaitingTeardown, delayedRunOnMainThreadPayload);
|
|
143
144
|
throw error;
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -166,23 +167,31 @@ export function installElementTemplateCommitHook(): void {
|
|
|
166
167
|
hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {
|
|
167
168
|
if (__BACKGROUND__) {
|
|
168
169
|
clearElementTemplateRenderScope();
|
|
170
|
+
try {
|
|
171
|
+
sendMTRefInitValueToMainThread();
|
|
172
|
+
} catch (error) {
|
|
173
|
+
cleanupFailedElementTemplateCommit(
|
|
174
|
+
takeRemovedSubtreesForPostDispatchTeardown(),
|
|
175
|
+
takeDelayedRunOnMainThreadData(),
|
|
176
|
+
);
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
169
179
|
}
|
|
170
180
|
|
|
171
181
|
if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {
|
|
172
182
|
// User effects can run before ET hydrate arrives, so ordinary refs must be
|
|
173
183
|
// attached on the background commit even though native UI ops are delayed.
|
|
174
184
|
flushPendingRefs();
|
|
175
|
-
} else if (
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
} else if (
|
|
186
|
+
__BACKGROUND__ && hasHydrated
|
|
187
|
+
&& (
|
|
178
188
|
globalCommitContext.ops.length > 0
|
|
179
189
|
|| !isEmptyObject(globalCommitContext.flushOptions)
|
|
180
190
|
|| hasPendingRefs()
|
|
181
191
|
|| delayedRunOnMainThreadData.length > 0
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
192
|
+
)
|
|
193
|
+
) {
|
|
194
|
+
flushElementTemplateCommitChanges();
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
originalCommit?.(vnode, commitQueue);
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
31
31
|
import { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';
|
|
32
32
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
33
|
+
import { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';
|
|
33
34
|
import { clearPendingEvents, flushPendingEvents } from '../prop-adapters/event.js';
|
|
34
35
|
import { clearDelayedRefUiOps, clearPendingRefs, flushDelayedRefUiOps } from '../prop-adapters/ref.js';
|
|
35
36
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
@@ -107,8 +108,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
107
108
|
const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread
|
|
108
109
|
? takeDelayedRunOnMainThreadData()
|
|
109
110
|
: undefined;
|
|
110
|
-
const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();
|
|
111
|
-
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
112
111
|
const pipelineOptions = globalPipelineOptions;
|
|
113
112
|
if (pipelineOptions) {
|
|
114
113
|
globalCommitContext.flushOptions.pipelineOptions = pipelineOptions;
|
|
@@ -122,6 +121,7 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
122
121
|
}
|
|
123
122
|
markTiming('packChangesStart');
|
|
124
123
|
try {
|
|
124
|
+
sendMTRefInitValueToMainThread();
|
|
125
125
|
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
126
126
|
console.alog?.(
|
|
127
127
|
'[ReactLynxDebug] ElementTemplate hydrate update commands:\n'
|
|
@@ -132,7 +132,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
132
132
|
flowIds: globalCommitContext.flowIds,
|
|
133
133
|
isHydration: true,
|
|
134
134
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
135
|
-
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
136
135
|
},
|
|
137
136
|
null,
|
|
138
137
|
2,
|
|
@@ -146,9 +145,6 @@ export function installElementTemplateHydrationListener(): void {
|
|
|
146
145
|
reloadVersion: getReloadVersion(),
|
|
147
146
|
flowIds: globalCommitContext.flowIds,
|
|
148
147
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
149
|
-
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
150
|
-
? mainThreadRefInitValuePatch
|
|
151
|
-
: undefined,
|
|
152
148
|
});
|
|
153
149
|
} catch (error) {
|
|
154
150
|
if (delayedRunOnMainThreadPayload) {
|
|
@@ -1,13 +1,11 @@
|
|
|
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 { createContext, createElement } from 'preact/compat';
|
|
5
|
-
// import { useState } from 'preact/hooks';
|
|
6
4
|
import type { ComponentChild, ContainerNode } from 'preact';
|
|
7
5
|
import { render } from 'preact';
|
|
8
6
|
import type { ReactNode } from 'react';
|
|
9
7
|
|
|
10
|
-
import type { DataProcessorDefinition } from '../../lynx-
|
|
8
|
+
import type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';
|
|
11
9
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
12
10
|
import { __root } from '../runtime/page/root-instance.js';
|
|
13
11
|
|
|
@@ -39,7 +39,7 @@ import { createGlobalProps } from '../core/globalProps.js';
|
|
|
39
39
|
import type { GlobalProps } from '../core/globalProps.js';
|
|
40
40
|
import { useLynxGlobalEventListener } from '../core/hooks/useLynxGlobalEventListener.js';
|
|
41
41
|
import { factory, withInitDataInState } from '../core/initData.js';
|
|
42
|
-
import type { InitData } from '../lynx-
|
|
42
|
+
import type { InitData } from '../core/lynx-data-processors.js';
|
|
43
43
|
import './native/index.js';
|
|
44
44
|
|
|
45
45
|
installComponentCompat();
|
|
@@ -141,4 +141,4 @@ export type {
|
|
|
141
141
|
MainThreadObjectType,
|
|
142
142
|
MainThreadObjectTypeDefinition,
|
|
143
143
|
} from '../core/main-thread-object.js';
|
|
144
|
-
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from '../lynx-
|
|
144
|
+
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from '../core/lynx-data-processors.js';
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
// import { Suspense, createElement, lazy } from 'preact/compat';
|
|
6
|
-
// import type { FC } from 'react';
|
|
7
|
-
|
|
8
5
|
import './runtime-marker.js';
|
|
9
6
|
import './native/index.js';
|
|
10
7
|
|
|
11
|
-
// import { factory as factory2 } from '../compat/componentIs.js';
|
|
12
|
-
// import { useMemo } from '../core/hooks/react.js';
|
|
13
8
|
import { __root } from './runtime/page/root-instance.js';
|
|
14
9
|
|
|
15
10
|
/**
|
|
@@ -47,27 +42,12 @@ export { withInitDataInState } from '../core/initData.js';
|
|
|
47
42
|
|
|
48
43
|
export { wrapWithLynxComponent } from '../core/compat/lynxComponent.js';
|
|
49
44
|
|
|
50
|
-
/**
|
|
51
|
-
* @internal a polyfill for <component is=? />
|
|
52
|
-
*/
|
|
53
|
-
// export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory2(
|
|
54
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
55
|
-
// { Suspense, lazy, createElement, useMemo } as any,
|
|
56
|
-
// loadLazyBundle,
|
|
57
|
-
// );
|
|
58
|
-
|
|
59
45
|
export { loadLazyBundle } from '../core/lynx/lazy-bundle.js';
|
|
60
46
|
|
|
61
47
|
export { transformToWorklet } from './runtime/template/main-thread-background-function.js';
|
|
62
48
|
|
|
63
49
|
export { captureMainThreadObject } from '../core/capture-main-thread-object.js';
|
|
64
50
|
|
|
65
|
-
export function registerWorkletOnBackground(
|
|
66
|
-
_type: string,
|
|
67
|
-
_hash: string,
|
|
68
|
-
_fn: (...args: unknown[]) => unknown,
|
|
69
|
-
): void {}
|
|
70
|
-
|
|
71
51
|
export {
|
|
72
52
|
__etAttrPlanMap,
|
|
73
53
|
adaptEventAttrSlot,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
import { createProcessData } from '../../core/lynx-data-processors.js';
|
|
5
|
-
import type { DataProcessorDefinition } from '../../lynx-
|
|
5
|
+
import type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';
|
|
6
6
|
|
|
7
7
|
export function setupLynxEnv(): void {
|
|
8
8
|
if (!__LEPUS__) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';
|
|
6
|
+
import type { MainThreadRefInitValuePatch } from '@lynx-js/react/worklet-runtime/bindings';
|
|
7
|
+
|
|
8
|
+
import { takeMainThreadRefInitValuePatch } from '../core/main-thread-ref-init-value.js';
|
|
9
|
+
import { ElementTemplateLifecycleConstant } from './protocol/lifecycle-constant.js';
|
|
10
|
+
|
|
11
|
+
let listener: ((event: RuntimeProxy.Event) => void) | undefined;
|
|
12
|
+
|
|
13
|
+
export function installElementTemplateRefInitValueListener(): void {
|
|
14
|
+
resetElementTemplateRefInitValueListener();
|
|
15
|
+
listener = (event) => {
|
|
16
|
+
const data = event.data as string;
|
|
17
|
+
const patch = JSON.parse(data) as MainThreadRefInitValuePatch;
|
|
18
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
19
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate MTS updateMTRefInitValue:\n' + data);
|
|
20
|
+
}
|
|
21
|
+
// Ref initialization outlives UI patches and must not be filtered by reloadVersion.
|
|
22
|
+
updateWorkletRefInitValueChanges(patch);
|
|
23
|
+
};
|
|
24
|
+
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resetElementTemplateRefInitValueListener(): void {
|
|
28
|
+
if (listener) {
|
|
29
|
+
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
30
|
+
}
|
|
31
|
+
listener = undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function sendMTRefInitValueToMainThread(): void {
|
|
35
|
+
const patch = takeMainThreadRefInitValuePatch();
|
|
36
|
+
if (patch.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const data = JSON.stringify(patch);
|
|
40
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
41
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS sendMTRefInitValue:\n' + data);
|
|
42
|
+
}
|
|
43
|
+
lynx.getCoreContext().dispatchEvent({ type: ElementTemplateLifecycleConstant.updateMTRefInitValue, data });
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
6
|
+
|
|
7
|
+
export function flushElementTemplate(options: FlushOptions = {}): void {
|
|
8
|
+
applyPendingMainThreadRefAttachments();
|
|
9
|
+
__FlushElementTree(undefined, options);
|
|
10
|
+
}
|
|
@@ -25,6 +25,7 @@ import { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';
|
|
|
25
25
|
import { initProfileHook } from '../debug/profile.js';
|
|
26
26
|
import { setupLynxEnv } from '../lynx/env.js';
|
|
27
27
|
import { initTimingAPI } from '../lynx/performance.js';
|
|
28
|
+
import { installElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
28
29
|
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
29
30
|
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
30
31
|
|
|
@@ -57,6 +58,7 @@ function init(): void {
|
|
|
57
58
|
if (__MAIN_THREAD__) {
|
|
58
59
|
installMainThreadHooks();
|
|
59
60
|
injectCalledByNative();
|
|
61
|
+
installElementTemplateRefInitValueListener();
|
|
60
62
|
installElementTemplatePatchListener();
|
|
61
63
|
installOnMtsDestruction();
|
|
62
64
|
if (__PROFILE__) {
|