@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
|
@@ -222,64 +222,121 @@ describe('ElementTemplate commit hook', () => {
|
|
|
222
222
|
expect(takeDelayedRunOnMainThreadData()).toEqual([]);
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
it('dispatches
|
|
226
|
-
markElementTemplateHydrated();
|
|
225
|
+
it.each([false, true])('dispatches ref initialization separately (hydrated: %s)', (hydrated) => {
|
|
226
|
+
if (hydrated) markElementTemplateHydrated();
|
|
227
|
+
const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
|
|
227
228
|
new MainThreadRef('commit-init');
|
|
228
229
|
|
|
229
230
|
options.__c?.({} as unknown as object, []);
|
|
230
231
|
|
|
232
|
+
expect(dispatch).toHaveBeenCalledExactlyOnceWith({
|
|
233
|
+
type: ElementTemplateLifecycleConstant.updateMTRefInitValue,
|
|
234
|
+
data: JSON.stringify([[1, 'commit-init']]),
|
|
235
|
+
});
|
|
236
|
+
expect(takeMainThreadRefInitValuePatch()).toEqual([]);
|
|
231
237
|
envManager.switchToMainThread();
|
|
232
|
-
expect(updateEvents).toEqual([
|
|
233
|
-
{
|
|
234
|
-
ops: [],
|
|
235
|
-
flushOptions: { emptyPatch: true },
|
|
236
|
-
flowIds: undefined,
|
|
237
|
-
reloadVersion: getReloadVersion(),
|
|
238
|
-
mainThreadRefInitValuePatch: [[1, 'commit-init']],
|
|
239
|
-
},
|
|
240
|
-
]);
|
|
238
|
+
expect(updateEvents).toEqual([]);
|
|
241
239
|
envManager.switchToBackground();
|
|
242
|
-
expect(takeMainThreadRefInitValuePatch()).toEqual([]);
|
|
243
240
|
});
|
|
244
241
|
|
|
245
|
-
it('
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
242
|
+
it.each(['update', 'ref', 'circular-ref', 'dispatch'])(
|
|
243
|
+
'cleans commit state when %s fails and allows the next commit',
|
|
244
|
+
(failure) => {
|
|
245
|
+
vi.useFakeTimers();
|
|
246
|
+
globalThis.__ALOG__ = false;
|
|
247
|
+
const serializeError = new Error('update serialization failed');
|
|
248
|
+
const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
|
|
249
|
+
const throwingValue = {
|
|
250
|
+
toJSON() {
|
|
251
|
+
throw serializeError;
|
|
252
|
+
},
|
|
253
|
+
} as unknown as string;
|
|
254
|
+
const circularValue: { self?: unknown } = {};
|
|
255
|
+
circularValue.self = circularValue;
|
|
256
|
+
new MainThreadRef(
|
|
257
|
+
failure === 'ref' ? throwingValue : failure === 'circular-ref' ? circularValue : 'survives-ui-serialization',
|
|
258
|
+
);
|
|
259
|
+
if (failure === 'dispatch') {
|
|
260
|
+
dispatch.mockImplementationOnce(() => {
|
|
261
|
+
throw serializeError;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
const ref = vi.fn();
|
|
265
|
+
const removedRoot = new BackgroundElementTemplateInstance('removed');
|
|
266
|
+
const removeEventListener = vi.spyOn(lynx.getCoreContext(), 'removeEventListener');
|
|
267
|
+
|
|
268
|
+
try {
|
|
269
|
+
markElementTemplateHydrated();
|
|
270
|
+
queueRefAttrUpdate(null, ref, { instanceId: -2 }, 0);
|
|
271
|
+
markRemovedSubtreeForPostDispatchTeardown(removedRoot);
|
|
272
|
+
globalCommitContext.ops = createRawTextOps(1, failure === 'update' ? throwingValue : 'failed');
|
|
273
|
+
enqueueDelayedRunOnMainThreadData({
|
|
274
|
+
worklet: { _wkltId: 'failed-serialize-main-thread-function' },
|
|
275
|
+
params: [],
|
|
276
|
+
resolveId: onFunctionCall(vi.fn()),
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
expect(() => options.__c?.({} as unknown as object, [])).toThrow(
|
|
280
|
+
failure === 'circular-ref' ? TypeError : serializeError,
|
|
281
|
+
);
|
|
282
|
+
if (failure === 'update' || failure === 'dispatch') {
|
|
283
|
+
expect(dispatch).toHaveBeenCalledExactlyOnceWith({
|
|
284
|
+
type: ElementTemplateLifecycleConstant.updateMTRefInitValue,
|
|
285
|
+
data: JSON.stringify([[1, 'survives-ui-serialization']]),
|
|
286
|
+
});
|
|
287
|
+
} else {
|
|
288
|
+
expect(dispatch).not.toHaveBeenCalled();
|
|
289
|
+
}
|
|
290
|
+
expect(takeMainThreadRefInitValuePatch()).toEqual([]);
|
|
291
|
+
expect(takeDelayedRunOnMainThreadData()).toEqual([]);
|
|
292
|
+
expect(removeEventListener).toHaveBeenCalledWith(WorkletEvents.FunctionCallRet, expect.any(Function));
|
|
293
|
+
expect(globalCommitContext.ops).toEqual([]);
|
|
294
|
+
expect([...globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown]).toEqual([]);
|
|
295
|
+
|
|
296
|
+
dispatch.mockClear();
|
|
297
|
+
new MainThreadRef('next-ref');
|
|
298
|
+
globalCommitContext.ops = createRawTextOps(2, 'next-commit');
|
|
299
|
+
options.__c?.({} as unknown as object, []);
|
|
300
|
+
expect(ref).not.toHaveBeenCalled();
|
|
301
|
+
expect(dispatch.mock.calls.map(([event]) => event.type)).toEqual([
|
|
302
|
+
ElementTemplateLifecycleConstant.updateMTRefInitValue,
|
|
303
|
+
ElementTemplateLifecycleConstant.update,
|
|
304
|
+
]);
|
|
305
|
+
expect(dispatch.mock.calls[0]![0].data).toBe(JSON.stringify([[2, 'next-ref']]));
|
|
306
|
+
expect(parseElementTemplateUpdateEventPayload(dispatch.mock.calls[1]![0].data)).toMatchObject({
|
|
307
|
+
ops: createRawTextOps(2, 'next-commit'),
|
|
308
|
+
});
|
|
309
|
+
expect(parseElementTemplateUpdateEventPayload(dispatch.mock.calls[1]![0].data).delayedRunOnMainThreadData)
|
|
310
|
+
.toBeUndefined();
|
|
311
|
+
|
|
312
|
+
vi.advanceTimersByTime(10000);
|
|
313
|
+
expect(backgroundElementTemplateInstanceManager.get(removedRoot.instanceId)).toBeUndefined();
|
|
314
|
+
} finally {
|
|
315
|
+
vi.useRealTimers();
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
it('cleans a failed ref initialization commit before hydration', () => {
|
|
321
|
+
const circularValue: { self?: unknown } = {};
|
|
322
|
+
circularValue.self = circularValue;
|
|
323
|
+
new MainThreadRef(circularValue);
|
|
254
324
|
const ref = vi.fn();
|
|
255
|
-
|
|
325
|
+
queueRefAttrUpdate(null, ref, { instanceId: -2 }, 0);
|
|
326
|
+
globalCommitContext.ops = createRawTextOps(1, 'failed');
|
|
327
|
+
enqueueDelayedRunOnMainThreadData({
|
|
328
|
+
worklet: { _wkltId: 'failed-ref-init' },
|
|
329
|
+
params: [],
|
|
330
|
+
resolveId: onFunctionCall(vi.fn()),
|
|
331
|
+
});
|
|
256
332
|
const removeEventListener = vi.spyOn(lynx.getCoreContext(), 'removeEventListener');
|
|
257
333
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
worklet: { _wkltId: 'failed-serialize-main-thread-function' },
|
|
265
|
-
params: [],
|
|
266
|
-
resolveId: onFunctionCall(vi.fn()),
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
expect(() => options.__c?.({} as unknown as object, [])).toThrow(serializeError);
|
|
270
|
-
expect(takeDelayedRunOnMainThreadData()).toEqual([]);
|
|
271
|
-
expect(removeEventListener).toHaveBeenCalledWith(WorkletEvents.FunctionCallRet, expect.any(Function));
|
|
272
|
-
expect(globalCommitContext.ops).toEqual([]);
|
|
273
|
-
expect([...globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown]).toEqual([]);
|
|
274
|
-
|
|
275
|
-
options.__c?.({} as unknown as object, []);
|
|
276
|
-
expect(ref).not.toHaveBeenCalled();
|
|
277
|
-
|
|
278
|
-
vi.advanceTimersByTime(10000);
|
|
279
|
-
expect(backgroundElementTemplateInstanceManager.get(removedRoot.instanceId)).toBeUndefined();
|
|
280
|
-
} finally {
|
|
281
|
-
vi.useRealTimers();
|
|
282
|
-
}
|
|
334
|
+
expect(() => options.__c?.({} as unknown as object, [])).toThrow(TypeError);
|
|
335
|
+
expect(globalCommitContext.ops).toEqual([]);
|
|
336
|
+
expect(takeDelayedRunOnMainThreadData()).toEqual([]);
|
|
337
|
+
expect(removeEventListener).toHaveBeenCalledWith(WorkletEvents.FunctionCallRet, expect.any(Function));
|
|
338
|
+
options.__c?.({} as unknown as object, []);
|
|
339
|
+
expect(ref).not.toHaveBeenCalled();
|
|
283
340
|
});
|
|
284
341
|
|
|
285
342
|
it('dispatches triggerDataUpdated when useInitData observes a data change', () => {
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
installElementTemplateRefInitValueListener,
|
|
8
|
+
resetElementTemplateRefInitValueListener,
|
|
9
|
+
} from '../../../../../src/element-template/main-thread-ref-init-value.js';
|
|
6
10
|
import { fileURLToPath } from 'node:url';
|
|
7
11
|
|
|
8
12
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -104,6 +108,7 @@ describe('Compiled runOnMainThread background fixtures', () => {
|
|
|
104
108
|
vi.stubGlobal('__LoadLepusChunk', vi.fn());
|
|
105
109
|
|
|
106
110
|
envManager.switchToMainThread();
|
|
111
|
+
installElementTemplateRefInitValueListener();
|
|
107
112
|
installElementTemplatePatchListener();
|
|
108
113
|
lynx.getJSContext().addEventListener(ElementTemplateLifecycleConstant.update, onUpdate);
|
|
109
114
|
envManager.switchToBackground();
|
|
@@ -113,6 +118,7 @@ describe('Compiled runOnMainThread background fixtures', () => {
|
|
|
113
118
|
envManager.switchToMainThread();
|
|
114
119
|
lynx.getJSContext().removeEventListener(ElementTemplateLifecycleConstant.update, onUpdate);
|
|
115
120
|
resetElementTemplatePatchListener();
|
|
121
|
+
resetElementTemplateRefInitValueListener();
|
|
116
122
|
envManager.switchToBackground();
|
|
117
123
|
resetElementTemplateHydrationListener();
|
|
118
124
|
resetElementTemplateCommitState();
|
|
@@ -137,7 +143,7 @@ describe('Compiled runOnMainThread background fixtures', () => {
|
|
|
137
143
|
}> {
|
|
138
144
|
return loadCompiledFixturePair<CompiledRunOnMainThreadModule>(
|
|
139
145
|
FIXTURE,
|
|
140
|
-
{ enableWorkletTransform: true },
|
|
146
|
+
{ enableWorkletTransform: true, envManager },
|
|
141
147
|
);
|
|
142
148
|
}
|
|
143
149
|
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { createElement, render } from 'preact';
|
|
6
|
+
import { Component } from 'preact/compat';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
installElementTemplateCommitHook,
|
|
10
|
+
markElementTemplateHydrated,
|
|
11
|
+
uninstallElementTemplateCommitHookForTesting,
|
|
12
|
+
} from '../../../../src/element-template/background/commit-hook.js';
|
|
13
|
+
import { callDestroyLifetimeFun } from '../../../../src/element-template/native/callDestroyLifetimeFun.js';
|
|
14
|
+
import { reloadBackground } from '../../../../src/element-template/native/reload-background.js';
|
|
15
|
+
import { __root } from '../../../../src/element-template/runtime/page/root-instance.js';
|
|
16
|
+
import { ElementTemplateEnvManager } from '../../test-utils/debug/envManager.js';
|
|
17
|
+
|
|
18
|
+
describe('ElementTemplate entry reload', () => {
|
|
19
|
+
const env = new ElementTemplateEnvManager();
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
env.resetEnv('background');
|
|
23
|
+
vi.stubGlobal('__EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__', true);
|
|
24
|
+
lynx[Symbol.for('__LYNX_ENTRY_SUPPORTS_RE_EVAL__')] = true;
|
|
25
|
+
installElementTemplateCommitHook();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
uninstallElementTemplateCommitHookForTesting();
|
|
30
|
+
delete lynx[Symbol.for('__LYNX_ENTRY_SUPPORTS_RE_EVAL__')];
|
|
31
|
+
vi.restoreAllMocks();
|
|
32
|
+
vi.unstubAllGlobals();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('runs old component cleanup without sending removals to the new native tree', () => {
|
|
36
|
+
const cleanup = vi.fn();
|
|
37
|
+
class Probe extends Component {
|
|
38
|
+
componentWillUnmount() {
|
|
39
|
+
cleanup();
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
return createElement('view', null, 'old page');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
__root.__jsx = createElement(Probe);
|
|
46
|
+
render(__root.__jsx, __root as never);
|
|
47
|
+
markElementTemplateHydrated();
|
|
48
|
+
const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
|
|
49
|
+
dispatch.mockClear();
|
|
50
|
+
const oldRoot = __root;
|
|
51
|
+
lynx.__initData = { retained: 'initial', count: 1 };
|
|
52
|
+
const reloadCard = vi.fn(() => {
|
|
53
|
+
expect(cleanup).toHaveBeenCalledOnce();
|
|
54
|
+
expect(oldRoot.__jsx).toBeUndefined();
|
|
55
|
+
expect(dispatch).not.toHaveBeenCalled();
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
vi.spyOn(lynx, 'getApp').mockReturnValue({ callDestroyLifetimeFun, reloadCard } as never);
|
|
59
|
+
const options = { processorName: 'reload' };
|
|
60
|
+
|
|
61
|
+
reloadBackground({ count: 2 }, options);
|
|
62
|
+
|
|
63
|
+
expect(reloadCard).toHaveBeenCalledWith({ retained: 'initial', count: 2 }, options);
|
|
64
|
+
// An already queued old globalProps rerender cannot remount its page.
|
|
65
|
+
render(oldRoot.__jsx, oldRoot as never);
|
|
66
|
+
expect(dispatch).not.toHaveBeenCalled();
|
|
67
|
+
expect(cleanup).toHaveBeenCalledOnce();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -124,4 +124,19 @@ describe('ElementTemplate update timing (background commit)', () => {
|
|
|
124
124
|
['pipelineID', 'packChangesEnd'],
|
|
125
125
|
]);
|
|
126
126
|
});
|
|
127
|
+
|
|
128
|
+
it('does not consume a previous environment timing flag during commit', () => {
|
|
129
|
+
markElementTemplateHydrated();
|
|
130
|
+
markTimingLegacy('updateSetStateTrigger', 'stale-flag');
|
|
131
|
+
|
|
132
|
+
envManager.resetEnv('background');
|
|
133
|
+
nativeMarkTiming.mockClear();
|
|
134
|
+
globalCommitContext.ops = createRawTextOps(1, 'payload');
|
|
135
|
+
|
|
136
|
+
options.__c?.({} as unknown as object, []);
|
|
137
|
+
|
|
138
|
+
envManager.switchToMainThread();
|
|
139
|
+
expect(updateEvents).toHaveLength(1);
|
|
140
|
+
expect(nativeMarkTiming).not.toHaveBeenCalled();
|
|
141
|
+
});
|
|
127
142
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installElementTemplateRefInitValueListener,
|
|
3
|
+
resetElementTemplateRefInitValueListener,
|
|
4
|
+
} from '../../../../src/element-template/main-thread-ref-init-value.js';
|
|
1
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
6
|
|
|
3
7
|
import { WorkletEvents } from '@lynx-js/react/worklet-runtime/bindings';
|
|
@@ -262,8 +266,12 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
262
266
|
isHydration: true,
|
|
263
267
|
reloadVersion: getReloadVersion(),
|
|
264
268
|
delayedRunOnMainThreadData: undefined,
|
|
265
|
-
mainThreadRefInitValuePatch: [[1, 'hydrate-init']],
|
|
266
269
|
});
|
|
270
|
+
expect(dispatchSpy.mock.calls.map(([event]) => event.type)).toEqual([
|
|
271
|
+
ElementTemplateLifecycleConstant.updateMTRefInitValue,
|
|
272
|
+
ElementTemplateLifecycleConstant.update,
|
|
273
|
+
]);
|
|
274
|
+
expect(dispatchSpy.mock.calls[0]![0].data).toBe(JSON.stringify([[1, 'hydrate-init']]));
|
|
267
275
|
expect(takeMainThreadRefInitValuePatch()).toEqual([]);
|
|
268
276
|
});
|
|
269
277
|
|
|
@@ -287,6 +295,7 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
287
295
|
new MainThreadRef('reload-init');
|
|
288
296
|
|
|
289
297
|
envManager.switchToMainThread();
|
|
298
|
+
installElementTemplateRefInitValueListener();
|
|
290
299
|
installElementTemplatePatchListener();
|
|
291
300
|
dispatchHydrate([createSerializedTemplate(after.instanceId, '_et_test')]);
|
|
292
301
|
|
|
@@ -302,6 +311,7 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
302
311
|
} finally {
|
|
303
312
|
envManager.switchToMainThread();
|
|
304
313
|
resetElementTemplatePatchListener();
|
|
314
|
+
resetElementTemplateRefInitValueListener();
|
|
305
315
|
globalThis.lynxWorkletImpl = previousWorkletImpl;
|
|
306
316
|
envManager.switchToBackground();
|
|
307
317
|
}
|
|
@@ -603,7 +613,7 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
603
613
|
}
|
|
604
614
|
});
|
|
605
615
|
|
|
606
|
-
it('resets commit state when
|
|
616
|
+
it.each(['update', 'ref', 'circular-ref', 'dispatch'])('resets hydrate commit state when %s fails', (failure) => {
|
|
607
617
|
SystemInfo.lynxSdkVersion = '4.0';
|
|
608
618
|
const serializeError = new Error('hydrate update serialization failed');
|
|
609
619
|
const oldReportError = lynx.reportError;
|
|
@@ -623,6 +633,12 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
623
633
|
envManager.switchToBackground();
|
|
624
634
|
installElementTemplateHydrationListener();
|
|
625
635
|
const removeEventListener = vi.spyOn(lynx.getCoreContext(), 'removeEventListener');
|
|
636
|
+
const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
|
|
637
|
+
if (failure === 'dispatch') {
|
|
638
|
+
dispatch.mockImplementationOnce(() => {
|
|
639
|
+
throw serializeError;
|
|
640
|
+
});
|
|
641
|
+
}
|
|
626
642
|
|
|
627
643
|
const backgroundRoot = __root as BackgroundElementTemplateInstance;
|
|
628
644
|
const throwingValue = {
|
|
@@ -630,11 +646,19 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
630
646
|
throw serializeError;
|
|
631
647
|
},
|
|
632
648
|
} as unknown as SerializableValue;
|
|
633
|
-
const after = new BackgroundElementTemplateInstance('_et_serialize_failure', [
|
|
649
|
+
const after = new BackgroundElementTemplateInstance('_et_serialize_failure', [
|
|
650
|
+
failure === 'update' ? throwingValue : 'after',
|
|
651
|
+
eventHandler,
|
|
652
|
+
ref,
|
|
653
|
+
]);
|
|
634
654
|
backgroundRoot.appendChild(after);
|
|
635
655
|
publishEvent('-1:1:', { type: 'tap' });
|
|
636
656
|
new ElementTemplateRefProxy(after.instanceId, 2).setNativeProps({ opacity: 1 }).exec();
|
|
637
|
-
|
|
657
|
+
const circularValue: { self?: unknown } = {};
|
|
658
|
+
circularValue.self = circularValue;
|
|
659
|
+
new MainThreadRef(
|
|
660
|
+
failure === 'ref' ? throwingValue : failure === 'circular-ref' ? circularValue : 'failed-serialize-init',
|
|
661
|
+
);
|
|
638
662
|
void runOnMainThread({ _wkltId: 'failed-serialize-main-thread-function' } as unknown as () => void)();
|
|
639
663
|
|
|
640
664
|
envManager.switchToMainThread();
|
|
@@ -646,7 +670,9 @@ describe('ElementTemplate hydration listener', () => {
|
|
|
646
670
|
]);
|
|
647
671
|
|
|
648
672
|
expect(() => envManager.switchToBackground()).not.toThrow();
|
|
649
|
-
expect(reportError).
|
|
673
|
+
expect(reportError).toHaveBeenCalledExactlyOnceWith(
|
|
674
|
+
failure === 'circular-ref' ? expect.any(TypeError) : serializeError,
|
|
675
|
+
);
|
|
650
676
|
expect(globalCommitContext.ops).toEqual([]);
|
|
651
677
|
expect([...globalCommitContext.nonPayload.removedSubtreesAwaitingTeardown]).toEqual([]);
|
|
652
678
|
expect(takeMainThreadRefInitValuePatch()).toEqual([]);
|