@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
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { prepareAttributeSlots } from '../../../../src/element-template/background/attr-slots.js';
|
|
8
|
+
import type { GestureSlotValue } from '../../../../src/element-template/prop-adapters/gesture.js';
|
|
9
|
+
import {
|
|
10
|
+
hydrateGestureCallbacks,
|
|
11
|
+
prepareGestureForNative,
|
|
12
|
+
} from '../../../../src/element-template/prop-adapters/gesture.js';
|
|
13
|
+
import {
|
|
14
|
+
__etAttrPlanMap,
|
|
15
|
+
adaptGestureAttrSlot,
|
|
16
|
+
clearEtAttrPlanMap,
|
|
17
|
+
} from '../../../../src/element-template/runtime/template/attr-slot-plan.js';
|
|
18
|
+
import type { MTEventCtx } from '../../../../src/element-template/runtime/template/main-thread-event-ctx.js';
|
|
19
|
+
import { resetElementTemplateBackgroundFunctionRuntime } from '../../../../src/element-template/runtime/template/main-thread-background-function.js';
|
|
20
|
+
import {
|
|
21
|
+
clearMainThreadDynamicAttrState,
|
|
22
|
+
deleteMainThreadDynamicAttrStateForSubtree,
|
|
23
|
+
initializeMainThreadDynamicAttrSlots,
|
|
24
|
+
prepareMainThreadDynamicAttrSlotsForNative,
|
|
25
|
+
updateGestureAttrSlot,
|
|
26
|
+
} from '../../../../src/element-template/runtime/template/main-thread-dynamic-attr-state.js';
|
|
27
|
+
import { createElementTemplateWithReservedHandle } from '../../../../src/element-template/runtime/template/handle.js';
|
|
28
|
+
import { elementTemplateRegistry } from '../../../../src/element-template/runtime/template/registry.js';
|
|
29
|
+
import { applyElementTemplateUpdateCommands } from '../../../../src/element-template/runtime/patch.js';
|
|
30
|
+
import { ElementTemplateUpdateOps } from '../../../../src/element-template/protocol/opcodes.js';
|
|
31
|
+
import { JsFunctionLifecycleManager } from '../../../../src/worklet-runtime/jsFunctionLifecycle.js';
|
|
32
|
+
|
|
33
|
+
function gesture(id: number, type: number, callbacks: Record<string, MTEventCtx> = { onBegin: { _wkltId: 'begin' } }) {
|
|
34
|
+
return { __isGesture: true, id, type, config: { enabled: true }, callbacks };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function slot(...gestures: ReturnType<typeof gesture>[]) {
|
|
38
|
+
return prepareGestureForNative({ __isGesture: true, type: -1, gestures })!;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function installHydrationObserver() {
|
|
42
|
+
const previous = globalThis.lynxWorkletImpl;
|
|
43
|
+
const hydrate = vi.fn();
|
|
44
|
+
globalThis.lynxWorkletImpl = { ...previous, _hydrateCtx: hydrate };
|
|
45
|
+
return { hydrate, restore: () => globalThis.lynxWorkletImpl = previous };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
globalThis.__JS__ = true;
|
|
50
|
+
globalThis.__LEPUS__ = false;
|
|
51
|
+
globalThis.__BACKGROUND__ = true;
|
|
52
|
+
globalThis.__MAIN_THREAD__ = false;
|
|
53
|
+
clearMainThreadDynamicAttrState();
|
|
54
|
+
clearEtAttrPlanMap();
|
|
55
|
+
resetElementTemplateBackgroundFunctionRuntime();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('ET direct Gesture preparation', () => {
|
|
59
|
+
it('flattens nested composition once per detector and preserves its relationships', () => {
|
|
60
|
+
const pan = {
|
|
61
|
+
...gesture(10, 0),
|
|
62
|
+
waitFor: [{ id: 11 }],
|
|
63
|
+
simultaneousWith: [{ id: 12 }],
|
|
64
|
+
continueWith: [{ id: 13 }],
|
|
65
|
+
};
|
|
66
|
+
const tap = gesture(11, 1);
|
|
67
|
+
const prepared = prepareGestureForNative({
|
|
68
|
+
__isGesture: true,
|
|
69
|
+
type: -1,
|
|
70
|
+
gestures: [pan, { type: -1, gestures: [tap, pan] }],
|
|
71
|
+
})!;
|
|
72
|
+
|
|
73
|
+
expect(prepared.type).toBe('gesture');
|
|
74
|
+
expect(prepared.value.map(item => item.id)).toEqual([10, 11]);
|
|
75
|
+
expect(prepared.value[0]).toMatchObject({
|
|
76
|
+
type: 0,
|
|
77
|
+
config: { enabled: true },
|
|
78
|
+
relationMap: { waitFor: [11], simultaneous: [12], continueWith: [13] },
|
|
79
|
+
callbacks: [{ name: 'onBegin', callback: { _wkltId: 'begin' } }],
|
|
80
|
+
});
|
|
81
|
+
expect(prepared.value[0]!.config).not.toBe(pan.config);
|
|
82
|
+
expect(prepared.value[0]!.callbacks[0]!.callback).not.toBe(pan.callbacks.onBegin);
|
|
83
|
+
expect(pan.callbacks.onBegin).toEqual({ _wkltId: 'begin' });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it.each([null, undefined, false])('clears an absent Gesture (%s)', value => {
|
|
87
|
+
expect(adaptGestureAttrSlot(-1, 0, value)).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it.each([true, 'pan', {}, { __isGesture: false }])('rejects an invalid public Gesture value (%j)', value => {
|
|
91
|
+
expect(() => prepareGestureForNative(value)).toThrow(
|
|
92
|
+
'ElementTemplate main-thread:gesture expects a Gesture object.',
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('omits unset callbacks from a serialized Gesture descriptor', () => {
|
|
97
|
+
const prepared = prepareGestureForNative({
|
|
98
|
+
__isSerialized: true,
|
|
99
|
+
id: 1,
|
|
100
|
+
type: 0,
|
|
101
|
+
callbacks: { onBegin: null, onEnd: undefined },
|
|
102
|
+
});
|
|
103
|
+
expect(prepared).toMatchObject({ value: [{ config: {}, callbacks: [] }] });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('rejects ordinary callbacks before passing an unusable detector to Native', () => {
|
|
107
|
+
expect(() =>
|
|
108
|
+
prepareGestureForNative({
|
|
109
|
+
...gesture(1, 0),
|
|
110
|
+
callbacks: { onBegin: () => {} },
|
|
111
|
+
})
|
|
112
|
+
).toThrow('Gesture callback \'onBegin\' must be a main-thread function.');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('reuses delivered callback contexts during repeated preparation while observing mutable configuration', () => {
|
|
116
|
+
const previousFlags = {
|
|
117
|
+
js: globalThis.__JS__,
|
|
118
|
+
lepus: globalThis.__LEPUS__,
|
|
119
|
+
background: globalThis.__BACKGROUND__,
|
|
120
|
+
main: globalThis.__MAIN_THREAD__,
|
|
121
|
+
};
|
|
122
|
+
const previousSdk = SystemInfo.lynxSdkVersion;
|
|
123
|
+
globalThis.__JS__ = true;
|
|
124
|
+
globalThis.__LEPUS__ = false;
|
|
125
|
+
globalThis.__BACKGROUND__ = true;
|
|
126
|
+
globalThis.__MAIN_THREAD__ = false;
|
|
127
|
+
SystemInfo.lynxSdkVersion = '4.0';
|
|
128
|
+
__etAttrPlanMap.gesture = [0, adaptGestureAttrSlot];
|
|
129
|
+
const raw = { ...gesture(1, 0), waitFor: [{ id: 2 }] };
|
|
130
|
+
const rawSlots = [raw];
|
|
131
|
+
try {
|
|
132
|
+
const initial = prepareAttributeSlots('gesture', 17, rawSlots);
|
|
133
|
+
const first = (initial[0] as unknown as GestureSlotValue).value[0]!;
|
|
134
|
+
const firstCallback = first.callbacks[0]!.callback;
|
|
135
|
+
expect(firstCallback._execId).toEqual(expect.any(Number));
|
|
136
|
+
const hydration = prepareAttributeSlots('gesture', 17, rawSlots, {
|
|
137
|
+
previousPreparedSlots: initial,
|
|
138
|
+
previousRawSlots: rawSlots,
|
|
139
|
+
});
|
|
140
|
+
expect((hydration[0] as unknown as GestureSlotValue).value[0]!.callbacks[0]!.callback).toBe(firstCallback);
|
|
141
|
+
raw.config.enabled = false;
|
|
142
|
+
raw.waitFor.push({ id: 3 });
|
|
143
|
+
const create = prepareAttributeSlots('gesture', 17, rawSlots, {
|
|
144
|
+
previousPreparedSlots: hydration,
|
|
145
|
+
previousRawSlots: rawSlots,
|
|
146
|
+
});
|
|
147
|
+
const created = (create[0] as unknown as GestureSlotValue).value[0]!;
|
|
148
|
+
expect(created.callbacks[0]!.callback).toBe(firstCallback);
|
|
149
|
+
expect(created.callbacks[0]!.callback._execId).toBe(firstCallback._execId);
|
|
150
|
+
expect(created.config.enabled).toBe(false);
|
|
151
|
+
expect(created.relationMap.waitFor).toEqual([2, 3]);
|
|
152
|
+
expect(first.config.enabled).toBe(true);
|
|
153
|
+
expect(first.relationMap.waitFor).toEqual([2]);
|
|
154
|
+
raw.callbacks.onBegin = { _wkltId: 'replacement' };
|
|
155
|
+
const changed = prepareAttributeSlots('gesture', 17, rawSlots, {
|
|
156
|
+
previousPreparedSlots: create,
|
|
157
|
+
previousRawSlots: rawSlots,
|
|
158
|
+
});
|
|
159
|
+
const changedCallback = (changed[0] as unknown as GestureSlotValue).value[0]!.callbacks[0]!.callback;
|
|
160
|
+
expect(changedCallback).not.toBe(firstCallback);
|
|
161
|
+
expect(changedCallback._execId).not.toBe(firstCallback._execId);
|
|
162
|
+
expect(changedCallback._wkltId).toBe('replacement');
|
|
163
|
+
expect(raw.callbacks.onBegin).not.toHaveProperty('_execId');
|
|
164
|
+
} finally {
|
|
165
|
+
globalThis.__JS__ = previousFlags.js;
|
|
166
|
+
globalThis.__LEPUS__ = previousFlags.lepus;
|
|
167
|
+
globalThis.__BACKGROUND__ = previousFlags.background;
|
|
168
|
+
globalThis.__MAIN_THREAD__ = previousFlags.main;
|
|
169
|
+
SystemInfo.lynxSdkVersion = previousSdk;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('registers each prepared callback without adding exec IDs to the authored Gesture', () => {
|
|
174
|
+
const previousJs = globalThis.__JS__;
|
|
175
|
+
const previousLepus = globalThis.__LEPUS__;
|
|
176
|
+
const previousBackground = globalThis.__BACKGROUND__;
|
|
177
|
+
const previousMain = globalThis.__MAIN_THREAD__;
|
|
178
|
+
const previousSdk = SystemInfo.lynxSdkVersion;
|
|
179
|
+
globalThis.__JS__ = true;
|
|
180
|
+
globalThis.__LEPUS__ = false;
|
|
181
|
+
globalThis.__BACKGROUND__ = true;
|
|
182
|
+
globalThis.__MAIN_THREAD__ = false;
|
|
183
|
+
SystemInfo.lynxSdkVersion = '4.0';
|
|
184
|
+
const raw = gesture(1, 0, { onBegin: { _wkltId: 'begin' } });
|
|
185
|
+
try {
|
|
186
|
+
const prepared = prepareGestureForNative(raw)!;
|
|
187
|
+
expect(prepared.value[0]!.callbacks[0]!.callback._execId).toEqual(expect.any(Number));
|
|
188
|
+
expect(raw.callbacks.onBegin).not.toHaveProperty('_execId');
|
|
189
|
+
} finally {
|
|
190
|
+
globalThis.__JS__ = previousJs;
|
|
191
|
+
globalThis.__LEPUS__ = previousLepus;
|
|
192
|
+
globalThis.__BACKGROUND__ = previousBackground;
|
|
193
|
+
globalThis.__MAIN_THREAD__ = previousMain;
|
|
194
|
+
SystemInfo.lynxSdkVersion = previousSdk;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe('ET Gesture callback handoff and lifecycle', () => {
|
|
200
|
+
it.each(
|
|
201
|
+
[
|
|
202
|
+
['reserved', 'success'],
|
|
203
|
+
['reserved', 'null'],
|
|
204
|
+
['reserved', 'throw'],
|
|
205
|
+
['patch', 'success'],
|
|
206
|
+
['patch', 'null'],
|
|
207
|
+
['patch', 'throw'],
|
|
208
|
+
] as const,
|
|
209
|
+
)('tracks %s create callbacks before Native %s without committing failed state', (mode, outcome) => {
|
|
210
|
+
const previous = globalThis.lynxWorkletImpl;
|
|
211
|
+
const manager = new JsFunctionLifecycleManager();
|
|
212
|
+
const hydrate = vi.fn();
|
|
213
|
+
globalThis.lynxWorkletImpl = { ...previous, _jsFunctionLifecycleManager: manager, _hydrateCtx: hydrate };
|
|
214
|
+
const first = slot(gesture(1, 0, { onBegin: { _wkltId: 'begin' }, onEnd: { _wkltId: 'end' } }));
|
|
215
|
+
first.value[0]!.callbacks[0]!.callback._execId = 41;
|
|
216
|
+
first.value[0]!.callbacks[1]!.callback._execId = 42;
|
|
217
|
+
const retain = vi.spyOn(manager, 'addRef');
|
|
218
|
+
const nativeRef = {} as ElementTemplateHandle;
|
|
219
|
+
const error = new Error('create failed');
|
|
220
|
+
__etAttrPlanMap['__Card__:_et_gesture_reject'] = [0, adaptGestureAttrSlot];
|
|
221
|
+
const create = vi.spyOn(globalThis, '__CreateElementTemplate').mockImplementationOnce((_key, _url, slots) => {
|
|
222
|
+
expect(slots![0]).toBe(first);
|
|
223
|
+
expect(retain).toHaveBeenCalledWith(41, first.value[0]!.callbacks[0]!.callback);
|
|
224
|
+
expect(retain).toHaveBeenCalledWith(42, first.value[0]!.callbacks[1]!.callback);
|
|
225
|
+
expect(elementTemplateRegistry.has(17)).toBe(false);
|
|
226
|
+
if (outcome === 'throw') throw error;
|
|
227
|
+
return outcome === 'null' ? null : nativeRef;
|
|
228
|
+
});
|
|
229
|
+
try {
|
|
230
|
+
const apply = () =>
|
|
231
|
+
mode === 'reserved'
|
|
232
|
+
? createElementTemplateWithReservedHandle(17, '_et_gesture_reject', null, [first], null)
|
|
233
|
+
: applyElementTemplateUpdateCommands([
|
|
234
|
+
ElementTemplateUpdateOps.createTemplate,
|
|
235
|
+
17,
|
|
236
|
+
'_et_gesture_reject',
|
|
237
|
+
null,
|
|
238
|
+
[first],
|
|
239
|
+
null,
|
|
240
|
+
]);
|
|
241
|
+
if (outcome === 'throw') expect(apply).toThrow(error);
|
|
242
|
+
else apply();
|
|
243
|
+
expect(retain).toHaveBeenCalledTimes(2);
|
|
244
|
+
expect(elementTemplateRegistry.has(17)).toBe(outcome === 'success');
|
|
245
|
+
const probe = slot(gesture(2, 0));
|
|
246
|
+
updateGestureAttrSlot(17, 0, probe, true);
|
|
247
|
+
if (outcome === 'success') {
|
|
248
|
+
expect(hydrate).toHaveBeenCalledExactlyOnceWith(
|
|
249
|
+
probe.value[0]!.callbacks[0]!.callback,
|
|
250
|
+
first.value[0]!.callbacks[0]!.callback,
|
|
251
|
+
);
|
|
252
|
+
} else expect(hydrate).not.toHaveBeenCalled();
|
|
253
|
+
} finally {
|
|
254
|
+
create.mockRestore();
|
|
255
|
+
elementTemplateRegistry.delete(17);
|
|
256
|
+
manager.dispose();
|
|
257
|
+
globalThis.lynxWorkletImpl = previous;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it.each([false, true])('tracks setter callbacks before Native and preserves failed state (throws=%s)', throws => {
|
|
262
|
+
const previous = globalThis.lynxWorkletImpl;
|
|
263
|
+
const manager = new JsFunctionLifecycleManager();
|
|
264
|
+
const hydrate = vi.fn();
|
|
265
|
+
globalThis.lynxWorkletImpl = { ...previous, _jsFunctionLifecycleManager: manager, _hydrateCtx: hydrate };
|
|
266
|
+
const first = slot(gesture(1, 0));
|
|
267
|
+
const next = slot(gesture(2, 0));
|
|
268
|
+
const probe = slot(gesture(3, 0));
|
|
269
|
+
next.value[0]!.callbacks[0]!.callback._execId = 51;
|
|
270
|
+
updateGestureAttrSlot(17, 0, first);
|
|
271
|
+
elementTemplateRegistry.set(17, {} as ElementTemplateHandle);
|
|
272
|
+
const retain = vi.spyOn(manager, 'addRef');
|
|
273
|
+
const error = new Error('setter failed');
|
|
274
|
+
const setter = vi.spyOn(globalThis, '__SetAttributeOfElementTemplate').mockImplementationOnce(
|
|
275
|
+
(_handle, _slot, value) => {
|
|
276
|
+
expect(value).toBe(next);
|
|
277
|
+
expect(retain).toHaveBeenCalledExactlyOnceWith(51, next.value[0]!.callbacks[0]!.callback);
|
|
278
|
+
expect(hydrate).not.toHaveBeenCalled();
|
|
279
|
+
if (throws) throw error;
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
try {
|
|
283
|
+
const apply = () => applyElementTemplateUpdateCommands([ElementTemplateUpdateOps.setGesture, 17, 0, next], true);
|
|
284
|
+
if (throws) expect(apply).toThrow(error);
|
|
285
|
+
else apply();
|
|
286
|
+
expect(retain).toHaveBeenCalledExactlyOnceWith(51, next.value[0]!.callbacks[0]!.callback);
|
|
287
|
+
if (throws) expect(hydrate).not.toHaveBeenCalled();
|
|
288
|
+
else {expect(hydrate).toHaveBeenCalledExactlyOnceWith(
|
|
289
|
+
next.value[0]!.callbacks[0]!.callback,
|
|
290
|
+
first.value[0]!.callbacks[0]!.callback,
|
|
291
|
+
);}
|
|
292
|
+
hydrate.mockClear();
|
|
293
|
+
updateGestureAttrSlot(17, 0, probe, true);
|
|
294
|
+
expect(hydrate).toHaveBeenCalledExactlyOnceWith(
|
|
295
|
+
probe.value[0]!.callbacks[0]!.callback,
|
|
296
|
+
(throws ? first : next).value[0]!.callbacks[0]!.callback,
|
|
297
|
+
);
|
|
298
|
+
} finally {
|
|
299
|
+
setter.mockRestore();
|
|
300
|
+
elementTemplateRegistry.delete(17);
|
|
301
|
+
manager.dispose();
|
|
302
|
+
globalThis.lynxWorkletImpl = previous;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('does not mistake colliding IDs allocated on different threads for callback identity', () => {
|
|
307
|
+
const previous = slot(gesture(1, 0), gesture(2, 1));
|
|
308
|
+
const next = slot(gesture(2, 0), gesture(3, 1));
|
|
309
|
+
const { hydrate, restore } = installHydrationObserver();
|
|
310
|
+
try {
|
|
311
|
+
hydrateGestureCallbacks(next, previous);
|
|
312
|
+
expect(hydrate.mock.calls).toEqual([
|
|
313
|
+
[next.value[0]!.callbacks[0]!.callback, previous.value[0]!.callbacks[0]!.callback],
|
|
314
|
+
[next.value[1]!.callbacks[0]!.callback, previous.value[1]!.callbacks[0]!.callback],
|
|
315
|
+
]);
|
|
316
|
+
} finally {
|
|
317
|
+
restore();
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('pairs reordered gesture types and callback names without moving state between detector kinds', () => {
|
|
322
|
+
const previous = slot(gesture(1, 0), gesture(2, 1));
|
|
323
|
+
const next = slot(gesture(1, 1), gesture(2, 0));
|
|
324
|
+
const { hydrate, restore } = installHydrationObserver();
|
|
325
|
+
try {
|
|
326
|
+
hydrateGestureCallbacks(next, previous);
|
|
327
|
+
expect(hydrate.mock.calls).toEqual([
|
|
328
|
+
[next.value[0]!.callbacks[0]!.callback, previous.value[1]!.callbacks[0]!.callback],
|
|
329
|
+
[next.value[1]!.callbacks[0]!.callback, previous.value[0]!.callbacks[0]!.callback],
|
|
330
|
+
]);
|
|
331
|
+
} finally {
|
|
332
|
+
restore();
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('hands off repeated detector types in declaration order without reusing an earlier callback', () => {
|
|
337
|
+
const previous = slot(
|
|
338
|
+
gesture(1, 0, { onBegin: { _wkltId: 'first-pan' } }),
|
|
339
|
+
gesture(2, 0, { onBegin: { _wkltId: 'second-pan' } }),
|
|
340
|
+
);
|
|
341
|
+
const next = slot(
|
|
342
|
+
gesture(3, 0, { onBegin: { _wkltId: 'first-pan' } }),
|
|
343
|
+
gesture(4, 0, { onBegin: { _wkltId: 'second-pan' } }),
|
|
344
|
+
);
|
|
345
|
+
const { hydrate, restore } = installHydrationObserver();
|
|
346
|
+
try {
|
|
347
|
+
hydrateGestureCallbacks(next, previous);
|
|
348
|
+
expect(hydrate.mock.calls).toEqual([
|
|
349
|
+
[next.value[0]!.callbacks[0]!.callback, previous.value[0]!.callbacks[0]!.callback],
|
|
350
|
+
[next.value[1]!.callbacks[0]!.callback, previous.value[1]!.callbacks[0]!.callback],
|
|
351
|
+
]);
|
|
352
|
+
} finally {
|
|
353
|
+
restore();
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
it('hands off callbacks by name and leaves new callbacks and new detector kinds unhydrated', () => {
|
|
358
|
+
const previous = slot(gesture(1, 0, { onBegin: { _wkltId: 'begin' }, onEnd: { _wkltId: 'end' } }));
|
|
359
|
+
const next = slot(
|
|
360
|
+
gesture(2, 0, { onEnd: { _wkltId: 'end' }, onBegin: { _wkltId: 'begin' }, onUpdate: { _wkltId: 'update' } }),
|
|
361
|
+
gesture(3, 1),
|
|
362
|
+
);
|
|
363
|
+
const { hydrate, restore } = installHydrationObserver();
|
|
364
|
+
try {
|
|
365
|
+
hydrateGestureCallbacks(next, previous);
|
|
366
|
+
expect(hydrate.mock.calls).toEqual([
|
|
367
|
+
[next.value[0]!.callbacks[0]!.callback, previous.value[0]!.callbacks[1]!.callback],
|
|
368
|
+
[next.value[0]!.callbacks[1]!.callback, previous.value[0]!.callbacks[0]!.callback],
|
|
369
|
+
]);
|
|
370
|
+
} finally {
|
|
371
|
+
restore();
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('retains all initial native callback contexts and hydrates only the current slot value', () => {
|
|
376
|
+
const previousRuntime = globalThis.lynxWorkletImpl;
|
|
377
|
+
const addRef = vi.fn();
|
|
378
|
+
const hydrate = vi.fn();
|
|
379
|
+
globalThis.lynxWorkletImpl = {
|
|
380
|
+
...previousRuntime,
|
|
381
|
+
_hydrateCtx: hydrate,
|
|
382
|
+
_jsFunctionLifecycleManager: { addRef },
|
|
383
|
+
} as typeof globalThis.lynxWorkletImpl;
|
|
384
|
+
const first = slot(gesture(1, 0, { onBegin: { _wkltId: 'begin' }, onEnd: { _wkltId: 'end' } }));
|
|
385
|
+
first.value[0]!.callbacks[0]!.callback._execId = 41;
|
|
386
|
+
first.value[0]!.callbacks[1]!.callback._execId = 42;
|
|
387
|
+
const updated = slot(gesture(2, 0));
|
|
388
|
+
const hydrated = slot(gesture(3, 0));
|
|
389
|
+
__etAttrPlanMap.gesture = [0, adaptGestureAttrSlot];
|
|
390
|
+
try {
|
|
391
|
+
prepareMainThreadDynamicAttrSlotsForNative('gesture', [first]);
|
|
392
|
+
initializeMainThreadDynamicAttrSlots(17, 'gesture', [first]);
|
|
393
|
+
expect(addRef).toHaveBeenCalledWith(41, first.value[0]!.callbacks[0]!.callback);
|
|
394
|
+
expect(addRef).toHaveBeenCalledWith(42, first.value[0]!.callbacks[1]!.callback);
|
|
395
|
+
updateGestureAttrSlot(17, 0, updated);
|
|
396
|
+
expect(hydrate).not.toHaveBeenCalled();
|
|
397
|
+
updateGestureAttrSlot(17, 0, hydrated, true);
|
|
398
|
+
expect(hydrate).toHaveBeenCalledWith(
|
|
399
|
+
hydrated.value[0]!.callbacks[0]!.callback,
|
|
400
|
+
updated.value[0]!.callbacks[0]!.callback,
|
|
401
|
+
);
|
|
402
|
+
} finally {
|
|
403
|
+
globalThis.lynxWorkletImpl = previousRuntime;
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it.each(['null', 'subtree', 'runtime'] as const)('drops stale first-screen callback state after %s cleanup', mode => {
|
|
408
|
+
const { hydrate, restore } = installHydrationObserver();
|
|
409
|
+
try {
|
|
410
|
+
updateGestureAttrSlot(17, 0, slot(gesture(1, 0)));
|
|
411
|
+
if (mode === 'null') updateGestureAttrSlot(17, 0, null);
|
|
412
|
+
if (mode === 'subtree') deleteMainThreadDynamicAttrStateForSubtree([17]);
|
|
413
|
+
if (mode === 'runtime') clearMainThreadDynamicAttrState();
|
|
414
|
+
updateGestureAttrSlot(17, 0, slot(gesture(2, 0)), true);
|
|
415
|
+
expect(hydrate).not.toHaveBeenCalled();
|
|
416
|
+
} finally {
|
|
417
|
+
restore();
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
});
|