@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
@@ -17,6 +17,7 @@ import { elementTemplateRegistry } from '../../../src/element-template/runtime/t
17
17
  import { resetTemplateId } from '../../../src/element-template/runtime/template/handle.js';
18
18
  import {
19
19
  attachMainThreadDynamicAttrRefsForSubtree,
20
+ applyPendingMainThreadRefAttachments,
20
21
  clearMainThreadDynamicAttrState,
21
22
  getMainThreadDynamicAttrState,
22
23
  initializeMainThreadDynamicAttrSlots,
@@ -220,6 +221,8 @@ describe('ElementTemplate reloadMainThread', () => {
220
221
  ],
221
222
  );
222
223
  attachMainThreadDynamicAttrRefsForSubtree([{ uid: -1, ref: oldRootRef }]);
224
+ vi.mocked(__GetElementByAttrSlot).mockReturnValue({ id: 'actual-element' } as unknown as ElementRef);
225
+ applyPendingMainThreadRefAttachments();
223
226
  expect(getMainThreadDynamicAttrState(-1, 0)).toBeDefined();
224
227
  expect(getMainThreadDynamicAttrState(-1, 1)).toBeDefined();
225
228
  vi.mocked(mockRender).mockReturnValueOnce({
@@ -301,7 +304,6 @@ describe('ElementTemplate reloadMainThread', () => {
301
304
  });
302
305
 
303
306
  it('evaluates the entry again and lets it render into the retained page', () => {
304
- vi.mocked(mockRender).mockReturnValue({ pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] });
305
307
  const supportsReEvalKey = Symbol.for('__LYNX_ENTRY_SUPPORTS_RE_EVAL__');
306
308
  const reloaderKey = Symbol.for('__LYNX_MAIN_THREAD_ENTRY_RELOADER__');
307
309
  const completerKey = Symbol.for('__LYNX_MAIN_THREAD_RELOAD_COMPLETER__');
@@ -310,6 +312,22 @@ describe('ElementTemplate reloadMainThread', () => {
310
312
  const page = mockedState.page;
311
313
  const newJsx = { type: 'NewApp' };
312
314
  const events: string[] = [];
315
+ const rootRef = { type: 'new-ref' } as unknown as ElementTemplateHandle;
316
+ const element = { id: 'new-element' } as unknown as ElementRef;
317
+ const callback = { _wkltId: 'reload-ref' };
318
+ const runWorklet = vi.fn(() => {
319
+ events.push('attach');
320
+ return vi.fn();
321
+ });
322
+ const dispatchEvent = vi.fn();
323
+ vi.stubGlobal('runWorklet', runWorklet);
324
+ vi.stubGlobal('__GetElementByAttrSlot', vi.fn(() => element));
325
+ vi.mocked(lynx.getJSContext).mockReturnValue({ dispatchEvent } as ReturnType<typeof lynx.getJSContext>);
326
+ vi.mocked(mockRender).mockImplementationOnce(() => {
327
+ __etAttrPlanMap._et_reload_ref = [0, adaptMTRefAttrSlot];
328
+ initializeMainThreadDynamicAttrSlots(-1, '_et_reload_ref', [{ type: 'main-thread-ref', value: callback }]);
329
+ return { pageAttributes: null, rootRefs: [rootRef], rootSubtreeHandles: [[{ uid: -1, ref: rootRef }]] };
330
+ });
313
331
  lynx.__initData = { kept: 'yes', count: 1 };
314
332
  vi.mocked(onMtsDestruction).mockImplementation(() => events.push('retire'));
315
333
  vi.mocked(increaseReloadVersion).mockImplementationOnce(() => {
@@ -334,7 +352,16 @@ describe('ElementTemplate reloadMainThread', () => {
334
352
  delete host[completerKey];
335
353
  }
336
354
 
337
- expect(events).toEqual(['retire', 'advance-version', 'evaluate']);
355
+ expect(events).toEqual(['retire', 'advance-version', 'evaluate', 'attach']);
356
+ expect(__GetElementByAttrSlot).toHaveBeenCalledWith(rootRef, 0);
357
+ expect(runWorklet).toHaveBeenCalledWith(callback, [{ elementRefptr: element }]);
358
+ expect(runWorklet.mock.invocationCallOrder[0]!).toBeLessThan(
359
+ vi.mocked(__SerializeElementTemplate).mock.invocationCallOrder[1]!,
360
+ );
361
+ expect(runWorklet.mock.invocationCallOrder[0]!).toBeLessThan(dispatchEvent.mock.invocationCallOrder[0]!);
362
+ expect(runWorklet.mock.invocationCallOrder[0]!).toBeLessThan(
363
+ vi.mocked(__FlushElementTree).mock.invocationCallOrder[0]!,
364
+ );
338
365
  expect(increaseReloadVersion).toHaveBeenCalledOnce();
339
366
  expect(lynx.__initData).toEqual({ kept: 'yes', count: 2 });
340
367
  expect(setupPage).toHaveBeenLastCalledWith(page);
@@ -465,6 +492,8 @@ describe('ElementTemplate reloadMainThread', () => {
465
492
  { uid: -2, ref: firstChildRef },
466
493
  { uid: -3, ref: secondRootRef },
467
494
  ]);
495
+ vi.mocked(__GetElementByAttrSlot).mockReturnValue({ id: 'actual-element' } as unknown as ElementRef);
496
+ applyPendingMainThreadRefAttachments();
468
497
  const nativeRefs = new Map([
469
498
  [-1, firstRootRef],
470
499
  [-2, firstChildRef],
@@ -540,6 +569,84 @@ describe('ElementTemplate reloadMainThread', () => {
540
569
  expect(lynx.__initData).toEqual({ msg: 'reset' });
541
570
  });
542
571
 
572
+ it('completes main-thread reload teardown and resets template id when subtree ref cleanup throws', () => {
573
+ const firstRootRef = { type: 'first-root' } as unknown as ElementTemplateHandle;
574
+ const secondRootRef = { type: 'second-root' } as unknown as ElementTemplateHandle;
575
+ const firstCleanupError = new Error('first subtree ref cleanup failed');
576
+ const secondCleanupError = new Error('second subtree ref cleanup failed');
577
+ const firstThrowingRef: { _wkltId: string; _unmount?: () => void } = { _wkltId: 'first-ref' };
578
+ const secondThrowingRef: { _wkltId: string; _unmount?: () => void } = { _wkltId: 'second-ref' };
579
+ __etAttrPlanMap._et_first_root = [0, adaptMTRefAttrSlot];
580
+ __etAttrPlanMap._et_second_root = [0, adaptMTRefAttrSlot];
581
+ initializeMainThreadDynamicAttrSlots(-1, '_et_first_root', [{ type: 'main-thread-ref', value: firstThrowingRef }]);
582
+ initializeMainThreadDynamicAttrSlots(-2, '_et_second_root', [{
583
+ type: 'main-thread-ref',
584
+ value: secondThrowingRef,
585
+ }]);
586
+ attachMainThreadDynamicAttrRefsForSubtree([
587
+ { uid: -1, ref: firstRootRef },
588
+ { uid: -2, ref: secondRootRef },
589
+ ]);
590
+ vi.mocked(__GetElementByAttrSlot).mockReturnValue({ id: 'actual-element' } as unknown as ElementRef);
591
+ applyPendingMainThreadRefAttachments();
592
+ firstThrowingRef._unmount = vi.fn(() => {
593
+ throw firstCleanupError;
594
+ });
595
+ secondThrowingRef._unmount = vi.fn(() => {
596
+ throw secondCleanupError;
597
+ });
598
+ const nativeRefs = new Map([
599
+ [-1, firstRootRef],
600
+ [-2, secondRootRef],
601
+ ]);
602
+ vi.mocked(elementTemplateRegistry.get).mockImplementation(id => nativeRefs.get(id));
603
+ vi.mocked(__SerializeElementTemplate).mockReturnValueOnce({
604
+ tag: 'page',
605
+ attributes: null,
606
+ childSlots: [[
607
+ { templateKey: '_et_first_root', uid: -1 },
608
+ { templateKey: '_et_second_root', uid: -2 },
609
+ ]],
610
+ uid: 0,
611
+ } as ReturnType<typeof __SerializeElementTemplate>);
612
+
613
+ expect(() => reloadMainThread(undefined, { reloadTemplate: true })).toThrow(firstCleanupError);
614
+ expect(elementTemplateRegistry.clear).toHaveBeenCalledTimes(1);
615
+ expect(resetTemplateId).toHaveBeenCalledTimes(1);
616
+ expect(increaseReloadVersion).toHaveBeenCalledTimes(1);
617
+ expect(getMainThreadDynamicAttrState(-1, 0)).toBeUndefined();
618
+ expect(getMainThreadDynamicAttrState(-2, 0)).toBeUndefined();
619
+
620
+ // Also verify re-eval reload branch when subtree ref cleanup throws.
621
+ const supportsReEvalKey = Symbol.for('__LYNX_ENTRY_SUPPORTS_RE_EVAL__');
622
+ const reloaderKey = Symbol.for('__LYNX_MAIN_THREAD_ENTRY_RELOADER__');
623
+ const host = lynx as unknown as Record<symbol, unknown>;
624
+ const reloader = vi.fn();
625
+ vi.stubGlobal('__EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__', true);
626
+ host[supportsReEvalKey] = true;
627
+ host[reloaderKey] = reloader;
628
+ initializeMainThreadDynamicAttrSlots(-1, '_et_first_root', [{ type: 'main-thread-ref', value: firstThrowingRef }]);
629
+ attachMainThreadDynamicAttrRefsForSubtree([{ uid: -1, ref: firstRootRef }]);
630
+ applyPendingMainThreadRefAttachments();
631
+ firstThrowingRef._unmount = vi.fn(() => {
632
+ throw firstCleanupError;
633
+ });
634
+ vi.mocked(__SerializeElementTemplate).mockReturnValueOnce({
635
+ tag: 'page',
636
+ attributes: null,
637
+ childSlots: [[{ templateKey: '_et_first_root', uid: -1 }]],
638
+ uid: 0,
639
+ } as ReturnType<typeof __SerializeElementTemplate>);
640
+ try {
641
+ expect(() => reloadMainThread(undefined, { reloadTemplate: true })).toThrow(firstCleanupError);
642
+ expect(onMtsDestruction).toHaveBeenCalledTimes(1);
643
+ expect(reloader).not.toHaveBeenCalled();
644
+ } finally {
645
+ delete host[supportsReEvalKey];
646
+ delete host[reloaderKey];
647
+ }
648
+ });
649
+
543
650
  it('profiles main-thread reload when profiling is enabled', () => {
544
651
  vi.stubGlobal('__PROFILE__', true);
545
652
  mockedState.root = { __jsx: null };
@@ -618,4 +725,13 @@ describe('ElementTemplate reloadBackground', () => {
618
725
  expect(lynx.__initData).not.toBe(initData);
619
726
  expect(lynx.__initData).toEqual({ stable: true });
620
727
  });
728
+
729
+ it('resets background initData when resetPageData is true', () => {
730
+ mockedState.root = { __jsx: null };
731
+ lynx.__initData = { stale: 1, value: 1 };
732
+
733
+ reloadBackground({ value: 2 }, { resetPageData: true });
734
+
735
+ expect(lynx.__initData).toEqual({ value: 2 });
736
+ });
621
737
  });
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
6
  import type { ElementTemplateUpdateCommitContext } from '../../../../../src/element-template/protocol/types.js';
7
7
  import type { CompiledFixtureModuleExports } from '../../../test-utils/debug/compiledFixtureModule.js';
8
8
 
9
- globalThis.__GLOBAL_PROPS_MODE__ = 'event';
9
+ lynx.__runtime_configs__ = { globalPropsMode: 'event' };
10
10
 
11
11
  const [
12
12
  { installElementTemplateCommitHook, resetElementTemplateCommitState },
@@ -138,13 +138,13 @@ describe('Compiled ET GlobalProps update fixtures', () => {
138
138
  resetElementTemplateHydrationListener();
139
139
  resetElementTemplateCommitState();
140
140
  envManager.setUseElementTemplate(false);
141
- globalThis.__GLOBAL_PROPS_MODE__ = 'event';
141
+ lynx.__runtime_configs__ = { globalPropsMode: 'event' };
142
142
  globalThis.lynx.getApp().GlobalEventEmitter = originalGlobalEventEmitter;
143
143
  vi.stubGlobal('lynx', originalLynx);
144
144
  });
145
145
 
146
146
  it('reactive updateGlobalProps force-renders direct globalProps reads into native update ops', async () => {
147
- globalThis.__GLOBAL_PROPS_MODE__ = 'reactive';
147
+ lynx.__runtime_configs__ = { globalPropsMode: 'reactive' };
148
148
  const { backgroundModule, mainModule } = await loadCompiledFixturePair<CompiledGlobalPropsModule>(
149
149
  DIRECT_READ_FIXTURE,
150
150
  );
@@ -166,7 +166,7 @@ describe('Compiled ET GlobalProps update fixtures', () => {
166
166
  });
167
167
 
168
168
  it('event mode emits without updating compiled direct globalProps reads', async () => {
169
- globalThis.__GLOBAL_PROPS_MODE__ = 'event';
169
+ lynx.__runtime_configs__ = { globalPropsMode: 'event' };
170
170
  const emitted = vi.fn();
171
171
  const { backgroundModule, mainModule } = await loadCompiledFixturePair<CompiledGlobalPropsModule>(
172
172
  DIRECT_READ_FIXTURE,
@@ -195,7 +195,7 @@ describe('Compiled ET GlobalProps update fixtures', () => {
195
195
  });
196
196
 
197
197
  it('event mode updates compiled GlobalProps hook and provider users through the changed event', async () => {
198
- globalThis.__GLOBAL_PROPS_MODE__ = 'event';
198
+ lynx.__runtime_configs__ = { globalPropsMode: 'event' };
199
199
  const changed = vi.fn();
200
200
  const { backgroundModule, mainModule } = await loadCompiledFixturePair<CompiledGlobalPropsModule>(
201
201
  EVENT_HOOK_FIXTURE,
@@ -15,7 +15,6 @@ function waitForRender(): Promise<void> {
15
15
 
16
16
  async function setupGlobalPropsRuntime(mode: 'reactive' | 'event') {
17
17
  vi.resetModules();
18
- vi.stubGlobal('__GLOBAL_PROPS_MODE__', mode);
19
18
 
20
19
  const { ElementTemplateEnvManager } = await import('../../test-utils/debug/envManager.js');
21
20
  const { ElementTemplateLifecycleConstant } = await import(
@@ -47,6 +46,7 @@ async function setupGlobalPropsRuntime(mode: 'reactive' | 'event') {
47
46
  const originalGlobalEventEmitter = globalThis.lynx.getApp().GlobalEventEmitter;
48
47
  vi.stubGlobal('lynx', {
49
48
  ...baseLynx,
49
+ __runtime_configs__: { globalPropsMode: mode },
50
50
  __globalProps: { theme: 'dark', stable: true },
51
51
  getJSModule(moduleName: string) {
52
52
  if (moduleName === 'GlobalEventEmitter') {
@@ -24,6 +24,7 @@ import {
24
24
  adaptEventAttrSlot,
25
25
  adaptMTEventAttrSlot,
26
26
  adaptMTRefAttrSlot,
27
+ adaptSpreadAttrSlot,
27
28
  clearEtAttrPlanMap,
28
29
  } from '../../../../src/element-template/runtime/template/attr-slot-plan.js';
29
30
  import { hydrateBackground as hydrate } from '../../test-utils/debug/hydrate.js';
@@ -261,6 +262,75 @@ describe('hydrate', () => {
261
262
  expect(globalCommitContext.ops).toEqual([]);
262
263
  });
263
264
 
265
+ it('forces spread slot hydration only when live main-thread capabilities or main-thread:ref keys exist', () => {
266
+ __etAttrPlanMap.root = [
267
+ 0,
268
+ adaptSpreadAttrSlot,
269
+ 1,
270
+ adaptSpreadAttrSlot,
271
+ 2,
272
+ adaptSpreadAttrSlot,
273
+ 3,
274
+ adaptSpreadAttrSlot,
275
+ 4,
276
+ adaptSpreadAttrSlot,
277
+ 5,
278
+ adaptSpreadAttrSlot,
279
+ ];
280
+ const gestureSpread = {
281
+ 'main-thread:gesture': { type: 'gesture', value: [] },
282
+ };
283
+ const eventSpread = {
284
+ 'main-thread:bindtap': { type: 'worklet', value: { _wkltId: 'tap' } },
285
+ };
286
+ const clearedRefSpread = {
287
+ 'main-thread:ref': null,
288
+ };
289
+ const clearedEventAndGestureSpread = {
290
+ id: 'same',
291
+ 'main-thread:gesture': null,
292
+ 'main-thread:bindtap': null,
293
+ };
294
+ const root = new BackgroundElementTemplateInstance('root');
295
+ root.attributeSlots = [
296
+ null,
297
+ { id: 'same' },
298
+ gestureSpread,
299
+ eventSpread,
300
+ clearedRefSpread,
301
+ clearedEventAndGestureSpread,
302
+ ];
303
+
304
+ const stream = hydrate(
305
+ createHydrationTemplate(root.instanceId, 'root', {
306
+ attributeSlots: [
307
+ null,
308
+ { id: 'same' },
309
+ { 'main-thread:gesture': { type: 'gesture', value: [] } },
310
+ { 'main-thread:bindtap': { type: 'worklet', value: { _wkltId: 'tap' } } },
311
+ { 'main-thread:ref': null },
312
+ { id: 'same', 'main-thread:gesture': null, 'main-thread:bindtap': null },
313
+ ],
314
+ }),
315
+ root,
316
+ );
317
+
318
+ expect(stream).toEqual([
319
+ ElementTemplateUpdateOps.setAttribute,
320
+ root.instanceId,
321
+ 2,
322
+ gestureSpread,
323
+ ElementTemplateUpdateOps.setAttribute,
324
+ root.instanceId,
325
+ 3,
326
+ eventSpread,
327
+ ElementTemplateUpdateOps.setAttribute,
328
+ root.instanceId,
329
+ 4,
330
+ clearedRefSpread,
331
+ ]);
332
+ });
333
+
264
334
  it('patches attribute slots while creating and inserting background-only children', () => {
265
335
  const root = new BackgroundElementTemplateInstance('root', ['background-root']);
266
336
 
@@ -175,14 +175,14 @@ describe('Compiled ordinary ref background updates', () => {
175
175
  );
176
176
  const stableRef = vi.fn();
177
177
  const newRef = vi.fn();
178
- const unsupportedMainThreadRef = vi.fn();
178
+ const unsupportedCustomRef = vi.fn();
179
179
  const unsupportedWorkletRef = vi.fn();
180
180
 
181
181
  const host = renderOnBackground(backgroundModule, {
182
182
  spread: {
183
183
  id: 'cta',
184
184
  ref: stableRef,
185
- 'main-thread:ref': unsupportedMainThreadRef,
185
+ 'custom:ref': unsupportedCustomRef,
186
186
  'worklet:ref': unsupportedWorkletRef,
187
187
  },
188
188
  });
@@ -192,7 +192,7 @@ describe('Compiled ordinary ref background updates', () => {
192
192
  spread: {
193
193
  id: 'cta',
194
194
  ref: stableRef,
195
- 'main-thread:ref': unsupportedMainThreadRef,
195
+ 'custom:ref': unsupportedCustomRef,
196
196
  'worklet:ref': unsupportedWorkletRef,
197
197
  },
198
198
  });
@@ -229,7 +229,6 @@ describe('Compiled ordinary ref background updates', () => {
229
229
  expect(newRef).toHaveBeenCalledWith(expect.objectContaining({
230
230
  selector: `[ref=${host.instanceId}-0]`,
231
231
  }));
232
- expect(unsupportedMainThreadRef).not.toHaveBeenCalled();
233
232
  expect(unsupportedWorkletRef).not.toHaveBeenCalled();
234
233
  });
235
234
 
@@ -1,6 +1,16 @@
1
+ import { createElement } from 'preact/compat';
1
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
3
 
4
+ import { MainThreadRef, clearMainThreadRefLastIdForTesting } from '../../../../src/core/main-thread-ref.js';
5
+ import { takeMainThreadRefInitValuePatch } from '../../../../src/core/main-thread-ref-init-value.js';
6
+ import { clearMtsConfigCacheForTesting } from '../../../../src/core/mts-capability.js';
3
7
  import { getReloadVersion } from '../../../../src/core/reload-version.js';
8
+ import {
9
+ installElementTemplateCommitHook,
10
+ markElementTemplateHydrated,
11
+ resetElementTemplateCommitState,
12
+ uninstallElementTemplateCommitHookForTesting,
13
+ } from '../../../../src/element-template/background/commit-hook.js';
4
14
  import { setupBackgroundElementTemplateDocument } from '../../../../src/element-template/background/document.js';
5
15
  import {
6
16
  installElementTemplateHydrationListener,
@@ -11,10 +21,17 @@ import {
11
21
  BackgroundPageRootInstance,
12
22
  } from '../../../../src/element-template/background/instance.js';
13
23
  import { backgroundElementTemplateInstanceManager } from '../../../../src/element-template/background/manager.js';
24
+ import { root } from '../../../../src/element-template/index.js';
14
25
  import { reloadBackground } from '../../../../src/element-template/native/reload-background.js';
26
+ import { clearRefState } from '../../../../src/element-template/prop-adapters/ref.js';
15
27
  import { ElementTemplateLifecycleConstant } from '../../../../src/element-template/protocol/lifecycle-constant.js';
16
28
  import type { SerializedCompiledNode } from '../../../../src/element-template/protocol/types.js';
17
29
  import { __root, setRoot } from '../../../../src/element-template/runtime/page/root-instance.js';
30
+ import {
31
+ __etAttrPlanMap,
32
+ adaptRefAttrSlot,
33
+ clearEtAttrPlanMap,
34
+ } from '../../../../src/element-template/runtime/template/attr-slot-plan.js';
18
35
  import { ElementTemplateEnvManager } from '../../test-utils/debug/envManager.js';
19
36
 
20
37
  function createSerializedTemplate(handleId: number, templateKey: string): SerializedCompiledNode {
@@ -40,7 +57,14 @@ describe('ElementTemplate background reload', () => {
40
57
  });
41
58
 
42
59
  afterEach(() => {
60
+ uninstallElementTemplateCommitHookForTesting();
61
+ resetElementTemplateCommitState();
43
62
  resetElementTemplateHydrationListener();
63
+ clearRefState();
64
+ clearEtAttrPlanMap();
65
+ clearMainThreadRefLastIdForTesting();
66
+ clearMtsConfigCacheForTesting();
67
+ takeMainThreadRefInitValuePatch();
44
68
  backgroundElementTemplateInstanceManager.clear();
45
69
  });
46
70
 
@@ -76,4 +100,54 @@ describe('ElementTemplate background reload', () => {
76
100
  expect(backgroundElementTemplateInstanceManager.get(oldId)).toBeUndefined();
77
101
  expect(backgroundElementTemplateInstanceManager.get(-1)).toBe(after);
78
102
  });
103
+
104
+ it('unmounts a hydrated tree on reload without dispatching removeNode patches or dropping MainThreadRef init created in ref detach', () => {
105
+ const originalLynxSdkVersion = SystemInfo.lynxSdkVersion;
106
+ SystemInfo.lynxSdkVersion = '4.0';
107
+ clearMtsConfigCacheForTesting();
108
+ installElementTemplateCommitHook();
109
+ const dispatch = vi.spyOn(lynx.getCoreContext(), 'dispatchEvent');
110
+
111
+ let retainedRefFromDetach: MainThreadRef<string> | undefined;
112
+ const refCalls: unknown[] = [];
113
+ const callbackRef = (value: unknown) => {
114
+ refCalls.push(value);
115
+ if (value === null && !retainedRefFromDetach) {
116
+ retainedRefFromDetach = new MainThreadRef('created-in-detach');
117
+ }
118
+ };
119
+
120
+ root.render(createElement('view', null));
121
+ const oldView = (__root as BackgroundElementTemplateInstance).firstChild!;
122
+ __etAttrPlanMap[oldView.type] = [0, adaptRefAttrSlot];
123
+ oldView.setAttribute('attributeSlots', [callbackRef]);
124
+ oldView.markMaterializedByHydration();
125
+ markElementTemplateHydrated();
126
+ dispatch.mockClear();
127
+
128
+ vi.useFakeTimers();
129
+ try {
130
+ reloadBackground({ next: 1 });
131
+
132
+ expect(refCalls).toContain(null);
133
+ expect(retainedRefFromDetach).toBeInstanceOf(MainThreadRef);
134
+ expect(vi.getTimerCount()).toBe(0);
135
+ expect(dispatch).toHaveBeenCalledExactlyOnceWith({
136
+ type: ElementTemplateLifecycleConstant.updateMTRefInitValue,
137
+ data: JSON.stringify([[retainedRefFromDetach!._wvid, 'created-in-detach']]),
138
+ });
139
+ } finally {
140
+ vi.useRealTimers();
141
+ SystemInfo.lynxSdkVersion = originalLynxSdkVersion;
142
+ }
143
+ });
144
+
145
+ it('forwards resetPageData options to applyUpdatePageData during ordinary background reload', () => {
146
+ lynx.__initData = { stale: 1, value: 1 };
147
+ __root.__jsx = null;
148
+
149
+ reloadBackground({ value: 2 }, { resetPageData: true });
150
+
151
+ expect(lynx.__initData).toEqual({ value: 2 });
152
+ });
79
153
  });
@@ -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
  });