vxrn 0.1.50 → 0.1.52

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 (330) hide show
  1. package/dist/cjs/exports/bindKeypressInput.js +58 -0
  2. package/dist/cjs/exports/bindKeypressInput.js.map +6 -0
  3. package/dist/cjs/exports/bindKeypressInput.native.js +63 -0
  4. package/dist/cjs/exports/bindKeypressInput.native.js.map +6 -0
  5. package/dist/cjs/exports/build.js +26 -93
  6. package/dist/cjs/exports/build.js.map +2 -2
  7. package/dist/cjs/exports/build.native.js +70 -360
  8. package/dist/cjs/exports/build.native.js.map +2 -2
  9. package/dist/cjs/exports/coerceToArray.js +23 -0
  10. package/dist/cjs/exports/coerceToArray.js.map +6 -0
  11. package/dist/cjs/exports/connectedNativeClients.js +21 -0
  12. package/dist/cjs/exports/connectedNativeClients.js.map +6 -0
  13. package/dist/cjs/exports/dev.js +10 -416
  14. package/dist/cjs/exports/dev.js.map +2 -2
  15. package/dist/cjs/exports/dev.native.js +16 -732
  16. package/dist/cjs/exports/dev.native.js.map +2 -2
  17. package/dist/cjs/exports/entryRoot.js +69 -0
  18. package/dist/cjs/exports/entryRoot.js.map +6 -0
  19. package/dist/cjs/exports/getIndexJsonResponse.js +71 -0
  20. package/dist/cjs/exports/getIndexJsonResponse.js.map +6 -0
  21. package/dist/cjs/exports/getIndexJsonResponse.native.js +99 -0
  22. package/dist/cjs/exports/getIndexJsonResponse.native.js.map +6 -0
  23. package/dist/cjs/exports/getReactNativeBundle.js +160 -0
  24. package/dist/cjs/exports/getReactNativeBundle.js.map +6 -0
  25. package/dist/cjs/exports/getViteServerConfig.js +77 -0
  26. package/dist/cjs/exports/getViteServerConfig.js.map +6 -0
  27. package/dist/cjs/exports/getViteServerConfig.native.js +253 -0
  28. package/dist/cjs/exports/getViteServerConfig.native.js.map +6 -0
  29. package/dist/cjs/exports/hotUpdateCache.js +21 -0
  30. package/dist/cjs/exports/hotUpdateCache.js.map +6 -0
  31. package/dist/cjs/exports/isBuildingNativeBundle.js +21 -0
  32. package/dist/cjs/exports/isBuildingNativeBundle.js.map +6 -0
  33. package/dist/cjs/exports/isWithin.js +25 -0
  34. package/dist/cjs/exports/isWithin.js.map +6 -0
  35. package/dist/cjs/exports/reactNativeHMRPlugin.js +69 -0
  36. package/dist/cjs/exports/reactNativeHMRPlugin.js.map +6 -0
  37. package/dist/cjs/exports/resolveFile.js +28 -0
  38. package/dist/cjs/exports/resolveFile.js.map +6 -0
  39. package/dist/cjs/exports/resolveFile.native.js +34 -0
  40. package/dist/cjs/exports/resolveFile.native.js.map +6 -0
  41. package/dist/cjs/exports/serve.js +1 -1
  42. package/dist/cjs/exports/serve.js.map +1 -1
  43. package/dist/cjs/exports/serve.native.js +1 -1
  44. package/dist/cjs/exports/serve.native.js.map +1 -1
  45. package/dist/cjs/exports/swapPrebuiltReactModules.js +100 -0
  46. package/dist/cjs/exports/swapPrebuiltReactModules.js.map +6 -0
  47. package/dist/cjs/exports/uniq.js +23 -0
  48. package/dist/cjs/exports/uniq.js.map +6 -0
  49. package/dist/cjs/index.js +4 -0
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/index.native.js +8 -0
  52. package/dist/cjs/index.native.js.map +1 -1
  53. package/dist/cjs/plugins/reactNativeCommonJsPlugin.js.map +1 -1
  54. package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  55. package/dist/cjs/plugins/reactNativeHMRPlugin.js +67 -0
  56. package/dist/cjs/plugins/reactNativeHMRPlugin.js.map +6 -0
  57. package/dist/cjs/plugins/reactNativeHMRPlugin.native.js +307 -0
  58. package/dist/cjs/plugins/reactNativeHMRPlugin.native.js.map +6 -0
  59. package/dist/cjs/types.native.js.map +1 -1
  60. package/dist/cjs/utils/bindKeypressInput.js +58 -0
  61. package/dist/cjs/utils/bindKeypressInput.js.map +6 -0
  62. package/dist/cjs/utils/bindKeypressInput.native.js +63 -0
  63. package/dist/cjs/utils/bindKeypressInput.native.js.map +6 -0
  64. package/dist/cjs/utils/coerceToArray.js +23 -0
  65. package/dist/cjs/utils/coerceToArray.js.map +6 -0
  66. package/dist/cjs/utils/coerceToArray.native.js +30 -0
  67. package/dist/cjs/utils/coerceToArray.native.js.map +6 -0
  68. package/dist/cjs/utils/connectedNativeClients.js +29 -0
  69. package/dist/cjs/utils/connectedNativeClients.js.map +6 -0
  70. package/dist/cjs/utils/connectedNativeClients.native.js +36 -0
  71. package/dist/cjs/utils/connectedNativeClients.native.js.map +6 -0
  72. package/dist/cjs/utils/getIndexJsonResponse.js +71 -0
  73. package/dist/cjs/utils/getIndexJsonResponse.js.map +6 -0
  74. package/dist/cjs/utils/getIndexJsonResponse.native.js +99 -0
  75. package/dist/cjs/utils/getIndexJsonResponse.native.js.map +6 -0
  76. package/dist/cjs/utils/getOptimizeDeps.js +8 -7
  77. package/dist/cjs/utils/getOptimizeDeps.js.map +1 -1
  78. package/dist/cjs/utils/getOptimizeDeps.native.js +8 -7
  79. package/dist/cjs/utils/getOptimizeDeps.native.js.map +1 -1
  80. package/dist/cjs/utils/getOptionsFilled.js.map +1 -1
  81. package/dist/cjs/utils/getOptionsFilled.native.js.map +1 -1
  82. package/dist/cjs/utils/getReactNativeBundle.js +165 -0
  83. package/dist/cjs/utils/getReactNativeBundle.js.map +6 -0
  84. package/dist/cjs/utils/getReactNativeBundle.native.js +389 -0
  85. package/dist/cjs/utils/getReactNativeBundle.native.js.map +6 -0
  86. package/dist/cjs/utils/getVitePath.js +2 -2
  87. package/dist/cjs/utils/getVitePath.js.map +2 -2
  88. package/dist/cjs/utils/getVitePath.native.js +8 -8
  89. package/dist/cjs/utils/getVitePath.native.js.map +2 -2
  90. package/dist/cjs/utils/getViteServerConfig.js +80 -0
  91. package/dist/cjs/utils/getViteServerConfig.js.map +6 -0
  92. package/dist/cjs/utils/getViteServerConfig.native.js +256 -0
  93. package/dist/cjs/utils/getViteServerConfig.native.js.map +6 -0
  94. package/dist/cjs/utils/hotUpdateCache.js +21 -0
  95. package/dist/cjs/utils/hotUpdateCache.js.map +6 -0
  96. package/dist/cjs/utils/hotUpdateCache.native.js +26 -0
  97. package/dist/cjs/utils/hotUpdateCache.native.js.map +6 -0
  98. package/dist/cjs/utils/isBuildingNativeBundle.js +25 -0
  99. package/dist/cjs/utils/isBuildingNativeBundle.js.map +6 -0
  100. package/dist/cjs/utils/isBuildingNativeBundle.native.js +32 -0
  101. package/dist/cjs/utils/isBuildingNativeBundle.native.js.map +6 -0
  102. package/dist/cjs/utils/isWithin.js +25 -0
  103. package/dist/cjs/utils/isWithin.js.map +6 -0
  104. package/dist/cjs/utils/isWithin.native.js +30 -0
  105. package/dist/cjs/utils/isWithin.native.js.map +6 -0
  106. package/dist/cjs/utils/readVXRNConfig.js +15 -18
  107. package/dist/cjs/utils/readVXRNConfig.js.map +2 -2
  108. package/dist/cjs/utils/readVXRNConfig.native.js +104 -49
  109. package/dist/cjs/utils/readVXRNConfig.native.js.map +2 -2
  110. package/dist/cjs/utils/resolveFile.js +28 -0
  111. package/dist/cjs/utils/resolveFile.js.map +6 -0
  112. package/dist/cjs/utils/resolveFile.native.js +34 -0
  113. package/dist/cjs/utils/resolveFile.native.js.map +6 -0
  114. package/dist/cjs/utils/swapPrebuiltReactModules.js +108 -0
  115. package/dist/cjs/utils/swapPrebuiltReactModules.js.map +6 -0
  116. package/dist/cjs/utils/swapPrebuiltReactModules.native.js +272 -0
  117. package/dist/cjs/utils/swapPrebuiltReactModules.native.js.map +6 -0
  118. package/dist/cjs/utils/uniq.js +23 -0
  119. package/dist/cjs/utils/uniq.js.map +6 -0
  120. package/dist/cjs/utils/uniq.native.js +59 -0
  121. package/dist/cjs/utils/uniq.native.js.map +6 -0
  122. package/dist/esm/exports/bindKeypressInput.js +34 -0
  123. package/dist/esm/exports/bindKeypressInput.js.map +6 -0
  124. package/dist/esm/exports/bindKeypressInput.mjs +31 -0
  125. package/dist/esm/exports/bindKeypressInput.native.js +34 -0
  126. package/dist/esm/exports/bindKeypressInput.native.js.map +6 -0
  127. package/dist/esm/exports/build.js +27 -98
  128. package/dist/esm/exports/build.js.map +1 -1
  129. package/dist/esm/exports/build.mjs +38 -135
  130. package/dist/esm/exports/build.native.js +71 -366
  131. package/dist/esm/exports/build.native.js.map +2 -2
  132. package/dist/esm/exports/coerceToArray.js +7 -0
  133. package/dist/esm/exports/coerceToArray.js.map +6 -0
  134. package/dist/esm/exports/coerceToArray.mjs +4 -0
  135. package/dist/esm/exports/connectedNativeClients.js +5 -0
  136. package/dist/esm/exports/connectedNativeClients.js.map +6 -0
  137. package/dist/esm/exports/connectedNativeClients.mjs +2 -0
  138. package/dist/esm/exports/dev.js +17 -431
  139. package/dist/esm/exports/dev.js.map +2 -2
  140. package/dist/esm/exports/dev.mjs +15 -430
  141. package/dist/esm/exports/dev.native.js +19 -738
  142. package/dist/esm/exports/dev.native.js.map +2 -2
  143. package/dist/esm/exports/entryRoot.js +58 -0
  144. package/dist/esm/exports/entryRoot.js.map +6 -0
  145. package/dist/esm/exports/entryRoot.mjs +62 -0
  146. package/dist/esm/exports/getIndexJsonResponse.js +55 -0
  147. package/dist/esm/exports/getIndexJsonResponse.js.map +6 -0
  148. package/dist/esm/exports/getIndexJsonResponse.mjs +71 -0
  149. package/dist/esm/exports/getIndexJsonResponse.native.js +78 -0
  150. package/dist/esm/exports/getIndexJsonResponse.native.js.map +6 -0
  151. package/dist/esm/exports/getReactNativeBundle.js +146 -0
  152. package/dist/esm/exports/getReactNativeBundle.js.map +6 -0
  153. package/dist/esm/exports/getReactNativeBundle.mjs +136 -0
  154. package/dist/esm/exports/getViteServerConfig.js +64 -0
  155. package/dist/esm/exports/getViteServerConfig.js.map +6 -0
  156. package/dist/esm/exports/getViteServerConfig.mjs +44 -0
  157. package/dist/esm/exports/getViteServerConfig.native.js +235 -0
  158. package/dist/esm/exports/getViteServerConfig.native.js.map +6 -0
  159. package/dist/esm/exports/hotUpdateCache.js +5 -0
  160. package/dist/esm/exports/hotUpdateCache.js.map +6 -0
  161. package/dist/esm/exports/hotUpdateCache.mjs +2 -0
  162. package/dist/esm/exports/isBuildingNativeBundle.js +5 -0
  163. package/dist/esm/exports/isBuildingNativeBundle.js.map +6 -0
  164. package/dist/esm/exports/isBuildingNativeBundle.mjs +2 -0
  165. package/dist/esm/exports/isWithin.js +9 -0
  166. package/dist/esm/exports/isWithin.js.map +6 -0
  167. package/dist/esm/exports/isWithin.mjs +6 -0
  168. package/dist/esm/exports/reactNativeHMRPlugin.js +58 -0
  169. package/dist/esm/exports/reactNativeHMRPlugin.js.map +6 -0
  170. package/dist/esm/exports/reactNativeHMRPlugin.mjs +62 -0
  171. package/dist/esm/exports/resolveFile.js +12 -0
  172. package/dist/esm/exports/resolveFile.js.map +6 -0
  173. package/dist/esm/exports/resolveFile.mjs +9 -0
  174. package/dist/esm/exports/resolveFile.native.js +12 -0
  175. package/dist/esm/exports/resolveFile.native.js.map +6 -0
  176. package/dist/esm/exports/serve.js +1 -1
  177. package/dist/esm/exports/serve.js.map +1 -1
  178. package/dist/esm/exports/serve.mjs +1 -1
  179. package/dist/esm/exports/serve.native.js +1 -1
  180. package/dist/esm/exports/serve.native.js.map +1 -1
  181. package/dist/esm/exports/swapPrebuiltReactModules.js +87 -0
  182. package/dist/esm/exports/swapPrebuiltReactModules.js.map +6 -0
  183. package/dist/esm/exports/swapPrebuiltReactModules.mjs +73 -0
  184. package/dist/esm/exports/uniq.js +7 -0
  185. package/dist/esm/exports/uniq.js.map +6 -0
  186. package/dist/esm/exports/uniq.mjs +4 -0
  187. package/dist/esm/index.js +4 -0
  188. package/dist/esm/index.js.map +1 -1
  189. package/dist/esm/index.mjs +4 -0
  190. package/dist/esm/index.native.js +4 -0
  191. package/dist/esm/index.native.js.map +1 -1
  192. package/dist/esm/plugins/reactNativeCommonJsPlugin.js.map +1 -1
  193. package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  194. package/dist/esm/plugins/reactNativeHMRPlugin.js +57 -0
  195. package/dist/esm/plugins/reactNativeHMRPlugin.js.map +6 -0
  196. package/dist/esm/plugins/reactNativeHMRPlugin.mjs +62 -0
  197. package/dist/esm/plugins/reactNativeHMRPlugin.native.js +292 -0
  198. package/dist/esm/plugins/reactNativeHMRPlugin.native.js.map +6 -0
  199. package/dist/esm/utils/bindKeypressInput.js +34 -0
  200. package/dist/esm/utils/bindKeypressInput.js.map +6 -0
  201. package/dist/esm/utils/bindKeypressInput.mjs +31 -0
  202. package/dist/esm/utils/bindKeypressInput.native.js +34 -0
  203. package/dist/esm/utils/bindKeypressInput.native.js.map +6 -0
  204. package/dist/esm/utils/coerceToArray.js +7 -0
  205. package/dist/esm/utils/coerceToArray.js.map +6 -0
  206. package/dist/esm/utils/coerceToArray.mjs +4 -0
  207. package/dist/esm/utils/coerceToArray.native.js +9 -0
  208. package/dist/esm/utils/coerceToArray.native.js.map +6 -0
  209. package/dist/esm/utils/connectedNativeClients.js +13 -0
  210. package/dist/esm/utils/connectedNativeClients.js.map +6 -0
  211. package/dist/esm/utils/connectedNativeClients.mjs +8 -0
  212. package/dist/esm/utils/connectedNativeClients.native.js +13 -0
  213. package/dist/esm/utils/connectedNativeClients.native.js.map +6 -0
  214. package/dist/esm/utils/getIndexJsonResponse.js +55 -0
  215. package/dist/esm/utils/getIndexJsonResponse.js.map +6 -0
  216. package/dist/esm/utils/getIndexJsonResponse.mjs +71 -0
  217. package/dist/esm/utils/getIndexJsonResponse.native.js +78 -0
  218. package/dist/esm/utils/getIndexJsonResponse.native.js.map +6 -0
  219. package/dist/esm/utils/getOptimizeDeps.js +8 -7
  220. package/dist/esm/utils/getOptimizeDeps.js.map +1 -1
  221. package/dist/esm/utils/getOptimizeDeps.mjs +2 -2
  222. package/dist/esm/utils/getOptimizeDeps.native.js +8 -7
  223. package/dist/esm/utils/getOptimizeDeps.native.js.map +1 -1
  224. package/dist/esm/utils/getOptionsFilled.js.map +1 -1
  225. package/dist/esm/utils/getOptionsFilled.native.js.map +1 -1
  226. package/dist/esm/utils/getReactNativeBundle.js +153 -0
  227. package/dist/esm/utils/getReactNativeBundle.js.map +6 -0
  228. package/dist/esm/utils/getReactNativeBundle.mjs +142 -0
  229. package/dist/esm/utils/getReactNativeBundle.native.js +371 -0
  230. package/dist/esm/utils/getReactNativeBundle.native.js.map +6 -0
  231. package/dist/esm/utils/getVitePath.js +2 -2
  232. package/dist/esm/utils/getVitePath.js.map +1 -1
  233. package/dist/esm/utils/getVitePath.mjs +2 -2
  234. package/dist/esm/utils/getVitePath.native.js +8 -8
  235. package/dist/esm/utils/getVitePath.native.js.map +2 -2
  236. package/dist/esm/utils/getViteServerConfig.js +69 -0
  237. package/dist/esm/utils/getViteServerConfig.js.map +6 -0
  238. package/dist/esm/utils/getViteServerConfig.mjs +49 -0
  239. package/dist/esm/utils/getViteServerConfig.native.js +240 -0
  240. package/dist/esm/utils/getViteServerConfig.native.js.map +6 -0
  241. package/dist/esm/utils/hotUpdateCache.js +5 -0
  242. package/dist/esm/utils/hotUpdateCache.js.map +6 -0
  243. package/dist/esm/utils/hotUpdateCache.mjs +2 -0
  244. package/dist/esm/utils/hotUpdateCache.native.js +5 -0
  245. package/dist/esm/utils/hotUpdateCache.native.js.map +6 -0
  246. package/dist/esm/utils/isBuildingNativeBundle.js +9 -0
  247. package/dist/esm/utils/isBuildingNativeBundle.js.map +6 -0
  248. package/dist/esm/utils/isBuildingNativeBundle.mjs +5 -0
  249. package/dist/esm/utils/isBuildingNativeBundle.native.js +10 -0
  250. package/dist/esm/utils/isBuildingNativeBundle.native.js.map +6 -0
  251. package/dist/esm/utils/isWithin.js +9 -0
  252. package/dist/esm/utils/isWithin.js.map +6 -0
  253. package/dist/esm/utils/isWithin.mjs +6 -0
  254. package/dist/esm/utils/isWithin.native.js +9 -0
  255. package/dist/esm/utils/isWithin.native.js.map +6 -0
  256. package/dist/esm/utils/readVXRNConfig.js +16 -19
  257. package/dist/esm/utils/readVXRNConfig.js.map +1 -1
  258. package/dist/esm/utils/readVXRNConfig.mjs +17 -21
  259. package/dist/esm/utils/readVXRNConfig.native.js +105 -50
  260. package/dist/esm/utils/readVXRNConfig.native.js.map +2 -2
  261. package/dist/esm/utils/resolveFile.js +12 -0
  262. package/dist/esm/utils/resolveFile.js.map +6 -0
  263. package/dist/esm/utils/resolveFile.mjs +9 -0
  264. package/dist/esm/utils/resolveFile.native.js +12 -0
  265. package/dist/esm/utils/resolveFile.native.js.map +6 -0
  266. package/dist/esm/utils/swapPrebuiltReactModules.js +89 -0
  267. package/dist/esm/utils/swapPrebuiltReactModules.js.map +6 -0
  268. package/dist/esm/utils/swapPrebuiltReactModules.mjs +75 -0
  269. package/dist/esm/utils/swapPrebuiltReactModules.native.js +248 -0
  270. package/dist/esm/utils/swapPrebuiltReactModules.native.js.map +6 -0
  271. package/dist/esm/utils/uniq.js +7 -0
  272. package/dist/esm/utils/uniq.js.map +6 -0
  273. package/dist/esm/utils/uniq.mjs +4 -0
  274. package/dist/esm/utils/uniq.native.js +38 -0
  275. package/dist/esm/utils/uniq.native.js.map +6 -0
  276. package/package.json +8 -8
  277. package/src/exports/build.ts +46 -183
  278. package/src/exports/dev.ts +18 -646
  279. package/src/exports/serve.ts +4 -0
  280. package/src/index.ts +5 -0
  281. package/src/plugins/reactNativeCommonJsPlugin.ts +0 -2
  282. package/src/plugins/reactNativeHMRPlugin.ts +105 -0
  283. package/src/types.ts +9 -0
  284. package/src/utils/bindKeypressInput.ts +46 -0
  285. package/src/utils/coerceToArray.ts +3 -0
  286. package/src/utils/connectedNativeClients.ts +9 -0
  287. package/src/utils/getIndexJsonResponse.ts +52 -0
  288. package/src/utils/getOptimizeDeps.ts +9 -8
  289. package/src/utils/getOptionsFilled.ts +0 -1
  290. package/src/utils/getReactNativeBundle.ts +228 -0
  291. package/src/utils/getVitePath.ts +3 -3
  292. package/src/utils/getViteServerConfig.ts +104 -0
  293. package/src/utils/hotUpdateCache.ts +1 -0
  294. package/src/utils/isBuildingNativeBundle.ts +7 -0
  295. package/src/utils/isWithin.ts +6 -0
  296. package/src/utils/readVXRNConfig.ts +81 -25
  297. package/src/utils/resolveFile.ts +9 -0
  298. package/src/utils/swapPrebuiltReactModules.ts +126 -0
  299. package/src/utils/uniq.ts +3 -0
  300. package/types/exports/bindKeypressInput.d.ts +2 -0
  301. package/types/exports/coerceToArray.d.ts +2 -0
  302. package/types/exports/connectedNativeClients.d.ts +2 -0
  303. package/types/exports/dev.d.ts +0 -2
  304. package/types/exports/entryRoot.d.ts +11 -0
  305. package/types/exports/getIndexJsonResponse.d.ts +68 -0
  306. package/types/exports/getReactNativeBundle.d.ts +3 -0
  307. package/types/exports/getViteServerConfig.d.ts +4 -0
  308. package/types/exports/hotUpdateCache.d.ts +2 -0
  309. package/types/exports/isBuildingNativeBundle.d.ts +2 -0
  310. package/types/exports/isWithin.d.ts +2 -0
  311. package/types/exports/reactNativeHMRPlugin.d.ts +11 -0
  312. package/types/exports/resolveFile.d.ts +2 -0
  313. package/types/exports/swapPrebuiltReactModules.d.ts +7 -0
  314. package/types/exports/uniq.d.ts +2 -0
  315. package/types/index.d.ts +4 -0
  316. package/types/plugins/reactNativeHMRPlugin.d.ts +10 -0
  317. package/types/types.d.ts +4 -0
  318. package/types/utils/bindKeypressInput.d.ts +2 -0
  319. package/types/utils/coerceToArray.d.ts +2 -0
  320. package/types/utils/connectedNativeClients.d.ts +4 -0
  321. package/types/utils/getIndexJsonResponse.d.ts +68 -0
  322. package/types/utils/getOptionsFilled.d.ts +2 -0
  323. package/types/utils/getReactNativeBundle.d.ts +4 -0
  324. package/types/utils/getViteServerConfig.d.ts +4 -0
  325. package/types/utils/hotUpdateCache.d.ts +2 -0
  326. package/types/utils/isBuildingNativeBundle.d.ts +3 -0
  327. package/types/utils/isWithin.d.ts +2 -0
  328. package/types/utils/resolveFile.d.ts +2 -0
  329. package/types/utils/swapPrebuiltReactModules.d.ts +7 -0
  330. package/types/utils/uniq.d.ts +2 -0
@@ -1,4 +1,6 @@
1
+ import type { Peer } from 'crossws'
1
2
  import wsAdapter from 'crossws/adapters/node'
3
+ import FSExtra from 'fs-extra'
2
4
  import {
3
5
  createApp,
4
6
  createRouter,
@@ -8,56 +10,26 @@ import {
8
10
  toNodeListener,
9
11
  } from 'h3'
10
12
  import { createProxyEventHandler } from 'h3-proxy'
11
- import { readFile, rm } from 'node:fs/promises'
13
+ import { rm } from 'node:fs/promises'
12
14
  import { createServer as nodeCreateServer } from 'node:http'
13
- import { dirname, join, relative, resolve } from 'node:path'
14
- import readline from 'node:readline'
15
+ import { join } from 'node:path'
16
+ import { createServer, resolveConfig } from 'vite'
15
17
  import { WebSocket } from 'ws'
16
- import * as babel from '@babel/core'
17
- import { buildReact, buildReactJSX, buildReactNative } from '@vxrn/react-native-prebuilt'
18
- import viteReactPlugin, { swcTransform, transformForBuild } from '@vxrn/vite-native-swc'
19
- import { parse } from 'es-module-lexer'
20
- import FSExtra from 'fs-extra'
21
- import {
22
- build,
23
- createServer,
24
- mergeConfig,
25
- resolveConfig,
26
- transformWithEsbuild,
27
- type InlineConfig,
28
- type PluginOption,
29
- type UserConfig,
30
- } from 'vite'
31
-
32
- import createViteFlow from '@vxrn/vite-flow'
33
- import type { Peer } from 'crossws'
34
- import { resolve as importMetaResolve } from 'import-meta-resolve'
35
- import { nativeExtensions } from '../constants'
36
18
  import { clientInjectionsPlugin } from '../plugins/clientInjectPlugin'
37
- import { reactNativeCommonJsPlugin } from '../plugins/reactNativeCommonJsPlugin'
38
19
  import type { VXRNConfig } from '../types'
39
- import { getBaseViteConfig } from '../utils/getBaseViteConfig'
40
- import { getOptionsFilled, type VXRNConfigFilled } from '../utils/getOptionsFilled'
41
- import { getVitePath } from '../utils/getVitePath'
20
+ import { bindKeypressInput } from '../utils/bindKeypressInput'
21
+ import {
22
+ addConnectedNativeClient,
23
+ removeConnectedNativeClient,
24
+ } from '../utils/connectedNativeClients'
25
+ import { getIndexJsonResponse } from '../utils/getIndexJsonResponse'
26
+ import { getOptionsFilled } from '../utils/getOptionsFilled'
27
+ import { getReactNativeBundle } from '../utils/getReactNativeBundle'
28
+ import { getViteServerConfig } from '../utils/getViteServerConfig'
29
+ import { hotUpdateCache } from '../utils/hotUpdateCache'
42
30
  import { checkPatches } from '../utils/patches'
43
- import { getOptimizeDeps } from '../utils/getOptimizeDeps'
44
-
45
- // sorry for the mess, exploring before abstracting
46
-
47
- let isBuildingNativeBundle: Promise<string> | null = null
48
- const hotUpdateCache = new Map<string, string>()
49
-
50
- let connectedNativeClients = 0
51
-
52
- export const resolveFile = (path: string) => {
53
- try {
54
- return importMetaResolve(path, import.meta.url).replace('file://', '')
55
- } catch {
56
- return require.resolve(path)
57
- }
58
- }
59
31
 
60
- const { ensureDir, pathExists, pathExistsSync } = FSExtra
32
+ const { ensureDir } = FSExtra
61
33
 
62
34
  export const dev = async ({ clean, ...rest }: VXRNConfig & { clean?: boolean }) => {
63
35
  const options = await getOptionsFilled(rest)
@@ -218,7 +190,7 @@ export const dev = async ({ clean, ...rest }: VXRNConfig & { clean?: boolean })
218
190
  websocket: {
219
191
  open(peer) {
220
192
  console.debug('[hmr] open', peer)
221
- connectedNativeClients++
193
+ addConnectedNativeClient()
222
194
  },
223
195
 
224
196
  message(peer, message) {
@@ -230,7 +202,7 @@ export const dev = async ({ clean, ...rest }: VXRNConfig & { clean?: boolean })
230
202
 
231
203
  close(peer, event) {
232
204
  console.info('[hmr] close', peer, event)
233
- connectedNativeClients--
205
+ removeConnectedNativeClient()
234
206
  },
235
207
 
236
208
  error(peer, error) {
@@ -344,603 +316,3 @@ export const dev = async ({ clean, ...rest }: VXRNConfig & { clean?: boolean })
344
316
  },
345
317
  }
346
318
  }
347
-
348
- async function getReactNativeBundle(options: VXRNConfigFilled, viteRNClientPlugin: any) {
349
- const { root, port, cacheDir } = options
350
- const { depsToOptimize } = getOptimizeDeps('build')
351
-
352
- if (process.env.LOAD_TMP_BUNDLE) {
353
- // for easier quick testing things:
354
- const tmpBundle = join(process.cwd(), 'bundle.tmp.js')
355
- if (await pathExists(tmpBundle)) {
356
- console.info('⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ returning temp bundle ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️', tmpBundle)
357
- return await readFile(tmpBundle, 'utf-8')
358
- }
359
- }
360
-
361
- if (isBuildingNativeBundle) {
362
- const res = await isBuildingNativeBundle
363
- return res
364
- }
365
-
366
- let done
367
- isBuildingNativeBundle = new Promise((res) => {
368
- done = res
369
- })
370
-
371
- async function babelReanimated(input: string, filename: string) {
372
- return await new Promise<string>((res, rej) => {
373
- babel.transform(
374
- input,
375
- {
376
- plugins: ['react-native-reanimated/plugin'],
377
- filename,
378
- },
379
- (err: any, result) => {
380
- if (!result || err) rej(err || 'no res')
381
- res(result!.code!)
382
- }
383
- )
384
- })
385
- }
386
-
387
- const viteFlow = options.flow ? createViteFlow(options.flow) : null
388
-
389
- // build app
390
- let nativeBuildConfig = {
391
- plugins: [
392
- viteFlow,
393
-
394
- swapPrebuiltReactModules(cacheDir),
395
-
396
- {
397
- name: 'reanimated',
398
- async transform(code, id) {
399
- if (code.includes('worklet')) {
400
- const out = await babelReanimated(code, id)
401
- return out
402
- }
403
- },
404
- },
405
-
406
- viteRNClientPlugin,
407
-
408
- reactNativeCommonJsPlugin({
409
- root,
410
- port,
411
- mode: 'build',
412
- }),
413
-
414
- viteReactPlugin({
415
- tsDecorators: true,
416
- mode: 'build',
417
- }),
418
-
419
- {
420
- name: 'treat-js-files-as-jsx',
421
- async transform(code, id) {
422
- if (!id.includes(`expo-status-bar`)) return null
423
- // Use the exposed transform from vite, instead of directly
424
- // transforming with esbuild
425
- return transformWithEsbuild(code, id, {
426
- loader: 'jsx',
427
- jsx: 'automatic',
428
- })
429
- },
430
- },
431
- ].filter(Boolean),
432
-
433
- appType: 'custom',
434
- root,
435
- clearScreen: false,
436
-
437
- optimizeDeps: {
438
- include: depsToOptimize,
439
- esbuildOptions: {
440
- jsx: 'automatic',
441
- },
442
- },
443
-
444
- resolve: {
445
- extensions: nativeExtensions,
446
- },
447
-
448
- mode: 'development',
449
-
450
- define: {
451
- 'process.env.NODE_ENV': `"development"`,
452
- },
453
-
454
- build: {
455
- ssr: false,
456
- minify: false,
457
- commonjsOptions: {
458
- transformMixedEsModules: true,
459
- },
460
- rollupOptions: {
461
- input: options.entries.native,
462
- treeshake: false,
463
- preserveEntrySignatures: 'strict',
464
- output: {
465
- preserveModules: true,
466
- format: 'cjs',
467
- },
468
- },
469
- },
470
- } satisfies InlineConfig
471
-
472
- if (options.nativeConfig) {
473
- nativeBuildConfig = mergeConfig(nativeBuildConfig, options.nativeConfig) as any
474
- }
475
-
476
- // // this fixes my swap-react-native plugin not being called pre 😳
477
- await resolveConfig(nativeBuildConfig, 'build')
478
-
479
- const buildOutput = await build(nativeBuildConfig)
480
-
481
- if (!('output' in buildOutput)) {
482
- throw `❌`
483
- }
484
-
485
- let appCode = buildOutput.output
486
- // entry last
487
- .sort((a, b) => (a['isEntry'] ? 1 : -1))
488
- .map((outputModule) => {
489
- if (outputModule.type == 'chunk') {
490
- const importsMap = {
491
- currentPath: outputModule.fileName,
492
- }
493
- for (const imp of outputModule.imports) {
494
- const relativePath = relative(dirname(outputModule.fileName), imp)
495
- importsMap[relativePath[0] === '.' ? relativePath : './' + relativePath] = imp
496
- }
497
-
498
- if (outputModule.isEntry) {
499
- entryRoot = dirname(outputModule.fileName)
500
- }
501
-
502
- return `
503
- ___modules___["${outputModule.fileName}"] = ((exports, module) => {
504
- const require = createRequire(${JSON.stringify(importsMap, null, 2)})
505
-
506
- ${outputModule.code}
507
- })
508
-
509
- ${
510
- outputModule.isEntry
511
- ? `
512
- // run entry
513
- const __require = createRequire({})
514
- __require("react-native")
515
- __require("${outputModule.fileName}")
516
- `
517
- : ''
518
- }
519
- `
520
- }
521
- })
522
- .join('\n')
523
-
524
- if (!appCode) {
525
- throw `❌`
526
- }
527
-
528
- appCode = appCode
529
- // TEMP FIX for router tamagui thing since expo router 3 upgrade
530
- .replaceAll('dist/esm/index.mjs"', 'dist/esm/index.js"')
531
-
532
- // TODO this is not stable based on cwd
533
- const appRootParent = join(root, '..', '..')
534
-
535
- const prebuilds = {
536
- reactJSX: join(cacheDir, 'react-jsx-runtime.js'),
537
- react: join(cacheDir, 'react.js'),
538
- reactNative: join(cacheDir, 'react-native.js'),
539
- }
540
-
541
- const templateFile = resolveFile('vxrn/react-native-template.js')
542
- const template = (await readFile(templateFile, 'utf-8'))
543
- .replace('_virtual/virtual_react-native.js', relative(appRootParent, prebuilds.reactNative))
544
- .replace('_virtual/virtual_react.js', relative(appRootParent, prebuilds.react))
545
- .replaceAll('_virtual/virtual_react-jsx.js', relative(appRootParent, prebuilds.reactJSX))
546
-
547
- const out = template + appCode
548
-
549
- done(out)
550
- isBuildingNativeBundle = null
551
-
552
- return out
553
- }
554
-
555
- // we should just detect or whitelist and use flow to convert instead of this but i did a
556
- // few things to the prebuilts to make them work, we may need to account for
557
- async function swapPrebuiltReactModules(cacheDir: string) {
558
- const prebuilds = {
559
- reactJSX: join(cacheDir, 'react-jsx-runtime.js'),
560
- react: join(cacheDir, 'react.js'),
561
- reactNative: join(cacheDir, 'react-native.js'),
562
- }
563
-
564
- if (!(await pathExists(prebuilds.reactNative))) {
565
- console.info('Pre-building react, react-native react/jsx-runtime (one time cost)...')
566
- await Promise.all([
567
- buildReactNative({
568
- entryPoints: [resolveFile('react-native')],
569
- outfile: prebuilds.reactNative,
570
- }),
571
- buildReact({
572
- entryPoints: [resolveFile('react')],
573
- outfile: prebuilds.react,
574
- }),
575
- buildReactJSX({
576
- entryPoints: [resolveFile('react/jsx-dev-runtime')],
577
- outfile: prebuilds.reactJSX,
578
- }),
579
- ])
580
- }
581
-
582
- // react native port (it scans 19000 +5)
583
- const jsxRuntime = {
584
- // alias: 'virtual:react-jsx',
585
- alias: prebuilds.reactJSX,
586
- contents: await readFile(prebuilds.reactJSX, 'utf-8'),
587
- } as const
588
-
589
- const virtualModules = {
590
- 'react-native': {
591
- // alias: 'virtual:react-native',
592
- alias: prebuilds.reactNative,
593
- contents: await readFile(prebuilds.reactNative, 'utf-8'),
594
- },
595
- react: {
596
- // alias: 'virtual:react',
597
- alias: prebuilds.react,
598
- contents: await readFile(prebuilds.react, 'utf-8'),
599
- },
600
- 'react/jsx-runtime': jsxRuntime,
601
- 'react/jsx-dev-runtime': jsxRuntime,
602
- } as const
603
-
604
- return {
605
- name: `swap-react-native`,
606
- enforce: 'pre',
607
-
608
- resolveId(id, importer = '') {
609
- if (id.startsWith('react-native/Libraries')) {
610
- return `virtual:rn-internals:${id}`
611
- }
612
-
613
- // this will break web support, we need a way to somehow switch between?
614
- if (id === 'react-native-web') {
615
- return prebuilds.reactNative
616
- }
617
-
618
- for (const targetId in virtualModules) {
619
- if (id === targetId || id.includes(`node_modules/${targetId}/`)) {
620
- const info = virtualModules[targetId]
621
-
622
- return info.alias
623
- }
624
- }
625
-
626
- // TODO this is terrible and slow, we should be able to get extensions working:
627
- // having trouble getting .native.js to be picked up via vite
628
- // tried adding packages to optimizeDeps, tried resolveExtensions + extensions...
629
- // tried this but seems to not be called for node_modules
630
- if (isBuildingNativeBundle) {
631
- if (id[0] === '.') {
632
- const absolutePath = resolve(dirname(importer), id)
633
- const nativePath = absolutePath.replace(/(.m?js)/, '.native.js')
634
- if (nativePath === id) return
635
- try {
636
- const directoryPath = absolutePath + '/index.native.js'
637
- const directoryNonNativePath = absolutePath + '/index.js'
638
- if (pathExistsSync(directoryPath)) {
639
- return directoryPath
640
- }
641
- if (pathExistsSync(directoryNonNativePath)) {
642
- return directoryNonNativePath
643
- }
644
- if (pathExistsSync(nativePath)) {
645
- return nativePath
646
- }
647
- } catch (err) {
648
- console.warn(`error probably fine`, err)
649
- }
650
- }
651
- }
652
- },
653
-
654
- load(id) {
655
- if (id.startsWith('virtual:rn-internals')) {
656
- const idOut = id.replace('virtual:rn-internals:', '')
657
- let out = `const ___val = __cachedModules["${idOut}"]
658
- const ___defaultVal = ___val ? ___val.default || ___val : ___val
659
- export default ___defaultVal`
660
- return out
661
- }
662
-
663
- for (const targetId in virtualModules) {
664
- const info = virtualModules[targetId as keyof typeof virtualModules]
665
- if (id === info.alias) {
666
- return info.contents
667
- }
668
- }
669
- },
670
- } satisfies PluginOption
671
- }
672
-
673
- function getIndexJsonResponse({ port, root }: { port: number | string; root }) {
674
- return {
675
- name: 'myapp',
676
- slug: 'myapp',
677
- scheme: 'myapp',
678
- version: '1.0.0',
679
- jsEngine: 'jsc',
680
- orientation: 'portrait',
681
- icon: './assets/icon.png',
682
- userInterfaceStyle: 'light',
683
- splash: {
684
- image: './assets/splash.png',
685
- resizeMode: 'contain',
686
- backgroundColor: '#ffffff',
687
- imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
688
- },
689
- updates: { fallbackToCacheTimeout: 0 },
690
- assetBundlePatterns: ['**/*'],
691
- ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
692
- android: {
693
- package: 'com.tamagui.myapp',
694
- adaptiveIcon: {
695
- foregroundImage: './assets/adaptive-icon.png',
696
- backgroundColor: '#FFFFFF',
697
- foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
698
- },
699
- },
700
- web: { favicon: './assets/favicon.png' },
701
- extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
702
- _internal: {
703
- isDebug: false,
704
- projectRoot: root,
705
- dynamicConfigPath: null,
706
- staticConfigPath: join(root, 'app.json'),
707
- packageJsonPath: join(root, 'package.json'),
708
- },
709
- sdkVersion: '50.0.0',
710
- platforms: ['ios', 'android', 'web'],
711
- iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
712
- debuggerHost: `127.0.0.1:${port}`,
713
- logUrl: `http://127.0.0.1:${port}/logs`,
714
- developer: { tool: 'expo-cli', projectRoot: root },
715
- packagerOpts: { dev: true },
716
- mainModuleName: 'index',
717
- __flipperHack: 'React Native packager is running',
718
- hostUri: `127.0.0.1:${port}`,
719
- bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false&lazy=true`,
720
- id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
721
- }
722
- }
723
-
724
- export function bindKeypressInput() {
725
- if (!process.stdin.setRawMode) {
726
- console.warn({
727
- msg: 'Interactive mode is not supported in this environment',
728
- })
729
- return
730
- }
731
-
732
- readline.emitKeypressEvents(process.stdin)
733
- process.stdin.setRawMode(true)
734
-
735
- process.stdin.on('keypress', (_key, data) => {
736
- const { ctrl, name } = data
737
- if (ctrl === true) {
738
- switch (name) {
739
- // biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation>
740
- case 'c':
741
- process.exit()
742
- case 'z':
743
- process.emit('SIGTSTP', 'SIGTSTP')
744
- break
745
- }
746
- } else {
747
- switch (name) {
748
- case 'r':
749
- // ctx.broadcastToMessageClients({ method: 'reload' })
750
- // ctx.log.info({
751
- // msg: 'Reloading app',
752
- // })
753
- break
754
- case 'd':
755
- // ctx.broadcastToMessageClients({ method: 'devMenu' })
756
- // ctx.log.info({
757
- // msg: 'Opening developer menu',
758
- // })
759
- break
760
- case 'c':
761
- process.stdout.write('\u001b[2J\u001b[0;0H')
762
- // TODO: after logging we should print information about port and host
763
- break
764
- }
765
- }
766
- })
767
- }
768
-
769
- function isWithin(outer: string, inner: string) {
770
- const rel = relative(outer, inner)
771
- return !rel.startsWith('../') && rel !== '..'
772
- }
773
-
774
- // used for normalizing hot reloads
775
- let entryRoot = ''
776
-
777
- async function getViteServerConfig(config: VXRNConfigFilled) {
778
- const { root, host, webConfig } = config
779
- const { optimizeDeps } = getOptimizeDeps('serve')
780
-
781
- let serverConfig: UserConfig = mergeConfig(
782
- getBaseViteConfig({
783
- mode: 'development',
784
- }),
785
- {
786
- root,
787
- clearScreen: false,
788
- plugins: [
789
- reactNativeHMRPlugin(config),
790
-
791
- {
792
- name: 'process-env-ssr',
793
- transform(code, id, options) {
794
- if (id.includes('node_modules')) return
795
- if (code.includes('process.env.TAMAGUI_IS_SERVER')) {
796
- return code.replaceAll('process.env.TAMAGUI_IS_SERVER', `${!!options?.ssr}`)
797
- }
798
- },
799
- },
800
- ],
801
-
802
- optimizeDeps,
803
-
804
- ssr: {
805
- // noExternal true causes many incompat issues because we need things on disk to work
806
- // eg generally node uses .cjs extensions to "switch" back to cjs mode on import, but once bundled
807
- // this wont happen, breaking many things
808
- // but we need react related things always so they dont duplicate
809
- noExternal: [
810
- ...optimizeDeps.include,
811
- 'react',
812
- 'react-dom',
813
- 'react-dom/server',
814
- 'react-dom/client',
815
- ],
816
- optimizeDeps,
817
- },
818
-
819
- server: {
820
- hmr: {
821
- path: '/__vxrnhmr',
822
- },
823
- cors: true,
824
- host,
825
- },
826
- } satisfies UserConfig
827
- ) satisfies InlineConfig
828
-
829
- if (webConfig) {
830
- serverConfig = mergeConfig(serverConfig, webConfig) as any
831
- // it doesnt override true with array which youd expect
832
- const theirNoExternal = webConfig.ssr?.noExternal
833
- if (theirNoExternal != null && theirNoExternal !== true) {
834
- serverConfig.ssr!.noExternal = theirNoExternal
835
- }
836
- }
837
-
838
- if (process.env.DEBUG) {
839
- console.debug('server config is', serverConfig)
840
- console.debug('server ssr\n', JSON.stringify(serverConfig.ssr, null, 2))
841
- }
842
-
843
- serverConfig = {
844
- ...serverConfig,
845
- plugins: [...serverConfig.plugins!],
846
- }
847
-
848
- return serverConfig
849
- }
850
-
851
- function reactNativeHMRPlugin({ root }: VXRNConfigFilled) {
852
- return {
853
- name: 'client-transform',
854
-
855
- async handleHotUpdate({ read, modules, file }) {
856
- try {
857
- if (!isWithin(root, file)) {
858
- return
859
- }
860
- if (!connectedNativeClients) {
861
- return
862
- }
863
-
864
- const [module] = modules
865
- if (!module) return
866
-
867
- const id = module?.url || file.replace(root, '')
868
-
869
- const code = await read()
870
-
871
- // got a weird pre compiled file on startup
872
- if (code.startsWith(`'use strict';`)) return
873
-
874
- if (!code) {
875
- return
876
- }
877
-
878
- let source = code
879
-
880
- // we have to remove jsx before we can parse imports...
881
- source = (await transformForBuild(id, source))?.code || ''
882
-
883
- const importsMap = {}
884
-
885
- // parse imports of modules into ids:
886
- // eg `import x from '@tamagui/core'` => `import x from '/me/node_modules/@tamagui/core/index.js'`
887
- const [imports] = parse(source)
888
-
889
- let accumulatedSliceOffset = 0
890
-
891
- for (const specifier of imports) {
892
- const { n: importName, s: start } = specifier
893
-
894
- if (importName) {
895
- const id = await getVitePath(entryRoot, file, importName)
896
- if (!id) {
897
- console.warn('???')
898
- continue
899
- }
900
-
901
- importsMap[id] = id.replace(/^(\.\.\/)+/, '')
902
-
903
- // replace module name with id for hmr
904
- const len = importName.length
905
- const extraLen = id.length - len
906
- source =
907
- source.slice(0, start + accumulatedSliceOffset) +
908
- id +
909
- source.slice(start + accumulatedSliceOffset + len)
910
- accumulatedSliceOffset += extraLen
911
- }
912
- }
913
-
914
- // then we have to convert to commonjs..
915
- source =
916
- (
917
- await swcTransform(id, source, {
918
- mode: 'serve-cjs',
919
- })
920
- )?.code || ''
921
-
922
- if (!source) {
923
- throw '❌ no source'
924
- }
925
-
926
- importsMap['currentPath'] = id
927
-
928
- const hotUpdateSource = `exports = ((exports) => {
929
- const require = createRequire(${JSON.stringify(importsMap, null, 2)})
930
- ${source
931
- .replace(`import.meta.hot.accept(() => {})`, ``)
932
- // replace import.meta.glob with empty array in hot reloads
933
- .replaceAll(/import.meta.glob\(.*\)/gi, `globalThis['__importMetaGlobbed'] || {}`)};
934
- return exports })({})`
935
-
936
- if (process.env.DEBUG) {
937
- console.info(`Sending hot update`, hotUpdateSource)
938
- }
939
-
940
- hotUpdateCache.set(id, hotUpdateSource)
941
- } catch (err) {
942
- console.error(`Error processing hmr update:`, err)
943
- }
944
- },
945
- }
946
- }
@@ -13,6 +13,10 @@ export const serve = async (optionsIn: VXRNConfig) => {
13
13
  gzip: true,
14
14
  })
15
15
 
16
+ if (options.serve) {
17
+ options.serve(options, app)
18
+ }
19
+
16
20
  app.use(
17
21
  defineEventHandler(async ({ node: { req, res } }) => {
18
22
  await new Promise<void>((response) => {