@lynx-js/react 0.118.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/package.json +28 -6
  3. package/refresh/.turbo/turbo-build.log +1 -1
  4. package/runtime/lazy/internal.js +3 -0
  5. package/runtime/lib/document.d.ts +4 -4
  6. package/runtime/lib/document.js +14 -12
  7. package/runtime/lib/document.js.map +1 -1
  8. package/runtime/lib/index.d.ts +3 -3
  9. package/runtime/lib/index.js +4 -4
  10. package/runtime/lib/index.js.map +1 -1
  11. package/runtime/lib/internal.d.ts +23 -20
  12. package/runtime/lib/internal.js +27 -23
  13. package/runtime/lib/internal.js.map +1 -1
  14. package/runtime/lib/lynx-api.d.ts +5 -5
  15. package/runtime/lib/lynx-api.js +9 -9
  16. package/runtime/lib/lynx-api.js.map +1 -1
  17. package/runtime/lib/lynx.d.ts +2 -2
  18. package/runtime/lib/lynx.js +17 -17
  19. package/runtime/lib/lynx.js.map +1 -1
  20. package/runtime/lib/root.d.ts +2 -2
  21. package/runtime/lib/root.js +2 -2
  22. package/runtime/lib/root.js.map +1 -1
  23. package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.js +1 -0
  24. package/runtime/lib/snapshot/alog/elementPAPICall.js.map +1 -0
  25. package/runtime/lib/snapshot/alog/index.js.map +1 -0
  26. package/runtime/lib/{alog → snapshot/alog}/render.js +1 -1
  27. package/runtime/lib/snapshot/alog/render.js.map +1 -0
  28. package/runtime/lib/snapshot/compat/componentIs.js.map +1 -0
  29. package/runtime/lib/snapshot/compat/initData.js.map +1 -0
  30. package/runtime/lib/snapshot/compat/lynxComponent.js.map +1 -0
  31. package/runtime/lib/{debug → snapshot/debug}/component-stack.d.ts +0 -6
  32. package/runtime/lib/snapshot/debug/component-stack.js.map +1 -0
  33. package/runtime/lib/snapshot/debug/debug.js.map +1 -0
  34. package/runtime/lib/snapshot/debug/describeInvalidValue.js.map +1 -0
  35. package/runtime/lib/snapshot/debug/formatPatch.js.map +1 -0
  36. package/runtime/lib/snapshot/debug/printSnapshot.js.map +1 -0
  37. package/runtime/lib/{debug → snapshot/debug}/profile.js +1 -1
  38. package/runtime/lib/snapshot/debug/profile.js.map +1 -0
  39. package/runtime/lib/{debug → snapshot/debug}/profileHooks.js +1 -1
  40. package/runtime/lib/snapshot/debug/profileHooks.js.map +1 -0
  41. package/runtime/lib/snapshot/debug/vnodeSource.js.map +1 -0
  42. package/runtime/lib/snapshot/gesture/processGesture.js +172 -0
  43. package/runtime/lib/snapshot/gesture/processGesture.js.map +1 -0
  44. package/runtime/lib/snapshot/gesture/processGestureBagkround.d.ts +9 -0
  45. package/runtime/lib/snapshot/gesture/processGestureBagkround.js +80 -0
  46. package/runtime/lib/snapshot/gesture/processGestureBagkround.js.map +1 -0
  47. package/runtime/lib/snapshot/gesture/types.js.map +1 -0
  48. package/runtime/lib/snapshot/hooks/mainThread.d.ts +17 -0
  49. package/runtime/lib/snapshot/hooks/mainThread.js +152 -0
  50. package/runtime/lib/snapshot/hooks/mainThread.js.map +1 -0
  51. package/runtime/lib/{hooks → snapshot/hooks}/react.d.ts +1 -2
  52. package/runtime/lib/{hooks → snapshot/hooks}/react.js +8 -14
  53. package/runtime/lib/snapshot/hooks/react.js.map +1 -0
  54. package/runtime/lib/snapshot/hooks/useLynxGlobalEventListener.js.map +1 -0
  55. package/runtime/lib/snapshot/index.d.ts +1 -4
  56. package/runtime/lib/snapshot/index.js +2 -5
  57. package/runtime/lib/snapshot/index.js.map +1 -1
  58. package/runtime/lib/snapshot/legacy-react-runtime/index.js.map +1 -0
  59. package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -0
  60. package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.js +1 -1
  61. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -0
  62. package/runtime/lib/snapshot/lifecycle/event/delayEvents.js.map +1 -0
  63. package/runtime/lib/snapshot/lifecycle/event/delayLifecycleEvents.js.map +1 -0
  64. package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.js +4 -2
  65. package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +1 -0
  66. package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.js +1 -1
  67. package/runtime/lib/snapshot/lifecycle/isRendering.js.map +1 -0
  68. package/runtime/lib/snapshot/lifecycle/pass.js.map +1 -0
  69. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.js +1 -1
  70. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -0
  71. package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -0
  72. package/runtime/lib/snapshot/lifecycle/patch/globalState.js.map +1 -0
  73. package/runtime/lib/snapshot/lifecycle/patch/isMainThreadHydrating.js.map +1 -0
  74. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.js +10 -2
  75. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js.map +1 -0
  76. package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.js +2 -0
  77. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -0
  78. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -0
  79. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -0
  80. package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.js +2 -2
  81. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -0
  82. package/runtime/lib/{lifecycle → snapshot/lifecycle}/render.js +1 -7
  83. package/runtime/lib/snapshot/lifecycle/render.js.map +1 -0
  84. package/runtime/lib/{list → snapshot/list}/list.js +1 -1
  85. package/runtime/lib/snapshot/list/list.js.map +1 -0
  86. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -0
  87. package/runtime/lib/snapshot/list/pendingListUpdates.js.map +1 -0
  88. package/runtime/lib/{lynx → snapshot/lynx}/calledByNative.js +2 -2
  89. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -0
  90. package/runtime/lib/snapshot/lynx/component.js.map +1 -0
  91. package/runtime/lib/snapshot/lynx/dynamic-js.js.map +1 -0
  92. package/runtime/lib/{lynx → snapshot/lynx}/env.js +0 -3
  93. package/runtime/lib/snapshot/lynx/env.js.map +1 -0
  94. package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -0
  95. package/runtime/lib/snapshot/lynx/lazy-bundle.js.map +1 -0
  96. package/runtime/lib/{lynx → snapshot/lynx}/performance.js +1 -1
  97. package/runtime/lib/snapshot/lynx/performance.js.map +1 -0
  98. package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.js +1 -1
  99. package/runtime/lib/snapshot/lynx/runWithForce.js.map +1 -0
  100. package/runtime/lib/{lynx → snapshot/lynx}/suspense.js +27 -17
  101. package/runtime/lib/snapshot/lynx/suspense.js.map +1 -0
  102. package/runtime/lib/{lynx → snapshot/lynx}/tt.js +1 -1
  103. package/runtime/lib/snapshot/lynx/tt.js.map +1 -0
  104. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/constants.d.ts +1 -0
  105. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/constants.js +1 -0
  106. package/runtime/lib/snapshot/renderToOpcodes/constants.js.map +1 -0
  107. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.js +21 -4
  108. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -0
  109. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.js +37 -14
  110. package/runtime/lib/snapshot/renderToOpcodes/index.js.map +1 -0
  111. package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.js +4 -2
  112. package/runtime/lib/snapshot/renderToOpcodes/opcodes.js.map +1 -0
  113. package/runtime/lib/snapshot/{backgroundSnapshot.d.ts → snapshot/backgroundSnapshot.d.ts} +1 -0
  114. package/runtime/lib/snapshot/{backgroundSnapshot.js → snapshot/backgroundSnapshot.js} +82 -53
  115. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -0
  116. package/runtime/lib/snapshot/snapshot/constants.js.map +1 -0
  117. package/runtime/lib/snapshot/{definition.d.ts → snapshot/definition.d.ts} +1 -0
  118. package/runtime/lib/snapshot/{definition.js → snapshot/definition.js} +6 -2
  119. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -0
  120. package/runtime/lib/snapshot/{dynamicPartType.d.ts → snapshot/dynamicPartType.d.ts} +2 -0
  121. package/runtime/lib/snapshot/{dynamicPartType.js → snapshot/dynamicPartType.js} +2 -0
  122. package/runtime/lib/snapshot/snapshot/dynamicPartType.js.map +1 -0
  123. package/runtime/lib/snapshot/snapshot/event.js.map +1 -0
  124. package/runtime/lib/snapshot/snapshot/gesture.js.map +1 -0
  125. package/runtime/lib/snapshot/snapshot/index.d.ts +4 -0
  126. package/runtime/lib/snapshot/snapshot/index.js +8 -0
  127. package/runtime/lib/snapshot/snapshot/index.js.map +1 -0
  128. package/runtime/lib/snapshot/snapshot/list.js.map +1 -0
  129. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -0
  130. package/runtime/lib/snapshot/{ref.d.ts → snapshot/ref.d.ts} +1 -0
  131. package/runtime/lib/snapshot/{ref.js → snapshot/ref.js} +13 -1
  132. package/runtime/lib/snapshot/snapshot/ref.js.map +1 -0
  133. package/runtime/lib/snapshot/{snapshot.d.ts → snapshot/snapshot.d.ts} +1 -0
  134. package/runtime/lib/snapshot/{snapshot.js → snapshot/snapshot.js} +28 -8
  135. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -0
  136. package/runtime/lib/snapshot/snapshot/snapshotInstanceHydrationMap.js.map +1 -0
  137. package/runtime/lib/snapshot/{spread.js → snapshot/spread.js} +4 -4
  138. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -0
  139. package/runtime/lib/snapshot/{types.d.ts → snapshot/types.d.ts} +1 -0
  140. package/runtime/lib/snapshot/snapshot/types.js.map +1 -0
  141. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -0
  142. package/runtime/lib/snapshot/snapshot/workletEvent.js.map +1 -0
  143. package/runtime/lib/snapshot/snapshot/workletRef.js.map +1 -0
  144. package/runtime/lib/snapshot/worklet/call/delayedRunOnMainThreadData.js.map +1 -0
  145. package/runtime/lib/snapshot/worklet/call/execMap.js.map +1 -0
  146. package/runtime/lib/snapshot/worklet/call/functionCall.js.map +1 -0
  147. package/runtime/lib/snapshot/worklet/call/runOnBackground.js.map +1 -0
  148. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -0
  149. package/runtime/lib/snapshot/worklet/call/transformToWorklet.js.map +1 -0
  150. package/runtime/lib/snapshot/worklet/ctx.js.map +1 -0
  151. package/runtime/lib/snapshot/worklet/destroy.js.map +1 -0
  152. package/runtime/lib/{worklet → snapshot/worklet}/functionality.js +1 -1
  153. package/runtime/lib/snapshot/worklet/functionality.js.map +1 -0
  154. package/runtime/lib/snapshot/worklet/hmr.js.map +1 -0
  155. package/runtime/lib/snapshot/worklet/indexMap.js.map +1 -0
  156. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -0
  157. package/runtime/lib/snapshot/worklet/ref/workletRef.js.map +1 -0
  158. package/runtime/lib/snapshot/worklet/ref/workletRefPool.js.map +1 -0
  159. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  160. package/runtime/lib/utils.js +1 -1
  161. package/runtime/lib/utils.js.map +1 -1
  162. package/testing-library/README.md +48 -9
  163. package/testing-library/dist/0~123.js +43 -0
  164. package/testing-library/dist/881.js +1 -0
  165. package/testing-library/dist/entry.d.ts +1 -0
  166. package/testing-library/dist/env/index.d.ts +2 -0
  167. package/testing-library/dist/env/index.js +661 -0
  168. package/testing-library/dist/env/rstest.d.ts +1 -0
  169. package/testing-library/dist/env/rstest.js +6 -0
  170. package/testing-library/dist/env/vitest.d.ts +3 -0
  171. package/testing-library/dist/env/vitest.js +8 -662
  172. package/testing-library/dist/fire-event.d.ts +111 -0
  173. package/testing-library/dist/index.d.ts +18 -6
  174. package/testing-library/dist/plugins/index.d.ts +2 -0
  175. package/testing-library/dist/plugins/index.js +282 -0
  176. package/testing-library/dist/plugins/vitest.d.ts +26 -0
  177. package/testing-library/dist/pure.js +4 -4
  178. package/testing-library/dist/rstest-config.d.ts +25 -0
  179. package/testing-library/dist/rstest-config.js +61 -0
  180. package/testing-library/dist/setupFiles/common/bootstrap.js +2 -0
  181. package/testing-library/dist/setupFiles/common/runtime-setup.js +85 -0
  182. package/testing-library/dist/setupFiles/inner/rstest.js +7 -0
  183. package/testing-library/dist/setupFiles/inner/vitest.js +11 -0
  184. package/testing-library/dist/setupFiles/rstest.js +21 -0
  185. package/testing-library/dist/setupFiles/vitest.js +20 -0
  186. package/testing-library/dist/vitest.config.d.ts +6 -0
  187. package/testing-library/dist/vitest.config.js +4 -257
  188. package/transform/dist/wasm.cjs +450 -389
  189. package/transform/index.d.ts +10 -0
  190. package/types/react.docs.d.ts +1 -1
  191. package/runtime/lib/alog/elementPAPICall.js.map +0 -1
  192. package/runtime/lib/alog/index.js.map +0 -1
  193. package/runtime/lib/alog/render.js.map +0 -1
  194. package/runtime/lib/compat/componentIs.js.map +0 -1
  195. package/runtime/lib/compat/initData.js.map +0 -1
  196. package/runtime/lib/compat/lynxComponent.js.map +0 -1
  197. package/runtime/lib/debug/component-stack.js.map +0 -1
  198. package/runtime/lib/debug/debug.js.map +0 -1
  199. package/runtime/lib/debug/describeInvalidValue.js.map +0 -1
  200. package/runtime/lib/debug/formatPatch.js.map +0 -1
  201. package/runtime/lib/debug/printSnapshot.js.map +0 -1
  202. package/runtime/lib/debug/profile.js.map +0 -1
  203. package/runtime/lib/debug/profileHooks.js.map +0 -1
  204. package/runtime/lib/debug/vnodeSource.js.map +0 -1
  205. package/runtime/lib/gesture/processGesture.js +0 -58
  206. package/runtime/lib/gesture/processGesture.js.map +0 -1
  207. package/runtime/lib/gesture/processGestureBagkround.d.ts +0 -2
  208. package/runtime/lib/gesture/processGestureBagkround.js +0 -19
  209. package/runtime/lib/gesture/processGestureBagkround.js.map +0 -1
  210. package/runtime/lib/gesture/types.js.map +0 -1
  211. package/runtime/lib/hooks/react.js.map +0 -1
  212. package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +0 -1
  213. package/runtime/lib/legacy-react-runtime/index.js.map +0 -1
  214. package/runtime/lib/lifecycle/constant.js.map +0 -1
  215. package/runtime/lib/lifecycle/destroy.js.map +0 -1
  216. package/runtime/lib/lifecycle/event/delayEvents.js.map +0 -1
  217. package/runtime/lib/lifecycle/event/delayLifecycleEvents.js.map +0 -1
  218. package/runtime/lib/lifecycle/event/jsReady.js.map +0 -1
  219. package/runtime/lib/lifecycle/isRendering.js.map +0 -1
  220. package/runtime/lib/lifecycle/pass.js.map +0 -1
  221. package/runtime/lib/lifecycle/patch/commit.js.map +0 -1
  222. package/runtime/lib/lifecycle/patch/error.js.map +0 -1
  223. package/runtime/lib/lifecycle/patch/globalState.js.map +0 -1
  224. package/runtime/lib/lifecycle/patch/isMainThreadHydrating.js.map +0 -1
  225. package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +0 -1
  226. package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +0 -1
  227. package/runtime/lib/lifecycle/patch/updateMainThread.js.map +0 -1
  228. package/runtime/lib/lifecycle/ref/delay.js.map +0 -1
  229. package/runtime/lib/lifecycle/reload.js.map +0 -1
  230. package/runtime/lib/lifecycle/render.js.map +0 -1
  231. package/runtime/lib/list/list.js.map +0 -1
  232. package/runtime/lib/list/listUpdateInfo.js.map +0 -1
  233. package/runtime/lib/list/pendingListUpdates.js.map +0 -1
  234. package/runtime/lib/lynx/calledByNative.js.map +0 -1
  235. package/runtime/lib/lynx/component.js.map +0 -1
  236. package/runtime/lib/lynx/dynamic-js.js.map +0 -1
  237. package/runtime/lib/lynx/env.js.map +0 -1
  238. package/runtime/lib/lynx/injectLepusMethods.js.map +0 -1
  239. package/runtime/lib/lynx/lazy-bundle.js.map +0 -1
  240. package/runtime/lib/lynx/performance.js.map +0 -1
  241. package/runtime/lib/lynx/runWithForce.js.map +0 -1
  242. package/runtime/lib/lynx/suspense.js.map +0 -1
  243. package/runtime/lib/lynx/tt.js.map +0 -1
  244. package/runtime/lib/renderToOpcodes/constants.js.map +0 -1
  245. package/runtime/lib/renderToOpcodes/hydrate.js.map +0 -1
  246. package/runtime/lib/renderToOpcodes/index.js.map +0 -1
  247. package/runtime/lib/renderToOpcodes/opcodes.js.map +0 -1
  248. package/runtime/lib/snapshot/backgroundSnapshot.js.map +0 -1
  249. package/runtime/lib/snapshot/constants.js.map +0 -1
  250. package/runtime/lib/snapshot/definition.js.map +0 -1
  251. package/runtime/lib/snapshot/dynamicPartType.js.map +0 -1
  252. package/runtime/lib/snapshot/event.js.map +0 -1
  253. package/runtime/lib/snapshot/gesture.js.map +0 -1
  254. package/runtime/lib/snapshot/list.js.map +0 -1
  255. package/runtime/lib/snapshot/platformInfo.js.map +0 -1
  256. package/runtime/lib/snapshot/ref.js.map +0 -1
  257. package/runtime/lib/snapshot/snapshot.js.map +0 -1
  258. package/runtime/lib/snapshot/snapshotInstanceHydrationMap.js.map +0 -1
  259. package/runtime/lib/snapshot/spread.js.map +0 -1
  260. package/runtime/lib/snapshot/types.js.map +0 -1
  261. package/runtime/lib/snapshot/utils.js.map +0 -1
  262. package/runtime/lib/snapshot/workletEvent.js.map +0 -1
  263. package/runtime/lib/snapshot/workletRef.js.map +0 -1
  264. package/runtime/lib/worklet/call/delayedRunOnMainThreadData.js.map +0 -1
  265. package/runtime/lib/worklet/call/execMap.js.map +0 -1
  266. package/runtime/lib/worklet/call/functionCall.js.map +0 -1
  267. package/runtime/lib/worklet/call/runOnBackground.js.map +0 -1
  268. package/runtime/lib/worklet/call/runOnMainThread.js.map +0 -1
  269. package/runtime/lib/worklet/call/transformToWorklet.js.map +0 -1
  270. package/runtime/lib/worklet/ctx.js.map +0 -1
  271. package/runtime/lib/worklet/destroy.js.map +0 -1
  272. package/runtime/lib/worklet/functionality.js.map +0 -1
  273. package/runtime/lib/worklet/hmr.js.map +0 -1
  274. package/runtime/lib/worklet/indexMap.js.map +0 -1
  275. package/runtime/lib/worklet/ref/updateInitValue.js.map +0 -1
  276. package/runtime/lib/worklet/ref/workletRef.js.map +0 -1
  277. package/runtime/lib/worklet/ref/workletRefPool.js.map +0 -1
  278. package/testing-library/dist/vitest-global-setup.js +0 -134
  279. package/testing-library/types/vitest-config.d.ts +0 -20
  280. /package/runtime/lib/{alog → snapshot/alog}/elementPAPICall.d.ts +0 -0
  281. /package/runtime/lib/{alog → snapshot/alog}/index.d.ts +0 -0
  282. /package/runtime/lib/{alog → snapshot/alog}/index.js +0 -0
  283. /package/runtime/lib/{alog → snapshot/alog}/render.d.ts +0 -0
  284. /package/runtime/lib/{compat → snapshot/compat}/componentIs.d.ts +0 -0
  285. /package/runtime/lib/{compat → snapshot/compat}/componentIs.js +0 -0
  286. /package/runtime/lib/{compat → snapshot/compat}/initData.d.ts +0 -0
  287. /package/runtime/lib/{compat → snapshot/compat}/initData.js +0 -0
  288. /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.d.ts +0 -0
  289. /package/runtime/lib/{compat → snapshot/compat}/lynxComponent.js +0 -0
  290. /package/runtime/lib/{debug → snapshot/debug}/component-stack.js +0 -0
  291. /package/runtime/lib/{debug → snapshot/debug}/debug.d.ts +0 -0
  292. /package/runtime/lib/{debug → snapshot/debug}/debug.js +0 -0
  293. /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.d.ts +0 -0
  294. /package/runtime/lib/{debug → snapshot/debug}/describeInvalidValue.js +0 -0
  295. /package/runtime/lib/{debug → snapshot/debug}/formatPatch.d.ts +0 -0
  296. /package/runtime/lib/{debug → snapshot/debug}/formatPatch.js +0 -0
  297. /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.d.ts +0 -0
  298. /package/runtime/lib/{debug → snapshot/debug}/printSnapshot.js +0 -0
  299. /package/runtime/lib/{debug → snapshot/debug}/profile.d.ts +0 -0
  300. /package/runtime/lib/{debug → snapshot/debug}/profileHooks.d.ts +0 -0
  301. /package/runtime/lib/{debug → snapshot/debug}/vnodeSource.d.ts +0 -0
  302. /package/runtime/lib/{debug → snapshot/debug}/vnodeSource.js +0 -0
  303. /package/runtime/lib/{gesture → snapshot/gesture}/processGesture.d.ts +0 -0
  304. /package/runtime/lib/{gesture → snapshot/gesture}/types.d.ts +0 -0
  305. /package/runtime/lib/{gesture → snapshot/gesture}/types.js +0 -0
  306. /package/runtime/lib/{hooks → snapshot/hooks}/useLynxGlobalEventListener.d.ts +0 -0
  307. /package/runtime/lib/{hooks → snapshot/hooks}/useLynxGlobalEventListener.js +0 -0
  308. /package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.d.ts +0 -0
  309. /package/runtime/lib/{legacy-react-runtime → snapshot/legacy-react-runtime}/index.js +0 -0
  310. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.d.ts +0 -0
  311. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/constant.js +0 -0
  312. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/destroy.d.ts +0 -0
  313. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.d.ts +0 -0
  314. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayEvents.js +0 -0
  315. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.d.ts +0 -0
  316. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/delayLifecycleEvents.js +0 -0
  317. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/event/jsReady.d.ts +0 -0
  318. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/isRendering.d.ts +0 -0
  319. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.d.ts +0 -0
  320. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/pass.js +0 -0
  321. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/commit.d.ts +0 -0
  322. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.d.ts +0 -0
  323. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/error.js +0 -0
  324. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.d.ts +0 -0
  325. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/globalState.js +0 -0
  326. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.d.ts +0 -0
  327. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/isMainThreadHydrating.js +0 -0
  328. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatch.d.ts +0 -0
  329. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/snapshotPatchApply.d.ts +0 -0
  330. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.d.ts +0 -0
  331. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/patch/updateMainThread.js +0 -0
  332. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.d.ts +0 -0
  333. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/ref/delay.js +0 -0
  334. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/reload.d.ts +0 -0
  335. /package/runtime/lib/{lifecycle → snapshot/lifecycle}/render.d.ts +0 -0
  336. /package/runtime/lib/{list → snapshot/list}/list.d.ts +0 -0
  337. /package/runtime/lib/{list → snapshot/list}/listUpdateInfo.d.ts +0 -0
  338. /package/runtime/lib/{list → snapshot/list}/listUpdateInfo.js +0 -0
  339. /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.d.ts +0 -0
  340. /package/runtime/lib/{list → snapshot/list}/pendingListUpdates.js +0 -0
  341. /package/runtime/lib/{lynx → snapshot/lynx}/calledByNative.d.ts +0 -0
  342. /package/runtime/lib/{lynx → snapshot/lynx}/component.d.ts +0 -0
  343. /package/runtime/lib/{lynx → snapshot/lynx}/component.js +0 -0
  344. /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.d.ts +0 -0
  345. /package/runtime/lib/{lynx → snapshot/lynx}/dynamic-js.js +0 -0
  346. /package/runtime/lib/{lynx → snapshot/lynx}/env.d.ts +0 -0
  347. /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.d.ts +0 -0
  348. /package/runtime/lib/{lynx → snapshot/lynx}/injectLepusMethods.js +0 -0
  349. /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.d.ts +0 -0
  350. /package/runtime/lib/{lynx → snapshot/lynx}/lazy-bundle.js +0 -0
  351. /package/runtime/lib/{lynx → snapshot/lynx}/performance.d.ts +0 -0
  352. /package/runtime/lib/{lynx → snapshot/lynx}/runWithForce.d.ts +0 -0
  353. /package/runtime/lib/{lynx → snapshot/lynx}/suspense.d.ts +0 -0
  354. /package/runtime/lib/{lynx → snapshot/lynx}/tt.d.ts +0 -0
  355. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/hydrate.d.ts +0 -0
  356. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/index.d.ts +0 -0
  357. /package/runtime/lib/{renderToOpcodes → snapshot/renderToOpcodes}/opcodes.d.ts +0 -0
  358. /package/runtime/lib/snapshot/{constants.d.ts → snapshot/constants.d.ts} +0 -0
  359. /package/runtime/lib/snapshot/{constants.js → snapshot/constants.js} +0 -0
  360. /package/runtime/lib/snapshot/{event.d.ts → snapshot/event.d.ts} +0 -0
  361. /package/runtime/lib/snapshot/{event.js → snapshot/event.js} +0 -0
  362. /package/runtime/lib/snapshot/{gesture.d.ts → snapshot/gesture.d.ts} +0 -0
  363. /package/runtime/lib/snapshot/{gesture.js → snapshot/gesture.js} +0 -0
  364. /package/runtime/lib/snapshot/{list.d.ts → snapshot/list.d.ts} +0 -0
  365. /package/runtime/lib/snapshot/{list.js → snapshot/list.js} +0 -0
  366. /package/runtime/lib/snapshot/{platformInfo.d.ts → snapshot/platformInfo.d.ts} +0 -0
  367. /package/runtime/lib/snapshot/{platformInfo.js → snapshot/platformInfo.js} +0 -0
  368. /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.d.ts → snapshot/snapshotInstanceHydrationMap.d.ts} +0 -0
  369. /package/runtime/lib/snapshot/{snapshotInstanceHydrationMap.js → snapshot/snapshotInstanceHydrationMap.js} +0 -0
  370. /package/runtime/lib/snapshot/{spread.d.ts → snapshot/spread.d.ts} +0 -0
  371. /package/runtime/lib/snapshot/{types.js → snapshot/types.js} +0 -0
  372. /package/runtime/lib/snapshot/{utils.d.ts → snapshot/utils.d.ts} +0 -0
  373. /package/runtime/lib/snapshot/{utils.js → snapshot/utils.js} +0 -0
  374. /package/runtime/lib/snapshot/{workletEvent.d.ts → snapshot/workletEvent.d.ts} +0 -0
  375. /package/runtime/lib/snapshot/{workletEvent.js → snapshot/workletEvent.js} +0 -0
  376. /package/runtime/lib/snapshot/{workletRef.d.ts → snapshot/workletRef.d.ts} +0 -0
  377. /package/runtime/lib/snapshot/{workletRef.js → snapshot/workletRef.js} +0 -0
  378. /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.d.ts +0 -0
  379. /package/runtime/lib/{worklet → snapshot/worklet}/call/delayedRunOnMainThreadData.js +0 -0
  380. /package/runtime/lib/{worklet → snapshot/worklet}/call/execMap.d.ts +0 -0
  381. /package/runtime/lib/{worklet → snapshot/worklet}/call/execMap.js +0 -0
  382. /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.d.ts +0 -0
  383. /package/runtime/lib/{worklet → snapshot/worklet}/call/functionCall.js +0 -0
  384. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.d.ts +0 -0
  385. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnBackground.js +0 -0
  386. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.d.ts +0 -0
  387. /package/runtime/lib/{worklet → snapshot/worklet}/call/runOnMainThread.js +0 -0
  388. /package/runtime/lib/{worklet → snapshot/worklet}/call/transformToWorklet.d.ts +0 -0
  389. /package/runtime/lib/{worklet → snapshot/worklet}/call/transformToWorklet.js +0 -0
  390. /package/runtime/lib/{worklet → snapshot/worklet}/ctx.d.ts +0 -0
  391. /package/runtime/lib/{worklet → snapshot/worklet}/ctx.js +0 -0
  392. /package/runtime/lib/{worklet → snapshot/worklet}/destroy.d.ts +0 -0
  393. /package/runtime/lib/{worklet → snapshot/worklet}/destroy.js +0 -0
  394. /package/runtime/lib/{worklet → snapshot/worklet}/functionality.d.ts +0 -0
  395. /package/runtime/lib/{worklet → snapshot/worklet}/hmr.d.ts +0 -0
  396. /package/runtime/lib/{worklet → snapshot/worklet}/hmr.js +0 -0
  397. /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.d.ts +0 -0
  398. /package/runtime/lib/{worklet → snapshot/worklet}/indexMap.js +0 -0
  399. /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.d.ts +0 -0
  400. /package/runtime/lib/{worklet → snapshot/worklet}/ref/updateInitValue.js +0 -0
  401. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.d.ts +0 -0
  402. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRef.js +0 -0
  403. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.d.ts +0 -0
  404. /package/runtime/lib/{worklet → snapshot/worklet}/ref/workletRefPool.js +0 -0
@@ -0,0 +1,85 @@
1
+ import { options } from "preact";
2
+ import { clearCommitTaskId, replaceCommitHook } from "../../../../runtime/lib/snapshot/lifecycle/patch/commit.js";
3
+ import { deinitGlobalSnapshotPatch } from "../../../../runtime/lib/snapshot/lifecycle/patch/snapshotPatch.js";
4
+ import { injectUpdateMainThread } from "../../../../runtime/lib/snapshot/lifecycle/patch/updateMainThread.js";
5
+ import { injectUpdateMTRefInitValue } from "../../../../runtime/lib/snapshot/worklet/ref/updateInitValue.js";
6
+ import { injectCalledByNative } from "../../../../runtime/lib/snapshot/lynx/calledByNative.js";
7
+ import { flushDelayedLifecycleEvents, injectTt } from "../../../../runtime/lib/snapshot/lynx/tt.js";
8
+ import { initElementPAPICallAlog } from "../../../../runtime/lib/snapshot/alog/elementPAPICall.js";
9
+ import { addCtxNotFoundEventListener } from "../../../../runtime/lib/snapshot/lifecycle/patch/error.js";
10
+ import { setRoot } from "../../../../runtime/lib/root.js";
11
+ import { BackgroundSnapshotInstance, SnapshotInstance, backgroundSnapshotInstanceManager, snapshotInstanceManager } from "../../../../runtime/lib/snapshot/index.js";
12
+ import { destroyWorklet } from "../../../../runtime/lib/snapshot/worklet/destroy.js";
13
+ import { initApiEnv } from "../../../../runtime/lib/worklet-runtime/api/lynxApi.js";
14
+ import { initEventListeners } from "../../../../runtime/lib/worklet-runtime/listeners.js";
15
+ import { initWorklet } from "../../../../runtime/lib/worklet-runtime/workletRuntime.js";
16
+ import { setupBackgroundDocument, setupDocument } from "../../../../runtime/lib/document.js";
17
+ const { onInjectMainThreadGlobals, onInjectBackgroundThreadGlobals, onResetLynxTestingEnv, onSwitchedToMainThread, onSwitchedToBackgroundThread, onInitWorkletRuntime } = globalThis;
18
+ injectCalledByNative();
19
+ injectUpdateMainThread();
20
+ injectUpdateMTRefInitValue();
21
+ replaceCommitHook();
22
+ globalThis.onInitWorkletRuntime = ()=>{
23
+ if (onInitWorkletRuntime) onInitWorkletRuntime();
24
+ lynx.setTimeout = setTimeout;
25
+ lynx.setInterval = setInterval;
26
+ lynx.clearTimeout = clearTimeout;
27
+ lynx.clearInterval = clearInterval;
28
+ initWorklet();
29
+ initApiEnv();
30
+ initEventListeners();
31
+ return true;
32
+ };
33
+ globalThis.onInjectMainThreadGlobals = (target)=>{
34
+ if (onInjectMainThreadGlobals) onInjectMainThreadGlobals(target);
35
+ snapshotInstanceManager.clear();
36
+ snapshotInstanceManager.nextId = 0;
37
+ target.__root = new SnapshotInstance('root');
38
+ target._document = {};
39
+ setupDocument(target._document);
40
+ target.globalPipelineOptions = void 0;
41
+ if (void 0 !== target.__ALOG_ELEMENT_API__ && target.__ALOG_ELEMENT_API__ && !target.__initElementPAPICallAlogInjected) {
42
+ initElementPAPICallAlog(target);
43
+ target.__initElementPAPICallAlogInjected = true;
44
+ }
45
+ };
46
+ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
47
+ if (onInjectBackgroundThreadGlobals) onInjectBackgroundThreadGlobals(target);
48
+ backgroundSnapshotInstanceManager.clear();
49
+ backgroundSnapshotInstanceManager.nextId = 0;
50
+ target.__root = new BackgroundSnapshotInstance('root');
51
+ target._document = {};
52
+ setupBackgroundDocument(target._document);
53
+ target.globalPipelineOptions = void 0;
54
+ const oldLynxCoreInject = globalThis.lynxCoreInject;
55
+ globalThis.lynxCoreInject = target.lynxCoreInject;
56
+ try {
57
+ injectTt();
58
+ } finally{
59
+ globalThis.lynxCoreInject = oldLynxCoreInject;
60
+ }
61
+ deinitGlobalSnapshotPatch();
62
+ clearCommitTaskId();
63
+ };
64
+ globalThis.onResetLynxTestingEnv = ()=>{
65
+ if (onResetLynxTestingEnv) onResetLynxTestingEnv();
66
+ flushDelayedLifecycleEvents();
67
+ destroyWorklet();
68
+ lynxTestingEnv.switchToMainThread();
69
+ initEventListeners();
70
+ lynxTestingEnv.switchToBackgroundThread();
71
+ injectTt();
72
+ addCtxNotFoundEventListener();
73
+ };
74
+ globalThis.onSwitchedToMainThread = ()=>{
75
+ if (onSwitchedToMainThread) onSwitchedToMainThread();
76
+ setRoot(globalThis.__root);
77
+ options.document = globalThis._document;
78
+ };
79
+ globalThis.onSwitchedToBackgroundThread = ()=>{
80
+ if (onSwitchedToBackgroundThread) onSwitchedToBackgroundThread();
81
+ setRoot(globalThis.__root);
82
+ options.document = globalThis._document;
83
+ };
84
+ globalThis.onInjectMainThreadGlobals(globalThis.lynxTestingEnv.mainThread.globalThis);
85
+ globalThis.onInjectBackgroundThreadGlobals(globalThis.lynxTestingEnv.backgroundThread.globalThis);
@@ -0,0 +1,7 @@
1
+ const { onInjectBackgroundThreadGlobals } = globalThis;
2
+ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
3
+ if (onInjectBackgroundThreadGlobals) onInjectBackgroundThreadGlobals(target);
4
+ target.lynx.requireModuleAsync = async (url, _callback)=>{
5
+ throw new Error('lynx.requireModuleAsync not implemented for rstest');
6
+ };
7
+ };
@@ -0,0 +1,11 @@
1
+ const { onInjectBackgroundThreadGlobals } = globalThis;
2
+ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
3
+ if (onInjectBackgroundThreadGlobals) onInjectBackgroundThreadGlobals(target);
4
+ target.lynx.requireModuleAsync = async (url, callback)=>{
5
+ try {
6
+ callback(null, await __vite_ssr_dynamic_import__(url));
7
+ } catch (err) {
8
+ callback(err, null);
9
+ }
10
+ };
11
+ };
@@ -0,0 +1,21 @@
1
+ import "../env/rstest.js";
2
+ import "./common/runtime-setup.js";
3
+ import "./inner/rstest.js";
4
+ import "./common/bootstrap.js";
5
+ import { expect } from "@rstest/core";
6
+ expect.addSnapshotSerializer({
7
+ test (val) {
8
+ return Boolean(val && 'object' == typeof val && Array.isArray(val.refAttr) && Object.prototype.hasOwnProperty.call(val, 'task') && 'function' == typeof val.exec);
9
+ },
10
+ print (val, serialize) {
11
+ const printed = serialize({
12
+ refAttr: Array.isArray(val.refAttr) ? [
13
+ ...val.refAttr
14
+ ] : val.refAttr,
15
+ task: val.task
16
+ });
17
+ if (printed.startsWith('Object')) return printed.replace(/^Object/, 'RefProxy');
18
+ if (printed.startsWith('{')) return `RefProxy ${printed}`;
19
+ return printed;
20
+ }
21
+ });
@@ -0,0 +1,20 @@
1
+ import "./common/runtime-setup.js";
2
+ import "./inner/vitest.js";
3
+ import "./common/bootstrap.js";
4
+ import { expect } from "vitest";
5
+ expect.addSnapshotSerializer({
6
+ test (val) {
7
+ return Boolean(val && 'object' == typeof val && Array.isArray(val.refAttr) && Object.prototype.hasOwnProperty.call(val, 'task') && 'function' == typeof val.exec);
8
+ },
9
+ print (val, serialize) {
10
+ const printed = serialize({
11
+ refAttr: Array.isArray(val.refAttr) ? [
12
+ ...val.refAttr
13
+ ] : val.refAttr,
14
+ task: val.task
15
+ });
16
+ if (printed.startsWith('Object')) return printed.replace(/^Object/, 'RefProxy');
17
+ if (printed.startsWith('{')) return `RefProxy ${printed}`;
18
+ return printed;
19
+ }
20
+ });
@@ -0,0 +1,6 @@
1
+ import { type ViteUserConfig } from 'vitest/config';
2
+ import type { TestingLibraryOptions } from './plugins/index.js';
3
+ /**
4
+ * @deprecated Use `vitestTestingLibraryPlugin` from `@lynx-js/react/testing-library/plugins` instead.
5
+ */
6
+ export declare function createVitestConfig(options?: TestingLibraryOptions): ViteUserConfig;
@@ -1,263 +1,10 @@
1
1
  import { defineConfig } from "vitest/config";
2
- import { VitestPackageInstaller } from "vitest/node";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- import { createRequire } from "module";
6
- const vitest_config_filename = fileURLToPath(import.meta.url);
7
- const vitest_config_dirname = path.dirname(vitest_config_filename);
8
- const vitest_config_require = createRequire(import.meta.url);
9
- async function ensurePackagesInstalled() {
10
- const installer = new VitestPackageInstaller();
11
- const installed = await installer.ensureInstalled('jsdom', process.cwd());
12
- if (!installed) {
13
- console.log('ReactLynx Testing Library requires jsdom to be installed.');
14
- process.exit(1);
15
- }
16
- }
17
- const createVitestConfig = async (options)=>{
18
- await ensurePackagesInstalled();
19
- const runtimeOSSPkgName = '@lynx-js/react';
20
- const runtimePkgName = options?.runtimePkgName ?? runtimeOSSPkgName;
21
- const runtimeDir = path.dirname(vitest_config_require.resolve(`${runtimePkgName}/package.json`));
22
- const runtimeOSSDir = path.dirname(vitest_config_require.resolve(`${runtimeOSSPkgName}/package.json`, {
23
- paths: [
24
- runtimeDir,
25
- vitest_config_dirname
26
- ]
27
- }));
28
- const preactDir = path.dirname(vitest_config_require.resolve('preact/package.json', {
29
- paths: [
30
- runtimeOSSDir
31
- ]
32
- }));
33
- const generateAlias = (pkgName, pkgDir, resolveDir)=>{
34
- const pkgExports = vitest_config_require(path.join(pkgDir, 'package.json')).exports;
35
- const pkgAlias = [];
36
- Object.keys(pkgExports).forEach((key)=>{
37
- const name = path.posix.join(pkgName, key);
38
- pkgAlias.push({
39
- find: new RegExp('^' + name + '$'),
40
- replacement: vitest_config_require.resolve(name, {
41
- paths: [
42
- resolveDir,
43
- vitest_config_dirname
44
- ]
45
- })
46
- });
47
- });
48
- return pkgAlias;
49
- };
50
- const runtimeOSSAlias = generateAlias(runtimeOSSPkgName, runtimeOSSDir, runtimeDir);
51
- let runtimeAlias = [];
52
- if (runtimePkgName !== runtimeOSSPkgName) runtimeAlias = generateAlias(runtimePkgName, runtimeDir, vitest_config_dirname);
53
- const preactAlias = generateAlias('preact', preactDir, runtimeOSSDir);
54
- preactAlias.forEach((alias)=>{
55
- alias.replacement = alias.replacement.replace(/\.js$/, '.mjs');
56
- });
57
- const reactAlias = [
58
- {
59
- find: /^react$/,
60
- replacement: vitest_config_require.resolve(runtimeOSSPkgName, {
61
- paths: [
62
- runtimeDir,
63
- vitest_config_dirname
64
- ]
65
- })
66
- },
67
- {
68
- find: /^react\/jsx-runtime$/,
69
- replacement: vitest_config_require.resolve(path.posix.join(runtimeOSSPkgName, 'jsx-runtime'), {
70
- paths: [
71
- runtimeDir,
72
- vitest_config_dirname
73
- ]
74
- })
75
- },
76
- {
77
- find: /^react\/jsx-dev-runtime$/,
78
- replacement: vitest_config_require.resolve(path.posix.join(runtimeOSSPkgName, 'jsx-dev-runtime'), {
79
- paths: [
80
- runtimeDir,
81
- vitest_config_dirname
82
- ]
83
- })
84
- }
85
- ];
86
- function transformReactCompilerPlugin() {
87
- let rootContext, compilerDeps, babel;
88
- function resolveCompilerDeps(rootContext) {
89
- const missingBabelPackages = [];
90
- const [babelPath, babelPluginReactCompilerPath, babelPluginSyntaxJsxPath, babelPluginSyntaxTypescriptPath] = [
91
- '@babel/core',
92
- 'babel-plugin-react-compiler',
93
- '@babel/plugin-syntax-jsx',
94
- "@babel/plugin-syntax-typescript"
95
- ].map((name)=>{
96
- try {
97
- return vitest_config_require.resolve(name, {
98
- paths: [
99
- rootContext
100
- ]
101
- });
102
- } catch {
103
- missingBabelPackages.push(name);
104
- }
105
- return '';
106
- });
107
- if (missingBabelPackages.length > 0) throw new Error(`With \`experimental_enableReactCompiler\` enabled, you need to install \`${missingBabelPackages.join('`, `')}\` in your project root to use React Compiler.`);
108
- return {
109
- babelPath,
110
- babelPluginReactCompilerPath,
111
- babelPluginSyntaxJsxPath,
112
- babelPluginSyntaxTypescriptPath
113
- };
114
- }
115
- return {
116
- name: 'transformReactCompilerPlugin',
117
- enforce: 'pre',
118
- config (config) {
119
- rootContext = config.root;
120
- const reactCompilerRuntimeAlias = [];
121
- try {
122
- reactCompilerRuntimeAlias.push({
123
- find: /^react-compiler-runtime$/,
124
- replacement: path.join(path.dirname(vitest_config_require.resolve('react-compiler-runtime/package.json', {
125
- paths: [
126
- rootContext
127
- ]
128
- })), 'src', 'index.ts')
129
- });
130
- } catch (e) {}
131
- config.test.alias.push(...reactCompilerRuntimeAlias);
132
- compilerDeps = resolveCompilerDeps(rootContext);
133
- const { babelPath } = compilerDeps;
134
- babel = vitest_config_require(babelPath);
135
- },
136
- async transform (sourceText, sourcePath) {
137
- if (/\.(?:jsx|tsx)$/.test(sourcePath)) {
138
- const { babelPluginReactCompilerPath, babelPluginSyntaxJsxPath, babelPluginSyntaxTypescriptPath } = compilerDeps;
139
- const isTSX = sourcePath.endsWith('.tsx');
140
- try {
141
- const result = babel.transformSync(sourceText, {
142
- plugins: [
143
- [
144
- babelPluginReactCompilerPath,
145
- {
146
- target: '17'
147
- }
148
- ],
149
- babelPluginSyntaxJsxPath,
150
- isTSX ? [
151
- babelPluginSyntaxTypescriptPath,
152
- {
153
- isTSX: true
154
- }
155
- ] : null
156
- ].filter(Boolean),
157
- filename: sourcePath,
158
- ast: false,
159
- sourceMaps: true
160
- });
161
- if (result?.code != null && result?.map != null) return {
162
- code: result.code,
163
- map: result.map
164
- };
165
- this.error(`babel-plugin-react-compiler transform failed for ${sourcePath}: ${result ? 'missing code or map' : 'no result'}`);
166
- } catch (e) {
167
- this.error(e);
168
- }
169
- }
170
- return null;
171
- }
172
- };
173
- }
174
- function transformReactLynxPlugin() {
175
- return {
176
- name: 'transformReactLynxPlugin',
177
- enforce: 'pre',
178
- transform (sourceText, sourcePath) {
179
- const id = sourcePath;
180
- const regex = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)(\?.*)?$/;
181
- if (!regex.test(id)) return null;
182
- const { transformReactLynxSync } = vitest_config_require('@lynx-js/react/transform');
183
- const relativePath = normalizeSlashes(path.relative(vitest_config_dirname, sourcePath));
184
- const basename = path.basename(sourcePath);
185
- const result = transformReactLynxSync(sourceText, {
186
- mode: 'test',
187
- pluginName: '',
188
- filename: basename,
189
- sourcemap: true,
190
- snapshot: {
191
- preserveJsx: false,
192
- runtimePkg: `${runtimePkgName}/internal`,
193
- jsxImportSource: runtimePkgName,
194
- filename: relativePath,
195
- target: 'MIXED'
196
- },
197
- engineVersion: options?.engineVersion ?? '',
198
- dynamicImport: {
199
- injectLazyBundle: false,
200
- layer: 'test',
201
- runtimePkg: `${runtimePkgName}/internal`
202
- },
203
- directiveDCE: false,
204
- defineDCE: false,
205
- shake: false,
206
- compat: false,
207
- worklet: {
208
- filename: relativePath,
209
- runtimePkg: `${runtimePkgName}/internal`,
210
- target: 'MIXED'
211
- },
212
- refresh: false,
213
- cssScope: false
214
- });
215
- if (result.errors.length > 0) result.errors.forEach((error)=>{
216
- this.error(error.text, error.location);
217
- });
218
- if (result.warnings.length > 0) result.warnings.forEach((warning)=>{
219
- this.warn(warning.text, warning.location);
220
- });
221
- return {
222
- code: result.code,
223
- map: result.map
224
- };
225
- }
226
- };
227
- }
2
+ import { vitestTestingLibraryPlugin } from "./plugins/index.js";
3
+ function createVitestConfig(options) {
228
4
  return defineConfig({
229
- server: {
230
- fs: {
231
- allow: [
232
- path.join(vitest_config_dirname, '..')
233
- ]
234
- }
235
- },
236
5
  plugins: [
237
- ...options?.experimental_enableReactCompiler ? [
238
- transformReactCompilerPlugin()
239
- ] : [],
240
- transformReactLynxPlugin()
241
- ],
242
- test: {
243
- environment: vitest_config_require.resolve('./env/vitest'),
244
- globals: true,
245
- setupFiles: [
246
- path.join(vitest_config_dirname, 'vitest-global-setup')
247
- ],
248
- alias: [
249
- ...runtimeOSSAlias,
250
- ...runtimeAlias,
251
- ...preactAlias,
252
- ...reactAlias
253
- ],
254
- include: options?.include ?? [
255
- 'src/**/*.test.{js,jsx,ts,tsx}'
256
- ]
257
- }
6
+ vitestTestingLibraryPlugin(options)
7
+ ]
258
8
  });
259
- };
260
- function normalizeSlashes(file) {
261
- return file.replaceAll(path.win32.sep, '/');
262
9
  }
263
10
  export { createVitestConfig };