rwsdk 0.1.16 → 0.1.17

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 (327) hide show
  1. package/dist/lib/$.d.mts +8 -0
  2. package/dist/lib/$.mjs +5 -0
  3. package/dist/lib/compileTsModule.d.mts +1 -0
  4. package/dist/lib/compileTsModule.mjs +27 -0
  5. package/dist/lib/constants.d.mts +4 -0
  6. package/dist/lib/constants.mjs +6 -0
  7. package/dist/lib/findWranglerConfig.d.mts +1 -0
  8. package/dist/lib/findWranglerConfig.mjs +12 -0
  9. package/dist/lib/getShortName.d.mts +1 -0
  10. package/dist/lib/getShortName.mjs +2 -0
  11. package/dist/lib/getSrcPaths.d.ts +15 -0
  12. package/dist/lib/getSrcPaths.js +80 -0
  13. package/dist/lib/hasPkgScript.d.mts +1 -0
  14. package/dist/lib/hasPkgScript.mjs +9 -0
  15. package/dist/lib/jsonUtils.d.mts +28 -0
  16. package/dist/lib/jsonUtils.mjs +167 -0
  17. package/dist/lib/setupEnvFiles.d.mts +4 -0
  18. package/dist/lib/setupEnvFiles.mjs +31 -0
  19. package/dist/lib/smokeTests/artifacts.d.mts +10 -0
  20. package/dist/lib/smokeTests/artifacts.mjs +164 -0
  21. package/dist/lib/smokeTests/browser.d.mts +48 -0
  22. package/dist/lib/smokeTests/browser.mjs +1041 -0
  23. package/dist/lib/smokeTests/cleanup.d.mts +5 -0
  24. package/dist/lib/smokeTests/cleanup.mjs +214 -0
  25. package/dist/lib/smokeTests/codeUpdates.d.mts +8 -0
  26. package/dist/lib/smokeTests/codeUpdates.mjs +229 -0
  27. package/dist/lib/smokeTests/constants.d.mts +5 -0
  28. package/dist/lib/smokeTests/constants.mjs +10 -0
  29. package/dist/lib/smokeTests/development.d.mts +11 -0
  30. package/dist/lib/smokeTests/development.mjs +209 -0
  31. package/dist/lib/smokeTests/environment.d.mts +14 -0
  32. package/dist/lib/smokeTests/environment.mjs +163 -0
  33. package/dist/lib/smokeTests/release.d.mts +61 -0
  34. package/dist/lib/smokeTests/release.mjs +526 -0
  35. package/dist/lib/smokeTests/reporting.d.mts +13 -0
  36. package/dist/lib/smokeTests/reporting.mjs +355 -0
  37. package/dist/lib/smokeTests/runSmokeTests.d.mts +5 -0
  38. package/dist/lib/smokeTests/runSmokeTests.mjs +144 -0
  39. package/dist/lib/smokeTests/state.d.mts +48 -0
  40. package/dist/lib/smokeTests/state.mjs +57 -0
  41. package/dist/lib/smokeTests/templates/SmokeTest.template.d.ts +1 -0
  42. package/dist/lib/smokeTests/templates/SmokeTest.template.js +81 -0
  43. package/dist/lib/smokeTests/templates/SmokeTestClient.template.d.ts +1 -0
  44. package/dist/lib/smokeTests/templates/SmokeTestClient.template.js +159 -0
  45. package/dist/lib/smokeTests/templates/smokeTestFunctions.template.d.ts +1 -0
  46. package/dist/lib/smokeTests/templates/smokeTestFunctions.template.js +19 -0
  47. package/dist/lib/smokeTests/types.d.mts +75 -0
  48. package/dist/lib/smokeTests/types.mjs +1 -0
  49. package/dist/lib/smokeTests/utils.d.mts +15 -0
  50. package/dist/lib/smokeTests/utils.mjs +147 -0
  51. package/dist/llms/index.d.ts +3 -0
  52. package/dist/llms/index.js +35 -0
  53. package/dist/llms/rules/interruptors.d.ts +1 -0
  54. package/dist/llms/rules/interruptors.js +243 -0
  55. package/dist/llms/rules/middleware.d.ts +1 -0
  56. package/dist/llms/rules/middleware.js +71 -0
  57. package/dist/llms/rules/react.d.ts +1 -0
  58. package/dist/llms/rules/react.js +106 -0
  59. package/dist/llms/rules/request-response.d.ts +1 -0
  60. package/dist/llms/rules/request-response.js +209 -0
  61. package/dist/runtime/client.d.ts +17 -0
  62. package/dist/runtime/client.js +74 -0
  63. package/dist/runtime/clientNavigation.d.ts +4 -0
  64. package/dist/runtime/clientNavigation.js +53 -0
  65. package/dist/runtime/clientNavigation.test.d.ts +1 -0
  66. package/dist/runtime/clientNavigation.test.js +55 -0
  67. package/dist/runtime/constants.d.ts +1 -0
  68. package/dist/runtime/constants.js +1 -0
  69. package/dist/runtime/entries/auth.d.ts +1 -0
  70. package/dist/runtime/entries/auth.js +1 -0
  71. package/dist/runtime/entries/client.d.ts +4 -0
  72. package/dist/runtime/entries/client.js +4 -0
  73. package/dist/runtime/entries/clientSSR.d.ts +1 -0
  74. package/dist/runtime/entries/clientSSR.js +1 -0
  75. package/dist/runtime/entries/navigation.d.ts +1 -0
  76. package/dist/runtime/entries/navigation.js +1 -0
  77. package/dist/runtime/entries/no-react-server.d.ts +0 -0
  78. package/dist/runtime/entries/no-react-server.js +2 -0
  79. package/dist/runtime/entries/react-server-only.d.ts +0 -0
  80. package/dist/runtime/entries/react-server-only.js +2 -0
  81. package/dist/runtime/entries/router.d.ts +2 -0
  82. package/dist/runtime/entries/router.js +2 -0
  83. package/dist/runtime/entries/ssr.d.ts +1 -0
  84. package/dist/runtime/entries/ssr.js +1 -0
  85. package/dist/runtime/entries/worker.d.ts +9 -0
  86. package/dist/runtime/entries/worker.js +9 -0
  87. package/dist/runtime/error.d.ts +6 -0
  88. package/dist/runtime/error.js +8 -0
  89. package/dist/runtime/imports/ClientOnly.d.ts +3 -0
  90. package/dist/runtime/imports/ClientOnly.js +8 -0
  91. package/dist/runtime/imports/client.d.ts +4 -0
  92. package/dist/runtime/imports/client.js +33 -0
  93. package/dist/runtime/imports/ssr.d.ts +5 -0
  94. package/dist/runtime/imports/ssr.js +20 -0
  95. package/dist/runtime/imports/worker.d.ts +5 -0
  96. package/dist/runtime/imports/worker.js +22 -0
  97. package/dist/runtime/lib/auth/index.d.ts +1 -0
  98. package/dist/runtime/lib/auth/index.js +1 -0
  99. package/dist/runtime/lib/auth/session.d.ts +50 -0
  100. package/dist/runtime/lib/auth/session.js +148 -0
  101. package/dist/runtime/lib/db/DOWorkerDialect.d.ts +29 -0
  102. package/dist/runtime/lib/db/DOWorkerDialect.js +66 -0
  103. package/dist/runtime/lib/db/SqliteDurableObject.d.ts +14 -0
  104. package/dist/runtime/lib/db/SqliteDurableObject.js +42 -0
  105. package/dist/runtime/lib/db/createDb.d.ts +2 -0
  106. package/dist/runtime/lib/db/createDb.js +33 -0
  107. package/dist/runtime/lib/db/index.d.ts +4 -0
  108. package/dist/runtime/lib/db/index.js +3 -0
  109. package/dist/runtime/lib/db/migrations.d.ts +23 -0
  110. package/dist/runtime/lib/db/migrations.js +34 -0
  111. package/dist/runtime/lib/db/typeInference/assert.d.ts +2 -0
  112. package/dist/runtime/lib/db/typeInference/assert.js +1 -0
  113. package/dist/runtime/lib/db/typeInference/builders/alterColumn.d.ts +27 -0
  114. package/dist/runtime/lib/db/typeInference/builders/alterColumn.js +1 -0
  115. package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +53 -0
  116. package/dist/runtime/lib/db/typeInference/builders/alterTable.js +1 -0
  117. package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +26 -0
  118. package/dist/runtime/lib/db/typeInference/builders/columnDefinition.js +1 -0
  119. package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +49 -0
  120. package/dist/runtime/lib/db/typeInference/builders/createTable.js +1 -0
  121. package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +17 -0
  122. package/dist/runtime/lib/db/typeInference/builders/createView.js +1 -0
  123. package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +11 -0
  124. package/dist/runtime/lib/db/typeInference/builders/dropTable.js +1 -0
  125. package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +12 -0
  126. package/dist/runtime/lib/db/typeInference/builders/dropView.js +1 -0
  127. package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +24 -0
  128. package/dist/runtime/lib/db/typeInference/builders/schema.js +1 -0
  129. package/dist/runtime/lib/db/typeInference/database.d.ts +27 -0
  130. package/dist/runtime/lib/db/typeInference/database.js +1 -0
  131. package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.d.ts +1 -0
  132. package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +360 -0
  133. package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.d.ts +1 -0
  134. package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +33 -0
  135. package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.d.ts +1 -0
  136. package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.js +143 -0
  137. package/dist/runtime/lib/db/typeInference/typetests/print.d.ts +3 -0
  138. package/dist/runtime/lib/db/typeInference/typetests/print.js +1 -0
  139. package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +2 -0
  140. package/dist/runtime/lib/db/typeInference/typetests/testUtils.js +1 -0
  141. package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.d.ts +1 -0
  142. package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.js +17 -0
  143. package/dist/runtime/lib/db/typeInference/utils.d.ts +82 -0
  144. package/dist/runtime/lib/db/typeInference/utils.js +2 -0
  145. package/dist/runtime/lib/debug.d.ts +2 -0
  146. package/dist/runtime/lib/debug.js +36 -0
  147. package/dist/runtime/lib/links.d.ts +14 -0
  148. package/dist/runtime/lib/links.js +38 -0
  149. package/dist/runtime/lib/realtime/client.d.ts +7 -0
  150. package/dist/runtime/lib/realtime/client.js +166 -0
  151. package/dist/runtime/lib/realtime/constants.d.ts +1 -0
  152. package/dist/runtime/lib/realtime/constants.js +1 -0
  153. package/dist/runtime/lib/realtime/durableObject.d.ts +29 -0
  154. package/dist/runtime/lib/realtime/durableObject.js +187 -0
  155. package/dist/runtime/lib/realtime/renderRealtimeClients.d.ts +7 -0
  156. package/dist/runtime/lib/realtime/renderRealtimeClients.js +6 -0
  157. package/dist/runtime/lib/realtime/shared.d.ts +10 -0
  158. package/dist/runtime/lib/realtime/shared.js +10 -0
  159. package/dist/runtime/lib/realtime/validateUpgradeRequest.d.ts +6 -0
  160. package/dist/runtime/lib/realtime/validateUpgradeRequest.js +29 -0
  161. package/dist/runtime/lib/realtime/worker.d.ts +3 -0
  162. package/dist/runtime/lib/realtime/worker.js +16 -0
  163. package/dist/runtime/lib/router.d.ts +56 -0
  164. package/dist/runtime/lib/router.js +210 -0
  165. package/dist/runtime/lib/router.test.d.ts +1 -0
  166. package/dist/runtime/lib/router.test.js +58 -0
  167. package/dist/runtime/lib/streams/consumeEventStream.d.ts +4 -0
  168. package/dist/runtime/lib/streams/consumeEventStream.js +13 -0
  169. package/dist/runtime/lib/turnstile/TurnstileScript.d.ts +1 -0
  170. package/dist/runtime/lib/turnstile/TurnstileScript.js +2 -0
  171. package/dist/runtime/lib/turnstile/turnstile.d.ts +3 -0
  172. package/dist/runtime/lib/turnstile/turnstile.js +3 -0
  173. package/dist/runtime/lib/turnstile/useTurnstile.d.ts +4 -0
  174. package/dist/runtime/lib/turnstile/useTurnstile.js +23 -0
  175. package/dist/runtime/lib/turnstile/verifyTurnstileToken.d.ts +4 -0
  176. package/dist/runtime/lib/turnstile/verifyTurnstileToken.js +15 -0
  177. package/dist/runtime/lib/utils.d.ts +1 -0
  178. package/dist/runtime/lib/utils.js +1 -0
  179. package/dist/runtime/register/client.d.ts +1 -0
  180. package/dist/runtime/register/client.js +5 -0
  181. package/dist/runtime/register/ssr.d.ts +3 -0
  182. package/dist/runtime/register/ssr.js +26 -0
  183. package/dist/runtime/register/worker.d.ts +4 -0
  184. package/dist/runtime/register/worker.js +42 -0
  185. package/dist/runtime/render/createClientManifest.d.ts +1 -0
  186. package/dist/runtime/render/createClientManifest.js +7 -0
  187. package/dist/runtime/render/createModuleMap.d.ts +1 -0
  188. package/dist/runtime/render/createModuleMap.js +13 -0
  189. package/dist/runtime/render/injectRSCPayload.d.ts +3 -0
  190. package/dist/runtime/render/injectRSCPayload.js +79 -0
  191. package/dist/runtime/render/renderRscThenableToHtmlStream.d.ts +9 -0
  192. package/dist/runtime/render/renderRscThenableToHtmlStream.js +49 -0
  193. package/dist/runtime/render/renderToRscStream.d.ts +5 -0
  194. package/dist/runtime/render/renderToRscStream.js +46 -0
  195. package/dist/runtime/render/renderToStream.d.ts +9 -0
  196. package/dist/runtime/render/renderToStream.js +27 -0
  197. package/dist/runtime/render/renderToString.d.ts +7 -0
  198. package/dist/runtime/render/renderToString.js +26 -0
  199. package/dist/runtime/render/transformRscToHtmlStream.d.ts +8 -0
  200. package/dist/runtime/render/transformRscToHtmlStream.js +19 -0
  201. package/dist/runtime/requestInfo/types.d.ts +11 -0
  202. package/dist/runtime/requestInfo/types.js +1 -0
  203. package/dist/runtime/requestInfo/worker.d.ts +5 -0
  204. package/dist/runtime/requestInfo/worker.js +33 -0
  205. package/dist/runtime/script.d.ts +5 -0
  206. package/dist/runtime/script.js +8 -0
  207. package/dist/runtime/ssrBridge.d.ts +2 -0
  208. package/dist/runtime/ssrBridge.js +11 -0
  209. package/dist/runtime/worker.d.ts +18 -0
  210. package/dist/runtime/worker.js +173 -0
  211. package/dist/scripts/__sdk.d.mts +1 -0
  212. package/dist/scripts/__sdk.mjs +14 -0
  213. package/dist/scripts/build-vendor-bundles.d.mts +1 -0
  214. package/dist/scripts/build-vendor-bundles.mjs +92 -0
  215. package/dist/scripts/debug-sync.d.mts +6 -0
  216. package/dist/scripts/debug-sync.mjs +224 -0
  217. package/dist/scripts/dev-init.d.mts +1 -0
  218. package/dist/scripts/dev-init.mjs +25 -0
  219. package/dist/scripts/ensure-deploy-env.d.mts +1 -0
  220. package/dist/scripts/ensure-deploy-env.mjs +271 -0
  221. package/dist/scripts/ensure-env.d.mts +1 -0
  222. package/dist/scripts/ensure-env.mjs +9 -0
  223. package/dist/scripts/migrate-new.d.mts +1 -0
  224. package/dist/scripts/migrate-new.mjs +51 -0
  225. package/dist/scripts/smoke-test.d.mts +1 -0
  226. package/dist/scripts/smoke-test.mjs +166 -0
  227. package/dist/scripts/worker-run.d.mts +1 -0
  228. package/dist/scripts/worker-run.mjs +82 -0
  229. package/dist/vite/aliasByEnvPlugin.d.mts +2 -0
  230. package/dist/vite/aliasByEnvPlugin.mjs +11 -0
  231. package/dist/vite/asyncSetupPlugin.d.mts +6 -0
  232. package/dist/vite/asyncSetupPlugin.mjs +23 -0
  233. package/dist/vite/checkIsUsingPrisma.d.mts +6 -0
  234. package/dist/vite/checkIsUsingPrisma.mjs +18 -0
  235. package/dist/vite/configPlugin.d.mts +9 -0
  236. package/dist/vite/configPlugin.mjs +169 -0
  237. package/dist/vite/copyPrismaWasmPlugin.d.mts +4 -0
  238. package/dist/vite/copyPrismaWasmPlugin.mjs +32 -0
  239. package/dist/vite/createDirectiveLookupPlugin.d.mts +21 -0
  240. package/dist/vite/createDirectiveLookupPlugin.mjs +231 -0
  241. package/dist/vite/customReactBuildPlugin.d.mts +4 -0
  242. package/dist/vite/customReactBuildPlugin.mjs +61 -0
  243. package/dist/vite/devServerTimingPlugin.d.mts +2 -0
  244. package/dist/vite/devServerTimingPlugin.mjs +24 -0
  245. package/dist/vite/directivesPlugin.d.mts +6 -0
  246. package/dist/vite/directivesPlugin.mjs +200 -0
  247. package/dist/vite/ensureAliasArray.d.mts +2 -0
  248. package/dist/vite/ensureAliasArray.mjs +17 -0
  249. package/dist/vite/findSpecifiers.d.mts +31 -0
  250. package/dist/vite/findSpecifiers.mjs +230 -0
  251. package/dist/vite/findSsrSpecifiers.d.mts +11 -0
  252. package/dist/vite/findSsrSpecifiers.mjs +67 -0
  253. package/dist/vite/hasDirective.d.mts +7 -0
  254. package/dist/vite/hasDirective.mjs +54 -0
  255. package/dist/vite/hasOwnCloudflareVitePlugin.d.mts +3 -0
  256. package/dist/vite/hasOwnCloudflareVitePlugin.mjs +14 -0
  257. package/dist/vite/index.d.mts +1 -0
  258. package/dist/vite/index.mjs +1 -0
  259. package/dist/vite/injectHmrPreambleJsxPlugin.d.mts +2 -0
  260. package/dist/vite/injectHmrPreambleJsxPlugin.mjs +22 -0
  261. package/dist/vite/injectVitePreamblePlugin.d.mts +4 -0
  262. package/dist/vite/injectVitePreamblePlugin.mjs +23 -0
  263. package/dist/vite/invalidateCacheIfPrismaClientChanged.d.mts +3 -0
  264. package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +27 -0
  265. package/dist/vite/invalidateModule.d.mts +6 -0
  266. package/dist/vite/invalidateModule.mjs +30 -0
  267. package/dist/vite/miniflareHMRPlugin.d.mts +10 -0
  268. package/dist/vite/miniflareHMRPlugin.mjs +209 -0
  269. package/dist/vite/miniflarePlugin.d.mts +9 -0
  270. package/dist/vite/miniflarePlugin.mjs +135 -0
  271. package/dist/vite/moveStaticAssetsPlugin.d.mts +4 -0
  272. package/dist/vite/moveStaticAssetsPlugin.mjs +12 -0
  273. package/dist/vite/normalizeModulePath.d.mts +1 -0
  274. package/dist/vite/normalizeModulePath.mjs +13 -0
  275. package/dist/vite/prismaPlugin.d.mts +4 -0
  276. package/dist/vite/prismaPlugin.mjs +43 -0
  277. package/dist/vite/reactConditionsResolverPlugin.d.mts +16 -0
  278. package/dist/vite/reactConditionsResolverPlugin.mjs +179 -0
  279. package/dist/vite/redwoodPlugin.d.mts +12 -0
  280. package/dist/vite/redwoodPlugin.mjs +105 -0
  281. package/dist/vite/requestUtils.d.mts +6 -0
  282. package/dist/vite/requestUtils.mjs +35 -0
  283. package/dist/vite/setupEnvFiles.d.mts +4 -0
  284. package/dist/vite/setupEnvFiles.mjs +31 -0
  285. package/dist/vite/ssrBridgePlugin.d.mts +7 -0
  286. package/dist/vite/ssrBridgePlugin.mjs +137 -0
  287. package/dist/vite/transformClientComponents.d.mts +12 -0
  288. package/dist/vite/transformClientComponents.mjs +116 -0
  289. package/dist/vite/transformClientComponents.test.d.mts +1 -0
  290. package/dist/vite/transformClientComponents.test.mjs +264 -0
  291. package/dist/vite/transformJsxScriptTagsPlugin.d.mts +8 -0
  292. package/dist/vite/transformJsxScriptTagsPlugin.mjs +315 -0
  293. package/dist/vite/transformJsxScriptTagsPlugin.test.d.mts +1 -0
  294. package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +334 -0
  295. package/dist/vite/transformServerFunctions.d.mts +16 -0
  296. package/dist/vite/transformServerFunctions.mjs +296 -0
  297. package/dist/vite/transformServerFunctions.test.d.mts +1 -0
  298. package/dist/vite/transformServerFunctions.test.mjs +124 -0
  299. package/dist/vite/useClientLookupPlugin.d.mts +5 -0
  300. package/dist/vite/useClientLookupPlugin.mjs +15 -0
  301. package/dist/vite/useClientPlugin.d.mts +8 -0
  302. package/dist/vite/useClientPlugin.mjs +295 -0
  303. package/dist/vite/useClientPlugin.test.d.mts +1 -0
  304. package/dist/vite/useClientPlugin.test.mjs +1204 -0
  305. package/dist/vite/useServerLookupPlugin.d.mts +5 -0
  306. package/dist/vite/useServerLookupPlugin.mjs +15 -0
  307. package/dist/vite/useServerPlugin.d.mts +1 -0
  308. package/dist/vite/useServerPlugin.mjs +1 -0
  309. package/dist/vite/virtualPlugin.d.mts +2 -0
  310. package/dist/vite/virtualPlugin.mjs +18 -0
  311. package/dist/vite/vitePreamblePlugin.d.mts +1 -0
  312. package/dist/vite/vitePreamblePlugin.mjs +11 -0
  313. package/dist/worker/__ssr_bridge.js +8947 -0
  314. package/dist/worker/__ssr_bridge.js.map +1 -0
  315. package/package.json +1 -1
  316. package/dist/vite/invalidateClientModule.d.mts +0 -2
  317. package/dist/vite/invalidateClientModule.mjs +0 -8
  318. package/dist/vite/invalidateModule copy.d.mts +0 -2
  319. package/dist/vite/invalidateModule copy.mjs +0 -14
  320. package/dist/vite/invalidateSSRModule.d.mts +0 -2
  321. package/dist/vite/invalidateSSRModule.mjs +0 -7
  322. package/dist/vite/mode.d.mts +0 -5
  323. package/dist/vite/mode.mjs +0 -25
  324. package/dist/vite/modePlugin.d.mts +0 -2
  325. package/dist/vite/modePlugin.mjs +0 -10
  326. /package/dist/vite/{isJsFile.d.ts → isJsFile.d.mts} +0 -0
  327. /package/dist/vite/{isJsFile.js → isJsFile.mjs} +0 -0
@@ -0,0 +1,166 @@
1
+ import { fileURLToPath } from "url";
2
+ import { join } from "path";
3
+ import debug from "debug";
4
+ import { runSmokeTests } from "../lib/smokeTests/runSmokeTests.mjs";
5
+ import { isRunningInCI } from "../lib/smokeTests/utils.mjs";
6
+ // Set up debug logging
7
+ if (!process.env.DEBUG) {
8
+ debug.enable("rwsdk:smoke");
9
+ }
10
+ const log = debug("rwsdk:smoke");
11
+ // Run the smoke test if this file is executed directly
12
+ if (fileURLToPath(import.meta.url) === process.argv[1]) {
13
+ // Parse command line arguments
14
+ const args = process.argv.slice(2);
15
+ log("Command line arguments: %O", args);
16
+ // Check for CI flag first
17
+ const ciFlag = args.includes("--ci");
18
+ // Set initial default values (sync will be determined below)
19
+ const options = {
20
+ customPath: "/", // Default path
21
+ skipDev: false,
22
+ skipRelease: false,
23
+ skipClient: false,
24
+ projectDir: undefined,
25
+ artifactDir: join(process.cwd(), ".artifacts"), // Default to .artifacts in current directory
26
+ keep: isRunningInCI(ciFlag), // Default to true in CI environments
27
+ headless: true,
28
+ ci: ciFlag,
29
+ bail: false, // Default to false - continue tests even if some fail
30
+ copyProject: false, // Default to false - don't copy project to artifacts
31
+ realtime: false, // Default to false - don't just test realtime
32
+ skipHmr: false, // Default to false - run HMR tests
33
+ // sync: will be set below
34
+ };
35
+ // Log if we're in CI
36
+ if (isRunningInCI(ciFlag)) {
37
+ log("Running in CI environment, keeping test directory by default");
38
+ }
39
+ // Track if user explicitly set sync or no-sync
40
+ let syncExplicit = undefined;
41
+ // Process arguments in order
42
+ for (let i = 0; i < args.length; i++) {
43
+ const arg = args[i];
44
+ if (arg === "--skip-dev") {
45
+ options.skipDev = true;
46
+ }
47
+ else if (arg === "--skip-release") {
48
+ options.skipRelease = true;
49
+ }
50
+ else if (arg === "--skip-client") {
51
+ options.skipClient = true;
52
+ }
53
+ else if (arg === "--skip-hmr") {
54
+ options.skipHmr = true;
55
+ }
56
+ else if (arg === "--keep") {
57
+ options.keep = true;
58
+ }
59
+ else if (arg === "--no-headless") {
60
+ options.headless = false;
61
+ }
62
+ else if (arg === "--copy-project") {
63
+ options.copyProject = true;
64
+ }
65
+ else if (arg === "--no-sync") {
66
+ syncExplicit = false;
67
+ }
68
+ else if (arg === "--sync") {
69
+ syncExplicit = true;
70
+ }
71
+ else if (arg === "--ci") {
72
+ // Already handled above, just skip
73
+ }
74
+ else if (arg === "--bail") {
75
+ options.bail = true;
76
+ }
77
+ else if (arg === "--realtime") {
78
+ options.realtime = true;
79
+ }
80
+ else if (arg === "--help" || arg === "-h") {
81
+ // Display help text
82
+ console.log(`
83
+ Smoke Test Usage:
84
+ node smoke-test.mjs [options]
85
+
86
+ Options:
87
+ --url=PATH Custom URL path to test (e.g., "/login")
88
+ --skip-dev Skip testing the local development server
89
+ --skip-release Skip testing the release/production deployment
90
+ --skip-client Skip client-side tests, only run server-side checks
91
+ --skip-hmr Skip hot module replacement (HMR) tests
92
+ --path=PATH Project directory to test
93
+ --artifact-dir=DIR Directory to store test artifacts (default: .artifacts)
94
+ --keep Keep temporary test directory after tests complete
95
+ --no-headless Run browser tests with GUI (not headless)
96
+ --sync Force syncing SDK code to test project
97
+ --no-sync Disable syncing SDK code to test project
98
+ --ci Run in CI mode (keeps temp dirs, sets headless)
99
+ --bail Stop on first test failure
100
+ --copy-project Copy the project to the artifacts directory
101
+ --realtime Only run realtime smoke tests, skip initial tests
102
+ --help Show this help message
103
+ `);
104
+ process.exit(0);
105
+ }
106
+ else if (arg.startsWith("--path=")) {
107
+ options.projectDir = arg.substring(7);
108
+ }
109
+ else if (arg.startsWith("--artifact-dir=")) {
110
+ options.artifactDir = arg.substring(15);
111
+ }
112
+ else if (arg.startsWith("--url=")) {
113
+ options.customPath = arg.substring(6);
114
+ }
115
+ else if (!arg.startsWith("--")) {
116
+ // For backwards compatibility, any non-flag argument is treated as the custom path
117
+ console.log(`Setting URL path to "${arg}" (use --url= format in the future)`);
118
+ options.customPath = arg;
119
+ }
120
+ else {
121
+ // Throw error for unknown options instead of just warning
122
+ log("Unknown option: %s", arg);
123
+ throw new Error(`Unknown option: ${arg}. Use --help to see available options.`);
124
+ }
125
+ }
126
+ // Async IIFE to determine sync default and run main
127
+ (async () => {
128
+ if (syncExplicit !== undefined) {
129
+ options.sync = syncExplicit;
130
+ }
131
+ else {
132
+ // Determine default for sync: true if cwd has package.json with name 'rwsdk', otherwise false
133
+ let syncDefault = false;
134
+ const pkgPath = join(process.cwd(), "package.json");
135
+ log(`[sync default] Checking for package.json at: %s`, pkgPath);
136
+ try {
137
+ const pkgRaw = await import("fs/promises").then((fs) => fs.readFile(pkgPath, "utf8"));
138
+ log(`[sync default] Read package.json: %s`, pkgRaw);
139
+ const pkg = JSON.parse(pkgRaw);
140
+ if (pkg && pkg.name === "rwsdk") {
141
+ log(`[sync default] package.json name is 'rwsdk', setting syncDefault = true`);
142
+ syncDefault = true;
143
+ }
144
+ else {
145
+ log(`[sync default] package.json name is not 'rwsdk', setting syncDefault = false`);
146
+ }
147
+ }
148
+ catch (e) {
149
+ log(`[sync default] Could not read package.json or parse name: %O`, e);
150
+ log(`[sync default] Defaulting syncDefault = false`);
151
+ }
152
+ log(`[sync default] Final syncDefault value: %s`, syncDefault);
153
+ options.sync = syncDefault;
154
+ }
155
+ log("Parsed options: %O", options);
156
+ // Run the smoke tests with the parsed options
157
+ try {
158
+ await runSmokeTests(options);
159
+ }
160
+ catch (error) {
161
+ log("Error running smoke tests: %O", error);
162
+ console.error(`Error running smoke tests: ${error instanceof Error ? error.message : String(error)}`);
163
+ process.exit(1);
164
+ }
165
+ })();
166
+ }
@@ -0,0 +1 @@
1
+ export declare const runWorkerScript: (relativeScriptPath: string) => Promise<never>;
@@ -0,0 +1,82 @@
1
+ import { resolve } from "path";
2
+ import { writeFile } from "fs/promises";
3
+ import { unstable_readConfig } from "wrangler";
4
+ import { createServer as createViteServer } from "vite";
5
+ import tmp from "tmp-promise";
6
+ import baseDebug from "debug";
7
+ import { redwood } from "../vite/index.mjs";
8
+ import { findWranglerConfig } from "../lib/findWranglerConfig.mjs";
9
+ const debug = baseDebug("rwsdk:worker-run");
10
+ export const runWorkerScript = async (relativeScriptPath) => {
11
+ if (!relativeScriptPath) {
12
+ console.error("Error: Script path is required");
13
+ console.log("\nUsage:");
14
+ console.log(" npm run worker:run <script-path>");
15
+ console.log("\nExample:");
16
+ console.log(" npm run worker:run src/scripts/seed.ts\n");
17
+ process.exit(1);
18
+ }
19
+ const scriptPath = resolve(process.cwd(), relativeScriptPath);
20
+ debug("Running worker script: %s", scriptPath);
21
+ const workerConfigPath = await findWranglerConfig(process.cwd());
22
+ debug("Using wrangler config: %s", workerConfigPath);
23
+ const workerConfig = unstable_readConfig({
24
+ config: workerConfigPath,
25
+ });
26
+ const tmpWorkerPath = await tmp.file({
27
+ postfix: ".json",
28
+ });
29
+ const scriptWorkerConfig = {
30
+ ...workerConfig,
31
+ configPath: tmpWorkerPath.path,
32
+ userConfigPath: tmpWorkerPath.path,
33
+ main: scriptPath,
34
+ };
35
+ try {
36
+ await writeFile(tmpWorkerPath.path, JSON.stringify(scriptWorkerConfig, null, 2));
37
+ debug("Worker config written to: %s", tmpWorkerPath.path);
38
+ process.env.RWSDK_WORKER_RUN = "1";
39
+ const server = await createViteServer({
40
+ configFile: false,
41
+ plugins: [
42
+ redwood({
43
+ configPath: tmpWorkerPath.path,
44
+ includeCloudflarePlugin: true,
45
+ entry: {
46
+ worker: scriptPath,
47
+ },
48
+ }),
49
+ ],
50
+ server: {
51
+ port: 0,
52
+ },
53
+ });
54
+ debug("Vite server created");
55
+ try {
56
+ await server.listen();
57
+ const address = server.httpServer?.address();
58
+ debug("Server listening on address: %o", address);
59
+ if (!address || typeof address === "string") {
60
+ throw new Error("Dev server address is invalid");
61
+ }
62
+ debug("Fetching worker...");
63
+ await fetch(`http://localhost:${address.port}/`);
64
+ debug("Worker fetched successfully");
65
+ }
66
+ finally {
67
+ debug("Closing server...");
68
+ await server.close();
69
+ debug("Server closed");
70
+ }
71
+ }
72
+ finally {
73
+ debug("Closing inspector servers...");
74
+ await tmpWorkerPath.cleanup();
75
+ debug("Temporary files cleaned up");
76
+ }
77
+ // todo(justinvdm, 01 Apr 2025): Investigate what handles are remaining open
78
+ process.exit(0);
79
+ };
80
+ if (import.meta.url === new URL(process.argv[1], import.meta.url).href) {
81
+ runWorkerScript(process.argv[2]);
82
+ }
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "vite";
2
+ export declare const aliasByEnvPlugin: (aliasesByEnv: Record<string, Record<string, string>>) => Plugin;
@@ -0,0 +1,11 @@
1
+ export const aliasByEnvPlugin = (aliasesByEnv) => ({
2
+ name: "rw-sdk-env-alias",
3
+ enforce: "pre",
4
+ resolveId(id, importer) {
5
+ const aliases = aliasesByEnv[this.environment.name] ?? {};
6
+ const alias = aliases[id];
7
+ if (alias) {
8
+ return alias;
9
+ }
10
+ },
11
+ });
@@ -0,0 +1,6 @@
1
+ import { Plugin } from "vite";
2
+ export declare const asyncSetupPlugin: ({ setup, }: {
3
+ setup: ({ command }: {
4
+ command: "serve" | "build";
5
+ }) => Promise<unknown>;
6
+ }) => Plugin[];
@@ -0,0 +1,23 @@
1
+ export const asyncSetupPlugin = ({ setup, }) => {
2
+ let taskPromise = Promise.resolve(null);
3
+ return [
4
+ {
5
+ name: "rw-sdk-async-setup:serve",
6
+ apply: "serve",
7
+ configureServer(server) {
8
+ taskPromise = setup({ command: "serve" });
9
+ server.middlewares.use(async (_req, _res, next) => {
10
+ await taskPromise;
11
+ next();
12
+ });
13
+ },
14
+ },
15
+ {
16
+ name: "rw-sdk-async-setup:build",
17
+ apply: "build",
18
+ async buildStart() {
19
+ await setup({ command: "build" });
20
+ },
21
+ },
22
+ ];
23
+ };
@@ -0,0 +1,6 @@
1
+ export type PrismaCheckResult = {
2
+ isUsingPrisma: boolean;
3
+ };
4
+ export declare const checkPrismaStatus: ({ projectRootDir, }: {
5
+ projectRootDir: string;
6
+ }) => PrismaCheckResult;
@@ -0,0 +1,18 @@
1
+ import enhancedResolve from "enhanced-resolve";
2
+ const isUsingPrisma = ({ projectRootDir }) => {
3
+ try {
4
+ const prismaClientPath = enhancedResolve.sync(projectRootDir, "@prisma/client");
5
+ if (!prismaClientPath) {
6
+ return false;
7
+ }
8
+ return true;
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ };
14
+ export const checkPrismaStatus = ({ projectRootDir, }) => {
15
+ return {
16
+ isUsingPrisma: isUsingPrisma({ projectRootDir }),
17
+ };
18
+ };
@@ -0,0 +1,9 @@
1
+ import { Plugin } from "vite";
2
+ export declare const cloudflareBuiltInModules: string[];
3
+ export declare const externalModules: string[];
4
+ export declare const configPlugin: ({ silent, projectRootDir, clientEntryPathnames, workerEntryPathname, }: {
5
+ silent: boolean;
6
+ projectRootDir: string;
7
+ clientEntryPathnames: string[];
8
+ workerEntryPathname: string;
9
+ }) => Plugin;
@@ -0,0 +1,169 @@
1
+ import path, { resolve } from "node:path";
2
+ import { builtinModules } from "node:module";
3
+ import enhancedResolve from "enhanced-resolve";
4
+ import { SSR_BRIDGE_PATH } from "../lib/constants.mjs";
5
+ // port(justinvdm, 09 Jun 2025):
6
+ // https://github.com/cloudflare/workers-sdk/blob/d533f5ee7da69c205d8d5e2a5f264d2370fc612b/packages/vite-plugin-cloudflare/src/cloudflare-environment.ts#L123-L128
7
+ export const cloudflareBuiltInModules = [
8
+ "cloudflare:email",
9
+ "cloudflare:sockets",
10
+ "cloudflare:workers",
11
+ "cloudflare:workflows",
12
+ ];
13
+ export const externalModules = [
14
+ ...cloudflareBuiltInModules,
15
+ ...builtinModules,
16
+ ...builtinModules.map((m) => `node:${m}`),
17
+ ];
18
+ export const configPlugin = ({ silent, projectRootDir, clientEntryPathnames, workerEntryPathname, }) => ({
19
+ name: "rwsdk:config",
20
+ config: async (_) => {
21
+ const mode = process.env.NODE_ENV;
22
+ const baseConfig = {
23
+ appType: "custom",
24
+ mode,
25
+ logLevel: silent ? "silent" : "info",
26
+ build: {
27
+ minify: mode !== "development",
28
+ sourcemap: true,
29
+ },
30
+ define: {
31
+ "process.env.NODE_ENV": JSON.stringify(mode),
32
+ },
33
+ ssr: {
34
+ target: "webworker",
35
+ },
36
+ environments: {
37
+ client: {
38
+ consumer: "client",
39
+ build: {
40
+ outDir: resolve(projectRootDir, "dist", "client"),
41
+ manifest: true,
42
+ rollupOptions: {
43
+ input: clientEntryPathnames,
44
+ },
45
+ },
46
+ define: {
47
+ "import.meta.env.RWSDK_ENV": JSON.stringify("client"),
48
+ },
49
+ optimizeDeps: {
50
+ noDiscovery: false,
51
+ include: ["rwsdk/client"],
52
+ esbuildOptions: {
53
+ jsx: "automatic",
54
+ jsxImportSource: "react",
55
+ plugins: [],
56
+ define: {
57
+ "process.env.NODE_ENV": JSON.stringify(mode),
58
+ },
59
+ },
60
+ },
61
+ resolve: {
62
+ conditions: ["browser", "module"],
63
+ },
64
+ },
65
+ ssr: {
66
+ resolve: {
67
+ conditions: ["workerd", "module", "browser"],
68
+ noExternal: true,
69
+ },
70
+ define: {
71
+ "import.meta.env.RWSDK_ENV": JSON.stringify("ssr"),
72
+ },
73
+ optimizeDeps: {
74
+ noDiscovery: false,
75
+ entries: [workerEntryPathname],
76
+ exclude: externalModules,
77
+ include: ["rwsdk/__ssr", "rwsdk/__ssr_bridge"],
78
+ esbuildOptions: {
79
+ jsx: "automatic",
80
+ jsxImportSource: "react",
81
+ plugins: [],
82
+ define: {
83
+ "process.env.NODE_ENV": JSON.stringify(mode),
84
+ },
85
+ },
86
+ },
87
+ build: {
88
+ lib: {
89
+ entry: {
90
+ [path.basename(SSR_BRIDGE_PATH, ".js")]: enhancedResolve.sync(projectRootDir, "rwsdk/__ssr_bridge"),
91
+ },
92
+ formats: ["es"],
93
+ fileName: () => path.basename(SSR_BRIDGE_PATH),
94
+ },
95
+ outDir: path.dirname(SSR_BRIDGE_PATH),
96
+ },
97
+ },
98
+ worker: {
99
+ resolve: {
100
+ conditions: [
101
+ "workerd",
102
+ "react-server",
103
+ "module",
104
+ // context(justinvdm, 11 Jun 2025): Some packages meant for cloudflare workers, yet
105
+ // their deps have only node import conditions, e.g. `agents` package (meant for CF),
106
+ // has `pkce-challenge` package as a dep, which has only node import conditions.
107
+ // https://github.com/crouchcd/pkce-challenge/blob/master/package.json#L17
108
+ //
109
+ // @cloudflare/vite-plugin should take care of any relevant polyfills for deps with
110
+ // node builtins imports that can be polyfilled though, so it is worth us including this condition here.
111
+ // However, it does mean we will try to run packages meant for node that cannot be run on cloudflare workers.
112
+ // That's the trade-off, but arguably worth it.
113
+ "node",
114
+ ],
115
+ noExternal: true,
116
+ },
117
+ define: {
118
+ "import.meta.env.RWSDK_ENV": JSON.stringify("worker"),
119
+ },
120
+ optimizeDeps: {
121
+ noDiscovery: false,
122
+ include: ["rwsdk/worker"],
123
+ exclude: [],
124
+ entries: [workerEntryPathname],
125
+ esbuildOptions: {
126
+ jsx: "automatic",
127
+ jsxImportSource: "react",
128
+ define: {
129
+ "process.env.NODE_ENV": JSON.stringify(mode),
130
+ },
131
+ },
132
+ },
133
+ build: {
134
+ outDir: resolve(projectRootDir, "dist", "worker"),
135
+ emitAssets: true,
136
+ ssr: true,
137
+ rollupOptions: {
138
+ output: {
139
+ inlineDynamicImports: true,
140
+ },
141
+ input: {
142
+ worker: workerEntryPathname,
143
+ },
144
+ },
145
+ },
146
+ },
147
+ },
148
+ server: {
149
+ hmr: true,
150
+ },
151
+ builder: {
152
+ buildApp: async (builder) => {
153
+ // note(justinvdm, 27 May 2025): **Ordering is important**:
154
+ // * When building, client needs to be build first, so that we have a
155
+ // manifest file to map to when looking at asset references in JSX
156
+ // (e.g. Document.tsx)
157
+ // * When bundling, the RSC build imports the SSR build - this way
158
+ // they each can have their own environments (e.g. with their own
159
+ // import conditions), while still having all worker-run code go
160
+ // through the processing done by `@cloudflare/vite-plugin`
161
+ await builder.build(builder.environments["client"]);
162
+ await builder.build(builder.environments["ssr"]);
163
+ await builder.build(builder.environments["worker"]);
164
+ },
165
+ },
166
+ };
167
+ return baseConfig;
168
+ },
169
+ });
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "vite";
2
+ export declare const copyPrismaWasmPlugin: ({ rootDir, }: {
3
+ rootDir: string;
4
+ }) => Plugin;
@@ -0,0 +1,32 @@
1
+ import { copy, pathExists } from "fs-extra";
2
+ import { resolve } from "node:path";
3
+ import MagicString from "magic-string";
4
+ import path from "path";
5
+ export const copyPrismaWasmPlugin = ({ rootDir, }) => ({
6
+ name: "rwsdk:copy-prisma-wasm",
7
+ enforce: "post",
8
+ apply: "build",
9
+ async writeBundle() {
10
+ const wasmFilePath = resolve(rootDir, "node_modules/.prisma/client/query_engine_bg.wasm");
11
+ const fileName = path.basename(wasmFilePath);
12
+ const outputPath = path.resolve(rootDir, "dist", "worker", fileName);
13
+ if (await pathExists(wasmFilePath)) {
14
+ await copy(wasmFilePath, outputPath);
15
+ console.log(`✅ Copied ${fileName} from ${wasmFilePath} to ${outputPath}`);
16
+ }
17
+ },
18
+ renderChunk(code) {
19
+ if (!code.includes(".wasm")) {
20
+ return;
21
+ }
22
+ const s = new MagicString(code);
23
+ s.replace(/import\(["'](.+?\.wasm)["']\)/g, (_, filePath) => {
24
+ const fileName = path.basename(filePath);
25
+ return `import("./${fileName}")`;
26
+ });
27
+ return {
28
+ code: s.toString(),
29
+ map: s.generateMap(),
30
+ };
31
+ },
32
+ });
@@ -0,0 +1,21 @@
1
+ import { Plugin } from "vite";
2
+ interface DirectiveLookupConfig {
3
+ kind: "client" | "server";
4
+ directive: "use client" | "use server";
5
+ virtualModuleName: string;
6
+ exportName: string;
7
+ pluginName: string;
8
+ optimizeForEnvironments?: string[];
9
+ }
10
+ export declare const findFilesContainingDirective: ({ projectRootDir, files, directive, debugNamespace, }: {
11
+ projectRootDir: string;
12
+ files: Set<string>;
13
+ directive: string;
14
+ debugNamespace: string;
15
+ }) => Promise<void>;
16
+ export declare const createDirectiveLookupPlugin: ({ projectRootDir, files, config, }: {
17
+ projectRootDir: string;
18
+ files: Set<string>;
19
+ config: DirectiveLookupConfig;
20
+ }) => Promise<Plugin>;
21
+ export {};