@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,2368 @@
1
+ /*
2
+ // Copyright 2024 The Lynx Authors. All rights reserved.
3
+ // Licensed under the Apache License Version 2.0 that can be found in the
4
+ // LICENSE file in the root directory of this source tree.
5
+ */
6
+ import { render } from 'preact';
7
+ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
8
+
9
+ import { RefProxy, runDelayedUiOps, shouldDelayUiOps } from '../../src/snapshot/lifecycle/ref/delay';
10
+
11
+ import { Component, createRef, useState } from '../../src/index';
12
+ import { clearCommitTaskId, replaceCommitHook } from '../../src/snapshot/lifecycle/patch/commit';
13
+ import { injectUpdateMainThread } from '../../src/snapshot/lifecycle/patch/updateMainThread';
14
+ import { __pendingListUpdates } from '../../src/snapshot/list/pendingListUpdates';
15
+ import { __root } from '../../src/root';
16
+ import { setupPage } from '../../src/snapshot';
17
+ import { globalEnvManager } from './utils/envManager';
18
+ import { elementTree, waitSchedule } from './utils/nativeMethod';
19
+
20
+ beforeAll(() => {
21
+ setupPage(__CreatePage('0', 0));
22
+
23
+ replaceCommitHook();
24
+ injectUpdateMainThread();
25
+ });
26
+
27
+ beforeEach(() => {
28
+ globalEnvManager.resetEnv();
29
+ clearCommitTaskId();
30
+ });
31
+
32
+ afterEach(() => {
33
+ vi.restoreAllMocks();
34
+
35
+ globalEnvManager.resetEnv();
36
+ elementTree.clear();
37
+ __pendingListUpdates.clear();
38
+ });
39
+
40
+ describe('component ref', () => {
41
+ it('basic', async function() {
42
+ const ref1 = vi.fn();
43
+ const ref2 = createRef();
44
+
45
+ class Child extends Component {
46
+ x = 'x';
47
+ render() {
48
+ return <view />;
49
+ }
50
+ }
51
+
52
+ class Comp extends Component {
53
+ x = 'x';
54
+ render() {
55
+ return this.props.show && (
56
+ <view>
57
+ <Child ref={ref1} />
58
+ <Child ref={ref2} />
59
+ </view>
60
+ );
61
+ }
62
+ }
63
+
64
+ globalEnvManager.switchToBackground();
65
+ render(<Comp show={true} />, __root);
66
+ expect(ref1).toBeCalledWith(expect.objectContaining({
67
+ x: 'x',
68
+ }));
69
+ expect(ref2.current).toHaveProperty('x', 'x');
70
+ ref1.mockClear();
71
+
72
+ render(<Comp show={false} />, __root);
73
+ expect(ref1).toBeCalledWith(null);
74
+ // TODO: check the behavior to this failed test
75
+ // expect(ref2.current).toBe(null);
76
+ });
77
+ });
78
+
79
+ describe('element ref', () => {
80
+ it('basic', async function() {
81
+ const ref1 = vi.fn();
82
+ const ref2 = createRef();
83
+
84
+ class Comp extends Component {
85
+ x = 'x';
86
+ render() {
87
+ return (
88
+ <view>
89
+ <view ref={ref1} />
90
+ <view ref={ref2} />
91
+ </view>
92
+ );
93
+ }
94
+ }
95
+
96
+ // main thread render
97
+ {
98
+ __root.__jsx = <Comp />;
99
+ renderPage();
100
+ expect(__root.__element_root).toMatchInlineSnapshot(`
101
+ <page
102
+ cssId="default-entry-from-native:0"
103
+ >
104
+ <view>
105
+ <view
106
+ react-ref--2-0={1}
107
+ />
108
+ <view
109
+ react-ref--2-1={1}
110
+ />
111
+ </view>
112
+ </page>
113
+ `);
114
+ expect(globalThis.__OnLifecycleEvent.mock.calls[0]).toMatchInlineSnapshot(`
115
+ [
116
+ [
117
+ "rLynxFirstScreen",
118
+ {
119
+ "firstScreenEventIdSwap": {},
120
+ "root": "{"id":-1,"type":"root","children":[{"id":-2,"type":"__snapshot_a94a8_test_3","values":["react-ref--2-0","react-ref--2-1"]}]}",
121
+ },
122
+ ],
123
+ ]
124
+ `);
125
+ }
126
+
127
+ // background render
128
+ {
129
+ globalEnvManager.switchToBackground();
130
+ render(<Comp />, __root);
131
+
132
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
133
+ [
134
+ [
135
+ RefProxy {
136
+ "refAttr": [
137
+ 2,
138
+ 0,
139
+ ],
140
+ "task": undefined,
141
+ },
142
+ ],
143
+ ]
144
+ `);
145
+ expect(ref2.current).toMatchInlineSnapshot(`
146
+ RefProxy {
147
+ "refAttr": [
148
+ 2,
149
+ 1,
150
+ ],
151
+ "task": undefined,
152
+ }
153
+ `);
154
+ }
155
+ });
156
+
157
+ it('should trigger ref when insert node', async function() {
158
+ const ref1 = vi.fn();
159
+ const ref2 = createRef();
160
+
161
+ class Comp extends Component {
162
+ x = 'x';
163
+ render() {
164
+ return this.props.show && (
165
+ <view>
166
+ <view ref={ref1} />
167
+ <view ref={ref2} />
168
+ </view>
169
+ );
170
+ }
171
+ }
172
+
173
+ // main thread render
174
+ {
175
+ __root.__jsx = <Comp show={false} />;
176
+ renderPage();
177
+ }
178
+
179
+ // background render
180
+ {
181
+ globalEnvManager.switchToBackground();
182
+ render(<Comp show={false} />, __root);
183
+ }
184
+
185
+ // hydrate
186
+ {
187
+ // LifecycleConstant.firstScreen
188
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
189
+
190
+ // rLynxChange
191
+ globalEnvManager.switchToMainThread();
192
+ globalThis.__OnLifecycleEvent.mockClear();
193
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
194
+ globalThis[rLynxChange[0]](rLynxChange[1]);
195
+ expect(globalThis.__OnLifecycleEvent).not.toBeCalled();
196
+ }
197
+
198
+ // insert node
199
+ {
200
+ globalEnvManager.switchToBackground();
201
+ lynx.getNativeApp().callLepusMethod.mockClear();
202
+ render(<Comp show={true} />, __root);
203
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
204
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
205
+ `"{"patchList":[{"id":3,"snapshotPatch":[0,"__snapshot_a94a8_test_4",2,4,2,[1,1],1,-1,2,null,0]}]}"`,
206
+ );
207
+ }
208
+
209
+ // rLynxChange
210
+ {
211
+ globalEnvManager.switchToMainThread();
212
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
213
+ globalThis[rLynxChange[0]](rLynxChange[1]);
214
+ rLynxChange[2]();
215
+ }
216
+
217
+ // ref
218
+ {
219
+ globalEnvManager.switchToBackground();
220
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
221
+ [
222
+ [
223
+ RefProxy {
224
+ "refAttr": [
225
+ 2,
226
+ 0,
227
+ ],
228
+ "task": undefined,
229
+ },
230
+ ],
231
+ ]
232
+ `);
233
+ expect(ref2).toMatchInlineSnapshot(`
234
+ {
235
+ "current": RefProxy {
236
+ "refAttr": [
237
+ 2,
238
+ 1,
239
+ ],
240
+ "task": undefined,
241
+ },
242
+ }
243
+ `);
244
+ }
245
+ });
246
+
247
+ it('should trigger ref when remove node', async function() {
248
+ const ref1 = vi.fn();
249
+ const ref2 = createRef();
250
+
251
+ class Comp extends Component {
252
+ x = 'x';
253
+ render() {
254
+ return this.props.show && (
255
+ <view>
256
+ <view ref={ref1} />
257
+ <view ref={ref2} />
258
+ </view>
259
+ );
260
+ }
261
+ }
262
+
263
+ // main thread render
264
+ {
265
+ __root.__jsx = <Comp show={true} />;
266
+ renderPage();
267
+ }
268
+
269
+ // background render
270
+ {
271
+ globalEnvManager.switchToBackground();
272
+ render(<Comp show={true} />, __root);
273
+ }
274
+
275
+ // hydrate
276
+ {
277
+ // LifecycleConstant.firstScreen
278
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
279
+
280
+ // rLynxChange
281
+ globalEnvManager.switchToMainThread();
282
+ globalThis.__OnLifecycleEvent.mockClear();
283
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
284
+ globalThis[rLynxChange[0]](rLynxChange[1]);
285
+ expect(globalThis.__OnLifecycleEvent).not.toBeCalled();
286
+ }
287
+
288
+ // remove node
289
+ {
290
+ ref1.mockClear();
291
+ globalEnvManager.switchToBackground();
292
+ lynx.getNativeApp().callLepusMethod.mockClear();
293
+ render(<Comp show={false} />, __root);
294
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
295
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
296
+ `"{"patchList":[{"id":3,"snapshotPatch":[2,-1,-2]}]}"`,
297
+ );
298
+ }
299
+
300
+ // ref patch
301
+ {
302
+ globalEnvManager.switchToBackground();
303
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
304
+ [
305
+ [
306
+ null,
307
+ ],
308
+ ]
309
+ `);
310
+ expect(ref2.current).toBeNull();
311
+ }
312
+ });
313
+
314
+ it('should trigger ref when remove node with cleanup function', async function() {
315
+ const cleanup = vi.fn();
316
+ const ref1 = vi.fn(() => {
317
+ return cleanup;
318
+ });
319
+
320
+ class Comp extends Component {
321
+ x = 'x';
322
+ render() {
323
+ return this.props.show && (
324
+ <view>
325
+ <view ref={ref1} />
326
+ </view>
327
+ );
328
+ }
329
+ }
330
+
331
+ // main thread render
332
+ {
333
+ __root.__jsx = <Comp show={true} />;
334
+ renderPage();
335
+ }
336
+
337
+ // background render
338
+ {
339
+ globalEnvManager.switchToBackground();
340
+ render(<Comp show={true} />, __root);
341
+ }
342
+
343
+ // hydrate
344
+ {
345
+ // LifecycleConstant.firstScreen
346
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
347
+
348
+ // rLynxChange
349
+ globalEnvManager.switchToMainThread();
350
+ globalThis.__OnLifecycleEvent.mockClear();
351
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
352
+ globalThis[rLynxChange[0]](rLynxChange[1]);
353
+ expect(globalThis.__OnLifecycleEvent).not.toBeCalled();
354
+ }
355
+
356
+ // remove node
357
+ {
358
+ ref1.mockClear();
359
+ globalEnvManager.switchToBackground();
360
+ lynx.getNativeApp().callLepusMethod.mockClear();
361
+ render(<Comp show={false} />, __root);
362
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
363
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
364
+ `"{"patchList":[{"id":3,"snapshotPatch":[2,-1,-2]}]}"`,
365
+ );
366
+ }
367
+
368
+ // ref patch
369
+ {
370
+ globalEnvManager.switchToBackground();
371
+ expect(ref1).not.toBeCalled();
372
+ expect(cleanup.mock.calls).toMatchInlineSnapshot(`
373
+ [
374
+ [],
375
+ ]
376
+ `);
377
+ }
378
+ });
379
+
380
+ it('should trigger ref when ref and unref deeply', async () => {
381
+ const ref1 = [vi.fn(), vi.fn(), vi.fn()];
382
+ const ref2 = vi.fn();
383
+ let _setShow;
384
+
385
+ function ComponentWithRef({ index }) {
386
+ return <view ref={ref1[index]} />;
387
+ }
388
+
389
+ function App() {
390
+ const [show, setShow] = useState(true);
391
+ _setShow = setShow;
392
+ return (
393
+ show && (
394
+ <view ref={ref2}>
395
+ {[0, 1, 2].map(i => {
396
+ return <ComponentWithRef index={i} />;
397
+ })}
398
+ </view>
399
+ )
400
+ );
401
+ }
402
+
403
+ // main thread render
404
+ {
405
+ __root.__jsx = <App />;
406
+ renderPage();
407
+ }
408
+
409
+ // background render
410
+ {
411
+ globalEnvManager.switchToBackground();
412
+ render(<App />, __root);
413
+ }
414
+
415
+ // hydrate
416
+ {
417
+ // LifecycleConstant.firstScreen
418
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
419
+
420
+ // rLynxChange
421
+ globalEnvManager.switchToMainThread();
422
+ globalThis.__OnLifecycleEvent.mockClear();
423
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
424
+ globalThis[rLynxChange[0]](rLynxChange[1]);
425
+ }
426
+
427
+ ref1.forEach(ref => {
428
+ expect(ref).toHaveBeenCalledWith(expect.objectContaining({
429
+ refAttr: expect.any(Array),
430
+ }));
431
+ });
432
+ expect(ref2).toHaveBeenCalledWith(expect.objectContaining({
433
+ refAttr: expect.any(Array),
434
+ }));
435
+ ref1.forEach(ref => ref.mockClear());
436
+ ref2.mockClear();
437
+
438
+ // remove node
439
+ {
440
+ globalEnvManager.switchToBackground();
441
+ lynx.getNativeApp().callLepusMethod.mockClear();
442
+ _setShow(false);
443
+ await waitSchedule();
444
+ }
445
+
446
+ // ref check
447
+ {
448
+ globalEnvManager.switchToBackground();
449
+ ref1.forEach(ref => expect(ref).toHaveBeenCalledWith(null));
450
+ expect(ref2).toHaveBeenCalledWith(null);
451
+ }
452
+ });
453
+
454
+ it('should trigger ref when ref is null in the first screen', async function() {
455
+ const ref1 = createRef();
456
+ const ref2 = createRef();
457
+ const ref3 = vi.fn();
458
+
459
+ class Comp extends Component {
460
+ x = 'x';
461
+ render() {
462
+ return (
463
+ <view>
464
+ <view ref={this.props.switch ? ref1 : null} />
465
+ <view ref={this.props.switch ? null : ref2} />
466
+ <view ref={this.props.switch ? null : ref3} />
467
+ </view>
468
+ );
469
+ }
470
+ }
471
+
472
+ // main thread render
473
+ {
474
+ __root.__jsx = <Comp switch={true} />;
475
+ renderPage();
476
+ expect(__root.__element_root).toMatchInlineSnapshot(`
477
+ <page
478
+ cssId="default-entry-from-native:0"
479
+ >
480
+ <view>
481
+ <view
482
+ react-ref--2-0={1}
483
+ />
484
+ <view
485
+ react-ref--2-1={1}
486
+ />
487
+ <view
488
+ react-ref--2-2={1}
489
+ />
490
+ </view>
491
+ </page>
492
+ `);
493
+ expect(globalThis.__OnLifecycleEvent.mock.calls[0]).toMatchInlineSnapshot(`
494
+ [
495
+ [
496
+ "rLynxFirstScreen",
497
+ {
498
+ "firstScreenEventIdSwap": {},
499
+ "root": "{"id":-1,"type":"root","children":[{"id":-2,"type":"__snapshot_a94a8_test_9","values":["react-ref--2-0","react-ref--2-1","react-ref--2-2"]}]}",
500
+ },
501
+ ],
502
+ ]
503
+ `);
504
+ }
505
+
506
+ // background render
507
+ {
508
+ globalEnvManager.switchToBackground();
509
+ render(<Comp switch={false} />, __root);
510
+ lynx.getNativeApp().callLepusMethod.mockClear();
511
+
512
+ expect(ref1.current).toBeNull();
513
+ expect(ref2.current).toMatchInlineSnapshot(`
514
+ RefProxy {
515
+ "refAttr": [
516
+ 2,
517
+ 1,
518
+ ],
519
+ "task": undefined,
520
+ }
521
+ `);
522
+ expect(ref3.mock.calls).toMatchInlineSnapshot(`
523
+ [
524
+ [
525
+ RefProxy {
526
+ "refAttr": [
527
+ 2,
528
+ 2,
529
+ ],
530
+ "task": undefined,
531
+ },
532
+ ],
533
+ ]
534
+ `);
535
+ }
536
+
537
+ // hydrate
538
+ {
539
+ // LifecycleConstant.firstScreen
540
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
541
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
542
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
543
+ `"{"patchList":[{"snapshotPatch":[3,-2,0,null],"id":2}]}"`,
544
+ );
545
+
546
+ // rLynxChange
547
+ globalEnvManager.switchToMainThread();
548
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
549
+ globalThis[rLynxChange[0]](rLynxChange[1]);
550
+ rLynxChange[2]();
551
+ // Keep "-2:0" exists even if it is set to null. This is for the first screen.
552
+ expect(__root.__element_root).toMatchInlineSnapshot(`
553
+ <page
554
+ cssId="default-entry-from-native:0"
555
+ >
556
+ <view>
557
+ <view
558
+ react-ref--2-0={1}
559
+ />
560
+ <view
561
+ react-ref--2-1={1}
562
+ />
563
+ <view
564
+ react-ref--2-2={1}
565
+ />
566
+ </view>
567
+ </page>
568
+ `);
569
+ }
570
+ });
571
+
572
+ it('should throw error when ref type is wrong', async function() {
573
+ let ref1 = 1;
574
+
575
+ class Comp extends Component {
576
+ x = 'x';
577
+ render() {
578
+ return (
579
+ <view>
580
+ <view ref={ref1} />
581
+ </view>
582
+ );
583
+ }
584
+ }
585
+
586
+ // background render
587
+ {
588
+ globalEnvManager.switchToBackground();
589
+ expect(() => {
590
+ render(<Comp />, __root);
591
+ }).toThrowError(
592
+ 'Elements\' "ref" property should be a function, or an object created by createRef(), but got [number] instead',
593
+ );
594
+ }
595
+
596
+ ref1 = {};
597
+
598
+ // background render
599
+ {
600
+ globalEnvManager.resetEnv();
601
+ globalEnvManager.switchToBackground();
602
+ expect(() => {
603
+ render(<Comp />, __root);
604
+ }).toThrowError(
605
+ 'Elements\' "ref" property should be a function, or an object created by createRef(), but got [object] instead',
606
+ );
607
+ }
608
+ });
609
+
610
+ it('should trigger ref when ref object is updated', async function() {
611
+ const cleanup = vi.fn();
612
+ let ref1 = vi.fn(() => {
613
+ return cleanup;
614
+ });
615
+ let ref2 = createRef();
616
+ let ref3 = createRef();
617
+
618
+ class Comp extends Component {
619
+ render() {
620
+ return (
621
+ <view>
622
+ <view ref={ref1} />
623
+ <view ref={ref2} />
624
+ <view ref={ref3} />
625
+ </view>
626
+ );
627
+ }
628
+ }
629
+
630
+ // main thread render
631
+ {
632
+ __root.__jsx = <Comp />;
633
+ renderPage();
634
+ }
635
+
636
+ // background render
637
+ {
638
+ globalEnvManager.switchToBackground();
639
+ render(<Comp />, __root);
640
+ }
641
+
642
+ // hydrate
643
+ {
644
+ // LifecycleConstant.firstScreen
645
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
646
+ globalThis.__OnLifecycleEvent.mockClear();
647
+
648
+ // rLynxChange
649
+ globalEnvManager.switchToMainThread();
650
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
651
+ globalThis[rLynxChange[0]](rLynxChange[1]);
652
+ lynx.getNativeApp().callLepusMethod.mockClear();
653
+ }
654
+
655
+ // update ref
656
+ const oldRef1 = ref1;
657
+ const oldRef2 = ref2;
658
+ const oldRef3 = ref3;
659
+ oldRef1.mockClear();
660
+ {
661
+ globalEnvManager.switchToBackground();
662
+ ref1 = vi.fn();
663
+ ref2 = createRef();
664
+ ref3 = null;
665
+ render(<Comp />, __root);
666
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
667
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
668
+ `"{"patchList":[{"id":3,"snapshotPatch":[3,-2,2,null]}]}"`,
669
+ );
670
+ }
671
+
672
+ // ref
673
+ {
674
+ globalEnvManager.switchToBackground();
675
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
676
+ [
677
+ [
678
+ RefProxy {
679
+ "refAttr": [
680
+ -2,
681
+ 0,
682
+ ],
683
+ "task": undefined,
684
+ },
685
+ ],
686
+ ]
687
+ `);
688
+ expect(ref2).toMatchInlineSnapshot(`
689
+ {
690
+ "current": RefProxy {
691
+ "refAttr": [
692
+ -2,
693
+ 1,
694
+ ],
695
+ "task": undefined,
696
+ },
697
+ }
698
+ `);
699
+ expect(oldRef1.mock.calls).toMatchInlineSnapshot(`[]`);
700
+ expect(cleanup.mock.calls).toMatchInlineSnapshot(`
701
+ [
702
+ [],
703
+ ]
704
+ `);
705
+ expect(oldRef2.current).toBeNull();
706
+ expect(oldRef3.current).toBeNull();
707
+ }
708
+ });
709
+
710
+ it('should work when using ref along with other attributes', async function() {
711
+ const ref = createRef();
712
+ const attr1 = 1;
713
+
714
+ class Comp extends Component {
715
+ render() {
716
+ return <view ref={ref} attr1={attr1} />;
717
+ }
718
+ }
719
+
720
+ // main thread render
721
+ {
722
+ __root.__jsx = <Comp />;
723
+ renderPage();
724
+ }
725
+
726
+ // background render
727
+ {
728
+ globalEnvManager.switchToBackground();
729
+ render(<Comp />, __root);
730
+ expect(ref.current).toMatchInlineSnapshot(`
731
+ RefProxy {
732
+ "refAttr": [
733
+ 2,
734
+ 0,
735
+ ],
736
+ "task": undefined,
737
+ }
738
+ `);
739
+ }
740
+ });
741
+
742
+ // NOT working for now
743
+ it.skip('should work when using error boundary with ref', async function() {
744
+ const ref = vi.fn(() => {
745
+ throw new Error('error in ref');
746
+ });
747
+ const errorHandler = vi.fn();
748
+
749
+ class Comp extends Component {
750
+ state = { hasError: false };
751
+
752
+ componentDidCatch(error, info) {
753
+ errorHandler(error, info);
754
+ this.setState({ hasError: true });
755
+ }
756
+
757
+ render() {
758
+ if (this.state.hasError) {
759
+ return <view>Error occurred</view>;
760
+ }
761
+ return <view ref={ref}></view>;
762
+ }
763
+ }
764
+
765
+ // main thread render
766
+ {
767
+ __root.__jsx = <Comp />;
768
+ renderPage();
769
+ }
770
+
771
+ // background render
772
+ {
773
+ globalEnvManager.switchToBackground();
774
+ render(<Comp />, __root);
775
+ expect(ref.current).toMatchInlineSnapshot(`undefined`);
776
+
777
+ expect(errorHandler).toHaveBeenCalledTimes(1);
778
+ }
779
+ });
780
+
781
+ it('should not trigger ref when ref function is not updated', async function() {
782
+ let ref1 = vi.fn();
783
+ let show = true;
784
+
785
+ class Comp extends Component {
786
+ render() {
787
+ return (
788
+ <view>
789
+ {show && <view ref={ref1} />}
790
+ </view>
791
+ );
792
+ }
793
+ }
794
+
795
+ // main thread render
796
+ {
797
+ __root.__jsx = <Comp />;
798
+ renderPage();
799
+ }
800
+
801
+ // background render
802
+ {
803
+ globalEnvManager.switchToBackground();
804
+ render(<Comp />, __root);
805
+ }
806
+
807
+ // hydrate
808
+ {
809
+ // LifecycleConstant.firstScreen
810
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
811
+ globalThis.__OnLifecycleEvent.mockClear();
812
+
813
+ // rLynxChange
814
+ globalEnvManager.switchToMainThread();
815
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
816
+ globalThis[rLynxChange[0]](rLynxChange[1]);
817
+ lynx.getNativeApp().callLepusMethod.mockClear();
818
+ }
819
+
820
+ // ref
821
+ {
822
+ globalEnvManager.switchToBackground();
823
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
824
+ [
825
+ [
826
+ RefProxy {
827
+ "refAttr": [
828
+ 3,
829
+ 0,
830
+ ],
831
+ "task": undefined,
832
+ },
833
+ ],
834
+ ]
835
+ `);
836
+ }
837
+
838
+ // background render
839
+ {
840
+ globalEnvManager.switchToBackground();
841
+ ref1.mockClear();
842
+ render(<Comp />, __root);
843
+ }
844
+
845
+ // ref
846
+ {
847
+ globalEnvManager.switchToBackground();
848
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`[]`);
849
+ }
850
+
851
+ // background render
852
+ {
853
+ globalEnvManager.switchToBackground();
854
+ ref1.mockClear();
855
+ show = false;
856
+ render(<Comp />, __root);
857
+ }
858
+ // ref
859
+ {
860
+ globalEnvManager.switchToBackground();
861
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
862
+ [
863
+ [
864
+ null,
865
+ ],
866
+ ]
867
+ `);
868
+ }
869
+ });
870
+
871
+ it('should trigger ref when element not exists in the first screen', async function() {
872
+ const ref1 = vi.fn();
873
+
874
+ class Comp extends Component {
875
+ x = 'x';
876
+ render() {
877
+ return (
878
+ <view>
879
+ {this.props.switch && (
880
+ <view>
881
+ <view ref={ref1} />
882
+ </view>
883
+ )}
884
+ </view>
885
+ );
886
+ }
887
+ }
888
+
889
+ // main thread render
890
+ {
891
+ __root.__jsx = <Comp switch={false} />;
892
+ renderPage();
893
+ expect(__root.__element_root).toMatchInlineSnapshot(`
894
+ <page
895
+ cssId="default-entry-from-native:0"
896
+ >
897
+ <view />
898
+ </page>
899
+ `);
900
+ expect(globalThis.__OnLifecycleEvent.mock.calls[0]).toMatchInlineSnapshot(`
901
+ [
902
+ [
903
+ "rLynxFirstScreen",
904
+ {
905
+ "firstScreenEventIdSwap": {},
906
+ "root": "{"id":-1,"type":"root","children":[{"id":-2,"type":"__snapshot_a94a8_test_17"}]}",
907
+ },
908
+ ],
909
+ ]
910
+ `);
911
+ }
912
+
913
+ // background render
914
+ {
915
+ globalEnvManager.switchToBackground();
916
+ render(<Comp switch={true} />, __root);
917
+ lynx.getNativeApp().callLepusMethod.mockClear();
918
+
919
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
920
+ [
921
+ [
922
+ RefProxy {
923
+ "refAttr": [
924
+ 3,
925
+ 0,
926
+ ],
927
+ "task": undefined,
928
+ },
929
+ ],
930
+ ]
931
+ `);
932
+ ref1.mockClear();
933
+ }
934
+
935
+ // hydrate
936
+ {
937
+ // LifecycleConstant.firstScreen
938
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
939
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
940
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
941
+ `"{"patchList":[{"snapshotPatch":[0,"__snapshot_a94a8_test_18",3,4,3,[1],1,-2,3,null,0],"id":2}]}"`,
942
+ );
943
+
944
+ // rLynxChange
945
+ globalEnvManager.switchToMainThread();
946
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
947
+ globalThis[rLynxChange[0]](rLynxChange[1]);
948
+ rLynxChange[2]();
949
+ // Keep "-2:0" exists even if it is set to null. This is for the first screen.
950
+ expect(__root.__element_root).toMatchInlineSnapshot(`
951
+ <page
952
+ cssId="default-entry-from-native:0"
953
+ >
954
+ <view>
955
+ <view>
956
+ <view
957
+ react-ref-3-0={1}
958
+ />
959
+ </view>
960
+ </view>
961
+ </page>
962
+ `);
963
+ }
964
+
965
+ // ref
966
+ {
967
+ globalEnvManager.switchToBackground();
968
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`[]`);
969
+ }
970
+ });
971
+ });
972
+
973
+ describe('element ref in spread', () => {
974
+ it('should trigger ref when insert ref into spread', async function() {
975
+ const ref1 = vi.fn();
976
+ const ref2 = createRef();
977
+ let spread1 = {};
978
+ const spread2 = { ref: ref2 };
979
+ const spread3 = { ref: undefined };
980
+
981
+ class Comp extends Component {
982
+ x = 'x';
983
+ render() {
984
+ return (
985
+ <view>
986
+ <view {...spread1} />
987
+ <view {...spread2} />
988
+ <view {...spread3} />
989
+ </view>
990
+ );
991
+ }
992
+ }
993
+
994
+ // main thread render
995
+ {
996
+ __root.__jsx = <Comp />;
997
+ renderPage();
998
+ expect(__root.__element_root).toMatchInlineSnapshot(`
999
+ <page
1000
+ cssId="default-entry-from-native:0"
1001
+ >
1002
+ <view>
1003
+ <view />
1004
+ <view
1005
+ react-ref--2-1={1}
1006
+ />
1007
+ <view />
1008
+ </view>
1009
+ </page>
1010
+ `);
1011
+ expect(globalThis.__OnLifecycleEvent.mock.calls).toMatchInlineSnapshot(`
1012
+ [
1013
+ [
1014
+ [
1015
+ "rLynxFirstScreen",
1016
+ {
1017
+ "firstScreenEventIdSwap": {},
1018
+ "root": "{"id":-1,"type":"root","children":[{"id":-2,"type":"__snapshot_a94a8_test_19","values":[{},{"ref":"react-ref--2-1"},{}]}]}",
1019
+ },
1020
+ ],
1021
+ ],
1022
+ ]
1023
+ `);
1024
+ }
1025
+
1026
+ // background render
1027
+ {
1028
+ globalEnvManager.switchToBackground();
1029
+ render(<Comp />, __root);
1030
+ lynx.getNativeApp().callLepusMethod.mockClear();
1031
+ }
1032
+
1033
+ // hydrate
1034
+ {
1035
+ // LifecycleConstant.firstScreen
1036
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1037
+ globalThis.__OnLifecycleEvent.mockClear();
1038
+
1039
+ // rLynxChange
1040
+ globalEnvManager.switchToMainThread();
1041
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1042
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1043
+ }
1044
+
1045
+ // ref
1046
+ {
1047
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`[]`);
1048
+ expect(ref2).toMatchInlineSnapshot(`
1049
+ {
1050
+ "current": RefProxy {
1051
+ "refAttr": [
1052
+ 2,
1053
+ 1,
1054
+ ],
1055
+ "task": undefined,
1056
+ },
1057
+ }
1058
+ `);
1059
+ }
1060
+
1061
+ // insert ref
1062
+ {
1063
+ globalEnvManager.switchToBackground();
1064
+ lynx.getNativeApp().callLepusMethod.mockClear();
1065
+ spread1 = { ref: ref1 };
1066
+ render(<Comp />, __root);
1067
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
1068
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
1069
+ `"{"patchList":[{"id":3,"snapshotPatch":[3,-2,0,{"ref":1}]}]}"`,
1070
+ );
1071
+ }
1072
+
1073
+ // rLynxChange
1074
+ {
1075
+ globalEnvManager.switchToMainThread();
1076
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1077
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1078
+ rLynxChange[2]();
1079
+ expect(__root.__element_root).toMatchInlineSnapshot(`
1080
+ <page
1081
+ cssId="default-entry-from-native:0"
1082
+ >
1083
+ <view>
1084
+ <view
1085
+ react-ref--2-0={1}
1086
+ />
1087
+ <view
1088
+ react-ref--2-1={1}
1089
+ />
1090
+ <view />
1091
+ </view>
1092
+ </page>
1093
+ `);
1094
+ }
1095
+
1096
+ // ref
1097
+ {
1098
+ globalEnvManager.switchToBackground();
1099
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
1100
+ [
1101
+ [
1102
+ RefProxy {
1103
+ "refAttr": [
1104
+ -2,
1105
+ 0,
1106
+ ],
1107
+ "task": undefined,
1108
+ },
1109
+ ],
1110
+ ]
1111
+ `);
1112
+ }
1113
+ });
1114
+
1115
+ it('should trigger ref when remove ref from spread', async function() {
1116
+ const ref1 = vi.fn();
1117
+ const ref2 = createRef();
1118
+ let spread1 = { ref: ref1 };
1119
+ let spread2 = { ref: ref2 };
1120
+
1121
+ class Comp extends Component {
1122
+ x = 'x';
1123
+ render() {
1124
+ return (
1125
+ <view>
1126
+ {this.props.show && <view {...spread1} />}
1127
+ <view {...spread2} />
1128
+ </view>
1129
+ );
1130
+ }
1131
+ }
1132
+
1133
+ // main thread render
1134
+ {
1135
+ __root.__jsx = <Comp show={true} />;
1136
+ renderPage();
1137
+ }
1138
+
1139
+ // background render
1140
+ {
1141
+ globalEnvManager.switchToBackground();
1142
+ render(<Comp show={true} />, __root);
1143
+ lynx.getNativeApp().callLepusMethod.mockClear();
1144
+ }
1145
+
1146
+ // hydrate
1147
+ {
1148
+ // LifecycleConstant.firstScreen
1149
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1150
+ globalThis.__OnLifecycleEvent.mockClear();
1151
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
1152
+ [
1153
+ [
1154
+ RefProxy {
1155
+ "refAttr": [
1156
+ 3,
1157
+ 0,
1158
+ ],
1159
+ "task": undefined,
1160
+ },
1161
+ ],
1162
+ ]
1163
+ `);
1164
+ expect(ref2).toMatchInlineSnapshot(`
1165
+ {
1166
+ "current": RefProxy {
1167
+ "refAttr": [
1168
+ 2,
1169
+ 0,
1170
+ ],
1171
+ "task": undefined,
1172
+ },
1173
+ }
1174
+ `);
1175
+
1176
+ // rLynxChange
1177
+ globalEnvManager.switchToMainThread();
1178
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1179
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1180
+ }
1181
+
1182
+ // ref
1183
+ {
1184
+ ref1.mockClear();
1185
+ }
1186
+
1187
+ // remove ref
1188
+ {
1189
+ globalEnvManager.switchToBackground();
1190
+ lynx.getNativeApp().callLepusMethod.mockClear();
1191
+ spread2 = {};
1192
+ render(<Comp show={false} />, __root);
1193
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
1194
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
1195
+ `"{"patchList":[{"id":3,"snapshotPatch":[3,-2,0,{},2,-2,-3]}]}"`,
1196
+ );
1197
+ }
1198
+
1199
+ // rLynxChange
1200
+ {
1201
+ globalEnvManager.switchToMainThread();
1202
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1203
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1204
+ rLynxChange[2]();
1205
+ }
1206
+
1207
+ // ref
1208
+ {
1209
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
1210
+ [
1211
+ [
1212
+ null,
1213
+ ],
1214
+ ]
1215
+ `);
1216
+ expect(ref2.current).toBeNull();
1217
+ }
1218
+ });
1219
+
1220
+ it('should trigger ref when update ref in spread', async function() {
1221
+ let ref1 = vi.fn();
1222
+ let ref2 = createRef();
1223
+ let ref3 = createRef();
1224
+ let spread1 = { ref: ref1 };
1225
+ let spread2 = { ref: ref2 };
1226
+ let spread3 = { ref: ref3 };
1227
+
1228
+ class Comp extends Component {
1229
+ x = 'x';
1230
+ render() {
1231
+ return (
1232
+ <view>
1233
+ <view {...spread1} />
1234
+ <view {...spread2} />
1235
+ <view {...spread3} />
1236
+ </view>
1237
+ );
1238
+ }
1239
+ }
1240
+
1241
+ // main thread render
1242
+ {
1243
+ __root.__jsx = <Comp show={true} />;
1244
+ renderPage();
1245
+ }
1246
+
1247
+ // background render
1248
+ {
1249
+ globalEnvManager.switchToBackground();
1250
+ render(<Comp show={true} />, __root);
1251
+ lynx.getNativeApp().callLepusMethod.mockClear();
1252
+ }
1253
+
1254
+ // hydrate
1255
+ {
1256
+ // LifecycleConstant.firstScreen
1257
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1258
+ globalThis.__OnLifecycleEvent.mockClear();
1259
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
1260
+ [
1261
+ [
1262
+ RefProxy {
1263
+ "refAttr": [
1264
+ 2,
1265
+ 0,
1266
+ ],
1267
+ "task": undefined,
1268
+ },
1269
+ ],
1270
+ ]
1271
+ `);
1272
+ expect(ref2).toMatchInlineSnapshot(`
1273
+ {
1274
+ "current": RefProxy {
1275
+ "refAttr": [
1276
+ 2,
1277
+ 1,
1278
+ ],
1279
+ "task": undefined,
1280
+ },
1281
+ }
1282
+ `);
1283
+ expect(ref3).toMatchInlineSnapshot(`
1284
+ {
1285
+ "current": RefProxy {
1286
+ "refAttr": [
1287
+ 2,
1288
+ 2,
1289
+ ],
1290
+ "task": undefined,
1291
+ },
1292
+ }
1293
+ `);
1294
+
1295
+ // rLynxChange
1296
+ globalEnvManager.switchToMainThread();
1297
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1298
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1299
+ rLynxChange[2]();
1300
+ lynx.getNativeApp().callLepusMethod.mockClear();
1301
+ await waitSchedule();
1302
+ }
1303
+
1304
+ // ref
1305
+ {
1306
+ globalEnvManager.switchToBackground();
1307
+ ref1.mockClear();
1308
+ }
1309
+
1310
+ // update ref
1311
+ const oldRef1 = ref1;
1312
+ const oldRef2 = ref2;
1313
+ const oldRef3 = ref3;
1314
+ {
1315
+ globalEnvManager.switchToBackground();
1316
+ ref1 = vi.fn();
1317
+ ref2 = createRef();
1318
+ ref3 = null;
1319
+ spread1 = { ref: ref1 };
1320
+ spread2 = { ref: ref2 };
1321
+ spread3 = { ref: ref3 };
1322
+ render(<Comp />, __root);
1323
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
1324
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
1325
+ `"{"patchList":[{"id":3,"snapshotPatch":[3,-2,2,{}]}]}"`,
1326
+ );
1327
+ }
1328
+
1329
+ // rLynxChange
1330
+ {
1331
+ globalEnvManager.switchToMainThread();
1332
+ const rLynxChange = lynx.getNativeApp().callLepusMethod.mock.calls[0];
1333
+ globalThis[rLynxChange[0]](rLynxChange[1]);
1334
+ rLynxChange[2]();
1335
+ lynx.getNativeApp().callLepusMethod.mockClear();
1336
+ }
1337
+
1338
+ // ref
1339
+ {
1340
+ globalEnvManager.switchToBackground();
1341
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`
1342
+ [
1343
+ [
1344
+ RefProxy {
1345
+ "refAttr": [
1346
+ -2,
1347
+ 0,
1348
+ ],
1349
+ "task": undefined,
1350
+ },
1351
+ ],
1352
+ ]
1353
+ `);
1354
+ expect(ref2).toMatchInlineSnapshot(`
1355
+ {
1356
+ "current": RefProxy {
1357
+ "refAttr": [
1358
+ -2,
1359
+ 1,
1360
+ ],
1361
+ "task": undefined,
1362
+ },
1363
+ }
1364
+ `);
1365
+ expect(oldRef1.mock.calls).toMatchInlineSnapshot(`
1366
+ [
1367
+ [
1368
+ null,
1369
+ ],
1370
+ ]
1371
+ `);
1372
+ expect(oldRef2.current).toBeNull();
1373
+ expect(oldRef3.current).toBeNull();
1374
+ ref1.mockClear();
1375
+ }
1376
+
1377
+ // update ref
1378
+ {
1379
+ ref3 = createRef();
1380
+ spread3 = { ref: ref3 };
1381
+ render(<Comp />, __root);
1382
+ expect(lynx.getNativeApp().callLepusMethod).toHaveBeenCalledTimes(1);
1383
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
1384
+ `"{"patchList":[{"id":4,"snapshotPatch":[3,-2,2,{"ref":1}]}]}"`,
1385
+ );
1386
+ expect(ref1.mock.calls).toMatchInlineSnapshot(`[]`);
1387
+ expect(ref3.current).toMatchInlineSnapshot(`
1388
+ RefProxy {
1389
+ "refAttr": [
1390
+ -2,
1391
+ 2,
1392
+ ],
1393
+ "task": undefined,
1394
+ }
1395
+ `);
1396
+ }
1397
+ });
1398
+ });
1399
+
1400
+ describe('element ref in list', () => {
1401
+ it('should trigger ref in list', async function() {
1402
+ const refs = [createRef(), createRef(), createRef()];
1403
+ const signs = [0, 0, 0];
1404
+
1405
+ class ListItem extends Component {
1406
+ render() {
1407
+ return <view ref={this.props._ref}></view>;
1408
+ }
1409
+ }
1410
+
1411
+ class Comp extends Component {
1412
+ render() {
1413
+ return (
1414
+ <list>
1415
+ {[0, 1, 2].map((index) => {
1416
+ return (
1417
+ <list-item item-key={index}>
1418
+ <ListItem _ref={refs[index]}></ListItem>
1419
+ </list-item>
1420
+ );
1421
+ })}
1422
+ </list>
1423
+ );
1424
+ }
1425
+ }
1426
+
1427
+ // main thread render
1428
+ {
1429
+ __root.__jsx = <Comp />;
1430
+ renderPage();
1431
+ expect(__root.__element_root).toMatchInlineSnapshot(`
1432
+ <page
1433
+ cssId="default-entry-from-native:0"
1434
+ >
1435
+ <list
1436
+ update-list-info={
1437
+ [
1438
+ {
1439
+ "insertAction": [
1440
+ {
1441
+ "item-key": 0,
1442
+ "position": 0,
1443
+ "type": "__snapshot_a94a8_test_25",
1444
+ },
1445
+ {
1446
+ "item-key": 1,
1447
+ "position": 1,
1448
+ "type": "__snapshot_a94a8_test_25",
1449
+ },
1450
+ {
1451
+ "item-key": 2,
1452
+ "position": 2,
1453
+ "type": "__snapshot_a94a8_test_25",
1454
+ },
1455
+ ],
1456
+ "removeAction": [],
1457
+ "updateAction": [],
1458
+ },
1459
+ ]
1460
+ }
1461
+ />
1462
+ </page>
1463
+ `);
1464
+ }
1465
+
1466
+ // background render
1467
+ {
1468
+ globalEnvManager.switchToBackground();
1469
+ render(<Comp />, __root);
1470
+ lynx.getNativeApp().callLepusMethod.mockClear();
1471
+
1472
+ expect(refs[0]).toMatchInlineSnapshot(`
1473
+ {
1474
+ "current": RefProxy {
1475
+ "refAttr": [
1476
+ 4,
1477
+ 0,
1478
+ ],
1479
+ "task": undefined,
1480
+ },
1481
+ }
1482
+ `);
1483
+ expect(refs[1]).toMatchInlineSnapshot(`
1484
+ {
1485
+ "current": RefProxy {
1486
+ "refAttr": [
1487
+ 6,
1488
+ 0,
1489
+ ],
1490
+ "task": undefined,
1491
+ },
1492
+ }
1493
+ `);
1494
+ expect(refs[2]).toMatchInlineSnapshot(`
1495
+ {
1496
+ "current": RefProxy {
1497
+ "refAttr": [
1498
+ 8,
1499
+ 0,
1500
+ ],
1501
+ "task": undefined,
1502
+ },
1503
+ }
1504
+ `);
1505
+ }
1506
+
1507
+ // list render item 1 & 2
1508
+ {
1509
+ globalEnvManager.switchToMainThread();
1510
+ globalThis.lynxWorkletImpl?._refImpl.updateWorkletRef.mockClear();
1511
+ signs[0] = elementTree.triggerComponentAtIndex(__root.childNodes[0].__elements[0], 0);
1512
+ signs[1] = elementTree.triggerComponentAtIndex(__root.childNodes[0].__elements[0], 1);
1513
+ expect(__root.__element_root).toMatchInlineSnapshot(`
1514
+ <page
1515
+ cssId="default-entry-from-native:0"
1516
+ >
1517
+ <list
1518
+ update-list-info={
1519
+ [
1520
+ {
1521
+ "insertAction": [
1522
+ {
1523
+ "item-key": 0,
1524
+ "position": 0,
1525
+ "type": "__snapshot_a94a8_test_25",
1526
+ },
1527
+ {
1528
+ "item-key": 1,
1529
+ "position": 1,
1530
+ "type": "__snapshot_a94a8_test_25",
1531
+ },
1532
+ {
1533
+ "item-key": 2,
1534
+ "position": 2,
1535
+ "type": "__snapshot_a94a8_test_25",
1536
+ },
1537
+ ],
1538
+ "removeAction": [],
1539
+ "updateAction": [],
1540
+ },
1541
+ ]
1542
+ }
1543
+ >
1544
+ <list-item
1545
+ item-key={0}
1546
+ >
1547
+ <view
1548
+ react-ref--4-0={1}
1549
+ />
1550
+ </list-item>
1551
+ <list-item
1552
+ item-key={1}
1553
+ >
1554
+ <view
1555
+ react-ref--6-0={1}
1556
+ />
1557
+ </list-item>
1558
+ </list>
1559
+ </page>
1560
+ `);
1561
+ }
1562
+
1563
+ // list enqueue item 1 & render item 3
1564
+ {
1565
+ globalThis.lynxWorkletImpl?._refImpl.updateWorkletRef.mockClear();
1566
+ elementTree.triggerEnqueueComponent(__root.childNodes[0].__elements[0], signs[0]);
1567
+ elementTree.triggerComponentAtIndex(__root.childNodes[0].__elements[0], 2);
1568
+ expect(__root.__element_root).toMatchInlineSnapshot(`
1569
+ <page
1570
+ cssId="default-entry-from-native:0"
1571
+ >
1572
+ <list
1573
+ update-list-info={
1574
+ [
1575
+ {
1576
+ "insertAction": [
1577
+ {
1578
+ "item-key": 0,
1579
+ "position": 0,
1580
+ "type": "__snapshot_a94a8_test_25",
1581
+ },
1582
+ {
1583
+ "item-key": 1,
1584
+ "position": 1,
1585
+ "type": "__snapshot_a94a8_test_25",
1586
+ },
1587
+ {
1588
+ "item-key": 2,
1589
+ "position": 2,
1590
+ "type": "__snapshot_a94a8_test_25",
1591
+ },
1592
+ ],
1593
+ "removeAction": [],
1594
+ "updateAction": [],
1595
+ },
1596
+ ]
1597
+ }
1598
+ >
1599
+ <list-item
1600
+ item-key={2}
1601
+ >
1602
+ <view
1603
+ react-ref--8-0={1}
1604
+ />
1605
+ </list-item>
1606
+ <list-item
1607
+ item-key={1}
1608
+ >
1609
+ <view
1610
+ react-ref--6-0={1}
1611
+ />
1612
+ </list-item>
1613
+ </list>
1614
+ </page>
1615
+ `);
1616
+ }
1617
+ });
1618
+ });
1619
+
1620
+ describe('ui operations', () => {
1621
+ it('should delay until hydration finished', async function() {
1622
+ const ref1 = vi.fn((ref) => {
1623
+ ref.invoke({
1624
+ method: 'boundingClientRect',
1625
+ }).exec();
1626
+ });
1627
+
1628
+ class Comp extends Component {
1629
+ x = 'x';
1630
+ render() {
1631
+ return (
1632
+ <view>
1633
+ <view ref={ref1} />
1634
+ </view>
1635
+ );
1636
+ }
1637
+ }
1638
+
1639
+ // main thread render
1640
+ {
1641
+ __root.__jsx = <Comp />;
1642
+ renderPage();
1643
+ }
1644
+
1645
+ // background render
1646
+ {
1647
+ globalEnvManager.switchToBackground();
1648
+ render(<Comp />, __root);
1649
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`[]`);
1650
+ }
1651
+
1652
+ // hydrate
1653
+ {
1654
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1655
+ globalThis.__OnLifecycleEvent.mockClear();
1656
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`
1657
+ [
1658
+ [
1659
+ "[react-ref--2-0]",
1660
+ "invoke",
1661
+ [
1662
+ {
1663
+ "method": "boundingClientRect",
1664
+ },
1665
+ ],
1666
+ ],
1667
+ ]
1668
+ `);
1669
+ lynx.createSelectorQuery().constructor.execLog.mockClear();
1670
+ }
1671
+ });
1672
+
1673
+ it('should support more usages of ref 1', async function() {
1674
+ const ref1 = vi.fn((ref) => {
1675
+ ref.setNativeProps({
1676
+ 'background-color': 'blue',
1677
+ }).exec();
1678
+ ref.path(vi.fn()).exec();
1679
+ });
1680
+
1681
+ class Comp extends Component {
1682
+ x = 'x';
1683
+ render() {
1684
+ return (
1685
+ <view>
1686
+ <view ref={ref1} />
1687
+ </view>
1688
+ );
1689
+ }
1690
+ }
1691
+
1692
+ // main thread render
1693
+ {
1694
+ __root.__jsx = <Comp />;
1695
+ renderPage();
1696
+ }
1697
+
1698
+ // background render
1699
+ {
1700
+ globalEnvManager.switchToBackground();
1701
+ render(<Comp />, __root);
1702
+ }
1703
+
1704
+ // hydrate
1705
+ {
1706
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1707
+ globalThis.__OnLifecycleEvent.mockClear();
1708
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`
1709
+ [
1710
+ [
1711
+ "[react-ref--2-0]",
1712
+ "setNativeProps",
1713
+ [
1714
+ {
1715
+ "background-color": "blue",
1716
+ },
1717
+ ],
1718
+ ],
1719
+ [
1720
+ "[react-ref--2-0]",
1721
+ "path",
1722
+ [
1723
+ [MockFunction spy],
1724
+ ],
1725
+ ],
1726
+ ]
1727
+ `);
1728
+ lynx.createSelectorQuery().constructor.execLog.mockClear();
1729
+ }
1730
+ });
1731
+
1732
+ it('should support more usages of ref 2', async function() {
1733
+ const ref1 = vi.fn((ref) => {
1734
+ const fields = ref.fields({
1735
+ id: true,
1736
+ });
1737
+ fields.exec();
1738
+ fields.exec();
1739
+ });
1740
+
1741
+ class Comp extends Component {
1742
+ x = 'x';
1743
+ render() {
1744
+ return (
1745
+ <view>
1746
+ <view ref={ref1} />
1747
+ </view>
1748
+ );
1749
+ }
1750
+ }
1751
+
1752
+ // main thread render
1753
+ {
1754
+ __root.__jsx = <Comp />;
1755
+ renderPage();
1756
+ }
1757
+
1758
+ // background render
1759
+ {
1760
+ globalEnvManager.switchToBackground();
1761
+ render(<Comp />, __root);
1762
+ }
1763
+
1764
+ // hydrate
1765
+ {
1766
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1767
+ globalThis.__OnLifecycleEvent.mockClear();
1768
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`
1769
+ [
1770
+ [
1771
+ "[react-ref--2-0]",
1772
+ "fields",
1773
+ [
1774
+ {
1775
+ "id": true,
1776
+ },
1777
+ ],
1778
+ ],
1779
+ [
1780
+ "[react-ref--2-0]",
1781
+ "fields",
1782
+ [
1783
+ {
1784
+ "id": true,
1785
+ },
1786
+ ],
1787
+ ],
1788
+ ]
1789
+ `);
1790
+ lynx.createSelectorQuery().constructor.execLog.mockClear();
1791
+ }
1792
+ });
1793
+
1794
+ it('should forward animation operations via ref proxy', () => {
1795
+ const selectorQueryConstructor = lynx.createSelectorQuery().constructor;
1796
+ selectorQueryConstructor.execLog.mockClear();
1797
+ shouldDelayUiOps.value = true;
1798
+
1799
+ const animations = [{ duration: 350, name: 'fade' }];
1800
+ const animationIds = ['anim-1', 'anim-2'];
1801
+
1802
+ const ref = new RefProxy([-2, 0]);
1803
+
1804
+ ref.animate(animations).exec();
1805
+ ref.playAnimation(animationIds).exec();
1806
+ ref.pauseAnimation('anim-2').exec();
1807
+ ref.cancelAnimation(animationIds).exec();
1808
+
1809
+ expect(selectorQueryConstructor.execLog.mock.calls).toMatchInlineSnapshot(`[]`);
1810
+
1811
+ runDelayedUiOps();
1812
+
1813
+ expect(selectorQueryConstructor.execLog.mock.calls).toMatchInlineSnapshot(`
1814
+ [
1815
+ [
1816
+ "[react-ref--2-0]",
1817
+ "animate",
1818
+ [
1819
+ [
1820
+ {
1821
+ "duration": 350,
1822
+ "name": "fade",
1823
+ },
1824
+ ],
1825
+ ],
1826
+ ],
1827
+ [
1828
+ "[react-ref--2-0]",
1829
+ "playAnimation",
1830
+ [
1831
+ [
1832
+ "anim-1",
1833
+ "anim-2",
1834
+ ],
1835
+ ],
1836
+ ],
1837
+ [
1838
+ "[react-ref--2-0]",
1839
+ "pauseAnimation",
1840
+ [
1841
+ "anim-2",
1842
+ ],
1843
+ ],
1844
+ [
1845
+ "[react-ref--2-0]",
1846
+ "cancelAnimation",
1847
+ [
1848
+ [
1849
+ "anim-1",
1850
+ "anim-2",
1851
+ ],
1852
+ ],
1853
+ ],
1854
+ ]
1855
+ `);
1856
+
1857
+ selectorQueryConstructor.execLog.mockClear();
1858
+ shouldDelayUiOps.value = true;
1859
+ });
1860
+
1861
+ it('should not delay after hydration', async function() {
1862
+ const ref1 = createRef();
1863
+
1864
+ function Comp() {
1865
+ return (
1866
+ <view>
1867
+ <view ref={ref1} />
1868
+ </view>
1869
+ );
1870
+ }
1871
+
1872
+ // main thread render
1873
+ {
1874
+ __root.__jsx = <Comp />;
1875
+ renderPage();
1876
+ }
1877
+
1878
+ // background render
1879
+ {
1880
+ globalEnvManager.switchToBackground();
1881
+ render(<Comp />, __root);
1882
+ }
1883
+
1884
+ // hydrate
1885
+ {
1886
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1887
+ globalThis.__OnLifecycleEvent.mockClear();
1888
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`[]`);
1889
+
1890
+ lynx.createSelectorQuery().constructor.execLog.mockClear();
1891
+ lynx.getNativeApp().callLepusMethod.mockClear();
1892
+ }
1893
+
1894
+ // call ref
1895
+ {
1896
+ ref1.current.invoke({
1897
+ method: 'boundingClientRect',
1898
+ }).exec();
1899
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`
1900
+ [
1901
+ [
1902
+ "[react-ref--2-0]",
1903
+ "invoke",
1904
+ [
1905
+ {
1906
+ "method": "boundingClientRect",
1907
+ },
1908
+ ],
1909
+ ],
1910
+ ]
1911
+ `);
1912
+ }
1913
+ });
1914
+
1915
+ it('should not delay after hydration', async function() {
1916
+ const ref1 = vi.fn((ref) => {
1917
+ ref.invoke({
1918
+ method: 'boundingClientRect',
1919
+ }).exec();
1920
+ });
1921
+
1922
+ let show = false;
1923
+ function Child() {
1924
+ return <view ref={ref1} />;
1925
+ }
1926
+
1927
+ function Comp() {
1928
+ return (
1929
+ <view>
1930
+ {show ? <Child /> : null}
1931
+ </view>
1932
+ );
1933
+ }
1934
+
1935
+ // main thread render
1936
+ {
1937
+ __root.__jsx = <Comp />;
1938
+ renderPage();
1939
+ }
1940
+
1941
+ // background render
1942
+ {
1943
+ globalEnvManager.switchToBackground();
1944
+ render(<Comp />, __root);
1945
+ }
1946
+
1947
+ // hydrate
1948
+ {
1949
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
1950
+ globalThis.__OnLifecycleEvent.mockClear();
1951
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`[]`);
1952
+
1953
+ lynx.createSelectorQuery().constructor.execLog.mockClear();
1954
+ lynx.getNativeApp().callLepusMethod.mockClear();
1955
+ }
1956
+
1957
+ // set show
1958
+ {
1959
+ show = true;
1960
+ render(<Comp />, __root);
1961
+
1962
+ expect(lynx.getNativeApp().callLepusMethod.mock.calls[0][1].data).toMatchInlineSnapshot(
1963
+ `"{"patchList":[{"id":3,"snapshotPatch":[0,"__snapshot_a94a8_test_30",3,4,3,[1],1,-2,3,null,0]}]}"`,
1964
+ );
1965
+ expect(lynx.createSelectorQuery().constructor.execLog.mock.calls).toMatchInlineSnapshot(`
1966
+ [
1967
+ [
1968
+ "[react-ref-3-0]",
1969
+ "invoke",
1970
+ [
1971
+ {
1972
+ "method": "boundingClientRect",
1973
+ },
1974
+ ],
1975
+ ],
1976
+ ]
1977
+ `);
1978
+ }
1979
+ });
1980
+ });
1981
+
1982
+ describe('applyRef before hydration', () => {
1983
+ it('ref is changed across rerenders before hydration', async function() {
1984
+ const oldCb = vi.fn();
1985
+ const newCb = vi.fn();
1986
+
1987
+ function App({ cb }) {
1988
+ return <view ref={cb} />;
1989
+ }
1990
+
1991
+ globalEnvManager.switchToBackground();
1992
+ render(<App cb={oldCb} />, __root);
1993
+ render(<App cb={newCb} />, __root);
1994
+
1995
+ expect(oldCb).toHaveBeenCalledTimes(2);
1996
+ expect(oldCb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
1997
+ expect(oldCb.mock.calls[1][0]).toBeNull();
1998
+
1999
+ expect(newCb).toHaveBeenCalledTimes(1);
2000
+ expect(newCb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2001
+ });
2002
+
2003
+ it('ref becomes null on rerender before hydration', async function() {
2004
+ const cb = vi.fn();
2005
+
2006
+ function App({ useRef }) {
2007
+ return <view ref={useRef ? cb : null} />;
2008
+ }
2009
+
2010
+ globalEnvManager.switchToBackground();
2011
+ render(<App useRef={true} />, __root);
2012
+ render(<App useRef={false} />, __root);
2013
+
2014
+ expect(cb).toHaveBeenCalledTimes(2);
2015
+ expect(cb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2016
+ expect(cb.mock.calls[1][0]).toBeNull();
2017
+ });
2018
+
2019
+ it('ref is added on rerender before hydration', async function() {
2020
+ const cb = vi.fn();
2021
+
2022
+ function App({ useRef }) {
2023
+ return <view ref={useRef ? cb : null} />;
2024
+ }
2025
+
2026
+ globalEnvManager.switchToBackground();
2027
+ render(<App useRef={false} />, __root);
2028
+ render(<App useRef={true} />, __root);
2029
+
2030
+ expect(cb).toHaveBeenCalledTimes(1);
2031
+ expect(cb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2032
+ });
2033
+
2034
+ it('spread ref is removed on rerender before hydration', async function() {
2035
+ const cb = vi.fn();
2036
+
2037
+ function App({ withRef }) {
2038
+ return <view {...(withRef ? { ref: cb } : {})} />;
2039
+ }
2040
+
2041
+ globalEnvManager.switchToBackground();
2042
+ render(<App withRef={true} />, __root);
2043
+ render(<App withRef={false} />, __root);
2044
+
2045
+ expect(cb).toHaveBeenCalledTimes(2);
2046
+ expect(cb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2047
+ expect(cb.mock.calls[1][0]).toBeNull();
2048
+ });
2049
+
2050
+ it('spread ref is added on rerender before hydration', async function() {
2051
+ const cb = vi.fn();
2052
+
2053
+ function App({ withRef }) {
2054
+ return <view {...(withRef ? { ref: cb } : {})} />;
2055
+ }
2056
+
2057
+ globalEnvManager.switchToBackground();
2058
+ render(<App withRef={false} />, __root);
2059
+ render(<App withRef={true} />, __root);
2060
+
2061
+ expect(cb).toHaveBeenCalledTimes(1);
2062
+ expect(cb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2063
+ });
2064
+
2065
+ it('object ref (createRef) is changed across rerenders before hydration', async function() {
2066
+ const oldRef = createRef();
2067
+ const newRef = createRef();
2068
+
2069
+ function App({ r }) {
2070
+ return <view ref={r} />;
2071
+ }
2072
+
2073
+ globalEnvManager.switchToBackground();
2074
+ render(<App r={oldRef} />, __root);
2075
+ expect(oldRef.current).toBeInstanceOf(RefProxy);
2076
+ expect(newRef.current).toBeNull();
2077
+
2078
+ render(<App r={newRef} />, __root);
2079
+ expect(oldRef.current).toBeNull();
2080
+ expect(newRef.current).toBeInstanceOf(RefProxy);
2081
+ });
2082
+
2083
+ it('object ref (createRef) becomes null on rerender before hydration', async function() {
2084
+ const ref = createRef();
2085
+
2086
+ function App({ useRef }) {
2087
+ return <view ref={useRef ? ref : null} />;
2088
+ }
2089
+
2090
+ globalEnvManager.switchToBackground();
2091
+ render(<App useRef={true} />, __root);
2092
+ expect(ref.current).toBeInstanceOf(RefProxy);
2093
+
2094
+ render(<App useRef={false} />, __root);
2095
+ expect(ref.current).toBeNull();
2096
+ });
2097
+
2098
+ it('object ref (createRef) is added on rerender before hydration', async function() {
2099
+ const ref = createRef();
2100
+
2101
+ function App({ useRef }) {
2102
+ return <view ref={useRef ? ref : null} />;
2103
+ }
2104
+
2105
+ globalEnvManager.switchToBackground();
2106
+ render(<App useRef={false} />, __root);
2107
+ expect(ref.current).toBeNull();
2108
+
2109
+ render(<App useRef={true} />, __root);
2110
+ expect(ref.current).toBeInstanceOf(RefProxy);
2111
+ });
2112
+
2113
+ it('same ref callback in spread form should not be re-invoked', async function() {
2114
+ const cb = vi.fn();
2115
+
2116
+ function App() {
2117
+ return <view {...{ ref: cb }} />;
2118
+ }
2119
+
2120
+ globalEnvManager.switchToBackground();
2121
+ render(<App />, __root);
2122
+ render(<App />, __root);
2123
+
2124
+ expect(cb).toHaveBeenCalledTimes(1);
2125
+ expect(cb.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2126
+ });
2127
+
2128
+ it('reports ref callback errors without breaking render', async function() {
2129
+ const error = new Error('ref failed');
2130
+ const cb = vi.fn(() => {
2131
+ throw error;
2132
+ });
2133
+ const reportError = vi.spyOn(lynx, 'reportError');
2134
+
2135
+ function App() {
2136
+ return <view ref={cb} />;
2137
+ }
2138
+
2139
+ globalEnvManager.switchToBackground();
2140
+ expect(() => render(<App />, __root)).not.toThrow();
2141
+
2142
+ expect(reportError).toHaveBeenCalledTimes(1);
2143
+ expect(reportError).toHaveBeenCalledWith(error);
2144
+ });
2145
+
2146
+ it('three consecutive rerenders before hydration clean up intermediate refs', async function() {
2147
+ const cb1 = vi.fn();
2148
+ const cb2 = vi.fn();
2149
+ const cb3 = vi.fn();
2150
+
2151
+ function App({ cb }) {
2152
+ return <view ref={cb} />;
2153
+ }
2154
+
2155
+ globalEnvManager.switchToBackground();
2156
+ render(<App cb={cb1} />, __root);
2157
+ render(<App cb={cb2} />, __root);
2158
+ render(<App cb={cb3} />, __root);
2159
+
2160
+ expect(cb1).toHaveBeenCalledTimes(2);
2161
+ expect(cb1.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2162
+ expect(cb1.mock.calls[1][0]).toBeNull();
2163
+
2164
+ expect(cb2).toHaveBeenCalledTimes(2);
2165
+ expect(cb2.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2166
+ expect(cb2.mock.calls[1][0]).toBeNull();
2167
+
2168
+ expect(cb3).toHaveBeenCalledTimes(1);
2169
+ expect(cb3.mock.calls[0][0]).toBeInstanceOf(RefProxy);
2170
+ });
2171
+ });
2172
+
2173
+ describe.each([false, true])('callback ref bindings (hydrated: %s)', (hydrated) => {
2174
+ function applyMainThreadUpdates() {
2175
+ const updates = lynx.getNativeApp().callLepusMethod.mock.calls.slice();
2176
+ lynx.getNativeApp().callLepusMethod.mockClear();
2177
+ globalEnvManager.switchToMainThread();
2178
+ updates.forEach(([name, data]) => globalThis[name](data));
2179
+ globalEnvManager.switchToBackground();
2180
+ }
2181
+
2182
+ function mount(createJsx) {
2183
+ globalThis.__OnLifecycleEvent.mockClear();
2184
+ lynx.getNativeApp().callLepusMethod.mockClear();
2185
+ if (hydrated) {
2186
+ __root.__jsx = createJsx();
2187
+ renderPage();
2188
+ }
2189
+ globalEnvManager.switchToBackground();
2190
+ render(createJsx(), __root);
2191
+ if (hydrated) {
2192
+ lynx.getApp().OnLifecycleEvent(...globalThis.__OnLifecycleEvent.mock.calls[0]);
2193
+ applyMainThreadUpdates();
2194
+ }
2195
+ }
2196
+
2197
+ function update(jsx) {
2198
+ render(jsx, __root);
2199
+ if (hydrated) {
2200
+ applyMainThreadUpdates();
2201
+ }
2202
+ }
2203
+
2204
+ function trackRefBindings() {
2205
+ const active = new Set();
2206
+ const cleanups = new Map();
2207
+ const callback = vi.fn((node) => {
2208
+ active.add(node);
2209
+ const cleanup = vi.fn(() => {
2210
+ active.delete(node);
2211
+ });
2212
+ cleanups.set(node, cleanup);
2213
+ return cleanup;
2214
+ });
2215
+ return { callback, active, cleanups };
2216
+ }
2217
+
2218
+ it.each([
2219
+ { clearedRef: null, returnsCleanup: false },
2220
+ { clearedRef: undefined, returnsCleanup: false },
2221
+ { clearedRef: null, returnsCleanup: true },
2222
+ { clearedRef: undefined, returnsCleanup: true },
2223
+ ])(
2224
+ 'cleans a callback ref set to $clearedRef (returns cleanup: $returnsCleanup)',
2225
+ ({ clearedRef, returnsCleanup }) => {
2226
+ const cleanup = vi.fn();
2227
+ const callback = vi.fn(() => returnsCleanup ? cleanup : undefined);
2228
+
2229
+ function App({ elementRef }) {
2230
+ return <view ref={elementRef} />;
2231
+ }
2232
+
2233
+ mount(() => <App elementRef={callback} />);
2234
+ expect(callback).toHaveBeenCalledTimes(1);
2235
+ const [[node]] = callback.mock.calls;
2236
+ expect(node).toBeInstanceOf(RefProxy);
2237
+ expect(cleanup).not.toHaveBeenCalled();
2238
+
2239
+ update(<App elementRef={clearedRef} />);
2240
+ const detachedCalls = returnsCleanup ? [[node]] : [[node], [null]];
2241
+ expect(callback.mock.calls).toEqual(detachedCalls);
2242
+ expect(cleanup).toHaveBeenCalledTimes(returnsCleanup ? 1 : 0);
2243
+
2244
+ update(<App elementRef={clearedRef} />);
2245
+ expect(callback.mock.calls).toEqual(detachedCalls);
2246
+ expect(cleanup).toHaveBeenCalledTimes(returnsCleanup ? 1 : 0);
2247
+
2248
+ update(<App elementRef={callback} />);
2249
+ const [reboundNode] = callback.mock.calls.at(-1);
2250
+ expect(reboundNode).toBeInstanceOf(RefProxy);
2251
+ expect(callback.mock.calls).toEqual([...detachedCalls, [reboundNode]]);
2252
+ expect(cleanup).toHaveBeenCalledTimes(returnsCleanup ? 1 : 0);
2253
+
2254
+ update(<App elementRef={clearedRef} />);
2255
+ const finalCalls = [...detachedCalls, [reboundNode], ...(returnsCleanup ? [] : [[null]])];
2256
+ expect(callback.mock.calls).toEqual(finalCalls);
2257
+ expect(cleanup).toHaveBeenCalledTimes(returnsCleanup ? 2 : 0);
2258
+
2259
+ update(null);
2260
+ expect(callback.mock.calls).toEqual(finalCalls);
2261
+ expect(cleanup).toHaveBeenCalledTimes(returnsCleanup ? 2 : 0);
2262
+ },
2263
+ );
2264
+
2265
+ it('replaces one ref slot without cleaning another slot using the same callback', () => {
2266
+ const shared = trackRefBindings();
2267
+ const replacement = trackRefBindings();
2268
+
2269
+ function App({ firstRef }) {
2270
+ return (
2271
+ <view>
2272
+ <view ref={firstRef} />
2273
+ <view ref={shared.callback} />
2274
+ </view>
2275
+ );
2276
+ }
2277
+
2278
+ mount(() => <App firstRef={shared.callback} />);
2279
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2280
+ const [[first], [second]] = shared.callback.mock.calls;
2281
+ expect(first).toBeInstanceOf(RefProxy);
2282
+ expect(second).toBeInstanceOf(RefProxy);
2283
+ expect(first.selector).not.toBe(second.selector);
2284
+ expect(shared.active).toEqual(new Set([first, second]));
2285
+ expect(shared.cleanups.get(first)).not.toHaveBeenCalled();
2286
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2287
+
2288
+ update(<App firstRef={replacement.callback} />);
2289
+ expect(shared.cleanups.get(first)).toHaveBeenCalledTimes(1);
2290
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2291
+ expect(shared.active).toEqual(new Set([second]));
2292
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2293
+ expect(replacement.callback).toHaveBeenCalledTimes(1);
2294
+ const [[replaced]] = replacement.callback.mock.calls;
2295
+ expect(replaced.selector).toBe(first.selector);
2296
+ expect(replacement.active).toEqual(new Set([replaced]));
2297
+
2298
+ update(<App firstRef={replacement.callback} />);
2299
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2300
+ expect(replacement.callback).toHaveBeenCalledTimes(1);
2301
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2302
+ expect(replacement.cleanups.get(replaced)).not.toHaveBeenCalled();
2303
+
2304
+ update(null);
2305
+ expect(shared.cleanups.get(first)).toHaveBeenCalledTimes(1);
2306
+ expect(shared.cleanups.get(second)).toHaveBeenCalledTimes(1);
2307
+ expect(replacement.cleanups.get(replaced)).toHaveBeenCalledTimes(1);
2308
+ expect(shared.active.size).toBe(0);
2309
+ expect(replacement.active.size).toBe(0);
2310
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2311
+ expect(replacement.callback).toHaveBeenCalledTimes(1);
2312
+ });
2313
+
2314
+ it('keeps shared bindings through a keyed move and cleans only the removed item', () => {
2315
+ const shared = trackRefBindings();
2316
+
2317
+ function Item({ id }) {
2318
+ return <view id={id} ref={shared.callback} />;
2319
+ }
2320
+
2321
+ function App({ ids }) {
2322
+ return <view id='items'>{ids.map(id => <Item key={id} id={id} />)}</view>;
2323
+ }
2324
+
2325
+ mount(() => <App ids={['first', 'second']} />);
2326
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2327
+ const [[first], [second]] = shared.callback.mock.calls;
2328
+ expect(shared.active).toEqual(new Set([first, second]));
2329
+ expect(shared.cleanups.get(first)).not.toHaveBeenCalled();
2330
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2331
+
2332
+ update(<App ids={['second', 'first']} />);
2333
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2334
+ expect(shared.active).toEqual(new Set([first, second]));
2335
+ expect(shared.cleanups.get(first)).not.toHaveBeenCalled();
2336
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2337
+ if (hydrated) {
2338
+ expect(elementTree.getElementById('items').children.map(node => node.props.id)).toEqual(['second', 'first']);
2339
+ }
2340
+
2341
+ update(<App ids={['second']} />);
2342
+ expect(shared.cleanups.get(first)).toHaveBeenCalledTimes(1);
2343
+ expect(shared.cleanups.get(second)).not.toHaveBeenCalled();
2344
+ expect(shared.active).toEqual(new Set([second]));
2345
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2346
+ if (hydrated) {
2347
+ expect(elementTree.getElementById('items').children.map(node => node.props.id)).toEqual(['second']);
2348
+ }
2349
+
2350
+ update(null);
2351
+ expect(shared.cleanups.get(first)).toHaveBeenCalledTimes(1);
2352
+ expect(shared.cleanups.get(second)).toHaveBeenCalledTimes(1);
2353
+ expect(shared.active.size).toBe(0);
2354
+ expect(shared.callback).toHaveBeenCalledTimes(2);
2355
+ });
2356
+ });
2357
+
2358
+ describe('runDelayedUiOps helper', () => {
2359
+ it('should reset shouldDelayUiOps when no tasks queued', () => {
2360
+ // flush any queued tasks from previous tests
2361
+ shouldDelayUiOps.value = false;
2362
+ runDelayedUiOps();
2363
+
2364
+ shouldDelayUiOps.value = true;
2365
+ runDelayedUiOps();
2366
+ expect(shouldDelayUiOps.value).toBe(false);
2367
+ });
2368
+ });