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,231 @@
1
+ import MagicString from "magic-string";
2
+ import path from "path";
3
+ import { readFile } from "fs/promises";
4
+ import debug from "debug";
5
+ import { normalizeModulePath } from "./normalizeModulePath.mjs";
6
+ import { pathExists } from "fs-extra";
7
+ import { stat } from "fs/promises";
8
+ import { getSrcPaths } from "../lib/getSrcPaths.js";
9
+ import { hasDirective } from "./hasDirective.mjs";
10
+ export const findFilesContainingDirective = async ({ projectRootDir, files, directive, debugNamespace, }) => {
11
+ const log = debug(debugNamespace);
12
+ log("Starting search for '%s' files in projectRootDir=%s", directive, projectRootDir);
13
+ const filesToScan = await getSrcPaths(projectRootDir);
14
+ log("Found %d files to scan for '%s' directive", filesToScan.length, directive);
15
+ for (const file of filesToScan) {
16
+ try {
17
+ const stats = await stat(file);
18
+ if (!stats.isFile()) {
19
+ process.env.VERBOSE && log("Skipping %s (not a file)", file);
20
+ continue;
21
+ }
22
+ process.env.VERBOSE && log("Scanning file: %s", file);
23
+ const content = await readFile(file, "utf-8");
24
+ if (hasDirective(content, directive)) {
25
+ const normalizedPath = normalizeModulePath(projectRootDir, file);
26
+ log("Found '%s' directive in file: %s -> %s", directive, file, normalizedPath);
27
+ files.add(normalizedPath);
28
+ }
29
+ }
30
+ catch (error) {
31
+ console.error(`Error reading file ${file}:`, error);
32
+ }
33
+ }
34
+ log("Completed scan. Found %d %s files total", files.size, directive);
35
+ process.env.VERBOSE &&
36
+ log("Found files for %s: %j", directive, Array.from(files));
37
+ };
38
+ const resolveOptimizedDep = async (projectRootDir, id, environment, debugNamespace) => {
39
+ const log = debug(debugNamespace);
40
+ try {
41
+ const depsDir = environment === "client" ? "deps" : `deps_${environment}`;
42
+ const nodeModulesDepsDirPath = path.join("node_modules", ".vite", depsDir);
43
+ const depsDirPath = path.join(projectRootDir, nodeModulesDepsDirPath);
44
+ const manifestPath = path.join(depsDirPath, "_metadata.json");
45
+ log("Checking for manifest at: %s", manifestPath);
46
+ const manifestExists = await pathExists(manifestPath);
47
+ if (!manifestExists) {
48
+ log("Manifest not found at %s", manifestPath);
49
+ return undefined;
50
+ }
51
+ const manifestContent = await readFile(manifestPath, "utf-8");
52
+ const manifest = JSON.parse(manifestContent);
53
+ if (manifest.optimized && manifest.optimized[id]) {
54
+ const optimizedFile = manifest.optimized[id].file;
55
+ const optimizedPath = path.join("/", nodeModulesDepsDirPath, optimizedFile);
56
+ log("Found optimized dependency: filePath=%s, optimizedPath=%s", id, optimizedPath);
57
+ return optimizedPath;
58
+ }
59
+ process.env.VERBOSE &&
60
+ log("File not found in optimized dependencies: id=%s", id);
61
+ return undefined;
62
+ }
63
+ catch (error) {
64
+ process.env.VERBOSE &&
65
+ log("Error resolving optimized dependency for id=%s: %s", id, error);
66
+ return undefined;
67
+ }
68
+ };
69
+ const addOptimizedDepsEntries = async ({ projectRootDir, directive, environment, debugNamespace, files, }) => {
70
+ const log = debug(debugNamespace);
71
+ try {
72
+ const depsDir = environment === "client" ? "deps" : `deps_${environment}`;
73
+ const depsDirPath = path.join(projectRootDir, "node_modules", ".vite", depsDir);
74
+ const manifestPath = path.join(depsDirPath, "_metadata.json");
75
+ process.env.VERBOSE && log("Checking for manifest at: %s", manifestPath);
76
+ const manifestExists = await pathExists(manifestPath);
77
+ if (!manifestExists) {
78
+ process.env.VERBOSE && log("Manifest not found at %s", manifestPath);
79
+ return;
80
+ }
81
+ const manifestContent = await readFile(manifestPath, "utf-8");
82
+ const manifest = JSON.parse(manifestContent);
83
+ for (const entryId of Object.keys(manifest.optimized)) {
84
+ if (entryId.startsWith("/node_modules/")) {
85
+ const srcPath = manifest.optimized[entryId].src;
86
+ const resolvedSrcPath = path.resolve(projectRootDir, "node_modules", ".vite", "deps", srcPath);
87
+ let contents;
88
+ try {
89
+ contents = await readFile(resolvedSrcPath, "utf-8");
90
+ }
91
+ catch (error) {
92
+ process.env.VERBOSE &&
93
+ log("Error reading file %s: %s", resolvedSrcPath, error);
94
+ continue;
95
+ }
96
+ if (hasDirective(contents, directive)) {
97
+ log("Adding optimized entry to files: %s", entryId);
98
+ files.add(entryId);
99
+ }
100
+ else {
101
+ log("Skipping optimized entry %s because it does not contain the '%s' directive", entryId, directive);
102
+ }
103
+ }
104
+ }
105
+ }
106
+ catch (error) {
107
+ process.env.VERBOSE &&
108
+ log("Error adding optimized deps entries: %s", error);
109
+ }
110
+ };
111
+ export const createDirectiveLookupPlugin = async ({ projectRootDir, files, config, }) => {
112
+ const debugNamespace = `rwsdk:vite:${config.pluginName}`;
113
+ const log = debug(debugNamespace);
114
+ let isDev = false;
115
+ log("Initializing %s plugin with projectRootDir=%s", config.pluginName, projectRootDir);
116
+ await findFilesContainingDirective({
117
+ projectRootDir,
118
+ files,
119
+ directive: config.directive,
120
+ debugNamespace,
121
+ });
122
+ let devServer;
123
+ return {
124
+ name: `rwsdk:${config.pluginName}`,
125
+ config(_, { command, isPreview }) {
126
+ isDev = !isPreview && command === "serve";
127
+ log("Development mode: %s", isDev);
128
+ },
129
+ configureServer(server) {
130
+ devServer = server;
131
+ },
132
+ async configEnvironment(env, viteConfig) {
133
+ log("Configuring environment: env=%s", env);
134
+ // Add optimized deps entries that match our pattern
135
+ await addOptimizedDepsEntries({
136
+ projectRootDir,
137
+ files,
138
+ directive: config.directive,
139
+ environment: env,
140
+ debugNamespace,
141
+ });
142
+ viteConfig.optimizeDeps ??= {};
143
+ viteConfig.optimizeDeps.esbuildOptions ??= {};
144
+ viteConfig.optimizeDeps.esbuildOptions.plugins ??= [];
145
+ viteConfig.optimizeDeps.esbuildOptions.plugins.push({
146
+ name: `rwsdk:${config.pluginName}`,
147
+ setup(build) {
148
+ log("Setting up esbuild plugin for %s", config.virtualModuleName);
149
+ // Handle both direct virtual module name and /@id/ prefixed version
150
+ const escapedVirtualModuleName = config.virtualModuleName.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
151
+ const escapedPrefixedModuleName = `/@id/${config.virtualModuleName}`.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
152
+ build.onResolve({
153
+ filter: new RegExp(`^(${escapedVirtualModuleName}|${escapedPrefixedModuleName})\.js$`),
154
+ }, () => {
155
+ process.env.VERBOSE &&
156
+ log("Esbuild onResolve: marking %s as external", config.virtualModuleName);
157
+ return {
158
+ path: `${config.virtualModuleName}.js`,
159
+ external: true,
160
+ };
161
+ });
162
+ },
163
+ });
164
+ const shouldOptimizeForEnv = !config.optimizeForEnvironments ||
165
+ config.optimizeForEnvironments.includes(env);
166
+ if (shouldOptimizeForEnv) {
167
+ log("Applying optimizeDeps and aliasing for environment: %s", env);
168
+ viteConfig.optimizeDeps.include ??= [];
169
+ for (const file of files) {
170
+ const actualFilePath = path.join(projectRootDir, file);
171
+ process.env.VERBOSE &&
172
+ log("Adding to optimizeDeps.entries: %s", actualFilePath);
173
+ const entries = Array.isArray(viteConfig.optimizeDeps.entries)
174
+ ? viteConfig.optimizeDeps.entries
175
+ : [].concat(viteConfig.optimizeDeps.entries ?? []);
176
+ viteConfig.optimizeDeps.entries = entries;
177
+ entries.push(actualFilePath);
178
+ }
179
+ log("Environment configuration complete for env=%s", env);
180
+ }
181
+ else {
182
+ log("Skipping optimizeDeps and aliasing for environment: %s", env);
183
+ }
184
+ },
185
+ resolveId(source) {
186
+ process.env.VERBOSE && log("Resolving id=%s", source);
187
+ if (source === `${config.virtualModuleName}.js`) {
188
+ log("Resolving %s module", config.virtualModuleName);
189
+ // context(justinvdm, 16 Jun 2025): Include .js extension
190
+ // so it goes through vite processing chain
191
+ return source;
192
+ }
193
+ process.env.VERBOSE && log("No resolution for id=%s", source);
194
+ },
195
+ async load(id) {
196
+ process.env.VERBOSE && log("Loading id=%s", id);
197
+ if (id === config.virtualModuleName + ".js") {
198
+ log("Loading %s module with %d files", config.virtualModuleName, files.size);
199
+ const environment = this.environment?.name || "client";
200
+ log("Current environment: %s, isDev: %s", environment, isDev);
201
+ const optimizedDeps = {};
202
+ if (isDev && devServer) {
203
+ for (const file of files) {
204
+ const resolvedPath = await resolveOptimizedDep(projectRootDir, file, environment, debugNamespace);
205
+ if (resolvedPath) {
206
+ optimizedDeps[file] = resolvedPath;
207
+ }
208
+ }
209
+ }
210
+ const s = new MagicString(`
211
+ export const ${config.exportName} = {
212
+ ${Array.from(files)
213
+ .map((file) => `
214
+ "${file}": () => import("${optimizedDeps[file] ?? file}"),
215
+ `)
216
+ .join("")}
217
+ };
218
+ `);
219
+ const code = s.toString();
220
+ const map = s.generateMap();
221
+ log("Generated virtual module code length: %d", code.length);
222
+ process.env.VERBOSE && log("Generated virtual module code: %s", code);
223
+ return {
224
+ code,
225
+ map,
226
+ };
227
+ }
228
+ process.env.VERBOSE && log("No load handling for id=%s", id);
229
+ },
230
+ };
231
+ };
@@ -0,0 +1,4 @@
1
+ import { Plugin } from "vite";
2
+ export declare const customReactBuildPlugin: ({ projectRootDir, }: {
3
+ projectRootDir: string;
4
+ }) => Promise<Plugin>;
@@ -0,0 +1,61 @@
1
+ import { resolve } from "path";
2
+ import { mkdirp, copy } from "fs-extra";
3
+ import { VENDOR_DIST_DIR } from "../lib/constants.mjs";
4
+ const copyReactFiles = async (viteDistDir) => {
5
+ await mkdirp(viteDistDir);
6
+ await copy(resolve(VENDOR_DIST_DIR, "react.js"), resolve(viteDistDir, "react.js"));
7
+ await copy(resolve(VENDOR_DIST_DIR, "react.js.map"), resolve(viteDistDir, "react.js.map"));
8
+ await copy(resolve(VENDOR_DIST_DIR, "react-dom-server-edge.js"), resolve(viteDistDir, "react-dom-server-edge.js"));
9
+ await copy(resolve(VENDOR_DIST_DIR, "react-dom-server-edge.js.map"), resolve(viteDistDir, "react-dom-server-edge.js.map"));
10
+ };
11
+ export const customReactBuildPlugin = async ({ projectRootDir, }) => {
12
+ const viteDistDir = resolve(projectRootDir, "node_modules", ".vite_@redwoodjs/sdk");
13
+ await copyReactFiles(viteDistDir);
14
+ return {
15
+ name: "custom-react-build-plugin",
16
+ enforce: "pre",
17
+ applyToEnvironment: (environment) => {
18
+ return environment.name === "worker";
19
+ },
20
+ async configureServer() {
21
+ await mkdirp(viteDistDir);
22
+ await copy(resolve(VENDOR_DIST_DIR, "react.js"), resolve(viteDistDir, "react.js"));
23
+ await copy(resolve(VENDOR_DIST_DIR, "react.js.map"), resolve(viteDistDir, "react.js.map"));
24
+ await copy(resolve(VENDOR_DIST_DIR, "react-dom-server-edge.js"), resolve(viteDistDir, "react-dom-server-edge.js"));
25
+ await copy(resolve(VENDOR_DIST_DIR, "react-dom-server-edge.js.map"), resolve(viteDistDir, "react-dom-server-edge.js.map"));
26
+ },
27
+ resolveId(id) {
28
+ if (id === "react") {
29
+ return resolve(viteDistDir, "react.js");
30
+ }
31
+ if (id === "react-dom/server.edge" || id === "react-dom/server") {
32
+ return resolve(viteDistDir, "react-dom-server-edge.js");
33
+ }
34
+ },
35
+ config: () => ({
36
+ environments: {
37
+ worker: {
38
+ optimizeDeps: {
39
+ esbuildOptions: {
40
+ plugins: [
41
+ {
42
+ name: "rewrite-react-imports",
43
+ setup(build) {
44
+ build.onResolve({ filter: /^react$/ }, (args) => {
45
+ return { path: resolve(viteDistDir, "react.js") };
46
+ });
47
+ build.onResolve({ filter: /^react-dom\/server\.edge$/ }, (args) => {
48
+ return {
49
+ path: resolve(viteDistDir, "react-dom-server-edge.js"),
50
+ };
51
+ });
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ },
57
+ },
58
+ },
59
+ }),
60
+ };
61
+ };
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "vite";
2
+ export declare const devServerTimingPlugin: () => Plugin;
@@ -0,0 +1,24 @@
1
+ import debug from "debug";
2
+ const log = debug("rwsdk:vite:dev-server-timing-plugin");
3
+ export const devServerTimingPlugin = () => {
4
+ const startTime = Date.now();
5
+ let hasLoggedFirstResponse = false;
6
+ return {
7
+ name: "rwsdk:dev-server-timing",
8
+ configureServer(server) {
9
+ server.middlewares.use((_req, res, next) => {
10
+ if (!hasLoggedFirstResponse) {
11
+ res.on("finish", () => {
12
+ if (!hasLoggedFirstResponse) {
13
+ hasLoggedFirstResponse = true;
14
+ const endTime = Date.now();
15
+ const duration = endTime - startTime;
16
+ log(`🚀 Dev server first response completed in ${duration}ms`);
17
+ }
18
+ });
19
+ }
20
+ next();
21
+ });
22
+ },
23
+ };
24
+ };
@@ -0,0 +1,6 @@
1
+ import { Plugin } from "vite";
2
+ export declare const directivesPlugin: ({ projectRootDir, clientFiles, serverFiles, }: {
3
+ projectRootDir: string;
4
+ clientFiles: Set<string>;
5
+ serverFiles: Set<string>;
6
+ }) => Plugin;
@@ -0,0 +1,200 @@
1
+ import path from "node:path";
2
+ import fs from "node:fs/promises";
3
+ import debug from "debug";
4
+ import { transformClientComponents } from "./transformClientComponents.mjs";
5
+ import { transformServerFunctions } from "./transformServerFunctions.mjs";
6
+ import { normalizeModulePath } from "./normalizeModulePath.mjs";
7
+ const log = debug("rwsdk:vite:rsc-directives-plugin");
8
+ const getLoader = (filePath) => {
9
+ const ext = path.extname(filePath).slice(1);
10
+ switch (ext) {
11
+ case "mjs":
12
+ case "cjs":
13
+ return "js";
14
+ case "mts":
15
+ case "cts":
16
+ return "ts";
17
+ case "jsx":
18
+ return "jsx";
19
+ case "tsx":
20
+ return "tsx";
21
+ case "ts":
22
+ return "ts";
23
+ case "js":
24
+ default:
25
+ return "js";
26
+ }
27
+ };
28
+ export const directivesPlugin = ({ projectRootDir, clientFiles, serverFiles, }) => {
29
+ let devServer;
30
+ let isAfterFirstResponse = false;
31
+ const addModule = (kind, environment, id) => {
32
+ const files = kind === "client" ? clientFiles : serverFiles;
33
+ const rawId = id.split("?")[0];
34
+ const resolvedId = rawId;
35
+ const relativePath = rawId.slice("/".length);
36
+ const fullPath = path.resolve(projectRootDir, relativePath);
37
+ const isNodeModule = id.includes("node_modules");
38
+ const hadFile = files.has(id);
39
+ log("Adding %s module to %s and invalidating cache: id=%s", kind, files, resolvedId);
40
+ files.add(resolvedId);
41
+ if (devServer && isNodeModule) {
42
+ const lookupModule = kind === "client"
43
+ ? "virtual:use-client-lookup"
44
+ : "virtual:use-server-lookup";
45
+ log("Registering missing import for %s module resolvedId=%s in environment %s, fullPath=%s", kind, resolvedId, environment, fullPath);
46
+ devServer.environments[environment].depsOptimizer?.registerMissingImport(resolvedId, fullPath);
47
+ if (isAfterFirstResponse && !hadFile) {
48
+ log("Invalidating cache for lookup module %s after adding module id=%s", lookupModule, id);
49
+ }
50
+ }
51
+ };
52
+ const addClientModule = (environment, id) => {
53
+ addModule("client", environment, id);
54
+ };
55
+ const addServerModule = (environment, id) => {
56
+ addModule("server", environment, id);
57
+ };
58
+ return {
59
+ name: "rwsdk:rsc-directives",
60
+ configureServer(server) {
61
+ devServer = server;
62
+ devServer.middlewares.use((_req, res, next) => {
63
+ // context(justinvdm, 15 Jun 2025): We want to watch for new client and server modules
64
+ // and invalidate their respective module lookups when this happens, but
65
+ // we only want to do this after the first render
66
+ if (!isAfterFirstResponse) {
67
+ res.on("finish", () => {
68
+ if (!isAfterFirstResponse) {
69
+ isAfterFirstResponse = true;
70
+ log("Dev server first response completed");
71
+ }
72
+ });
73
+ }
74
+ next();
75
+ });
76
+ },
77
+ async transform(code, id) {
78
+ process.env.VERBOSE &&
79
+ log("Transform called for id=%s, environment=%s", id, this.environment.name);
80
+ const normalizedId = normalizeModulePath(projectRootDir, id);
81
+ const clientResult = await transformClientComponents(code, normalizedId, {
82
+ environmentName: this.environment.name,
83
+ clientFiles,
84
+ addClientModule,
85
+ });
86
+ if (clientResult) {
87
+ log("Client component transformation successful for id=%s", id);
88
+ return {
89
+ code: clientResult.code,
90
+ map: clientResult.map,
91
+ };
92
+ }
93
+ const serverResult = transformServerFunctions(code, normalizedId, this.environment.name, serverFiles, addServerModule);
94
+ if (serverResult) {
95
+ log("Server function transformation successful for id=%s", id);
96
+ return {
97
+ code: serverResult.code,
98
+ map: serverResult.map,
99
+ };
100
+ }
101
+ process.env.VERBOSE && log("No transformation applied for id=%s", id);
102
+ },
103
+ configEnvironment(env, config) {
104
+ log("Configuring environment: env=%s", env);
105
+ config.optimizeDeps ??= {};
106
+ config.optimizeDeps.esbuildOptions ??= {};
107
+ config.optimizeDeps.esbuildOptions.plugins ??= [];
108
+ config.optimizeDeps.esbuildOptions.plugins.push({
109
+ name: "rsc-directives-esbuild-transform",
110
+ setup(build) {
111
+ log("Setting up esbuild plugin for environment: %s", env);
112
+ build.onLoad({ filter: /\.(js|ts|jsx|tsx|mts|mjs|cjs)$/ }, async (args) => {
113
+ process.env.VERBOSE &&
114
+ log("Esbuild onLoad called for environment=%s, path=%s", env, args.path);
115
+ const normalizedPath = normalizeModulePath(projectRootDir, args.path);
116
+ // context(justinvdm,2025-06-15): If we're in app code,
117
+ // we will be doing the transform work in the vite plugin hooks,
118
+ // the only reason we're in esbuild land for app code is for
119
+ // dependency discovery, so we can skip transform work
120
+ // and use heuristics instead - see below inside if block
121
+ if (!args.path.includes("node_modules")) {
122
+ log("Esbuild onLoad found app code, path=%s", args.path);
123
+ if (clientFiles.has(normalizedPath)) {
124
+ // context(justinvdm,2025-06-15): If this is a client file:
125
+ // * for ssr and client envs we can skip so esbuild looks at the
126
+ // original source code to discovery dependencies
127
+ // * for worker env, the transform would have just created
128
+ // references and dropped all imports, so we can just return empty code
129
+ if (env === "client" || env === "ssr") {
130
+ log("Esbuild onLoad skipping client module in app code for client or ssr env, path=%s", args.path);
131
+ return undefined;
132
+ }
133
+ else {
134
+ log("Esbuild onLoad returning empty code for server module in app code for worker env, path=%s to bypass esbuild dependency discovery", args.path);
135
+ return {
136
+ contents: "",
137
+ loader: "js",
138
+ };
139
+ }
140
+ }
141
+ else if (serverFiles.has(normalizedPath)) {
142
+ // context(justinvdm,2025-06-15): If this is a server file:
143
+ // * for worker env, we can skip so esbuild looks at the
144
+ // original source code to discovery dependencies
145
+ // * for ssr and client envs, the transform would have just created
146
+ // references and dropped all imports, so we can just return empty code
147
+ if (env === "worker") {
148
+ log("Esbuild onLoad skipping server module in app code for worker env, path=%s", args.path);
149
+ return undefined;
150
+ }
151
+ else if (env === "ssr" || env === "client") {
152
+ log("Esbuild onLoad returning empty code for server module in app code for ssr or client env, path=%s", args.path);
153
+ return {
154
+ contents: "",
155
+ loader: "js",
156
+ };
157
+ }
158
+ }
159
+ }
160
+ let code;
161
+ try {
162
+ code = await fs.readFile(args.path, "utf-8");
163
+ }
164
+ catch {
165
+ process.env.VERBOSE &&
166
+ log("Failed to read file: %s, environment=%s", args.path, env);
167
+ return undefined;
168
+ }
169
+ const clientResult = await transformClientComponents(code, normalizedPath, {
170
+ environmentName: env,
171
+ clientFiles,
172
+ isEsbuild: true,
173
+ addClientModule,
174
+ });
175
+ if (clientResult) {
176
+ log("Esbuild client component transformation successful for environment=%s, path=%s", env, args.path);
177
+ process.env.VERBOSE &&
178
+ log("Esbuild client component transformation for environment=%s, path=%s, code: %j", env, args.path, clientResult.code);
179
+ return {
180
+ contents: clientResult.code,
181
+ loader: getLoader(args.path),
182
+ };
183
+ }
184
+ const serverResult = transformServerFunctions(code, normalizedPath, env, serverFiles, addServerModule);
185
+ if (serverResult) {
186
+ log("Esbuild server function transformation successful for environment=%s, path=%s", env, args.path);
187
+ return {
188
+ contents: serverResult.code,
189
+ loader: getLoader(args.path),
190
+ };
191
+ }
192
+ process.env.VERBOSE &&
193
+ log("Esbuild no transformation applied for environment=%s, path=%s", env, args.path);
194
+ });
195
+ },
196
+ });
197
+ log("Environment configuration complete for env=%s", env);
198
+ },
199
+ };
200
+ };
@@ -0,0 +1,2 @@
1
+ import type { Alias, UserConfig } from "vite";
2
+ export declare const ensureAliasArray: (config: UserConfig) => Alias[];
@@ -0,0 +1,17 @@
1
+ export const ensureAliasArray = (config) => {
2
+ config.resolve ??= {};
3
+ if (!config.resolve?.alias) {
4
+ config.resolve.alias = [];
5
+ }
6
+ else if (!Array.isArray(config.resolve.alias)) {
7
+ const existingAlias = config.resolve.alias;
8
+ config.resolve.alias = Object.entries(existingAlias).map(([find, replacement]) => ({ find, replacement }));
9
+ }
10
+ else {
11
+ // context(justinvdm, 2025-05-29): The cloning here is necessary:
12
+ // vite (6.2.6) environments appear to be sharing the same alias
13
+ // array instance - presumably a result of a deep merge
14
+ return (config.resolve.alias = [...config.resolve.alias]);
15
+ }
16
+ return config.resolve.alias;
17
+ };
@@ -0,0 +1,31 @@
1
+ export declare const IMPORT_PATTERNS: string[];
2
+ export declare const EXPORT_PATTERNS: string[];
3
+ export interface ExportInfo {
4
+ name: string;
5
+ isDefault: boolean;
6
+ alias?: string;
7
+ originalName?: string;
8
+ isReExport?: boolean;
9
+ moduleSpecifier?: string;
10
+ }
11
+ /**
12
+ * Finds import specifiers and their positions in the code using the provided patterns.
13
+ * @param code The code to search for import specifiers.
14
+ * @param lang The language parser to use (TypeScript or Tsx).
15
+ * @param ignoredImportPatterns Array of regex patterns to ignore.
16
+ * @param log Optional logger function for debug output.
17
+ * @returns Array of objects with start, end, and raw import string.
18
+ */
19
+ export declare function findImportSpecifiers(id: string, code: string, ignoredImportPatterns: RegExp[], log?: (...args: any[]) => void): Array<{
20
+ s: number;
21
+ e: number;
22
+ raw: string;
23
+ }>;
24
+ /**
25
+ * Finds export information in the code using ast-grep patterns.
26
+ * @param id The file identifier for language detection.
27
+ * @param code The code to search for exports.
28
+ * @param log Optional logger function for debug output.
29
+ * @returns Array of export information objects.
30
+ */
31
+ export declare function findExports(id: string, code: string, log?: (...args: any[]) => void): ExportInfo[];