@lynx-js/react 0.126.1 → 0.126.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 (271) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +3 -3
  4. package/refresh/.turbo/turbo-build.log +3 -3
  5. package/refresh/dist/index.js +1 -2
  6. package/refresh/package.json +1 -1
  7. package/runtime/__test__/element-template/debug/profile-installation.test.tsx +97 -1
  8. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -1
  9. package/runtime/__test__/element-template/fixtures/render/child-siblings/index.js.txt +15 -11
  10. package/runtime/__test__/element-template/fixtures/render/component/index.js.txt +8 -7
  11. package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.js.txt +14 -10
  12. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.js.txt +4 -3
  13. package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/_shared.ts +2 -9
  14. package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/case.ts +2 -4
  15. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/case.ts +20 -0
  16. package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/case.ts +3 -16
  17. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/case.ts +18 -0
  18. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/case.ts +20 -0
  19. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/case.ts +18 -0
  20. package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/case.ts +15 -0
  21. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.js.txt +12 -11
  22. package/runtime/__test__/element-template/fixtures/render/mixed-children/index.js.txt +8 -7
  23. package/runtime/__test__/element-template/fixtures/render/multiple-text/index.js.txt +15 -13
  24. package/runtime/__test__/element-template/fixtures/render/nested-templates/index.js.txt +9 -7
  25. package/runtime/__test__/element-template/fixtures/render/react-example/index.js.txt +17 -20
  26. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.js.txt +13 -10
  27. package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.js.txt +14 -11
  28. package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +52 -7
  29. package/runtime/__test__/element-template/native/reload.test.ts +10 -26
  30. package/runtime/__test__/element-template/runtime/background/component-stack.test.tsx +76 -0
  31. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +87 -43
  32. package/runtime/__test__/element-template/runtime/background/instance.test.ts +14 -0
  33. package/runtime/__test__/element-template/runtime/render/compact-host-debug.test.ts +57 -0
  34. package/runtime/__test__/element-template/runtime/render/compact-host.test.ts +199 -0
  35. package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +292 -0
  36. package/runtime/__test__/element-template/runtime/render/{render-opcodes-into-element-template.et.test.tsx → render-direct-native.test.tsx} +50 -314
  37. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +378 -0
  38. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +491 -0
  39. package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -28
  40. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +21 -35
  41. package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +6 -5
  42. package/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +4 -4
  43. package/runtime/__test__/element-template/vitest.config.ts +2 -1
  44. package/runtime/__test__/snapshot/debug/main-thread-children-with-same-key.test.ts +28 -0
  45. package/runtime/__test__/snapshot/debug/profile.test.jsx +108 -3
  46. package/runtime/__test__/snapshot/lazy.test.js +44 -9
  47. package/runtime/__test__/snapshot/lifecycle/reloadGc.test.jsx +66 -0
  48. package/runtime/__test__/snapshot/lynx/runtime-version.test.ts +140 -0
  49. package/runtime/__test__/snapshot/spread.test.jsx +22 -15
  50. package/runtime/__test__/snapshot/ssr.legacy-slot.test.jsx +168 -0
  51. package/runtime/__test__/snapshot/ssr.list.test.jsx +211 -0
  52. package/runtime/__test__/worklet-runtime/hydrate.test.js +92 -0
  53. package/runtime/__test__/worklet-runtime/runOnBackground.test.js +8 -6
  54. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +3 -2
  55. package/runtime/lazy/element-template-import.js +0 -4
  56. package/runtime/lazy/element-template-internal.js +18 -8
  57. package/runtime/lazy/element-template-jsx-dev-runtime.js +1 -8
  58. package/runtime/lazy/element-template-jsx-runtime.js +1 -3
  59. package/runtime/lazy/element-template.js +1 -3
  60. package/runtime/lazy/import.js +0 -4
  61. package/runtime/lazy/internal.js +15 -1
  62. package/runtime/lazy/target.js +0 -21
  63. package/runtime/lib/core/hooks/react.d.ts +2 -0
  64. package/runtime/lib/core/hooks/react.js +2 -0
  65. package/runtime/lib/core/hooks/react.js.map +1 -1
  66. package/runtime/lib/core/lynx/runtime-version.d.ts +16 -0
  67. package/runtime/lib/core/lynx/runtime-version.js +51 -0
  68. package/runtime/lib/core/lynx/runtime-version.js.map +1 -0
  69. package/runtime/lib/element-template/background/document.d.ts +1 -1
  70. package/runtime/lib/element-template/background/document.js +1 -1
  71. package/runtime/lib/element-template/background/document.js.map +1 -1
  72. package/runtime/lib/element-template/background/hydrate.js +51 -19
  73. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  74. package/runtime/lib/element-template/background/instance.js +5 -6
  75. package/runtime/lib/element-template/background/instance.js.map +1 -1
  76. package/runtime/lib/element-template/debug/profile.js +38 -22
  77. package/runtime/lib/element-template/debug/profile.js.map +1 -1
  78. package/runtime/lib/element-template/index.d.ts +1 -1
  79. package/runtime/lib/element-template/index.js +1 -1
  80. package/runtime/lib/element-template/index.js.map +1 -1
  81. package/runtime/lib/element-template/internal.d.ts +4 -1
  82. package/runtime/lib/element-template/internal.js +6 -1
  83. package/runtime/lib/element-template/internal.js.map +1 -1
  84. package/runtime/lib/element-template/native/index.js +4 -0
  85. package/runtime/lib/element-template/native/index.js.map +1 -1
  86. package/runtime/lib/element-template/runtime/list/list.d.ts +1 -0
  87. package/runtime/lib/element-template/runtime/list/list.js +3 -0
  88. package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
  89. package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +7 -0
  90. package/runtime/lib/element-template/runtime/render/create-rendered-host.js +65 -0
  91. package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -0
  92. package/runtime/lib/element-template/runtime/render/host.d.ts +18 -0
  93. package/runtime/lib/element-template/runtime/render/host.js +25 -0
  94. package/runtime/lib/element-template/runtime/render/host.js.map +1 -0
  95. package/runtime/lib/element-template/runtime/render/render-components.d.ts +6 -0
  96. package/runtime/lib/element-template/runtime/render/render-components.js +190 -0
  97. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -0
  98. package/runtime/lib/element-template/runtime/render/{render-opcodes.d.ts → render-direct.d.ts} +3 -1
  99. package/runtime/lib/element-template/runtime/render/render-direct.js +194 -0
  100. package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -0
  101. package/runtime/lib/element-template/runtime/render/render-main-thread.js +10 -9
  102. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  103. package/runtime/lib/element-template/runtime/template/handle.d.ts +2 -1
  104. package/runtime/lib/element-template/runtime/template/handle.js +12 -4
  105. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
  106. package/runtime/lib/element-template/runtime-marker.js +13 -0
  107. package/runtime/lib/element-template/runtime-marker.js.map +1 -0
  108. package/runtime/lib/index.d.ts +1 -1
  109. package/runtime/lib/index.js +1 -1
  110. package/runtime/lib/index.js.map +1 -1
  111. package/runtime/lib/internal.d.ts +3 -1
  112. package/runtime/lib/internal.js +5 -1
  113. package/runtime/lib/internal.js.map +1 -1
  114. package/runtime/lib/lynx-api.d.ts +15 -6
  115. package/runtime/lib/lynx-api.js +13 -4
  116. package/runtime/lib/lynx-api.js.map +1 -1
  117. package/runtime/lib/runtime-marker.js +13 -0
  118. package/runtime/lib/runtime-marker.js.map +1 -0
  119. package/runtime/lib/shared/component-stack.js +5 -1
  120. package/runtime/lib/shared/component-stack.js.map +1 -1
  121. package/runtime/lib/snapshot/debug/profileHooks.js +38 -22
  122. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
  123. package/runtime/lib/snapshot/lifecycle/reload.js +3 -0
  124. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  125. package/runtime/lib/snapshot/lynx/calledByNative.js +3 -0
  126. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  127. package/runtime/lib/snapshot/lynx/element.d.ts +2 -0
  128. package/runtime/lib/snapshot/lynx/element.js +2 -0
  129. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  130. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +2 -1
  131. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  132. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  133. package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
  134. package/runtime/lib/worklet-runtime/hydrate.js +1 -1
  135. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  136. package/runtime/lib/worklet-runtime/workletRuntime.js +5 -14
  137. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  138. package/runtime/src/core/hooks/react.ts +2 -0
  139. package/runtime/src/core/lynx/runtime-version.ts +62 -0
  140. package/runtime/src/element-template/background/document.ts +3 -3
  141. package/runtime/src/element-template/background/hydrate.ts +61 -29
  142. package/runtime/src/element-template/background/instance.ts +5 -6
  143. package/runtime/src/element-template/debug/profile.ts +48 -36
  144. package/runtime/src/element-template/index.ts +1 -1
  145. package/runtime/src/element-template/internal.ts +12 -1
  146. package/runtime/src/element-template/native/index.ts +4 -0
  147. package/runtime/src/element-template/runtime/list/list.ts +4 -0
  148. package/runtime/src/element-template/runtime/render/create-rendered-host.ts +126 -0
  149. package/runtime/src/element-template/runtime/render/host.ts +51 -0
  150. package/runtime/src/element-template/runtime/render/render-components.ts +255 -0
  151. package/runtime/src/element-template/runtime/render/render-direct.ts +275 -0
  152. package/runtime/src/element-template/runtime/render/render-main-thread.ts +10 -9
  153. package/runtime/src/element-template/runtime/template/handle.ts +17 -7
  154. package/runtime/src/element-template/runtime-marker.ts +17 -0
  155. package/runtime/src/index.ts +1 -1
  156. package/runtime/src/internal.ts +10 -1
  157. package/runtime/src/lynx-api.ts +15 -6
  158. package/runtime/src/runtime-marker.ts +17 -0
  159. package/runtime/src/shared/component-stack.ts +5 -1
  160. package/runtime/src/snapshot/debug/profileHooks.ts +52 -40
  161. package/runtime/src/snapshot/lifecycle/reload.ts +4 -0
  162. package/runtime/src/snapshot/lynx/calledByNative.ts +4 -0
  163. package/runtime/src/snapshot/lynx/element.ts +2 -0
  164. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +2 -1
  165. package/runtime/src/worklet-runtime/bindings/types.ts +1 -1
  166. package/runtime/src/worklet-runtime/hydrate.ts +1 -1
  167. package/runtime/src/worklet-runtime/workletRuntime.ts +5 -14
  168. package/runtime/types/types.d.ts +2 -0
  169. package/runtime/worklet-runtime/dev.js +4 -16
  170. package/runtime/worklet-runtime/main.js +1 -1
  171. package/testing-library/.turbo/turbo-build.log +12 -12
  172. package/testing-library/dist/env/index.js +2 -2
  173. package/testing-library/dist/index.d.ts +2 -2
  174. package/testing-library/dist/plugins/index.js +1 -1
  175. package/testing-library/dist/pure.js +45 -44
  176. package/testing-library/etc/react-lynx-testing-library.api.md +1 -1
  177. package/testing-library/node_modules/.bin/rsbuild +19 -6
  178. package/testing-library/node_modules/.bin/rspeedy +17 -4
  179. package/testing-library/node_modules/.bin/rstest +19 -6
  180. package/testing-library/package.json +2 -2
  181. package/testing-library/src/__tests__/reload/reloadGc.test.jsx +64 -0
  182. package/testing-library/src/__tests__/reload/reloadTemplate.js +39 -0
  183. package/testing-library/types/entry.d.ts +2 -2
  184. package/transform/.turbo/turbo-build$colon$wasm.log +68 -56
  185. package/transform/__test__/fixture.spec.js +17 -20
  186. package/transform/__test__/text.spec.js +75 -0
  187. package/transform/crates/swc_plugin_compat/lib.rs +4 -3
  188. package/transform/crates/swc_plugin_compat/napi.rs +4 -3
  189. package/transform/crates/swc_plugin_define_dce/napi.rs +1 -1
  190. package/transform/crates/swc_plugin_dynamic_import/lib.rs +105 -3
  191. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_suffix_webpack_chunk_name.js +5 -0
  192. package/transform/crates/swc_plugin_element_template/host_lowering.rs +111 -0
  193. package/transform/crates/swc_plugin_element_template/lib.rs +41 -5
  194. package/transform/crates/swc_plugin_element_template/lowering.rs +39 -7
  195. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_generate_attribute_slots_for_dynamic_attributes.snap +1 -1
  196. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_background_conditional_attributes.snap +1 -1
  197. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_boolean_and_number_attributes.snap +1 -1
  198. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_complex_text_structure.snap +1 -1
  199. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dataset_attributes.snap +1 -1
  200. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_deeply_nested_user_components.snap +1 -1
  201. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dynamic_class_attributes.snap +1 -1
  202. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_lepus.snap +1 -1
  203. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_id_attributes.snap +1 -1
  204. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_inline_styles.snap +1 -1
  205. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_lepus.snap +1 -1
  206. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_mixed_content.snap +1 -1
  207. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_nested_structure_and_dynamic_content.snap +1 -1
  208. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_lepus.snap +1 -1
  209. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_sibling_user_components.snap +1 -1
  210. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_spread_attributes.snap +1 -1
  211. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_user_component.snap +1 -1
  212. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_isolate_arrays_with_child_slot_placeholder.snap +1 -1
  213. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_keep_code_and_template_attribute_slots_in_sync_for_spread.snap +1 -1
  214. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_element_template_simple_lepus.snap +1 -1
  215. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_template_with_static_attributes.snap +1 -1
  216. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_template_structure_complex.snap +1 -1
  217. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_text_attribute_and_child_text_slots.snap +1 -1
  218. package/transform/crates/swc_plugin_element_template/tests/element_template.rs +70 -66
  219. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +94 -8
  220. package/transform/crates/swc_plugin_shake/lib.rs +1 -1
  221. package/transform/crates/swc_plugin_shake/napi.rs +1 -1
  222. package/transform/crates/swc_plugin_text/lib.rs +57 -16
  223. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_keep_children_for_dynamic_or_multiple_text.js +13 -0
  224. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_string_expressions_to_text_attr.js +13 -0
  225. package/transform/crates/swc_plugins_shared/jsx_helpers.rs +8 -4
  226. package/transform/dist/wasm.cjs +1 -1
  227. package/transform/index.d.ts +7 -6
  228. package/transform/node_modules/.bin/esbuild +17 -4
  229. package/transform/node_modules/.bin/napi +17 -4
  230. package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
  231. package/transform/src/swc_plugin_extract_str/mod.rs +1 -1
  232. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +310 -114
  233. package/transform/swc-plugin-reactlynx/index.d.ts +2 -2
  234. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  235. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +10 -208
  236. package/transform/swc-plugin-reactlynx-compat/index.d.ts +3 -3
  237. package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
  238. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/case.ts +0 -39
  239. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/case.ts +0 -29
  240. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/case.ts +0 -42
  241. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/case.ts +0 -31
  242. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/passes-bundle-url-to-native-create/case.ts +0 -20
  243. package/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx +0 -522
  244. package/runtime/lib/element-template/runtime/render/render-opcodes.js +0 -216
  245. package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +0 -1
  246. package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +0 -16
  247. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +0 -324
  248. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +0 -1
  249. package/runtime/lib/element-template/runtime-backend-marker.js +0 -6
  250. package/runtime/lib/element-template/runtime-backend-marker.js.map +0 -1
  251. package/runtime/lib/runtime-backend-marker.js +0 -6
  252. package/runtime/lib/runtime-backend-marker.js.map +0 -1
  253. package/runtime/src/element-template/runtime/render/render-opcodes.ts +0 -313
  254. package/runtime/src/element-template/runtime/render/render-to-opcodes.ts +0 -411
  255. package/runtime/src/element-template/runtime-backend-marker.ts +0 -7
  256. package/runtime/src/runtime-backend-marker.ts +0 -7
  257. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/native-log.txt +0 -0
  258. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/output.txt +0 -0
  259. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/creates-template-from-attrs-and-slot-text/native-log.txt +0 -0
  260. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/creates-template-from-attrs-and-slot-text/output.txt +0 -0
  261. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/native-log.txt +0 -0
  262. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-template-children-in-the-same-slot/output.txt +0 -0
  263. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +0 -0
  264. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/handles-multiple-text-nodes-in-the-same-slot/output.txt +0 -0
  265. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/native-log.txt +0 -0
  266. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/output.txt +0 -0
  267. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/native-log.txt +0 -0
  268. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/output.txt +0 -0
  269. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/passes-bundle-url-to-native-create/native-log.txt +0 -0
  270. /package/runtime/lib/element-template/{runtime-backend-marker.d.ts → runtime-marker.d.ts} +0 -0
  271. /package/runtime/lib/{runtime-backend-marker.d.ts → runtime-marker.d.ts} +0 -0
@@ -6,8 +6,7 @@
6
6
  * Implements the IFR (Instant First-Frame Rendering) on main thread.
7
7
  */
8
8
 
9
- import { renderOpcodesIntoElementTemplate } from './render-opcodes.js';
10
- import { render as renderToString } from './render-to-opcodes.js';
9
+ import { renderToElementTemplate } from './render-direct.js';
11
10
  import { getReloadVersion } from '../../../core/reload-version.js';
12
11
  import { profileEnd, profileStart } from '../../debug/profile.js';
13
12
  import { ElementTemplateLifecycleConstant } from '../../protocol/lifecycle-constant.js';
@@ -21,20 +20,22 @@ import { getElementTemplateNativeRef } from '../template/registry.js';
21
20
  import { TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX } from '../template/typed-attributes.js';
22
21
 
23
22
  function renderMainThread(): void {
24
- let opcodes;
23
+ let rendered;
25
24
  profileStart('ReactLynx::renderMainThread');
26
25
  try {
27
- opcodes = renderToString(__root.__jsx, undefined);
28
- } catch (e) {
29
- lynx.reportError(e as Error);
30
- opcodes = [];
26
+ rendered = renderToElementTemplate(__root.__jsx, undefined);
27
+ } catch (error) {
28
+ // Like Snapshot, any failure during synchronous rendering is reported at
29
+ // the lifecycle boundary before committing an empty result.
30
+ lynx.reportError(error as Error);
31
+ rendered = { pageAttributes: null, rootRefs: [], rootSubtreeHandles: [] };
31
32
  } finally {
32
33
  profileEnd();
33
34
  }
34
35
 
35
- profileStart('ReactLynx::renderOpcodes');
36
+ profileStart('ReactLynx::commitElementTemplate');
36
37
  try {
37
- const { pageAttributes, rootRefs, rootSubtreeHandles } = renderOpcodesIntoElementTemplate(opcodes);
38
+ const { pageAttributes, rootRefs, rootSubtreeHandles } = rendered;
38
39
  __SetAttributeOfElementTemplate(__page, TYPED_ELEMENT_ATTRIBUTES_SLOT_INDEX, pageAttributes);
39
40
  for (let index = 0; index < rootRefs.length; index += 1) {
40
41
  const rootRef = rootRefs[index]!;
@@ -22,6 +22,10 @@ import type {
22
22
  // Main-thread IFR allocates ids as consecutive negative integers.
23
23
  let nextId = -1;
24
24
 
25
+ export function getNextElementTemplateId(): number {
26
+ return nextId;
27
+ }
28
+
25
29
  export function reserveElementTemplateId(): number {
26
30
  const id = nextId--;
27
31
  return id;
@@ -33,9 +37,13 @@ export function createElementTemplateWithReservedHandle(
33
37
  bundleUrl: string | null | undefined,
34
38
  attributeSlots: SerializableValue[] | null | undefined,
35
39
  childSlots: RuntimeChildSlots | null | undefined,
40
+ hasDynamicAttributes = true,
36
41
  ): ElementTemplateHandle {
37
- const templateType = elementTemplateTypeTag(templateKey, bundleUrl);
38
- const nativeAttributeSlots = prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);
42
+ // Adapter-free compiled hosts need neither dynamic state nor native slot preparation.
43
+ const templateType = hasDynamicAttributes ? elementTemplateTypeTag(templateKey, bundleUrl) : undefined;
44
+ const nativeAttributeSlots = templateType === undefined
45
+ ? attributeSlots
46
+ : prepareMainThreadDynamicAttrSlotsForNative(templateType, attributeSlots);
39
47
  const nativeRef = __CreateElementTemplate(
40
48
  templateKey,
41
49
  bundleUrl,
@@ -45,11 +53,13 @@ export function createElementTemplateWithReservedHandle(
45
53
  );
46
54
  if (nativeRef) {
47
55
  setElementTemplateNativeRef(handleId, nativeRef);
48
- initializeMainThreadDynamicAttrSlots(
49
- handleId,
50
- templateType,
51
- attributeSlots,
52
- );
56
+ if (templateType !== undefined) {
57
+ initializeMainThreadDynamicAttrSlots(
58
+ handleId,
59
+ templateType,
60
+ attributeSlots,
61
+ );
62
+ }
53
63
  }
54
64
  return nativeRef;
55
65
  }
@@ -0,0 +1,17 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ // Side-effect entry that registers this bundle's runtime markers (backend,
6
+ // version, ...) on load. Imported once by the element-template runtime entry
7
+ // so later-loaded lazy bundles register their own markers too.
8
+
9
+ import { RUNTIME_BACKEND_ELEMENT_TEMPLATE, registerRuntimeBackend } from '../core/lynx/runtime-backend.js';
10
+ import { registerRuntimeVersion } from '../core/lynx/runtime-version.js';
11
+
12
+ registerRuntimeBackend(RUNTIME_BACKEND_ELEMENT_TEMPLATE);
13
+ // An older `react-webpack-plugin` may not stamp `__RUNTIME_VERSION__`. Guard
14
+ // with `typeof` so referencing it does not throw when the define is missing.
15
+ registerRuntimeVersion(
16
+ typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
17
+ );
@@ -2,7 +2,7 @@
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
- import './runtime-backend-marker.js';
5
+ import './runtime-marker.js';
6
6
  import './lynx.js';
7
7
  import {
8
8
  Component,
@@ -5,7 +5,7 @@
5
5
  import { Suspense, createElement, lazy, cloneElement as preactCloneElement } from 'preact/compat';
6
6
  import type { FC } from 'react';
7
7
 
8
- import './runtime-backend-marker.js';
8
+ import './runtime-marker.js';
9
9
  import './lynx.js';
10
10
 
11
11
  import { useMemo } from './core/hooks/react.js';
@@ -73,6 +73,15 @@ export type { Options } from 'preact';
73
73
 
74
74
  export { loadDynamicJS, __dynamicImport } from './core/lynx/dynamic-import.js';
75
75
 
76
+ // Re-exported so lazy bundle shells can reach the host runtime APIs
77
+ // via `target[sExportsReactInternal]`.
78
+ export { registerRuntimeVersion, getRuntimeVersion } from './core/lynx/runtime-version.js';
79
+ export {
80
+ RUNTIME_BACKEND_ELEMENT_TEMPLATE,
81
+ RUNTIME_BACKEND_SNAPSHOT,
82
+ registerRuntimeBackend,
83
+ } from './core/lynx/runtime-backend.js';
84
+
76
85
  export { withInitDataInState } from './core/initData.js';
77
86
 
78
87
  export { wrapWithLynxComponent } from './core/compat/lynxComponent.js';
@@ -207,6 +207,7 @@ export const InitDataConsumer: Consumer<InitData> = /* @__PURE__ */ _InitData.Co
207
207
  * }
208
208
  * ```
209
209
  *
210
+ * @function
210
211
  * @public
211
212
  */
212
213
  export const useInitData: () => InitData = /* @__PURE__ */ _InitData.use();
@@ -221,6 +222,7 @@ export const useInitData: () => InitData = /* @__PURE__ */ _InitData.use();
221
222
  * })
222
223
  * }
223
224
  * ```
225
+ * @function
224
226
  * @public
225
227
  */
226
228
  export const useInitDataChanged: (callback: (data: InitData) => void) => void = /* @__PURE__ */ _InitData.useChanged();
@@ -235,12 +237,15 @@ const _GlobalProps = /* @__PURE__ */ createGlobalProps<GlobalProps>({
235
237
  });
236
238
 
237
239
  /**
238
- * The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps`,
239
- * you must wrap your JSX inside it
240
+ * The {@link https://react.dev/reference/react/createContext#provider | Provider} Component that provide `lynx.__globalProps`.
241
+ * Only needed with `globalPropsMode: 'event'`; in the default `'reactive'` mode it renders its children directly
242
+ * and updates come from a full re-render.
240
243
  * @group Components
241
244
  *
242
245
  * @example
243
246
  *
247
+ * With `globalPropsMode: 'event'`:
248
+ *
244
249
  * ```ts
245
250
  * import { root } from "@lynx-js/react"
246
251
  *
@@ -265,7 +270,8 @@ export const GlobalPropsProvider: FC<{ children?: ReactNode | undefined }> = /*
265
270
 
266
271
  /**
267
272
  * The {@link https://react.dev/reference/react/createContext#consumer | Consumer} Component that provide `lynx.__globalProps`.
268
- * This should be used with {@link GlobalPropsProvider}
273
+ * Only needed with `globalPropsMode: 'event'`, together with {@link GlobalPropsProvider}; in the default `'reactive'` mode
274
+ * it calls `children` with `lynx.__globalProps` directly and updates come from a full re-render.
269
275
  * @group Components
270
276
  * @public
271
277
  */
@@ -274,7 +280,8 @@ export const GlobalPropsConsumer: Consumer<GlobalProps> = /* @__PURE__ */ _Globa
274
280
 
275
281
  /**
276
282
  * A React Hooks for you to get `lynx.__globalProps`.
277
- * If `lynx.__globalProps` is changed, a re-render will be triggered automatically.
283
+ * With `globalPropsMode: 'event'`, the component re-renders when `lynx.__globalProps` changes;
284
+ * in the default `'reactive'` mode, updates arrive through a full re-render.
278
285
  *
279
286
  * @example
280
287
  *
@@ -286,6 +293,7 @@ export const GlobalPropsConsumer: Consumer<GlobalProps> = /* @__PURE__ */ _Globa
286
293
  * }
287
294
  * ```
288
295
  *
296
+ * @function
289
297
  * @public
290
298
  */
291
299
  export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.use();
@@ -302,6 +310,7 @@ export const useGlobalProps: () => GlobalProps = /* @__PURE__ */ _GlobalProps.us
302
310
  * })
303
311
  * }
304
312
  * ```
313
+ * @function
305
314
  * @public
306
315
  */
307
316
  export const useGlobalPropsChanged: (callback: (data: GlobalProps) => void) => void = /* @__PURE__ */ _GlobalProps
@@ -523,7 +532,7 @@ export interface Lynx {
523
532
  * they can achieve it by extends interface `InitDataRaw` and `InitData`.
524
533
  *
525
534
  * ```ts
526
- * import { root, useInitData } from "@lynx-js/react"
535
+ * import { useInitData } from "@lynx-js/react"
527
536
  *
528
537
  * interface AnotherExistingInterface {
529
538
  * someAnotherPropertyFromExistingInterface: number
@@ -535,7 +544,7 @@ export interface Lynx {
535
544
  * }
536
545
  * }
537
546
  *
538
- * root.registerDataProcessors({
547
+ * lynx.registerDataProcessors({
539
548
  * defaultDataProcessor: () => {
540
549
  * return {
541
550
  * someCustomProperty: 'value', // will be typed
@@ -0,0 +1,17 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ // Side-effect entry that registers this bundle's runtime markers (backend,
6
+ // version, ...) on load. Imported once by the runtime entry so later-loaded
7
+ // lazy bundles register their own markers too.
8
+
9
+ import { RUNTIME_BACKEND_SNAPSHOT, registerRuntimeBackend } from './core/lynx/runtime-backend.js';
10
+ import { registerRuntimeVersion } from './core/lynx/runtime-version.js';
11
+
12
+ registerRuntimeBackend(RUNTIME_BACKEND_SNAPSHOT);
13
+ // An older `react-webpack-plugin` may not stamp `__RUNTIME_VERSION__`. Guard
14
+ // with `typeof` so referencing it does not throw when the define is missing.
15
+ registerRuntimeVersion(
16
+ typeof __RUNTIME_VERSION__ === 'undefined' ? undefined : __RUNTIME_VERSION__,
17
+ );
@@ -154,7 +154,11 @@ export function setupComponentStack(): void {
154
154
  };
155
155
 
156
156
  options.vnode = (vnode: PatchedVNode) => {
157
- vnode._owner = ownerStack.length > 0 ? ownerStack[ownerStack.length - 1]! : null;
157
+ // Scheduled component updates clone the vnode before entering its render scope.
158
+ // Preserve the original owner when Preact invokes this hook for that clone.
159
+ if (vnode._owner === undefined) {
160
+ vnode._owner = ownerStack.length > 0 ? ownerStack[ownerStack.length - 1]! : null;
161
+ }
158
162
  if (oldVNode) oldVNode(vnode);
159
163
  };
160
164
 
@@ -22,7 +22,7 @@ import {
22
22
  VALUE,
23
23
  VNODE,
24
24
  } from '../../shared/render-constants.js';
25
- import { getDisplayName, hook } from '../../utils.js';
25
+ import { getDisplayName } from '../../utils.js';
26
26
  import { globalPatchOptions } from '../lifecycle/patch/commit.js';
27
27
  import { __globalSnapshotPatch } from '../lifecycle/patch/snapshotPatch.js';
28
28
 
@@ -103,33 +103,35 @@ export function initProfileHook(): void {
103
103
  type PatchedComponent = Component & { [sFlowID]?: number };
104
104
 
105
105
  if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
106
- hook(
107
- Component.prototype,
108
- 'setState',
109
- function(this: PatchedComponent & { [NEXT_STATE]: unknown }, old, state, callback) {
110
- old?.call(this, state, callback);
106
+ // eslint-disable-next-line @typescript-eslint/unbound-method
107
+ const oldSetState = Component.prototype.setState;
108
+ Component.prototype.setState = function(this: PatchedComponent & { [NEXT_STATE]: unknown }, state, callback) {
109
+ oldSetState?.call(this, state, callback);
111
110
 
112
- if (this[BITS] & COMPONENT_DIRTY) {
113
- const type = this[VNODE]!.type;
114
- const isClassComponent = typeof type === 'function' && ('prototype' in type)
115
- && ('render' in type.prototype);
111
+ if (this[BITS] & COMPONENT_DIRTY) {
112
+ const type = this[VNODE]!.type;
113
+ const isClassComponent = typeof type === 'function' && ('prototype' in type)
114
+ && ('render' in type.prototype);
116
115
 
117
- if (isClassComponent) {
118
- profileMark('ReactLynx::setState', {
119
- flowId: this[sFlowID] ??= profileFlowId(),
120
- args: buildSetStateProfileMarkArgs(
121
- type,
122
- this.state,
123
- this[NEXT_STATE],
124
- ),
125
- });
126
- }
116
+ if (isClassComponent) {
117
+ profileMark('ReactLynx::setState', {
118
+ flowId: this[sFlowID] ??= profileFlowId(),
119
+ args: buildSetStateProfileMarkArgs(
120
+ type,
121
+ this.state,
122
+ this[NEXT_STATE],
123
+ ),
124
+ });
127
125
  }
128
- },
129
- );
126
+ }
127
+ };
130
128
  }
131
129
 
132
- hook(options, DIFF2, (old, vnode, oldVNode) => {
130
+ // These hot callbacks have fixed signatures; avoid collecting and spreading
131
+ // an argument array for every host and component visited.
132
+ // eslint-disable-next-line @typescript-eslint/unbound-method
133
+ const oldDiff2 = options[DIFF2];
134
+ options[DIFF2] = (vnode, oldVNode) => {
133
135
  // We only add profiling trace for Component
134
136
  if (typeof vnode.type === 'function') {
135
137
  const profileOptions: TraceOption = {};
@@ -152,10 +154,12 @@ export function initProfileHook(): void {
152
154
  profileOptions,
153
155
  );
154
156
  }
155
- old?.(vnode, oldVNode);
156
- });
157
+ oldDiff2?.(vnode, oldVNode);
158
+ };
157
159
 
158
- hook(options, DIFFED, (old, vnode) => {
160
+ // eslint-disable-next-line @typescript-eslint/unbound-method
161
+ const oldDiffed = options[DIFFED];
162
+ options[DIFFED] = vnode => {
159
163
  if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
160
164
  const hooks = vnode[COMPONENT]?.[HOOKS];
161
165
  const hookList = hooks?.[LIST];
@@ -205,11 +209,13 @@ export function initProfileHook(): void {
205
209
  if (typeof vnode.type === 'function') {
206
210
  profileEnd(); // for options[DIFF2]
207
211
  }
208
- old?.(vnode);
209
- });
212
+ oldDiffed?.(vnode);
213
+ };
210
214
 
211
215
  if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
212
- hook(options, COMMIT, (old, vnode, commitQueue) => {
216
+ // eslint-disable-next-line @typescript-eslint/unbound-method
217
+ const oldCommit = options[COMMIT];
218
+ options[COMMIT] = (vnode, commitQueue) => {
213
219
  profileStart('ReactLynx::commit', {
214
220
  ...globalPatchOptions.flowIds
215
221
  ? {
@@ -218,14 +224,16 @@ export function initProfileHook(): void {
218
224
  }
219
225
  : {},
220
226
  });
221
- old?.(vnode, commitQueue);
227
+ oldCommit?.(vnode, commitQueue);
222
228
  profileEnd();
223
- });
229
+ };
224
230
  }
225
231
  }
226
232
 
227
233
  // Profile the user-provided `render`.
228
- hook(options, RENDER, (old, vnode: VNode) => {
234
+ // eslint-disable-next-line @typescript-eslint/unbound-method
235
+ const oldRender = options[RENDER];
236
+ options[RENDER] = (vnode: VNode) => {
229
237
  // eslint-disable-next-line @typescript-eslint/unbound-method
230
238
  const originalRender = vnode[COMPONENT]!.render;
231
239
  vnode[COMPONENT]!.render = function render(this, props, state, context) {
@@ -237,22 +245,26 @@ export function initProfileHook(): void {
237
245
  vnode[COMPONENT]!.render = originalRender;
238
246
  }
239
247
  };
240
- old?.(vnode);
241
- });
248
+ oldRender?.(vnode);
249
+ };
242
250
 
243
251
  if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
244
252
  const sPatchLength = Symbol('PATCH_LENGTH');
245
253
 
246
254
  type PatchedVNode = VNode & { [sPatchLength]?: number };
247
255
 
248
- hook(options, DIFF, (old, vnode: PatchedVNode) => {
256
+ // eslint-disable-next-line @typescript-eslint/unbound-method
257
+ const oldDiff = options[DIFF];
258
+ options[DIFF] = (vnode: PatchedVNode) => {
249
259
  if (typeof vnode.type === 'function' && __globalSnapshotPatch) {
250
260
  vnode[sPatchLength] = __globalSnapshotPatch.length;
251
261
  }
252
- old?.(vnode);
253
- });
262
+ oldDiff?.(vnode);
263
+ };
254
264
 
255
- hook(options, DIFFED, (old, vnode: PatchedVNode) => {
265
+ // eslint-disable-next-line @typescript-eslint/unbound-method
266
+ const oldPatchDiffed = options[DIFFED];
267
+ options[DIFFED] = (vnode: PatchedVNode) => {
256
268
  if (typeof vnode.type === 'function') {
257
269
  const patchLength = vnode[sPatchLength];
258
270
  delete vnode[sPatchLength];
@@ -265,7 +277,7 @@ export function initProfileHook(): void {
265
277
  });
266
278
  }
267
279
  }
268
- old?.(vnode);
269
- });
280
+ oldPatchDiffed?.(vnode);
281
+ };
270
282
  }
271
283
  }
@@ -52,6 +52,10 @@ function reloadMainThread(data: unknown, options: UpdatePageOption): void {
52
52
  __pendingListUpdates.flush();
53
53
  applyRefQueue();
54
54
 
55
+ if (typeof lepusng_gc === 'function') {
56
+ lepusng_gc();
57
+ }
58
+
55
59
  if (isFirstScreenSynced) {
56
60
  __OnLifecycleEvent([
57
61
  LifecycleConstant.firstScreen, /* FIRST_SCREEN */
@@ -161,6 +161,10 @@ function updatePage(data: Record<string, unknown> | undefined, options?: UpdateP
161
161
 
162
162
  flushOptions.triggerDataUpdated = true;
163
163
  markTiming('updateDiffVdomEnd');
164
+
165
+ if (typeof lepusng_gc === 'function') {
166
+ lepusng_gc();
167
+ }
164
168
  }
165
169
 
166
170
  __FlushElementTree(__page, flushOptions);
@@ -107,6 +107,7 @@ function pickChildrenProps(
107
107
  /**
108
108
  * Creates a ReactLynx element using the snapshot runtime.
109
109
  *
110
+ * @function
110
111
  * @public
111
112
  */
112
113
  export const createElement =
@@ -143,6 +144,7 @@ export const createElement =
143
144
  /**
144
145
  * Clones a ReactLynx element using the snapshot runtime.
145
146
  *
147
+ * @function
146
148
  * @public
147
149
  */
148
150
  export const cloneElement =
@@ -47,7 +47,8 @@ export function ssrHydrateByOpcodes(
47
47
  delete top.__pendingElements;
48
48
 
49
49
  if (top.__snapshot_def.isListHolder) {
50
- const listElement = top.__element_root!;
50
+ const [, elementIndex] = top.__snapshot_def.slot[0]!;
51
+ const listElement = top.__elements[elementIndex]!;
51
52
  const listElementUniqueID = __GetElementUniqueID(listElement);
52
53
  const signMap = gSignMap[listElementUniqueID] = new Map();
53
54
  gRecycleMap[listElementUniqueID] = new Map();
@@ -35,7 +35,7 @@ export type ClosureValueType =
35
35
  | WorkletRef<unknown>
36
36
  | Element
37
37
  | (((...args: unknown[]) => unknown) & {
38
- ctxRef?: WeakRef<object>;
38
+ boundCtx?: object;
39
39
  })
40
40
  | ClosureValueType_
41
41
  | ClosureValueType[];
@@ -52,7 +52,7 @@ function hydrateCtxImpl(
52
52
  );
53
53
  } else {
54
54
  const firstScreenValue = typeof firstScreenCtxObj[key] === 'function'
55
- ? (firstScreenCtxObj[key] as { ctxRef?: WeakRef<object> }).ctxRef?.deref() as ClosureValueType
55
+ ? (firstScreenCtxObj[key] as { boundCtx?: object }).boundCtx as ClosureValueType
56
56
  : firstScreenCtxObj[key];
57
57
  hydrateCtxImpl(ctxObj[key], firstScreenValue, execId);
58
58
  }
@@ -180,15 +180,14 @@ const transformWorkletInner = (
180
180
  if (isWorklet) {
181
181
  const isRootWorklet = subObj === ctx;
182
182
  const boundCtx = { ...subObj };
183
- // `subObj` is worklet ctx. Shallow copy it to prevent the transformed worklet from referencing ctx.
184
- // This would result in the value of `workletCache` referencing its key.
183
+ // Keep the original context collectible. PrimJS traces WeakMap values even
184
+ // when their keys are otherwise unreachable, so the cached function must not point back to its key.
185
185
  obj[key] = lynxWorkletImpl._workletMap[(subObj as Worklet)._wkltId]!
186
186
  .bind(boundCtx);
187
187
  if (!isRootWorklet) {
188
- const ctxRef = createWeakCtxRef(subObj as object);
189
- if (ctxRef) {
190
- obj[key].ctxRef = ctxRef;
191
- }
188
+ // Hydration needs the same context that the function already owns through bind().
189
+ // The original nested context can disappear after its parent replaces it with this function.
190
+ obj[key].boundCtx = boundCtx;
192
191
  }
193
192
  continue;
194
193
  }
@@ -204,12 +203,4 @@ const transformWorkletInner = (
204
203
  }
205
204
  };
206
205
 
207
- function createWeakCtxRef(ctx: object): WeakRef<object> | undefined {
208
- try {
209
- return new WeakRef(ctx);
210
- } catch {
211
- return undefined;
212
- }
213
- }
214
-
215
206
  export { initWorklet };
@@ -27,12 +27,14 @@ declare global {
27
27
  declare const __BACKGROUND__: boolean;
28
28
  declare const __MAIN_THREAD__: boolean;
29
29
  declare const __PROFILE__: boolean;
30
+ declare const lepusng_gc: (() => void) | undefined;
30
31
  declare const __REACT_DEVTOOL__: boolean | undefined;
31
32
  declare const __ALOG__: boolean | undefined;
32
33
  declare const __ALOG_ELEMENT_API__: boolean | undefined;
33
34
  declare const __ENABLE_SSR__: boolean;
34
35
  declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
35
36
  declare const __LAZY_BUNDLE_FETCHER__: 'FetchBundle' | 'QueryComponent';
37
+ declare const __RUNTIME_VERSION__: string | undefined;
36
38
  declare function __CreatePage(componentId: string, cssId: number): FiberElement;
37
39
  declare function __CreateElement(
38
40
  tag: string,