@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.
Files changed (282) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +3 -4
  4. package/refresh/.turbo/turbo-build.log +1 -1
  5. package/runtime/__test__/core/globalProps.test.ts +27 -6
  6. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +1 -1
  7. package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
  8. package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
  9. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +7 -6
  10. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +1 -2
  11. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
  12. package/runtime/__test__/element-template/native/main-thread-api.test.ts +5 -2
  13. package/runtime/__test__/element-template/native/mts-destroy.test.ts +88 -0
  14. package/runtime/__test__/element-template/native/reload-dual-thread-communication.test.ts +3 -0
  15. package/runtime/__test__/element-template/native/reload.test.ts +118 -2
  16. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
  17. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
  18. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
  19. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
  20. package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
  21. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +15 -0
  22. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +212 -7
  23. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +4 -1
  24. package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
  25. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
  26. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
  27. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
  28. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
  29. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +4 -1
  30. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +4 -1
  31. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +101 -1
  32. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +32 -0
  33. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +309 -26
  34. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +8 -5
  35. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +35 -2
  36. package/runtime/__test__/guardrails/snapshot-containment.test.ts +45 -11
  37. package/runtime/__test__/shared/component-stack.test.ts +211 -0
  38. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +0 -8
  39. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +1 -1
  40. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  41. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  42. package/runtime/__test__/snapshot/lynx/timing.test.jsx +3 -0
  43. package/runtime/__test__/snapshot/preact.test.jsx +0 -3
  44. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  45. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +0 -33
  46. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +12 -0
  47. package/runtime/__test__/worklet-runtime/loadRuntime.test.js +68 -0
  48. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +30 -0
  49. package/runtime/lazy/element-template-internal.js +1 -1
  50. package/runtime/lazy/internal.js +1 -1
  51. package/runtime/lazy/jsx-dev-runtime.js +1 -1
  52. package/runtime/lazy/jsx-runtime.js +1 -1
  53. package/runtime/lazy/legacy-react-runtime.js +1 -1
  54. package/runtime/lazy/react-lepus.js +1 -1
  55. package/runtime/lazy/react.js +1 -1
  56. package/runtime/lib/core/capture-main-thread-object.js +2 -1
  57. package/runtime/lib/core/capture-main-thread-object.js.map +1 -1
  58. package/runtime/lib/core/compat/legacy-react-runtime.js +1 -1
  59. package/runtime/lib/core/compat/legacy-react-runtime.js.map +1 -1
  60. package/runtime/lib/core/globalProps.js +1 -1
  61. package/runtime/lib/core/globalProps.js.map +1 -1
  62. package/runtime/lib/core/lynx/lazy-bundle.js +1 -1
  63. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  64. package/runtime/lib/core/lynx-data-processors.d.ts +125 -1
  65. package/runtime/lib/core/lynx-data-processors.js +3 -0
  66. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  67. package/runtime/lib/core/runtime-destroy.js +1 -1
  68. package/runtime/lib/core/runtime-destroy.js.map +1 -1
  69. package/runtime/lib/document.js +0 -5
  70. package/runtime/lib/document.js.map +1 -1
  71. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  72. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  73. package/runtime/lib/element-template/background/commit-hook.js +11 -12
  74. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  75. package/runtime/lib/element-template/background/destroy.js +16 -11
  76. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  77. package/runtime/lib/element-template/background/hydrate.js +23 -0
  78. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  79. package/runtime/lib/element-template/client/root.d.ts +1 -1
  80. package/runtime/lib/element-template/client/root.js.map +1 -1
  81. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  82. package/runtime/lib/element-template/debug/alog.js +4 -1
  83. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  84. package/runtime/lib/element-template/index.d.ts +2 -2
  85. package/runtime/lib/element-template/index.js.map +1 -1
  86. package/runtime/lib/element-template/internal.d.ts +2 -2
  87. package/runtime/lib/element-template/internal.js +1 -14
  88. package/runtime/lib/element-template/internal.js.map +1 -1
  89. package/runtime/lib/element-template/lynx/env.js.map +1 -1
  90. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  91. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  92. package/runtime/lib/element-template/native/flush.d.ts +1 -0
  93. package/runtime/lib/element-template/native/flush.js +9 -0
  94. package/runtime/lib/element-template/native/flush.js.map +1 -0
  95. package/runtime/lib/element-template/native/main-thread-api.js +3 -7
  96. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  97. package/runtime/lib/element-template/native/mts-destroy.js +8 -2
  98. package/runtime/lib/element-template/native/mts-destroy.js.map +1 -1
  99. package/runtime/lib/element-template/native/patch-listener.js +57 -50
  100. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  101. package/runtime/lib/element-template/native/reload-background.js +1 -1
  102. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  103. package/runtime/lib/element-template/native/reload-main-thread.js +35 -10
  104. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  105. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  106. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  107. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  108. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  109. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  110. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  111. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  112. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  113. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  114. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  115. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  116. package/runtime/lib/element-template/runtime/page/root-instance.d.ts +0 -1
  117. package/runtime/lib/element-template/runtime/page/root-instance.js.map +1 -1
  118. package/runtime/lib/element-template/runtime/patch.js +31 -2
  119. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  120. package/runtime/lib/element-template/runtime/render/render-components.js +4 -4
  121. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -1
  122. package/runtime/lib/element-template/runtime/render/render-main-thread.js +2 -0
  123. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  124. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  125. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  126. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  127. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js +8 -1
  128. package/runtime/lib/element-template/runtime/template/main-thread-background-function.js.map +1 -1
  129. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -1
  130. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +380 -50
  131. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  132. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +3 -2
  133. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  134. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  135. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  136. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  137. package/runtime/lib/internal.d.ts +1 -1
  138. package/runtime/lib/internal.js +1 -1
  139. package/runtime/lib/internal.js.map +1 -1
  140. package/runtime/lib/lynx-api.d.ts +2 -125
  141. package/runtime/lib/lynx-api.js.map +1 -1
  142. package/runtime/lib/shared/component-stack.d.ts +0 -4
  143. package/runtime/lib/shared/component-stack.js +21 -5
  144. package/runtime/lib/shared/component-stack.js.map +1 -1
  145. package/runtime/lib/snapshot/gesture/{processGestureBagkround.js → processGestureBackground.js} +1 -1
  146. package/runtime/lib/snapshot/gesture/processGestureBackground.js.map +1 -0
  147. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  148. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  149. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.d.ts +0 -1
  150. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js +0 -5
  151. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -1
  152. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +0 -10
  153. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  154. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +56 -51
  155. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  156. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  157. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  158. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  159. package/runtime/lib/snapshot/list/listUpdateInfo.js +0 -30
  160. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  161. package/runtime/lib/snapshot/lynx/calledByNative.js +11 -8
  162. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  163. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +0 -52
  164. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  165. package/runtime/lib/snapshot/renderToOpcodes/index.js +10 -10
  166. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  167. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +0 -51
  168. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  169. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +1 -1
  170. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  171. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  172. package/runtime/lib/worklet-runtime/bindings/index.d.ts +1 -0
  173. package/runtime/lib/worklet-runtime/bindings/index.js +1 -0
  174. package/runtime/lib/worklet-runtime/bindings/index.js.map +1 -1
  175. package/runtime/lib/worklet-runtime/bindings/loadRuntime.d.ts +8 -0
  176. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js +23 -0
  177. package/runtime/lib/worklet-runtime/bindings/loadRuntime.js.map +1 -0
  178. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.d.ts +2 -0
  179. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js +6 -0
  180. package/runtime/lib/worklet-runtime/jsFunctionLifecycle.js.map +1 -1
  181. package/runtime/lib/worklet-runtime/workletRuntime.js +2 -0
  182. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  183. package/runtime/package.json +2 -3
  184. package/runtime/src/core/capture-main-thread-object.ts +2 -1
  185. package/runtime/src/core/compat/legacy-react-runtime.ts +1 -1
  186. package/runtime/src/core/globalProps.ts +1 -1
  187. package/runtime/src/core/lynx/lazy-bundle.ts +1 -1
  188. package/runtime/src/core/lynx-data-processors.ts +124 -1
  189. package/runtime/src/core/runtime-destroy.ts +1 -1
  190. package/runtime/src/document.ts +0 -6
  191. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  192. package/runtime/src/element-template/background/commit-hook.ts +18 -12
  193. package/runtime/src/element-template/background/destroy.ts +16 -13
  194. package/runtime/src/element-template/background/hydrate.ts +23 -0
  195. package/runtime/src/element-template/client/root.ts +1 -3
  196. package/runtime/src/element-template/debug/alog.ts +5 -2
  197. package/runtime/src/element-template/index.ts +2 -2
  198. package/runtime/src/element-template/internal.ts +1 -20
  199. package/runtime/src/element-template/lynx/env.ts +1 -1
  200. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  201. package/runtime/src/element-template/native/flush.ts +10 -0
  202. package/runtime/src/element-template/native/main-thread-api.ts +3 -6
  203. package/runtime/src/element-template/native/mts-destroy.ts +7 -2
  204. package/runtime/src/element-template/native/patch-listener.ts +62 -57
  205. package/runtime/src/element-template/native/reload-background.ts +1 -1
  206. package/runtime/src/element-template/native/reload-main-thread.ts +32 -11
  207. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  208. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  209. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  210. package/runtime/src/element-template/protocol/types.ts +8 -13
  211. package/runtime/src/element-template/runtime/page/root-instance.ts +0 -1
  212. package/runtime/src/element-template/runtime/patch.ts +38 -0
  213. package/runtime/src/element-template/runtime/render/render-components.ts +3 -3
  214. package/runtime/src/element-template/runtime/render/render-main-thread.ts +2 -0
  215. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  216. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +8 -1
  217. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +456 -50
  218. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +14 -4
  219. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  220. package/runtime/src/element-template/types.d.ts +6 -0
  221. package/runtime/src/internal.ts +1 -1
  222. package/runtime/src/lynx-api.ts +2 -124
  223. package/runtime/src/shared/component-stack.ts +22 -5
  224. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  225. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +0 -5
  226. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +0 -10
  227. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +62 -58
  228. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  229. package/runtime/src/snapshot/list/listUpdateInfo.ts +0 -52
  230. package/runtime/src/snapshot/lynx/calledByNative.ts +11 -9
  231. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +0 -58
  232. package/runtime/src/snapshot/renderToOpcodes/index.ts +8 -8
  233. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +0 -57
  234. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +1 -1
  235. package/runtime/src/worklet-runtime/README.md +30 -10
  236. package/runtime/src/worklet-runtime/bindings/index.ts +2 -0
  237. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  238. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +6 -0
  239. package/runtime/src/worklet-runtime/workletRuntime.ts +2 -0
  240. package/runtime/types/types.d.ts +2 -1
  241. package/runtime/vitest.config.ts +0 -2
  242. package/testing-library/.turbo/turbo-build.log +7 -7
  243. package/testing-library/src/__tests__/act.test.jsx +0 -7
  244. package/testing-library/src/__tests__/alog.test.jsx +12 -54
  245. package/testing-library/src/__tests__/end-to-end.test.jsx +0 -7
  246. package/testing-library/src/__tests__/renderComponent.test.jsx +0 -14
  247. package/testing-library/src/__tests__/worklet.test.jsx +49 -0
  248. package/transform/.turbo/turbo-build$colon$wasm.log +133 -297
  249. package/transform/__test__/defines.spec.js +30 -0
  250. package/transform/__test__/fixture.spec.js +11 -11
  251. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  252. package/transform/__test__/object-methods.spec.js +79 -0
  253. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  254. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  255. package/transform/crates/swc_plugin_worklet/extract_ident.rs +99 -49
  256. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +63 -57
  257. package/transform/crates/swc_plugin_worklet/lib.rs +393 -589
  258. package/transform/crates/swc_plugin_worklet/napi.rs +4 -6
  259. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  260. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  261. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +11 -6
  262. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +12 -6
  263. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +14 -5
  264. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +17 -6
  265. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  266. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  267. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  268. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  269. package/transform/dist/wasm.cjs +1 -1
  270. package/transform/package.json +0 -1
  271. package/transform/src/lib.rs +1 -1
  272. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +167 -69
  273. package/transform/swc-plugin-reactlynx/src/lib.rs +1 -4
  274. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  275. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +226 -132
  276. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +0 -1
  277. package/runtime/lib/snapshot/worklet/hmr.d.ts +0 -1
  278. package/runtime/lib/snapshot/worklet/hmr.js +0 -28
  279. package/runtime/lib/snapshot/worklet/hmr.js.map +0 -1
  280. package/runtime/src/snapshot/worklet/hmr.ts +0 -34
  281. /package/runtime/lib/snapshot/gesture/{processGestureBagkround.d.ts → processGestureBackground.d.ts} +0 -0
  282. /package/runtime/src/snapshot/gesture/{processGestureBagkround.ts → processGestureBackground.ts} +0 -0
@@ -0,0 +1,197 @@
1
+ import { runOnBackground, useMainThreadRef, useMemo } from '@lynx-js/react';
2
+
3
+ export interface SpreadMtsFixtureProps {
4
+ mode?: 'normal' | 'typed-page' | 'typed-list';
5
+ show?: boolean;
6
+ label?: string;
7
+ cardId?: string;
8
+ enableEvents?: boolean;
9
+ enableGesture?: boolean;
10
+ refKind?: 'none' | 'object' | 'callback';
11
+ secondSpreadMode?: 'omit' | 'override-events-gesture-ref' | 'null-ref';
12
+ onTapReport?: (source: string, label: string, count: number) => string;
13
+ onMoveReport?: (label: string, count: number) => string;
14
+ onGestureReport?: (source: string, label: string, count: number) => string;
15
+ onRefReport?: (phase: string, tag: string) => void;
16
+ }
17
+
18
+ export function App({
19
+ mode = 'normal',
20
+ show = true,
21
+ label = 'first',
22
+ cardId = 'card-1',
23
+ enableEvents = true,
24
+ enableGesture = true,
25
+ refKind = 'object',
26
+ secondSpreadMode = 'omit',
27
+ onTapReport = () => '',
28
+ onMoveReport = () => '',
29
+ onGestureReport = () => '',
30
+ onRefReport = () => {},
31
+ }: SpreadMtsFixtureProps) {
32
+ const countRef = useMainThreadRef(0);
33
+ const rootElRef = useMainThreadRef<unknown>(null);
34
+ const nestedElRef = useMainThreadRef<unknown>(null);
35
+
36
+ const primaryTap = useMemo(() => {
37
+ const fn = () => {
38
+ 'main thread';
39
+ countRef.current += 1;
40
+ const hasEl = rootElRef.current != null ? 'with-ref' : 'no-ref';
41
+ return runOnBackground(onTapReport)(`primary:${hasEl}`, label, countRef.current);
42
+ };
43
+ return fn;
44
+ }, [label]);
45
+
46
+ const secondaryTap = () => {
47
+ 'main thread';
48
+ countRef.current += 10;
49
+ return runOnBackground(onTapReport)('secondary', label, countRef.current);
50
+ };
51
+
52
+ const handleCatchMove = useMemo(() => {
53
+ const fn = () => {
54
+ 'main thread';
55
+ countRef.current += 1;
56
+ return runOnBackground(onMoveReport)(label, countRef.current);
57
+ };
58
+ return fn;
59
+ }, [label]);
60
+
61
+ const primaryGestureUpdate = useMemo(() => {
62
+ const fn = () => {
63
+ 'main thread';
64
+ countRef.current += 1;
65
+ return runOnBackground(onGestureReport)('primary-gesture', label, countRef.current);
66
+ };
67
+ return fn;
68
+ }, [label]);
69
+
70
+ const secondaryGestureUpdate = () => {
71
+ 'main thread';
72
+ countRef.current += 100;
73
+ return runOnBackground(onGestureReport)('secondary-gesture', label, countRef.current);
74
+ };
75
+
76
+ const primaryCallbackRef = useMemo(() => {
77
+ const fn = (el: unknown) => {
78
+ 'main thread';
79
+ rootElRef.current = el;
80
+ void runOnBackground(onRefReport)(`mount:${label}`, el ? 'present' : 'null');
81
+ return () => {
82
+ 'main thread';
83
+ rootElRef.current = null;
84
+ void runOnBackground(onRefReport)(`cleanup:${label}`, 'cleaned');
85
+ };
86
+ };
87
+ return fn;
88
+ }, [label]);
89
+
90
+ const secondaryCallbackRef = (el: unknown) => {
91
+ 'main thread';
92
+ rootElRef.current = el;
93
+ void runOnBackground(onRefReport)(`mount-override:${label}`, el ? 'present' : 'null');
94
+ return () => {
95
+ 'main thread';
96
+ rootElRef.current = null;
97
+ void runOnBackground(onRefReport)(`cleanup-override:${label}`, 'cleaned');
98
+ };
99
+ };
100
+
101
+ const primaryGesture = useMemo(
102
+ () =>
103
+ enableGesture
104
+ ? {
105
+ __isGesture: true,
106
+ id: 21,
107
+ type: -1,
108
+ gestures: [
109
+ {
110
+ __isGesture: true,
111
+ id: 22,
112
+ type: 0,
113
+ config: { minDistance: 4 },
114
+ callbacks: { onUpdate: primaryGestureUpdate },
115
+ },
116
+ {
117
+ __isGesture: true,
118
+ id: 23,
119
+ type: 1,
120
+ config: { taps: 1 },
121
+ callbacks: { onBegin: primaryGestureUpdate },
122
+ },
123
+ ],
124
+ callbacks: {},
125
+ }
126
+ : null,
127
+ [enableGesture, primaryGestureUpdate],
128
+ );
129
+
130
+ const secondaryGesture = {
131
+ __isGesture: true,
132
+ id: 31,
133
+ type: 0,
134
+ config: { minDistance: 12 },
135
+ callbacks: { onUpdate: secondaryGestureUpdate },
136
+ };
137
+
138
+ const firstSpread: Record<string, unknown> = {
139
+ id: cardId,
140
+ 'main-thread:bindtap': enableEvents ? primaryTap : null,
141
+ 'main-thread:catchtouchmove': enableEvents ? handleCatchMove : false,
142
+ 'main-thread:gesture': primaryGesture,
143
+ };
144
+ if (refKind === 'object') {
145
+ firstSpread['main-thread:ref'] = rootElRef;
146
+ } else if (refKind === 'callback') {
147
+ firstSpread['main-thread:ref'] = primaryCallbackRef;
148
+ }
149
+
150
+ if (mode === 'typed-page') {
151
+ return (
152
+ <page {...firstSpread}>
153
+ <view id='inside-page' />
154
+ </page>
155
+ );
156
+ }
157
+
158
+ if (mode === 'typed-list') {
159
+ return (
160
+ <list {...firstSpread}>
161
+ <list-item item-key='k1'>
162
+ <view id='inside-list' />
163
+ </list-item>
164
+ </list>
165
+ );
166
+ }
167
+
168
+ let secondSpread: Record<string, unknown> = { 'data-extra': 'ok' };
169
+ if (secondSpreadMode === 'override-events-gesture-ref') {
170
+ secondSpread = {
171
+ 'data-extra': 'override',
172
+ 'main-thread:bindtap': secondaryTap,
173
+ 'main-thread:gesture': secondaryGesture,
174
+ 'main-thread:ref': secondaryCallbackRef,
175
+ };
176
+ } else if (secondSpreadMode === 'null-ref') {
177
+ secondSpread = {
178
+ 'data-extra': 'ok',
179
+ 'main-thread:ref': undefined,
180
+ };
181
+ }
182
+
183
+ const nestedSpread: Record<string, unknown> = {
184
+ id: `nested-${cardId}`,
185
+ 'main-thread:ref': nestedElRef,
186
+ };
187
+
188
+ if (!show) {
189
+ return <view id='empty' />;
190
+ }
191
+
192
+ return (
193
+ <view {...firstSpread} {...secondSpread}>
194
+ <text {...nestedSpread}>Hello</text>
195
+ </view>
196
+ );
197
+ }
@@ -19,16 +19,17 @@ const entryFiles = [
19
19
  ];
20
20
 
21
21
  const forbiddenExact = new Set([
22
- path.resolve(runtimeSrc, 'snapshot.ts'),
23
- path.resolve(runtimeSrc, 'backgroundSnapshot.ts'),
24
- path.resolve(runtimeSrc, 'listUpdateInfo.ts'),
25
- path.resolve(runtimeSrc, 'pendingListUpdates.ts'),
22
+ path.resolve(runtimeSrc, 'document.ts'),
23
+ path.resolve(runtimeSrc, 'index.ts'),
24
+ path.resolve(runtimeSrc, 'internal.ts'),
25
+ path.resolve(runtimeSrc, 'lynx-api.ts'),
26
+ path.resolve(runtimeSrc, 'lynx.ts'),
27
+ path.resolve(runtimeSrc, 'root.ts'),
28
+ path.resolve(runtimeSrc, 'runtime-marker.ts'),
26
29
  ]);
27
30
 
28
31
  const forbiddenDirs = [
29
- path.resolve(runtimeSrc, 'lynx') + path.sep,
30
32
  path.resolve(runtimeSrc, 'snapshot') + path.sep,
31
- path.resolve(runtimeSrc, 'lifecycle', 'patch') + path.sep,
32
33
  ];
33
34
 
34
35
  function isForbidden(filePath: string): boolean {
@@ -25,8 +25,7 @@ describe('legacy internal guardrail', () => {
25
25
  expect(ElementTemplateInternal.captureMainThreadObject({ value: 1 })).toBeUndefined();
26
26
  expect('captureMainThreadObject' in ElementTemplateRuntime).toBe(false);
27
27
 
28
- expect(ElementTemplateInternal.registerWorkletOnBackground).toBeTypeOf('function');
29
- expect(() => ElementTemplateInternal.registerWorkletOnBackground('main-thread', 'hash', () => {})).not.toThrow();
28
+ expect('registerWorkletOnBackground' in ElementTemplateInternal).toBe(false);
30
29
  expect('registerWorkletOnBackground' in ElementTemplateRuntime).toBe(false);
31
30
  expect(ElementTemplateInternal.transformToWorklet).toBeTypeOf('function');
32
31
  expect('transformToWorklet' in ElementTemplateRuntime).toBe(false);
@@ -1,3 +1,4 @@
1
+ import { createElement } from 'preact/compat';
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
3
 
3
4
  import { getReloadVersion } from '../../../src/core/reload-version.js';
@@ -8,19 +9,36 @@ import {
8
9
  globalCommitContext,
9
10
  markRemovedSubtreeForPostDispatchTeardown,
10
11
  } from '../../../src/element-template/background/commit-context.js';
11
- import { resetElementTemplateCommitState } from '../../../src/element-template/background/commit-hook.js';
12
+ import {
13
+ installElementTemplateCommitHook,
14
+ markElementTemplateHydrated,
15
+ resetElementTemplateCommitState,
16
+ uninstallElementTemplateCommitHookForTesting,
17
+ } from '../../../src/element-template/background/commit-hook.js';
18
+ import { setupBackgroundElementTemplateDocument } from '../../../src/element-template/background/document.js';
12
19
  import {
13
20
  installElementTemplateHydrationListener,
14
21
  resetElementTemplateHydrationListener,
15
22
  } from '../../../src/element-template/background/hydration-listener.js';
16
- import { BackgroundElementTemplateInstance } from '../../../src/element-template/background/instance.js';
23
+ import {
24
+ BackgroundElementTemplateInstance,
25
+ BackgroundPageRootInstance,
26
+ } from '../../../src/element-template/background/instance.js';
17
27
  import { backgroundElementTemplateInstanceManager } from '../../../src/element-template/background/manager.js';
28
+ import { root, useEffect } from '../../../src/element-template/index.js';
29
+ import { clearRefState } from '../../../src/element-template/prop-adapters/ref.js';
18
30
  import { ElementTemplateLifecycleConstant } from '../../../src/element-template/protocol/lifecycle-constant.js';
19
31
  import { ElementTemplateUpdateOps } from '../../../src/element-template/protocol/opcodes.js';
20
32
  import type { SerializedCompiledNode } from '../../../src/element-template/protocol/types.js';
21
33
  import { callDestroyLifetimeFun } from '../../../src/element-template/native/callDestroyLifetimeFun.js';
22
- import { __root } from '../../../src/element-template/runtime/page/root-instance.js';
34
+ import { __root, setRoot } from '../../../src/element-template/runtime/page/root-instance.js';
35
+ import {
36
+ __etAttrPlanMap,
37
+ adaptRefAttrSlot,
38
+ clearEtAttrPlanMap,
39
+ } from '../../../src/element-template/runtime/template/attr-slot-plan.js';
23
40
  import { ElementTemplateEnvManager } from '../test-utils/debug/envManager.js';
41
+ import { resetPerformanceMocks } from '../test-utils/mock/performance.js';
24
42
 
25
43
  describe('callDestroyLifetimeFun', () => {
26
44
  const envManager = new ElementTemplateEnvManager();
@@ -36,8 +54,11 @@ describe('callDestroyLifetimeFun', () => {
36
54
  });
37
55
 
38
56
  afterEach(() => {
57
+ uninstallElementTemplateCommitHookForTesting();
39
58
  resetElementTemplateHydrationListener();
40
59
  resetElementTemplateCommitState();
60
+ clearRefState();
61
+ clearEtAttrPlanMap();
41
62
  takeMainThreadRefInitValuePatch();
42
63
  });
43
64
 
@@ -104,4 +125,69 @@ describe('callDestroyLifetimeFun', () => {
104
125
  expect(backgroundElementTemplateInstanceManager.get(-1)).toBeUndefined();
105
126
  expect(backgroundElementTemplateInstanceManager.values.size).toBe(0);
106
127
  });
128
+
129
+ it('unmounts a hydrated tree without dispatching removeNode patches and discards MainThreadRef init created in ref detach', () => {
130
+ setRoot(new BackgroundPageRootInstance());
131
+ setupBackgroundElementTemplateDocument();
132
+ installElementTemplateCommitHook();
133
+ const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
134
+
135
+ const refCalls: unknown[] = [];
136
+ const callbackRef = (value: unknown) => {
137
+ refCalls.push(value);
138
+ if (value === null) {
139
+ new MainThreadRef('created-during-destroy-detach');
140
+ }
141
+ };
142
+
143
+ root.render(createElement('view', null));
144
+ const oldView = (__root as BackgroundElementTemplateInstance).firstChild!;
145
+ __etAttrPlanMap[oldView.type] = [0, adaptRefAttrSlot];
146
+ oldView.setAttribute('attributeSlots', [callbackRef]);
147
+ oldView.markMaterializedByHydration();
148
+ markElementTemplateHydrated();
149
+ dispatch.mockClear();
150
+
151
+ vi.useFakeTimers();
152
+ try {
153
+ callDestroyLifetimeFun();
154
+
155
+ expect(refCalls).toContain(null);
156
+ expect(dispatch).not.toHaveBeenCalled();
157
+ expect(vi.getTimerCount()).toBe(0);
158
+ expect(takeMainThreadRefInitValuePatch()).toEqual([]);
159
+ expect(backgroundElementTemplateInstanceManager.values.size).toBe(0);
160
+ } finally {
161
+ vi.useRealTimers();
162
+ }
163
+ });
164
+
165
+ it('cleans up background runtime state in finally even when unmount effect cleanup throws', async () => {
166
+ setRoot(new BackgroundPageRootInstance());
167
+ setupBackgroundElementTemplateDocument();
168
+ installElementTemplateCommitHook();
169
+
170
+ const cleanupError = new Error('unmount effect cleanup failure');
171
+ function ThrowingOnCleanup() {
172
+ useEffect(() => {
173
+ return () => {
174
+ new MainThreadRef('created-before-throw');
175
+ throw cleanupError;
176
+ };
177
+ }, []);
178
+ return createElement('view', null);
179
+ }
180
+
181
+ root.render(createElement(ThrowingOnCleanup, null));
182
+ await Promise.resolve();
183
+ markElementTemplateHydrated();
184
+
185
+ try {
186
+ expect(() => callDestroyLifetimeFun()).toThrow(cleanupError);
187
+ expect(backgroundElementTemplateInstanceManager.values.size).toBe(0);
188
+ expect(takeMainThreadRefInitValuePatch()).toEqual([]);
189
+ } finally {
190
+ resetPerformanceMocks();
191
+ }
192
+ });
107
193
  });
@@ -4,6 +4,7 @@ import { injectCalledByNative } from '../../../src/element-template/native/main-
4
4
  import { reloadMainThread } from '../../../src/element-template/native/reload-main-thread.js';
5
5
  import { createElementTemplatePage, setupPage } from '../../../src/element-template/runtime/page/page.js';
6
6
  import { renderMainThread } from '../../../src/element-template/runtime/render/render-main-thread.js';
7
+ import { clearMainThreadDynamicAttrState } from '../../../src/element-template/runtime/template/main-thread-dynamic-attr-state.js';
7
8
 
8
9
  const mockedPageModuleState = vi.hoisted(() => ({
9
10
  page: undefined as unknown,
@@ -42,6 +43,7 @@ describe('injectCalledByNative', () => {
42
43
  });
43
44
 
44
45
  afterEach(() => {
46
+ clearMainThreadDynamicAttrState();
45
47
  vi.unstubAllGlobals();
46
48
  vi.clearAllMocks();
47
49
  });
@@ -82,7 +84,7 @@ describe('injectCalledByNative', () => {
82
84
  expect(vi.mocked(reloadMainThread)).not.toHaveBeenCalled();
83
85
  });
84
86
 
85
- it('flushes updateGlobalProps without page or options when options are absent', () => {
87
+ it('flushes updateGlobalProps with default root options when options are absent', () => {
86
88
  injectCalledByNative();
87
89
  const globalAny = globalThis as typeof globalThis & {
88
90
  updateGlobalProps: (data?: Record<string, unknown>, options?: UpdatePageOption) => void;
@@ -92,7 +94,7 @@ describe('injectCalledByNative', () => {
92
94
 
93
95
  globalAny.updateGlobalProps({ theme: 'light' });
94
96
 
95
- expect(__FlushElementTree).toHaveBeenCalledWith();
97
+ expect(__FlushElementTree).toHaveBeenCalledWith(undefined, {});
96
98
  expect(globalThis.lynx.__globalProps).toEqual({ theme: 'dark' });
97
99
  expect(vi.mocked(renderMainThread)).not.toHaveBeenCalled();
98
100
  expect(vi.mocked(reloadMainThread)).not.toHaveBeenCalled();
@@ -110,6 +112,7 @@ describe('injectCalledByNative', () => {
110
112
  expect(vi.mocked(createElementTemplatePage)).toHaveBeenCalledTimes(1);
111
113
  expect(vi.mocked(setupPage)).toHaveBeenCalledWith({ type: 'page', id: '0', children: [] });
112
114
  expect(vi.mocked(renderMainThread)).toHaveBeenCalledTimes(1);
115
+ expect(__FlushElementTree).not.toHaveBeenCalled();
113
116
  });
114
117
 
115
118
  it('merges updatePage data into initData and flushes at the root', () => {
@@ -1,5 +1,6 @@
1
1
  import { afterEach, describe, expect, it, vi } from 'vitest';
2
2
 
3
+ import { JsFunctionLifecycleManager } from '../../../src/worklet-runtime/jsFunctionLifecycle.js';
3
4
  import { installOnMtsDestruction, onMtsDestruction } from '../../../src/element-template/native/mts-destroy.js';
4
5
  import {
5
6
  composeElementTemplateListAttributes,
@@ -7,8 +8,13 @@ import {
7
8
  registerElementTemplateListItem,
8
9
  registerElementTemplateListState,
9
10
  } from '../../../src/element-template/runtime/list/list.js';
11
+ import {
12
+ getNextElementTemplateId,
13
+ reserveElementTemplateId,
14
+ } from '../../../src/element-template/runtime/template/handle.js';
10
15
  import {
11
16
  attachMainThreadDynamicAttrRefsForSubtree,
17
+ applyPendingMainThreadRefAttachments,
12
18
  clearMainThreadDynamicAttrState,
13
19
  getMainThreadDynamicAttrState,
14
20
  initializeMainThreadDynamicAttrSlots,
@@ -92,6 +98,37 @@ describe('mts-destroy', () => {
92
98
  }
93
99
  });
94
100
 
101
+ it('retires callback owners before a new runtime can reuse background execution IDs', () => {
102
+ const previousWorkletImpl = globalThis.lynxWorkletImpl;
103
+ const previous = new JsFunctionLifecycleManager();
104
+ const oldCtx = { _wkltId: 'tap', _execId: 3 };
105
+ previous.addRef(3, oldCtx);
106
+ globalThis.lynxWorkletImpl = {
107
+ ...previousWorkletImpl,
108
+ _jsFunctionLifecycleManager: previous,
109
+ } as typeof globalThis.lynxWorkletImpl;
110
+ const dispatch = vi.spyOn(lynx.getJSContext(), 'dispatchEvent');
111
+ try {
112
+ onMtsDestruction();
113
+ const current = globalThis.lynxWorkletImpl._jsFunctionLifecycleManager!;
114
+ const next = { _wkltId: 'tap', _execId: 3 };
115
+ current.addRef(3, next);
116
+ expect(current).not.toBe(previous);
117
+ previous.removeRef(3);
118
+ previous.fire();
119
+ expect(dispatch).not.toHaveBeenCalled();
120
+ current.removeRef(3);
121
+ current.fire();
122
+ expect(dispatch).toHaveBeenCalledExactlyOnceWith({
123
+ type: 'Lynx.Worklet.releaseBackgroundWorkletCtx',
124
+ data: [3],
125
+ });
126
+ } finally {
127
+ dispatch.mockRestore();
128
+ globalThis.lynxWorkletImpl = previousWorkletImpl;
129
+ }
130
+ });
131
+
95
132
  it('clears the element template registry on destruction', () => {
96
133
  const registryRef = {} as ElementTemplateHandle;
97
134
  const mtRef = { _wvid: 7 };
@@ -120,6 +157,8 @@ describe('mts-destroy', () => {
120
157
  ],
121
158
  );
122
159
  attachMainThreadDynamicAttrRefsForSubtree([{ uid: -1, ref: registryRef }]);
160
+ vi.mocked(__GetElementByAttrSlot).mockReturnValue({ id: 'actual-element' } as unknown as ElementRef);
161
+ applyPendingMainThreadRefAttachments();
123
162
 
124
163
  try {
125
164
  expect(elementTemplateRegistry.get(-1)).toBe(registryRef);
@@ -157,6 +196,55 @@ describe('mts-destroy', () => {
157
196
  expect(delayedBackgroundFunctionArray).toHaveLength(0);
158
197
  });
159
198
 
199
+ it('resets main-thread template id counter on destruction', () => {
200
+ expect(reserveElementTemplateId()).toBe(-1);
201
+ expect(reserveElementTemplateId()).toBe(-2);
202
+ expect(getNextElementTemplateId()).toBe(-3);
203
+
204
+ onMtsDestruction();
205
+
206
+ expect(getNextElementTemplateId()).toBe(-1);
207
+ });
208
+
209
+ it('still clears dynamic attr state and resets template id when a materialized main-thread ref cleanup throws', () => {
210
+ const registryRef = {} as ElementTemplateHandle;
211
+ const cleanupError = new Error('mt-ref cleanup failed');
212
+ const throwingRef: { _wkltId: string; _unmount?: () => void } = {
213
+ _wkltId: 'ref-cleanup',
214
+ };
215
+ expect(reserveElementTemplateId()).toBe(-1);
216
+ elementTemplateRegistry.set(-1, registryRef);
217
+ __etAttrPlanMap._et_throwing_destroy = [0, adaptMTEventAttrSlot, 1, adaptMTRefAttrSlot];
218
+ initializeMainThreadDynamicAttrSlots(
219
+ -1,
220
+ '_et_throwing_destroy',
221
+ [
222
+ {
223
+ type: 'worklet',
224
+ value: { _wkltId: 'tap' },
225
+ },
226
+ {
227
+ type: 'main-thread-ref',
228
+ value: throwingRef,
229
+ },
230
+ ],
231
+ );
232
+ vi.stubGlobal(
233
+ 'runWorklet',
234
+ vi.fn(() => () => {
235
+ throw cleanupError;
236
+ }),
237
+ );
238
+ attachMainThreadDynamicAttrRefsForSubtree([{ uid: -1, ref: registryRef }]);
239
+ vi.mocked(__GetElementByAttrSlot).mockReturnValue({ id: 'actual-element' } as unknown as ElementRef);
240
+ applyPendingMainThreadRefAttachments();
241
+
242
+ expect(() => onMtsDestruction()).toThrow(cleanupError);
243
+ expect(getMainThreadDynamicAttrState(-1, 0)).toBeUndefined();
244
+ expect(getMainThreadDynamicAttrState(-1, 1)).toBeUndefined();
245
+ expect(getNextElementTemplateId()).toBe(-1);
246
+ });
247
+
160
248
  it('marks list callbacks destroyed on main-thread runtime destruction', () => {
161
249
  const listRef = { __isNativeRef: true, id: 'list', __mockNativeId: 100 } as unknown as ElementTemplateHandle;
162
250
  const itemRef = { __isNativeRef: true, id: 'item', __mockNativeId: 101 } as unknown as ElementTemplateHandle;
@@ -20,6 +20,7 @@ import {
20
20
  import {
21
21
  initializeMainThreadDynamicAttrSlots,
22
22
  attachMainThreadDynamicAttrRefsForSubtree,
23
+ applyPendingMainThreadRefAttachments,
23
24
  } from '../../../src/element-template/runtime/template/main-thread-dynamic-attr-state.js';
24
25
  import { reloadBackground } from '../../../src/element-template/native/reload-background.js';
25
26
  import { resetElementTemplateMainThreadBackgroundFunctionRuntime } from '../../../src/element-template/runtime/template/main-thread-background-function.js';
@@ -51,6 +52,8 @@ describe('ElementTemplate dual-thread communication delivery across ordinary rel
51
52
  { type: 'main-thread-ref', value: { _wkltId: 'ref-cleanup' } },
52
53
  ]);
53
54
  attachMainThreadDynamicAttrRefsForSubtree([{ uid: -1, ref: page }]);
55
+ vi.mocked(__GetElementByAttrSlot).mockReturnValueOnce({ id: 'actual-element' } as unknown as ElementRef);
56
+ applyPendingMainThreadRefAttachments();
54
57
 
55
58
  reloadMainThread({}, { reloadTemplate: true });
56
59