@lynx-js/react 0.126.0 → 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 (1317) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +202 -0
  3. package/components/.gitignore +3 -0
  4. package/components/.npmignore +5 -0
  5. package/components/tsconfig.json +17 -0
  6. package/components/tsconfig.tsbuildinfo +1 -0
  7. package/package.json +7 -3
  8. package/refresh/.gitignore +1 -0
  9. package/refresh/.npmignore +3 -0
  10. package/refresh/.turbo/turbo-build.log +9 -0
  11. package/refresh/dist/index.js +1 -2
  12. package/refresh/package.json +21 -0
  13. package/refresh/rslib.config.ts +24 -0
  14. package/refresh/tsconfig.json +4 -0
  15. package/refresh/turbo.json +16 -0
  16. package/runtime/.gitignore +4 -0
  17. package/runtime/.npmignore +15 -0
  18. package/runtime/.prettierrc +6 -0
  19. package/runtime/.turbo/turbo-build.log +1 -0
  20. package/runtime/CHANGELOG.md +7 -0
  21. package/runtime/__test__/core/background-function.test.ts +133 -0
  22. package/runtime/__test__/core/commit-context.test.ts +37 -0
  23. package/runtime/__test__/core/forceRootRender.test.ts +65 -0
  24. package/runtime/__test__/core/globalProps.test.ts +141 -0
  25. package/runtime/__test__/core/hooks/mainThread.test.tsx +279 -0
  26. package/runtime/__test__/core/hooks/useLynxGlobalEventListener.test.jsx +168 -0
  27. package/runtime/__test__/core/lynx-data-processors.test.ts +131 -0
  28. package/runtime/__test__/core/lynx-page-data.test.ts +62 -0
  29. package/runtime/__test__/core/lynx-update-data.test.ts +97 -0
  30. package/runtime/__test__/core/main-thread-function.test.ts +13 -0
  31. package/runtime/__test__/core/main-thread-ref.test.ts +102 -0
  32. package/runtime/__test__/core/ref.test.ts +261 -0
  33. package/runtime/__test__/core/reload-version.test.ts +14 -0
  34. package/runtime/__test__/core/thread-function-call.test.ts +182 -0
  35. package/runtime/__test__/element-template/debug/alog.test.ts +214 -0
  36. package/runtime/__test__/element-template/debug/elementPAPICall.test.ts +157 -0
  37. package/runtime/__test__/element-template/debug/profile-hook.test.tsx +67 -0
  38. package/runtime/__test__/element-template/debug/profile-installation.test.tsx +145 -0
  39. package/runtime/__test__/element-template/fixtures/background/event/conditional-direct-event/index.tsx +8 -0
  40. package/runtime/__test__/element-template/fixtures/background/event/direct-event/index.tsx +7 -0
  41. package/runtime/__test__/element-template/fixtures/background/event/main-thread-direct-event/index.tsx +11 -0
  42. package/runtime/__test__/element-template/fixtures/background/event/main-thread-run-on-background-event/index.tsx +14 -0
  43. package/runtime/__test__/element-template/fixtures/background/event/spread-event/index.tsx +20 -0
  44. package/runtime/__test__/element-template/fixtures/background/global-props/direct-read/index.tsx +7 -0
  45. package/runtime/__test__/element-template/fixtures/background/global-props/event-hook/index.tsx +34 -0
  46. package/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx +584 -0
  47. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/case.tsx +5 -0
  48. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/output.txt +11 -0
  49. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/case.tsx +5 -0
  50. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/output.txt +12 -0
  51. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/case.tsx +5 -0
  52. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/output.txt +13 -0
  53. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/case.tsx +5 -0
  54. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/output.txt +12 -0
  55. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/case.tsx +5 -0
  56. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/output.txt +10 -0
  57. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/case.tsx +5 -0
  58. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/output.txt +13 -0
  59. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/case.tsx +5 -0
  60. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/output.txt +13 -0
  61. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/case.tsx +5 -0
  62. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/output.txt +10 -0
  63. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/case.tsx +5 -0
  64. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/output.txt +3 -0
  65. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/case.tsx +5 -0
  66. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/output.txt +13 -0
  67. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/case.tsx +5 -0
  68. package/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/output.txt +10 -0
  69. package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/case.tsx +5 -0
  70. package/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt +39 -0
  71. package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/case.tsx +5 -0
  72. package/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt +16 -0
  73. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/case.tsx +5 -0
  74. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt +3 -0
  75. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/case.tsx +5 -0
  76. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/output.txt +11 -0
  77. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/case.tsx +5 -0
  78. package/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt +16 -0
  79. package/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/case.tsx +5 -0
  80. package/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/output.txt +4 -0
  81. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/case.tsx +5 -0
  82. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt +12 -0
  83. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/case.tsx +5 -0
  84. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt +10 -0
  85. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/case.tsx +5 -0
  86. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt +10 -0
  87. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx +5 -0
  88. package/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/output.txt +22 -0
  89. package/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/case.tsx +5 -0
  90. package/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/output.txt +5 -0
  91. package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/case.tsx +5 -0
  92. package/runtime/__test__/element-template/fixtures/background/hydrate/root-key-mismatch-reconciles/output.txt +24 -0
  93. package/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/case.tsx +5 -0
  94. package/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/output.txt +5 -0
  95. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/index.tsx +14 -0
  96. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt +20 -0
  97. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/index.tsx +39 -0
  98. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt +20 -0
  99. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/index.tsx +38 -0
  100. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt +29 -0
  101. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/index.tsx +40 -0
  102. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt +12 -0
  103. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx +14 -0
  104. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +22 -0
  105. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/index.tsx +14 -0
  106. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt +13 -0
  107. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/index.tsx +34 -0
  108. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt +12 -0
  109. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx +18 -0
  110. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt +16 -0
  111. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx +33 -0
  112. package/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +26 -0
  113. package/runtime/__test__/element-template/fixtures/background/init-data/update/index.tsx +11 -0
  114. package/runtime/__test__/element-template/fixtures/background/instance/_shared.ts +30 -0
  115. package/runtime/__test__/element-template/fixtures/background/instance/ops/does-not-emit-patch-when-attrs-reference-reused/case.ts +24 -0
  116. package/runtime/__test__/element-template/fixtures/background/instance/ops/does-not-emit-patch-when-attrs-reference-reused/output.txt +1 -0
  117. package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/case.ts +11 -0
  118. package/runtime/__test__/element-template/fixtures/background/instance/ops/emits-bundle-url-in-create-template/output.txt +8 -0
  119. package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/case.ts +11 -0
  120. package/runtime/__test__/element-template/fixtures/background/instance/ops/supports-silent-insert-before/output.txt +1 -0
  121. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-non-object-attrs-entry-as-empty-object/case.ts +23 -0
  122. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-non-object-attrs-entry-as-empty-object/output.txt +6 -0
  123. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/case.ts +23 -0
  124. package/runtime/__test__/element-template/fixtures/background/instance/ops/treats-nullish-attrs-as-empty-object/output.txt +6 -0
  125. package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +24 -0
  126. package/runtime/__test__/element-template/fixtures/background/ref/direct-ref/index.tsx +7 -0
  127. package/runtime/__test__/element-template/fixtures/background/ref/multi-ref/index.tsx +20 -0
  128. package/runtime/__test__/element-template/fixtures/background/ref/spread-ref/index.tsx +14 -0
  129. package/runtime/__test__/element-template/fixtures/background/ref/unsupported-ref/index.tsx +12 -0
  130. package/runtime/__test__/element-template/fixtures/background/render/_shared.tsx +85 -0
  131. package/runtime/__test__/element-template/fixtures/background/render/constructs-shadow-tree/case.tsx +5 -0
  132. package/runtime/__test__/element-template/fixtures/background/render/constructs-shadow-tree/output.txt +7 -0
  133. package/runtime/__test__/element-template/fixtures/background/render/supports-slot-component-materiality/case.tsx +5 -0
  134. package/runtime/__test__/element-template/fixtures/background/render/supports-slot-component-materiality/output.txt +13 -0
  135. package/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-list/index.tsx +15 -0
  136. package/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-subtree-list/index.tsx +19 -0
  137. package/runtime/__test__/element-template/fixtures/background/update/sparse/compiled-element-slot/index.tsx +26 -0
  138. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/_shared.tsx +169 -0
  139. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/case.tsx +5 -0
  140. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/output.txt +14 -0
  141. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/case.tsx +5 -0
  142. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/output.txt +8 -0
  143. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/case.tsx +5 -0
  144. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/output.txt +10 -0
  145. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/case.tsx +5 -0
  146. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txt +28 -0
  147. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/source.tsx +15 -0
  148. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/case.tsx +5 -0
  149. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txt +19 -0
  150. package/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/source.tsx +8 -0
  151. package/runtime/__test__/element-template/fixtures/page/render-page/case.tsx +41 -0
  152. package/runtime/__test__/element-template/fixtures/page/render-page/native-log.txt +31 -0
  153. package/runtime/__test__/element-template/fixtures/page/render-page/output.txt +5 -0
  154. package/runtime/__test__/element-template/fixtures/page-compiled/authored-page/index.tsx +67 -0
  155. package/runtime/__test__/element-template/fixtures/patch/_shared.tsx +270 -0
  156. package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/after-jsx.txt +7 -0
  157. package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/before-jsx.txt +8 -0
  158. package/runtime/__test__/element-template/fixtures/patch/detaches-node-when-moving-between-slots/case.tsx +100 -0
  159. package/runtime/__test__/element-template/fixtures/patch/props-update/after-jsx.txt +3 -0
  160. package/runtime/__test__/element-template/fixtures/patch/props-update/before-jsx.txt +3 -0
  161. package/runtime/__test__/element-template/fixtures/patch/props-update/case.tsx +42 -0
  162. package/runtime/__test__/element-template/fixtures/patch/props-update/ops.txt +8 -0
  163. package/runtime/__test__/element-template/fixtures/patch/state-update/after-jsx.txt +3 -0
  164. package/runtime/__test__/element-template/fixtures/patch/state-update/before-jsx.txt +3 -0
  165. package/runtime/__test__/element-template/fixtures/patch/state-update/case.tsx +64 -0
  166. package/runtime/__test__/element-template/fixtures/patch/state-update/ops.txt +8 -0
  167. package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/after-jsx.txt +7 -0
  168. package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/before-jsx.txt +6 -0
  169. package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/index.tsx +39 -0
  170. package/runtime/__test__/element-template/fixtures/patch-compiled/applies-insert-before-with-reference/ops.txt +14 -0
  171. package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/after-jsx.txt +10 -0
  172. package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/before-jsx.txt +9 -0
  173. package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/index.tsx +47 -0
  174. package/runtime/__test__/element-template/fixtures/patch-compiled/apply-hydration-ops/ops.txt +34 -0
  175. package/runtime/__test__/element-template/fixtures/render/child-siblings/index.js.txt +25 -0
  176. package/runtime/__test__/element-template/fixtures/render/child-siblings/index.tsx +16 -0
  177. package/runtime/__test__/element-template/fixtures/render/child-siblings/output.txt +8 -0
  178. package/runtime/__test__/element-template/fixtures/render/child-siblings/papi.txt +128 -0
  179. package/runtime/__test__/element-template/fixtures/render/child-siblings/templates.json.txt +66 -0
  180. package/runtime/__test__/element-template/fixtures/render/component/index.js.txt +13 -0
  181. package/runtime/__test__/element-template/fixtures/render/component/index.tsx +17 -0
  182. package/runtime/__test__/element-template/fixtures/render/component/output.txt +7 -0
  183. package/runtime/__test__/element-template/fixtures/render/component/papi.txt +67 -0
  184. package/runtime/__test__/element-template/fixtures/render/component/templates.json.txt +68 -0
  185. package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.js.txt +20 -0
  186. package/runtime/__test__/element-template/fixtures/render/component-slot-content/index.tsx +18 -0
  187. package/runtime/__test__/element-template/fixtures/render/component-slot-content/output.txt +6 -0
  188. package/runtime/__test__/element-template/fixtures/render/component-slot-content/papi.txt +85 -0
  189. package/runtime/__test__/element-template/fixtures/render/component-slot-content/templates.json.txt +78 -0
  190. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/fixture.config.json +5 -0
  191. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.js.txt +7 -0
  192. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/index.tsx +9 -0
  193. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/output.txt +3 -0
  194. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/papi.txt +25 -0
  195. package/runtime/__test__/element-template/fixtures/render/css-scope-dynamic-bundle-url/templates.json.txt +57 -0
  196. package/runtime/__test__/element-template/fixtures/render/direct-native/_shared.ts +124 -0
  197. package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/case.ts +17 -0
  198. package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/native-log.txt +27 -0
  199. package/runtime/__test__/element-template/fixtures/render/direct-native/appends-root-text-via-append-element/output.txt +12 -0
  200. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/case.ts +20 -0
  201. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/native-log.txt +49 -0
  202. package/runtime/__test__/element-template/fixtures/render/direct-native/creates-template-from-attrs-and-slot-text/output.txt +34 -0
  203. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/case.ts +21 -0
  204. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/native-log.txt +56 -0
  205. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-template-children-in-the-same-slot/output.txt +11 -0
  206. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/case.ts +18 -0
  207. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/native-log.txt +64 -0
  208. package/runtime/__test__/element-template/fixtures/render/direct-native/handles-multiple-text-nodes-in-the-same-slot/output.txt +20 -0
  209. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/case.ts +20 -0
  210. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/native-log.txt +84 -0
  211. package/runtime/__test__/element-template/fixtures/render/direct-native/inserts-nested-templates-into-parent-slots/output.txt +42 -0
  212. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/case.ts +18 -0
  213. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/native-log.txt +66 -0
  214. package/runtime/__test__/element-template/fixtures/render/direct-native/keeps-slot-children-separated-and-ordered/output.txt +41 -0
  215. package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/case.ts +15 -0
  216. package/runtime/__test__/element-template/fixtures/render/direct-native/passes-bundle-url-to-native-create/native-log.txt +25 -0
  217. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.js.txt +19 -0
  218. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/index.tsx +13 -0
  219. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/output.txt +17 -0
  220. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/papi.txt +214 -0
  221. package/runtime/__test__/element-template/fixtures/render/mapped-view-children/templates.json.txt +63 -0
  222. package/runtime/__test__/element-template/fixtures/render/mixed-children/index.js.txt +16 -0
  223. package/runtime/__test__/element-template/fixtures/render/mixed-children/index.tsx +15 -0
  224. package/runtime/__test__/element-template/fixtures/render/mixed-children/output.txt +7 -0
  225. package/runtime/__test__/element-template/fixtures/render/mixed-children/papi.txt +86 -0
  226. package/runtime/__test__/element-template/fixtures/render/mixed-children/templates.json.txt +51 -0
  227. package/runtime/__test__/element-template/fixtures/render/multiple-text/index.js.txt +25 -0
  228. package/runtime/__test__/element-template/fixtures/render/multiple-text/index.tsx +22 -0
  229. package/runtime/__test__/element-template/fixtures/render/multiple-text/output.txt +38 -0
  230. package/runtime/__test__/element-template/fixtures/render/multiple-text/papi.txt +454 -0
  231. package/runtime/__test__/element-template/fixtures/render/multiple-text/templates.json.txt +131 -0
  232. package/runtime/__test__/element-template/fixtures/render/nested-templates/index.js.txt +21 -0
  233. package/runtime/__test__/element-template/fixtures/render/nested-templates/index.tsx +19 -0
  234. package/runtime/__test__/element-template/fixtures/render/nested-templates/output.txt +5 -0
  235. package/runtime/__test__/element-template/fixtures/render/nested-templates/papi.txt +80 -0
  236. package/runtime/__test__/element-template/fixtures/render/nested-templates/templates.json.txt +34 -0
  237. package/runtime/__test__/element-template/fixtures/render/react-example/index.js.txt +36 -0
  238. package/runtime/__test__/element-template/fixtures/render/react-example/index.tsx +51 -0
  239. package/runtime/__test__/element-template/fixtures/render/react-example/output.txt +24 -0
  240. package/runtime/__test__/element-template/fixtures/render/react-example/papi.txt +70 -0
  241. package/runtime/__test__/element-template/fixtures/render/react-example/templates.json.txt +280 -0
  242. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.js.txt +17 -0
  243. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/index.tsx +17 -0
  244. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/output.txt +10 -0
  245. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/papi.txt +81 -0
  246. package/runtime/__test__/element-template/fixtures/render/sparse-element-slot/templates.json.txt +97 -0
  247. package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.js.txt +31 -0
  248. package/runtime/__test__/element-template/fixtures/render/template-dedupe/index.tsx +28 -0
  249. package/runtime/__test__/element-template/fixtures/render/template-dedupe/output.txt +12 -0
  250. package/runtime/__test__/element-template/fixtures/render/template-dedupe/papi.txt +144 -0
  251. package/runtime/__test__/element-template/fixtures/render/template-dedupe/templates.json.txt +57 -0
  252. package/runtime/__test__/element-template/imports/global-props-api.test.ts +23 -0
  253. package/runtime/__test__/element-template/imports/init-data-api.test.ts +19 -0
  254. package/runtime/__test__/element-template/imports/jsx-runtime.test.ts +76 -0
  255. package/runtime/__test__/element-template/imports/legacy-react-runtime.test.ts +100 -0
  256. package/runtime/__test__/element-template/imports/main-thread-ref-api.test.ts +10 -0
  257. package/runtime/__test__/element-template/imports/no-legacy-imports.test.ts +415 -0
  258. package/runtime/__test__/element-template/imports/register-data-processors.test.ts +34 -0
  259. package/runtime/__test__/element-template/imports/suspense-lazy.test.ts +340 -0
  260. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +35 -0
  261. package/runtime/__test__/element-template/lynx/env.test.ts +242 -0
  262. package/runtime/__test__/element-template/lynx/lazy-bundle.test.ts +294 -0
  263. package/runtime/__test__/element-template/lynx/performance.test.ts +161 -0
  264. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +107 -0
  265. package/runtime/__test__/element-template/native/index.test.ts +224 -0
  266. package/runtime/__test__/element-template/native/init-timing-api.test.ts +29 -0
  267. package/runtime/__test__/element-template/native/main-thread-api.test.ts +202 -0
  268. package/runtime/__test__/element-template/native/mts-destroy.test.ts +226 -0
  269. package/runtime/__test__/element-template/native/reload.test.ts +572 -0
  270. package/runtime/__test__/element-template/runtime/background/adapter/background-adapter.et.test.tsx +65 -0
  271. package/runtime/__test__/element-template/runtime/background/commit-context.test.ts +91 -0
  272. package/runtime/__test__/element-template/runtime/background/commit-hook.test.ts +800 -0
  273. package/runtime/__test__/element-template/runtime/background/component-stack.test.tsx +76 -0
  274. package/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +867 -0
  275. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +220 -0
  276. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +173 -0
  277. package/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.ts +43 -0
  278. package/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts +16 -0
  279. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +2223 -0
  280. package/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsx +129 -0
  281. package/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts +16 -0
  282. package/runtime/__test__/element-template/runtime/background/instance.test.ts +2765 -0
  283. package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +287 -0
  284. package/runtime/__test__/element-template/runtime/background/manager.test.ts +142 -0
  285. package/runtime/__test__/element-template/runtime/background/page-root-hydrate.test.ts +75 -0
  286. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +339 -0
  287. package/runtime/__test__/element-template/runtime/background/reload.test.ts +79 -0
  288. package/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts +16 -0
  289. package/runtime/__test__/element-template/runtime/background/render/preact.test.tsx +268 -0
  290. package/runtime/__test__/element-template/runtime/background/root-render.test.tsx +265 -0
  291. package/runtime/__test__/element-template/runtime/background/suspense.test.tsx +940 -0
  292. package/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +277 -0
  293. package/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx +163 -0
  294. package/runtime/__test__/element-template/runtime/background/update-timing.test.ts +127 -0
  295. package/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts +16 -0
  296. package/runtime/__test__/element-template/runtime/hydration/hydration-listener.test.ts +1249 -0
  297. package/runtime/__test__/element-template/runtime/page/authored-page.test.ts +35 -0
  298. package/runtime/__test__/element-template/runtime/page/compiled-fixtures.test.tsx +560 -0
  299. package/runtime/__test__/element-template/runtime/page/fixtures.test.ts +16 -0
  300. package/runtime/__test__/element-template/runtime/page/page.test.ts +25 -0
  301. package/runtime/__test__/element-template/runtime/page/root-instance.test.ts +25 -0
  302. package/runtime/__test__/element-template/runtime/patch/compiled-fixtures.test.ts +40 -0
  303. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +3704 -0
  304. package/runtime/__test__/element-template/runtime/patch/fixtures.test.ts +16 -0
  305. package/runtime/__test__/element-template/runtime/patch/patch-listener-alog.test.ts +80 -0
  306. package/runtime/__test__/element-template/runtime/patch/update-fixture-helper.test.tsx +40 -0
  307. package/runtime/__test__/element-template/runtime/patch/update-timing.test.ts +203 -0
  308. package/runtime/__test__/element-template/runtime/prop-adapters/event.test.ts +183 -0
  309. package/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts +246 -0
  310. package/runtime/__test__/element-template/runtime/prop-adapters/ref.test.ts +155 -0
  311. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +160 -0
  312. package/runtime/__test__/element-template/runtime/protocol/template-type.test.ts +40 -0
  313. package/runtime/__test__/element-template/runtime/render/compact-host-debug.test.ts +57 -0
  314. package/runtime/__test__/element-template/runtime/render/compact-host.test.ts +199 -0
  315. package/runtime/__test__/element-template/runtime/render/fixtures.test.ts +18 -0
  316. package/runtime/__test__/element-template/runtime/render/render-components.test.jsx +292 -0
  317. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +527 -0
  318. package/runtime/__test__/element-template/runtime/render/render-direct-suspense.test.ts +378 -0
  319. package/runtime/__test__/element-template/runtime/render/render-direct.test.ts +491 -0
  320. package/runtime/__test__/element-template/runtime/render/render-main-thread.contract.test.ts +117 -0
  321. package/runtime/__test__/element-template/runtime/render/render-main-thread.test.ts +363 -0
  322. package/runtime/__test__/element-template/runtime/render/render-transform.contract.test.ts +565 -0
  323. package/runtime/__test__/element-template/runtime/template/element-template-attr-slot-plan.test.ts +373 -0
  324. package/runtime/__test__/element-template/runtime/template/element-template-handle.test.ts +228 -0
  325. package/runtime/__test__/element-template/runtime/template/element-template-registry.test.ts +65 -0
  326. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +567 -0
  327. package/runtime/__test__/element-template/runtime/template/main-thread-function.test.ts +280 -0
  328. package/runtime/__test__/element-template/test-utils/debug/compiledFixtureApp.ts +26 -0
  329. package/runtime/__test__/element-template/test-utils/debug/compiledFixtureCompiler.ts +76 -0
  330. package/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +74 -0
  331. package/runtime/__test__/element-template/test-utils/debug/compiledFixtureRegistry.ts +22 -0
  332. package/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts +82 -0
  333. package/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts +70 -0
  334. package/runtime/__test__/element-template/test-utils/debug/envManager.ts +96 -0
  335. package/runtime/__test__/element-template/test-utils/debug/fixtureRunner.ts +284 -0
  336. package/runtime/__test__/element-template/test-utils/debug/hydrate.ts +23 -0
  337. package/runtime/__test__/element-template/test-utils/debug/registry.ts +43 -0
  338. package/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +337 -0
  339. package/runtime/__test__/element-template/test-utils/debug/serializer.ts +79 -0
  340. package/runtime/__test__/element-template/test-utils/debug/updateRunner.test.tsx +148 -0
  341. package/runtime/__test__/element-template/test-utils/debug/updateRunner.ts +303 -0
  342. package/runtime/__test__/element-template/test-utils/mock/globals.js +35 -0
  343. package/runtime/__test__/element-template/test-utils/mock/jscontext-mock.test.ts +142 -0
  344. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/context.ts +305 -0
  345. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.test.ts +187 -0
  346. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi/templateTree.ts +745 -0
  347. package/runtime/__test__/element-template/test-utils/mock/mockNativePapi.ts +432 -0
  348. package/runtime/__test__/element-template/test-utils/mock/performance.js +68 -0
  349. package/runtime/__test__/element-template/test-utils/setup.js +100 -0
  350. package/runtime/__test__/element-template/vitest.config.ts +129 -0
  351. package/runtime/__test__/guardrails/snapshot-containment.test.ts +198 -0
  352. package/runtime/__test__/shared/profile.test.ts +88 -0
  353. package/runtime/__test__/snapshot/alog/elementPAPICall.test.js +50 -0
  354. package/runtime/__test__/snapshot/attribute-name.test.ts +78 -0
  355. package/runtime/__test__/snapshot/basic.test.jsx +718 -0
  356. package/runtime/__test__/snapshot/children.test.jsx +476 -0
  357. package/runtime/__test__/snapshot/clone.test.jsx +959 -0
  358. package/runtime/__test__/snapshot/commit-context.test.ts +29 -0
  359. package/runtime/__test__/snapshot/compat/export.test.jsx +42 -0
  360. package/runtime/__test__/snapshot/compat/hooks.test.jsx +45 -0
  361. package/runtime/__test__/snapshot/compat/initData.test.jsx +195 -0
  362. package/runtime/__test__/snapshot/compat/use-insertion-effect.test.jsx +128 -0
  363. package/runtime/__test__/snapshot/compat/use.test.jsx +111 -0
  364. package/runtime/__test__/snapshot/compat.test.jsx +199 -0
  365. package/runtime/__test__/snapshot/createElement.test.jsx +1352 -0
  366. package/runtime/__test__/snapshot/createSuspender.jsx +26 -0
  367. package/runtime/__test__/snapshot/css/compat.test.jsx +164 -0
  368. package/runtime/__test__/snapshot/css/remove-scoped-lazy-bundle.test.jsx +40 -0
  369. package/runtime/__test__/snapshot/css/remove-scoped-main-bundle.test.jsx +27 -0
  370. package/runtime/__test__/snapshot/css/scoped-lazy-bundle.test.jsx +45 -0
  371. package/runtime/__test__/snapshot/css/scoped-main-bundle.test.jsx +36 -0
  372. package/runtime/__test__/snapshot/debug/backgroundSnapshot-profile.test.jsx +366 -0
  373. package/runtime/__test__/snapshot/debug/children-with-same-key.test.jsx +43 -0
  374. package/runtime/__test__/snapshot/debug/describeInvalidValue.test.ts +32 -0
  375. package/runtime/__test__/snapshot/debug/formatPatch.test.ts +89 -0
  376. package/runtime/__test__/snapshot/debug/hooks-in-render.test.jsx +13 -0
  377. package/runtime/__test__/snapshot/debug/hooks-invalid-args.test.jsx +42 -0
  378. package/runtime/__test__/snapshot/debug/jsx-twice.test.jsx +55 -0
  379. package/runtime/__test__/snapshot/debug/main-thread-children-with-same-key.test.ts +28 -0
  380. package/runtime/__test__/snapshot/debug/missing-suspense.test.jsx +35 -0
  381. package/runtime/__test__/snapshot/debug/object-as-child.test.jsx +35 -0
  382. package/runtime/__test__/snapshot/debug/printSnapshot.test.jsx +155 -0
  383. package/runtime/__test__/snapshot/debug/profile.test.jsx +453 -0
  384. package/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx +285 -0
  385. package/runtime/__test__/snapshot/debug/set-state-in-ctor.test.jsx +40 -0
  386. package/runtime/__test__/snapshot/debug/too-many-rerenders.test.jsx +33 -0
  387. package/runtime/__test__/snapshot/debug/undefined-component.test.jsx +40 -0
  388. package/runtime/__test__/snapshot/debug/vnodeSource.test.ts +120 -0
  389. package/runtime/__test__/snapshot/delayed-lifecycle-events.test.jsx +62 -0
  390. package/runtime/__test__/snapshot/dynamicPartType.test.jsx +690 -0
  391. package/runtime/__test__/snapshot/element.test.jsx +46 -0
  392. package/runtime/__test__/snapshot/event.test.jsx +1294 -0
  393. package/runtime/__test__/snapshot/gesture/prepareGestureForCommit.test.js +86 -0
  394. package/runtime/__test__/snapshot/gesture/processGesture.test.ts +326 -0
  395. package/runtime/__test__/snapshot/gesture.test.jsx +1446 -0
  396. package/runtime/__test__/snapshot/hydrate.test.jsx +372 -0
  397. package/runtime/__test__/snapshot/jsx-runtime-lepus.test.jsx +89 -0
  398. package/runtime/__test__/snapshot/lazy.test.js +238 -0
  399. package/runtime/__test__/snapshot/legacySlot.legacy-slot.test.jsx +437 -0
  400. package/runtime/__test__/snapshot/lifecycle/commitHook.test.jsx +112 -0
  401. package/runtime/__test__/snapshot/lifecycle/destroy.test.jsx +47 -0
  402. package/runtime/__test__/snapshot/lifecycle/emptyPatch.test.jsx +104 -0
  403. package/runtime/__test__/snapshot/lifecycle/isRendering.test.jsx +114 -0
  404. package/runtime/__test__/snapshot/lifecycle/reload.test.jsx +1908 -0
  405. package/runtime/__test__/snapshot/lifecycle/reloadBG.jsx +79 -0
  406. package/runtime/__test__/snapshot/lifecycle/reloadGc.test.jsx +66 -0
  407. package/runtime/__test__/snapshot/lifecycle/reloadMT.jsx +76 -0
  408. package/runtime/__test__/snapshot/lifecycle/resetPageDataError.test.jsx +79 -0
  409. package/runtime/__test__/snapshot/lifecycle/updateData.test.jsx +1688 -0
  410. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +226 -0
  411. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +382 -0
  412. package/runtime/__test__/snapshot/lifecycle.test.jsx +675 -0
  413. package/runtime/__test__/snapshot/list.test.jsx +4956 -0
  414. package/runtime/__test__/snapshot/lynx/component-compat.test.ts +188 -0
  415. package/runtime/__test__/snapshot/lynx/dynamic-import.test.ts +111 -0
  416. package/runtime/__test__/snapshot/lynx/injectLepusMethods.test.jsx +81 -0
  417. package/runtime/__test__/snapshot/lynx/lazy-bundle-fetchbundle.test.js +659 -0
  418. package/runtime/__test__/snapshot/lynx/lazy-bundle.test.js +576 -0
  419. package/runtime/__test__/snapshot/lynx/portals.test.jsx +677 -0
  420. package/runtime/__test__/snapshot/lynx/prepareLazyBundleMTS.test.js +212 -0
  421. package/runtime/__test__/snapshot/lynx/processEvalResult.test.js +23 -0
  422. package/runtime/__test__/snapshot/lynx/runtime-backend.test.ts +81 -0
  423. package/runtime/__test__/snapshot/lynx/runtime-version.test.ts +140 -0
  424. package/runtime/__test__/snapshot/lynx/suspense.test.jsx +1641 -0
  425. package/runtime/__test__/snapshot/lynx/timing.test.jsx +1011 -0
  426. package/runtime/__test__/snapshot/lynx-data-processors.test.ts +3 -0
  427. package/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx +38 -0
  428. package/runtime/__test__/snapshot/mtf-execid-churn.test.jsx +216 -0
  429. package/runtime/__test__/snapshot/page.test.jsx +417 -0
  430. package/runtime/__test__/snapshot/preact.test.jsx +930 -0
  431. package/runtime/__test__/snapshot/ref-parity.test.jsx +78 -0
  432. package/runtime/__test__/snapshot/ref.test.jsx +2368 -0
  433. package/runtime/__test__/snapshot/render.test.jsx +148 -0
  434. package/runtime/__test__/snapshot/renderToOpcodes.test.jsx +1618 -0
  435. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +1798 -0
  436. package/runtime/__test__/snapshot/spread.test.jsx +778 -0
  437. package/runtime/__test__/snapshot/ssr.legacy-slot.test.jsx +168 -0
  438. package/runtime/__test__/snapshot/ssr.list.test.jsx +211 -0
  439. package/runtime/__test__/snapshot/ssr.test.jsx +574 -0
  440. package/runtime/__test__/snapshot/use-main-thread.test.jsx +141 -0
  441. package/runtime/__test__/snapshot/utils/debug.js +41 -0
  442. package/runtime/__test__/snapshot/utils/envManager.ts +109 -0
  443. package/runtime/__test__/snapshot/utils/globals.js +224 -0
  444. package/runtime/__test__/snapshot/utils/inject.ts +31 -0
  445. package/runtime/__test__/snapshot/utils/jsModule.ts +49 -0
  446. package/runtime/__test__/snapshot/utils/nativeMethod.ts +498 -0
  447. package/runtime/__test__/snapshot/utils/runtimeProxy.test.js +36 -0
  448. package/runtime/__test__/snapshot/utils/runtimeProxy.ts +73 -0
  449. package/runtime/__test__/snapshot/utils/setup.js +72 -0
  450. package/runtime/__test__/snapshot/worklet/onPost.test.js +30 -0
  451. package/runtime/__test__/snapshot/worklet/runOnBackground.test.js +234 -0
  452. package/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx +402 -0
  453. package/runtime/__test__/snapshot/worklet/transform.test.js +35 -0
  454. package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +292 -0
  455. package/runtime/__test__/snapshot/workletEvent.test.jsx +1286 -0
  456. package/runtime/__test__/snapshot/workletLifecycle.test.ts +198 -0
  457. package/runtime/__test__/snapshot/workletRef.test.jsx +831 -0
  458. package/runtime/__test__/snapshot/workletRefBG.jsx +95 -0
  459. package/runtime/__test__/snapshot/workletRefMT.jsx +99 -0
  460. package/runtime/__test__/test-utils/lynx-event-emitter.ts +63 -0
  461. package/runtime/__test__/tsconfig.json +9 -0
  462. package/runtime/__test__/worklet-runtime/api/element.test.js +274 -0
  463. package/runtime/__test__/worklet-runtime/delayWorkletEvent.test.js +89 -0
  464. package/runtime/__test__/worklet-runtime/eventPropagation.test.js +89 -0
  465. package/runtime/__test__/worklet-runtime/hydrate.test.js +92 -0
  466. package/runtime/__test__/worklet-runtime/jsFunctionLifecycle.test.js +89 -0
  467. package/runtime/__test__/worklet-runtime/mainThreadFlushLoopGuard.test.js +235 -0
  468. package/runtime/__test__/worklet-runtime/observers.test.js +119 -0
  469. package/runtime/__test__/worklet-runtime/profile.test.js +27 -0
  470. package/runtime/__test__/worklet-runtime/runOnBackground.test.js +188 -0
  471. package/runtime/__test__/worklet-runtime/runOnMainThread.test.js +66 -0
  472. package/runtime/__test__/worklet-runtime/workletRef.test.js +328 -0
  473. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +535 -0
  474. package/runtime/compat/index.d.ts +1 -1
  475. package/runtime/lazy/element-template-import.js +0 -4
  476. package/runtime/lazy/element-template-internal.js +45 -0
  477. package/runtime/lazy/element-template-jsx-dev-runtime.js +12 -0
  478. package/runtime/lazy/element-template-jsx-runtime.js +12 -0
  479. package/runtime/lazy/element-template.js +51 -0
  480. package/runtime/lazy/import.js +0 -4
  481. package/runtime/lazy/internal.js +15 -1
  482. package/runtime/lazy/target.js +0 -21
  483. package/runtime/lib/core/hooks/react.d.ts +2 -0
  484. package/runtime/lib/core/hooks/react.js +2 -0
  485. package/runtime/lib/core/hooks/react.js.map +1 -1
  486. package/runtime/lib/core/lynx/runtime-version.d.ts +16 -0
  487. package/runtime/lib/core/lynx/runtime-version.js +51 -0
  488. package/runtime/lib/core/lynx/runtime-version.js.map +1 -0
  489. package/runtime/lib/core/ref.d.ts +7 -5
  490. package/runtime/lib/core/ref.js +22 -11
  491. package/runtime/lib/core/ref.js.map +1 -1
  492. package/runtime/lib/element-template/background/attr-slots.d.ts +3 -1
  493. package/runtime/lib/element-template/background/attr-slots.js +5 -5
  494. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  495. package/runtime/lib/element-template/background/commit-context.d.ts +1 -1
  496. package/runtime/lib/element-template/background/commit-context.js +8 -9
  497. package/runtime/lib/element-template/background/commit-context.js.map +1 -1
  498. package/runtime/lib/element-template/background/document.d.ts +1 -1
  499. package/runtime/lib/element-template/background/document.js +1 -1
  500. package/runtime/lib/element-template/background/document.js.map +1 -1
  501. package/runtime/lib/element-template/background/hydrate.js +70 -36
  502. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  503. package/runtime/lib/element-template/background/instance.d.ts +4 -4
  504. package/runtime/lib/element-template/background/instance.js +15 -16
  505. package/runtime/lib/element-template/background/instance.js.map +1 -1
  506. package/runtime/lib/element-template/background/page-root-hydrate.js +1 -1
  507. package/runtime/lib/element-template/background/page-root-hydrate.js.map +1 -1
  508. package/runtime/lib/element-template/debug/alog.d.ts +4 -4
  509. package/runtime/lib/element-template/debug/alog.js +8 -8
  510. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  511. package/runtime/lib/element-template/debug/profile.js +38 -22
  512. package/runtime/lib/element-template/debug/profile.js.map +1 -1
  513. package/runtime/lib/element-template/index.d.ts +1 -1
  514. package/runtime/lib/element-template/index.js +1 -1
  515. package/runtime/lib/element-template/index.js.map +1 -1
  516. package/runtime/lib/element-template/internal.d.ts +4 -1
  517. package/runtime/lib/element-template/internal.js +6 -1
  518. package/runtime/lib/element-template/internal.js.map +1 -1
  519. package/runtime/lib/element-template/native/index.js +7 -1
  520. package/runtime/lib/element-template/native/index.js.map +1 -1
  521. package/runtime/lib/element-template/native/main-thread-api.js +3 -3
  522. package/runtime/lib/element-template/native/main-thread-api.js.map +1 -1
  523. package/runtime/lib/element-template/native/patch-listener.js +1 -2
  524. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  525. package/runtime/lib/element-template/native/reload-main-thread.js +3 -3
  526. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  527. package/runtime/lib/element-template/prop-adapters/ref.d.ts +3 -1
  528. package/runtime/lib/element-template/prop-adapters/ref.js +2 -2
  529. package/runtime/lib/element-template/prop-adapters/ref.js.map +1 -1
  530. package/runtime/lib/element-template/protocol/types.d.ts +27 -20
  531. package/runtime/lib/element-template/runtime/list/list.d.ts +6 -5
  532. package/runtime/lib/element-template/runtime/list/list.js +11 -7
  533. package/runtime/lib/element-template/runtime/list/list.js.map +1 -1
  534. package/runtime/lib/element-template/runtime/page/page.d.ts +3 -3
  535. package/runtime/lib/element-template/runtime/page/page.js +1 -1
  536. package/runtime/lib/element-template/runtime/page/page.js.map +1 -1
  537. package/runtime/lib/element-template/runtime/patch.js +35 -40
  538. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  539. package/runtime/lib/element-template/runtime/render/create-rendered-host.d.ts +7 -0
  540. package/runtime/lib/element-template/runtime/render/create-rendered-host.js +65 -0
  541. package/runtime/lib/element-template/runtime/render/create-rendered-host.js.map +1 -0
  542. package/runtime/lib/element-template/runtime/render/host.d.ts +18 -0
  543. package/runtime/lib/element-template/runtime/render/host.js +25 -0
  544. package/runtime/lib/element-template/runtime/render/host.js.map +1 -0
  545. package/runtime/lib/element-template/runtime/render/render-components.d.ts +6 -0
  546. package/runtime/lib/element-template/runtime/render/render-components.js +190 -0
  547. package/runtime/lib/element-template/runtime/render/render-components.js.map +1 -0
  548. package/runtime/lib/element-template/runtime/render/{render-opcodes.d.ts → render-direct.d.ts} +4 -2
  549. package/runtime/lib/element-template/runtime/render/render-direct.js +194 -0
  550. package/runtime/lib/element-template/runtime/render/render-direct.js.map +1 -0
  551. package/runtime/lib/element-template/runtime/render/render-main-thread.js +12 -11
  552. package/runtime/lib/element-template/runtime/render/render-main-thread.js.map +1 -1
  553. package/runtime/lib/element-template/runtime/template/handle.d.ts +5 -4
  554. package/runtime/lib/element-template/runtime/template/handle.js +17 -9
  555. package/runtime/lib/element-template/runtime/template/handle.js.map +1 -1
  556. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +2 -2
  557. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  558. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +1 -1
  559. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  560. package/runtime/lib/element-template/runtime/template/registry.d.ts +6 -6
  561. package/runtime/lib/element-template/runtime/template/registry.js.map +1 -1
  562. package/runtime/lib/element-template/runtime-marker.js +13 -0
  563. package/runtime/lib/element-template/runtime-marker.js.map +1 -0
  564. package/runtime/lib/index.d.ts +1 -1
  565. package/runtime/lib/index.js +1 -1
  566. package/runtime/lib/index.js.map +1 -1
  567. package/runtime/lib/internal.d.ts +3 -1
  568. package/runtime/lib/internal.js +5 -1
  569. package/runtime/lib/internal.js.map +1 -1
  570. package/runtime/lib/lynx-api.d.ts +15 -6
  571. package/runtime/lib/lynx-api.js +13 -4
  572. package/runtime/lib/lynx-api.js.map +1 -1
  573. package/runtime/lib/runtime-marker.js +13 -0
  574. package/runtime/lib/runtime-marker.js.map +1 -0
  575. package/runtime/lib/shared/component-stack.js +5 -1
  576. package/runtime/lib/shared/component-stack.js.map +1 -1
  577. package/runtime/lib/shared/render-constants.d.ts +1 -0
  578. package/runtime/lib/shared/render-constants.js +1 -0
  579. package/runtime/lib/shared/render-constants.js.map +1 -1
  580. package/runtime/lib/snapshot/debug/profileHooks.js +38 -22
  581. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -1
  582. package/runtime/lib/snapshot/lifecycle/reload.js +3 -0
  583. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  584. package/runtime/lib/snapshot/lynx/calledByNative.js +3 -0
  585. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  586. package/runtime/lib/snapshot/lynx/element.d.ts +2 -0
  587. package/runtime/lib/snapshot/lynx/element.js +2 -0
  588. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  589. package/runtime/lib/snapshot/renderToOpcodes/index.js +5 -3
  590. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -1
  591. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js +2 -1
  592. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -1
  593. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +18 -25
  594. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  595. package/runtime/lib/snapshot/snapshot/ref.d.ts +3 -2
  596. package/runtime/lib/snapshot/snapshot/ref.js +4 -7
  597. package/runtime/lib/snapshot/snapshot/ref.js.map +1 -1
  598. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  599. package/runtime/lib/worklet-runtime/bindings/types.d.ts +1 -1
  600. package/runtime/lib/worklet-runtime/hydrate.js +1 -1
  601. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  602. package/runtime/lib/worklet-runtime/workletRuntime.js +5 -14
  603. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  604. package/runtime/package.json +37 -0
  605. package/runtime/src/core/background-function/exec-map.ts +44 -0
  606. package/runtime/src/core/background-function/handle.ts +31 -0
  607. package/runtime/src/core/background-function/run-on-background.ts +151 -0
  608. package/runtime/src/core/commit-context.ts +26 -0
  609. package/runtime/src/core/compat/legacy-react-runtime.ts +39 -0
  610. package/runtime/src/core/compat/lynxComponent.ts +91 -0
  611. package/runtime/src/core/component.ts +152 -0
  612. package/runtime/src/core/forceRootRender.ts +52 -0
  613. package/runtime/src/core/globalProps.ts +111 -0
  614. package/runtime/src/core/hooks/mainThread.ts +9 -0
  615. package/runtime/src/core/hooks/mainThreadImpl.ts +226 -0
  616. package/runtime/src/core/hooks/react.ts +174 -0
  617. package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +59 -0
  618. package/runtime/src/core/initData.ts +191 -0
  619. package/runtime/src/core/lynx/dynamic-import.ts +37 -0
  620. package/runtime/src/core/lynx/lazy-bundle.ts +352 -0
  621. package/runtime/src/core/lynx/runtime-backend.ts +30 -0
  622. package/runtime/src/core/lynx/runtime-version.ts +62 -0
  623. package/runtime/src/core/lynx-data-processors.ts +85 -0
  624. package/runtime/src/core/lynx-page-data.ts +22 -0
  625. package/runtime/src/core/lynx-update-data.ts +47 -0
  626. package/runtime/src/core/main-thread-function.ts +12 -0
  627. package/runtime/src/core/main-thread-ref-init-value.ts +29 -0
  628. package/runtime/src/core/main-thread-ref.ts +225 -0
  629. package/runtime/src/core/mts-capability.ts +21 -0
  630. package/runtime/src/core/performance.ts +186 -0
  631. package/runtime/src/core/ref.ts +181 -0
  632. package/runtime/src/core/reload-version.ts +13 -0
  633. package/runtime/src/core/runtime-destroy.ts +22 -0
  634. package/runtime/src/core/thread-function-call/main-thread.ts +81 -0
  635. package/runtime/src/core/thread-function-call/return-value.ts +77 -0
  636. package/runtime/src/document.ts +86 -0
  637. package/runtime/src/element-template/background/attr-slots.ts +132 -0
  638. package/runtime/src/element-template/background/commit-context.ts +47 -0
  639. package/runtime/src/element-template/background/commit-hook.ts +211 -0
  640. package/runtime/src/element-template/background/destroy.ts +34 -0
  641. package/runtime/src/element-template/background/document.ts +41 -0
  642. package/runtime/src/element-template/background/hydrate.ts +637 -0
  643. package/runtime/src/element-template/background/hydration-listener.ts +198 -0
  644. package/runtime/src/element-template/background/instance.ts +819 -0
  645. package/runtime/src/element-template/background/manager.ts +89 -0
  646. package/runtime/src/element-template/background/page-root-hydrate.ts +23 -0
  647. package/runtime/src/element-template/background/render-scope.ts +52 -0
  648. package/runtime/src/element-template/client/root.ts +71 -0
  649. package/runtime/src/element-template/debug/alog.ts +238 -0
  650. package/runtime/src/element-template/debug/elementPAPICall.ts +89 -0
  651. package/runtime/src/element-template/debug/profile.ts +206 -0
  652. package/runtime/src/element-template/hydration-map.ts +13 -0
  653. package/runtime/src/element-template/index.ts +138 -0
  654. package/runtime/src/element-template/internal.ts +80 -0
  655. package/runtime/src/element-template/jsx-dev-runtime/index.ts +4 -0
  656. package/runtime/src/element-template/jsx-runtime/index.ts +86 -0
  657. package/runtime/src/element-template/lynx/env.ts +59 -0
  658. package/runtime/src/element-template/lynx/performance.ts +20 -0
  659. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +10 -0
  660. package/runtime/src/element-template/native/index.ts +96 -0
  661. package/runtime/src/element-template/native/main-thread-api.ts +55 -0
  662. package/runtime/src/element-template/native/mts-destroy.ts +46 -0
  663. package/runtime/src/element-template/native/patch-listener.ts +136 -0
  664. package/runtime/src/element-template/native/reload-background.ts +43 -0
  665. package/runtime/src/element-template/native/reload-main-thread.ts +76 -0
  666. package/runtime/src/element-template/prop-adapters/event-value.ts +11 -0
  667. package/runtime/src/element-template/prop-adapters/event.ts +87 -0
  668. package/runtime/src/element-template/prop-adapters/ref.ts +148 -0
  669. package/runtime/src/element-template/prop-adapters/spread.ts +66 -0
  670. package/runtime/src/element-template/protocol/lifecycle-constant.ts +8 -0
  671. package/runtime/src/element-template/protocol/opcodes.ts +18 -0
  672. package/runtime/src/element-template/protocol/page.ts +7 -0
  673. package/runtime/src/element-template/protocol/template-type.ts +56 -0
  674. package/runtime/src/element-template/protocol/types.ts +229 -0
  675. package/runtime/src/element-template/protocol/update-event.ts +46 -0
  676. package/runtime/src/element-template/runtime/list/list.ts +833 -0
  677. package/runtime/src/element-template/runtime/page/authored-page.ts +53 -0
  678. package/runtime/src/element-template/runtime/page/page.ts +21 -0
  679. package/runtime/src/element-template/runtime/page/root-instance.ts +25 -0
  680. package/runtime/src/element-template/runtime/patch.ts +517 -0
  681. package/runtime/src/element-template/runtime/render/create-rendered-host.ts +126 -0
  682. package/runtime/src/element-template/runtime/render/host.ts +51 -0
  683. package/runtime/src/element-template/runtime/render/render-components.ts +255 -0
  684. package/runtime/src/element-template/runtime/render/render-direct.ts +275 -0
  685. package/runtime/src/element-template/runtime/render/render-main-thread.ts +82 -0
  686. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +153 -0
  687. package/runtime/src/element-template/runtime/template/handle.ts +105 -0
  688. package/runtime/src/element-template/runtime/template/main-thread-background-function.ts +48 -0
  689. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +242 -0
  690. package/runtime/src/element-template/runtime/template/main-thread-event-ctx.ts +46 -0
  691. package/runtime/src/element-template/runtime/template/main-thread-function.ts +32 -0
  692. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +95 -0
  693. package/runtime/src/element-template/runtime/template/registry.ts +72 -0
  694. package/runtime/src/element-template/runtime/template/typed-attributes.ts +25 -0
  695. package/runtime/src/element-template/runtime-marker.ts +17 -0
  696. package/runtime/src/element-template/types.d.ts +128 -0
  697. package/runtime/src/index.ts +95 -0
  698. package/runtime/src/internal.ts +111 -0
  699. package/runtime/src/lynx-api.ts +572 -0
  700. package/runtime/src/lynx.ts +93 -0
  701. package/runtime/src/root.ts +38 -0
  702. package/runtime/src/runtime-marker.ts +17 -0
  703. package/runtime/src/shared/attribute-name.ts +109 -0
  704. package/runtime/src/shared/component-stack.ts +172 -0
  705. package/runtime/src/shared/index-map.ts +26 -0
  706. package/runtime/src/shared/profile.ts +36 -0
  707. package/runtime/src/shared/render-constants.ts +42 -0
  708. package/runtime/src/snapshot/alog/elementPAPICall.ts +132 -0
  709. package/runtime/src/snapshot/alog/index.ts +8 -0
  710. package/runtime/src/snapshot/alog/render.ts +33 -0
  711. package/runtime/src/snapshot/compat/componentIs.ts +30 -0
  712. package/runtime/src/snapshot/debug/debug.ts +9 -0
  713. package/runtime/src/snapshot/debug/describeInvalidValue.ts +25 -0
  714. package/runtime/src/snapshot/debug/formatPatch.ts +28 -0
  715. package/runtime/src/snapshot/debug/printSnapshot.ts +63 -0
  716. package/runtime/src/snapshot/debug/profileHooks.ts +283 -0
  717. package/runtime/src/snapshot/debug/vnodeSource.ts +82 -0
  718. package/runtime/src/snapshot/gesture/processGesture.ts +274 -0
  719. package/runtime/src/snapshot/gesture/processGestureBagkround.ts +94 -0
  720. package/runtime/src/snapshot/gesture/types.ts +46 -0
  721. package/runtime/src/snapshot/index.ts +5 -0
  722. package/runtime/src/snapshot/lifecycle/constant.ts +29 -0
  723. package/runtime/src/snapshot/lifecycle/destroy.ts +38 -0
  724. package/runtime/src/snapshot/lifecycle/event/delayEvents.ts +11 -0
  725. package/runtime/src/snapshot/lifecycle/event/delayLifecycleEvents.ts +15 -0
  726. package/runtime/src/snapshot/lifecycle/event/firstScreenSync.ts +97 -0
  727. package/runtime/src/snapshot/lifecycle/isRendering.ts +27 -0
  728. package/runtime/src/snapshot/lifecycle/patch/commit.ts +278 -0
  729. package/runtime/src/snapshot/lifecycle/patch/error.ts +66 -0
  730. package/runtime/src/snapshot/lifecycle/patch/globalState.ts +16 -0
  731. package/runtime/src/snapshot/lifecycle/patch/isMainThreadHydrating.ts +13 -0
  732. package/runtime/src/snapshot/lifecycle/patch/nodesRefApply.ts +119 -0
  733. package/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts +97 -0
  734. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +170 -0
  735. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +115 -0
  736. package/runtime/src/snapshot/lifecycle/ref/delay.ts +82 -0
  737. package/runtime/src/snapshot/lifecycle/reload.ts +99 -0
  738. package/runtime/src/snapshot/lifecycle/render.ts +36 -0
  739. package/runtime/src/snapshot/list/list.ts +320 -0
  740. package/runtime/src/snapshot/list/listUpdateInfo.ts +265 -0
  741. package/runtime/src/snapshot/list/pendingListUpdates.ts +44 -0
  742. package/runtime/src/snapshot/lynx/calledByNative.ts +184 -0
  743. package/runtime/src/snapshot/lynx/children.ts +40 -0
  744. package/runtime/src/snapshot/lynx/element.ts +219 -0
  745. package/runtime/src/snapshot/lynx/env.ts +58 -0
  746. package/runtime/src/snapshot/lynx/injectLepusMethods.ts +53 -0
  747. package/runtime/src/snapshot/lynx/lazyBundleConstants.ts +9 -0
  748. package/runtime/src/snapshot/lynx/nodesRef.ts +47 -0
  749. package/runtime/src/snapshot/lynx/performance.ts +20 -0
  750. package/runtime/src/snapshot/lynx/portals.ts +203 -0
  751. package/runtime/src/snapshot/lynx/portalsPending.ts +62 -0
  752. package/runtime/src/snapshot/lynx/prepareLazyBundleMTS.ts +68 -0
  753. package/runtime/src/snapshot/lynx/runWithForce.ts +18 -0
  754. package/runtime/src/snapshot/lynx/suspense.ts +58 -0
  755. package/runtime/src/snapshot/lynx/tt.ts +281 -0
  756. package/runtime/src/snapshot/renderToOpcodes/hydrate.ts +465 -0
  757. package/runtime/src/snapshot/renderToOpcodes/index.ts +445 -0
  758. package/runtime/src/snapshot/renderToOpcodes/opcodes.ts +156 -0
  759. package/runtime/src/snapshot/snapshot/backgroundSnapshot.ts +822 -0
  760. package/runtime/src/snapshot/snapshot/constants.ts +27 -0
  761. package/runtime/src/snapshot/snapshot/definition.ts +258 -0
  762. package/runtime/src/snapshot/snapshot/dynamicPartType.ts +40 -0
  763. package/runtime/src/snapshot/snapshot/event.ts +33 -0
  764. package/runtime/src/snapshot/snapshot/gesture.ts +31 -0
  765. package/runtime/src/snapshot/snapshot/index.ts +8 -0
  766. package/runtime/src/snapshot/snapshot/list.ts +66 -0
  767. package/runtime/src/snapshot/snapshot/platformInfo.ts +109 -0
  768. package/runtime/src/snapshot/snapshot/reconstructInstanceTree.ts +46 -0
  769. package/runtime/src/snapshot/snapshot/ref.ts +116 -0
  770. package/runtime/src/snapshot/snapshot/snapshot.ts +627 -0
  771. package/runtime/src/snapshot/snapshot/snapshotCreatorMap.ts +33 -0
  772. package/runtime/src/snapshot/snapshot/snapshotInstanceHydrationMap.ts +17 -0
  773. package/runtime/src/snapshot/snapshot/snapshotInstanceManager.ts +22 -0
  774. package/runtime/src/snapshot/snapshot/spread.ts +378 -0
  775. package/runtime/src/snapshot/snapshot/types.ts +29 -0
  776. package/runtime/src/snapshot/snapshot/utils.ts +59 -0
  777. package/runtime/src/snapshot/snapshot/workletEvent.ts +73 -0
  778. package/runtime/src/snapshot/snapshot/workletRef.ts +97 -0
  779. package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +37 -0
  780. package/runtime/src/snapshot/worklet/ctx.ts +22 -0
  781. package/runtime/src/snapshot/worklet/destroy.ts +14 -0
  782. package/runtime/src/snapshot/worklet/functionality.ts +22 -0
  783. package/runtime/src/snapshot/worklet/hmr.ts +34 -0
  784. package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +30 -0
  785. package/runtime/src/utils.ts +134 -0
  786. package/runtime/src/worklet-runtime/api/animation/animation.ts +48 -0
  787. package/runtime/src/worklet-runtime/api/animation/effect.ts +20 -0
  788. package/runtime/src/worklet-runtime/api/element.ts +152 -0
  789. package/runtime/src/worklet-runtime/api/lepusQuerySelector.ts +34 -0
  790. package/runtime/src/worklet-runtime/api/lynxApi.ts +42 -0
  791. package/runtime/src/worklet-runtime/bindings/bindings.ts +91 -0
  792. package/runtime/src/worklet-runtime/bindings/events.ts +29 -0
  793. package/runtime/src/worklet-runtime/bindings/index.ts +12 -0
  794. package/runtime/src/worklet-runtime/bindings/loadRuntime.ts +25 -0
  795. package/runtime/src/worklet-runtime/bindings/observers.ts +61 -0
  796. package/runtime/src/worklet-runtime/bindings/types.ts +84 -0
  797. package/runtime/src/worklet-runtime/delayRunOnBackground.ts +51 -0
  798. package/runtime/src/worklet-runtime/delayWorkletEvent.ts +70 -0
  799. package/runtime/src/worklet-runtime/eomImpl.ts +14 -0
  800. package/runtime/src/worklet-runtime/eventPropagation.ts +56 -0
  801. package/runtime/src/worklet-runtime/global.ts +28 -0
  802. package/runtime/src/worklet-runtime/hydrate.ts +113 -0
  803. package/runtime/src/worklet-runtime/index.ts +12 -0
  804. package/runtime/src/worklet-runtime/jsFunctionLifecycle.ts +69 -0
  805. package/runtime/src/worklet-runtime/listeners.ts +28 -0
  806. package/runtime/src/worklet-runtime/runOnMainThread.ts +21 -0
  807. package/runtime/src/worklet-runtime/types/dev.d.ts +4 -0
  808. package/runtime/src/worklet-runtime/types/elementApi.d.ts +97 -0
  809. package/runtime/src/worklet-runtime/types/runtimeProxy.d.ts +32 -0
  810. package/runtime/src/worklet-runtime/types/systeminfo.d.ts +19 -0
  811. package/runtime/src/worklet-runtime/utils/mainThreadFlushLoopGuard.ts +87 -0
  812. package/runtime/src/worklet-runtime/utils/profile.ts +20 -0
  813. package/runtime/src/worklet-runtime/utils/version.ts +11 -0
  814. package/runtime/src/worklet-runtime/workletRef.ts +119 -0
  815. package/runtime/src/worklet-runtime/workletRuntime.ts +206 -0
  816. package/runtime/tsconfig.json +30 -0
  817. package/runtime/turbo.json +21 -0
  818. package/runtime/types/internal-preact.d.ts +67 -0
  819. package/runtime/types/types.d.ts +341 -0
  820. package/runtime/vitest.config.ts +181 -0
  821. package/runtime/worklet-runtime/dev.js +4 -16
  822. package/runtime/worklet-runtime/main.js +1 -1
  823. package/testing-library/.npmignore +6 -0
  824. package/testing-library/.turbo/turbo-build.log +28 -0
  825. package/testing-library/README.md +109 -0
  826. package/testing-library/dist/env/index.js +2 -2
  827. package/testing-library/dist/index.d.ts +3 -3
  828. package/testing-library/dist/plugins/index.js +1 -1
  829. package/testing-library/dist/pure.js +45 -44
  830. package/testing-library/dist/rstest-config.d.ts +15 -1
  831. package/testing-library/dist/rstest-config.js +38 -5
  832. package/testing-library/etc/react-lynx-testing-library.api.md +71 -0
  833. package/testing-library/loaders/jsx-loader.js +49 -0
  834. package/testing-library/node_modules/.bin/rsbuild +68 -0
  835. package/testing-library/node_modules/.bin/rspeedy +68 -0
  836. package/testing-library/node_modules/.bin/rstest +68 -0
  837. package/testing-library/package.json +28 -0
  838. package/testing-library/rslib.config.ts +97 -0
  839. package/testing-library/rstest.config.ts +44 -0
  840. package/testing-library/src/__tests__/3.1/text.test.jsx +109 -0
  841. package/testing-library/src/__tests__/act.test.jsx +348 -0
  842. package/testing-library/src/__tests__/alog.test.jsx +813 -0
  843. package/testing-library/src/__tests__/auto-cleanup-skip.test.jsx +25 -0
  844. package/testing-library/src/__tests__/auto-cleanup.test.jsx +12 -0
  845. package/testing-library/src/__tests__/background-only.test.jsx +45 -0
  846. package/testing-library/src/__tests__/button.test.jsx +25 -0
  847. package/testing-library/src/__tests__/cleanup.test.jsx +29 -0
  848. package/testing-library/src/__tests__/css/index.test.jsx +47 -0
  849. package/testing-library/src/__tests__/css/style1.css +3 -0
  850. package/testing-library/src/__tests__/css/style2.css +3 -0
  851. package/testing-library/src/__tests__/css/style3.module.css +3 -0
  852. package/testing-library/src/__tests__/dom-reuse.test.jsx +1515 -0
  853. package/testing-library/src/__tests__/end-to-end.test.jsx +212 -0
  854. package/testing-library/src/__tests__/events.test.jsx +368 -0
  855. package/testing-library/src/__tests__/lazy-bundle/LazyComponent.jsx +4 -0
  856. package/testing-library/src/__tests__/lazy-bundle/index.test.jsx +598 -0
  857. package/testing-library/src/__tests__/list.test.jsx +1015 -0
  858. package/testing-library/src/__tests__/lynx.test.jsx +85 -0
  859. package/testing-library/src/__tests__/portals.test.jsx +1303 -0
  860. package/testing-library/src/__tests__/preact-signals.test.jsx +190 -0
  861. package/testing-library/src/__tests__/raw-text.test.jsx +59 -0
  862. package/testing-library/src/__tests__/ref.test.jsx +573 -0
  863. package/testing-library/src/__tests__/reload/reloadGc.test.jsx +64 -0
  864. package/testing-library/src/__tests__/reload/reloadTemplate.js +39 -0
  865. package/testing-library/src/__tests__/remove-element.test.jsx +68 -0
  866. package/testing-library/src/__tests__/render.test.jsx +296 -0
  867. package/testing-library/src/__tests__/renderComponent.test.jsx +344 -0
  868. package/testing-library/src/__tests__/renderHook.test.jsx +61 -0
  869. package/testing-library/src/__tests__/rerender.test.jsx +62 -0
  870. package/testing-library/src/__tests__/rstest-config.test.js +31 -0
  871. package/testing-library/src/__tests__/slot-jsx.test.jsx +965 -0
  872. package/testing-library/src/__tests__/spread.test.jsx +212 -0
  873. package/testing-library/src/__tests__/stopwatch.test.jsx +80 -0
  874. package/testing-library/src/__tests__/text.test.jsx +130 -0
  875. package/testing-library/src/__tests__/worklet.test.jsx +618 -0
  876. package/testing-library/src/entry.ts +2 -0
  877. package/testing-library/src/env/index.ts +2 -0
  878. package/testing-library/src/env/rstest.ts +7 -0
  879. package/testing-library/src/env/vitest.ts +27 -0
  880. package/testing-library/src/fire-event.ts +199 -0
  881. package/testing-library/src/index.jsx +25 -0
  882. package/testing-library/src/plugins/index.ts +2 -0
  883. package/testing-library/src/plugins/vitest.ts +387 -0
  884. package/testing-library/src/pure.jsx +159 -0
  885. package/testing-library/src/rstest-config.ts +173 -0
  886. package/testing-library/src/setupFiles/common/bootstrap.js +6 -0
  887. package/testing-library/src/setupFiles/common/runtime-setup.js +142 -0
  888. package/testing-library/src/setupFiles/inner/rstest.js +13 -0
  889. package/testing-library/src/setupFiles/inner/vitest.js +17 -0
  890. package/testing-library/src/setupFiles/rstest.js +30 -0
  891. package/testing-library/src/setupFiles/vitest.js +29 -0
  892. package/testing-library/src/vitest.config.ts +14 -0
  893. package/testing-library/tsconfig.json +16 -0
  894. package/testing-library/turbo.json +21 -0
  895. package/testing-library/types/entry.d.ts +3 -3
  896. package/testing-library/vitest-polyfill.cjs +6 -0
  897. package/testing-library/vitest.3.1.config.ts +17 -0
  898. package/testing-library/vitest.config.ts +14 -0
  899. package/transform/.cargo/config.toml +2 -0
  900. package/transform/.gitignore +6 -0
  901. package/transform/.npmignore +8 -0
  902. package/transform/.turbo/turbo-build$colon$wasm.log +264 -0
  903. package/transform/Cargo.toml +45 -0
  904. package/transform/__test__/background-only.spec.js +222 -0
  905. package/transform/__test__/basic.bench.js +80 -0
  906. package/transform/__test__/css/__snapshots__/transform-all-css-scoped-all.js +18 -0
  907. package/transform/__test__/css/__snapshots__/transform-all-css-scoped-modules.js +18 -0
  908. package/transform/__test__/css/__snapshots__/transform-all-css-scoped-none.js +18 -0
  909. package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-all.js +24 -0
  910. package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-modules.js +24 -0
  911. package/transform/__test__/css/__snapshots__/transform-imports-css-scoped-none.js +24 -0
  912. package/transform/__test__/css/__snapshots__/transform-imports-defaults.js +5 -0
  913. package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-all.js +5 -0
  914. package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-modules.js +5 -0
  915. package/transform/__test__/css/__snapshots__/transform-imports-without-jsx-css-scoped-none.js +5 -0
  916. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all-lazy-bundle.js +50 -0
  917. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-all.js +50 -0
  918. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules-lazy-bundle.js +50 -0
  919. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-modules.js +50 -0
  920. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none-lazy-bundle.js +50 -0
  921. package/transform/__test__/css/__snapshots__/transform-jsx-css-scoped-none.js +50 -0
  922. package/transform/__test__/css/__snapshots__/transform-jsx-defaults.js +50 -0
  923. package/transform/__test__/css/css-scope.spec.js +209 -0
  924. package/transform/__test__/css/inline-style.spec.js +53 -0
  925. package/transform/__test__/css/object-lit-style.spec.js +293 -0
  926. package/transform/__test__/defines.spec.js +321 -0
  927. package/transform/__test__/fixture.spec.js +2493 -0
  928. package/transform/__test__/text.spec.js +75 -0
  929. package/transform/__test__/typescript.spec.js +97 -0
  930. package/transform/build.rs +11 -0
  931. package/transform/crates/swc_plugin_background_only/Cargo.toml +13 -0
  932. package/transform/crates/swc_plugin_background_only/lib.rs +326 -0
  933. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/defaults_to_null_without_fallback.js +5 -0
  934. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_nested_background_only.js +5 -0
  935. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_to_thread_conditional_in_child_position.js +8 -0
  936. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/desugars_to_thread_conditional_in_expression_position.js +3 -0
  937. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/keeps_the_fragment_for_a_lone_text_child.js +3 -0
  938. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/renders_nothing_for_empty_children.js +5 -0
  939. package/transform/crates/swc_plugin_background_only/tests/__swc_snapshots__/lib.rs/unwraps_a_lone_child_past_layout_and_comments.js +3 -0
  940. package/transform/crates/swc_plugin_compat/Cargo.toml +24 -0
  941. package/transform/crates/swc_plugin_compat/is_component_class.rs +51 -0
  942. package/transform/crates/swc_plugin_compat/lib.rs +1886 -0
  943. package/transform/crates/swc_plugin_compat/napi.rs +527 -0
  944. package/transform/crates/swc_plugin_compat/simplify_ctor_like_react_lynx_2.rs +172 -0
  945. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element.js +17 -0
  946. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_compiler_only.js +16 -0
  947. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_embedded.js +2 -0
  948. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_element_embedded_compiler_only.js +1 -0
  949. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_add_component_is_import.js +3 -0
  950. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_change_runtime_pkg.js +1 -0
  951. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_handle_recursive.js +4 -0
  952. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_left_no_remove_component_element_attr.js +1 -0
  953. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_handle_jsx_member_expression.js +1 -0
  954. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_rename_view_in_scope.js +6 -0
  955. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_rename_view_redeclaration.js +4 -0
  956. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_not_transform_event_props_when_disabled.js +1 -0
  957. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_remove_component_attr_regex.js +8 -0
  958. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_rename_view.js +1 -0
  959. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor.js +9 -0
  960. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_correct_order.js +10 -0
  961. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls.js +9 -0
  962. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls_with_macro.js +19 -0
  963. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_simplify_ctor_not_remain_local_decls_with_spread.js +12 -0
  964. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_transform_event_props_1.js +1 -0
  965. package/transform/crates/swc_plugin_compat/tests/__swc_snapshots__/lib.rs/should_transform_event_props_2.js +1 -0
  966. package/transform/crates/swc_plugin_css_scope/Cargo.toml +18 -0
  967. package/transform/crates/swc_plugin_css_scope/lib.rs +327 -0
  968. package/transform/crates/swc_plugin_css_scope/napi.rs +144 -0
  969. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_all_transform_imports.js +5 -0
  970. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_all_transform_imports_without_jsx.js +4 -0
  971. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_modules_transform_imports.js +5 -0
  972. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_modules_transform_imports_without_jsx.js +4 -0
  973. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_none_transform_imports.js +5 -0
  974. package/transform/crates/swc_plugin_css_scope/tests/__swc_snapshots__/lib.rs/scoped_none_transform_imports_without_jsx.js +4 -0
  975. package/transform/crates/swc_plugin_define_dce/Cargo.toml +15 -0
  976. package/transform/crates/swc_plugin_define_dce/lib.rs +21 -0
  977. package/transform/crates/swc_plugin_define_dce/napi.rs +79 -0
  978. package/transform/crates/swc_plugin_directive_dce/Cargo.toml +18 -0
  979. package/transform/crates/swc_plugin_directive_dce/lib.rs +489 -0
  980. package/transform/crates/swc_plugin_directive_dce/napi.rs +65 -0
  981. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_do_nothing_in_mixed_target.js +6 -0
  982. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_do_nothing_when_arrow_function_return_directive.js +1 -0
  983. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_async_arrow_with_background_only_directive.js +1 -0
  984. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_background_only_generator_forms.js +7 -0
  985. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_fn_body_in_component_props.js +1 -0
  986. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_fn_decl.js +1 -0
  987. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_but_keep_constructor.js +6 -0
  988. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_class_method.js +4 -0
  989. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_class_property.js +4 -0
  990. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_js_only_embedded.js +5 -0
  991. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_native_modules_in_default_params.js +1 -0
  992. package/transform/crates/swc_plugin_directive_dce/tests/__swc_snapshots__/lib.rs/should_eliminate_transpiled_async_arrow_with_background_only_generator.js +1 -0
  993. package/transform/crates/swc_plugin_dynamic_import/Cargo.toml +18 -0
  994. package/transform/crates/swc_plugin_dynamic_import/lib.rs +510 -0
  995. package/transform/crates/swc_plugin_dynamic_import/napi.rs +89 -0
  996. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_import_lazy_bundle.js +4 -0
  997. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_import_lazy_import.js +9 -0
  998. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_not_import_lazy.js +3 -0
  999. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_suffix_webpack_chunk_name.js +5 -0
  1000. package/transform/crates/swc_plugin_dynamic_import/tests/__swc_snapshots__/lib.rs/should_transform_import_call.js +61 -0
  1001. package/transform/crates/swc_plugin_element_template/Cargo.toml +29 -0
  1002. package/transform/crates/swc_plugin_element_template/asset.rs +64 -0
  1003. package/transform/crates/swc_plugin_element_template/attr_name.rs +77 -0
  1004. package/transform/crates/swc_plugin_element_template/extractor.rs +484 -0
  1005. package/transform/crates/swc_plugin_element_template/host_lowering.rs +111 -0
  1006. package/transform/crates/swc_plugin_element_template/lib.rs +770 -0
  1007. package/transform/crates/swc_plugin_element_template/lowering.rs +157 -0
  1008. package/transform/crates/swc_plugin_element_template/napi.rs +168 -0
  1009. package/transform/crates/swc_plugin_element_template/template_attribute.rs +31 -0
  1010. package/transform/crates/swc_plugin_element_template/template_definition.rs +375 -0
  1011. package/transform/crates/swc_plugin_element_template/template_identity.rs +160 -0
  1012. package/transform/crates/swc_plugin_element_template/template_slot.rs +81 -0
  1013. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_generate_attribute_slots_for_dynamic_attributes.snap +81 -0
  1014. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_background_conditional_attributes.snap +44 -0
  1015. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_boolean_and_number_attributes.snap +62 -0
  1016. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_complex_text_structure.snap +120 -0
  1017. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dataset_attributes.snap +62 -0
  1018. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_deeply_nested_user_components.snap +54 -0
  1019. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_dynamic_class_attributes.snap +57 -0
  1020. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_js.snap +57 -0
  1021. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_events_lepus.snap +57 -0
  1022. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_id_attributes.snap +57 -0
  1023. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_inline_styles.snap +82 -0
  1024. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_js.snap +85 -0
  1025. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_interpolated_text_with_siblings_lepus.snap +85 -0
  1026. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_mixed_content.snap +82 -0
  1027. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_nested_structure_and_dynamic_content.snap +143 -0
  1028. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_js.snap +52 -0
  1029. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_refs_lepus.snap +52 -0
  1030. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_sibling_user_components.snap +69 -0
  1031. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_spread_attributes.snap +56 -0
  1032. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_handle_user_component.snap +54 -0
  1033. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_isolate_arrays_with_child_slot_placeholder.snap +56 -0
  1034. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_keep_code_and_template_attribute_slots_in_sync_for_spread.snap +66 -0
  1035. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_element_template_simple_lepus.snap +52 -0
  1036. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_output_template_with_static_attributes.snap +62 -0
  1037. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_template_structure_complex.snap +69 -0
  1038. package/transform/crates/swc_plugin_element_template/tests/__combined_snapshots__/should_verify_text_attribute_and_child_text_slots.snap +70 -0
  1039. package/transform/crates/swc_plugin_element_template/tests/element_template.rs +1211 -0
  1040. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +1016 -0
  1041. package/transform/crates/swc_plugin_inject/Cargo.toml +18 -0
  1042. package/transform/crates/swc_plugin_inject/lib.rs +344 -0
  1043. package/transform/crates/swc_plugin_inject/napi.rs +150 -0
  1044. package/transform/crates/swc_plugin_inject/tests/__swc_snapshots__/lib.rs/should_inject.js +8 -0
  1045. package/transform/crates/swc_plugin_inject/tests/__swc_snapshots__/lib.rs/should_inject_callee.js +1 -0
  1046. package/transform/crates/swc_plugin_list/Cargo.toml +15 -0
  1047. package/transform/crates/swc_plugin_list/legacy_slot.rs +410 -0
  1048. package/transform/crates/swc_plugin_list/lib.rs +631 -0
  1049. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_legacy_slot.js +61 -0
  1050. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_toplevel_legacy_slot.js +40 -0
  1051. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/basic_list_with_fragment_legacy_slot.js +65 -0
  1052. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_in_view_legacy_slot.js +6 -0
  1053. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_in_view_with_snapshot_legacy_slot.js +49 -0
  1054. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_item_deferred_in_list_legacy_slot.js +5 -0
  1055. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/legacy_slot.rs/should_transform_list_item_deferred_with_children_with_snapshot_legacy_slot.js +95 -0
  1056. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list.js +53 -0
  1057. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list_toplevel.js +40 -0
  1058. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/basic_list_with_fragment.js +57 -0
  1059. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_not_transform_list_item_with_defer_false.js +1 -0
  1060. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view.js +6 -0
  1061. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_snapshot.js +54 -0
  1062. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling.js +7 -0
  1063. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_nested.js +16 -0
  1064. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_with_snapshot.js +65 -0
  1065. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_in_view_with_static_sibling_with_snapshot_nested.js +138 -0
  1066. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_basic.js +2 -0
  1067. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_in_list.js +5 -0
  1068. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children.js +6 -0
  1069. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_deferred_with_children_with_snapshot.js +95 -0
  1070. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_not_deferred.js +1 -0
  1071. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_when_defer_is_expr.js +4 -0
  1072. package/transform/crates/swc_plugin_list/tests/__swc_snapshots__/lib.rs/should_transform_list_item_with_spread_deferred.js +2 -0
  1073. package/transform/crates/swc_plugin_shake/Cargo.toml +20 -0
  1074. package/transform/crates/swc_plugin_shake/is_component_class.rs +66 -0
  1075. package/transform/crates/swc_plugin_shake/lib.rs +908 -0
  1076. package/transform/crates/swc_plugin_shake/napi.rs +220 -0
  1077. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/only_shake_class_like_react_component_class.js +10 -0
  1078. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_access_inside_class_property_iife.js +11 -0
  1079. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_constructor_and_used.js +12 -0
  1080. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_indirect.js +12 -0
  1081. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_render_and_used.js +11 -0
  1082. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_state_and_remove_other.js +8 -0
  1083. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_use_effect_call_from_custom_runtime.js +6 -0
  1084. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_keep_with_nested_class.js +11 -0
  1085. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_call_in_scope_id.js +5 -0
  1086. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_in_scope_id.js +5 -0
  1087. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_not_remove_test_with_other_runtime.js +3 -0
  1088. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_call.js +4 -0
  1089. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_call_by_local_name.js +4 -0
  1090. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_param.js +4 -0
  1091. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_aliased_use_effect_param_by_local_name.js +4 -0
  1092. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_default_and_namespace_runtime_import_calls.js +6 -0
  1093. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_default_and_namespace_runtime_import_params.js +6 -0
  1094. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_test.js +5 -0
  1095. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_unused_indirect.js +5 -0
  1096. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_use_effect_call.js +8 -0
  1097. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_remove_use_effect_param.js +8 -0
  1098. package/transform/crates/swc_plugin_shake/tests/__swc_snapshots__/lib.rs/should_replace_use_effect_call_with_undefined.js +2 -0
  1099. package/transform/crates/swc_plugin_snapshot/Cargo.toml +25 -0
  1100. package/transform/crates/swc_plugin_snapshot/attr_name.rs +84 -0
  1101. package/transform/crates/swc_plugin_snapshot/legacy_slot.rs +2201 -0
  1102. package/transform/crates/swc_plugin_snapshot/lib.rs +3495 -0
  1103. package/transform/crates/swc_plugin_snapshot/napi.rs +184 -0
  1104. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_legacy_slot.js +10 -0
  1105. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_jsx_dev_legacy_slot.js +35 -0
  1106. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_jsx_legacy_slot.js +27 -0
  1107. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_component_with_static_sibling_legacy_slot.js +24 -0
  1108. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_expr_container_legacy_slot.js +10 -0
  1109. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_expr_container_with_static_sibling_legacy_slot.js +24 -0
  1110. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/basic_spread_list_item_legacy_slot.js +42 -0
  1111. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/full_static_children_map_jsx_legacy_slot.js +44 -0
  1112. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_component_legacy_slot.js +15 -0
  1113. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_element_dev_legacy_slot.js +16 -0
  1114. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/page_element_legacy_slot.js +16 -0
  1115. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_create_raw_text_node_for_text_node_legacy_slot.js +55 -0
  1116. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_emit_list_item_platform_info_marker_for_spread_props_legacy_slot.js +32 -0
  1117. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_inject_implicit_flatten_legacy_slot.js +67 -0
  1118. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_not_wrap_dynamic_part.js +29 -0
  1119. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_wrap_dynamic_key_legacy_slot.js +54 -0
  1120. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/legacy_slot.rs/should_wrap_dynamic_part.js +34 -0
  1121. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component.js +10 -0
  1122. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling.js +24 -0
  1123. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx.js +27 -0
  1124. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_component_with_static_sibling_jsx_dev.js +35 -0
  1125. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_event.js +26 -0
  1126. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container.js +10 -0
  1127. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_expr_container_with_static_sibling.js +24 -0
  1128. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static.js +25 -0
  1129. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract.js +16 -0
  1130. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_full_static_snapshot_extract_it.js +21 -0
  1131. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_ref.js +45 -0
  1132. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread.js +30 -0
  1133. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_spread_list_item.js +30 -0
  1134. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/basic_timing_flag.js +31 -0
  1135. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/empty_module.js +1 -0
  1136. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/external_bundle_uses_card_entry_name.js +16 -0
  1137. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_comments.js +19 -0
  1138. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_map_jsx.js +28 -0
  1139. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_new_line.js +25 -0
  1140. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/full_static_children_self_close.js +25 -0
  1141. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/gesture.js +26 -0
  1142. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal.js +11 -0
  1143. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/inline_style_literal_unknown_property.js +11 -0
  1144. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/mode_development_spread.js +24 -0
  1145. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_component.js +15 -0
  1146. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element.js +16 -0
  1147. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/page_element_dev.js +16 -0
  1148. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_create_raw_text_node_for_text_node.js +47 -0
  1149. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_emit_list_item_platform_info_marker_for_non_zero_value_index.js +25 -0
  1150. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_emit_list_item_platform_info_marker_for_spread_props.js +22 -0
  1151. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_escape_newline_character.js +55 -0
  1152. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id.js +71 -0
  1153. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component.js +71 -0
  1154. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_dynamic_component_without_css_id.js +69 -0
  1155. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_extract_css_id_without_css_id.js +69 -0
  1156. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_inject_implicit_flatten.js +59 -0
  1157. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_set_attribute_for_text_node.js +44 -0
  1158. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js +69 -0
  1159. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_inline_style.js +21 -0
  1160. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_wrap_dynamic_key.js +46 -0
  1161. package/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/worklet.js +35 -0
  1162. package/transform/crates/swc_plugin_text/Cargo.toml +14 -0
  1163. package/transform/crates/swc_plugin_text/lib.rs +134 -0
  1164. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_keep_children_for_dynamic_or_multiple_text.js +22 -0
  1165. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_single_static_text_to_text_attr.js +8 -0
  1166. package/transform/crates/swc_plugin_text/tests/__swc_snapshots__/lib.rs/should_transform_string_expressions_to_text_attr.js +13 -0
  1167. package/transform/crates/swc_plugin_worklet/Cargo.toml +24 -0
  1168. package/transform/crates/swc_plugin_worklet/decl_collect.rs +226 -0
  1169. package/transform/crates/swc_plugin_worklet/extract_ident.rs +460 -0
  1170. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +326 -0
  1171. package/transform/crates/swc_plugin_worklet/globals.rs +104 -0
  1172. package/transform/crates/swc_plugin_worklet/hash.rs +29 -0
  1173. package/transform/crates/swc_plugin_worklet/lib.rs +2869 -0
  1174. package/transform/crates/swc_plugin_worklet/napi.rs +116 -0
  1175. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/class_in_worklet_1.js +3 -0
  1176. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_inner_ident.js +13 -0
  1177. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_add_worklet_runtime_ident_with_outer_ident.js +13 -0
  1178. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +12 -0
  1179. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +35 -0
  1180. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_js.js +6 -0
  1181. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_ident_from_this_lepus.js +15 -0
  1182. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_idents_outside_of_ctx.js +9 -0
  1183. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +29 -0
  1184. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +54 -0
  1185. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_js.js +12 -0
  1186. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_3_lepus.js +89 -0
  1187. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_js.js +3 -0
  1188. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_4_lepus.js +13 -0
  1189. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +23 -0
  1190. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +46 -0
  1191. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_handle_renamed_import_shadowing_js.js +16 -0
  1192. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_globals.js +15 -0
  1193. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_type_annotations.js +22 -0
  1194. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_destructure_from_closure.js +12 -0
  1195. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_catch_clause_params.js +17 -0
  1196. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_ident_from_this.js +9 -0
  1197. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_extract_idents_inside_of_ctx.js +24 -0
  1198. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_constructor.js +7 -0
  1199. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_getter_and_setter.js +13 -0
  1200. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_recursively.js +23 -0
  1201. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_transform_when_wrong_directives.js +14 -0
  1202. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_default_import_js.js +12 -0
  1203. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_js.js +12 -0
  1204. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_lepus.js +23 -0
  1205. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_namespace_import_js.js +12 -0
  1206. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_skip_shared_identifiers_string_key_js.js +12 -0
  1207. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_arrow_function.js +15 -0
  1208. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_js.js +6 -0
  1209. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_fn_decl_lepus.js +16 -0
  1210. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_function_expr.js +15 -0
  1211. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_js.js +11 -0
  1212. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_js_capture_values.js +11 -0
  1213. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_lepus.js +17 -0
  1214. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_js.js +14 -0
  1215. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_js_capture_values.js +11 -0
  1216. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_property_lepus.js +21 -0
  1217. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_js.js +9 -0
  1218. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_lepus.js +18 -0
  1219. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_js.js +9 -0
  1220. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_in_class_static_property_lepus.js +17 -0
  1221. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +15 -0
  1222. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_js.js +10 -0
  1223. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_fn_in_run_on_js_lepus.js +25 -0
  1224. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js_general.js +9 -0
  1225. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +34 -0
  1226. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_alias.js +20 -0
  1227. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general.js +20 -0
  1228. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus_general_mixed.js +20 -0
  1229. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets.js +29 -0
  1230. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_multiple_worklets_in_func.js +31 -0
  1231. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_js.js +6 -0
  1232. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_ui_worklet_lepus.js +15 -0
  1233. package/transform/crates/swc_plugin_worklet/worklet_type.rs +24 -0
  1234. package/transform/crates/swc_plugins_shared/Cargo.toml +27 -0
  1235. package/transform/crates/swc_plugins_shared/css.rs +64 -0
  1236. package/transform/crates/swc_plugins_shared/defines.rs +51 -0
  1237. package/transform/crates/swc_plugins_shared/engine_version.rs +50 -0
  1238. package/transform/crates/swc_plugins_shared/jsx_helpers.rs +455 -0
  1239. package/transform/crates/swc_plugins_shared/lib.rs +12 -0
  1240. package/transform/crates/swc_plugins_shared/lynx_event.rs +159 -0
  1241. package/transform/crates/swc_plugins_shared/target.rs +66 -0
  1242. package/transform/crates/swc_plugins_shared/target_napi.rs +69 -0
  1243. package/transform/crates/swc_plugins_shared/transform_mode.rs +61 -0
  1244. package/transform/crates/swc_plugins_shared/transform_mode_napi.rs +72 -0
  1245. package/transform/crates/swc_plugins_shared/utils.rs +149 -0
  1246. package/transform/dist/wasm.cjs +1 -1
  1247. package/transform/index.d.ts +7 -6
  1248. package/transform/node_modules/.bin/esbuild +59 -0
  1249. package/transform/node_modules/.bin/napi +68 -0
  1250. package/transform/package.json +42 -0
  1251. package/transform/rspack-napi/lib/index.d.ts +32 -0
  1252. package/transform/rspack-napi/lib/index.js +96 -0
  1253. package/transform/rspack-napi/lib/index.js.map +1 -0
  1254. package/transform/rspack-napi/package.json +25 -0
  1255. package/transform/rspack-napi/src/index.ts +161 -0
  1256. package/transform/rspack-napi/tsconfig.json +17 -0
  1257. package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -0
  1258. package/transform/scripts/build_wasm.js +55 -0
  1259. package/transform/src/bundle.rs +249 -0
  1260. package/transform/src/esbuild.rs +201 -0
  1261. package/transform/src/lib.rs +1197 -0
  1262. package/transform/src/swc_plugin_compat_post/mod.rs +143 -0
  1263. package/transform/src/swc_plugin_extract_str/mod.rs +382 -0
  1264. package/transform/src/swc_plugin_refresh/mod.rs +546 -0
  1265. package/transform/src/swc_plugin_transform_builtin_attribute_names/mod.rs +286 -0
  1266. package/transform/src/swc_plugin_worklet_post_process/mod.rs +100 -0
  1267. package/transform/src/wasm.js +39 -0
  1268. package/transform/swc-plugin-reactlynx/.cargo/config.toml +9 -0
  1269. package/transform/swc-plugin-reactlynx/.gitignore +2 -0
  1270. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +542 -0
  1271. package/transform/swc-plugin-reactlynx/Cargo.toml +30 -0
  1272. package/transform/swc-plugin-reactlynx/build.js +27 -0
  1273. package/transform/swc-plugin-reactlynx/index.d.ts +273 -0
  1274. package/transform/swc-plugin-reactlynx/package.json +22 -0
  1275. package/transform/swc-plugin-reactlynx/src/lib.rs +606 -0
  1276. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  1277. package/transform/swc-plugin-reactlynx/turbo.json +18 -0
  1278. package/transform/swc-plugin-reactlynx-compat/.cargo/config.toml +9 -0
  1279. package/transform/swc-plugin-reactlynx-compat/.gitignore +2 -0
  1280. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +58 -0
  1281. package/transform/swc-plugin-reactlynx-compat/Cargo.toml +17 -0
  1282. package/transform/swc-plugin-reactlynx-compat/build.js +27 -0
  1283. package/transform/swc-plugin-reactlynx-compat/index.d.ts +326 -0
  1284. package/transform/swc-plugin-reactlynx-compat/package.json +22 -0
  1285. package/transform/swc-plugin-reactlynx-compat/src/lib.rs +15 -0
  1286. package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
  1287. package/transform/swc-plugin-reactlynx-compat/turbo.json +18 -0
  1288. package/transform/tests/__swc_snapshots__/src/swc_plugin_compat_post/mod.rs/should_compat_dark_mode.js +3 -0
  1289. package/transform/tests/__swc_snapshots__/src/swc_plugin_compat_post/mod.rs/should_compat_dark_mode_custom_theme_expr.js +3 -0
  1290. package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_str.js +21 -0
  1291. package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_str_with_arr.js +20 -0
  1292. package/transform/tests/__swc_snapshots__/src/swc_plugin_extract_str/mod.rs/should_extract_tpl_str.js +9 -0
  1293. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_basic.js +4 -0
  1294. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_custom_library.js +4 -0
  1295. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_function_parameter.js +4 -0
  1296. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_computed.js +4 -0
  1297. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_default.js +4 -0
  1298. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_named_computed.js +4 -0
  1299. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_import_namespace_computed.js +4 -0
  1300. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_init_value.js +10 -0
  1301. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_local_ident.js +8 -0
  1302. package/transform/tests/__swc_snapshots__/src/swc_plugin_refresh/mod.rs/should_handle_multiple_index.js +21 -0
  1303. package/transform/tests/__swc_snapshots__/src/swc_plugin_worklet_post_process/mod.rs/should_transform_worklet.js +12 -0
  1304. package/transform/tests/__swc_snapshots__/src/swc_plugin_worklet_post_process/mod.rs/should_transform_worklet_2.js +14 -0
  1305. package/transform/turbo.json +38 -0
  1306. package/transform/vitest.config.ts +19 -0
  1307. package/runtime/lib/element-template/runtime/render/render-opcodes.js +0 -216
  1308. package/runtime/lib/element-template/runtime/render/render-opcodes.js.map +0 -1
  1309. package/runtime/lib/element-template/runtime/render/render-to-opcodes.d.ts +0 -16
  1310. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js +0 -322
  1311. package/runtime/lib/element-template/runtime/render/render-to-opcodes.js.map +0 -1
  1312. package/runtime/lib/element-template/runtime-backend-marker.js +0 -6
  1313. package/runtime/lib/element-template/runtime-backend-marker.js.map +0 -1
  1314. package/runtime/lib/runtime-backend-marker.js +0 -6
  1315. package/runtime/lib/runtime-backend-marker.js.map +0 -1
  1316. /package/runtime/lib/element-template/{runtime-backend-marker.d.ts → runtime-marker.d.ts} +0 -0
  1317. /package/runtime/lib/{runtime-backend-marker.d.ts → runtime-marker.d.ts} +0 -0
@@ -0,0 +1,2493 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+ import { formatMessages } from 'esbuild';
6
+ import { describe, expect, it } from 'vitest';
7
+
8
+ import { transformBundleResult, transformReactLynx } from '../main.js';
9
+
10
+ const TEST_FILENAMES = {
11
+ uiSourceMap: '/path/to/src/ui-source-map.js',
12
+ };
13
+ const TEST_SNAPSHOT_FILENAMES = {
14
+ uiSourceMap: 'src/ui-source-map.js',
15
+ };
16
+
17
+ describe('transform builtin attribute names', () => {
18
+ it('should transform explicit attributes in the async transform task', async () => {
19
+ const result = await transformReactLynx(
20
+ 'const node = <view textMaxline={2} onClick={() => {}} onCatchTap={() => {}} onReady={() => {}} {...spread} />;',
21
+ {
22
+ mode: 'test',
23
+ pluginName: '',
24
+ filename: 'test.jsx',
25
+ sourcemap: false,
26
+ cssScope: false,
27
+ snapshot: false,
28
+ jsx: true,
29
+ directiveDCE: false,
30
+ defineDCE: false,
31
+ shake: false,
32
+ compat: false,
33
+ worklet: false,
34
+ refresh: false,
35
+ experimental_transformBuiltinAttributeNames: true,
36
+ },
37
+ );
38
+
39
+ expect(result.errors).toEqual([]);
40
+ expect(result.code).toContain('text-maxline');
41
+ expect(result.code).not.toContain('textMaxline');
42
+ expect(result.code).toContain('bindtap');
43
+ expect(result.code).toContain('catchtap');
44
+ expect(result.code).toContain('bindready');
45
+ expect(result.code).not.toContain('onClick');
46
+ expect(result.code).not.toContain('onCatchTap');
47
+ expect(result.code).not.toContain('onReady');
48
+ expect(result.code).toContain('...spread');
49
+ });
50
+
51
+ it('should apply serializable custom rules in the async transform task', async () => {
52
+ const result = await transformReactLynx(
53
+ 'const node = <view textMaxline={2} tailColorConvert accessibilityLabel="label" {...spread} />;',
54
+ {
55
+ mode: 'test',
56
+ pluginName: '',
57
+ filename: 'test.jsx',
58
+ sourcemap: false,
59
+ cssScope: false,
60
+ snapshot: false,
61
+ jsx: true,
62
+ directiveDCE: false,
63
+ defineDCE: false,
64
+ shake: false,
65
+ compat: false,
66
+ worklet: false,
67
+ refresh: false,
68
+ experimental_transformBuiltinAttributeNames: {
69
+ mode: 'dash-case',
70
+ preserve: ['tailColorConvert'],
71
+ rename: {
72
+ textMaxline: 'custom-maxline',
73
+ },
74
+ },
75
+ },
76
+ );
77
+
78
+ expect(result.errors).toEqual([]);
79
+ expect(result.code).toContain('custom-maxline');
80
+ expect(result.code).toContain('tailColorConvert');
81
+ expect(result.code).toContain('accessibility-label');
82
+ expect(result.code).toContain('...spread');
83
+ });
84
+
85
+ it('should allow builtin event conversion to run without compat event conversion', async () => {
86
+ const result = await transformReactLynx(
87
+ 'const node = <view onClick={() => {}} onCatchTap={() => {}} onReady={() => {}} />;',
88
+ {
89
+ mode: 'test',
90
+ pluginName: '',
91
+ filename: 'test.jsx',
92
+ sourcemap: false,
93
+ cssScope: false,
94
+ snapshot: false,
95
+ jsx: true,
96
+ directiveDCE: false,
97
+ defineDCE: false,
98
+ shake: false,
99
+ compat: {
100
+ target: 'MIXED',
101
+ componentsPkg: ['@lynx-js/react-components'],
102
+ oldRuntimePkg: ['@lynx-js/react-runtime'],
103
+ newRuntimePkg: '@lynx-js/react',
104
+ additionalComponentAttributes: [],
105
+ addComponentElement: false,
106
+ simplifyCtorLikeReactLynx2: false,
107
+ transformLegacyEventAttributeNames: false,
108
+ disableDeprecatedWarning: false,
109
+ },
110
+ worklet: false,
111
+ refresh: false,
112
+ experimental_transformBuiltinAttributeNames: true,
113
+ },
114
+ );
115
+
116
+ expect(result.errors).toEqual([]);
117
+ expect(result.code).toContain('bindtap');
118
+ expect(result.code).toContain('catchtap');
119
+ expect(result.code).toContain('bindready');
120
+ expect(result.code).not.toContain('bindcatchtap');
121
+ expect(result.code).not.toContain('onClick');
122
+ expect(result.code).not.toContain('onCatchTap');
123
+ expect(result.code).not.toContain('onReady');
124
+ });
125
+ });
126
+
127
+ describe('shake', () => {
128
+ it('should match', async () => {
129
+ const inputContent = `
130
+ import { Component } from "@lynx-js/react-runtime";
131
+ export class A extends Component {
132
+ d = 1
133
+ c = 2
134
+ renderA(){
135
+ this.c = 1;
136
+ this.renderB()
137
+ }
138
+ renderB(){}
139
+ renderC(){}
140
+ render(){
141
+ }
142
+ }`;
143
+ const result = await transformReactLynx(inputContent);
144
+ expect(result.code).toMatchInlineSnapshot(`
145
+ "import { Component } from "@lynx-js/react-runtime";
146
+ export class A extends Component {
147
+ d = 1;
148
+ c = 2;
149
+ renderA() {
150
+ this.c = 1;
151
+ this.renderB();
152
+ }
153
+ renderB() {}
154
+ renderC() {}
155
+ render() {}
156
+ }
157
+ "
158
+ `);
159
+ });
160
+
161
+ it('should shake with/without jsx transform', async () => {
162
+ const inputContent = `
163
+ import { Component } from "@lynx-js/react-runtime";
164
+ export class A extends Component {
165
+ d = 1
166
+ c = 2
167
+ renderA(){
168
+ this.c = 1;
169
+ this.renderB()
170
+ }
171
+ renderB(){}
172
+ renderC(){}
173
+ render(){
174
+ return <view/>
175
+ }
176
+ }`;
177
+
178
+ // eslint-disable-next-line unicorn/consistent-function-scoping
179
+ const __cfg = (jsx) => ({
180
+ mode: 'test',
181
+ pluginName: '',
182
+ filename: '',
183
+ sourcemap: false,
184
+ cssScope: false,
185
+ jsx,
186
+ directiveDCE: false,
187
+ defineDCE: false,
188
+ shake: true,
189
+ compat: true,
190
+ worklet: false,
191
+ refresh: false,
192
+ });
193
+
194
+ const result = await transformReactLynx(inputContent, __cfg(true));
195
+ expect(result.code).toMatchInlineSnapshot(`
196
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
197
+ import * as ReactLynx from "@lynx-js/react";
198
+ import { Component } from "@lynx-js/react/legacy-react-runtime";
199
+ const __snapshot_da39a_test_1 = "__snapshot_da39a_test_1";
200
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() {
201
+ const pageId = ReactLynx.__pageId;
202
+ const el = __CreateView(pageId);
203
+ return [
204
+ el
205
+ ];
206
+ }, null, null, undefined, globDynamicComponentEntry, null, true);
207
+ export class A extends Component {
208
+ render() {
209
+ return /*#__PURE__*/ _jsx(__snapshot_da39a_test_1, {});
210
+ }
211
+ }
212
+ "
213
+ `);
214
+
215
+ const result2 = await transformReactLynx(inputContent, __cfg(false));
216
+ expect(result2.code).toMatchInlineSnapshot(`
217
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
218
+ import * as ReactLynx from "@lynx-js/react";
219
+ import { Component } from "@lynx-js/react/legacy-react-runtime";
220
+ const __snapshot_da39a_test_1 = "__snapshot_da39a_test_1";
221
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_test_1] = (__snapshot_da39a_test_1)=>ReactLynx.createSnapshot(__snapshot_da39a_test_1, function() {
222
+ const pageId = ReactLynx.__pageId;
223
+ const el = __CreateView(pageId);
224
+ return [
225
+ el
226
+ ];
227
+ }, null, null, undefined, globDynamicComponentEntry, null, true);
228
+ export class A extends Component {
229
+ render() {
230
+ return /*#__PURE__*/ _jsx(__snapshot_da39a_test_1, {});
231
+ }
232
+ }
233
+ "
234
+ `);
235
+ });
236
+ });
237
+
238
+ describe('ui source map', () => {
239
+ it('should use the top-level filename for exported uiSourceMapRecords', async () => {
240
+ const result = await transformReactLynx('const node = <view />;', {
241
+ mode: 'test',
242
+ pluginName: '',
243
+ filename: TEST_FILENAMES.uiSourceMap,
244
+ sourcemap: false,
245
+ cssScope: false,
246
+ snapshot: {
247
+ preserveJsx: false,
248
+ runtimePkg: '@lynx-js/react',
249
+ jsxImportSource: '@lynx-js/react',
250
+ filename: TEST_SNAPSHOT_FILENAMES.uiSourceMap,
251
+ target: 'MIXED',
252
+ enableUiSourceMap: true,
253
+ },
254
+ jsx: true,
255
+ directiveDCE: false,
256
+ defineDCE: false,
257
+ shake: false,
258
+ compat: false,
259
+ worklet: false,
260
+ refresh: false,
261
+ });
262
+
263
+ expect(result.uiSourceMapRecords).toMatchInlineSnapshot(`
264
+ [
265
+ {
266
+ "columnNumber": 14,
267
+ "filename": "/path/to/src/ui-source-map.js",
268
+ "lineNumber": 1,
269
+ "snapshotId": "__snapshot_cf7b3_test_1",
270
+ "uiSourceMap": 222048564,
271
+ },
272
+ ]
273
+ `);
274
+ });
275
+ });
276
+
277
+ describe('element template', () => {
278
+ it('should export compiled element templates when enabled', async () => {
279
+ const result = await transformReactLynx('const node = <view className="foo" />;', {
280
+ mode: 'test',
281
+ pluginName: '',
282
+ filename: 'test.js',
283
+ sourcemap: false,
284
+ cssScope: false,
285
+ elementTemplate: {
286
+ preserveJsx: false,
287
+ runtimePkg: '@lynx-js/react',
288
+ filename: 'test.js',
289
+ target: 'LEPUS',
290
+ },
291
+ jsx: true,
292
+ directiveDCE: false,
293
+ defineDCE: false,
294
+ shake: false,
295
+ compat: true,
296
+ worklet: false,
297
+ refresh: false,
298
+ });
299
+
300
+ expect(Array.isArray(result.elementTemplates)).toBe(true);
301
+ const template = result.elementTemplates?.[0];
302
+ expect(template?.templateId).toEqual(expect.any(String));
303
+ expect(template?.templateId.length).toBeGreaterThan(0);
304
+ expect(template?.compiledTemplate).toEqual(expect.any(Object));
305
+ expect(Array.isArray(template?.compiledTemplate)).toBe(false);
306
+ expect(template?.sourceFile).toEqual(expect.any(String));
307
+ });
308
+
309
+ it('should not bridge legacy snapshot ET flags into the new ET plugin path', async () => {
310
+ const result = await transformReactLynx('const node = <view className="foo" />;', {
311
+ mode: 'test',
312
+ pluginName: '',
313
+ filename: 'test.js',
314
+ sourcemap: false,
315
+ cssScope: false,
316
+ snapshot: {
317
+ preserveJsx: false,
318
+ runtimePkg: '@lynx-js/react',
319
+ filename: 'test.js',
320
+ target: 'LEPUS',
321
+ enableElementTemplate: true,
322
+ },
323
+ jsx: true,
324
+ directiveDCE: false,
325
+ defineDCE: false,
326
+ shake: false,
327
+ compat: true,
328
+ worklet: false,
329
+ refresh: false,
330
+ });
331
+
332
+ expect(result.elementTemplates).toBeUndefined();
333
+ });
334
+
335
+ it('should return an empty template list when element template emits no assets', async () => {
336
+ const result = await transformReactLynx('const value = 1;', {
337
+ mode: 'test',
338
+ pluginName: '',
339
+ filename: 'test.js',
340
+ sourcemap: false,
341
+ cssScope: false,
342
+ elementTemplate: {
343
+ preserveJsx: false,
344
+ runtimePkg: '@lynx-js/react',
345
+ filename: 'test.js',
346
+ target: 'LEPUS',
347
+ },
348
+ jsx: true,
349
+ directiveDCE: false,
350
+ defineDCE: false,
351
+ shake: false,
352
+ compat: true,
353
+ worklet: false,
354
+ refresh: false,
355
+ });
356
+
357
+ expect(result.elementTemplates).toEqual([]);
358
+ });
359
+
360
+ it('should lower list as an exact typed host in element template mode', async () => {
361
+ const result = await transformReactLynx(
362
+ `
363
+ const node = (
364
+ <list id={listId} className="feed">
365
+ <list-item key="a" item-key={firstKey} full-span />
366
+ <list-item key="b" item-key={secondKey} recyclable />
367
+ </list>
368
+ );
369
+ `,
370
+ {
371
+ mode: 'test',
372
+ pluginName: '',
373
+ filename: 'test.js',
374
+ sourcemap: false,
375
+ cssScope: false,
376
+ elementTemplate: {
377
+ preserveJsx: false,
378
+ runtimePkg: '@lynx-js/react',
379
+ filename: 'test.js',
380
+ target: 'LEPUS',
381
+ },
382
+ jsx: true,
383
+ directiveDCE: false,
384
+ defineDCE: false,
385
+ shake: false,
386
+ compat: true,
387
+ worklet: false,
388
+ refresh: false,
389
+ },
390
+ );
391
+
392
+ expect(result.elementTemplates?.some(template => template.compiledTemplate.type === 'list')).toBe(false);
393
+ expect(result.elementTemplates?.some(template => template.compiledTemplate.type === 'list-item')).toBe(true);
394
+ expect(result.code).toMatchInlineSnapshot(`
395
+ "import { jsx as _jsx } from "react/jsx-runtime";
396
+ import * as ReactLynxInternal from "@lynx-js/react/internal";
397
+ const _et_4f796f70cdd7_bundle = globDynamicComponentEntry;
398
+ const _et_4f796f70cdd7 = \`\${_et_4f796f70cdd7_bundle}:\${"_et_4f796f70cdd7"}\`;
399
+ const _et_b8da8bac988e_bundle = globDynamicComponentEntry;
400
+ const _et_b8da8bac988e = \`\${_et_b8da8bac988e_bundle}:\${"_et_b8da8bac988e"}\`;
401
+ /*#__PURE__*/ _jsx("list", {
402
+ attributes: {
403
+ "id": listId,
404
+ "class": "feed"
405
+ },
406
+ $0: [
407
+ /*#__PURE__*/ ReactLynxInternal.__etHost(_et_4f796f70cdd7, "_et_4f796f70cdd7", _et_4f796f70cdd7_bundle, "a", [
408
+ firstKey
409
+ ], void 0, {
410
+ "item-key": firstKey,
411
+ "full-span": true
412
+ }),
413
+ /*#__PURE__*/ ReactLynxInternal.__etHost(_et_b8da8bac988e, "_et_b8da8bac988e", _et_b8da8bac988e_bundle, "b", [
414
+ secondKey
415
+ ], void 0, {
416
+ "item-key": secondKey,
417
+ "recyclable": true
418
+ })
419
+ ]
420
+ });
421
+ "
422
+ `);
423
+ });
424
+
425
+ it('should keep deferred list items on the existing unsupported component path in element template mode', async () => {
426
+ const result = await transformReactLynx('const node = <list><list-item defer item-key="1" /></list>;', {
427
+ mode: 'test',
428
+ pluginName: '',
429
+ filename: 'test.js',
430
+ sourcemap: false,
431
+ cssScope: false,
432
+ elementTemplate: {
433
+ preserveJsx: false,
434
+ runtimePkg: '@lynx-js/react',
435
+ filename: 'test.js',
436
+ target: 'LEPUS',
437
+ },
438
+ jsx: true,
439
+ directiveDCE: false,
440
+ defineDCE: false,
441
+ shake: false,
442
+ compat: true,
443
+ worklet: false,
444
+ refresh: false,
445
+ });
446
+
447
+ expect(result.errors).toEqual([]);
448
+ expect(result.code).toContain('DeferredListItem');
449
+ expect(result.code).toContain('_jsx("list", {');
450
+ expect(result.elementTemplates?.some(template => template.compiledTemplate.type === 'list')).toBe(false);
451
+ });
452
+
453
+ it('should warn when snapshot and element template are both explicitly enabled', async () => {
454
+ const result = await transformReactLynx('const node = <view />;', {
455
+ mode: 'test',
456
+ pluginName: '',
457
+ filename: 'test.js',
458
+ sourcemap: false,
459
+ cssScope: false,
460
+ snapshot: true,
461
+ elementTemplate: true,
462
+ jsx: true,
463
+ directiveDCE: false,
464
+ defineDCE: false,
465
+ shake: false,
466
+ compat: true,
467
+ worklet: false,
468
+ refresh: false,
469
+ });
470
+
471
+ expect(result.elementTemplates).toEqual(expect.any(Array));
472
+ expect(result.warnings).toEqual([
473
+ expect.objectContaining({
474
+ text: expect.stringContaining('elementTemplate'),
475
+ }),
476
+ ]);
477
+ });
478
+ });
479
+
480
+ describe('jsx', () => {
481
+ it('should allow JSXNamespace', async () => {
482
+ const result = await transformReactLynx('const jsx = <Foo main-thread:foo={foo} />', {
483
+ pluginName: '',
484
+ filename: '',
485
+ sourceFileName: '',
486
+ defineDCE: true,
487
+ sourcemap: false,
488
+ compat: false,
489
+ jsx: true,
490
+ shake: true,
491
+ cssScope: false,
492
+ refresh: false,
493
+ directiveDCE: {
494
+ target: 'LEPUS',
495
+ },
496
+ worklet: true,
497
+ experimental_moduleCompress: false,
498
+ });
499
+
500
+ expect(result).toMatchInlineSnapshot(`
501
+ {
502
+ "code": "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
503
+ /*#__PURE__*/ _jsx(Foo, {
504
+ "main-thread:foo": foo
505
+ });
506
+ ",
507
+ "definesForSnapshot": [],
508
+ "definesForWorklet": [],
509
+ "errors": [],
510
+ "uiSourceMapRecords": [],
511
+ "warnings": [],
512
+ }
513
+ `);
514
+ });
515
+
516
+ it('<list-item defer item-key="1" />', async () => {
517
+ const result = await transformReactLynx('const jsx = <list><list-item defer item-key="1" /></list>;', {
518
+ pluginName: '',
519
+ filename: '',
520
+ sourceFileName: '',
521
+ defineDCE: true,
522
+ sourcemap: false,
523
+ compat: false,
524
+ jsx: true,
525
+ shake: true,
526
+ cssScope: false,
527
+ refresh: false,
528
+ directiveDCE: {
529
+ target: 'LEPUS',
530
+ },
531
+ worklet: true,
532
+ experimental_moduleCompress: false,
533
+ });
534
+
535
+ expect(result).toMatchInlineSnapshot(`
536
+ {
537
+ "code": "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
538
+ import * as ReactLynx from "@lynx-js/react";
539
+ import * as ReactLynxRuntimeComponents from '@lynx-js/react/runtime-components';
540
+ const __snapshot_da39a_04d8c_2 = "__snapshot_da39a_04d8c_2";
541
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_04d8c_2] = (__snapshot_da39a_04d8c_2)=>ReactLynx.createSnapshot(__snapshot_da39a_04d8c_2, function() {
542
+ const pageId = ReactLynx.__pageId;
543
+ const el = __CreateElement("list-item", pageId);
544
+ return [
545
+ el
546
+ ];
547
+ }, [
548
+ (snapshot, index, oldValue)=>ReactLynx.updateListItemPlatformInfo(snapshot, index, oldValue, 0)
549
+ ], ReactLynx.__DynamicPartSlotV2_0, undefined, globDynamicComponentEntry, null, true);
550
+ const __snapshot_da39a_04d8c_1 = "__snapshot_da39a_04d8c_1";
551
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_04d8c_1] = (__snapshot_da39a_04d8c_1)=>ReactLynx.createSnapshot(__snapshot_da39a_04d8c_1, function(snapshotInstance) {
552
+ const pageId = ReactLynx.__pageId;
553
+ const el = ReactLynx.snapshotCreateList(pageId, snapshotInstance, 0);
554
+ return [
555
+ el
556
+ ];
557
+ }, null, [
558
+ [
559
+ ReactLynx.__DynamicPartListSlotV2,
560
+ 0
561
+ ]
562
+ ], undefined, globDynamicComponentEntry, null, true);
563
+ /*#__PURE__*/ _jsx(__snapshot_da39a_04d8c_1, {
564
+ $0: /*#__PURE__*/ _jsx(ReactLynxRuntimeComponents.DeferredListItem, {
565
+ renderListItem: (__c)=>_jsx(__snapshot_da39a_04d8c_2, {
566
+ values: [
567
+ {
568
+ "item-key": "1"
569
+ }
570
+ ],
571
+ __listItemPlatformInfoIndex: 0,
572
+ $0: __c
573
+ }),
574
+ renderChildren: ()=>[],
575
+ defer: true
576
+ })
577
+ });
578
+ ",
579
+ "definesForSnapshot": [
580
+ {
581
+ "code": "const __snapshot_da39a_04d8c_2 = "__snapshot_da39a_04d8c_2";
582
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_04d8c_2] = (__snapshot_da39a_04d8c_2)=>ReactLynx.createSnapshot(__snapshot_da39a_04d8c_2, function() {
583
+ const pageId = ReactLynx.__pageId;
584
+ const el = __CreateElement("list-item", pageId);
585
+ return [
586
+ el
587
+ ];
588
+ }, [
589
+ (snapshot, index, oldValue)=>ReactLynx.updateListItemPlatformInfo(snapshot, index, oldValue, 0)
590
+ ], ReactLynx.__DynamicPartSlotV2_0, undefined, globDynamicComponentEntry, null, true);
591
+ ",
592
+ "id": "__snapshot_da39a_04d8c_2",
593
+ },
594
+ {
595
+ "code": "const __snapshot_da39a_04d8c_1 = "__snapshot_da39a_04d8c_1";
596
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_04d8c_1] = (__snapshot_da39a_04d8c_1)=>ReactLynx.createSnapshot(__snapshot_da39a_04d8c_1, function(snapshotInstance) {
597
+ const pageId = ReactLynx.__pageId;
598
+ const el = ReactLynx.snapshotCreateList(pageId, snapshotInstance, 0);
599
+ return [
600
+ el
601
+ ];
602
+ }, null, [
603
+ [
604
+ ReactLynx.__DynamicPartListSlotV2,
605
+ 0
606
+ ]
607
+ ], undefined, globDynamicComponentEntry, null, true);
608
+ ",
609
+ "id": "__snapshot_da39a_04d8c_1",
610
+ },
611
+ ],
612
+ "definesForWorklet": [],
613
+ "errors": [],
614
+ "uiSourceMapRecords": [],
615
+ "warnings": [],
616
+ }
617
+ `);
618
+ });
619
+
620
+ it('<list-item> with dynamic key and spread attributes', async () => {
621
+ const result = await transformReactLynx(
622
+ `
623
+ const jsx = (
624
+ <list>
625
+ <list-item key={dynamicKey} item-key="hello-world" {...{ 'estimated-height-px': '10px' }}>
626
+ <text>123</text>
627
+ </list-item>
628
+ </list>
629
+ );
630
+ `,
631
+ {
632
+ pluginName: '',
633
+ filename: '',
634
+ sourceFileName: '',
635
+ defineDCE: true,
636
+ sourcemap: false,
637
+ compat: false,
638
+ jsx: true,
639
+ shake: true,
640
+ cssScope: false,
641
+ refresh: false,
642
+ directiveDCE: {
643
+ target: 'LEPUS',
644
+ },
645
+ worklet: true,
646
+ experimental_moduleCompress: false,
647
+ },
648
+ );
649
+
650
+ expect(result.code).toMatchInlineSnapshot(`
651
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
652
+ import * as ReactLynx from "@lynx-js/react";
653
+ const __snapshot_da39a_5e2e0_2 = "__snapshot_da39a_5e2e0_2";
654
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_5e2e0_2] = (__snapshot_da39a_5e2e0_2)=>ReactLynx.createSnapshot(__snapshot_da39a_5e2e0_2, function() {
655
+ const pageId = ReactLynx.__pageId;
656
+ const el = __CreateElement("list-item", pageId);
657
+ const el1 = __CreateText(pageId);
658
+ __AppendElement(el, el1);
659
+ const el2 = __CreateRawText("123");
660
+ __AppendElement(el1, el2);
661
+ return [
662
+ el,
663
+ el1,
664
+ el2
665
+ ];
666
+ }, [
667
+ (snapshot, index, oldValue)=>ReactLynx.updateSpread(snapshot, index, oldValue, 0, true)
668
+ ], null, undefined, globDynamicComponentEntry, [
669
+ 0
670
+ ], true);
671
+ const __snapshot_da39a_5e2e0_1 = "__snapshot_da39a_5e2e0_1";
672
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_5e2e0_1] = (__snapshot_da39a_5e2e0_1)=>ReactLynx.createSnapshot(__snapshot_da39a_5e2e0_1, function(snapshotInstance) {
673
+ const pageId = ReactLynx.__pageId;
674
+ const el = ReactLynx.snapshotCreateList(pageId, snapshotInstance, 0);
675
+ return [
676
+ el
677
+ ];
678
+ }, null, [
679
+ [
680
+ ReactLynx.__DynamicPartListSlotV2,
681
+ 0
682
+ ]
683
+ ], undefined, globDynamicComponentEntry, null, true);
684
+ /*#__PURE__*/ _jsx(__snapshot_da39a_5e2e0_1, {
685
+ $0: /*#__PURE__*/ _jsx(__snapshot_da39a_5e2e0_2, {
686
+ values: [
687
+ {
688
+ "item-key": "hello-world",
689
+ 'estimated-height-px': '10px',
690
+ __spread: true
691
+ }
692
+ ],
693
+ __listItemPlatformInfoIndex: 0
694
+ }, dynamicKey)
695
+ });
696
+ "
697
+ `);
698
+ });
699
+ });
700
+
701
+ describe('errors and warnings', () => {
702
+ it('should handle error', async () => {
703
+ const result = await transformReactLynx(`<view>;`);
704
+ expect(result).toMatchInlineSnapshot(`
705
+ {
706
+ "code": "",
707
+ "errors": [
708
+ {
709
+ "location": {
710
+ "column": 7,
711
+ "file": "",
712
+ "length": 0,
713
+ "line": 1,
714
+ "lineText": "<view>;",
715
+ },
716
+ "pluginName": "",
717
+ "text": "Expected '</', got '<eof>'",
718
+ },
719
+ ],
720
+ "uiSourceMapRecords": [],
721
+ "warnings": [],
722
+ }
723
+ `);
724
+ });
725
+
726
+ it('should nodiff compat', async () => {
727
+ const result = await transformReactLynx(
728
+ `
729
+ import { View } from "@lynx-js/react-components";
730
+ import { Unused } from "@lynx-js/react-components";
731
+ import { Component } from "@lynx-js/react-runtime";
732
+ Component, View
733
+ `,
734
+ {
735
+ pluginName: '',
736
+ filename: '',
737
+ sourcemap: false,
738
+ cssScope: false,
739
+ jsx: {
740
+ runtimePkg: '@lynx-js/react-runtime',
741
+ filename: '',
742
+ target: 'MIXED',
743
+ },
744
+ directiveDCE: false,
745
+ defineDCE: false,
746
+ shake: false,
747
+ compat: true,
748
+ worklet: false,
749
+ refresh: false,
750
+ },
751
+ );
752
+
753
+ expect(result).toMatchInlineSnapshot(`
754
+ {
755
+ "code": "import { Component } from "@lynx-js/react/legacy-react-runtime";
756
+ Component, View;
757
+ ",
758
+ "definesForSnapshot": [],
759
+ "definesForWorklet": [],
760
+ "errors": [],
761
+ "uiSourceMapRecords": [],
762
+ "warnings": [
763
+ {
764
+ "location": {
765
+ "column": 0,
766
+ "file": "",
767
+ "length": 49,
768
+ "line": 2,
769
+ "lineText": "import { View } from "@lynx-js/react-components";",
770
+ },
771
+ "pluginName": "",
772
+ "text": "DEPRECATED: old package "@lynx-js/react-components" is removed",
773
+ },
774
+ {
775
+ "location": {
776
+ "column": 0,
777
+ "file": "",
778
+ "length": 51,
779
+ "line": 4,
780
+ "lineText": "import { Component } from "@lynx-js/react-runtime";",
781
+ },
782
+ "pluginName": "",
783
+ "text": "DEPRECATED: old runtime package "@lynx-js/react-runtime" is changed to "@lynx-js/react"",
784
+ },
785
+ ],
786
+ }
787
+ `);
788
+ });
789
+
790
+ it('should format message', async () => {
791
+ const result = await transformReactLynx(`<view style="invalid: true;"/>;`);
792
+ // Should not have `__AddInlineStyle`
793
+ expect(result.code).not.toContain(`__AddInlineStyle`);
794
+ // Should have __SetInlineStyles(element, "invalid: true")
795
+ expect(result.code).toContain('invalid: true');
796
+ expect(
797
+ await formatMessages(result.warnings, { kind: 'warning', color: false }),
798
+ ).toMatchInlineSnapshot(`[]`);
799
+ });
800
+
801
+ it('should not warn JSXSpread when not enable addComponentElement', async () => {
802
+ const { formatMessages } = await import('esbuild');
803
+
804
+ const cfg = {
805
+ pluginName: '',
806
+ filename: '',
807
+ sourcemap: false,
808
+ cssScope: false,
809
+ jsx: {
810
+ runtimePkg: '@lynx-js/react-runtime',
811
+ filename: '',
812
+ target: 'MIXED',
813
+ },
814
+ directiveDCE: false,
815
+ defineDCE: false,
816
+ shake: false,
817
+ compat: {
818
+ target: 'LEPUS',
819
+ componentsPkg: ['@lynx-js/react-components'],
820
+ oldRuntimePkg: ['@lynx-js/react-runtime'],
821
+ newRuntimePkg: '@lynx-js/react',
822
+ additionalComponentAttributes: [],
823
+ addComponentElement: true,
824
+ simplifyCtorLikeReactLynx2: false,
825
+ disableDeprecatedWarning: false,
826
+ },
827
+ worklet: false,
828
+ refresh: false,
829
+ };
830
+
831
+ {
832
+ cfg.compat.addComponentElement = false;
833
+ const result = await transformReactLynx(`<Comp {...s}/>;`, cfg);
834
+ expect(
835
+ await formatMessages(result.warnings, {
836
+ kind: 'warning',
837
+ color: false,
838
+ }),
839
+ ).toMatchInlineSnapshot(`[]`);
840
+ }
841
+
842
+ {
843
+ cfg.compat.addComponentElement = {
844
+ compilerOnly: true,
845
+ };
846
+ const result = await transformReactLynx(`<Comp {...s}/>;`, cfg);
847
+ expect(
848
+ await formatMessages(result.warnings, {
849
+ kind: 'warning',
850
+ color: false,
851
+ }),
852
+ ).toMatchInlineSnapshot(`
853
+ [
854
+ "▲ [WARNING] addComponentElement: component with JSXSpread is ignored to avoid badcase, you can switch addComponentElement.compilerOnly to false to enable JSXSpread support
855
+
856
+ :1:7:
857
+ 1 │ <Comp {...s}/>;
858
+ ╵ ~~~
859
+
860
+ ",
861
+ ]
862
+ `);
863
+ expect(result.code).toMatchInlineSnapshot(`
864
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
865
+ /*#__PURE__*/ _jsx(Comp, {
866
+ ...s
867
+ });
868
+ "
869
+ `);
870
+ }
871
+
872
+ {
873
+ cfg.compat.addComponentElement = true;
874
+ const result = await transformReactLynx(`<Comp {...s}/>;`, cfg);
875
+ expect(
876
+ await formatMessages(result.warnings, {
877
+ kind: 'warning',
878
+ color: false,
879
+ }),
880
+ ).toMatchInlineSnapshot(`[]`);
881
+ expect(result.code).toMatchInlineSnapshot(`
882
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
883
+ import * as ReactLynx from "@lynx-js/react";
884
+ import * as ReactLynx1 from "@lynx-js/react/internal";
885
+ const __snapshot_da39a_89b7f_1 = "__snapshot_da39a_89b7f_1";
886
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_89b7f_1] = (__snapshot_da39a_89b7f_1)=>ReactLynx.createSnapshot(__snapshot_da39a_89b7f_1, function() {
887
+ const pageId = ReactLynx.__pageId;
888
+ const el = __CreateView(pageId);
889
+ return [
890
+ el
891
+ ];
892
+ }, [
893
+ (snapshot, index, oldValue)=>ReactLynx.updateSpread(snapshot, index, oldValue, 0, false)
894
+ ], ReactLynx.__DynamicPartSlotV2_0, undefined, globDynamicComponentEntry, [
895
+ 0
896
+ ], true);
897
+ /*#__PURE__*/ ReactLynx1.wrapWithLynxComponent((__c, __spread)=>_jsx(__snapshot_da39a_89b7f_1, {
898
+ values: [
899
+ {
900
+ ...__spread,
901
+ __spread: true
902
+ }
903
+ ],
904
+ $0: __c
905
+ }), _jsx(Comp, {
906
+ ...s
907
+ }));
908
+ "
909
+ `);
910
+ }
911
+ });
912
+
913
+ // eslint-disable-next-line unicorn/consistent-function-scoping
914
+ const __cfg = () => ({
915
+ pluginName: 'transform',
916
+ filename: '',
917
+ sourcemap: false,
918
+ cssScope: false,
919
+ jsx: {
920
+ runtimePkg: '@lynx-js/react-runtime',
921
+ filename: '',
922
+ target: 'MIXED',
923
+ },
924
+ directiveDCE: false,
925
+ defineDCE: false,
926
+ shake: false,
927
+ compat: {
928
+ target: 'LEPUS',
929
+ componentsPkg: ['@lynx-js/react-components'],
930
+ oldRuntimePkg: ['@lynx-js/react-runtime'],
931
+ newRuntimePkg: '@lynx-js/react',
932
+ additionalComponentAttributes: [],
933
+ addComponentElement: true,
934
+ simplifyCtorLikeReactLynx2: false,
935
+ disableDeprecatedWarning: false,
936
+ },
937
+ worklet: false,
938
+ refresh: false,
939
+ });
940
+
941
+ it('should error when encounter <component/>', async () => {
942
+ const { formatMessages } = await import('esbuild');
943
+
944
+ const cfg = __cfg();
945
+ {
946
+ cfg.compat.addComponentElement = true;
947
+ const result = await transformReactLynx(
948
+ `function A() { return <view><component/></view>; }`,
949
+ cfg,
950
+ );
951
+ expect(
952
+ await formatMessages(result.errors, { kind: 'error', color: false }),
953
+ ).toMatchInlineSnapshot(`[]`);
954
+ }
955
+ });
956
+
957
+ it('should error when encounter class property config', async () => {
958
+ const { formatMessages } = await import('esbuild');
959
+
960
+ const cfg = __cfg();
961
+ {
962
+ const result = await transformReactLynx(
963
+ `class A extends Component { config = {}; render() {return <view/>;} }`,
964
+ cfg,
965
+ );
966
+ expect(
967
+ await formatMessages(result.warnings, {
968
+ kind: 'warning',
969
+ color: false,
970
+ }),
971
+ ).toMatchInlineSnapshot(`
972
+ [
973
+ "▲ [WARNING] BROKEN: supporting for class property \`config\` is removed and MUST be migrated in ReactLynx 3.0, you should put your configs inside \`pageConfig\` in lynx.config.js [plugin transform]
974
+
975
+ :1:28:
976
+ 1 │ class A extends Component { config = {}; render() {return <view/>;} }
977
+ ╵ ~~~~~~~~~~~~
978
+
979
+ ",
980
+ ]
981
+ `);
982
+ }
983
+ });
984
+
985
+ it('should warning when encounter this.createSelectorQuery', async () => {
986
+ const { formatMessages } = await import('esbuild');
987
+
988
+ const cfg = __cfg();
989
+ {
990
+ const result = await transformReactLynx(
991
+ `this.createSelectorQuery();
992
+ this.getElementById();`,
993
+ cfg,
994
+ );
995
+ expect(
996
+ await formatMessages(result.warnings, {
997
+ kind: 'warning',
998
+ color: false,
999
+ }),
1000
+ ).toMatchInlineSnapshot(`
1001
+ [
1002
+ "▲ [WARNING] BROKEN: createSelectorQuery on component instance is broken and MUST be migrated in ReactLynx 3.0, please use ref or lynx.createSelectorQuery instead. [plugin transform]
1003
+
1004
+ :1:0:
1005
+ 1 │ this.createSelectorQuery();
1006
+ ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~
1007
+
1008
+ ",
1009
+ "▲ [WARNING] BROKEN: getElementById on component instance is broken and MUST be migrated in ReactLynx 3.0, please use ref or lynx.getElementById instead. [plugin transform]
1010
+
1011
+ :2:9:
1012
+ 2 │ this.getElementById();
1013
+ ╵ ~~~~~~~~~~~~~~~~~~~~~
1014
+
1015
+ ",
1016
+ ]
1017
+ `);
1018
+ }
1019
+
1020
+ {
1021
+ cfg.compat.disableDeprecatedWarning = true;
1022
+ const result = await transformReactLynx(
1023
+ `this.createSelectorQuery();
1024
+ this.getElementById();`,
1025
+ cfg,
1026
+ );
1027
+ expect(
1028
+ await formatMessages(result.warnings, {
1029
+ kind: 'warning',
1030
+ color: false,
1031
+ }),
1032
+ ).toMatchInlineSnapshot(`[]`);
1033
+ }
1034
+ });
1035
+ });
1036
+
1037
+ describe('transformBundle', () => {
1038
+ it('should extract lepus str', async () => {
1039
+ const inputContent = `
1040
+ globalThis.processData = ()=>{
1041
+ if (true) {
1042
+ return {
1043
+ _EXTRACT_STR: __EXTRACT_STR_IDENT_FLAG__,
1044
+ };
1045
+ }
1046
+ }
1047
+ const qq = {
1048
+ a: '123',
1049
+ b: false ? '456' : '789'
1050
+ };
1051
+ console.log('!@#@#$!!@#!#!3sasdega!!23!#$!@#%%');
1052
+ let q = fun('456');
1053
+ let a = '789';
1054
+ const b = '111' + '000';
1055
+ const tpl = \`Hello \${a}\`;
1056
+ const wrapped = \`\${a} middle \${b}\`;`;
1057
+ const result = await transformBundleResult(inputContent, {
1058
+ filename: 'lepus.js',
1059
+ pluginName: 'transformBundleResult',
1060
+ sourcemap: true,
1061
+ extractStr: {
1062
+ strLength: 1,
1063
+ },
1064
+ });
1065
+ expect(result.code).toMatchInlineSnapshot(`
1066
+ "var _EXTRACT_STR = [
1067
+ "123",
1068
+ "456",
1069
+ "789",
1070
+ "!@#@#$!!@#!#!3sasdega!!23!#$!@#%%",
1071
+ "111",
1072
+ "000",
1073
+ "Hello",
1074
+ "middle"
1075
+ ];
1076
+ globalThis.processData = ()=>{
1077
+ if (true) {
1078
+ return {
1079
+ _EXTRACT_STR: _EXTRACT_STR
1080
+ };
1081
+ }
1082
+ };
1083
+ const qq = {
1084
+ a: _EXTRACT_STR[0],
1085
+ b: false ? _EXTRACT_STR[1] : _EXTRACT_STR[2]
1086
+ };
1087
+ console.log(_EXTRACT_STR[3]);
1088
+ let q = fun(_EXTRACT_STR[1]);
1089
+ let a = _EXTRACT_STR[2];
1090
+ const b = _EXTRACT_STR[4] + _EXTRACT_STR[5];
1091
+ const tpl = \`\${_EXTRACT_STR[6]} \${a}\`;
1092
+ const wrapped = \`\${a} \${_EXTRACT_STR[7]} \${b}\`;
1093
+ "
1094
+ `);
1095
+ });
1096
+ it('should apply js str', async () => {
1097
+ const inputContent = `
1098
+ function aaa() {
1099
+ var tt = lynxCoreInject.tt;
1100
+ // for __EXTRACT_STR_FLAG__
1101
+ tt.__sourcemap__release__ = "123";
1102
+ tt.define("app-service.js", function(){
1103
+ __EXTRACT_STR_JS_FLAG__(z=lynxCoreInject.tt._params.updateData._EXTRACT_STR,z);
1104
+ const qq = {
1105
+ a: '123',
1106
+ b: false ? '456' : '789'
1107
+ };
1108
+ function render(){
1109
+ const { abc: z } = this.state
1110
+ console.log(z);
1111
+ console.log('456');
1112
+ }
1113
+ function ffff(z) {
1114
+ console.log(z);
1115
+ return "asdasdasd"
1116
+ }
1117
+ console.log('!@#@#$!!@#!#!3sasdega!!23!#$!@#%%');
1118
+ let q = fun('456');
1119
+ let a = '789';
1120
+ const b = '111' + '000';
1121
+ const tpl = \`Hello \${a}\`;
1122
+ const wrapped = \`\${a} middle \${b}\`;
1123
+ });
1124
+ }`;
1125
+ const result = await transformBundleResult(inputContent, {
1126
+ filename: 'app-service.js',
1127
+ pluginName: 'transformBundleResult',
1128
+ sourcemap: true,
1129
+ extractStr: {
1130
+ strLength: 1,
1131
+ extractedStrArr: ['123', '456', 'asdasdasd'],
1132
+ },
1133
+ });
1134
+ expect(result.code).toMatchInlineSnapshot(`
1135
+ "function aaa() {
1136
+ var tt = lynxCoreInject.tt;
1137
+ // for __EXTRACT_STR_FLAG__
1138
+ tt.__sourcemap__release__ = "123";
1139
+ tt.define("app-service.js", function() {
1140
+ __EXTRACT_STR_JS_FLAG__(z = lynxCoreInject.tt._params.updateData._EXTRACT_STR, z);
1141
+ const qq = {
1142
+ a: '123',
1143
+ b: false ? '456' : '789'
1144
+ };
1145
+ function render() {
1146
+ const { abc: z1 } = this.state;
1147
+ console.log(z1);
1148
+ console.log('456');
1149
+ }
1150
+ function ffff(z1) {
1151
+ console.log(z1);
1152
+ return "asdasdasd";
1153
+ }
1154
+ console.log('!@#@#$!!@#!#!3sasdega!!23!#$!@#%%');
1155
+ let q = fun('456');
1156
+ let a = '789';
1157
+ const b = '111' + '000';
1158
+ const tpl = \`Hello \${a}\`;
1159
+ const wrapped = \`\${a} middle \${b}\`;
1160
+ });
1161
+ }
1162
+ "
1163
+ `);
1164
+ });
1165
+
1166
+ it('should allow C-style type cast in .ts', async () => {
1167
+ const result = await transformReactLynx(`const p = <any>Promise.all([]);`, {
1168
+ pluginName: '',
1169
+ filename: '',
1170
+ sourcemap: false,
1171
+ syntaxConfig: JSON.stringify({
1172
+ syntax: 'typescript',
1173
+ tsx: false,
1174
+ }),
1175
+ cssScope: false,
1176
+ jsx: false,
1177
+ directiveDCE: false,
1178
+ defineDCE: false,
1179
+ shake: false,
1180
+ compat: false,
1181
+ worklet: false,
1182
+ refresh: false,
1183
+ });
1184
+ expect(result.code).toMatchInlineSnapshot(`
1185
+ "Promise.all([]);
1186
+ "
1187
+ `);
1188
+ });
1189
+
1190
+ it('should throw when using TS feature as TSX', async () => {
1191
+ const result = await transformReactLynx(`const p = <any>Promise.all([]);`, {
1192
+ pluginName: '',
1193
+ filename: '',
1194
+ sourcemap: false,
1195
+ syntaxConfig: JSON.stringify({
1196
+ syntax: 'typescript',
1197
+ tsx: true,
1198
+ }),
1199
+ cssScope: false,
1200
+ jsx: false,
1201
+ directiveDCE: false,
1202
+ defineDCE: false,
1203
+ shake: false,
1204
+ compat: false,
1205
+ worklet: false,
1206
+ refresh: false,
1207
+ });
1208
+
1209
+ expect(result.code).toBe('');
1210
+ expect(result.errors).toMatchInlineSnapshot(`
1211
+ [
1212
+ {
1213
+ "location": {
1214
+ "column": 31,
1215
+ "file": "",
1216
+ "length": 0,
1217
+ "line": 1,
1218
+ "lineText": "const p = <any>Promise.all([]);",
1219
+ },
1220
+ "pluginName": "",
1221
+ "text": "Expected '</', got '<eof>'",
1222
+ },
1223
+ ]
1224
+ `);
1225
+ });
1226
+
1227
+ it('should allow tsx-style type cast in .tsx', async () => {
1228
+ const result = await transformReactLynx(`const foo = <T,>(v: T) => v;foo`, {
1229
+ pluginName: '',
1230
+ filename: '',
1231
+ sourcemap: false,
1232
+ syntaxConfig: JSON.stringify({
1233
+ syntax: 'typescript',
1234
+ tsx: true,
1235
+ }),
1236
+ cssScope: false,
1237
+ jsx: false,
1238
+ directiveDCE: false,
1239
+ defineDCE: false,
1240
+ shake: false,
1241
+ compat: false,
1242
+ worklet: false,
1243
+ refresh: false,
1244
+ });
1245
+
1246
+ // Note that the result is not valid TSX code, but it is valid TS code.
1247
+ expect(result.code).toMatchInlineSnapshot(`
1248
+ "const foo = (v)=>v;
1249
+ foo;
1250
+ "
1251
+ `);
1252
+ });
1253
+
1254
+ it('should compile when using with', async () => {
1255
+ const result = await transformReactLynx(`with(x) {y}`, {
1256
+ pluginName: '',
1257
+ filename: '',
1258
+ sourcemap: false,
1259
+ syntaxConfig: JSON.stringify({
1260
+ syntax: 'ecmascript',
1261
+ jsx: false,
1262
+ }),
1263
+ isModule: false,
1264
+ cssScope: false,
1265
+ jsx: false,
1266
+ directiveDCE: false,
1267
+ defineDCE: false,
1268
+ shake: false,
1269
+ compat: false,
1270
+ worklet: {
1271
+ filename: 'filename',
1272
+ target: 'LEPUS',
1273
+ minSdkVersion: '2.14',
1274
+ runtimePkg: '@lynx-js/react',
1275
+ },
1276
+ refresh: false,
1277
+ });
1278
+
1279
+ expect(result.errors.length).toBe(0);
1280
+ });
1281
+ });
1282
+
1283
+ describe('directive dce', () => {
1284
+ it('directive dce warning', async () => {
1285
+ const result = await transformReactLynx(
1286
+ `
1287
+ class X {
1288
+ constructor() {
1289
+ 'use js only';
1290
+ console.log("js only");
1291
+ }
1292
+ get xxx() {
1293
+ 'use js only';
1294
+ return 'js only';
1295
+ }
1296
+ set xxx(v) {
1297
+ 'use js only';
1298
+ }
1299
+ }
1300
+ `,
1301
+ {
1302
+ pluginName: '',
1303
+ filename: '',
1304
+ sourcemap: false,
1305
+ cssScope: false,
1306
+ jsx: false,
1307
+ directiveDCE: {
1308
+ target: 'LEPUS',
1309
+ },
1310
+ defineDCE: false,
1311
+ shake: false,
1312
+ compat: true,
1313
+ worklet: false,
1314
+ refresh: false,
1315
+ },
1316
+ );
1317
+
1318
+ expect(
1319
+ await formatMessages(result.warnings, { kind: 'warning', color: false }),
1320
+ ).toMatchInlineSnapshot(`
1321
+ [
1322
+ "▲ [WARNING] directive inside constructor is not allowed
1323
+
1324
+ :4:4:
1325
+ 4 │ 'use js only';
1326
+ ╵ ~~~~~~~~~~~~~~
1327
+
1328
+ ",
1329
+ "▲ [WARNING] directive inside getter/setter is ignored
1330
+
1331
+ :8:4:
1332
+ 8 │ 'use js only';
1333
+ ╵ ~~~~~~~~~~~~~~
1334
+
1335
+ ",
1336
+ "▲ [WARNING] directive inside getter/setter is ignored
1337
+
1338
+ :12:4:
1339
+ 12 │ 'use js only';
1340
+ ╵ ~~~~~~~~~~~~~~
1341
+
1342
+ ",
1343
+ ]
1344
+ `);
1345
+ });
1346
+ });
1347
+
1348
+ describe('simplifyCtorLikeReactLynx2', () => {
1349
+ it('enable', async () => {
1350
+ const result = await transformReactLynx(
1351
+ `
1352
+ let c = 1;
1353
+ export default class App extends Component {
1354
+ a(){}
1355
+ constructor(props) {
1356
+ super(props);
1357
+ if (!__LEPUS__) {
1358
+ this.a();
1359
+ }
1360
+ this.state = {
1361
+ a: c,
1362
+ }
1363
+ }
1364
+
1365
+ render() {
1366
+ return <view/>;
1367
+ }
1368
+ }
1369
+ `,
1370
+ {
1371
+ pluginName: 'transform',
1372
+ filename: '',
1373
+ sourcemap: false,
1374
+ cssScope: false,
1375
+ jsx: false,
1376
+ directiveDCE: false,
1377
+ defineDCE: false,
1378
+ shake: true,
1379
+ compat: {
1380
+ target: 'LEPUS',
1381
+ componentsPkg: ['@lynx-js/react-components'],
1382
+ oldRuntimePkg: ['@lynx-js/react-runtime'],
1383
+ newRuntimePkg: '@lynx-js/react',
1384
+ additionalComponentAttributes: [],
1385
+ addComponentElement: true,
1386
+ simplifyCtorLikeReactLynx2: true,
1387
+ disableDeprecatedWarning: false,
1388
+ },
1389
+ worklet: false,
1390
+ refresh: false,
1391
+ },
1392
+ );
1393
+
1394
+ expect(result.code).toMatchInlineSnapshot(`
1395
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
1396
+ import * as ReactLynx from "@lynx-js/react";
1397
+ let c = 1;
1398
+ const __snapshot_da39a_b7447_1 = "__snapshot_da39a_b7447_1";
1399
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_b7447_1] = (__snapshot_da39a_b7447_1)=>ReactLynx.createSnapshot(__snapshot_da39a_b7447_1, function() {
1400
+ const pageId = ReactLynx.__pageId;
1401
+ const el = __CreateView(pageId);
1402
+ return [
1403
+ el
1404
+ ];
1405
+ }, null, null, undefined, globDynamicComponentEntry, null, true);
1406
+ export default class App extends Component {
1407
+ a() {}
1408
+ render() {
1409
+ return /*#__PURE__*/ _jsx(__snapshot_da39a_b7447_1, {});
1410
+ }
1411
+ state = ((()=>{
1412
+ if (!__LEPUS__) this.a();
1413
+ })(), {
1414
+ a: c
1415
+ });
1416
+ }
1417
+ "
1418
+ `);
1419
+ });
1420
+ });
1421
+
1422
+ describe('dynamic import', () => {
1423
+ it('lazy import', async () => {
1424
+ const result = await transformReactLynx(`await import("https://www/a.js", { with: { type: "component" } });`, {
1425
+ pluginName: '',
1426
+ filename: '',
1427
+ sourcemap: false,
1428
+ parserConfig: {
1429
+ tsx: true,
1430
+ },
1431
+ cssScope: false,
1432
+ jsx: false,
1433
+ directiveDCE: false,
1434
+ defineDCE: false,
1435
+ shake: false,
1436
+ compat: false,
1437
+ worklet: false,
1438
+ refresh: false,
1439
+ });
1440
+ expect(result.code).toMatchInlineSnapshot(`
1441
+ "import "@lynx-js/react/experimental/lazy/import";
1442
+ import { __dynamicImport } from "@lynx-js/react/internal";
1443
+ await __dynamicImport("https://www/a.js", {
1444
+ with: {
1445
+ type: "component"
1446
+ }
1447
+ });
1448
+ "
1449
+ `);
1450
+ });
1451
+ it('inline import', async () => {
1452
+ const result = await transformReactLynx(`await import(/*webpackChunkName: "./index.js-test"*/"./index.js");`, {
1453
+ pluginName: '',
1454
+ filename: '',
1455
+ sourcemap: false,
1456
+ parserConfig: {
1457
+ tsx: true,
1458
+ },
1459
+ cssScope: false,
1460
+ jsx: false,
1461
+ directiveDCE: false,
1462
+ defineDCE: false,
1463
+ shake: false,
1464
+ compat: false,
1465
+ worklet: false,
1466
+ refresh: false,
1467
+ });
1468
+ expect(result.code).toMatchInlineSnapshot(`
1469
+ "import 'data:text/javascript;charset=utf-8,import { loadLazyBundle } from "@lynx-js/react/internal";lynx.loadLazyBundle = loadLazyBundle;';
1470
+ await import(/*webpackChunkName: "./index.js-test"*/ "./index.js");
1471
+ "
1472
+ `);
1473
+ });
1474
+ it('badcase', async () => {
1475
+ const result = await transformReactLynx(
1476
+ `\
1477
+ (async function () {
1478
+ await import(0);
1479
+ await import(0, 0);
1480
+ await import("./index.js", { with: { typo: "component" } });
1481
+ await import("https://www/a.js", { with: { typo: "component" } });
1482
+ await import(url, { with: { typo: "component" } });
1483
+ })();
1484
+ `,
1485
+ {
1486
+ pluginName: '',
1487
+ filename: '',
1488
+ sourcemap: false,
1489
+ parserConfig: {
1490
+ tsx: true,
1491
+ },
1492
+ cssScope: false,
1493
+ jsx: false,
1494
+ directiveDCE: false,
1495
+ defineDCE: false,
1496
+ shake: false,
1497
+ compat: false,
1498
+ worklet: false,
1499
+ refresh: false,
1500
+ },
1501
+ );
1502
+
1503
+ expect(result.code).toMatchInlineSnapshot(`
1504
+ "import "@lynx-js/react/experimental/lazy/import";
1505
+ import { __dynamicImport } from "@lynx-js/react/internal";
1506
+ (async function() {
1507
+ await import(0);
1508
+ await import(0, 0);
1509
+ await import("./index.js", {
1510
+ with: {
1511
+ typo: "component"
1512
+ }
1513
+ });
1514
+ await __dynamicImport("https://www/a.js", {
1515
+ with: {
1516
+ typo: "component"
1517
+ }
1518
+ });
1519
+ await __dynamicImport(url, {
1520
+ with: {
1521
+ typo: "component"
1522
+ }
1523
+ });
1524
+ })();
1525
+ "
1526
+ `);
1527
+ // esbuild uses different icon on Windows
1528
+ // See https://github.com/evanw/esbuild/blob/f4159a7b823cd5fe2217da2c30e8873d2f319667/internal/logger/logger.go#L82
1529
+ const errorIcon = process.platform === 'win32' ? 'X' : '✘';
1530
+ expect(await formatMessages(result.errors, { kind: 'error', color: false }))
1531
+ .toMatchInlineSnapshot(`
1532
+ [
1533
+ "${errorIcon} [ERROR] \`import(...)\` call with non-string literal module id is not allowed
1534
+
1535
+ :2:8:
1536
+ 2 │ await import(0);
1537
+ ╵ ~~~~~~~~~
1538
+
1539
+ ",
1540
+ "${errorIcon} [ERROR] \`import(...)\` call with non-string literal module id is not allowed
1541
+
1542
+ :3:8:
1543
+ 3 │ await import(0, 0);
1544
+ ╵ ~~~~~~~~~~~~
1545
+
1546
+ ",
1547
+ "${errorIcon} [ERROR] \`import("...", ...)\` with invalid options is not allowed
1548
+
1549
+ :4:8:
1550
+ 4 │ await import("./index.js", { with: { typo: "component" } });
1551
+ ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1552
+
1553
+ ",
1554
+ ]
1555
+ `);
1556
+ });
1557
+ });
1558
+
1559
+ describe('define dce', () => {
1560
+ it('define dce should work - basic', async () => {
1561
+ const result = await transformReactLynx(
1562
+ `
1563
+ function X() {
1564
+ if (__LEPUS__) {
1565
+ return;
1566
+ }
1567
+ console.log("xxx");
1568
+ }
1569
+
1570
+ X();
1571
+ `,
1572
+ {
1573
+ pluginName: '',
1574
+ filename: '',
1575
+ sourcemap: false,
1576
+ cssScope: false,
1577
+ jsx: false,
1578
+ directiveDCE: false,
1579
+ defineDCE: {
1580
+ define: {
1581
+ __LEPUS__: 'true',
1582
+ __JS__: 'false',
1583
+ },
1584
+ },
1585
+ shake: false,
1586
+ compat: true,
1587
+ worklet: false,
1588
+ refresh: false,
1589
+ },
1590
+ );
1591
+
1592
+ expect(
1593
+ result.code,
1594
+ ).toMatchInlineSnapshot(`
1595
+ "function X() {
1596
+ return;
1597
+ }
1598
+ X();
1599
+ "
1600
+ `);
1601
+ });
1602
+
1603
+ it('define dce should work - with && ||', async () => {
1604
+ const result = await transformReactLynx(
1605
+ `
1606
+ function X1() {
1607
+ if (__LEPUS__ && __JS__) {
1608
+ return;
1609
+ }
1610
+ console.log("xxx");
1611
+ }
1612
+ function X2() {
1613
+ if (__LEPUS__ || __JS__) {
1614
+ return;
1615
+ }
1616
+ console.log("xxx");
1617
+ }
1618
+ function X3() {
1619
+ if (__LEPUS__ && 0) {
1620
+ return;
1621
+ }
1622
+ console.log("xxx");
1623
+ }
1624
+ function X4() {
1625
+ if (__LEPUS__ && 1) {
1626
+ return;
1627
+ }
1628
+ console.log("xxx");
1629
+ }
1630
+ function X5() {
1631
+ if (__LEPUS__ || 1) {
1632
+ return;
1633
+ }
1634
+ console.log("xxx");
1635
+ }
1636
+
1637
+
1638
+ X1();
1639
+ X2();
1640
+ X3();
1641
+ X4();
1642
+ X5();
1643
+ `,
1644
+ {
1645
+ pluginName: '',
1646
+ filename: '',
1647
+ sourcemap: false,
1648
+ cssScope: false,
1649
+ jsx: false,
1650
+ directiveDCE: false,
1651
+ defineDCE: {
1652
+ define: {
1653
+ __LEPUS__: 'true',
1654
+ __JS__: 'false',
1655
+ },
1656
+ },
1657
+ shake: false,
1658
+ compat: true,
1659
+ worklet: false,
1660
+ refresh: false,
1661
+ },
1662
+ );
1663
+
1664
+ expect(
1665
+ result.code,
1666
+ ).toMatchInlineSnapshot(`
1667
+ "function X1() {
1668
+ console.log("xxx");
1669
+ }
1670
+ function X2() {
1671
+ return;
1672
+ }
1673
+ function X3() {
1674
+ console.log("xxx");
1675
+ }
1676
+ function X4() {
1677
+ return;
1678
+ }
1679
+ function X5() {
1680
+ return;
1681
+ }
1682
+ X1();
1683
+ X2();
1684
+ X3();
1685
+ X4();
1686
+ X5();
1687
+ "
1688
+ `);
1689
+ });
1690
+
1691
+ it('define dce should work - with import', async () => {
1692
+ const result = await transformReactLynx(
1693
+ `
1694
+ import { x } from "./a"
1695
+ function X() {
1696
+ if (__LEPUS__ || 0) {
1697
+ return;
1698
+ }
1699
+ x();
1700
+ }
1701
+
1702
+ X();
1703
+ `,
1704
+ {
1705
+ pluginName: '',
1706
+ filename: '',
1707
+ sourcemap: false,
1708
+ cssScope: false,
1709
+ jsx: false,
1710
+ directiveDCE: false,
1711
+ defineDCE: {
1712
+ define: {
1713
+ __LEPUS__: 'true',
1714
+ __JS__: 'false',
1715
+ },
1716
+ },
1717
+ shake: false,
1718
+ compat: true,
1719
+ worklet: false,
1720
+ refresh: false,
1721
+ },
1722
+ );
1723
+
1724
+ expect(
1725
+ result.code,
1726
+ ).toMatchInlineSnapshot(`
1727
+ "function X() {
1728
+ return;
1729
+ }
1730
+ X();
1731
+ "
1732
+ `);
1733
+ });
1734
+
1735
+ it('define dce should work - with typeof', async () => {
1736
+ const result = await transformReactLynx(
1737
+ `
1738
+ function X() {
1739
+ console.log(typeof __LEPUS__)
1740
+ console.log(typeof __NON_EXISTS__)
1741
+ if (typeof __LEPUS__ === "boolean") {
1742
+ console.log("xxx")
1743
+ } else {
1744
+ console.log("yyy")
1745
+ }
1746
+ }
1747
+
1748
+ X();
1749
+ `,
1750
+ {
1751
+ pluginName: '',
1752
+ filename: '',
1753
+ sourcemap: false,
1754
+ cssScope: false,
1755
+ jsx: false,
1756
+ directiveDCE: false,
1757
+ defineDCE: {
1758
+ define: {
1759
+ __LEPUS__: 'true',
1760
+ __JS__: 'false',
1761
+ },
1762
+ },
1763
+ shake: false,
1764
+ compat: true,
1765
+ worklet: false,
1766
+ refresh: false,
1767
+ },
1768
+ );
1769
+
1770
+ expect(
1771
+ result.code,
1772
+ ).toMatchInlineSnapshot(`
1773
+ "function X() {
1774
+ console.log("boolean");
1775
+ console.log(typeof __NON_EXISTS__);
1776
+ console.log("xxx");
1777
+ }
1778
+ X();
1779
+ "
1780
+ `);
1781
+ });
1782
+
1783
+ it('define dce should work - should recursive', async () => {
1784
+ const result = await transformReactLynx(
1785
+ `
1786
+ function X() {
1787
+ console.log(typeof __LEPUS__)
1788
+ console.log(typeof __NON_EXISTS__)
1789
+ console.log(typeof __NON_EXISTS_2__)
1790
+ }
1791
+
1792
+ X();
1793
+ `,
1794
+ {
1795
+ pluginName: '',
1796
+ filename: '',
1797
+ sourcemap: false,
1798
+ cssScope: false,
1799
+ jsx: false,
1800
+ directiveDCE: false,
1801
+ defineDCE: {
1802
+ define: {
1803
+ __LEPUS__: 'true',
1804
+ __NON_EXISTS__: '__LEPUS__',
1805
+ __NON_EXISTS_2__: '__NON_EXISTS__',
1806
+ },
1807
+ },
1808
+ shake: false,
1809
+ compat: true,
1810
+ worklet: false,
1811
+ refresh: false,
1812
+ },
1813
+ );
1814
+
1815
+ expect(
1816
+ result.code,
1817
+ ).toMatchInlineSnapshot(`
1818
+ "function X() {
1819
+ console.log("boolean");
1820
+ console.log("boolean");
1821
+ console.log("boolean");
1822
+ }
1823
+ X();
1824
+ "
1825
+ `);
1826
+ });
1827
+
1828
+ it('define dce should work - shorthand object property', async () => {
1829
+ const result = await transformReactLynx(
1830
+ `
1831
+ function X() {
1832
+ return {
1833
+ __LEPUS__
1834
+ }
1835
+ }
1836
+
1837
+ X();
1838
+ `,
1839
+ {
1840
+ pluginName: '',
1841
+ filename: '',
1842
+ sourcemap: false,
1843
+ cssScope: false,
1844
+ jsx: false,
1845
+ directiveDCE: false,
1846
+ defineDCE: {
1847
+ define: {
1848
+ __LEPUS__: 'true',
1849
+ },
1850
+ },
1851
+ shake: false,
1852
+ compat: true,
1853
+ worklet: false,
1854
+ refresh: false,
1855
+ },
1856
+ );
1857
+
1858
+ expect(
1859
+ result.code,
1860
+ ).toMatchInlineSnapshot(`
1861
+ "function X() {
1862
+ return {
1863
+ __LEPUS__: true
1864
+ };
1865
+ }
1866
+ X();
1867
+ "
1868
+ `);
1869
+ });
1870
+
1871
+ it('define dce should work - with shake', async () => {
1872
+ const result = await transformReactLynx(
1873
+ `
1874
+ class X extends Component {
1875
+ constructor() {
1876
+ if (__JS__) {
1877
+ this.init();
1878
+ }
1879
+ }
1880
+ componentDidMount() {
1881
+ this.init();
1882
+ }
1883
+ init() {
1884
+ console.log("should be shake")
1885
+ }
1886
+ render() {
1887
+ return <view/>
1888
+ }
1889
+ }
1890
+ <X/>;
1891
+ `,
1892
+ {
1893
+ pluginName: '',
1894
+ filename: '',
1895
+ sourcemap: false,
1896
+ cssScope: false,
1897
+ jsx: false,
1898
+ directiveDCE: false,
1899
+ defineDCE: {
1900
+ define: {
1901
+ __LEPUS__: 'true',
1902
+ __JS__: 'false',
1903
+ },
1904
+ },
1905
+ shake: true,
1906
+ compat: true,
1907
+ worklet: false,
1908
+ refresh: false,
1909
+ },
1910
+ );
1911
+
1912
+ expect(
1913
+ result.code,
1914
+ ).toMatchInlineSnapshot(`
1915
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
1916
+ import * as ReactLynx from "@lynx-js/react";
1917
+ const __snapshot_da39a_e2935_1 = "__snapshot_da39a_e2935_1";
1918
+ ReactLynx.snapshotCreatorMap[__snapshot_da39a_e2935_1] = (__snapshot_da39a_e2935_1)=>ReactLynx.createSnapshot(__snapshot_da39a_e2935_1, function() {
1919
+ const pageId = ReactLynx.__pageId;
1920
+ const el = __CreateView(pageId);
1921
+ return [
1922
+ el
1923
+ ];
1924
+ }, null, null, undefined, globDynamicComponentEntry, null, true);
1925
+ class X extends Component {
1926
+ constructor(){}
1927
+ render() {
1928
+ return /*#__PURE__*/ _jsx(__snapshot_da39a_e2935_1, {});
1929
+ }
1930
+ }
1931
+ /*#__PURE__*/ _jsx(X, {});
1932
+ "
1933
+ `);
1934
+ });
1935
+ });
1936
+
1937
+ describe('worklet', () => {
1938
+ const lepusWorkletOptions = {
1939
+ pluginName: '',
1940
+ filename: '',
1941
+ sourcemap: false,
1942
+ cssScope: false,
1943
+ jsx: false,
1944
+ directiveDCE: true,
1945
+ defineDCE: {
1946
+ define: {
1947
+ __LEPUS__: 'true',
1948
+ __JS__: 'false',
1949
+ },
1950
+ },
1951
+ shake: false,
1952
+ compat: true,
1953
+ refresh: false,
1954
+ worklet: {
1955
+ target: 'LEPUS',
1956
+ filename: '',
1957
+ runtimePkg: '@lynx-js/react',
1958
+ },
1959
+ };
1960
+
1961
+ it('should error on unsupported runtime import attribute', async () => {
1962
+ const result = await transformReactLynx(
1963
+ `\
1964
+ import { foo } from "./shared.js" with { runtime: "invalid" };
1965
+ export function bar() {
1966
+ "main thread";
1967
+ foo();
1968
+ }
1969
+ `,
1970
+ {
1971
+ pluginName: '',
1972
+ filename: '',
1973
+ sourcemap: false,
1974
+ cssScope: false,
1975
+ jsx: false,
1976
+ directiveDCE: true,
1977
+ defineDCE: {
1978
+ define: {
1979
+ __LEPUS__: 'true',
1980
+ __JS__: 'false',
1981
+ },
1982
+ },
1983
+ shake: false,
1984
+ compat: true,
1985
+ refresh: false,
1986
+ worklet: {
1987
+ target: 'LEPUS',
1988
+ filename: '',
1989
+ runtimePkg: '@lynx-js/react',
1990
+ },
1991
+ },
1992
+ );
1993
+
1994
+ expect(result.errors).toHaveLength(1);
1995
+ expect(result.errors[0].text).toBe(
1996
+ 'Invalid runtime value. Only \'shared\' is supported.',
1997
+ );
1998
+ });
1999
+
2000
+ it('should error on non-string runtime import attribute', async () => {
2001
+ const result = await transformReactLynx(
2002
+ `\
2003
+ import { foo } from "./shared.js" with { runtime: 123 };
2004
+ export function bar() {
2005
+ "main thread";
2006
+ foo();
2007
+ }
2008
+ `,
2009
+ {
2010
+ pluginName: '',
2011
+ filename: '',
2012
+ sourcemap: false,
2013
+ cssScope: false,
2014
+ jsx: false,
2015
+ directiveDCE: true,
2016
+ defineDCE: {
2017
+ define: {
2018
+ __LEPUS__: 'true',
2019
+ __JS__: 'false',
2020
+ },
2021
+ },
2022
+ shake: false,
2023
+ compat: true,
2024
+ refresh: false,
2025
+ worklet: {
2026
+ target: 'LEPUS',
2027
+ filename: '',
2028
+ runtimePkg: '@lynx-js/react',
2029
+ },
2030
+ },
2031
+ );
2032
+
2033
+ expect(result.errors).toHaveLength(1);
2034
+ expect(result.errors[0].text).toBe(
2035
+ 'Invalid runtime value. Only \'shared\' is supported.',
2036
+ );
2037
+ });
2038
+
2039
+ it('should error on non-string \'runtime\' key runtime import attribute', async () => {
2040
+ const result = await transformReactLynx(
2041
+ `\
2042
+ import { foo } from "./shared.js" with { 'runtime': 123 };
2043
+ export function bar() {
2044
+ "main thread";
2045
+ foo();
2046
+ }
2047
+ `,
2048
+ {
2049
+ pluginName: '',
2050
+ filename: '',
2051
+ sourcemap: false,
2052
+ cssScope: false,
2053
+ jsx: false,
2054
+ directiveDCE: true,
2055
+ defineDCE: {
2056
+ define: {
2057
+ __LEPUS__: 'true',
2058
+ __JS__: 'false',
2059
+ },
2060
+ },
2061
+ shake: false,
2062
+ compat: true,
2063
+ refresh: false,
2064
+ worklet: {
2065
+ target: 'LEPUS',
2066
+ filename: '',
2067
+ runtimePkg: '@lynx-js/react',
2068
+ },
2069
+ },
2070
+ );
2071
+
2072
+ expect(result.errors).toHaveLength(1);
2073
+ expect(result.errors[0].text).toBe(
2074
+ 'Invalid runtime value. Only \'shared\' is supported.',
2075
+ );
2076
+ });
2077
+
2078
+ it('should not inject runtime when no worklet exists', async () => {
2079
+ const { code } = await transformReactLynx(
2080
+ `\
2081
+ export function getCurrentDelta(event) {
2082
+ return foo.bar.baz;
2083
+ }
2084
+ `,
2085
+ lepusWorkletOptions,
2086
+ );
2087
+
2088
+ expect(code).not.toContain('loadWorkletRuntime');
2089
+ expect(code).not.toContain('registerWorkletInternal');
2090
+ expect(code).not.toContain('_wkltId');
2091
+ });
2092
+
2093
+ for (const target of ['LEPUS', 'JS', 'MIXED']) {
2094
+ it('member expression', async () => {
2095
+ const { code } = await transformReactLynx(
2096
+ `\
2097
+ export function getCurrentDelta(event) {
2098
+ "main thread";
2099
+ return foo.bar.baz;
2100
+ }
2101
+ `,
2102
+ {
2103
+ pluginName: '',
2104
+ filename: '',
2105
+ sourcemap: false,
2106
+ cssScope: false,
2107
+ jsx: false,
2108
+ directiveDCE: true,
2109
+ defineDCE: {
2110
+ define: {
2111
+ __LEPUS__: 'true',
2112
+ __JS__: 'false',
2113
+ },
2114
+ },
2115
+ shake: false,
2116
+ compat: true,
2117
+ refresh: false,
2118
+ worklet: {
2119
+ target,
2120
+ filename: '',
2121
+ runtimePkg: '@lynx-js/react',
2122
+ },
2123
+ },
2124
+ );
2125
+
2126
+ if (target === 'LEPUS') {
2127
+ expect(code).toMatchInlineSnapshot(`
2128
+ "import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2129
+ var loadWorkletRuntime = __loadWorkletRuntime;
2130
+ export let getCurrentDelta = {
2131
+ _c: {
2132
+ foo: {
2133
+ bar: {
2134
+ baz: foo.bar.baz
2135
+ }
2136
+ }
2137
+ },
2138
+ _wkltId: "da39:75a1b:1"
2139
+ };
2140
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
2141
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:75a1b:1", function(event) {
2142
+ const getCurrentDelta = lynxWorkletImpl._workletMap["da39:75a1b:1"].bind(this);
2143
+ let { foo } = this["_c"];
2144
+ "main thread";
2145
+ return foo.bar.baz;
2146
+ });
2147
+ "
2148
+ `);
2149
+ expect(code).toContain('loadWorkletRuntime');
2150
+ expect(code).toContain('registerWorkletInternal("main-thread"');
2151
+ } else if (target === 'JS') {
2152
+ expect(code).toMatchInlineSnapshot(`
2153
+ "export let getCurrentDelta = {
2154
+ _c: {
2155
+ foo: {
2156
+ bar: {
2157
+ baz: foo.bar.baz
2158
+ }
2159
+ }
2160
+ },
2161
+ _wkltId: "da39:75a1b:1"
2162
+ };
2163
+ "
2164
+ `);
2165
+ expect(code).not.toContain('loadWorkletRuntime');
2166
+ expect(code).not.toContain('registerWorkletInternal');
2167
+ } else if (target === 'MIXED') {
2168
+ expect(code).toMatchInlineSnapshot(`
2169
+ "import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2170
+ var loadWorkletRuntime = __loadWorkletRuntime;
2171
+ export let getCurrentDelta = {
2172
+ _c: {
2173
+ foo: {
2174
+ bar: {
2175
+ baz: foo.bar.baz
2176
+ }
2177
+ }
2178
+ },
2179
+ _wkltId: "da39:75a1b:1"
2180
+ };
2181
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
2182
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:75a1b:1", function(event) {
2183
+ const getCurrentDelta = lynxWorkletImpl._workletMap["da39:75a1b:1"].bind(this);
2184
+ let { foo } = this["_c"];
2185
+ "main thread";
2186
+ return foo.bar.baz;
2187
+ });
2188
+ "
2189
+ `);
2190
+ expect(code).toContain('loadWorkletRuntime');
2191
+ expect(code).toContain('registerWorkletInternal("main-thread"');
2192
+ }
2193
+ });
2194
+ }
2195
+
2196
+ it('member expression with multiple times', async () => {
2197
+ const { code } = await transformReactLynx(
2198
+ `\
2199
+ export function foo(event) {
2200
+ "main thread";
2201
+ return bar.baz['qux'] || bar.qux['baz'] || qux.bar.baz;
2202
+ }
2203
+ `,
2204
+ {
2205
+ pluginName: '',
2206
+ filename: '',
2207
+ sourcemap: false,
2208
+ cssScope: false,
2209
+ jsx: false,
2210
+ directiveDCE: true,
2211
+ defineDCE: {
2212
+ define: {
2213
+ __LEPUS__: 'true',
2214
+ __JS__: 'false',
2215
+ },
2216
+ },
2217
+ shake: false,
2218
+ compat: true,
2219
+ refresh: false,
2220
+ worklet: {
2221
+ target: 'LEPUS',
2222
+ filename: '',
2223
+ runtimePkg: '@lynx-js/react',
2224
+ },
2225
+ },
2226
+ );
2227
+
2228
+ expect(code).toMatchInlineSnapshot(`
2229
+ "import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2230
+ var loadWorkletRuntime = __loadWorkletRuntime;
2231
+ export let foo = {
2232
+ _c: {
2233
+ bar: {
2234
+ baz: {
2235
+ 'qux': bar.baz['qux']
2236
+ },
2237
+ qux: {
2238
+ 'baz': bar.qux['baz']
2239
+ }
2240
+ },
2241
+ qux: {
2242
+ bar: {
2243
+ baz: qux.bar.baz
2244
+ }
2245
+ }
2246
+ },
2247
+ _wkltId: "da39:64631:1"
2248
+ };
2249
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
2250
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:64631:1", function(event) {
2251
+ const foo = lynxWorkletImpl._workletMap["da39:64631:1"].bind(this);
2252
+ let { bar, qux } = this["_c"];
2253
+ "main thread";
2254
+ return bar.baz['qux'] || bar.qux['baz'] || qux.bar.baz;
2255
+ });
2256
+ "
2257
+ `);
2258
+ expect((code.match(/registerWorkletInternal/g) ?? []).length).toBe(1);
2259
+ expect((code.match(/const __workletRuntimeLoaded = loadWorkletRuntime/g) ?? []).length).toBe(1);
2260
+ });
2261
+
2262
+ it('nested', async () => {
2263
+ const { code } = await transformReactLynx(
2264
+ `\
2265
+ function foo() {
2266
+ "main thread";
2267
+ return null;
2268
+ }
2269
+ function bar() {
2270
+ "main thread";
2271
+ foo()
2272
+ }
2273
+ console.log(bar)
2274
+ `,
2275
+ {
2276
+ pluginName: '',
2277
+ filename: '',
2278
+ sourcemap: false,
2279
+ cssScope: false,
2280
+ jsx: false,
2281
+ directiveDCE: true,
2282
+ defineDCE: {
2283
+ define: {
2284
+ __LEPUS__: 'true',
2285
+ __JS__: 'false',
2286
+ },
2287
+ },
2288
+ shake: false,
2289
+ compat: true,
2290
+ refresh: false,
2291
+ worklet: {
2292
+ target: 'LEPUS',
2293
+ filename: '',
2294
+ runtimePkg: '@lynx-js/react',
2295
+ },
2296
+ },
2297
+ );
2298
+
2299
+ expect(code).toMatchInlineSnapshot(`
2300
+ "import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2301
+ var loadWorkletRuntime = __loadWorkletRuntime;
2302
+ let foo = {
2303
+ _wkltId: "da39:80ef4:1"
2304
+ };
2305
+ let bar = {
2306
+ _c: {
2307
+ foo
2308
+ },
2309
+ _wkltId: "da39:80ef4:2"
2310
+ };
2311
+ console.log(bar);
2312
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
2313
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:80ef4:1", function() {
2314
+ const foo = lynxWorkletImpl._workletMap["da39:80ef4:1"].bind(this);
2315
+ "main thread";
2316
+ return null;
2317
+ });
2318
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:80ef4:2", function() {
2319
+ const bar = lynxWorkletImpl._workletMap["da39:80ef4:2"].bind(this);
2320
+ let { foo } = this["_c"];
2321
+ "main thread";
2322
+ foo();
2323
+ });
2324
+ "
2325
+ `);
2326
+ expect((code.match(/registerWorkletInternal/g) ?? []).length).toBe(2);
2327
+ expect((code.match(/const __workletRuntimeLoaded = loadWorkletRuntime/g) ?? []).length).toBe(1);
2328
+ });
2329
+
2330
+ it('use multiple times', async () => {
2331
+ const { code } = await transformReactLynx(
2332
+ `\
2333
+ function getCurrentDelta(event) {
2334
+ "main thread";
2335
+ if (foo(a)) {
2336
+ if (foo(b)) {}
2337
+ }
2338
+ return null;
2339
+ }
2340
+ `,
2341
+ {
2342
+ pluginName: '',
2343
+ filename: '',
2344
+ sourcemap: false,
2345
+ cssScope: false,
2346
+ jsx: false,
2347
+ directiveDCE: true,
2348
+ defineDCE: {
2349
+ define: {
2350
+ __LEPUS__: 'true',
2351
+ __JS__: 'false',
2352
+ },
2353
+ },
2354
+ shake: false,
2355
+ compat: true,
2356
+ refresh: false,
2357
+ worklet: {
2358
+ target: 'LEPUS',
2359
+ filename: '',
2360
+ runtimePkg: '@lynx-js/react',
2361
+ },
2362
+ },
2363
+ );
2364
+
2365
+ expect(code).toMatchInlineSnapshot(`
2366
+ "import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2367
+ var loadWorkletRuntime = __loadWorkletRuntime;
2368
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
2369
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "da39:059d0:1", function(event) {
2370
+ lynxWorkletImpl._workletMap["da39:059d0:1"].bind(this);
2371
+ let { foo, a, b } = this["_c"];
2372
+ "main thread";
2373
+ if (foo(a)) foo(b);
2374
+ return null;
2375
+ });
2376
+ "
2377
+ `);
2378
+ expect((code.match(/registerWorkletInternal/g) ?? []).length).toBe(1);
2379
+ expect((code.match(/const __workletRuntimeLoaded = loadWorkletRuntime/g) ?? []).length).toBe(1);
2380
+ });
2381
+
2382
+ it('should keep webpack runtime variables', async () => {
2383
+ const inputContent = `
2384
+ __webpack_public_path__="a";
2385
+ __webpack_require__.p="b";
2386
+ __webpack_test__="a";
2387
+ import { Component } from "@lynx-js/react-runtime";
2388
+ export class A extends Component {}
2389
+ `;
2390
+ const { code } = await transformReactLynx(inputContent);
2391
+ expect(code).toMatchInlineSnapshot(`
2392
+ "__webpack_public_path__ = "a";
2393
+ __webpack_require__.p = "b";
2394
+ "a";
2395
+ import { Component } from "@lynx-js/react-runtime";
2396
+ export class A extends Component {
2397
+ }
2398
+ "
2399
+ `);
2400
+ });
2401
+ });
2402
+
2403
+ describe('legacySlot', () => {
2404
+ // eslint-disable-next-line unicorn/consistent-function-scoping
2405
+ const options = (legacySlot) => ({
2406
+ mode: 'test',
2407
+ pluginName: '',
2408
+ filename: '',
2409
+ sourcemap: false,
2410
+ cssScope: false,
2411
+ snapshot: {
2412
+ preserveJsx: false,
2413
+ runtimePkg: '@lynx-js/react',
2414
+ jsxImportSource: '@lynx-js/react',
2415
+ filename: 'test',
2416
+ target: 'MIXED',
2417
+ legacySlot,
2418
+ },
2419
+ jsx: true,
2420
+ directiveDCE: false,
2421
+ defineDCE: false,
2422
+ shake: false,
2423
+ compat: false,
2424
+ worklet: false,
2425
+ refresh: false,
2426
+ });
2427
+
2428
+ it('should compile dynamic children as children + wrapper when enabled', async () => {
2429
+ const inputContent = 'const jsx = <view><text>{content}</text></view>;';
2430
+
2431
+ const result = await transformReactLynx(inputContent, options(true));
2432
+ expect(result.errors).toEqual([]);
2433
+ expect(result.code).toContain('__DynamicPartChildren');
2434
+ expect(result.code).not.toContain('SlotV2');
2435
+ expect(result.code).toMatchInlineSnapshot(`
2436
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2437
+ import * as ReactLynx from "@lynx-js/react";
2438
+ const __snapshot_a94a8_test_1 = "__snapshot_a94a8_test_1";
2439
+ ReactLynx.snapshotCreatorMap[__snapshot_a94a8_test_1] = (__snapshot_a94a8_test_1)=>ReactLynx.createSnapshot(__snapshot_a94a8_test_1, function() {
2440
+ const pageId = ReactLynx.__pageId;
2441
+ const el = __CreateView(pageId);
2442
+ const el1 = __CreateText(pageId);
2443
+ __AppendElement(el, el1);
2444
+ return [
2445
+ el,
2446
+ el1
2447
+ ];
2448
+ }, null, [
2449
+ [
2450
+ ReactLynx.__DynamicPartChildren,
2451
+ 1
2452
+ ]
2453
+ ], undefined, globDynamicComponentEntry, null, true);
2454
+ /*#__PURE__*/ _jsx(__snapshot_a94a8_test_1, {
2455
+ children: content
2456
+ });
2457
+ "
2458
+ `);
2459
+ });
2460
+
2461
+ it('should keep the default SlotV2 codegen when disabled', async () => {
2462
+ const inputContent = 'const jsx = <view><text>{content}</text></view>;';
2463
+
2464
+ const result = await transformReactLynx(inputContent, options(false));
2465
+ expect(result.errors).toEqual([]);
2466
+ expect(result.code).toContain('__DynamicPartSlotV2');
2467
+ expect(result.code).not.toContain('__DynamicPartChildren');
2468
+ expect(result.code).toMatchInlineSnapshot(`
2469
+ "import { jsx as _jsx } from "@lynx-js/react/jsx-runtime";
2470
+ import * as ReactLynx from "@lynx-js/react";
2471
+ const __snapshot_a94a8_test_1 = "__snapshot_a94a8_test_1";
2472
+ ReactLynx.snapshotCreatorMap[__snapshot_a94a8_test_1] = (__snapshot_a94a8_test_1)=>ReactLynx.createSnapshot(__snapshot_a94a8_test_1, function() {
2473
+ const pageId = ReactLynx.__pageId;
2474
+ const el = __CreateView(pageId);
2475
+ const el1 = __CreateText(pageId);
2476
+ __AppendElement(el, el1);
2477
+ return [
2478
+ el,
2479
+ el1
2480
+ ];
2481
+ }, null, [
2482
+ [
2483
+ ReactLynx.__DynamicPartSlotV2,
2484
+ 1
2485
+ ]
2486
+ ], undefined, globDynamicComponentEntry, null, true);
2487
+ /*#__PURE__*/ _jsx(__snapshot_a94a8_test_1, {
2488
+ $0: content
2489
+ });
2490
+ "
2491
+ `);
2492
+ });
2493
+ });