@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAA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C,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC;mBAChD,cAAc,EAAE;mBAChB,0BAA0B,CAAC,MAAM,GAAG,CAAC;mBACrC,2BAA2B,CAAC,MAAM,GAAG,CAAC,EACzC,CAAC;gBACD,iCAAiC,CAAC,2BAA2B,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { options } from 'preact';\n\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport type { BackgroundElementTemplateInstance } from './instance.js';\nimport { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';\nimport { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';\nimport { COMMIT } from '../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../utils.js';\nimport type { MainThreadRefInitValuePatch } from '../../worklet-runtime/bindings/types.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';\nimport { createElementTemplateUpdateEvent } from '../protocol/update-event.js';\n\nlet installed = false;\nlet previousCommit: typeof options[typeof COMMIT];\nlet hasHydrated = false;\nconst scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set<ReturnType<typeof setTimeout>>();\n\nexport function markElementTemplateHydrated(): void {\n hasHydrated = true;\n}\n\nexport function isElementTemplateHydrated(): boolean {\n return hasHydrated;\n}\n\nexport function resetElementTemplateCommitState(): void {\n hasHydrated = false;\n resetElementTemplateRenderScope();\n resetGlobalCommitContext();\n}\n\nexport function scheduleElementTemplateRemovedSubtreeCleanup(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n): void {\n if (removedSubtreesAwaitingTeardown.length === 0) {\n return;\n }\n const timer = setTimeout(() => {\n scheduledRemovedSubtreeCleanupTimers.delete(timer);\n for (const root of removedSubtreesAwaitingTeardown) {\n root.releaseDetachedSubtreeFromManager();\n }\n }, 10000);\n scheduledRemovedSubtreeCleanupTimers.add(timer);\n}\n\nexport function cancelElementTemplateRemovedSubtreeCleanup(): void {\n for (const timer of scheduledRemovedSubtreeCleanupTimers) {\n clearTimeout(timer);\n }\n scheduledRemovedSubtreeCleanupTimers.clear();\n}\n\nfunction flushElementTemplateCommitChanges(mainThreadRefInitValuePatch: MainThreadRefInitValuePatch): void {\n const hasNativeOps = globalCommitContext.ops.length > 0;\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;\n const hasUpdatePayload = hasNativeOps\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasDelayedRunOnMainThread\n || hasMainThreadRefInitValuePatch;\n const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];\n if (hasUpdatePayload) {\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n if (globalPipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;\n }\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n\n if (!hasNativeOps && !hasDelayedRunOnMainThread) {\n globalCommitContext.flushOptions.emptyPatch = true;\n }\n\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n\n let updateEvent: ReturnType<typeof createElementTemplateUpdateEvent>;\n try {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate BTS -> MTS update:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),\n flushOptions: globalCommitContext.flushOptions,\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,\n mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,\n },\n null,\n 2,\n ),\n );\n }\n\n updateEvent = createElementTemplateUpdateEvent({\n ops: globalCommitContext.ops,\n flushOptions: globalCommitContext.flushOptions,\n reloadVersion: getReloadVersion(),\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,\n mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch\n ? mainThreadRefInitValuePatch\n : undefined,\n });\n } catch (error) {\n if (delayedRunOnMainThreadPayload) {\n dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));\n }\n clearPendingRefs();\n resetGlobalCommitContext();\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n throw error;\n }\n\n lynx.getCoreContext().dispatchEvent(updateEvent);\n }\n // When native ops exist, patch first so a newly attached ref observes the\n // committed native state. Ref-only commits still flush through this path.\n flushPendingRefs();\n resetGlobalCommitContext();\n // Match Snapshot's cleanup boundary: start the delayed teardown only\n // after the bridge dispatch, so background JS objects are not torn down\n // before main-thread detach observes the same commit.\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nexport function installElementTemplateCommitHook(): void {\n if (installed) {\n return;\n }\n installed = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {\n if (__BACKGROUND__) {\n clearElementTemplateRenderScope();\n }\n\n if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {\n // User effects can run before ET hydrate arrives, so ordinary refs must be\n // attached on the background commit even though native UI ops are delayed.\n flushPendingRefs();\n } else if (__BACKGROUND__ && hasHydrated) {\n const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();\n if (\n globalCommitContext.ops.length > 0\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasPendingRefs()\n || delayedRunOnMainThreadData.length > 0\n || mainThreadRefInitValuePatch.length > 0\n ) {\n flushElementTemplateCommitChanges(mainThreadRefInitValuePatch);\n }\n }\n\n originalCommit?.(vnode, commitQueue);\n });\n}\n\n/**\n * Restores the commit option replaced by\n * {@link installElementTemplateCommitHook} so tests can clean up the global\n * Preact `options` object. Assumes the matching install was the most recent\n * commit-option replacement; the snapshot and ElementTemplate runtimes are\n * separate entrypoints and never install their commit hooks in the same\n * context.\n */\nexport function uninstallElementTemplateCommitHookForTesting(): void {\n if (!installed) {\n return;\n }\n installed = false;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"commit-hook.js","sourceRoot":"","sources":["../../../src/element-template/background/commit-hook.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,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,cAAc,IAAI,CAAC,WAAW,IAAI,cAAc,EAAE,EAAE,CAAC;YACvD,2EAA2E;YAC3E,2EAA2E;YAC3E,gBAAgB,EAAE,CAAC;QACrB,CAAC;aAAM,IACL,cAAc,IAAI,WAAW;eAC1B,CACD,mBAAmB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;mBAC/B,CAAC,aAAa,CAAC,mBAAmB,CAAC,YAAY,CAAC;mBAChD,cAAc,EAAE;mBAChB,0BAA0B,CAAC,MAAM,GAAG,CAAC,CACzC,EACD,CAAC;YACD,iCAAiC,EAAE,CAAC;QACtC,CAAC;QAED,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4CAA4C;IAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,SAAS,GAAG,KAAK,CAAC;IAClB,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC;QACjC,cAAc,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { options } from 'preact';\n\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport type { BackgroundElementTemplateInstance } from './instance.js';\nimport { clearElementTemplateRenderScope, resetElementTemplateRenderScope } from './render-scope.js';\nimport { globalPipelineOptions, markTiming, markTimingLegacy, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';\nimport { COMMIT } from '../../shared/render-constants.js';\nimport { hook, isEmptyObject } from '../../utils.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';\nimport { clearPendingRefs, flushPendingRefs, hasPendingRefs } from '../prop-adapters/ref.js';\nimport { createElementTemplateUpdateEvent } from '../protocol/update-event.js';\n\nlet installed = false;\nlet previousCommit: typeof options[typeof COMMIT];\nlet hasHydrated = false;\nconst scheduledRemovedSubtreeCleanupTimers = /*#__PURE__*/ new Set<ReturnType<typeof setTimeout>>();\n\nexport function markElementTemplateHydrated(): void {\n hasHydrated = true;\n}\n\nexport function isElementTemplateHydrated(): boolean {\n return hasHydrated;\n}\n\nexport function resetElementTemplateCommitState(): void {\n hasHydrated = false;\n resetElementTemplateRenderScope();\n resetGlobalCommitContext();\n}\n\nexport function scheduleElementTemplateRemovedSubtreeCleanup(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n): void {\n if (removedSubtreesAwaitingTeardown.length === 0) {\n return;\n }\n const timer = setTimeout(() => {\n scheduledRemovedSubtreeCleanupTimers.delete(timer);\n for (const root of removedSubtreesAwaitingTeardown) {\n root.releaseDetachedSubtreeFromManager();\n }\n }, 10000);\n scheduledRemovedSubtreeCleanupTimers.add(timer);\n}\n\nexport function cancelElementTemplateRemovedSubtreeCleanup(): void {\n for (const timer of scheduledRemovedSubtreeCleanupTimers) {\n clearTimeout(timer);\n }\n scheduledRemovedSubtreeCleanupTimers.clear();\n}\n\nfunction cleanupFailedElementTemplateCommit(\n removedSubtreesAwaitingTeardown: BackgroundElementTemplateInstance[],\n delayedRunOnMainThreadPayload: readonly { resolveId: number }[] | undefined,\n): void {\n if (delayedRunOnMainThreadPayload) {\n dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));\n }\n clearPendingRefs();\n resetGlobalCommitContext();\n setPipeline(undefined);\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nfunction flushElementTemplateCommitChanges(): void {\n const hasNativeOps = globalCommitContext.ops.length > 0;\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const hasUpdatePayload = hasNativeOps\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasDelayedRunOnMainThread;\n const removedSubtreesAwaitingTeardown = hasNativeOps ? takeRemovedSubtreesForPostDispatchTeardown() : [];\n if (hasUpdatePayload) {\n markTimingLegacy('updateDiffVdomEnd');\n markTiming('diffVdomEnd');\n\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n if (globalPipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = globalPipelineOptions;\n }\n markTiming('packChangesEnd');\n if (globalPipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n\n if (!hasNativeOps && !hasDelayedRunOnMainThread) {\n globalCommitContext.flushOptions.emptyPatch = true;\n }\n\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n\n let updateEvent: ReturnType<typeof createElementTemplateUpdateEvent>;\n try {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate BTS -> MTS update:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),\n flushOptions: globalCommitContext.flushOptions,\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,\n },\n null,\n 2,\n ),\n );\n }\n\n updateEvent = createElementTemplateUpdateEvent({\n ops: globalCommitContext.ops,\n flushOptions: globalCommitContext.flushOptions,\n reloadVersion: getReloadVersion(),\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,\n });\n } catch (error) {\n cleanupFailedElementTemplateCommit(removedSubtreesAwaitingTeardown, delayedRunOnMainThreadPayload);\n throw error;\n }\n\n lynx.getCoreContext().dispatchEvent(updateEvent);\n }\n // When native ops exist, patch first so a newly attached ref observes the\n // committed native state. Ref-only commits still flush through this path.\n flushPendingRefs();\n resetGlobalCommitContext();\n // Match Snapshot's cleanup boundary: start the delayed teardown only\n // after the bridge dispatch, so background JS objects are not torn down\n // before main-thread detach observes the same commit.\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n}\n\nexport function installElementTemplateCommitHook(): void {\n if (installed) {\n return;\n }\n installed = true;\n // eslint-disable-next-line @typescript-eslint/unbound-method\n previousCommit = options[COMMIT];\n\n hook(options, COMMIT, (originalCommit, vnode, commitQueue) => {\n if (__BACKGROUND__) {\n clearElementTemplateRenderScope();\n try {\n sendMTRefInitValueToMainThread();\n } catch (error) {\n cleanupFailedElementTemplateCommit(\n takeRemovedSubtreesForPostDispatchTeardown(),\n takeDelayedRunOnMainThreadData(),\n );\n throw error;\n }\n }\n\n if (__BACKGROUND__ && !hasHydrated && hasPendingRefs()) {\n // User effects can run before ET hydrate arrives, so ordinary refs must be\n // attached on the background commit even though native UI ops are delayed.\n flushPendingRefs();\n } else if (\n __BACKGROUND__ && hasHydrated\n && (\n globalCommitContext.ops.length > 0\n || !isEmptyObject(globalCommitContext.flushOptions)\n || hasPendingRefs()\n || delayedRunOnMainThreadData.length > 0\n )\n ) {\n flushElementTemplateCommitChanges();\n }\n\n originalCommit?.(vnode, commitQueue);\n });\n}\n\n/**\n * Restores the commit option replaced by\n * {@link installElementTemplateCommitHook} so tests can clean up the global\n * Preact `options` object. Assumes the matching install was the most recent\n * commit-option replacement; the snapshot and ElementTemplate runtimes are\n * separate entrypoints and never install their commit hooks in the same\n * context.\n */\nexport function uninstallElementTemplateCommitHookForTesting(): void {\n if (!installed) {\n return;\n }\n installed = false;\n if (previousCommit) {\n options[COMMIT] = previousCommit;\n previousCommit = undefined;\n } else {\n delete options[COMMIT];\n }\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import { delayedRunOnMainThreadData, takeDelayedRunOnMainThreadData, } from '../
|
|
|
11
11
|
import { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';
|
|
12
12
|
import { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';
|
|
13
13
|
import { profileEnd, profileStart } from '../debug/profile.js';
|
|
14
|
+
import { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';
|
|
14
15
|
import { clearPendingEvents, flushPendingEvents } from '../prop-adapters/event.js';
|
|
15
16
|
import { clearDelayedRefUiOps, clearPendingRefs, flushDelayedRefUiOps } from '../prop-adapters/ref.js';
|
|
16
17
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
@@ -70,8 +71,6 @@ export function installElementTemplateHydrationListener() {
|
|
|
70
71
|
const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread
|
|
71
72
|
? takeDelayedRunOnMainThreadData()
|
|
72
73
|
: undefined;
|
|
73
|
-
const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();
|
|
74
|
-
const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;
|
|
75
74
|
const pipelineOptions = globalPipelineOptions;
|
|
76
75
|
if (pipelineOptions) {
|
|
77
76
|
globalCommitContext.flushOptions.pipelineOptions = pipelineOptions;
|
|
@@ -85,6 +84,7 @@ export function installElementTemplateHydrationListener() {
|
|
|
85
84
|
}
|
|
86
85
|
markTiming('packChangesStart');
|
|
87
86
|
try {
|
|
87
|
+
sendMTRefInitValueToMainThread();
|
|
88
88
|
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
89
89
|
console.alog?.('[ReactLynxDebug] ElementTemplate hydrate update commands:\n'
|
|
90
90
|
+ JSON.stringify({
|
|
@@ -93,7 +93,6 @@ export function installElementTemplateHydrationListener() {
|
|
|
93
93
|
flowIds: globalCommitContext.flowIds,
|
|
94
94
|
isHydration: true,
|
|
95
95
|
delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,
|
|
96
|
-
mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,
|
|
97
96
|
}, null, 2));
|
|
98
97
|
}
|
|
99
98
|
hydrateUpdateEvent = createElementTemplateUpdateEvent({
|
|
@@ -103,9 +102,6 @@ export function installElementTemplateHydrationListener() {
|
|
|
103
102
|
reloadVersion: getReloadVersion(),
|
|
104
103
|
flowIds: globalCommitContext.flowIds,
|
|
105
104
|
delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,
|
|
106
|
-
mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch
|
|
107
|
-
? mainThreadRefInitValuePatch
|
|
108
|
-
: undefined,
|
|
109
105
|
});
|
|
110
106
|
}
|
|
111
107
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration-listener.js","sourceRoot":"","sources":["../../../src/element-template/background/hydration-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,4CAA4C,GAC7C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,0BAA0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I,CAAC,cAAc,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChG,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport {\n markElementTemplateHydrated,\n resetElementTemplateCommitState,\n scheduleElementTemplateRemovedSubtreeCleanup,\n} from './commit-hook.js';\nimport type { BackgroundPageRootInstance } from './instance.js';\nimport { hydratePageRootIntoContext } from './page-root-hydrate.js';\nimport { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';\nimport {\n PerformanceTimingFlags,\n PipelineOrigins,\n beginPipeline,\n globalPipelineOptions,\n markTiming,\n setPipeline,\n} from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';\nimport { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { clearPendingEvents, flushPendingEvents } from '../prop-adapters/event.js';\nimport { clearDelayedRefUiOps, clearPendingRefs, flushDelayedRefUiOps } from '../prop-adapters/ref.js';\nimport { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';\nimport type { ElementTemplateHydrateCommitContext } from '../protocol/types.js';\nimport { createElementTemplateUpdateEvent } from '../protocol/update-event.js';\nimport { __root } from '../runtime/page/root-instance.js';\nimport { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/template/main-thread-function.js';\n\nlet listener:\n | ((event: { data: ElementTemplateHydrateCommitContext }) => void)\n | undefined;\n\nexport function installElementTemplateHydrationListener(): void {\n resetElementTemplateHydrationListener();\n resetElementTemplateCommitState();\n\n listener = (event: { data: ElementTemplateHydrateCommitContext }) => {\n const { page, reloadVersion } = event.data;\n if (reloadVersion < getReloadVersion()) {\n return;\n }\n\n const root = __root as BackgroundPageRootInstance;\n\n if (__PROFILE__) {\n profileStart('ReactLynx::hydrate');\n }\n beginPipeline(true, PipelineOrigins.reactLynxHydrate, PerformanceTimingFlags.reactLynxHydrate);\n try {\n markTiming('hydrateParseSnapshotStart');\n markTiming('hydrateParseSnapshotEnd');\n markTiming('diffVdomStart');\n\n resetGlobalCommitContext();\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate MTS -> BTS hydrate:\\n'\n + JSON.stringify({ data: page }, null, 2),\n );\n console.alog?.(\n '[ReactLynxDebug] BackgroundElementTemplate tree before hydration:\\n'\n + printElementTemplateTreeToString(root),\n );\n }\n\n const didHydrateMatchedInstances = hydratePageRootIntoContext(page, root);\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BackgroundElementTemplate tree after hydration:\\n'\n + printElementTemplateTreeToString(root),\n );\n }\n\n if (__PROFILE__) {\n profileEnd();\n }\n markTiming('diffVdomEnd');\n\n if (didHydrateMatchedInstances) {\n markElementTemplateHydrated();\n } else {\n // Hydrate is not transactional; a later failure can happen after earlier\n // nodes were rebound. Treat the pass as failed for externally observable\n // work, so delayed refs/events are not released from an incomplete tree.\n clearPendingEvents();\n clearPendingRefs();\n clearDelayedRefUiOps();\n resetElementTemplateMainThreadFunctionRuntime();\n takeMainThreadRefInitValuePatch();\n resetGlobalCommitContext();\n }\n\n if (didHydrateMatchedInstances) {\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n const mainThreadRefInitValuePatch = takeMainThreadRefInitValuePatch();\n const hasMainThreadRefInitValuePatch = mainThreadRefInitValuePatch.length > 0;\n const pipelineOptions = globalPipelineOptions;\n if (pipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = pipelineOptions;\n }\n const removedSubtreesAwaitingTeardown = globalCommitContext.ops.length > 0\n ? takeRemovedSubtreesForPostDispatchTeardown()\n : [];\n let hydrateUpdateEvent: ReturnType<typeof createElementTemplateUpdateEvent> | undefined;\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n try {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate hydrate update commands:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),\n flushOptions: globalCommitContext.flushOptions,\n flowIds: globalCommitContext.flowIds,\n isHydration: true,\n delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,\n mainThreadRefInitValuePatchCount: mainThreadRefInitValuePatch.length,\n },\n null,\n 2,\n ),\n );\n }\n hydrateUpdateEvent = createElementTemplateUpdateEvent({\n ops: globalCommitContext.ops,\n flushOptions: globalCommitContext.flushOptions,\n isHydration: true,\n reloadVersion: getReloadVersion(),\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,\n mainThreadRefInitValuePatch: hasMainThreadRefInitValuePatch\n ? mainThreadRefInitValuePatch\n : undefined,\n });\n } catch (error) {\n if (delayedRunOnMainThreadPayload) {\n dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));\n }\n // Do not expose refs or replay delayed selector ops if the hydrate\n // patch failed to serialize; selectors may still point at stale\n // pre-hydration ids in that case.\n clearPendingEvents();\n clearPendingRefs();\n clearDelayedRefUiOps();\n lynx.reportError(error as Error);\n }\n markTiming('packChangesEnd');\n if (pipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n resetGlobalCommitContext();\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n\n if (!hydrateUpdateEvent) {\n return;\n }\n\n lynx.getCoreContext().dispatchEvent(hydrateUpdateEvent);\n flushPendingEvents();\n // Ordinary refs attach on Preact commit boundaries; hydration only releases\n // delayed selector ops after ids have been rebound to stable native handles.\n flushDelayedRefUiOps();\n }\n } finally {\n setPipeline(undefined);\n }\n };\n\n lynx.getCoreContext().addEventListener(ElementTemplateLifecycleConstant.hydrate, listener);\n}\n\nexport function resetElementTemplateHydrationListener(): void {\n if (listener) {\n lynx.getCoreContext().removeEventListener(ElementTemplateLifecycleConstant.hydrate, listener);\n }\n listener = undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hydration-listener.js","sourceRoot":"","sources":["../../../src/element-template/background/hydration-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,GAC3C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,4CAA4C,GAC7C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,mCAAmC,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAE,UA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AAE,CAAC;oBACrB,gBAAgB,EAAE,CAAC;oBACnB,oBAAoB,EAAE,CAAC;oBACvB,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,CAAC;gBACnC,CAAC;gBACD,UAAU,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,IAAI,eAAe,EAAE,CAAC;oBACpB,WAAW,CAAC,SAAS,CAAC,CAAC;gBACzB,CAAC;gBACD,IAAI,WAAW,EAAE,CAAC;oBAChB,UAAU,EAAE,CAAC;gBACf,CAAC;gBACD,wBAAwB,EAAE,CAAC;gBAC3B,4CAA4C,CAAC,+BAA+B,CAAC,CAAC;gBAE9E,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBACxB,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC,cAAc,EAAE,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBACxD,kBAAkB,EAAE,CAAC;gBACrB,4EAA4E;gBAC5E,6EAA6E;gBAC7E,oBAAoB,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,qCAAqC;IACnD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChG,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport {\n globalCommitContext,\n resetGlobalCommitContext,\n takeRemovedSubtreesForPostDispatchTeardown,\n} from './commit-context.js';\nimport {\n markElementTemplateHydrated,\n resetElementTemplateCommitState,\n scheduleElementTemplateRemovedSubtreeCleanup,\n} from './commit-hook.js';\nimport type { BackgroundPageRootInstance } from './instance.js';\nimport { hydratePageRootIntoContext } from './page-root-hydrate.js';\nimport { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';\nimport {\n PerformanceTimingFlags,\n PipelineOrigins,\n beginPipeline,\n globalPipelineOptions,\n markTiming,\n setPipeline,\n} from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport {\n delayedRunOnMainThreadData,\n takeDelayedRunOnMainThreadData,\n} from '../../core/thread-function-call/main-thread.js';\nimport { dropFunctionCallReturnIds } from '../../core/thread-function-call/return-value.js';\nimport { formatElementTemplateUpdateCommands, printElementTemplateTreeToString } from '../debug/alog.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { sendMTRefInitValueToMainThread } from '../main-thread-ref-init-value.js';\nimport { clearPendingEvents, flushPendingEvents } from '../prop-adapters/event.js';\nimport { clearDelayedRefUiOps, clearPendingRefs, flushDelayedRefUiOps } from '../prop-adapters/ref.js';\nimport { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';\nimport type { ElementTemplateHydrateCommitContext } from '../protocol/types.js';\nimport { createElementTemplateUpdateEvent } from '../protocol/update-event.js';\nimport { __root } from '../runtime/page/root-instance.js';\nimport { resetElementTemplateMainThreadFunctionRuntime } from '../runtime/template/main-thread-function.js';\n\nlet listener:\n | ((event: { data: ElementTemplateHydrateCommitContext }) => void)\n | undefined;\n\nexport function installElementTemplateHydrationListener(): void {\n resetElementTemplateHydrationListener();\n resetElementTemplateCommitState();\n\n listener = (event: { data: ElementTemplateHydrateCommitContext }) => {\n const { page, reloadVersion } = event.data;\n if (reloadVersion < getReloadVersion()) {\n return;\n }\n\n const root = __root as BackgroundPageRootInstance;\n\n if (__PROFILE__) {\n profileStart('ReactLynx::hydrate');\n }\n beginPipeline(true, PipelineOrigins.reactLynxHydrate, PerformanceTimingFlags.reactLynxHydrate);\n try {\n markTiming('hydrateParseSnapshotStart');\n markTiming('hydrateParseSnapshotEnd');\n markTiming('diffVdomStart');\n\n resetGlobalCommitContext();\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate MTS -> BTS hydrate:\\n'\n + JSON.stringify({ data: page }, null, 2),\n );\n console.alog?.(\n '[ReactLynxDebug] BackgroundElementTemplate tree before hydration:\\n'\n + printElementTemplateTreeToString(root),\n );\n }\n\n const didHydrateMatchedInstances = hydratePageRootIntoContext(page, root);\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] BackgroundElementTemplate tree after hydration:\\n'\n + printElementTemplateTreeToString(root),\n );\n }\n\n if (__PROFILE__) {\n profileEnd();\n }\n markTiming('diffVdomEnd');\n\n if (didHydrateMatchedInstances) {\n markElementTemplateHydrated();\n } else {\n // Hydrate is not transactional; a later failure can happen after earlier\n // nodes were rebound. Treat the pass as failed for externally observable\n // work, so delayed refs/events are not released from an incomplete tree.\n clearPendingEvents();\n clearPendingRefs();\n clearDelayedRefUiOps();\n resetElementTemplateMainThreadFunctionRuntime();\n takeMainThreadRefInitValuePatch();\n resetGlobalCommitContext();\n }\n\n if (didHydrateMatchedInstances) {\n const hasDelayedRunOnMainThread = delayedRunOnMainThreadData.length > 0;\n const delayedRunOnMainThreadPayload = hasDelayedRunOnMainThread\n ? takeDelayedRunOnMainThreadData()\n : undefined;\n const pipelineOptions = globalPipelineOptions;\n if (pipelineOptions) {\n globalCommitContext.flushOptions.pipelineOptions = pipelineOptions;\n }\n const removedSubtreesAwaitingTeardown = globalCommitContext.ops.length > 0\n ? takeRemovedSubtreesForPostDispatchTeardown()\n : [];\n let hydrateUpdateEvent: ReturnType<typeof createElementTemplateUpdateEvent> | undefined;\n if (__PROFILE__) {\n profileStart('ReactLynx::commitChanges');\n }\n markTiming('packChangesStart');\n try {\n sendMTRefInitValueToMainThread();\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate hydrate update commands:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(globalCommitContext.ops),\n flushOptions: globalCommitContext.flushOptions,\n flowIds: globalCommitContext.flowIds,\n isHydration: true,\n delayedRunOnMainThreadDataCount: delayedRunOnMainThreadPayload?.length,\n },\n null,\n 2,\n ),\n );\n }\n hydrateUpdateEvent = createElementTemplateUpdateEvent({\n ops: globalCommitContext.ops,\n flushOptions: globalCommitContext.flushOptions,\n isHydration: true,\n reloadVersion: getReloadVersion(),\n flowIds: globalCommitContext.flowIds,\n delayedRunOnMainThreadData: delayedRunOnMainThreadPayload,\n });\n } catch (error) {\n if (delayedRunOnMainThreadPayload) {\n dropFunctionCallReturnIds(delayedRunOnMainThreadPayload.map(data => data.resolveId));\n }\n // Do not expose refs or replay delayed selector ops if the hydrate\n // patch failed to serialize; selectors may still point at stale\n // pre-hydration ids in that case.\n clearPendingEvents();\n clearPendingRefs();\n clearDelayedRefUiOps();\n lynx.reportError(error as Error);\n }\n markTiming('packChangesEnd');\n if (pipelineOptions) {\n setPipeline(undefined);\n }\n if (__PROFILE__) {\n profileEnd();\n }\n resetGlobalCommitContext();\n scheduleElementTemplateRemovedSubtreeCleanup(removedSubtreesAwaitingTeardown);\n\n if (!hydrateUpdateEvent) {\n return;\n }\n\n lynx.getCoreContext().dispatchEvent(hydrateUpdateEvent);\n flushPendingEvents();\n // Ordinary refs attach on Preact commit boundaries; hydration only releases\n // delayed selector ops after ids have been rebound to stable native handles.\n flushDelayedRefUiOps();\n }\n } finally {\n setPipeline(undefined);\n }\n };\n\n lynx.getCoreContext().addEventListener(ElementTemplateLifecycleConstant.hydrate, listener);\n}\n\nexport function resetElementTemplateHydrationListener(): void {\n if (listener) {\n lynx.getCoreContext().removeEventListener(ElementTemplateLifecycleConstant.hydrate, listener);\n }\n listener = undefined;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { DataProcessorDefinition } from '../../lynx-
|
|
2
|
+
import type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';
|
|
3
3
|
/**
|
|
4
4
|
* The default root exported by `@lynx-js/react` for you to render a JSX
|
|
5
5
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/element-template/client/root.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/element-template/client/root.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAkC1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,MAAM,EAAE,CAAC,GAAc,EAAQ,EAAE;QAC/B,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;QACnB,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,WAAW,EAAE,CAAC;gBAChB,YAAY,CAAC,6BAA6B,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,CAAC,GAAqB,EAAE,MAAkC,CAAC,CAAC;YAClE,IAAI,WAAW,EAAE,CAAC;gBAChB,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,sBAAsB,EAAE,CAAC,uBAAiD,EAAQ,EAAE;QAClF,IAAI,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;IACvD,CAAC;CACF,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport type { ComponentChild, ContainerNode } from 'preact';\nimport { render } from 'preact';\nimport type { ReactNode } from 'react';\n\nimport type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { __root } from '../runtime/page/root-instance.js';\n\n/**\n * The default root exported by `@lynx-js/react` for you to render a JSX\n * @public\n */\nexport interface Root {\n /**\n * Use this API to pass in your JSX to render\n *\n * @example\n *\n * ```ts\n * import { root } from \"@lynx-js/react\"\n *\n * function App() {\n * // Your app\n * return <view>...</view>\n * }\n *\n * root.render(<App/>);\n * ```\n *\n * @public\n */\n render: (jsx: ReactNode) => void;\n /**\n * {@inheritDoc Lynx.registerDataProcessors}\n * @deprecated use {@link Lynx.registerDataProcessors | lynx.registerDataProcessors} instead\n * @public\n */\n registerDataProcessors: (dataProcessorDefinition?: DataProcessorDefinition) => void;\n}\n\n/**\n * The default and only root of ReactLynx for you to render JSX\n * @example\n * ```ts\n * import { root } from \"@lynx-js/react\"\n * ```\n *\n * @public\n */\nexport const root: Root = {\n render: (jsx: ReactNode): void => {\n __root.__jsx = jsx;\n if (__BACKGROUND__) {\n if (__PROFILE__) {\n profileStart('ReactLynx::renderBackground');\n }\n render(jsx as ComponentChild, __root as unknown as ContainerNode);\n if (__PROFILE__) {\n profileEnd();\n }\n }\n },\n registerDataProcessors: (dataProcessorDefinition?: DataProcessorDefinition): void => {\n lynx.registerDataProcessors(dataProcessorDefinition);\n },\n};\n"]}
|
|
@@ -4,7 +4,7 @@ import type { Consumer, FC, ReactNode } from 'react';
|
|
|
4
4
|
import type { GlobalProps } from '../core/globalProps.js';
|
|
5
5
|
import { useLynxGlobalEventListener } from '../core/hooks/useLynxGlobalEventListener.js';
|
|
6
6
|
import { withInitDataInState } from '../core/initData.js';
|
|
7
|
-
import type { InitData } from '../lynx-
|
|
7
|
+
import type { InitData } from '../core/lynx-data-processors.js';
|
|
8
8
|
import './native/index.js';
|
|
9
9
|
export { Component, createContext } from 'preact';
|
|
10
10
|
export { PureComponent } from 'preact/compat';
|
|
@@ -31,4 +31,4 @@ export { MainThreadRef, useMainThreadRef } from '../core/main-thread-ref.js';
|
|
|
31
31
|
export { defineMainThreadObjectType, useMainThreadObject } from '../core/main-thread-object.js';
|
|
32
32
|
export type { GlobalProps } from '../core/globalProps.js';
|
|
33
33
|
export type { MainThreadObjectHandle, MainThreadObjectType, MainThreadObjectTypeDefinition, } from '../core/main-thread-object.js';
|
|
34
|
-
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from '../lynx-
|
|
34
|
+
export type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from '../core/lynx-data-processors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element-template/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,mBAAmB,CAAC;AAE3B,sBAAsB,EAAE,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;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AAC,MAAM,mBAAmB,GAA0B,eAAe,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;AAClG,MAAM,CAAC,MAAM,cAAc,GAAsB,eAAe,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAoD,eAAe,CAAC,YAAY;KAC/G,UAAU,EAAE,CAAC;AAEhB,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport './runtime-marker.js';\nimport {\n Children,\n Component,\n Fragment,\n PureComponent,\n Suspense,\n cloneElement,\n createContext,\n createElement,\n createRef,\n forwardRef,\n isValidElement,\n lazy,\n memo,\n useSyncExternalStore,\n} from 'preact/compat';\nimport type { Consumer, FC, ReactNode } from 'react';\n\nimport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from '@lynx-js/react/hooks';\n\nimport { installComponentCompat } from '../core/component.js';\nimport { createGlobalProps } from '../core/globalProps.js';\nimport type { GlobalProps } from '../core/globalProps.js';\nimport { useLynxGlobalEventListener } from '../core/hooks/useLynxGlobalEventListener.js';\nimport { factory, withInitDataInState } from '../core/initData.js';\nimport type { InitData } from '../lynx-
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/element-template/index.ts"],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AE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport './runtime-marker.js';\nimport {\n Children,\n Component,\n Fragment,\n PureComponent,\n Suspense,\n cloneElement,\n createContext,\n createElement,\n createRef,\n forwardRef,\n isValidElement,\n lazy,\n memo,\n useSyncExternalStore,\n} from 'preact/compat';\nimport type { Consumer, FC, ReactNode } from 'react';\n\nimport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from '@lynx-js/react/hooks';\n\nimport { installComponentCompat } from '../core/component.js';\nimport { createGlobalProps } from '../core/globalProps.js';\nimport type { GlobalProps } from '../core/globalProps.js';\nimport { useLynxGlobalEventListener } from '../core/hooks/useLynxGlobalEventListener.js';\nimport { factory, withInitDataInState } from '../core/initData.js';\nimport type { InitData } from '../core/lynx-data-processors.js';\nimport './native/index.js';\n\ninstallComponentCompat();\n\nexport { Component, createContext } from 'preact';\nexport { PureComponent } from 'preact/compat';\nexport * from '@lynx-js/react/hooks';\n\n/**\n * @internal\n */\nexport default {\n // hooks\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useRef,\n useImperativeHandle,\n useMemo,\n useCallback,\n useContext,\n useDebugValue,\n useSyncExternalStore,\n\n createContext,\n createRef,\n Fragment,\n isValidElement,\n Children,\n Component,\n PureComponent,\n memo,\n forwardRef,\n Suspense,\n lazy,\n createElement,\n};\n\nexport {\n Children,\n createRef,\n Fragment,\n isValidElement,\n memo,\n forwardRef,\n Suspense,\n lazy,\n createElement,\n cloneElement,\n useSyncExternalStore,\n};\n\nconst _InitData = /* @__PURE__ */ factory<InitData>(\n {\n createContext,\n useState,\n createElement,\n useLynxGlobalEventListener,\n },\n '__initData',\n 'onDataChanged',\n);\n\n// @ts-expect-error make preact and react types work\nexport const InitDataProvider: FC<{ children?: ReactNode | undefined }> = /* @__PURE__ */ _InitData.Provider();\n// @ts-expect-error make preact and react types work\nexport const InitDataConsumer: Consumer<InitData> = /* @__PURE__ */ _InitData.Consumer();\nexport const useInitData: () => InitData = /* @__PURE__ */ _InitData.use();\nexport const useInitDataChanged: (callback: (data: InitData) => void) => void = /* @__PURE__ */ _InitData.useChanged();\n\nconst _GlobalProps = /* @__PURE__ */ createGlobalProps<GlobalProps>({\n createContext,\n useState,\n createElement,\n useLynxGlobalEventListener,\n});\n\n// @ts-expect-error make preact and react types work\nexport const GlobalPropsProvider: FC<{ children?: ReactNode | undefined }> = /* @__PURE__ */ _GlobalProps.Provider();\n// @ts-expect-error make preact and react types work\nexport const GlobalPropsConsumer: Consumer<GlobalProps> = /* @__PURE__ */ _GlobalProps.Consumer();\nexport const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.use();\nexport const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps\n .useChanged();\n\nexport { withInitDataInState };\nexport { useLynxGlobalEventListener };\n\nexport * from './client/root.js';\nexport { runOnBackground } from './runtime/template/main-thread-background-function.js';\nexport { runOnMainThread } from './runtime/template/main-thread-function.js';\nexport { MainThreadRef, useMainThreadRef } from '../core/main-thread-ref.js';\nexport { defineMainThreadObjectType, useMainThreadObject } from '../core/main-thread-object.js';\n\nexport type { GlobalProps } from '../core/globalProps.js';\nexport type {\n MainThreadObjectHandle,\n MainThreadObjectType,\n MainThreadObjectTypeDefinition,\n} from '../core/main-thread-object.js';\nexport type { DataProcessorDefinition, DataProcessors, InitData, InitDataRaw } from '../core/lynx-data-processors.js';\n"]}
|
|
@@ -9,9 +9,9 @@ export { registerRuntimeVersion, getRuntimeVersion } from '../core/lynx/runtime-
|
|
|
9
9
|
export { RUNTIME_BACKEND_ELEMENT_TEMPLATE, RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend, } from '../core/lynx/runtime-backend.js';
|
|
10
10
|
export { withInitDataInState } from '../core/initData.js';
|
|
11
11
|
export { wrapWithLynxComponent } from '../core/compat/lynxComponent.js';
|
|
12
|
+
export { loadLazyBundle } from '../core/lynx/lazy-bundle.js';
|
|
12
13
|
export { transformToWorklet } from './runtime/template/main-thread-background-function.js';
|
|
13
14
|
export { captureMainThreadObject } from '../core/capture-main-thread-object.js';
|
|
14
|
-
export declare function registerWorkletOnBackground(_type: string, _hash: string, _fn: (...args: unknown[]) => unknown): void;
|
|
15
15
|
export { __etAttrPlanMap, adaptEventAttrSlot, adaptMTEventAttrSlot, adaptMTRefAttrSlot, adaptRefAttrSlot, adaptSpreadAttrSlot, } from './runtime/template/attr-slot-plan.js';
|
|
16
16
|
export { __ElementTemplatePage } from './runtime/page/authored-page.js';
|
|
17
17
|
export { __etHost } from './runtime/render/host.js';
|
|
@@ -1,12 +1,8 @@
|
|
|
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 { Suspense, createElement, lazy } from 'preact/compat';
|
|
5
|
-
// import type { FC } from 'react';
|
|
6
4
|
import './runtime-marker.js';
|
|
7
5
|
import './native/index.js';
|
|
8
|
-
// import { factory as factory2 } from '../compat/componentIs.js';
|
|
9
|
-
// import { useMemo } from '../core/hooks/react.js';
|
|
10
6
|
import { __root } from './runtime/page/root-instance.js';
|
|
11
7
|
/**
|
|
12
8
|
* @internal kept only to fail fast when stale internal imports leak into the
|
|
@@ -30,18 +26,9 @@ export { registerRuntimeVersion, getRuntimeVersion } from '../core/lynx/runtime-
|
|
|
30
26
|
export { RUNTIME_BACKEND_ELEMENT_TEMPLATE, RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend, } from '../core/lynx/runtime-backend.js';
|
|
31
27
|
export { withInitDataInState } from '../core/initData.js';
|
|
32
28
|
export { wrapWithLynxComponent } from '../core/compat/lynxComponent.js';
|
|
33
|
-
/**
|
|
34
|
-
* @internal a polyfill for <component is=? />
|
|
35
|
-
*/
|
|
36
|
-
// export const __ComponentIsPolyfill: FC<{ is: string }> = /* @__PURE__ */ factory2(
|
|
37
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
38
|
-
// { Suspense, lazy, createElement, useMemo } as any,
|
|
39
|
-
// loadLazyBundle,
|
|
40
|
-
// );
|
|
41
29
|
export { loadLazyBundle } from '../core/lynx/lazy-bundle.js';
|
|
42
30
|
export { transformToWorklet } from './runtime/template/main-thread-background-function.js';
|
|
43
31
|
export { captureMainThreadObject } from '../core/capture-main-thread-object.js';
|
|
44
|
-
export function registerWorkletOnBackground(_type, _hash, _fn) { }
|
|
45
32
|
export { __etAttrPlanMap, adaptEventAttrSlot, adaptMTEventAttrSlot, adaptMTRefAttrSlot, adaptRefAttrSlot, adaptSpreadAttrSlot, } from './runtime/template/attr-slot-plan.js';
|
|
46
33
|
export { __ElementTemplatePage } from './runtime/page/authored-page.js';
|
|
47
34
|
export { __etHost } from './runtime/render/host.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/element-template/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/element-template/internal.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEzD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACR;IAAnB,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAC7B,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC9F,CAAC;CACF;AAED,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,OAAO,EACL,OAAO;AACP,+EAA+E;AAC/E,SAAS,EACT,OAAO,GACR,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEhF,oEAAoE;AACpE,uCAAuC;AACvC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAE3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport './runtime-marker.js';\nimport './native/index.js';\n\nimport { __root } from './runtime/page/root-instance.js';\n\n/**\n * @internal kept only to fail fast when stale internal imports leak into the\n * Element Template alias surface. This is not a supported ET runtime API.\n */\nexport class SnapshotInstance {\n constructor(public type: string) {\n throw new Error('SnapshotInstance should not be instantiated when using Element Template.');\n }\n}\n\nexport { __root };\n\nexport {\n options,\n // Component is not an internal API, but refresh needs it from 'react/internal'\n Component,\n process,\n} from 'preact';\nexport type { Options } from 'preact';\n\nexport { loadDynamicJS, __dynamicImport } from '../core/lynx/dynamic-import.js';\n\n// Re-exported so lazy bundle shells can reach the host runtime APIs\n// via `target[sExportsReactInternal]`.\nexport { registerRuntimeVersion, getRuntimeVersion } from '../core/lynx/runtime-version.js';\nexport {\n RUNTIME_BACKEND_ELEMENT_TEMPLATE,\n RUNTIME_BACKEND_SNAPSHOT,\n registerRuntimeBackend,\n} from '../core/lynx/runtime-backend.js';\n\nexport { withInitDataInState } from '../core/initData.js';\n\nexport { wrapWithLynxComponent } from '../core/compat/lynxComponent.js';\n\nexport { loadLazyBundle } from '../core/lynx/lazy-bundle.js';\n\nexport { transformToWorklet } from './runtime/template/main-thread-background-function.js';\n\nexport { captureMainThreadObject } from '../core/capture-main-thread-object.js';\n\nexport {\n __etAttrPlanMap,\n adaptEventAttrSlot,\n adaptMTEventAttrSlot,\n adaptMTRefAttrSlot,\n adaptRefAttrSlot,\n adaptSpreadAttrSlot,\n} from './runtime/template/attr-slot-plan.js';\nexport { __ElementTemplatePage } from './runtime/page/authored-page.js';\n\nexport { __etHost } from './runtime/render/host.js';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/element-template/lynx/env.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,QAAQ,GAA4B,EAAE,CAAC;QAC3C,IAAI,UAAU,GAA4B,EAAE,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,C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ache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { createProcessData } from '../../core/lynx-data-processors.js';\nimport type { DataProcessorDefinition } from '../../lynx-
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/element-template/lynx/env.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAI,QAAQ,GAA4B,EAAE,CAAC;QAC3C,IAAI,UAAU,GAA4B,EAAE,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;YACrC,IAAI,MAAM,EAAE,CAAC;gBACX,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACjC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,UAAU,EAAE,CAAC;QACjD,IAAI,CAAC,sBAAsB,GAAG,cAAY,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG;QAChB,kCAAkC;SACnC,CAAC;QACD,UAA2D,CAAC,UAAU;YACpE,IAA+C,CAAC,UAAU,IAAI,EAAE,CAAC;QAEpE,IAAI,CAAC,2BAA2B,GAAG,UACjC,SAAiB,EACjB,MAAW;YAEX,kBAAkB,CAAC,CAAC,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC;QAEF,CAAC;YACC,+DAA+D;YAC/D,SAAS,MAAM,CAAC,KAAa;gBAC3B,OAAO,SAAS,KAAK,SAAS,CAAC;YACjC,CAAC;YACD,8GAA8G;YAC9G,wBAAwB;YACxB,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;gBAClD,wBAAwB;gBACxB,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;YACrC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,sBAAsB,GAAG,UAC5B,uBAAiD;YAEjD,UAAU,CAAC,WAAW,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;QACtE,CAAC,CAAC;QAEF,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { createProcessData } from '../../core/lynx-data-processors.js';\nimport type { DataProcessorDefinition } from '../../core/lynx-data-processors.js';\n\nexport function setupLynxEnv(): void {\n if (!__LEPUS__) {\n let initData: Record<string, unknown> = {};\n let updateData: Record<string, unknown> = {};\n\n try {\n const params = lynx.getApp()._params;\n if (params) {\n initData = params.initData ?? {};\n updateData = params.updateData ?? {};\n }\n } catch {}\n\n lynx.__initData = { ...initData, ...updateData };\n lynx.registerDataProcessors = function() {};\n }\n\n if (__LEPUS__) {\n lynx.__initData = {\n /* available only in renderPage */\n };\n (globalThis as typeof globalThis & { SystemInfo?: unknown }).SystemInfo =\n (lynx as typeof lynx & { SystemInfo?: unknown }).SystemInfo ?? {};\n\n lynx.triggerGlobalEventFromLepus = function(\n eventName: string,\n params: any,\n ) {\n __OnLifecycleEvent(['globalEventFromLepus', [eventName, params]]);\n };\n\n {\n // eslint-disable-next-line unicorn/consistent-function-scoping\n function __name(empty: string) {\n return `Native${empty}Modules`;\n }\n // TODO(hongzhiyuan.hzy): make sure this is run before any other code (especially code access `NativeModules`)\n // @ts-expect-error hack\n if (typeof globalThis[__name('')] === 'undefined') {\n // @ts-expect-error hack\n globalThis[__name('')] = undefined;\n }\n }\n\n lynx.registerDataProcessors = function(\n dataProcessorDefinition?: DataProcessorDefinition,\n ) {\n globalThis.processData = createProcessData(dataProcessorDefinition);\n };\n\n lynx.registerDataProcessors();\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
import { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';
|
|
5
|
+
import { takeMainThreadRefInitValuePatch } from '../core/main-thread-ref-init-value.js';
|
|
6
|
+
import { ElementTemplateLifecycleConstant } from './protocol/lifecycle-constant.js';
|
|
7
|
+
let listener;
|
|
8
|
+
export function installElementTemplateRefInitValueListener() {
|
|
9
|
+
resetElementTemplateRefInitValueListener();
|
|
10
|
+
listener = (event) => {
|
|
11
|
+
const data = event.data;
|
|
12
|
+
const patch = JSON.parse(data);
|
|
13
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
14
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate MTS updateMTRefInitValue:\n' + data);
|
|
15
|
+
}
|
|
16
|
+
// Ref initialization outlives UI patches and must not be filtered by reloadVersion.
|
|
17
|
+
updateWorkletRefInitValueChanges(patch);
|
|
18
|
+
};
|
|
19
|
+
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
20
|
+
}
|
|
21
|
+
export function resetElementTemplateRefInitValueListener() {
|
|
22
|
+
if (listener) {
|
|
23
|
+
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);
|
|
24
|
+
}
|
|
25
|
+
listener = undefined;
|
|
26
|
+
}
|
|
27
|
+
export function sendMTRefInitValueToMainThread() {
|
|
28
|
+
const patch = takeMainThreadRefInitValuePatch();
|
|
29
|
+
if (patch.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const data = JSON.stringify(patch);
|
|
33
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
34
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS sendMTRefInitValue:\n' + data);
|
|
35
|
+
}
|
|
36
|
+
lynx.getCoreContext().dispatchEvent({ type: ElementTemplateLifecycleConstant.updateMTRefInitValue, data });
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=main-thread-ref-init-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-thread-ref-init-value.js","sourceRoot":"","sources":["../../src/element-template/main-thread-ref-init-value.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAG3F,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEpF,IAAI,QAA2D,CAAC;AAEhE,MAAM,UAAU,0CAA0C;IACxD,wCAAwC,EAAE,CAAC;IAC3C,QAAQ,GAAG,CAAC,KAAK,EAAE,EAAE;QACnB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAc,CAAC;QAClC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAgC,CAAC;QAC9D,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,CAAC;YAChD,OAAO,CAAC,IAAI,EAAE,CAAC,8DAA8D,GAAG,IAAI,CAAC,CAAC;QACxF,CAAC;QACD,oFAAoF;QACpF,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;IACF,IAAI,CAAC,YAAY,EAAE,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;AACxG,CAAC;AAED,MAAM,UAAU,wCAAwC;IACtD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAC3G,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,MAAM,KAAK,GAAG,+BAA+B,EAAE,CAAC;IAChD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,EAAE,CAAC,mEAAmE,GAAG,IAAI,CAAC,CAAC;IAC7F,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,gCAAgC,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7G,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';\nimport type { MainThreadRefInitValuePatch } from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { takeMainThreadRefInitValuePatch } from '../core/main-thread-ref-init-value.js';\nimport { ElementTemplateLifecycleConstant } from './protocol/lifecycle-constant.js';\n\nlet listener: ((event: RuntimeProxy.Event) => void) | undefined;\n\nexport function installElementTemplateRefInitValueListener(): void {\n resetElementTemplateRefInitValueListener();\n listener = (event) => {\n const data = event.data as string;\n const patch = JSON.parse(data) as MainThreadRefInitValuePatch;\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.('[ReactLynxDebug] ElementTemplate MTS updateMTRefInitValue:\\n' + data);\n }\n // Ref initialization outlives UI patches and must not be filtered by reloadVersion.\n updateWorkletRefInitValueChanges(patch);\n };\n lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);\n}\n\nexport function resetElementTemplateRefInitValueListener(): void {\n if (listener) {\n lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.updateMTRefInitValue, listener);\n }\n listener = undefined;\n}\n\nexport function sendMTRefInitValueToMainThread(): void {\n const patch = takeMainThreadRefInitValuePatch();\n if (patch.length === 0) {\n return;\n }\n const data = JSON.stringify(patch);\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.('[ReactLynxDebug] ElementTemplate BTS -> MTS sendMTRefInitValue:\\n' + data);\n }\n lynx.getCoreContext().dispatchEvent({ type: ElementTemplateLifecycleConstant.updateMTRefInitValue, data });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flushElementTemplate(options?: FlushOptions): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
5
|
+
export function flushElementTemplate(options = {}) {
|
|
6
|
+
applyPendingMainThreadRefAttachments();
|
|
7
|
+
__FlushElementTree(undefined, options);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush.js","sourceRoot":"","sources":["../../../src/element-template/native/flush.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oCAAoC,EAAE,MAAM,uDAAuD,CAAC;AAE7G,MAAM,UAAU,oBAAoB,CAAC,UAAwB,EAAE;IAC7D,oCAAoC,EAAE,CAAC;IACvC,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';\n\nexport function flushElementTemplate(options: FlushOptions = {}): void {\n applyPendingMainThreadRefAttachments();\n __FlushElementTree(undefined, options);\n}\n"]}
|
|
@@ -23,6 +23,7 @@ import { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';
|
|
|
23
23
|
import { initProfileHook } from '../debug/profile.js';
|
|
24
24
|
import { setupLynxEnv } from '../lynx/env.js';
|
|
25
25
|
import { initTimingAPI } from '../lynx/performance.js';
|
|
26
|
+
import { installElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
26
27
|
import { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';
|
|
27
28
|
import { __root, setRoot } from '../runtime/page/root-instance.js';
|
|
28
29
|
function forceRootRender() {
|
|
@@ -50,6 +51,7 @@ function init() {
|
|
|
50
51
|
if (__MAIN_THREAD__) {
|
|
51
52
|
installMainThreadHooks();
|
|
52
53
|
injectCalledByNative();
|
|
54
|
+
installElementTemplateRefInitValueListener();
|
|
53
55
|
installElementTemplatePatchListener();
|
|
54
56
|
installOnMtsDestruction();
|
|
55
57
|
if (__PROFILE__) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM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AAG,YAAY,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAC1D,IAAI,CAAC,MAAM,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QACpD,IAAI,CAAC,MAAM,EAAE,CAAC,cAAc,GAAG,cAAc,CAAC;QAC9C,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,GAAG,gBAAgB,CAAC;QAC7C,sCAAsC,EAAE,CAAC;QACzC,gCAAgC,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;YACvC,aAAa,EAAE,CAAC;YAChB,IAAI,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;gBAC7C,eAAe,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,YAAY,EAAE,CAAC;AACjB,CAAC;AAED,IAAI,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport '@lynx-js/react/hooks';\nimport type { ComponentChild, ContainerNode, VNode } from 'preact';\nimport { options, render } from 'preact';\n\nimport { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';\nimport { injectCalledByNative } from './main-thread-api.js';\nimport { installOnMtsDestruction } from './mts-destroy.js';\nimport { installElementTemplatePatchListener } from './patch-listener.js';\nimport { reloadBackground } from './reload-background.js';\nimport { runWithForceRootRender } from '../../core/forceRootRender.js';\nimport { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';\nimport { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';\nimport { updateCardData } from '../../core/lynx-update-data.js';\nimport { setupComponentStack } from '../../shared/component-stack.js';\nimport { lynxQueueMicrotask } from '../../utils.js';\nimport { installElementTemplateCommitHook } from '../background/commit-hook.js';\nimport { setupBackgroundElementTemplateDocument } from '../background/document.js';\nimport { installElementTemplateHydrationListener } from '../background/hydration-listener.js';\nimport { BackgroundPageRootInstance } from '../background/instance.js';\nimport { installElementTemplateRenderScopeHooks } from '../background/render-scope.js';\nimport { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';\nimport { initProfileHook } from '../debug/profile.js';\nimport { setupLynxEnv } from '../lynx/env.js';\nimport { initTimingAPI } from '../lynx/performance.js';\nimport { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\n\nfunction forceRootRender(): void {\n runWithForceRootRender({\n getRootVNode: () => __root.__jsx,\n setRootVNode: (vnode: VNode) => {\n // @ts-expect-error: __root.__jsx is a Preact VNode during background force render.\n __root.__jsx = vnode;\n },\n render: () => {\n render(__root.__jsx as ComponentChild, __root as unknown as ContainerNode);\n },\n });\n}\n\nconst updateGlobalPropsOptions = {\n forceRerender: forceRootRender,\n};\n\nfunction updateGlobalProps(newData: Record<string, any>): void {\n updateGlobalPropsCore(newData, updateGlobalPropsOptions);\n}\n\nfunction init(): void {\n if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {\n initElementTemplatePAPICallAlog();\n }\n\n if (__MAIN_THREAD__) {\n installMainThreadHooks();\n injectCalledByNative();\n installElementTemplatePatchListener();\n installOnMtsDestruction();\n if (__PROFILE__) {\n initProfileHook();\n }\n }\n\n if (__BACKGROUND__) {\n if (__DEV__) {\n setupComponentStack();\n }\n options.requestAnimationFrame = lynxQueueMicrotask;\n console.log('experimental_useElementTemplate:', __USE_ELEMENT_TEMPLATE__);\n setRoot(new BackgroundPageRootInstance());\n setupBackgroundElementTemplateDocument();\n installElementTemplateHydrationListener();\n resetEventStateForRuntime();\n lynx.getApp().callDestroyLifetimeFun = callDestroyLifetimeFun;\n lynx.getApp().publishEvent = publishEvent;\n lynx.getApp().publicComponentEvent = publicComponentEvent;\n lynx.getApp().updateGlobalProps = updateGlobalProps;\n lynx.getApp().updateCardData = updateCardData;\n lynx.getApp().onAppReload = reloadBackground;\n installElementTemplateRenderScopeHooks();\n installElementTemplateCommitHook();\n if (process.env['NODE_ENV'] !== 'test') {\n initTimingAPI();\n if (lynx.performance?.isProfileRecording?.()) {\n initProfileHook();\n }\n }\n }\n\n setupLynxEnv();\n}\n\ninit();\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/element-template/native/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MA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be found in the\n// LICENSE file in the root directory of this source tree.\nimport '@lynx-js/react/hooks';\nimport type { ComponentChild, ContainerNode, VNode } from 'preact';\nimport { options, render } from 'preact';\n\nimport { callDestroyLifetimeFun } from './callDestroyLifetimeFun.js';\nimport { injectCalledByNative } from './main-thread-api.js';\nimport { installOnMtsDestruction } from './mts-destroy.js';\nimport { installElementTemplatePatchListener } from './patch-listener.js';\nimport { reloadBackground } from './reload-background.js';\nimport { runWithForceRootRender } from '../../core/forceRootRender.js';\nimport { updateGlobalProps as updateGlobalPropsCore } from '../../core/globalProps.js';\nimport { installMainThreadHooks } from '../../core/hooks/mainThreadImpl.js';\nimport { updateCardData } from '../../core/lynx-update-data.js';\nimport { setupComponentStack } from '../../shared/component-stack.js';\nimport { lynxQueueMicrotask } from '../../utils.js';\nimport { installElementTemplateCommitHook } from '../background/commit-hook.js';\nimport { setupBackgroundElementTemplateDocument } from '../background/document.js';\nimport { installElementTemplateHydrationListener } from '../background/hydration-listener.js';\nimport { BackgroundPageRootInstance } from '../background/instance.js';\nimport { installElementTemplateRenderScopeHooks } from '../background/render-scope.js';\nimport { initElementTemplatePAPICallAlog } from '../debug/elementPAPICall.js';\nimport { initProfileHook } from '../debug/profile.js';\nimport { setupLynxEnv } from '../lynx/env.js';\nimport { initTimingAPI } from '../lynx/performance.js';\nimport { installElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';\nimport { publicComponentEvent, publishEvent, resetEventStateForRuntime } from '../prop-adapters/event.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\n\nfunction forceRootRender(): void {\n runWithForceRootRender({\n getRootVNode: () => __root.__jsx,\n setRootVNode: (vnode: VNode) => {\n // @ts-expect-error: __root.__jsx is a Preact VNode during background force render.\n __root.__jsx = vnode;\n },\n render: () => {\n render(__root.__jsx as ComponentChild, __root as unknown as ContainerNode);\n },\n });\n}\n\nconst updateGlobalPropsOptions = {\n forceRerender: forceRootRender,\n};\n\nfunction updateGlobalProps(newData: Record<string, any>): void {\n updateGlobalPropsCore(newData, updateGlobalPropsOptions);\n}\n\nfunction init(): void {\n if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {\n initElementTemplatePAPICallAlog();\n }\n\n if (__MAIN_THREAD__) {\n installMainThreadHooks();\n injectCalledByNative();\n installElementTemplateRefInitValueListener();\n installElementTemplatePatchListener();\n installOnMtsDestruction();\n if (__PROFILE__) {\n initProfileHook();\n }\n }\n\n if (__BACKGROUND__) {\n if (__DEV__) {\n setupComponentStack();\n }\n options.requestAnimationFrame = lynxQueueMicrotask;\n console.log('experimental_useElementTemplate:', __USE_ELEMENT_TEMPLATE__);\n setRoot(new BackgroundPageRootInstance());\n setupBackgroundElementTemplateDocument();\n installElementTemplateHydrationListener();\n resetEventStateForRuntime();\n lynx.getApp().callDestroyLifetimeFun = callDestroyLifetimeFun;\n lynx.getApp().publishEvent = publishEvent;\n lynx.getApp().publicComponentEvent = publicComponentEvent;\n lynx.getApp().updateGlobalProps = updateGlobalProps;\n lynx.getApp().updateCardData = updateCardData;\n lynx.getApp().onAppReload = reloadBackground;\n installElementTemplateRenderScopeHooks();\n installElementTemplateCommitHook();\n if (process.env['NODE_ENV'] !== 'test') {\n initTimingAPI();\n if (lynx.performance?.isProfileRecording?.()) {\n initProfileHook();\n }\n }\n }\n\n setupLynxEnv();\n}\n\ninit();\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { flushElementTemplate } from './flush.js';
|
|
4
5
|
import { reloadMainThread } from './reload-main-thread.js';
|
|
5
6
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
6
7
|
import { createElementTemplatePage, setupPage } from '../runtime/page/page.js';
|
|
@@ -31,15 +32,10 @@ function updatePage(data, options) {
|
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
34
|
applyUpdatePageData(data, options);
|
|
34
|
-
|
|
35
|
+
flushElementTemplate(options);
|
|
35
36
|
}
|
|
36
37
|
function updateGlobalProps(_data, options) {
|
|
37
|
-
|
|
38
|
-
__FlushElementTree(undefined, options);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
__FlushElementTree();
|
|
42
|
-
}
|
|
38
|
+
flushElementTemplate(options);
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
41
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,
|
|
1
|
+
{"version":3,"file":"main-thread-api.js","sourceRoot":"","sources":["../../../src/element-template/native/main-thread-api.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAqB;QACvC,UAAU;QACV,UAAU;QACV,iBAAiB;QACjB,WAAW,EAAE;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,cAAkB,CAAC;KACtC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC;IAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,IAAyC,EAAE,OAA0B;IACvF,IAAI,4BAA4B,KAAK,aAAa,EAAE,CAAC;QACnD,OAAO;IACT,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO;IACT,CAAC;IAED,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc,EAAE,OAA0B;IACnE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { flushElementTemplate } from './flush.js';\nimport { reloadMainThread } from './reload-main-thread.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { createElementTemplatePage, setupPage } from '../runtime/page/page.js';\nimport { renderMainThread } from '../runtime/render/render-main-thread.js';\n\nfunction injectCalledByNative(): void {\n const calledByNative: LynxCallByNative = {\n renderPage,\n updatePage,\n updateGlobalProps,\n getPageData: function() {\n return null;\n },\n removeComponents: function(): void {},\n };\n\n Object.assign(globalThis, calledByNative);\n}\n\nfunction renderPage(data: Record<string, unknown> | undefined): void {\n lynx.__initData = data ?? {};\n setupPage(createElementTemplatePage());\n renderMainThread();\n}\n\nfunction updatePage(data: Record<string, unknown> | undefined, options?: UpdatePageOption): void {\n if (__FIRST_SCREEN_SYNC_TIMING__ !== 'immediately') {\n return;\n }\n\n if (options?.reloadTemplate) {\n reloadMainThread(data, options);\n return;\n }\n\n applyUpdatePageData(data, options);\n flushElementTemplate(options);\n}\n\nfunction updateGlobalProps(_data: unknown, options?: UpdatePageOption): void {\n flushElementTemplate(options);\n}\n\n/**\n * @internal\n */\nexport { injectCalledByNative };\n"]}
|
|
@@ -2,7 +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
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
|
+
import { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
5
6
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
7
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
6
8
|
import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
7
9
|
import { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
8
10
|
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
@@ -30,12 +32,18 @@ export function destroyElementTemplateMainThreadRuntime() {
|
|
|
30
32
|
patchListenerResetError = error;
|
|
31
33
|
didPatchListenerResetThrow = true;
|
|
32
34
|
}
|
|
35
|
+
resetElementTemplateRefInitValueListener();
|
|
33
36
|
// The registry is the main-thread strong-reference owner for ET refs. Clear it
|
|
34
37
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
35
38
|
destroyAllElementTemplateListStates();
|
|
36
39
|
elementTemplateRegistry.clear();
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
try {
|
|
41
|
+
clearMainThreadDynamicAttrState();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
45
|
+
resetTemplateId();
|
|
46
|
+
}
|
|
39
47
|
if (didPatchListenerResetThrow) {
|
|
40
48
|
throw patchListenerResetError;
|
|
41
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mts-destroy.js","sourceRoot":"","sources":["../../../src/element-template/native/mts-destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,uDAAuD,EAAE,MAAM,wDAAwD,CAAC;AACjI,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAC;AACxG,OAAO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ChC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { resetElementTemplatePatchListener } from './patch-listener.js';\nimport { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';\nimport { destroyAllElementTemplateListStates } from '../runtime/list/list.js';\nimport { resetTemplateId } from '../runtime/template/handle.js';\nimport { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\nimport { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';\nimport { elementTemplateRegistry } from '../runtime/template/registry.js';\n\nexport function installOnMtsDestruction(): void {\n lynx.getNative?.().addEventListener('__DestroyLifetime', onMtsDestruction);\n}\n\nexport function onMtsDestruction(): void {\n const performance = lynx.performance;\n performance?.profileStart?.('ReactLynx::onMtsDestruction');\n try {\n destroyElementTemplateMainThreadRuntime();\n } finally {\n performance?.profileEnd?.();\n lynx.getNative?.().removeEventListener('__DestroyLifetime', onMtsDestruction);\n }\n}\n\nexport function destroyElementTemplateMainThreadRuntime(): void {\n let patchListenerResetError: unknown;\n let didPatchListenerResetThrow = false;\n try {\n resetElementTemplatePatchListener();\n } catch (error) {\n patchListenerResetError = error;\n didPatchListenerResetThrow = true;\n }\n\n resetElementTemplateRefInitValueListener();\n\n // The registry is the main-thread strong-reference owner for ET refs. Clear it\n // even if listener reset fails so destroy does not leave removed pages retained.\n destroyAllElementTemplateListStates();\n elementTemplateRegistry.clear();\n try {\n clearMainThreadDynamicAttrState();\n } finally {\n resetElementTemplateMainThreadBackgroundFunctionRuntime();\n resetTemplateId();\n }\n\n if (didPatchListenerResetThrow) {\n throw patchListenerResetError;\n }\n}\n"]}
|