@lynx-js/react 0.126.1 → 0.127.0

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 (398) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/docs/directives.md +90 -0
  4. package/docs/global-events.md +50 -0
  5. package/docs/import-attributes.md +43 -0
  6. package/docs/macros.md +285 -0
  7. package/package.json +4 -3
  8. package/refresh/.turbo/turbo-build.log +4 -4
  9. package/refresh/dist/index.js +27 -8
  10. package/refresh/package.json +2 -2
  11. package/runtime/__test__/core/main-thread-object.test.js +149 -0
  12. package/runtime/__test__/element-template/debug/profile-installation.test.tsx +97 -1
  13. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +1 -1
  14. package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +26 -3
  15. package/runtime/__test__/element-template/fixtures/render/child-siblings/index.js.txt +15 -11
  16. package/runtime/__test__/element-template/fixtures/render/component/index.js.txt +8 -7
  17. package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.js.txt +14 -10
  18. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.js.txt +4 -3
  19. package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/_shared.ts +2 -9
  20. package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/case.ts +2 -4
  21. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/case.ts +20 -0
  22. 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
  23. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/case.ts +18 -0
  24. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/case.ts +20 -0
  25. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/case.ts +18 -0
  26. package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/case.ts +15 -0
  27. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.js.txt +12 -11
  28. package/runtime/__test__/element-template/fixtures/render/mixed-children/index.js.txt +8 -7
  29. package/runtime/__test__/element-template/fixtures/render/multiple-text/index.js.txt +15 -13
  30. package/runtime/__test__/element-template/fixtures/render/nested-templates/index.js.txt +9 -7
  31. package/runtime/__test__/element-template/fixtures/render/react-example/index.js.txt +17 -20
  32. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.js.txt +13 -10
  33. package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.js.txt +14 -11
  34. package/runtime/__test__/element-template/imports/main-thread-object-api.test.ts +10 -0
  35. package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +52 -7
  36. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +3 -0
  37. package/runtime/__test__/element-template/native/reload.test.ts +10 -26
  38. package/runtime/__test__/element-template/runtime/background/component-stack.test.tsx +76 -0
  39. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +87 -43
  40. package/runtime/__test__/element-template/runtime/background/instance.test.ts +14 -0
  41. package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +4 -0
  42. package/runtime/__test__/element-template/runtime/render/compact-host-debug.test.ts +57 -0
  43. package/runtime/__test__/element-template/runtime/render/compact-host.test.ts +199 -0
  44. package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +292 -0
  45. package/runtime/__test__/element-template/runtime/render/{render-opcodes-into-element-template.et.test.tsx → render-direct-native.test.tsx} +50 -314
  46. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +378 -0
  47. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +491 -0
  48. package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +2 -28
  49. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +21 -35
  50. package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +6 -5
  51. package/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +4 -4
  52. package/runtime/__test__/element-template/vitest.config.ts +2 -1
  53. package/runtime/__test__/snapshot/ctxNotFound.test.ts +271 -0
  54. package/runtime/__test__/snapshot/debug/main-thread-children-with-same-key.test.ts +28 -0
  55. package/runtime/__test__/snapshot/debug/profile.test.jsx +108 -3
  56. package/runtime/__test__/snapshot/event.test.jsx +7 -7
  57. package/runtime/__test__/snapshot/lazy.test.js +114 -7
  58. package/runtime/__test__/snapshot/lifecycle/reloadGc.test.jsx +66 -0
  59. package/runtime/__test__/snapshot/lynx/portals.test.jsx +75 -37
  60. package/runtime/__test__/snapshot/lynx/runtime-version.test.ts +140 -0
  61. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +59 -47
  62. package/runtime/__test__/snapshot/spread.test.jsx +32 -25
  63. package/runtime/__test__/snapshot/ssr.legacy-slot.test.jsx +168 -0
  64. package/runtime/__test__/snapshot/ssr.list.test.jsx +211 -0
  65. package/runtime/__test__/snapshot/worklet/main-thread-object.test.jsx +306 -0
  66. package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +1 -0
  67. package/runtime/__test__/worklet-runtime/hydrate.test.js +92 -0
  68. package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +182 -0
  69. package/runtime/__test__/worklet-runtime/object-methods.test.js +60 -0
  70. package/runtime/__test__/worklet-runtime/runOnBackground.test.js +8 -6
  71. package/runtime/__test__/worklet-runtime/workletRef.test.js +362 -2
  72. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +249 -3
  73. package/runtime/lazy/compat.js +2 -0
  74. package/runtime/lazy/element-template-import.js +0 -4
  75. package/runtime/lazy/element-template-internal.js +19 -8
  76. package/runtime/lazy/element-template-jsx-dev-runtime.js +1 -8
  77. package/runtime/lazy/element-template-jsx-runtime.js +1 -3
  78. package/runtime/lazy/element-template.js +3 -3
  79. package/runtime/lazy/import.js +0 -4
  80. package/runtime/lazy/internal.js +17 -1
  81. package/runtime/lazy/react.js +2 -0
  82. package/runtime/lazy/target.js +0 -21
  83. package/runtime/lib/core/background-function/run-on-background.d.ts +16 -0
  84. package/runtime/lib/core/background-function/run-on-background.js +16 -0
  85. package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
  86. package/runtime/lib/core/capture-main-thread-object.js +16 -0
  87. package/runtime/lib/core/capture-main-thread-object.js.map +1 -0
  88. package/runtime/lib/core/globalProps.d.ts +2 -0
  89. package/runtime/lib/core/globalProps.js.map +1 -1
  90. package/runtime/lib/core/hooks/react.d.ts +6 -0
  91. package/runtime/lib/core/hooks/react.js +6 -0
  92. package/runtime/lib/core/hooks/react.js.map +1 -1
  93. package/runtime/lib/core/hooks/useLynxGlobalEventListener.d.ts +2 -0
  94. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +2 -0
  95. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
  96. package/runtime/lib/core/initData.d.ts +2 -0
  97. package/runtime/lib/core/initData.js +2 -0
  98. package/runtime/lib/core/initData.js.map +1 -1
  99. package/runtime/lib/core/lynx/runtime-version.d.ts +16 -0
  100. package/runtime/lib/core/lynx/runtime-version.js +51 -0
  101. package/runtime/lib/core/lynx/runtime-version.js.map +1 -0
  102. package/runtime/lib/core/main-thread-object-handle-registry.d.ts +3 -0
  103. package/runtime/lib/core/main-thread-object-handle-registry.js +17 -0
  104. package/runtime/lib/core/main-thread-object-handle-registry.js.map +1 -0
  105. package/runtime/lib/core/main-thread-object.d.ts +77 -0
  106. package/runtime/lib/core/main-thread-object.js +261 -0
  107. package/runtime/lib/core/main-thread-object.js.map +1 -0
  108. package/runtime/lib/core/main-thread-ref-id.js +14 -0
  109. package/runtime/lib/core/main-thread-ref-id.js.map +1 -0
  110. package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -1
  111. package/runtime/lib/core/main-thread-ref-init-value.js +4 -2
  112. package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -1
  113. package/runtime/lib/core/main-thread-ref.d.ts +4 -0
  114. package/runtime/lib/core/main-thread-ref.js +5 -8
  115. package/runtime/lib/core/main-thread-ref.js.map +1 -1
  116. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  117. package/runtime/lib/element-template/background/document.d.ts +1 -1
  118. package/runtime/lib/element-template/background/document.js +1 -1
  119. package/runtime/lib/element-template/background/document.js.map +1 -1
  120. package/runtime/lib/element-template/background/hydrate.js +51 -19
  121. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  122. package/runtime/lib/element-template/background/instance.js +5 -6
  123. package/runtime/lib/element-template/background/instance.js.map +1 -1
  124. package/runtime/lib/element-template/debug/profile.js +38 -22
  125. package/runtime/lib/element-template/debug/profile.js.map +1 -1
  126. package/runtime/lib/element-template/index.d.ts +3 -1
  127. package/runtime/lib/element-template/index.js +2 -1
  128. package/runtime/lib/element-template/index.js.map +1 -1
  129. package/runtime/lib/element-template/internal.d.ts +5 -1
  130. package/runtime/lib/element-template/internal.js +7 -1
  131. package/runtime/lib/element-template/internal.js.map +1 -1
  132. package/runtime/lib/element-template/native/index.js +4 -0
  133. package/runtime/lib/element-template/native/index.js.map +1 -1
  134. package/runtime/lib/element-template/protocol/types.d.ts +1 -1
  135. package/runtime/lib/element-template/runtime/list/list.d.ts +1 -0
  136. package/runtime/lib/element-template/runtime/list/list.js +3 -0
  137. package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
  138. package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +7 -0
  139. package/runtime/lib/element-template/runtime/render/create-rendered-host.js +65 -0
  140. package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -0
  141. package/runtime/lib/element-template/runtime/render/host.d.ts +18 -0
  142. package/runtime/lib/element-template/runtime/render/host.js +25 -0
  143. package/runtime/lib/element-template/runtime/render/host.js.map +1 -0
  144. package/runtime/lib/element-template/runtime/render/render-components.d.ts +6 -0
  145. package/runtime/lib/element-template/runtime/render/render-components.js +190 -0
  146. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -0
  147. package/runtime/lib/element-template/runtime/render/{render-opcodes.d.ts → render-direct.d.ts} +3 -1
  148. package/runtime/lib/element-template/runtime/render/render-direct.js +194 -0
  149. package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -0
  150. package/runtime/lib/element-template/runtime/render/render-main-thread.js +10 -9
  151. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  152. package/runtime/lib/element-template/runtime/template/handle.d.ts +2 -1
  153. package/runtime/lib/element-template/runtime/template/handle.js +12 -4
  154. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
  155. package/runtime/lib/element-template/runtime-marker.d.ts +1 -0
  156. package/runtime/lib/element-template/runtime-marker.js +13 -0
  157. package/runtime/lib/element-template/runtime-marker.js.map +1 -0
  158. package/runtime/lib/index.d.ts +1 -1
  159. package/runtime/lib/index.js +1 -1
  160. package/runtime/lib/index.js.map +1 -1
  161. package/runtime/lib/internal.d.ts +4 -1
  162. package/runtime/lib/internal.js +6 -1
  163. package/runtime/lib/internal.js.map +1 -1
  164. package/runtime/lib/lynx-api.d.ts +49 -6
  165. package/runtime/lib/lynx-api.js +34 -4
  166. package/runtime/lib/lynx-api.js.map +1 -1
  167. package/runtime/lib/lynx.js +4 -1
  168. package/runtime/lib/lynx.js.map +1 -1
  169. package/runtime/lib/runtime-marker.d.ts +1 -0
  170. package/runtime/lib/runtime-marker.js +13 -0
  171. package/runtime/lib/runtime-marker.js.map +1 -0
  172. package/runtime/lib/shared/component-stack.js +5 -1
  173. package/runtime/lib/shared/component-stack.js.map +1 -1
  174. package/runtime/lib/snapshot/debug/profileHooks.js +38 -22
  175. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
  176. package/runtime/lib/snapshot/lifecycle/patch/error.d.ts +11 -1
  177. package/runtime/lib/snapshot/lifecycle/patch/error.js +24 -16
  178. package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -1
  179. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.d.ts +1 -1
  180. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +29 -7
  181. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  182. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +2 -2
  183. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  184. package/runtime/lib/snapshot/lifecycle/reload.js +3 -0
  185. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  186. package/runtime/lib/snapshot/lynx/calledByNative.js +3 -0
  187. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  188. package/runtime/lib/snapshot/lynx/children.d.ts +2 -0
  189. package/runtime/lib/snapshot/lynx/children.js.map +1 -1
  190. package/runtime/lib/snapshot/lynx/element.d.ts +10 -0
  191. package/runtime/lib/snapshot/lynx/element.js +6 -0
  192. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  193. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +2 -1
  194. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  195. package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +2 -0
  196. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +2 -0
  197. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
  198. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
  199. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  200. package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -3
  201. package/runtime/lib/worklet-runtime/bindings/bindings.js +9 -1
  202. package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
  203. package/runtime/lib/worklet-runtime/bindings/types.d.ts +3 -6
  204. package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
  205. package/runtime/lib/worklet-runtime/hydrate.js +27 -8
  206. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  207. package/runtime/lib/worklet-runtime/mainThreadObject.d.ts +8 -0
  208. package/runtime/lib/worklet-runtime/mainThreadObject.js +67 -0
  209. package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -0
  210. package/runtime/lib/worklet-runtime/workletRef.d.ts +11 -7
  211. package/runtime/lib/worklet-runtime/workletRef.js +72 -9
  212. package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
  213. package/runtime/lib/worklet-runtime/workletRuntime.js +69 -19
  214. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  215. package/runtime/package.json +2 -3
  216. package/runtime/src/core/background-function/run-on-background.ts +16 -0
  217. package/runtime/src/core/capture-main-thread-object.ts +17 -0
  218. package/runtime/src/core/globalProps.ts +2 -0
  219. package/runtime/src/core/hooks/react.ts +6 -0
  220. package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +2 -0
  221. package/runtime/src/core/initData.ts +2 -0
  222. package/runtime/src/core/lynx/runtime-version.ts +62 -0
  223. package/runtime/src/core/main-thread-object-handle-registry.ts +25 -0
  224. package/runtime/src/core/main-thread-object.ts +387 -0
  225. package/runtime/src/core/main-thread-ref-id.ts +16 -0
  226. package/runtime/src/core/main-thread-ref-init-value.ts +12 -4
  227. package/runtime/src/core/main-thread-ref.ts +7 -8
  228. package/runtime/src/element-template/background/commit-hook.ts +1 -1
  229. package/runtime/src/element-template/background/document.ts +3 -3
  230. package/runtime/src/element-template/background/hydrate.ts +61 -29
  231. package/runtime/src/element-template/background/instance.ts +5 -6
  232. package/runtime/src/element-template/debug/profile.ts +48 -36
  233. package/runtime/src/element-template/index.ts +7 -1
  234. package/runtime/src/element-template/internal.ts +14 -1
  235. package/runtime/src/element-template/native/index.ts +4 -0
  236. package/runtime/src/element-template/protocol/types.ts +1 -1
  237. package/runtime/src/element-template/runtime/list/list.ts +4 -0
  238. package/runtime/src/element-template/runtime/render/create-rendered-host.ts +126 -0
  239. package/runtime/src/element-template/runtime/render/host.ts +51 -0
  240. package/runtime/src/element-template/runtime/render/render-components.ts +255 -0
  241. package/runtime/src/element-template/runtime/render/render-direct.ts +275 -0
  242. package/runtime/src/element-template/runtime/render/render-main-thread.ts +10 -9
  243. package/runtime/src/element-template/runtime/template/handle.ts +17 -7
  244. package/runtime/src/element-template/runtime-marker.ts +17 -0
  245. package/runtime/src/index.ts +1 -1
  246. package/runtime/src/internal.ts +11 -1
  247. package/runtime/src/lynx-api.ts +53 -6
  248. package/runtime/src/lynx.ts +5 -1
  249. package/runtime/src/runtime-marker.ts +17 -0
  250. package/runtime/src/shared/component-stack.ts +5 -1
  251. package/runtime/src/snapshot/debug/profileHooks.ts +52 -40
  252. package/runtime/src/snapshot/lifecycle/patch/error.ts +36 -19
  253. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +29 -7
  254. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +2 -2
  255. package/runtime/src/snapshot/lifecycle/reload.ts +4 -0
  256. package/runtime/src/snapshot/lynx/calledByNative.ts +4 -0
  257. package/runtime/src/snapshot/lynx/children.ts +2 -0
  258. package/runtime/src/snapshot/lynx/element.ts +10 -0
  259. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +2 -1
  260. package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +2 -0
  261. package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +1 -1
  262. package/runtime/src/worklet-runtime/bindings/bindings.ts +17 -2
  263. package/runtime/src/worklet-runtime/bindings/types.ts +7 -11
  264. package/runtime/src/worklet-runtime/hydrate.ts +44 -11
  265. package/runtime/src/worklet-runtime/mainThreadObject.ts +117 -0
  266. package/runtime/src/worklet-runtime/workletRef.ts +120 -19
  267. package/runtime/src/worklet-runtime/workletRuntime.ts +84 -21
  268. package/runtime/types/types.d.ts +2 -0
  269. package/runtime/worklet-runtime/dev.js +155 -30
  270. package/runtime/worklet-runtime/main.js +1 -1
  271. package/testing-library/.turbo/turbo-build.log +12 -12
  272. package/testing-library/dist/env/index.js +2 -2
  273. package/testing-library/dist/index.d.ts +167 -4
  274. package/testing-library/dist/plugins/index.js +1 -1
  275. package/testing-library/dist/pure.js +45 -44
  276. package/testing-library/etc/react-lynx-testing-library.api.md +1 -1
  277. package/testing-library/package.json +4 -3
  278. package/testing-library/src/__tests__/lynx.test.jsx +1 -1
  279. package/testing-library/src/__tests__/reload/reloadGc.test.jsx +64 -0
  280. package/testing-library/src/__tests__/reload/reloadTemplate.js +39 -0
  281. package/testing-library/src/__tests__/worklet.test.jsx +46 -1
  282. package/testing-library/tsconfig.docs.json +9 -0
  283. package/testing-library/typedoc.json +22 -0
  284. package/testing-library/types/entry.d.ts +2 -2
  285. package/transform/.turbo/turbo-build$colon$wasm.log +151 -67
  286. package/transform/__test__/fixture.spec.js +89 -50
  287. package/transform/__test__/object-methods.spec.js +84 -0
  288. package/transform/__test__/text.spec.js +75 -0
  289. package/transform/crates/swc_plugin_compat/lib.rs +4 -3
  290. package/transform/crates/swc_plugin_compat/napi.rs +4 -3
  291. package/transform/crates/swc_plugin_define_dce/napi.rs +1 -1
  292. package/transform/crates/swc_plugin_dynamic_import/lib.rs +105 -3
  293. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_suffix_webpack_chunk_name.js +5 -0
  294. package/transform/crates/swc_plugin_element_template/host_lowering.rs +111 -0
  295. package/transform/crates/swc_plugin_element_template/lib.rs +41 -5
  296. package/transform/crates/swc_plugin_element_template/lowering.rs +39 -7
  297. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_generate_attribute_slots_for_dynamic_attributes.snap +1 -1
  298. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_background_conditional_attributes.snap +1 -1
  299. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_boolean_and_number_attributes.snap +1 -1
  300. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_complex_text_structure.snap +1 -1
  301. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dataset_attributes.snap +1 -1
  302. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_deeply_nested_user_components.snap +1 -1
  303. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dynamic_class_attributes.snap +1 -1
  304. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_lepus.snap +1 -1
  305. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_id_attributes.snap +1 -1
  306. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_inline_styles.snap +1 -1
  307. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_lepus.snap +1 -1
  308. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_mixed_content.snap +1 -1
  309. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_nested_structure_and_dynamic_content.snap +1 -1
  310. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_lepus.snap +1 -1
  311. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_sibling_user_components.snap +1 -1
  312. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_spread_attributes.snap +1 -1
  313. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_user_component.snap +1 -1
  314. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_isolate_arrays_with_child_slot_placeholder.snap +1 -1
  315. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_keep_code_and_template_attribute_slots_in_sync_for_spread.snap +1 -1
  316. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_element_template_simple_lepus.snap +1 -1
  317. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_template_with_static_attributes.snap +1 -1
  318. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_template_structure_complex.snap +1 -1
  319. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_text_attribute_and_child_text_slots.snap +1 -1
  320. package/transform/crates/swc_plugin_element_template/tests/element_template.rs +70 -66
  321. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +94 -8
  322. package/transform/crates/swc_plugin_shake/lib.rs +1 -1
  323. package/transform/crates/swc_plugin_shake/napi.rs +1 -1
  324. package/transform/crates/swc_plugin_text/lib.rs +57 -16
  325. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_keep_children_for_dynamic_or_multiple_text.js +13 -0
  326. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_string_expressions_to_text_attr.js +13 -0
  327. package/transform/crates/swc_plugin_worklet/decl_collect.rs +10 -0
  328. package/transform/crates/swc_plugin_worklet/extract_ident.rs +14 -0
  329. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +202 -3
  330. package/transform/crates/swc_plugin_worklet/lib.rs +468 -3
  331. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +8 -1
  332. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +10 -5
  333. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_js.js +27 -0
  334. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_lepus.js +45 -0
  335. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +16 -14
  336. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +16 -16
  337. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +7 -5
  338. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +7 -7
  339. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_computed_object_method_key_lepus.js +24 -0
  340. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_object_method_local_decls_lepus.js +16 -0
  341. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +42 -0
  342. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +58 -0
  343. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +3 -1
  344. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +3 -3
  345. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_js.js +9 -0
  346. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_lepus.js +16 -0
  347. package/transform/crates/swc_plugins_shared/jsx_helpers.rs +8 -4
  348. package/transform/dist/wasm.cjs +1 -1
  349. package/transform/index.d.ts +7 -6
  350. package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
  351. package/transform/src/swc_plugin_extract_str/mod.rs +1 -1
  352. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +63 -270
  353. package/transform/swc-plugin-reactlynx/index.d.ts +2 -2
  354. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  355. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +306 -170
  356. package/transform/swc-plugin-reactlynx-compat/index.d.ts +3 -3
  357. package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
  358. package/transform/vitest.config.ts +5 -1
  359. package/types/react.docs.d.ts +130 -11
  360. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/creates-template-from-attrs-and-slot-text/case.ts +0 -39
  361. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/handles-multiple-text-nodes-in-the-same-slot/case.ts +0 -29
  362. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/inserts-nested-templates-into-parent-slots/case.ts +0 -42
  363. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/keeps-slot-children-separated-and-ordered/case.ts +0 -31
  364. package/runtime/__test__/element-template/fixtures/render/opcodes-into-element-template/passes-bundle-url-to-native-create/case.ts +0 -20
  365. package/runtime/__test__/element-template/runtime/render/render-to-opcodes.et.test.jsx +0 -522
  366. package/runtime/lib/element-template/runtime/render/render-opcodes.js +0 -216
  367. package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +0 -1
  368. package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +0 -16
  369. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +0 -324
  370. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +0 -1
  371. package/runtime/lib/element-template/runtime-backend-marker.js +0 -6
  372. package/runtime/lib/element-template/runtime-backend-marker.js.map +0 -1
  373. package/runtime/lib/runtime-backend-marker.js +0 -6
  374. package/runtime/lib/runtime-backend-marker.js.map +0 -1
  375. package/runtime/src/element-template/runtime/render/render-opcodes.ts +0 -313
  376. package/runtime/src/element-template/runtime/render/render-to-opcodes.ts +0 -411
  377. package/runtime/src/element-template/runtime-backend-marker.ts +0 -7
  378. package/runtime/src/runtime-backend-marker.ts +0 -7
  379. package/testing-library/node_modules/.bin/rsbuild +0 -55
  380. package/testing-library/node_modules/.bin/rspeedy +0 -55
  381. package/testing-library/node_modules/.bin/rstest +0 -55
  382. package/transform/node_modules/.bin/esbuild +0 -46
  383. package/transform/node_modules/.bin/napi +0 -55
  384. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/native-log.txt +0 -0
  385. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/appends-root-text-via-append-element/output.txt +0 -0
  386. /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
  387. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/creates-template-from-attrs-and-slot-text/output.txt +0 -0
  388. /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
  389. /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
  390. /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
  391. /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
  392. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/native-log.txt +0 -0
  393. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/inserts-nested-templates-into-parent-slots/output.txt +0 -0
  394. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/native-log.txt +0 -0
  395. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/keeps-slot-children-separated-and-ordered/output.txt +0 -0
  396. /package/runtime/__test__/element-template/fixtures/render/{opcodes-into-element-template → direct-native}/passes-bundle-url-to-native-create/native-log.txt +0 -0
  397. /package/runtime/lib/{element-template/runtime-backend-marker.d.ts → core/capture-main-thread-object.d.ts} +0 -0
  398. /package/runtime/lib/{runtime-backend-marker.d.ts → core/main-thread-ref-id.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { runOnMainThread } from '@lynx-js/react';
1
+ import { defineMainThreadObjectType, runOnMainThread, useMainThreadObject } from '@lynx-js/react';
2
2
 
3
3
  interface AppProps {
4
4
  label?: string;
@@ -7,9 +7,23 @@ interface AppProps {
7
7
 
8
8
  export let lastRenderPromise: Promise<string> | undefined;
9
9
 
10
+ const config = { prefix: 'main' };
11
+
12
+ const formatterType = defineMainThreadObjectType({
13
+ type: 'element-template-formatter',
14
+ create: (prefix: string) => {
15
+ 'main thread';
16
+ return {
17
+ format(value: string) {
18
+ return `${prefix}:${value}`;
19
+ },
20
+ };
21
+ },
22
+ });
23
+
10
24
  const echoOnMainThread = (value: string): string => {
11
25
  'main thread';
12
- return `main:${value}`;
26
+ return `${config.prefix}:${value}`;
13
27
  };
14
28
 
15
29
  export function callMainDirect(label = 'manual'): Promise<string> {
@@ -17,8 +31,17 @@ export function callMainDirect(label = 'manual'): Promise<string> {
17
31
  }
18
32
 
19
33
  export function App({ label = 'first', source = 'render' }: AppProps) {
34
+ const formatter = useMainThreadObject(formatterType, config.prefix);
35
+ const formatOnMainThread = (value: string): string => {
36
+ 'main thread';
37
+ // Capture the handle itself so this runtime fixture does not require
38
+ // the separate compiler feature for narrowed member captures.
39
+ const target = formatter;
40
+ return target.format(value);
41
+ };
42
+
20
43
  if (__BACKGROUND__) {
21
- lastRenderPromise = runOnMainThread(echoOnMainThread)(`${source}:${label}`);
44
+ lastRenderPromise = runOnMainThread(formatOnMainThread)(`${source}:${label}`);
22
45
  }
23
46
  return <view id={label} />;
24
47
  }
@@ -1,21 +1,25 @@
1
1
  import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
- const _et_1d658c77caa0 = `${globDynamicComponentEntry}:${"_et_1d658c77caa0"}`;
3
- const _et_f4df0f2dba8f = `${globDynamicComponentEntry}:${"_et_f4df0f2dba8f"}`;
4
- const _et_955a06fee137 = `${globDynamicComponentEntry}:${"_et_955a06fee137"}`;
2
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
3
+ const _et_1d658c77caa0_bundle = globDynamicComponentEntry;
4
+ const _et_1d658c77caa0 = `${_et_1d658c77caa0_bundle}:${"_et_1d658c77caa0"}`;
5
+ const _et_f4df0f2dba8f_bundle = globDynamicComponentEntry;
6
+ const _et_f4df0f2dba8f = `${_et_f4df0f2dba8f_bundle}:${"_et_f4df0f2dba8f"}`;
7
+ const _et_955a06fee137_bundle = globDynamicComponentEntry;
8
+ const _et_955a06fee137 = `${_et_955a06fee137_bundle}:${"_et_955a06fee137"}`;
5
9
  export function App() {
6
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
7
- $0: [
10
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
11
+ [
8
12
  /*#__PURE__*/ _jsx(Sub, {
9
- children: /*#__PURE__*/ _jsx(_et_1d658c77caa0, {})
13
+ children: /*#__PURE__*/ ReactLynxInternal.__etHost(_et_1d658c77caa0, "_et_1d658c77caa0", _et_1d658c77caa0_bundle, void 0, void 0, void 0, void 0, true)
10
14
  }),
11
15
  /*#__PURE__*/ _jsx(Sub, {
12
- children: /*#__PURE__*/ _jsx(_et_f4df0f2dba8f, {})
16
+ children: /*#__PURE__*/ ReactLynxInternal.__etHost(_et_f4df0f2dba8f, "_et_f4df0f2dba8f", _et_f4df0f2dba8f_bundle, void 0, void 0, void 0, void 0, true)
13
17
  })
14
18
  ]
15
- });
19
+ ], void 0, true);
16
20
  }
17
21
  function Sub(props) {
18
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
19
- $0: props.children
20
- });
22
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
23
+ props.children
24
+ ], void 0, true);
21
25
  }
@@ -1,12 +1,13 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
- const _et_f6567016e14b = `${globDynamicComponentEntry}:${"_et_f6567016e14b"}`;
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
+ const _et_f6567016e14b_bundle = globDynamicComponentEntry;
3
+ const _et_f6567016e14b = `${_et_f6567016e14b_bundle}:${"_et_f6567016e14b"}`;
3
4
  export function App() {
4
5
  const x = null;
5
6
  const y = 2;
6
7
  const z = 3;
7
- return /*#__PURE__*/ _jsx(_et_f6567016e14b, {
8
- $0: x,
9
- $1: y,
10
- $2: z
11
- });
8
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_f6567016e14b, "_et_f6567016e14b", _et_f6567016e14b_bundle, void 0, void 0, [
9
+ x,
10
+ y,
11
+ z
12
+ ], void 0, true);
12
13
  }
@@ -1,16 +1,20 @@
1
1
  import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
- const _et_49c2d60c49a6 = `${globDynamicComponentEntry}:${"_et_49c2d60c49a6"}`;
2
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
3
+ const _et_49c2d60c49a6_bundle = globDynamicComponentEntry;
4
+ const _et_49c2d60c49a6 = `${_et_49c2d60c49a6_bundle}:${"_et_49c2d60c49a6"}`;
3
5
  function CustomComponent(props) {
4
- return /*#__PURE__*/ _jsx(_et_49c2d60c49a6, {
5
- $0: props.children
6
- });
6
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_49c2d60c49a6, "_et_49c2d60c49a6", _et_49c2d60c49a6_bundle, void 0, void 0, [
7
+ props.children
8
+ ], void 0, true);
7
9
  }
8
- const _et_d33ba201dffe = `${globDynamicComponentEntry}:${"_et_d33ba201dffe"}`;
9
- const _et_955a06fee137 = `${globDynamicComponentEntry}:${"_et_955a06fee137"}`;
10
+ const _et_d33ba201dffe_bundle = globDynamicComponentEntry;
11
+ const _et_d33ba201dffe = `${_et_d33ba201dffe_bundle}:${"_et_d33ba201dffe"}`;
12
+ const _et_955a06fee137_bundle = globDynamicComponentEntry;
13
+ const _et_955a06fee137 = `${_et_955a06fee137_bundle}:${"_et_955a06fee137"}`;
10
14
  export function App() {
11
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
12
- $0: /*#__PURE__*/ _jsx(CustomComponent, {
13
- children: /*#__PURE__*/ _jsx(_et_d33ba201dffe, {})
15
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
16
+ /*#__PURE__*/ _jsx(CustomComponent, {
17
+ children: /*#__PURE__*/ ReactLynxInternal.__etHost(_et_d33ba201dffe, "_et_d33ba201dffe", _et_d33ba201dffe_bundle, void 0, void 0, void 0, void 0, true)
14
18
  })
15
- });
19
+ ], void 0, true);
16
20
  }
@@ -1,6 +1,7 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
2
  /*@jsxCSSId 1501958*/ import "./style.css?cssId=1501958";
3
- const _et_517e4a08d202 = `${globDynamicComponentEntry}:${"_et_517e4a08d202"}`;
3
+ const _et_517e4a08d202_bundle = globDynamicComponentEntry;
4
+ const _et_517e4a08d202 = `${_et_517e4a08d202_bundle}:${"_et_517e4a08d202"}`;
4
5
  export function App() {
5
- return /*#__PURE__*/ _jsx(_et_517e4a08d202, {});
6
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_517e4a08d202, "_et_517e4a08d202", _et_517e4a08d202_bundle, void 0, void 0, void 0, void 0, true);
6
7
  }
@@ -1,15 +1,8 @@
1
1
  import { vi } from 'vitest';
2
2
 
3
- import { renderOpcodesIntoElementTemplate } from '../../../../../src/element-template/runtime/render/render-opcodes.js';
3
+ import { renderToElementTemplate } from '../../../../../src/element-template/runtime/render/render-direct.js';
4
4
  import { resetTemplateId } from '../../../../../src/element-template/runtime/template/handle.js';
5
5
  import { elementTemplateRegistry } from '../../../../../src/element-template/runtime/template/registry.js';
6
- import {
7
- __OpAttr,
8
- __OpBegin,
9
- __OpEnd,
10
- __OpSlot,
11
- __OpText,
12
- } from '../../../../../src/element-template/runtime/render/render-to-opcodes.js';
13
6
  import { installMockNativePapi } from '../../../test-utils/mock/mockNativePapi.js';
14
7
  import { registerBuiltinRawTextTemplate, registerTemplates } from '../../../test-utils/debug/registry.js';
15
8
 
@@ -128,4 +121,4 @@ export function runCase<T>(runner: (context: CaseContext) => T): T {
128
121
  }
129
122
  }
130
123
 
131
- export { elementTemplateRegistry, renderOpcodesIntoElementTemplate, __OpAttr, __OpBegin, __OpEnd, __OpSlot, __OpText };
124
+ export { elementTemplateRegistry, renderToElementTemplate };
@@ -1,10 +1,8 @@
1
- import { __OpText, renderOpcodesIntoElementTemplate, runCase } from '../_shared.js';
1
+ import { renderToElementTemplate, runCase } from '../_shared.js';
2
2
 
3
3
  export function run() {
4
4
  return runCase(({ root, nativeLog }) => {
5
- const opcodes = [__OpText, 'root'];
6
-
7
- const { rootRefs } = renderOpcodesIntoElementTemplate(opcodes);
5
+ const { rootRefs } = renderToElementTemplate('root');
8
6
  rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
9
7
 
10
8
  return {
@@ -0,0 +1,20 @@
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
3
+
4
+ export function run() {
5
+ return runCase(({ root, nativeLog }) => {
6
+ const { rootRefs } = renderToElementTemplate(h('_et_foo', { attributeSlots: ['test'], $1: 'Hello' }));
7
+ rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
8
+
9
+ const rootChild = root.children?.[0];
10
+
11
+ return {
12
+ output: {
13
+ rootChild,
14
+ },
15
+ files: {
16
+ 'native-log.txt': nativeLog,
17
+ },
18
+ };
19
+ });
20
+ }
@@ -1,22 +1,9 @@
1
- import { __OpBegin, __OpEnd, __OpSlot, renderOpcodesIntoElementTemplate, runCase } from '../_shared.js';
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
2
3
 
3
4
  export function run() {
4
5
  return runCase(({ root, nativeLog }) => {
5
- const opcodes = [
6
- __OpBegin,
7
- { type: '_et_parent', props: {} },
8
- __OpSlot,
9
- 0,
10
- __OpBegin,
11
- { type: '_et_child_a', props: {} },
12
- __OpEnd,
13
- __OpBegin,
14
- { type: '_et_child_b', props: {} },
15
- __OpEnd,
16
- __OpEnd,
17
- ];
18
-
19
- const { rootRefs } = renderOpcodesIntoElementTemplate(opcodes);
6
+ const { rootRefs } = renderToElementTemplate(h('_et_parent', { $0: [h('_et_child_a', {}), h('_et_child_b', {})] }));
20
7
  rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
21
8
 
22
9
  const slotChildren = root.children?.[0]?.children?.[0]?.children ?? [];
@@ -0,0 +1,18 @@
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
3
+
4
+ export function run() {
5
+ return runCase(({ root, nativeLog }) => {
6
+ const { rootRefs } = renderToElementTemplate(h('_et_parent', { $0: ['A', 'B'] }));
7
+ rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
8
+
9
+ return {
10
+ output: {
11
+ slotChildren: root.children?.[0]?.children?.[0]?.children ?? [],
12
+ },
13
+ files: {
14
+ 'native-log.txt': nativeLog,
15
+ },
16
+ };
17
+ });
18
+ }
@@ -0,0 +1,20 @@
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
3
+
4
+ export function run() {
5
+ return runCase(({ root, nativeLog }) => {
6
+ const { rootRefs } = renderToElementTemplate(
7
+ h('_et_outer', { $0: h('_et_inner', { attributeSlots: ['inner'], $0: 'X' }) }),
8
+ );
9
+ rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
10
+
11
+ return {
12
+ output: {
13
+ rootChild: root.children?.[0],
14
+ },
15
+ files: {
16
+ 'native-log.txt': nativeLog,
17
+ },
18
+ };
19
+ });
20
+ }
@@ -0,0 +1,18 @@
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
3
+
4
+ export function run() {
5
+ return runCase(({ root, nativeLog }) => {
6
+ const { rootRefs } = renderToElementTemplate(h('_et_foo', { $0: 'A', $1: 'B' }));
7
+ rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
8
+
9
+ return {
10
+ output: {
11
+ rootChild: root.children?.[0],
12
+ },
13
+ files: {
14
+ 'native-log.txt': nativeLog,
15
+ },
16
+ };
17
+ });
18
+ }
@@ -0,0 +1,15 @@
1
+ import { h } from 'preact';
2
+ import { renderToElementTemplate, runCase } from '../_shared.js';
3
+
4
+ export function run() {
5
+ return runCase(({ root, nativeLog }) => {
6
+ const { rootRefs } = renderToElementTemplate(h('dynamic-entry:_et_foo', {}));
7
+ rootRefs.forEach(rootRef => __InsertNodeToElementTemplate(root, 0, rootRef, null));
8
+
9
+ return {
10
+ files: {
11
+ 'native-log.txt': nativeLog,
12
+ },
13
+ };
14
+ });
15
+ }
@@ -1,18 +1,19 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
- const _et_80daa5907c0f = `${globDynamicComponentEntry}:${"_et_80daa5907c0f"}`;
3
- const _et_955a06fee137 = `${globDynamicComponentEntry}:${"_et_955a06fee137"}`;
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
+ const _et_80daa5907c0f_bundle = globDynamicComponentEntry;
3
+ const _et_80daa5907c0f = `${_et_80daa5907c0f_bundle}:${"_et_80daa5907c0f"}`;
4
+ const _et_955a06fee137_bundle = globDynamicComponentEntry;
5
+ const _et_955a06fee137 = `${_et_955a06fee137_bundle}:${"_et_955a06fee137"}`;
4
6
  export function App() {
5
7
  const items = [
6
8
  'A',
7
9
  'B',
8
10
  'C'
9
11
  ];
10
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
11
- $0: items.map((item)=>/*#__PURE__*/ _jsx(_et_80daa5907c0f, {
12
- attributeSlots: [
13
- item
14
- ],
15
- $0: item
16
- }))
17
- });
12
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
13
+ items.map((item)=>/*#__PURE__*/ ReactLynxInternal.__etHost(_et_80daa5907c0f, "_et_80daa5907c0f", _et_80daa5907c0f_bundle, void 0, [
14
+ item
15
+ ], [
16
+ item
17
+ ], void 0, true))
18
+ ], void 0, true);
18
19
  }
@@ -1,15 +1,16 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
2
  import { Component } from '@lynx-js/react';
3
- const _et_5c988e5983da = `${globDynamicComponentEntry}:${"_et_5c988e5983da"}`;
3
+ const _et_5c988e5983da_bundle = globDynamicComponentEntry;
4
+ const _et_5c988e5983da = `${_et_5c988e5983da_bundle}:${"_et_5c988e5983da"}`;
4
5
  export class App extends Component {
5
6
  render() {
6
7
  const leading = 'A';
7
8
  const innerText = 'B';
8
9
  const trailing = 'C';
9
- return /*#__PURE__*/ _jsx(_et_5c988e5983da, {
10
- $0: leading,
11
- $1: innerText,
12
- $2: trailing
13
- });
10
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_5c988e5983da, "_et_5c988e5983da", _et_5c988e5983da_bundle, void 0, void 0, [
11
+ leading,
12
+ innerText,
13
+ trailing
14
+ ], void 0, true);
14
15
  }
15
16
  }
@@ -1,7 +1,9 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
2
  import { Component } from '@lynx-js/react';
3
- const _et_895419ad7379 = `${globDynamicComponentEntry}:${"_et_895419ad7379"}`;
4
- const _et_66e1ae2ed39b = `${globDynamicComponentEntry}:${"_et_66e1ae2ed39b"}`;
3
+ const _et_895419ad7379_bundle = globDynamicComponentEntry;
4
+ const _et_895419ad7379 = `${_et_895419ad7379_bundle}:${"_et_895419ad7379"}`;
5
+ const _et_66e1ae2ed39b_bundle = globDynamicComponentEntry;
6
+ const _et_66e1ae2ed39b = `${_et_66e1ae2ed39b_bundle}:${"_et_66e1ae2ed39b"}`;
5
7
  export class App extends Component {
6
8
  render() {
7
9
  const items = [
@@ -9,15 +11,15 @@ export class App extends Component {
9
11
  'B',
10
12
  'C'
11
13
  ];
12
- return /*#__PURE__*/ _jsx(_et_66e1ae2ed39b, {
13
- $0: items,
14
- $1: items.map((item)=>/*#__PURE__*/ _jsx(_et_895419ad7379, {
15
- $0: item
16
- })),
17
- $2: items,
18
- $3: items.map((item)=>/*#__PURE__*/ _jsx(_et_895419ad7379, {
19
- $0: item
20
- }))
21
- });
14
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_66e1ae2ed39b, "_et_66e1ae2ed39b", _et_66e1ae2ed39b_bundle, void 0, void 0, [
15
+ items,
16
+ items.map((item)=>/*#__PURE__*/ ReactLynxInternal.__etHost(_et_895419ad7379, "_et_895419ad7379", _et_895419ad7379_bundle, void 0, void 0, [
17
+ item
18
+ ], void 0, true)),
19
+ items,
20
+ items.map((item)=>/*#__PURE__*/ ReactLynxInternal.__etHost(_et_895419ad7379, "_et_895419ad7379", _et_895419ad7379_bundle, void 0, void 0, [
21
+ item
22
+ ], void 0, true))
23
+ ], void 0, true);
22
24
  }
23
25
  }
@@ -1,19 +1,21 @@
1
1
  import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
3
  import { Component } from '@lynx-js/react';
3
- const _et_955a06fee137 = `${globDynamicComponentEntry}:${"_et_955a06fee137"}`;
4
+ const _et_955a06fee137_bundle = globDynamicComponentEntry;
5
+ const _et_955a06fee137 = `${_et_955a06fee137_bundle}:${"_et_955a06fee137"}`;
4
6
  class Inner extends Component {
5
7
  render() {
6
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
7
- $0: this.props.message
8
- });
8
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
9
+ this.props.message
10
+ ], void 0, true);
9
11
  }
10
12
  }
11
13
  export class App extends Component {
12
14
  render() {
13
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
14
- $0: /*#__PURE__*/ _jsx(Inner, {
15
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
16
+ /*#__PURE__*/ _jsx(Inner, {
15
17
  message: "X"
16
18
  })
17
- });
19
+ ], void 0, true);
18
20
  }
19
21
  }
@@ -1,12 +1,14 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
1
  import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
3
2
  import { useCallback, useEffect, useState } from '@lynx-js/react';
4
3
  const arrow = './assets/arrow.png';
5
4
  const lynxLogo = './assets/lynx-logo.png';
6
5
  const reactLynxLogo = './assets/react-logo.png';
7
- const _et_b89c02b1874f = `${globDynamicComponentEntry}:${"_et_b89c02b1874f"}`;
8
- const _et_a51110b9901e = `${globDynamicComponentEntry}:${"_et_a51110b9901e"}`;
9
- const _et_b2bb4db3b1ed = `${globDynamicComponentEntry}:${"_et_b2bb4db3b1ed"}`;
6
+ const _et_b89c02b1874f_bundle = globDynamicComponentEntry;
7
+ const _et_b89c02b1874f = `${_et_b89c02b1874f_bundle}:${"_et_b89c02b1874f"}`;
8
+ const _et_a51110b9901e_bundle = globDynamicComponentEntry;
9
+ const _et_a51110b9901e = `${_et_a51110b9901e_bundle}:${"_et_a51110b9901e"}`;
10
+ const _et_b2bb4db3b1ed_bundle = globDynamicComponentEntry;
11
+ const _et_b2bb4db3b1ed = `${_et_b2bb4db3b1ed_bundle}:${"_et_b2bb4db3b1ed"}`;
10
12
  ReactLynxInternal.__etAttrPlanMap[_et_b2bb4db3b1ed] = [
11
13
  0,
12
14
  ReactLynxInternal.adaptEventAttrSlot
@@ -20,20 +22,15 @@ export function App() {
20
22
  'background-only';
21
23
  setAlterLogo((prevAlterLogo)=>!prevAlterLogo);
22
24
  }, []);
23
- return /*#__PURE__*/ _jsx(_et_b2bb4db3b1ed, {
24
- attributeSlots: [
25
- 1,
26
- arrow
27
- ],
28
- $0: alterLogo ? /*#__PURE__*/ _jsx(_et_b89c02b1874f, {
29
- attributeSlots: [
30
- reactLynxLogo
31
- ]
32
- }) : /*#__PURE__*/ _jsx(_et_a51110b9901e, {
33
- attributeSlots: [
34
- lynxLogo
35
- ]
36
- }),
37
- $1: ' src/App.tsx '
38
- });
25
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_b2bb4db3b1ed, "_et_b2bb4db3b1ed", _et_b2bb4db3b1ed_bundle, void 0, [
26
+ 1,
27
+ arrow
28
+ ], [
29
+ alterLogo ? /*#__PURE__*/ ReactLynxInternal.__etHost(_et_b89c02b1874f, "_et_b89c02b1874f", _et_b89c02b1874f_bundle, void 0, [
30
+ reactLynxLogo
31
+ ], void 0, void 0, true) : /*#__PURE__*/ ReactLynxInternal.__etHost(_et_a51110b9901e, "_et_a51110b9901e", _et_a51110b9901e_bundle, void 0, [
32
+ lynxLogo
33
+ ], void 0, void 0, true),
34
+ ' src/App.tsx '
35
+ ], void 0);
39
36
  }
@@ -1,14 +1,17 @@
1
- import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
- const _et_01c4a5c2b24f = `${globDynamicComponentEntry}:${"_et_01c4a5c2b24f"}`;
3
- const _et_895419ad7379 = `${globDynamicComponentEntry}:${"_et_895419ad7379"}`;
4
- const _et_06d9ec2f2156 = `${globDynamicComponentEntry}:${"_et_06d9ec2f2156"}`;
1
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
+ const _et_01c4a5c2b24f_bundle = globDynamicComponentEntry;
3
+ const _et_01c4a5c2b24f = `${_et_01c4a5c2b24f_bundle}:${"_et_01c4a5c2b24f"}`;
4
+ const _et_895419ad7379_bundle = globDynamicComponentEntry;
5
+ const _et_895419ad7379 = `${_et_895419ad7379_bundle}:${"_et_895419ad7379"}`;
6
+ const _et_06d9ec2f2156_bundle = globDynamicComponentEntry;
7
+ const _et_06d9ec2f2156 = `${_et_06d9ec2f2156_bundle}:${"_et_06d9ec2f2156"}`;
5
8
  export function App({ showHeader = false, items = [
6
9
  'body'
7
10
  ] }) {
8
- return /*#__PURE__*/ _jsx(_et_06d9ec2f2156, {
9
- $0: showHeader && /*#__PURE__*/ _jsx(_et_01c4a5c2b24f, {}),
10
- $1: items.map((item)=>/*#__PURE__*/ _jsx(_et_895419ad7379, {
11
- $0: item
12
- }, item))
13
- });
11
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_06d9ec2f2156, "_et_06d9ec2f2156", _et_06d9ec2f2156_bundle, void 0, void 0, [
12
+ showHeader && /*#__PURE__*/ ReactLynxInternal.__etHost(_et_01c4a5c2b24f, "_et_01c4a5c2b24f", _et_01c4a5c2b24f_bundle, void 0, void 0, void 0, void 0, true),
13
+ items.map((item)=>/*#__PURE__*/ ReactLynxInternal.__etHost(_et_895419ad7379, "_et_895419ad7379", _et_895419ad7379_bundle, item, void 0, [
14
+ item
15
+ ], void 0, true))
16
+ ], void 0, true);
14
17
  }
@@ -1,21 +1,24 @@
1
1
  import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2
+ import * as ReactLynxInternal from "@lynx-js/react/element-template/internal";
2
3
  import { Component } from '@lynx-js/react';
3
- const _et_244555d10b38 = `${globDynamicComponentEntry}:${"_et_244555d10b38"}`;
4
+ const _et_244555d10b38_bundle = globDynamicComponentEntry;
5
+ const _et_244555d10b38 = `${_et_244555d10b38_bundle}:${"_et_244555d10b38"}`;
4
6
  function PrimaryRow({ label }) {
5
- return /*#__PURE__*/ _jsx(_et_244555d10b38, {
6
- $0: label
7
- });
7
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_244555d10b38, "_et_244555d10b38", _et_244555d10b38_bundle, void 0, void 0, [
8
+ label
9
+ ], void 0, true);
8
10
  }
9
11
  function SecondaryRow({ label }) {
10
- return /*#__PURE__*/ _jsx(_et_244555d10b38, {
11
- $0: label
12
- });
12
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_244555d10b38, "_et_244555d10b38", _et_244555d10b38_bundle, void 0, void 0, [
13
+ label
14
+ ], void 0, true);
13
15
  }
14
- const _et_955a06fee137 = `${globDynamicComponentEntry}:${"_et_955a06fee137"}`;
16
+ const _et_955a06fee137_bundle = globDynamicComponentEntry;
17
+ const _et_955a06fee137 = `${_et_955a06fee137_bundle}:${"_et_955a06fee137"}`;
15
18
  export class App extends Component {
16
19
  render() {
17
- return /*#__PURE__*/ _jsx(_et_955a06fee137, {
18
- $0: [
20
+ return /*#__PURE__*/ ReactLynxInternal.__etHost(_et_955a06fee137, "_et_955a06fee137", _et_955a06fee137_bundle, void 0, void 0, [
21
+ [
19
22
  /*#__PURE__*/ _jsx(PrimaryRow, {
20
23
  label: "Alpha"
21
24
  }),
@@ -23,6 +26,6 @@ export class App extends Component {
23
26
  label: "Beta"
24
27
  })
25
28
  ]
26
- });
29
+ ], void 0, true);
27
30
  }
28
31
  }
@@ -0,0 +1,10 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { defineMainThreadObjectType, useMainThreadObject } from '@lynx-js/react/element-template';
4
+
5
+ describe('element-template MainThreadObject entry', () => {
6
+ it('exposes MainThreadObject APIs from the public ET alias', () => {
7
+ expect(defineMainThreadObjectType).toBeTypeOf('function');
8
+ expect(useMainThreadObject).toBeTypeOf('function');
9
+ });
10
+ });