@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
package/runtime/src/lynx-api.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { createGlobalProps } from './core/globalProps.js';
|
|
|
10
10
|
import type { GlobalProps } from './core/globalProps.js';
|
|
11
11
|
import { useLynxGlobalEventListener } from './core/hooks/useLynxGlobalEventListener.js';
|
|
12
12
|
import { factory, withInitDataInState } from './core/initData.js';
|
|
13
|
+
import type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from './core/lynx-data-processors.js';
|
|
13
14
|
import { __root } from './root.js';
|
|
14
15
|
import { profileEnd, profileStart } from './shared/profile.js';
|
|
15
16
|
import { LifecycleConstant } from './snapshot/lifecycle/constant.js';
|
|
@@ -338,132 +339,9 @@ export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.us
|
|
|
338
339
|
export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps
|
|
339
340
|
.useChanged();
|
|
340
341
|
|
|
341
|
-
|
|
342
|
-
* The interface you can extends so that the `defaultDataProcessor` parameter can be customized
|
|
343
|
-
*
|
|
344
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
345
|
-
*
|
|
346
|
-
* @public
|
|
347
|
-
*
|
|
348
|
-
* @group Types
|
|
349
|
-
*/
|
|
350
|
-
export interface InitDataRaw {}
|
|
351
|
-
/**
|
|
352
|
-
* The interface you can extends so that the `defaultDataProcessor` returning value can be customized
|
|
353
|
-
*
|
|
354
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
355
|
-
*
|
|
356
|
-
* @public
|
|
357
|
-
*
|
|
358
|
-
* @group Types
|
|
359
|
-
*/
|
|
360
|
-
export interface InitData {}
|
|
361
|
-
|
|
342
|
+
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw };
|
|
362
343
|
export { withInitDataInState };
|
|
363
344
|
|
|
364
|
-
/**
|
|
365
|
-
* The data processors that registered with {@link Lynx.registerDataProcessors}.
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
*
|
|
369
|
-
* Extending `dataProcessors` interface
|
|
370
|
-
*
|
|
371
|
-
* ```ts
|
|
372
|
-
* import type { DataProcessors as WellKnownDataProcessors } from '@lynx-js/react';
|
|
373
|
-
*
|
|
374
|
-
* declare module '@lynx-js/react' {
|
|
375
|
-
* interface DataProcessors extends WellKnownDataProcessors {
|
|
376
|
-
* foo(bar: string): number;
|
|
377
|
-
* }
|
|
378
|
-
* }
|
|
379
|
-
* ```
|
|
380
|
-
*
|
|
381
|
-
* Then you can use `lynx.registerDataProcessors` with types.
|
|
382
|
-
*
|
|
383
|
-
* ```js
|
|
384
|
-
* lynx.registerDataProcessors({
|
|
385
|
-
* dataProcessors: {
|
|
386
|
-
* foo(bar) {
|
|
387
|
-
* return 1;
|
|
388
|
-
* }
|
|
389
|
-
* }
|
|
390
|
-
* })
|
|
391
|
-
* ```
|
|
392
|
-
*
|
|
393
|
-
* @public
|
|
394
|
-
*
|
|
395
|
-
* @group Types
|
|
396
|
-
*/
|
|
397
|
-
export interface DataProcessors {
|
|
398
|
-
/**
|
|
399
|
-
* Optional processor to override screen metrics used by the app
|
|
400
|
-
*
|
|
401
|
-
* @param metrics - The physical screen dimensions in pixels
|
|
402
|
-
*
|
|
403
|
-
* @returns New screen dimensions to be used by the app
|
|
404
|
-
*
|
|
405
|
-
* @example
|
|
406
|
-
*
|
|
407
|
-
* ```ts
|
|
408
|
-
* lynx.registerDataProcessors({
|
|
409
|
-
* dataProcessors: {
|
|
410
|
-
* getScreenMetricsOverride: (metrics) => {
|
|
411
|
-
* // Force a specific aspect ratio
|
|
412
|
-
* return {
|
|
413
|
-
* width: metrics.width,
|
|
414
|
-
* height: metrics.width * (16/9)
|
|
415
|
-
* };
|
|
416
|
-
* }
|
|
417
|
-
* }
|
|
418
|
-
* });
|
|
419
|
-
* ```
|
|
420
|
-
*/
|
|
421
|
-
getScreenMetricsOverride?(metrics: {
|
|
422
|
-
/**
|
|
423
|
-
* The physical pixel width of the screen
|
|
424
|
-
*/
|
|
425
|
-
width: number;
|
|
426
|
-
/**
|
|
427
|
-
* The physical pixel height of the screen
|
|
428
|
-
*/
|
|
429
|
-
height: number;
|
|
430
|
-
}): { width: number; height: number };
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Custom unknown data processors.
|
|
434
|
-
*
|
|
435
|
-
* @remarks
|
|
436
|
-
*
|
|
437
|
-
* You may extends the `DataProcessors` interface for better TypeScript types. See {@link DataProcessors}.
|
|
438
|
-
*/
|
|
439
|
-
[processorName: string]: (...args: any[]) => any;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Definition of DataProcessor(s)
|
|
444
|
-
* @public
|
|
445
|
-
*
|
|
446
|
-
* @group Types
|
|
447
|
-
*/
|
|
448
|
-
export interface DataProcessorDefinition {
|
|
449
|
-
/**
|
|
450
|
-
* You can custom input and output type of `defaultDataProcessor` by extends {@link InitDataRaw} and {@link InitData}
|
|
451
|
-
*
|
|
452
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
453
|
-
*
|
|
454
|
-
* @param rawInitData - initData passed from native code
|
|
455
|
-
* @returns
|
|
456
|
-
* @public
|
|
457
|
-
*/
|
|
458
|
-
defaultDataProcessor?: (rawInitData: InitDataRaw) => InitData;
|
|
459
|
-
/**
|
|
460
|
-
* Should be used with `lynx.registerDataProcessors`. See more examples at {@link Lynx.registerDataProcessors}.
|
|
461
|
-
*
|
|
462
|
-
* @public
|
|
463
|
-
*/
|
|
464
|
-
dataProcessors?: DataProcessors;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
345
|
/**
|
|
468
346
|
* APIs under `lynx` global variable that added by ReactLynx.
|
|
469
347
|
*
|
|
@@ -44,7 +44,7 @@ interface PatchedVNode extends VNode {
|
|
|
44
44
|
/**
|
|
45
45
|
* Get human readable name of the component/dom node
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
function getVNodeDisplayName(vnode: PatchedVNode): string {
|
|
48
48
|
if (vnode.type === Fragment) {
|
|
49
49
|
return 'Fragment';
|
|
50
50
|
} else if (typeof vnode.type == 'function') {
|
|
@@ -81,6 +81,7 @@ const renderStack: PatchedVNode[] = [];
|
|
|
81
81
|
* optimization. In these cases the `_owner` will be different.
|
|
82
82
|
*/
|
|
83
83
|
let ownerStack: PatchedVNode[] = [];
|
|
84
|
+
let didInstallComponentStack = false;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* Get the currently rendered `vnode`
|
|
@@ -108,7 +109,7 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
return stack.reduce((acc, owner) => {
|
|
111
|
-
acc += ` in ${
|
|
112
|
+
acc += ` in ${getVNodeDisplayName(owner)}`;
|
|
112
113
|
|
|
113
114
|
const source = owner.__source;
|
|
114
115
|
if (source) {
|
|
@@ -125,6 +126,13 @@ export function getOwnerStack(vnode: PatchedVNode): string {
|
|
|
125
126
|
* debug messages for `this.setState` where the `vnode` is `undefined`.
|
|
126
127
|
*/
|
|
127
128
|
export function setupComponentStack(): void {
|
|
129
|
+
renderStack.length = 0;
|
|
130
|
+
ownerStack = [];
|
|
131
|
+
if (didInstallComponentStack) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
didInstallComponentStack = true;
|
|
135
|
+
|
|
128
136
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
129
137
|
const oldDiff = options[DIFF];
|
|
130
138
|
const oldDiffed = options[DIFFED];
|
|
@@ -135,9 +143,15 @@ export function setupComponentStack(): void {
|
|
|
135
143
|
|
|
136
144
|
options[DIFFED] = vnode => {
|
|
137
145
|
if (isPossibleOwner(vnode)) {
|
|
138
|
-
ownerStack.
|
|
146
|
+
const ownerIndex = ownerStack.lastIndexOf(vnode);
|
|
147
|
+
if (ownerIndex !== -1) {
|
|
148
|
+
ownerStack.length = ownerIndex;
|
|
149
|
+
}
|
|
150
|
+
const renderIndex = renderStack.lastIndexOf(vnode);
|
|
151
|
+
if (renderIndex !== -1) {
|
|
152
|
+
renderStack.length = renderIndex;
|
|
153
|
+
}
|
|
139
154
|
}
|
|
140
|
-
renderStack.pop();
|
|
141
155
|
if (oldDiffed) oldDiffed(vnode);
|
|
142
156
|
};
|
|
143
157
|
|
|
@@ -149,7 +163,10 @@ export function setupComponentStack(): void {
|
|
|
149
163
|
};
|
|
150
164
|
|
|
151
165
|
options[ROOT] = (vnode, parent) => {
|
|
152
|
-
|
|
166
|
+
if (!(parent as { parentNode?: unknown } | null | undefined)?.parentNode) {
|
|
167
|
+
renderStack.length = 0;
|
|
168
|
+
ownerStack = [];
|
|
169
|
+
}
|
|
153
170
|
if (oldRoot) oldRoot(vnode, parent);
|
|
154
171
|
};
|
|
155
172
|
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
export class IndexMap<T> {
|
|
6
|
-
protected lastIndex = 0;
|
|
7
6
|
protected indexMap: Map<number, T> = new Map<number, T>();
|
|
8
7
|
|
|
8
|
+
constructor(private counter: { lastIndex: number } = { lastIndex: 0 }) {}
|
|
9
|
+
|
|
9
10
|
public add(value: T): number {
|
|
10
|
-
const index = ++this.lastIndex;
|
|
11
|
+
const index = ++this.counter.lastIndex;
|
|
11
12
|
this.indexMap.set(index, value);
|
|
12
13
|
return index;
|
|
13
14
|
}
|
|
@@ -7,14 +7,19 @@ import { __root } from '../../root.js';
|
|
|
7
7
|
import { delayedEvents } from './event/delayEvents.js';
|
|
8
8
|
import { delayedLifecycleEvents } from './event/delayLifecycleEvents.js';
|
|
9
9
|
import { globalCommitTaskMap } from './patch/commit.js';
|
|
10
|
+
import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
|
|
10
11
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
11
12
|
import { withSyncEffectFlush } from '../../utils.js';
|
|
13
|
+
import { resetSnapshotMainThreadFunctionRuntime } from '../worklet/call/runOnMainThread.js';
|
|
14
|
+
import { resetSnapshotBackgroundFunctionRuntime } from '../worklet/ctx.js';
|
|
12
15
|
|
|
13
16
|
function destroyBackground(): void {
|
|
14
17
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
15
18
|
profileStart('ReactLynx::destroyBackground');
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
deinitGlobalSnapshotPatch();
|
|
22
|
+
|
|
18
23
|
withSyncEffectFlush(() => {
|
|
19
24
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
20
25
|
render(null, __root as any);
|
|
@@ -30,6 +35,8 @@ function destroyBackground(): void {
|
|
|
30
35
|
if (delayedEvents) {
|
|
31
36
|
delayedEvents.length = 0;
|
|
32
37
|
}
|
|
38
|
+
resetSnapshotBackgroundFunctionRuntime();
|
|
39
|
+
resetSnapshotMainThreadFunctionRuntime();
|
|
33
40
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
34
41
|
profileEnd();
|
|
35
42
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 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 { cardLifetime } from '../../../core/card-lifetime.js';
|
|
4
5
|
import { isProcessingDefaultData } from '../../../core/lynx-data-processors.js';
|
|
5
6
|
import { __root } from '../../../root.js';
|
|
6
7
|
import { profileEnd, profileStart } from '../../../shared/profile.js';
|
|
@@ -9,13 +10,20 @@ import { LifecycleConstant } from '../../lifecycle/constant.js';
|
|
|
9
10
|
// Initialized once at module load (`renderPage` runs once per runtime and does
|
|
10
11
|
// not reset), so a ready mark set before `renderPage` (e.g. in `defaultDataProcessor`)
|
|
11
12
|
// survives. In `'manual'` mode the first screen syncs only after both are true.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const firstScreenSync: {
|
|
14
|
+
isSynced: boolean;
|
|
15
|
+
eventIdSwap: Record<string | number, number>;
|
|
16
|
+
isMarkedReady: boolean;
|
|
17
|
+
isTreeReady: boolean;
|
|
18
|
+
} = /*#__PURE__*/ cardLifetime('firstScreenSync', () => ({
|
|
19
|
+
isSynced: false,
|
|
20
|
+
eventIdSwap: {},
|
|
21
|
+
isMarkedReady: false,
|
|
22
|
+
isTreeReady: false,
|
|
23
|
+
}));
|
|
16
24
|
|
|
17
25
|
function syncFirstScreen(): void {
|
|
18
|
-
|
|
26
|
+
firstScreenSync.isSynced = true;
|
|
19
27
|
|
|
20
28
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
21
29
|
profileStart('ReactLynx::serializeRoot');
|
|
@@ -31,13 +39,13 @@ function syncFirstScreen(): void {
|
|
|
31
39
|
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
32
40
|
{
|
|
33
41
|
root,
|
|
34
|
-
firstScreenEventIdSwap,
|
|
42
|
+
firstScreenEventIdSwap: firstScreenSync.eventIdSwap,
|
|
35
43
|
},
|
|
36
44
|
]);
|
|
37
45
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
38
46
|
profileEnd();
|
|
39
47
|
}
|
|
40
|
-
|
|
48
|
+
firstScreenSync.eventIdSwap = {};
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
// ready signal: business/framework allows the handover. Syncs if the tree is ready.
|
|
@@ -45,10 +53,10 @@ function onFirstScreenSyncReady(): void {
|
|
|
45
53
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
46
54
|
profileStart('ReactLynx::onFirstScreenSyncReady');
|
|
47
55
|
}
|
|
48
|
-
|
|
56
|
+
firstScreenSync.isMarkedReady = true;
|
|
49
57
|
// A mark made inside `defaultDataProcessor` (a native call before the upcoming render)
|
|
50
58
|
// is recorded but not synced now; `onFirstScreenTreeReady` honors it once render ends.
|
|
51
|
-
if (
|
|
59
|
+
if (firstScreenSync.isTreeReady && !isProcessingDefaultData() && !firstScreenSync.isSynced) {
|
|
52
60
|
syncFirstScreen();
|
|
53
61
|
}
|
|
54
62
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -58,8 +66,8 @@ function onFirstScreenSyncReady(): void {
|
|
|
58
66
|
|
|
59
67
|
// tree built (`renderPage` / `updatePage` done). Syncs if the ready signal already came.
|
|
60
68
|
function onFirstScreenTreeReady(): void {
|
|
61
|
-
|
|
62
|
-
if (
|
|
69
|
+
firstScreenSync.isTreeReady = true;
|
|
70
|
+
if (firstScreenSync.isMarkedReady && !firstScreenSync.isSynced) {
|
|
63
71
|
syncFirstScreen();
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -67,19 +75,19 @@ function onFirstScreenTreeReady(): void {
|
|
|
67
75
|
// the first-screen tree is being (re-)rendered, a mark during this period
|
|
68
76
|
// must not sync until the next `onFirstScreenTreeReady`
|
|
69
77
|
function resetFirstScreenTreeReady(): void {
|
|
70
|
-
|
|
78
|
+
firstScreenSync.isTreeReady = false;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
function clearFirstScreenEventIdSwap(): void {
|
|
74
|
-
|
|
82
|
+
firstScreenSync.eventIdSwap = {};
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
// Full reset of all first-screen state. Used by SSR hydration to re-initialize.
|
|
78
86
|
function resetFirstScreenSyncState(): void {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
firstScreenSync.isSynced = false;
|
|
88
|
+
firstScreenSync.eventIdSwap = {};
|
|
89
|
+
firstScreenSync.isMarkedReady = false;
|
|
90
|
+
firstScreenSync.isTreeReady = false;
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
/**
|
|
@@ -87,8 +95,7 @@ function resetFirstScreenSyncState(): void {
|
|
|
87
95
|
*/
|
|
88
96
|
export {
|
|
89
97
|
syncFirstScreen,
|
|
90
|
-
|
|
91
|
-
firstScreenEventIdSwap,
|
|
98
|
+
firstScreenSync,
|
|
92
99
|
clearFirstScreenEventIdSwap,
|
|
93
100
|
resetFirstScreenSyncState,
|
|
94
101
|
onFirstScreenSyncReady,
|
|
@@ -18,7 +18,6 @@ export const SnapshotOperation = {
|
|
|
18
18
|
nodesRefRemoveChild: 6,
|
|
19
19
|
|
|
20
20
|
DEV_ONLY_AddSnapshot: 100,
|
|
21
|
-
DEV_ONLY_RegisterWorklet: 101,
|
|
22
21
|
DEV_ONLY_SetSnapshotEntryName: 102,
|
|
23
22
|
} as const;
|
|
24
23
|
|
|
@@ -64,10 +63,6 @@ export const SnapshotOperationParams: Record<number, { name: string; params: str
|
|
|
64
63
|
'snapshotCreator', /* string */
|
|
65
64
|
],
|
|
66
65
|
},
|
|
67
|
-
[SnapshotOperation.DEV_ONLY_RegisterWorklet]: {
|
|
68
|
-
name: 'DEV_ONLY_RegisterWorklet',
|
|
69
|
-
params: ['hash', /* string */ 'fnStr' /* string */],
|
|
70
|
-
},
|
|
71
66
|
[SnapshotOperation.DEV_ONLY_SetSnapshotEntryName]: {
|
|
72
67
|
name: 'DEV_ONLY_SetSnapshotEntryName',
|
|
73
68
|
params: ['uniqID', /* string */ 'entryName' /* string */],
|
|
@@ -161,16 +161,6 @@ export function snapshotPatchApply(snapshotPatch: SnapshotPatch, commitId: numbe
|
|
|
161
161
|
}
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
|
-
// case SnapshotOperation.DEV_ONLY_RegisterWorklet: {
|
|
165
|
-
// // HMR-related
|
|
166
|
-
// if (__DEV__) {
|
|
167
|
-
// const hash: string = snapshotPatch[++i];
|
|
168
|
-
// const fnStr: string = snapshotPatch[++i];
|
|
169
|
-
// const fn = evaluate<(ctx: SnapshotInstance) => FiberElement[]>(fnStr);
|
|
170
|
-
// registerWorklet('main-thread', hash, fn);
|
|
171
|
-
// }
|
|
172
|
-
// break;
|
|
173
|
-
// }
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
}
|
|
@@ -36,72 +36,76 @@ function updateMainThread(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
setPipeline(patchOptions.pipelineOptions);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
try {
|
|
40
|
+
markTiming('mtsRenderStart');
|
|
41
|
+
markTiming('parseChangesStart');
|
|
42
|
+
const parsedData = JSON.parse(data) as PatchList;
|
|
43
|
+
const { patchList, flushOptions = {}, delayedRunOnMainThreadData } = parsedData;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
46
|
+
console.alog?.(
|
|
47
|
+
'[ReactLynxDebug] BTS -> MTS updateMainThread:\n' + JSON.stringify(
|
|
48
|
+
{
|
|
49
|
+
data: {
|
|
50
|
+
...parsedData,
|
|
51
|
+
patchList: parsedData.patchList.map(patch => ({
|
|
52
|
+
...patch,
|
|
53
|
+
snapshotPatch: prettyFormatSnapshotPatch(patch.snapshotPatch),
|
|
54
|
+
})),
|
|
55
|
+
},
|
|
56
|
+
patchOptions,
|
|
54
57
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
markTiming('parseChangesEnd');
|
|
64
|
-
markTiming('patchChangesStart');
|
|
65
|
-
if (patchOptions.isHydration) {
|
|
66
|
-
setMainThreadHydrating(true);
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
for (const { snapshotPatch, id } of patchList) {
|
|
70
|
-
__pendingListUpdates.clearAttachedLists();
|
|
71
|
-
if (snapshotPatch) {
|
|
72
|
-
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
73
|
-
}
|
|
74
|
-
__pendingListUpdates.flush();
|
|
75
|
-
// console.debug('********** Lepus updatePatch:');
|
|
76
|
-
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
58
|
+
null,
|
|
59
|
+
2,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
77
62
|
}
|
|
78
|
-
|
|
79
|
-
markTiming('
|
|
80
|
-
markTiming('
|
|
63
|
+
|
|
64
|
+
markTiming('parseChangesEnd');
|
|
65
|
+
markTiming('patchChangesStart');
|
|
81
66
|
if (patchOptions.isHydration) {
|
|
82
|
-
setMainThreadHydrating(
|
|
67
|
+
setMainThreadHydrating(true);
|
|
83
68
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
69
|
+
try {
|
|
70
|
+
for (const { snapshotPatch, id } of patchList) {
|
|
71
|
+
__pendingListUpdates.clearAttachedLists();
|
|
72
|
+
if (snapshotPatch) {
|
|
73
|
+
snapshotPatchApply(snapshotPatch, id, patchOptions.isHydration === true);
|
|
74
|
+
}
|
|
75
|
+
__pendingListUpdates.flush();
|
|
76
|
+
// console.debug('********** Lepus updatePatch:');
|
|
77
|
+
// printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
markTiming('patchChangesEnd');
|
|
81
|
+
markTiming('mtsRenderEnd');
|
|
82
|
+
if (patchOptions.isHydration) {
|
|
83
|
+
setMainThreadHydrating(false);
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
applyRefQueue();
|
|
87
|
+
if (delayedRunOnMainThreadData && isMtsEnabled()) {
|
|
88
|
+
setEomShouldFlushElementTree(false);
|
|
89
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
90
|
+
try {
|
|
91
|
+
runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);
|
|
92
|
+
/* v8 ignore next 3 */
|
|
93
|
+
} catch (e) {
|
|
94
|
+
lynx.reportError(e as Error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
setEomShouldFlushElementTree(true);
|
|
98
|
+
}
|
|
99
|
+
if (patchOptions.pipelineOptions) {
|
|
100
|
+
flushOptions.pipelineOptions = patchOptions.pipelineOptions;
|
|
101
|
+
}
|
|
102
|
+
__FlushElementTree(__page, flushOptions);
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
if (flowIds) {
|
|
105
|
+
lynx.performance.profileEnd();
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
setPipeline(undefined);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -9,20 +9,29 @@
|
|
|
9
9
|
|
|
10
10
|
import { render } from 'preact';
|
|
11
11
|
|
|
12
|
+
import { clearDelayedRunOnBackgroundFunctions } from '@lynx-js/react/worklet-runtime/bindings';
|
|
13
|
+
|
|
12
14
|
import { destroyBackground } from './destroy.js';
|
|
13
15
|
import { renderMainThread } from './render.js';
|
|
16
|
+
import {
|
|
17
|
+
canReEvalBackgroundEntry,
|
|
18
|
+
canReEvalMainThreadEntry,
|
|
19
|
+
installMainThreadReloadCompleter,
|
|
20
|
+
reEvalBackgroundEntry,
|
|
21
|
+
reEvalMainThreadEntry,
|
|
22
|
+
} from '../../core/entry-reload.js';
|
|
14
23
|
import { increaseReloadVersion } from '../../core/reload-version.js';
|
|
24
|
+
import { resetFunctionCallReturnListener } from '../../core/thread-function-call/return-value.js';
|
|
15
25
|
import { __root, setRoot } from '../../root.js';
|
|
16
26
|
import { profileEnd, profileStart } from '../../shared/profile.js';
|
|
17
27
|
import { isEmptyObject } from '../../utils.js';
|
|
18
28
|
import { LifecycleConstant } from '../lifecycle/constant.js';
|
|
19
29
|
import { __pendingListUpdates } from '../list/pendingListUpdates.js';
|
|
20
30
|
import { hydrate } from '../renderToOpcodes/hydrate.js';
|
|
21
|
-
import { __page } from '../snapshot/definition.js';
|
|
31
|
+
import { __page, setupPage } from '../snapshot/definition.js';
|
|
22
32
|
import { SnapshotInstance, snapshotInstanceManager } from '../snapshot/snapshot.js';
|
|
23
33
|
import { applyRefQueue } from '../snapshot/workletRef.js';
|
|
24
|
-
import { clearFirstScreenEventIdSwap,
|
|
25
|
-
import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
|
|
34
|
+
import { clearFirstScreenEventIdSwap, firstScreenSync } from './event/firstScreenSync.js';
|
|
26
35
|
import { shouldDelayUiOps } from './ref/delay.js';
|
|
27
36
|
|
|
28
37
|
function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
@@ -30,6 +39,8 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
|
30
39
|
profileStart('ReactLynx::reloadMainThread');
|
|
31
40
|
}
|
|
32
41
|
|
|
42
|
+
clearDelayedRunOnBackgroundFunctions();
|
|
43
|
+
resetFunctionCallReturnListener();
|
|
33
44
|
increaseReloadVersion();
|
|
34
45
|
|
|
35
46
|
if (typeof data == 'object' && data !== null && !isEmptyObject(data)) {
|
|
@@ -41,10 +52,31 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
|
41
52
|
clearFirstScreenEventIdSwap();
|
|
42
53
|
|
|
43
54
|
const oldRoot = __root;
|
|
55
|
+
if (canReEvalMainThreadEntry()) {
|
|
56
|
+
reEvalMainThreadEntry<MainThreadReloadHandoff>({ oldRoot: oldRoot as SnapshotInstance, page: __page, options });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
44
59
|
setRoot(new SnapshotInstance('root'));
|
|
45
60
|
__root.__jsx = oldRoot.__jsx;
|
|
61
|
+
finishMainThreadReload(oldRoot as SnapshotInstance, options);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface MainThreadReloadHandoff {
|
|
65
|
+
oldRoot: SnapshotInstance;
|
|
66
|
+
page: FiberElement;
|
|
67
|
+
options: UpdatePageOption;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function completeMainThreadReload({ oldRoot, page, options }: MainThreadReloadHandoff): void {
|
|
71
|
+
setupPage(page);
|
|
72
|
+
finishMainThreadReload(oldRoot, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
installMainThreadReloadCompleter(completeMainThreadReload);
|
|
76
|
+
|
|
77
|
+
function finishMainThreadReload(oldRoot: SnapshotInstance, options: UpdatePageOption): void {
|
|
46
78
|
renderMainThread();
|
|
47
|
-
hydrate(oldRoot
|
|
79
|
+
hydrate(oldRoot, __root as SnapshotInstance, {
|
|
48
80
|
skipUnRef: true,
|
|
49
81
|
});
|
|
50
82
|
|
|
@@ -56,7 +88,7 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
|
56
88
|
lepusng_gc();
|
|
57
89
|
}
|
|
58
90
|
|
|
59
|
-
if (
|
|
91
|
+
if (firstScreenSync.isSynced) {
|
|
60
92
|
__OnLifecycleEvent([
|
|
61
93
|
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
62
94
|
{
|
|
@@ -70,18 +102,22 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
|
|
|
70
102
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
71
103
|
profileEnd();
|
|
72
104
|
}
|
|
73
|
-
return;
|
|
74
105
|
}
|
|
75
106
|
|
|
76
|
-
function reloadBackground(updateData: Record<string, any>): void {
|
|
107
|
+
function reloadBackground(updateData: Record<string, any>, options?: Record<string, unknown>): void {
|
|
108
|
+
if (canReEvalBackgroundEntry()) {
|
|
109
|
+
reEvalBackgroundEntry(updateData, options, () => {
|
|
110
|
+
// A queued `updateGlobalProps` callback must not render it again.
|
|
111
|
+
__root.__jsx = undefined;
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
77
116
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
78
117
|
profileStart('ReactLynx::reloadBackground');
|
|
79
118
|
}
|
|
80
119
|
|
|
81
|
-
deinitGlobalSnapshotPatch();
|
|
82
|
-
|
|
83
120
|
destroyBackground();
|
|
84
|
-
|
|
85
121
|
increaseReloadVersion();
|
|
86
122
|
|
|
87
123
|
// COW when modify `lynx.__initData` to make sure Provider & Consumer works
|
|
@@ -96,4 +132,4 @@ function reloadBackground(updateData: Record<string, any>): void {
|
|
|
96
132
|
}
|
|
97
133
|
}
|
|
98
134
|
|
|
99
|
-
export { reloadBackground, reloadMainThread };
|
|
135
|
+
export { completeMainThreadReload, reloadBackground, reloadMainThread };
|
|
@@ -1,13 +1,20 @@
|
|
|
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 { cardLifetime } from '../../core/card-lifetime.js';
|
|
4
5
|
import { maybePromise } from '../../utils.js';
|
|
5
6
|
import { LifecycleConstant } from '../lifecycle/constant.js';
|
|
6
7
|
import type { SnapshotInstance } from '../snapshot/snapshot.js';
|
|
7
8
|
import { applyRefQueue } from '../snapshot/workletRef.js';
|
|
8
9
|
|
|
9
|
-
export const gSignMap: Record<number, Map<number, SnapshotInstance>> =
|
|
10
|
-
|
|
10
|
+
export const gSignMap: Record<number, Map<number, SnapshotInstance>> = /*#__PURE__*/ cardLifetime(
|
|
11
|
+
'listSignMap',
|
|
12
|
+
() => ({}),
|
|
13
|
+
);
|
|
14
|
+
export const gRecycleMap: Record<number, Map<string, Map<number, SnapshotInstance>>> = /*#__PURE__*/ cardLifetime(
|
|
15
|
+
'listRecycleMap',
|
|
16
|
+
() => ({}),
|
|
17
|
+
);
|
|
11
18
|
const gParentWeakMap: WeakMap<SnapshotInstance, unknown> = /*#__PURE__*/ new WeakMap();
|
|
12
19
|
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
13
20
|
|