@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
@@ -39,7 +39,7 @@ const isArray = /* @__PURE__ */ Array.isArray;
39
39
  const assign = /* @__PURE__ */ Object.assign;
40
40
 
41
41
  // Global state for the current render pass
42
- let beforeDiff, beforeDiff2, afterDiff, renderHook, ummountHook;
42
+ let beforeDiff, beforeDiff2, afterDiff, renderHook, unmountHook;
43
43
 
44
44
  /**
45
45
  * Render Preact JSX + Components to an HTML string.
@@ -60,7 +60,7 @@ export function renderToString(vnode: any, context: any, into: SnapshotInstance)
60
60
  beforeDiff2 = options[DIFF2];
61
61
  afterDiff = options[DIFFED];
62
62
  renderHook = options[RENDER];
63
- ummountHook = options.unmount;
63
+ unmountHook = options.unmount;
64
64
 
65
65
  const parent = h(Fragment, null);
66
66
  parent[CHILDREN] = [vnode];
@@ -194,7 +194,7 @@ function _renderToString(
194
194
  opcodes,
195
195
  /* v8 ignore start */
196
196
  __ENABLE_SSR__ ? opcodes.length : 0,
197
- /* v8 ignore end */
197
+ /* v8 ignore stop */
198
198
  into,
199
199
  );
200
200
  }
@@ -282,7 +282,7 @@ function _renderToString(
282
282
  opcodes,
283
283
  /* v8 ignore start */
284
284
  __ENABLE_SSR__ ? opcodes.length : 0,
285
- /* v8 ignore end */
285
+ /* v8 ignore stop */
286
286
  into,
287
287
  );
288
288
  } catch (e) {
@@ -312,7 +312,7 @@ function _renderToString(
312
312
  opcodes,
313
313
  /* v8 ignore start */
314
314
  __ENABLE_SSR__ ? opcodes.length : 0,
315
- /* v8 ignore end */
315
+ /* v8 ignore stop */
316
316
  into,
317
317
  );
318
318
  }
@@ -323,7 +323,7 @@ function _renderToString(
323
323
  if (afterDiff) afterDiff(vnode);
324
324
  vnode[PARENT] = undefined;
325
325
 
326
- if (ummountHook) ummountHook(vnode);
326
+ if (unmountHook) unmountHook(vnode);
327
327
  }
328
328
 
329
329
  return;
@@ -406,14 +406,14 @@ function _renderToString(
406
406
  opcodes,
407
407
  /* v8 ignore start */
408
408
  __ENABLE_SSR__ ? opcodes.length : 0,
409
- /* v8 ignore end */
409
+ /* v8 ignore stop */
410
410
  vnode,
411
411
  );
412
412
  }
413
413
 
414
414
  if (afterDiff) afterDiff(vnode);
415
415
  vnode[PARENT] = undefined;
416
- if (ummountHook) ummountHook(vnode);
416
+ if (unmountHook) unmountHook(vnode);
417
417
 
418
418
  if (__ENABLE_SSR__) {
419
419
  opcodes.push(__OpEnd);
@@ -97,60 +97,3 @@ export function ssrHydrateByOpcodes(
97
97
  }
98
98
  }
99
99
  }
100
-
101
- // export function renderOpcodesInto(opcodes: any[], into: SnapshotInstance): void {
102
- // let top: SnapshotInstance = into;
103
- // const stack: SnapshotInstance[] = [into];
104
- // for (let i = 0; i < opcodes.length;) {
105
- // const opcode = opcodes[i];
106
- // switch (opcode) {
107
- // case OpcodeBegin: {
108
- // const p = top;
109
- // top = opcodes[i + 1];
110
- // // @ts-ignore
111
- // if (top.__parent) {
112
- // // already inserted
113
- // top = new SnapshotInstance(top.type);
114
- // opcodes[i + 1] = top;
115
- // }
116
- // p.insertBefore(top);
117
- // stack.push(top);
118
-
119
- // i += 2;
120
- // break;
121
- // }
122
- // case OpcodeEnd: {
123
- // // @ts-ignore
124
- // top[CHILDREN] = undefined;
125
-
126
- // stack.pop();
127
- // const p = stack[stack.length - 1];
128
- // top = p!;
129
-
130
- // i += 1;
131
- // break;
132
- // }
133
- // case OpcodeAttr: {
134
- // const key = opcodes[i + 1];
135
- // const value = opcodes[i + 2];
136
- // top.setAttribute(key, value);
137
-
138
- // i += 3;
139
- // break;
140
- // }
141
- // case OpcodeText: {
142
- // const text = opcodes[i + 1];
143
- // const s = new SnapshotInstance(null as unknown as string);
144
- // if (__ENABLE_SSR__) {
145
- // // We need store the just created SnapshotInstance, or it will be lost when we leave the function
146
- // opcodes[i + 1] = [s, text];
147
- // }
148
- // s.setAttribute(0, text);
149
- // top.insertBefore(s);
150
-
151
- // i += 2;
152
- // break;
153
- // }
154
- // }
155
- // }
156
- // }
@@ -28,7 +28,7 @@ import { globalPipelineOptions } from '../../core/performance.js';
28
28
  import { profileEnd, profileStart } from '../../shared/profile.js';
29
29
  import { isDirectOrDeepEqual } from '../../utils.js';
30
30
  import { clearSnapshotVNodeSource, getSnapshotVNodeSource, moveSnapshotVNodeSource } from '../debug/vnodeSource.js';
31
- import { prepareGestureForCommit } from '../gesture/processGestureBagkround.js';
31
+ import { prepareGestureForCommit } from '../gesture/processGestureBackground.js';
32
32
  import type { GestureKind } from '../gesture/types.js';
33
33
  import { globalBackgroundSnapshotInstancesToRemove } from '../lifecycle/patch/globalState.js';
34
34
  import {
@@ -1,13 +1,33 @@
1
- # Background-function lifecycle cleanup
1
+ # Element Template worklet identity
2
2
 
3
- Reference tracking publishes its retained marker and count only after
4
- `FinalizationRegistry.register` succeeds. A failed registration leaves the same
5
- target eligible for retry and cannot create an untracked reference count.
3
+ Element Template Native storage must preserve the original JavaScript worklet
4
+ context in declared main-thread event slots, as Snapshot does. Native may snapshot
5
+ the event wrapper and ordinary attribute data, but it must retain the wrapper's
6
+ `value` as a live MTS object. Background element preparation must exclude live
7
+ event and gesture values from both its task input and prepared result.
6
8
 
7
- Delayed replay drops the consumed queue rather than truncating its array.
8
- PrimJS can keep truncated array storage alive, retaining completed tasks and
9
- function handles after their external owners disappear. Dropping the queue lets
10
- those targets be collected and their background executions released.
9
+ `runWorklet` transforms the context delivered by Native directly. The original
10
+ context and its captured callback objects remain ordinary JavaScript objects
11
+ accepted by `FinalizationRegistry.register`; no context identifier or reverse
12
+ lookup is needed. This runtime requires the corresponding Native storage behavior.
13
+ Older ET Native implementations that deep-copy worklet contexts are unsupported by
14
+ this integration.
11
15
 
12
- These cleanup rules do not establish ownership across Native dictionary cloning.
13
- Native event descriptors still require a separate local-context ownership bridge.
16
+ Track a background input before calling Native. If Native rejects it, collecting
17
+ that input must still release its already-registered background execution. Only
18
+ Native success commits the slot's strong reference and hydration handoff;
19
+ committing does not register the context again. Removal drops the slot's reference.
20
+ Escaped callbacks follow the existing Snapshot capture and GC behavior.
21
+
22
+ Retire the previous lifecycle manager to stop old finalizers from sending release
23
+ events into the new runtime. Native event ingress must reject detached old
24
+ bindings so they cannot dispatch into a replacement runtime; `runWorklet` does not
25
+ reject contexts based on the lifecycle manager that originally retained them.
26
+ Snapshot observers continue to track references through the same lifecycle manager.
27
+
28
+ This integration keeps Snapshot's existing callback transformation, first-screen
29
+ hydration, and delayed-call replay semantics. It does not add per-binding callback
30
+ materialization, shared-capture isolation, or a new delayed queue representation.
31
+ Shared first-screen context mutation and escaped-callback lifetime limitations
32
+ that also occur in Snapshot remain unchanged. Registration atomicity and
33
+ consumed-queue cleanup remain unchanged.
@@ -2,6 +2,8 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
+ export { loadWorkletRuntime } from './loadRuntime.js';
6
+
5
7
  export * from './bindings.js';
6
8
 
7
9
  export * from './observers.js';
@@ -0,0 +1,25 @@
1
+ // Copyright 2024 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 '../global.js';
6
+
7
+ /**
8
+ * Loads the legacy main-thread worklet chunk or reuses an initialized runtime.
9
+ * @param __schema - The dynamic component entry for loading the Lepus chunk.
10
+ * @returns Whether the worklet runtime was loaded and initialized successfully.
11
+ */
12
+ function loadWorkletRuntime(__schema?: string): boolean {
13
+ if (typeof __LoadLepusChunk === 'undefined') {
14
+ return false;
15
+ }
16
+ if (globalThis.lynxWorkletImpl) {
17
+ return true;
18
+ }
19
+ return __LoadLepusChunk('worklet-runtime', {
20
+ dynamicComponentEntry: __schema,
21
+ chunkType: 0,
22
+ });
23
+ }
24
+
25
+ export { loadWorkletRuntime };
@@ -16,6 +16,7 @@ class JsFunctionLifecycleManager {
16
16
  private execIdSetToFire = new Set<number>();
17
17
  private retainedObjects = new WeakSet<object>();
18
18
  private willFire = false;
19
+ private active = true;
19
20
  private registry: FinalizationRegistry<number>;
20
21
 
21
22
  constructor() {
@@ -51,7 +52,12 @@ class JsFunctionLifecycleManager {
51
52
  }
52
53
  }
53
54
 
55
+ dispose(): void {
56
+ this.active = false;
57
+ }
58
+
54
59
  fire(): void {
60
+ if (!this.active) return;
55
61
  profile('JsFunctionLifecycleManager.fire', () => {
56
62
  lynx.getJSContext().dispatchEvent({
57
63
  type: WorkletEvents.releaseBackgroundWorkletCtx,
@@ -17,6 +17,8 @@ import { profile } from './utils/profile.js';
17
17
  import { getFromWorkletRefMap, initWorkletRef } from './workletRef.js';
18
18
 
19
19
  function initWorklet(): void {
20
+ const previousManager = globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager;
21
+ previousManager?.dispose();
20
22
  globalThis.lynxWorkletImpl = {
21
23
  _workletMap: {},
22
24
  _refImpl: initWorkletRef(),
@@ -11,6 +11,7 @@ import type { InitData, InitDataRaw } from '../src/lynx-api.js';
11
11
 
12
12
  interface ReactLynxRuntimeConfig {
13
13
  [key: string]: unknown;
14
+ globalPropsMode?: 'reactive' | 'event';
14
15
  transformBuiltinAttributeNames?:
15
16
  | boolean
16
17
  | TransformBuiltinAttributeNamesOptions;
@@ -21,6 +22,7 @@ declare global {
21
22
  declare const __REF_FIRE_IMMEDIATELY__: boolean;
22
23
  declare const __TESTING_FORCE_RENDER_TO_OPCODE__: boolean;
23
24
  declare const __FIRST_SCREEN_SYNC_TIMING__: 'immediately' | 'jsReady' | 'manual';
25
+ declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
24
26
  declare const __DEV__: boolean;
25
27
  declare const __JS__: boolean;
26
28
  declare const __LEPUS__: boolean;
@@ -32,7 +34,6 @@ declare global {
32
34
  declare const __ALOG__: boolean | undefined;
33
35
  declare const __ALOG_ELEMENT_API__: boolean | undefined;
34
36
  declare const __ENABLE_SSR__: boolean;
35
- declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
36
37
  declare const __LAZY_BUNDLE_FETCHER__: 'FetchBundle' | 'QueryComponent';
37
38
  declare const __RUNTIME_VERSION__: string | undefined;
38
39
  declare const __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__: boolean | undefined;
@@ -142,7 +142,6 @@ export default defineConfig({
142
142
  'src/element-template/**',
143
143
  'src/core/hooks/mainThread.ts',
144
144
  'src/core/hooks/mainThreadImpl.ts',
145
- 'src/shared/component-stack.ts',
146
145
  'src/shared/profile.ts',
147
146
  'src/index.ts',
148
147
  'src/lynx-api.ts',
@@ -163,7 +162,6 @@ export default defineConfig({
163
162
  'src/snapshot/lynx/tt.ts',
164
163
  'src/snapshot/compat/componentIs.ts',
165
164
  'src/snapshot/snapshot/types.ts',
166
- 'src/snapshot/worklet/hmr.ts',
167
165
 
168
166
  '__test__/snapshot/page.test.jsx',
169
167
  '**/*.d.ts',
@@ -2,14 +2,14 @@ $ rslib
2
2
  Rslib v1.0.2
3
3
 
4
4
  info build started...
5
- start generating declaration files... (esm2)
6
- ready built in 0.55s (esm2)
7
5
  start generating declaration files... (esm0)
8
- ready built in 0.65s (esm1)
9
- ready built in 0.88s (esm0)
10
- info declaration files prepared with tsgo in 1.39 s (esm2)
11
- ready declaration files generated in 6.51 s (esm0)
12
- ready declaration files bundled successfully: dist/index.d.ts in 3.66 s (esm2)
6
+ start generating declaration files... (esm2)
7
+ ready built in 0.68s (esm2)
8
+ ready built in 0.73s (esm1)
9
+ ready built in 1.22s (esm0)
10
+ info declaration files prepared with tsgo in 1.47 s (esm2)
11
+ ready declaration files bundled successfully: dist/index.d.ts in 2.78 s (esm2)
12
+ ready declaration files generated in 6.21 s (esm0)
13
13
 
14
14
  File (esm0) Size
15
15
  dist/rslib-runtime-0.js 1.6 kB
@@ -305,13 +305,6 @@ test('fireEvent triggers useEffect calls', async () => {
305
305
  {
306
306
  "data": "{"patchList":[{"id":3,"snapshotPatch":[3,3,0,1]}]}",
307
307
  "patchOptions": {
308
- "pipelineOptions": {
309
- "dsl": "reactLynx",
310
- "needTimestamps": true,
311
- "pipelineID": "pipelineID",
312
- "pipelineOrigin": "reactLynxHydrate",
313
- "stage": "hydrate",
314
- },
315
308
  "reloadVersion": 0,
316
309
  },
317
310
  },
@@ -298,14 +298,7 @@ describe('alog', () => {
298
298
  ]
299
299
  },
300
300
  "patchOptions": {
301
- "reloadVersion": 0,
302
- "pipelineOptions": {
303
- "pipelineID": "pipelineID",
304
- "needTimestamps": true,
305
- "pipelineOrigin": "reactLynxHydrate",
306
- "dsl": "reactLynx",
307
- "stage": "hydrate"
308
- }
301
+ "reloadVersion": 0
309
302
  }
310
303
  }",
311
304
  ],
@@ -313,7 +306,7 @@ describe('alog', () => {
313
306
  "[ReactLynxDebug] FiberElement API call #30: __SetAttribute(#text#6, "text", 1)",
314
307
  ],
315
308
  [
316
- "[ReactLynxDebug] FiberElement API call #31: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
309
+ "[ReactLynxDebug] FiberElement API call #31: __FlushElementTree(PAGE#0, {})",
317
310
  ],
318
311
  ]
319
312
  `);
@@ -566,14 +559,7 @@ describe('alog', () => {
566
559
  ]
567
560
  },
568
561
  "patchOptions": {
569
- "reloadVersion": 0,
570
- "pipelineOptions": {
571
- "pipelineID": "pipelineID",
572
- "needTimestamps": true,
573
- "pipelineOrigin": "reactLynxHydrate",
574
- "dsl": "reactLynx",
575
- "stage": "hydrate"
576
- }
562
+ "reloadVersion": 0
577
563
  }
578
564
  }",
579
565
  ],
@@ -581,7 +567,7 @@ describe('alog', () => {
581
567
  "[ReactLynxDebug] FiberElement API call #30: __SetAttribute(#text#6, "text", 1)",
582
568
  ],
583
569
  [
584
- "[ReactLynxDebug] FiberElement API call #31: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
570
+ "[ReactLynxDebug] FiberElement API call #31: __FlushElementTree(PAGE#0, {})",
585
571
  ],
586
572
  ]
587
573
  `);
@@ -626,14 +612,7 @@ describe('alog', () => {
626
612
  ]
627
613
  },
628
614
  "patchOptions": {
629
- "reloadVersion": 0,
630
- "pipelineOptions": {
631
- "pipelineID": "pipelineID",
632
- "needTimestamps": true,
633
- "pipelineOrigin": "reactLynxHydrate",
634
- "dsl": "reactLynx",
635
- "stage": "hydrate"
636
- }
615
+ "reloadVersion": 0
637
616
  }
638
617
  }",
639
618
  ],
@@ -641,7 +620,7 @@ describe('alog', () => {
641
620
  "[ReactLynxDebug] FiberElement API call #32: __SetAttribute(#text#6, "text", 0)",
642
621
  ],
643
622
  [
644
- "[ReactLynxDebug] FiberElement API call #33: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
623
+ "[ReactLynxDebug] FiberElement API call #33: __FlushElementTree(PAGE#0, {})",
645
624
  ],
646
625
  ]
647
626
  `);
@@ -678,14 +657,7 @@ describe('alog', () => {
678
657
  ]
679
658
  },
680
659
  "patchOptions": {
681
- "reloadVersion": 0,
682
- "pipelineOptions": {
683
- "pipelineID": "pipelineID",
684
- "needTimestamps": true,
685
- "pipelineOrigin": "reactLynxHydrate",
686
- "dsl": "reactLynx",
687
- "stage": "hydrate"
688
- }
660
+ "reloadVersion": 0
689
661
  }
690
662
  }",
691
663
  ],
@@ -693,7 +665,7 @@ describe('alog', () => {
693
665
  "[ReactLynxDebug] FiberElement API call #32: __SetAttribute(#text#6, "text", 0)",
694
666
  ],
695
667
  [
696
- "[ReactLynxDebug] FiberElement API call #33: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
668
+ "[ReactLynxDebug] FiberElement API call #33: __FlushElementTree(PAGE#0, {})",
697
669
  ],
698
670
  ]
699
671
  `);
@@ -738,14 +710,7 @@ describe('alog', () => {
738
710
  ]
739
711
  },
740
712
  "patchOptions": {
741
- "reloadVersion": 0,
742
- "pipelineOptions": {
743
- "pipelineID": "pipelineID",
744
- "needTimestamps": true,
745
- "pipelineOrigin": "reactLynxHydrate",
746
- "dsl": "reactLynx",
747
- "stage": "hydrate"
748
- }
713
+ "reloadVersion": 0
749
714
  }
750
715
  }",
751
716
  ],
@@ -753,7 +718,7 @@ describe('alog', () => {
753
718
  "[ReactLynxDebug] FiberElement API call #34: __SetAttribute(#text#6, "text", 1)",
754
719
  ],
755
720
  [
756
- "[ReactLynxDebug] FiberElement API call #35: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
721
+ "[ReactLynxDebug] FiberElement API call #35: __FlushElementTree(PAGE#0, {})",
757
722
  ],
758
723
  ]
759
724
  `);
@@ -790,14 +755,7 @@ describe('alog', () => {
790
755
  ]
791
756
  },
792
757
  "patchOptions": {
793
- "reloadVersion": 0,
794
- "pipelineOptions": {
795
- "pipelineID": "pipelineID",
796
- "needTimestamps": true,
797
- "pipelineOrigin": "reactLynxHydrate",
798
- "dsl": "reactLynx",
799
- "stage": "hydrate"
800
- }
758
+ "reloadVersion": 0
801
759
  }
802
760
  }",
803
761
  ],
@@ -805,7 +763,7 @@ describe('alog', () => {
805
763
  "[ReactLynxDebug] FiberElement API call #34: __SetAttribute(#text#6, "text", 1)",
806
764
  ],
807
765
  [
808
- "[ReactLynxDebug] FiberElement API call #35: __FlushElementTree(PAGE#0, {"pipelineOptions":{"pipelineID":"pipelineID","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})",
766
+ "[ReactLynxDebug] FiberElement API call #35: __FlushElementTree(PAGE#0, {})",
809
767
  ],
810
768
  ]
811
769
  `);
@@ -120,13 +120,6 @@ test('state change will cause re-render', async () => {
120
120
  {
121
121
  "data": "{"patchList":[{"id":3,"snapshotPatch":[2,-1,2,0,"__snapshot_f46c5_test_2",3,0,null,4,3,4,0,"Hello World",1,3,4,null,0,1,-1,3,null,0]}]}",
122
122
  "patchOptions": {
123
- "pipelineOptions": {
124
- "dsl": "reactLynx",
125
- "needTimestamps": true,
126
- "pipelineID": "pipelineID",
127
- "pipelineOrigin": "reactLynxHydrate",
128
- "stage": "hydrate",
129
- },
130
123
  "reloadVersion": 0,
131
124
  },
132
125
  },
@@ -97,13 +97,6 @@ test('setState generates insertBefore operation', async () => {
97
97
  {
98
98
  "data": "{"patchList":[{"id":3,"snapshotPatch":[1,-2,-7,-5,0]}]}",
99
99
  "patchOptions": {
100
- "pipelineOptions": {
101
- "dsl": "reactLynx",
102
- "needTimestamps": true,
103
- "pipelineID": "pipelineID",
104
- "pipelineOrigin": "reactLynxHydrate",
105
- "stage": "hydrate",
106
- },
107
100
  "reloadVersion": 0,
108
101
  },
109
102
  },
@@ -268,13 +261,6 @@ test('setState triggered renderComponent should have correct slotIndex', async (
268
261
  {
269
262
  "data": "{"patchList":[{"id":3,"snapshotPatch":[2,-2,-4,0,"__snapshot_289e0_test_5",6,0,null,7,3,7,0,1,1,6,7,null,0,1,-2,6,null,1]}]}",
270
263
  "patchOptions": {
271
- "pipelineOptions": {
272
- "dsl": "reactLynx",
273
- "needTimestamps": true,
274
- "pipelineID": "pipelineID",
275
- "pipelineOrigin": "reactLynxHydrate",
276
- "stage": "hydrate",
277
- },
278
264
  "reloadVersion": 0,
279
265
  },
280
266
  },
@@ -674,4 +674,53 @@ describe('worklet', () => {
674
674
 
675
675
  expect(globalThis.classCaptureCb).toHaveBeenCalledWith(42);
676
676
  });
677
+
678
+ it('renders and invokes worklets with nullish optional member captures', () => {
679
+ globalThis.optionalCaptureCb = vi.fn();
680
+
681
+ const start = () => {
682
+ 'main thread';
683
+ globalThis.optionalCaptureCb('started');
684
+ };
685
+ const nestedStart = () => {
686
+ 'main thread';
687
+ globalThis.optionalCaptureCb('nested-started');
688
+ };
689
+
690
+ const Comp = ({ enabled, handlers }) => {
691
+ return (
692
+ <view
693
+ main-thread:bindtap={() => {
694
+ 'main thread';
695
+ if (enabled && handlers?.start) handlers.start();
696
+ if (enabled && handlers?.nested?.start) handlers.nested.start();
697
+ }}
698
+ />
699
+ );
700
+ };
701
+
702
+ const { container, rerender } = render(
703
+ <Comp enabled={false} handlers={null} />,
704
+ {
705
+ enableMainThread: true,
706
+ enableBackgroundThread: true,
707
+ },
708
+ );
709
+ fireEvent.tap(container.firstChild);
710
+ expect(globalThis.optionalCaptureCb).not.toHaveBeenCalled();
711
+
712
+ rerender(<Comp enabled={true} handlers={undefined} />);
713
+ fireEvent.tap(container.firstChild);
714
+ expect(globalThis.optionalCaptureCb).not.toHaveBeenCalled();
715
+
716
+ rerender(<Comp enabled={true} handlers={{ start, nested: null }} />);
717
+ fireEvent.tap(container.firstChild);
718
+ expect(globalThis.optionalCaptureCb).toHaveBeenCalledTimes(1);
719
+ expect(globalThis.optionalCaptureCb).toHaveBeenLastCalledWith('started');
720
+
721
+ rerender(<Comp enabled={true} handlers={{ start, nested: { start: nestedStart } }} />);
722
+ fireEvent.tap(container.firstChild);
723
+ expect(globalThis.optionalCaptureCb).toHaveBeenCalledTimes(3);
724
+ expect(globalThis.optionalCaptureCb).toHaveBeenLastCalledWith('nested-started');
725
+ });
677
726
  });