@lynx-js/react 0.129.0 → 0.129.2
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 +24 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/globalProps.test.ts +27 -6
- package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
- package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
- package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -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/callDestroyLifetimeFun.test.ts +89 -3
- package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
- package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
- package/runtime/__test__/element-template/native/reload.test.ts +118 -2
- package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
- package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
- package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
- package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
- package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
- package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -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/template/element-template-handle.test.ts +32 -0
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
- 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/updateGlobalProps.event.test.jsx +2 -2
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
- package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
- package/runtime/__test__/snapshot/preact.test.jsx +0 -3
- package/runtime/__test__/snapshot/ref.test.jsx +30 -0
- package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
- package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
- package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
- package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
- package/runtime/lazy/element-template-internal.js +1 -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/capture-main-thread-object.js +2 -1
- package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
- 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/globalProps.js +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
- 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/runtime-destroy.js +1 -1
- package/runtime/lib/core/runtime-destroy.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/attr-slots.js +5 -2
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/commit-hook.js +11 -12
- package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +16 -11
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +23 -0
- package/runtime/lib/element-template/background/hydrate.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/debug/alog.d.ts +1 -1
- package/runtime/lib/element-template/debug/alog.js +4 -1
- package/runtime/lib/element-template/debug/alog.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 +2 -2
- package/runtime/lib/element-template/internal.js +1 -14
- 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/native/callDestroyLifetimeFun.js +6 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- 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/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 +8 -2
- package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +57 -50
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +1 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +7 -1
- 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 +31 -2
- 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/attr-slot-plan.d.ts +4 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.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 +7 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
- 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 +3 -2
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
- package/runtime/lib/element-template/runtime/template/typed-attributes.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/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 +23 -17
- package/runtime/lib/snapshot/lifecycle/destroy.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/ref/delay.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.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 +11 -8
- 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/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/jsFunctionLifecycle.d.ts +2 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
- package/runtime/lib/worklet-runtime/jsFunctionLifecycle.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/capture-main-thread-object.ts +2 -1
- package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
- package/runtime/src/core/globalProps.ts +1 -1
- package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
- package/runtime/src/core/lynx-data-processors.ts +124 -1
- package/runtime/src/core/runtime-destroy.ts +1 -1
- package/runtime/src/document.ts +0 -6
- package/runtime/src/element-template/background/attr-slots.ts +5 -1
- package/runtime/src/element-template/background/commit-hook.ts +18 -12
- package/runtime/src/element-template/background/destroy.ts +16 -13
- package/runtime/src/element-template/background/hydrate.ts +23 -0
- package/runtime/src/element-template/client/root.ts +1 -3
- package/runtime/src/element-template/debug/alog.ts +5 -2
- package/runtime/src/element-template/index.ts +2 -2
- package/runtime/src/element-template/internal.ts +1 -20
- package/runtime/src/element-template/lynx/env.ts +1 -1
- package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
- package/runtime/src/element-template/native/flush.ts +10 -0
- package/runtime/src/element-template/native/main-thread-api.ts +3 -6
- package/runtime/src/element-template/native/mts-destroy.ts +7 -2
- package/runtime/src/element-template/native/patch-listener.ts +62 -57
- package/runtime/src/element-template/native/reload-background.ts +1 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
- package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
- package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
- package/runtime/src/element-template/protocol/opcodes.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +8 -13
- package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
- package/runtime/src/element-template/runtime/patch.ts +38 -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/attr-slot-plan.ts +31 -4
- 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 +456 -50
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
- 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/snapshot/lifecycle/destroy.ts +23 -18
- 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/ref/delay.ts +1 -1
- package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
- package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
- 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/worklet-runtime/README.md +30 -10
- 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/jsFunctionLifecycle.ts +6 -0
- package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
- package/runtime/types/types.d.ts +2 -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 +49 -0
- package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
- package/transform/__test__/defines.spec.js +30 -0
- package/transform/__test__/fixture.spec.js +11 -11
- package/transform/__test__/main-thread-object-compat.spec.js +111 -0
- package/transform/__test__/object-methods.spec.js +79 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
- package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
- package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
- package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/package.json +0 -1
- package/transform/src/lib.rs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
- 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 +226 -132
- 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":"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 '../../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;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 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"]}
|
|
@@ -5,6 +5,11 @@ import { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init
|
|
|
5
5
|
import { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';
|
|
6
6
|
export function callDestroyLifetimeFun() {
|
|
7
7
|
takeMainThreadRefInitValuePatch();
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
destroyElementTemplateBackgroundRuntime();
|
|
10
|
+
}
|
|
11
|
+
finally {
|
|
12
|
+
takeMainThreadRefInitValuePatch();
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
//# sourceMappingURL=callDestroyLifetimeFun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callDestroyLifetimeFun.js","sourceRoot":"","sources":["../../../src/element-template/native/callDestroyLifetimeFun.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AAEnF,MAAM,UAAU,sBAAsB;IACpC,+BAA+B,EAAE,CAAC;IAClC,uCAAuC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"callDestroyLifetimeFun.js","sourceRoot":"","sources":["../../../src/element-template/native/callDestroyLifetimeFun.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAC3F,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AAEnF,MAAM,UAAU,sBAAsB;IACpC,+BAA+B,EAAE,CAAC;IAClC,IAAI,CAAC;QACH,uCAAuC,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,+BAA+B,EAAE,CAAC;IACpC,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.\nimport { takeMainThreadRefInitValuePatch } from '../../core/main-thread-ref-init-value.js';\nimport { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';\n\nexport function callDestroyLifetimeFun(): void {\n takeMainThreadRefInitValuePatch();\n try {\n destroyElementTemplateBackgroundRuntime();\n } finally {\n takeMainThreadRefInitValuePatch();\n }\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"]}
|
|
@@ -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"]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { resetElementTemplatePatchListener } from './patch-listener.js';
|
|
5
5
|
import { resetElementTemplateRefInitValueListener } from '../main-thread-ref-init-value.js';
|
|
6
6
|
import { destroyAllElementTemplateListStates } from '../runtime/list/list.js';
|
|
7
|
+
import { resetTemplateId } from '../runtime/template/handle.js';
|
|
7
8
|
import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';
|
|
8
9
|
import { clearMainThreadDynamicAttrState } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
9
10
|
import { elementTemplateRegistry } from '../runtime/template/registry.js';
|
|
@@ -36,8 +37,13 @@ export function destroyElementTemplateMainThreadRuntime() {
|
|
|
36
37
|
// even if listener reset fails so destroy does not leave removed pages retained.
|
|
37
38
|
destroyAllElementTemplateListStates();
|
|
38
39
|
elementTemplateRegistry.clear();
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
try {
|
|
41
|
+
clearMainThreadDynamicAttrState();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
45
|
+
resetTemplateId();
|
|
46
|
+
}
|
|
41
47
|
if (didPatchListenerResetThrow) {
|
|
42
48
|
throw patchListenerResetError;
|
|
43
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,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,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,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,uBA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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"]}
|
|
@@ -7,6 +7,7 @@ import { getReloadVersion } from '../../core/reload-version.js';
|
|
|
7
7
|
import { formatElementTemplateUpdateCommands } from '../debug/alog.js';
|
|
8
8
|
import { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';
|
|
9
9
|
import { applyElementTemplateUpdateCommands } from '../runtime/patch.js';
|
|
10
|
+
import { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';
|
|
10
11
|
let listener;
|
|
11
12
|
export function installElementTemplatePatchListener() {
|
|
12
13
|
resetElementTemplatePatchListener();
|
|
@@ -23,70 +24,76 @@ export function installElementTemplatePatchListener() {
|
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
setPipeline(pipelineOptions);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const hasOps = payload.ops.length > 0;
|
|
39
|
-
const flushOptions = payload.flushOptions;
|
|
40
|
-
const isHydration = payload.isHydration === true;
|
|
41
|
-
const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;
|
|
42
|
-
if (hasOps) {
|
|
43
|
-
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
44
|
-
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
45
|
-
+ JSON.stringify({
|
|
46
|
-
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
47
|
-
flushOptions,
|
|
48
|
-
flowIds,
|
|
49
|
-
}, null, 2));
|
|
27
|
+
try {
|
|
28
|
+
markTiming('mtsRenderStart');
|
|
29
|
+
markTiming('parseChangesStart');
|
|
30
|
+
const payload = JSON.parse(event.data.payload);
|
|
31
|
+
markTiming('parseChangesEnd');
|
|
32
|
+
if (typeof patchOptions.reloadVersion === 'number'
|
|
33
|
+
&& patchOptions.reloadVersion < getReloadVersion()) {
|
|
34
|
+
markTiming('mtsRenderEnd');
|
|
35
|
+
if (shouldProfilePatch) {
|
|
36
|
+
lynx.performance.profileEnd();
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
50
39
|
}
|
|
51
|
-
|
|
40
|
+
const hasOps = payload.ops.length > 0;
|
|
41
|
+
const flushOptions = payload.flushOptions;
|
|
42
|
+
const isHydration = payload.isHydration === true;
|
|
43
|
+
const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;
|
|
52
44
|
try {
|
|
53
|
-
|
|
45
|
+
if (hasOps) {
|
|
46
|
+
if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
|
|
47
|
+
console.alog?.('[ReactLynxDebug] ElementTemplate main-thread patch:\n'
|
|
48
|
+
+ JSON.stringify({
|
|
49
|
+
ops: formatElementTemplateUpdateCommands(payload.ops),
|
|
50
|
+
flushOptions,
|
|
51
|
+
flowIds,
|
|
52
|
+
}, null, 2));
|
|
53
|
+
}
|
|
54
|
+
markTiming('patchChangesStart');
|
|
55
|
+
try {
|
|
56
|
+
applyElementTemplateUpdateCommands(payload.ops, isHydration);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
markTiming('patchChangesEnd');
|
|
60
|
+
markTiming('mtsRenderEnd');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
markTiming('mtsRenderEnd');
|
|
65
|
+
}
|
|
66
|
+
applyPendingMainThreadRefAttachments(isHydration);
|
|
54
67
|
}
|
|
55
68
|
finally {
|
|
56
|
-
markTiming('patchChangesEnd');
|
|
57
|
-
markTiming('mtsRenderEnd');
|
|
58
69
|
if (isHydration) {
|
|
59
70
|
flushDelayedRunOnBackgroundFunctions();
|
|
60
71
|
clearFirstScreenMainThreadRefs();
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
for (const data of delayedRunOnMainThreadData) {
|
|
75
|
-
try {
|
|
76
|
-
runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
lynx.reportError(error);
|
|
74
|
+
if (delayedRunOnMainThreadData?.length) {
|
|
75
|
+
setEomShouldFlushElementTree(false);
|
|
76
|
+
try {
|
|
77
|
+
for (const data of delayedRunOnMainThreadData) {
|
|
78
|
+
try {
|
|
79
|
+
runRunOnMainThreadTask(data.worklet, data.params, data.resolveId);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
lynx.reportError(error);
|
|
83
|
+
}
|
|
80
84
|
}
|
|
81
85
|
}
|
|
86
|
+
finally {
|
|
87
|
+
setEomShouldFlushElementTree(true);
|
|
88
|
+
}
|
|
82
89
|
}
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
__FlushElementTree(undefined, flushOptions);
|
|
91
|
+
if (shouldProfilePatch) {
|
|
92
|
+
lynx.performance.profileEnd();
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
lynx.performance.profileEnd();
|
|
95
|
+
finally {
|
|
96
|
+
setPipeline(undefined);
|
|
90
97
|
}
|
|
91
98
|
};
|
|
92
99
|
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.update, listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAGrF,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"patch-listener.js","sourceRoot":"","sources":["../../../src/element-template/native/patch-listener.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAGrF,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,oCAAoC,EAAE,MAAM,uDAAuD,CAAC;AAE7G,IAAI,QAES,CAAC;AAEd,MAAM,UAAU,mCAAmC;IACjD,iCAAiC,EAAE,CAAC;IAEpC,QAAQ,GAAG,CAAC,KAA+C,EAAE,EAAE;QAC7D,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QACpC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;QAClD,MAAM,kBAAkB,GAAG,CAAC,CAAC,OAAO;eAC/B,OAAO,IAAI,CAAC,WAAW,EAAE,YAAY,KAAK,UAAU;eACpD,OAAO,IAAI,CAAC,WAAW,EAAE,UAAU,KAAK,UAAU,CAAC;QACxD,IAAI,kBAAkB,EAAE,CAAC;YACvB,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,kBAAkB,EAAE;gBAChD,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAClB,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QACD,WAAW,CAAC,eAAe,CAAC,CAAC;QAC7B,IAAI,CAAC;YACH,UAAU,CAAC,g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,CACT,CAAC;IACJ,CAAC;IACD,QAAQ,GAAG,SAAS,CAAC;AACvB,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 type { ClosureValueType } from '@lynx-js/react/worklet-runtime/bindings';\nimport {\n clearFirstScreenMainThreadRefs,\n flushDelayedRunOnBackgroundFunctions,\n runRunOnMainThreadTask,\n setEomShouldFlushElementTree,\n} from '@lynx-js/react/worklet-runtime/bindings';\n\nimport { markTiming, setPipeline } from '../../core/performance.js';\nimport { getReloadVersion } from '../../core/reload-version.js';\nimport { formatElementTemplateUpdateCommands } from '../debug/alog.js';\nimport { ElementTemplateLifecycleConstant } from '../protocol/lifecycle-constant.js';\nimport type { ElementTemplateUpdateCommitContext } from '../protocol/types.js';\nimport type { ElementTemplateUpdateEvent } from '../protocol/update-event.js';\nimport { applyElementTemplateUpdateCommands } from '../runtime/patch.js';\nimport { applyPendingMainThreadRefAttachments } from '../runtime/template/main-thread-dynamic-attr-state.js';\n\nlet listener:\n | ((event: Pick<ElementTemplateUpdateEvent, 'data'>) => void)\n | undefined;\n\nexport function installElementTemplatePatchListener(): void {\n resetElementTemplatePatchListener();\n\n listener = (event: Pick<ElementTemplateUpdateEvent, 'data'>) => {\n const { patchOptions } = event.data;\n const { flowIds, pipelineOptions } = patchOptions;\n const shouldProfilePatch = !!flowIds\n && typeof lynx.performance?.profileStart === 'function'\n && typeof lynx.performance?.profileEnd === 'function';\n if (shouldProfilePatch) {\n lynx.performance.profileStart('ReactLynx::patch', {\n flowId: flowIds[0],\n flowIds,\n });\n }\n setPipeline(pipelineOptions);\n try {\n markTiming('mtsRenderStart');\n markTiming('parseChangesStart');\n\n const payload = JSON.parse(event.data.payload) as ElementTemplateUpdateCommitContext;\n markTiming('parseChangesEnd');\n\n if (\n typeof patchOptions.reloadVersion === 'number'\n && patchOptions.reloadVersion < getReloadVersion()\n ) {\n markTiming('mtsRenderEnd');\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n return;\n }\n\n const hasOps = payload.ops.length > 0;\n const flushOptions = payload.flushOptions;\n const isHydration = payload.isHydration === true;\n const delayedRunOnMainThreadData = payload.delayedRunOnMainThreadData;\n try {\n if (hasOps) {\n if (typeof __ALOG__ !== 'undefined' && __ALOG__) {\n console.alog?.(\n '[ReactLynxDebug] ElementTemplate main-thread patch:\\n'\n + JSON.stringify(\n {\n ops: formatElementTemplateUpdateCommands(payload.ops),\n flushOptions,\n flowIds,\n },\n null,\n 2,\n ),\n );\n }\n markTiming('patchChangesStart');\n try {\n applyElementTemplateUpdateCommands(payload.ops, isHydration);\n } finally {\n markTiming('patchChangesEnd');\n markTiming('mtsRenderEnd');\n }\n } else {\n markTiming('mtsRenderEnd');\n }\n applyPendingMainThreadRefAttachments(isHydration);\n } finally {\n if (isHydration) {\n flushDelayedRunOnBackgroundFunctions();\n clearFirstScreenMainThreadRefs();\n }\n }\n if (delayedRunOnMainThreadData?.length) {\n setEomShouldFlushElementTree(false);\n try {\n for (const data of delayedRunOnMainThreadData) {\n try {\n runRunOnMainThreadTask(data.worklet, data.params as ClosureValueType[], data.resolveId);\n } catch (error) {\n lynx.reportError(error as Error);\n }\n }\n } finally {\n setEomShouldFlushElementTree(true);\n }\n }\n\n __FlushElementTree(undefined, flushOptions);\n\n if (shouldProfilePatch) {\n lynx.performance.profileEnd();\n }\n } finally {\n setPipeline(undefined);\n }\n };\n\n lynx.getJSContext().addEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n}\n\nexport function resetElementTemplatePatchListener(): void {\n if (listener) {\n lynx.getJSContext().removeEventListener(\n ElementTemplateLifecycleConstant.update,\n listener,\n );\n }\n listener = undefined;\n}\n"]}
|
|
@@ -33,7 +33,7 @@ export function reloadBackground(updateData, options) {
|
|
|
33
33
|
// Reload creates a new object so InitData Provider / Consumer observers do
|
|
34
34
|
// not retain the pre-reload object identity.
|
|
35
35
|
lynx.__initData = Object.assign({}, lynx.__initData);
|
|
36
|
-
applyUpdatePageData(updateData);
|
|
36
|
+
applyUpdatePageData(updateData, options);
|
|
37
37
|
setRoot(new BackgroundPageRootInstance());
|
|
38
38
|
__root.__jsx = jsx;
|
|
39
39
|
setupBackgroundElementTemplateDocument();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload-background.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-background.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,UAAU,gBAAgB,CAAC,UAAmB,EAAE,OAAiC;IACrF,IAAI,wBAAwB,EAAE,EAAE,CAAC;QAC/B,qBAAqB,CAAC,UAAqC,EAAE,OAAO,EAAE,GAAG,EAAE;YACzE,4DAA4D;YAC5D,+BAA+B,EAAE,CAAC;YAClC,kEAAkE;YAClE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;QACzB,uCAAuC,EAAE,CAAC;QAC1C,qBAAqB,EAAE,CAAC;QACxB,2EAA2E;QAC3E,6CAA6C;QAC7C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,mBAAmB,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"reload-background.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-background.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAG1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,uCAAuC,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,UAAU,gBAAgB,CAAC,UAAmB,EAAE,OAAiC;IACrF,IAAI,wBAAwB,EAAE,EAAE,CAAC;QAC/B,qBAAqB,CAAC,UAAqC,EAAE,OAAO,EAAE,GAAG,EAAE;YACzE,4DAA4D;YAC5D,+BAA+B,EAAE,CAAC;YAClC,kEAAkE;YAClE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;QACzB,uCAAuC,EAAE,CAAC;QAC1C,qBAAqB,EAAE,CAAC;QACxB,2EAA2E;QAC3E,6CAA6C;QAC7C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACrD,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAEzC,OAAO,CAAC,IAAI,0BAA0B,EAAE,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC;QACnB,sCAAsC,EAAE,CAAC;QACzC,uCAAuC,EAAE,CAAC;QAC1C,yBAAyB,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAqB,EAAE,MAAkC,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;YACtD,UAAU,EAAE,CAAC;QACf,CAAC;IACH,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 type { ComponentChild, ContainerNode } from 'preact';\nimport { render } from 'preact';\n\nimport { canReEvalBackgroundEntry, reEvalBackgroundEntry } from '../../core/entry-reload.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { increaseReloadVersion } from '../../core/reload-version.js';\nimport { resetElementTemplateCommitState } from '../background/commit-hook.js';\nimport { destroyElementTemplateBackgroundRuntime } from '../background/destroy.js';\nimport { setupBackgroundElementTemplateDocument } from '../background/document.js';\nimport { installElementTemplateHydrationListener } from '../background/hydration-listener.js';\nimport { BackgroundPageRootInstance } from '../background/instance.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { resetEventStateForRuntime } from '../prop-adapters/event.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\n\nexport function reloadBackground(updateData: unknown, options?: Record<string, unknown>): void {\n if (canReEvalBackgroundEntry()) {\n reEvalBackgroundEntry(updateData as Record<string, unknown>, options, () => {\n // The unmount of the old tree must not reach the new entry.\n resetElementTemplateCommitState();\n // A queued `updateGlobalProps` callback must not render it again.\n __root.__jsx = undefined;\n });\n return;\n }\n\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadBackground');\n }\n\n try {\n const jsx = __root.__jsx;\n destroyElementTemplateBackgroundRuntime();\n increaseReloadVersion();\n // Reload creates a new object so InitData Provider / Consumer observers do\n // not retain the pre-reload object identity.\n lynx.__initData = Object.assign({}, lynx.__initData);\n applyUpdatePageData(updateData, options);\n\n setRoot(new BackgroundPageRootInstance());\n __root.__jsx = jsx;\n setupBackgroundElementTemplateDocument();\n installElementTemplateHydrationListener();\n resetEventStateForRuntime();\n render(jsx as ComponentChild, __root as unknown as ContainerNode);\n } finally {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2026 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 { onMtsDestruction } from './mts-destroy.js';
|
|
5
6
|
import { canReEvalMainThreadEntry, installMainThreadReloadCompleter, reEvalMainThreadEntry, } from '../../core/entry-reload.js';
|
|
6
7
|
import { applyUpdatePageData } from '../../core/lynx-page-data.js';
|
|
@@ -25,6 +26,8 @@ export function reloadMainThread(data, options) {
|
|
|
25
26
|
// TODO: Replace this cleanup-only serialization with a direct page-children
|
|
26
27
|
// or clear-slot PAPI once native exposes one.
|
|
27
28
|
const page = __SerializeElementTemplate(__page);
|
|
29
|
+
let cleanupError;
|
|
30
|
+
let didCleanupThrow = false;
|
|
28
31
|
for (const root of page.childSlots?.[ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX] ?? []) {
|
|
29
32
|
const rootRef = elementTemplateRegistry.get(root.uid);
|
|
30
33
|
__RemoveNodeFromElementTemplate(__page, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, rootRef);
|
|
@@ -33,25 +36,47 @@ export function reloadMainThread(data, options) {
|
|
|
33
36
|
for (const handleId of removedHandleIds) {
|
|
34
37
|
elementTemplateRegistry.delete(handleId);
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
try {
|
|
40
|
+
deleteMainThreadDynamicAttrStateForSubtree(removedHandleIds);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!didCleanupThrow) {
|
|
44
|
+
cleanupError = error;
|
|
45
|
+
didCleanupThrow = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
49
|
if (canReEvalMainThreadEntry()) {
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
try {
|
|
51
|
+
onMtsDestruction();
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
increaseReloadVersion();
|
|
55
|
+
}
|
|
56
|
+
if (didCleanupThrow) {
|
|
57
|
+
throw cleanupError;
|
|
58
|
+
}
|
|
41
59
|
reEvalMainThreadEntry({ page: __page, options });
|
|
42
60
|
return;
|
|
43
61
|
}
|
|
44
62
|
elementTemplateRegistry.clear();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
try {
|
|
64
|
+
clearMainThreadDynamicAttrState();
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
resetElementTemplateMainThreadBackgroundFunctionRuntime();
|
|
68
|
+
resetTemplateId();
|
|
69
|
+
// Ref cleanup still belongs to the old page. Advance only before rendering
|
|
70
|
+
// the new tree so calls queued by old ref/unmount callbacks remain stale.
|
|
71
|
+
increaseReloadVersion();
|
|
72
|
+
}
|
|
73
|
+
if (didCleanupThrow) {
|
|
74
|
+
throw cleanupError;
|
|
75
|
+
}
|
|
51
76
|
const oldRoot = __root;
|
|
52
77
|
setRoot({ __jsx: oldRoot.__jsx });
|
|
53
78
|
renderMainThread();
|
|
54
|
-
|
|
79
|
+
flushElementTemplate(options);
|
|
55
80
|
}
|
|
56
81
|
finally {
|
|
57
82
|
if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,C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AAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;YACD,0CAA0C,CAAC,gBAAgB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"reload-main-thread.js","sourceRoot":"","sources":["../../../src/element-template/native/reload-main-thread.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,uDAAuD,EAAE,MAAM,wDAAwD,CAAC;AACjI,OAAO,EACL,+BAA+B,EAC/B,0CAA0C,GAC3C,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,UAAU,gBAAgB,CAAC,IAAa,EAAE,OAAyB;IACvE,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,6BAA6B,CAAC,CA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YAAY,CAAC;IACzG,KAAK,MAAM,KAAK,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QACvC,iCAAiC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACtD,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 { flushElementTemplate } from './flush.js';\nimport { onMtsDestruction } from './mts-destroy.js';\nimport {\n canReEvalMainThreadEntry,\n installMainThreadReloadCompleter,\n reEvalMainThreadEntry,\n} from '../../core/entry-reload.js';\nimport { applyUpdatePageData } from '../../core/lynx-page-data.js';\nimport { increaseReloadVersion } from '../../core/reload-version.js';\nimport { profileEnd, profileStart } from '../debug/profile.js';\nimport { ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX } from '../protocol/page.js';\nimport type { SerializedEtNode, SerializedPageRoot } from '../protocol/types.js';\nimport { destroyAllElementTemplateListStates } from '../runtime/list/list.js';\nimport { __page, setupPage } from '../runtime/page/page.js';\nimport { __root, setRoot } from '../runtime/page/root-instance.js';\nimport { renderMainThread } from '../runtime/render/render-main-thread.js';\nimport { resetTemplateId } from '../runtime/template/handle.js';\nimport { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../runtime/template/main-thread-background-function.js';\nimport {\n clearMainThreadDynamicAttrState,\n deleteMainThreadDynamicAttrStateForSubtree,\n} from '../runtime/template/main-thread-dynamic-attr-state.js';\nimport { elementTemplateRegistry } from '../runtime/template/registry.js';\n\nexport function reloadMainThread(data: unknown, options: UpdatePageOption): void {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileStart('ReactLynx::reloadMainThread');\n }\n\n try {\n applyUpdatePageData(data, options);\n\n destroyAllElementTemplateListStates();\n // TODO: Replace this cleanup-only serialization with a direct page-children\n // or clear-slot PAPI once native exposes one.\n const page = __SerializeElementTemplate(__page) as SerializedPageRoot;\n let cleanupError: unknown;\n let didCleanupThrow = false;\n for (const root of page.childSlots?.[ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX] ?? []) {\n const rootRef = elementTemplateRegistry.get(root.uid)!;\n __RemoveNodeFromElementTemplate(__page, ELEMENT_TEMPLATE_PAGE_ROOT_SLOT_INDEX, rootRef);\n const removedHandleIds: number[] = [];\n collectSerializedSubtreeHandleIds(root, removedHandleIds);\n for (const handleId of removedHandleIds) {\n elementTemplateRegistry.delete(handleId);\n }\n try {\n deleteMainThreadDynamicAttrStateForSubtree(removedHandleIds);\n } catch (error) {\n if (!didCleanupThrow) {\n cleanupError = error;\n didCleanupThrow = true;\n }\n }\n }\n if (canReEvalMainThreadEntry()) {\n try {\n onMtsDestruction();\n } finally {\n increaseReloadVersion();\n }\n if (didCleanupThrow) {\n throw cleanupError;\n }\n reEvalMainThreadEntry<MainThreadReloadHandoff>({ page: __page, options });\n return;\n }\n elementTemplateRegistry.clear();\n try {\n clearMainThreadDynamicAttrState();\n } finally {\n resetElementTemplateMainThreadBackgroundFunctionRuntime();\n resetTemplateId();\n // Ref cleanup still belongs to the old page. Advance only before rendering\n // the new tree so calls queued by old ref/unmount callbacks remain stale.\n increaseReloadVersion();\n }\n if (didCleanupThrow) {\n throw cleanupError;\n }\n\n const oldRoot = __root;\n setRoot({ __jsx: oldRoot.__jsx });\n renderMainThread();\n\n flushElementTemplate(options);\n } finally {\n if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {\n profileEnd();\n }\n }\n}\n\ninterface MainThreadReloadHandoff {\n page: ElementTemplateHandle;\n options: UpdatePageOption;\n}\n\nexport function completeMainThreadReload({ page, options }: MainThreadReloadHandoff): void {\n setupPage(page);\n renderMainThread();\n __FlushElementTree(undefined, options);\n}\n\ninstallMainThreadReloadCompleter(completeMainThreadReload);\n\nfunction collectSerializedSubtreeHandleIds(\n node: SerializedEtNode,\n handleIds: number[],\n): void {\n handleIds.push(node.uid as number);\n for (const slot of node.childSlots ?? []) {\n for (const child of slot ?? []) {\n collectSerializedSubtreeHandleIds(child, handleIds);\n }\n }\n const listChildren = (node as { options?: { listChildren?: SerializedEtNode[] } }).options?.listChildren;\n for (const child of listChildren ?? []) {\n collectSerializedSubtreeHandleIds(child, handleIds);\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MTEventCtx } from '../runtime/template/main-thread-event-ctx.js';
|
|
2
|
+
export interface GestureDescriptor {
|
|
3
|
+
id: number;
|
|
4
|
+
type: number;
|
|
5
|
+
config: Record<string, unknown>;
|
|
6
|
+
callbacks: {
|
|
7
|
+
name: string;
|
|
8
|
+
callback: MTEventCtx;
|
|
9
|
+
}[];
|
|
10
|
+
relationMap: {
|
|
11
|
+
waitFor: number[];
|
|
12
|
+
simultaneous: number[];
|
|
13
|
+
continueWith: number[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface GestureSlotValue {
|
|
17
|
+
type: 'gesture';
|
|
18
|
+
value: GestureDescriptor[];
|
|
19
|
+
}
|
|
20
|
+
export declare function isGestureSlotValue(value: unknown): value is GestureSlotValue;
|
|
21
|
+
export declare function prepareGestureForNative(value: unknown, previous?: GestureSlotValue | null): GestureSlotValue | null;
|
|
22
|
+
export declare function retainGestureCallbacks(value: GestureSlotValue): void;
|
|
23
|
+
export declare function hydrateGestureCallbacks(value: GestureSlotValue, previous: GestureSlotValue): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 { hydrateWorkletCtx } from '@lynx-js/react/worklet-runtime/bindings';
|
|
5
|
+
import { isMainThreadFunction } from '../../core/main-thread-function.js';
|
|
6
|
+
import { registerMainThreadBackgroundFunctionCtx, retainMainThreadBackgroundFunctionCtx, } from '../runtime/template/main-thread-background-function.js';
|
|
7
|
+
export function isGestureSlotValue(value) {
|
|
8
|
+
return value !== null
|
|
9
|
+
&& typeof value === 'object'
|
|
10
|
+
&& !Array.isArray(value)
|
|
11
|
+
&& value.type === 'gesture'
|
|
12
|
+
&& Array.isArray(value.value);
|
|
13
|
+
}
|
|
14
|
+
// Provenance stays outside the wire value. A repeated prepare before native
|
|
15
|
+
// delivery must reuse its registered ctx, while mutable Gesture config is copied.
|
|
16
|
+
const callbackSources = new WeakMap();
|
|
17
|
+
export function prepareGestureForNative(value, previous) {
|
|
18
|
+
if (value == null || value === false) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value !== 'object'
|
|
22
|
+
|| !(value.__isGesture === true || value.__isSerialized === true)) {
|
|
23
|
+
throw new Error('ElementTemplate main-thread:gesture expects a Gesture object.');
|
|
24
|
+
}
|
|
25
|
+
const descriptors = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
function append(gesture) {
|
|
28
|
+
if (gesture.type === -1) {
|
|
29
|
+
for (const child of gesture.gestures) {
|
|
30
|
+
append(child);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (seen.has(gesture.id)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
seen.add(gesture.id);
|
|
38
|
+
const callbacks = [];
|
|
39
|
+
const previousGesture = previous?.value.find(item => item.id === gesture.id);
|
|
40
|
+
for (const name of Object.keys(gesture.callbacks)) {
|
|
41
|
+
const rawCallback = gesture.callbacks[name];
|
|
42
|
+
if (rawCallback == null) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!isMainThreadFunction(rawCallback)) {
|
|
46
|
+
throw new Error(`Gesture callback '${name}' must be a main-thread function.`);
|
|
47
|
+
}
|
|
48
|
+
const previousCallback = previousGesture?.callbacks.find(item => item.name === name)?.callback;
|
|
49
|
+
let callback = previousCallback;
|
|
50
|
+
if (!callback || callbackSources.get(callback) !== rawCallback) {
|
|
51
|
+
callback = { ...rawCallback };
|
|
52
|
+
callbackSources.set(callback, rawCallback);
|
|
53
|
+
registerMainThreadBackgroundFunctionCtx(callback);
|
|
54
|
+
}
|
|
55
|
+
callbacks.push({ name, callback });
|
|
56
|
+
}
|
|
57
|
+
descriptors.push({
|
|
58
|
+
id: gesture.id,
|
|
59
|
+
type: gesture.type,
|
|
60
|
+
config: { ...gesture.config },
|
|
61
|
+
callbacks,
|
|
62
|
+
relationMap: {
|
|
63
|
+
waitFor: gesture.waitFor?.map(item => item.id) ?? [],
|
|
64
|
+
simultaneous: gesture.simultaneousWith?.map(item => item.id) ?? [],
|
|
65
|
+
continueWith: gesture.continueWith?.map(item => item.id) ?? [],
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
append(value);
|
|
70
|
+
return { type: 'gesture', value: descriptors };
|
|
71
|
+
}
|
|
72
|
+
export function retainGestureCallbacks(value) {
|
|
73
|
+
for (const gesture of value.value) {
|
|
74
|
+
for (const { callback } of gesture.callbacks) {
|
|
75
|
+
retainMainThreadBackgroundFunctionCtx(callback);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function hydrateGestureCallbacks(value, previous) {
|
|
80
|
+
// IDs belong to independent thread-local allocators. Pair each type in
|
|
81
|
+
// declaration order; the worklet hydrator also checks callback source identity.
|
|
82
|
+
const remaining = previous.value.slice();
|
|
83
|
+
for (const gesture of value.value) {
|
|
84
|
+
const index = remaining.findIndex(old => old.type === gesture.type);
|
|
85
|
+
if (index === -1) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const oldGesture = remaining.splice(index, 1)[0];
|
|
89
|
+
for (const { name, callback } of gesture.callbacks) {
|
|
90
|
+
const oldCallback = oldGesture.callbacks.find(item => item.name === name)?.callback;
|
|
91
|
+
if (oldCallback) {
|
|
92
|
+
hydrateWorkletCtx(callback, oldCallback);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=gesture.js.map
|