rwsdk 0.1.15 → 0.1.16

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 (287) hide show
  1. package/package.json +1 -1
  2. package/dist/lib/$.d.mts +0 -8
  3. package/dist/lib/$.mjs +0 -5
  4. package/dist/lib/constants.d.mts +0 -4
  5. package/dist/lib/constants.mjs +0 -6
  6. package/dist/lib/findWranglerConfig.d.mts +0 -1
  7. package/dist/lib/findWranglerConfig.mjs +0 -12
  8. package/dist/lib/getShortName.d.mts +0 -1
  9. package/dist/lib/getShortName.mjs +0 -2
  10. package/dist/lib/getSrcPaths.d.ts +0 -15
  11. package/dist/lib/getSrcPaths.js +0 -80
  12. package/dist/lib/hasPkgScript.d.mts +0 -1
  13. package/dist/lib/hasPkgScript.mjs +0 -9
  14. package/dist/lib/jsonUtils.d.mts +0 -28
  15. package/dist/lib/jsonUtils.mjs +0 -167
  16. package/dist/lib/setupEnvFiles.d.mts +0 -4
  17. package/dist/lib/setupEnvFiles.mjs +0 -31
  18. package/dist/lib/smokeTests/artifacts.d.mts +0 -10
  19. package/dist/lib/smokeTests/artifacts.mjs +0 -164
  20. package/dist/lib/smokeTests/browser.d.mts +0 -48
  21. package/dist/lib/smokeTests/browser.mjs +0 -1041
  22. package/dist/lib/smokeTests/cleanup.d.mts +0 -5
  23. package/dist/lib/smokeTests/cleanup.mjs +0 -214
  24. package/dist/lib/smokeTests/codeUpdates.d.mts +0 -8
  25. package/dist/lib/smokeTests/codeUpdates.mjs +0 -229
  26. package/dist/lib/smokeTests/constants.d.mts +0 -5
  27. package/dist/lib/smokeTests/constants.mjs +0 -10
  28. package/dist/lib/smokeTests/development.d.mts +0 -11
  29. package/dist/lib/smokeTests/development.mjs +0 -209
  30. package/dist/lib/smokeTests/environment.d.mts +0 -14
  31. package/dist/lib/smokeTests/environment.mjs +0 -163
  32. package/dist/lib/smokeTests/release.d.mts +0 -61
  33. package/dist/lib/smokeTests/release.mjs +0 -526
  34. package/dist/lib/smokeTests/reporting.d.mts +0 -13
  35. package/dist/lib/smokeTests/reporting.mjs +0 -355
  36. package/dist/lib/smokeTests/runSmokeTests.d.mts +0 -5
  37. package/dist/lib/smokeTests/runSmokeTests.mjs +0 -144
  38. package/dist/lib/smokeTests/state.d.mts +0 -48
  39. package/dist/lib/smokeTests/state.mjs +0 -57
  40. package/dist/lib/smokeTests/templates/SmokeTest.template.d.ts +0 -1
  41. package/dist/lib/smokeTests/templates/SmokeTest.template.js +0 -81
  42. package/dist/lib/smokeTests/templates/SmokeTestClient.template.d.ts +0 -1
  43. package/dist/lib/smokeTests/templates/SmokeTestClient.template.js +0 -159
  44. package/dist/lib/smokeTests/templates/smokeTestFunctions.template.d.ts +0 -1
  45. package/dist/lib/smokeTests/templates/smokeTestFunctions.template.js +0 -19
  46. package/dist/lib/smokeTests/types.d.mts +0 -75
  47. package/dist/lib/smokeTests/types.mjs +0 -1
  48. package/dist/lib/smokeTests/utils.d.mts +0 -15
  49. package/dist/lib/smokeTests/utils.mjs +0 -147
  50. package/dist/llms/index.d.ts +0 -3
  51. package/dist/llms/index.js +0 -35
  52. package/dist/llms/rules/interruptors.d.ts +0 -1
  53. package/dist/llms/rules/interruptors.js +0 -243
  54. package/dist/llms/rules/middleware.d.ts +0 -1
  55. package/dist/llms/rules/middleware.js +0 -71
  56. package/dist/llms/rules/react.d.ts +0 -1
  57. package/dist/llms/rules/react.js +0 -106
  58. package/dist/llms/rules/request-response.d.ts +0 -1
  59. package/dist/llms/rules/request-response.js +0 -209
  60. package/dist/runtime/client.d.ts +0 -17
  61. package/dist/runtime/client.js +0 -74
  62. package/dist/runtime/clientNavigation.d.ts +0 -4
  63. package/dist/runtime/clientNavigation.js +0 -53
  64. package/dist/runtime/clientNavigation.test.d.ts +0 -1
  65. package/dist/runtime/clientNavigation.test.js +0 -55
  66. package/dist/runtime/constants.d.ts +0 -1
  67. package/dist/runtime/constants.js +0 -1
  68. package/dist/runtime/entries/auth.d.ts +0 -1
  69. package/dist/runtime/entries/auth.js +0 -1
  70. package/dist/runtime/entries/client.d.ts +0 -4
  71. package/dist/runtime/entries/client.js +0 -4
  72. package/dist/runtime/entries/clientSSR.d.ts +0 -1
  73. package/dist/runtime/entries/clientSSR.js +0 -1
  74. package/dist/runtime/entries/no-react-server.d.ts +0 -0
  75. package/dist/runtime/entries/no-react-server.js +0 -2
  76. package/dist/runtime/entries/react-server-only.d.ts +0 -0
  77. package/dist/runtime/entries/react-server-only.js +0 -2
  78. package/dist/runtime/entries/router.d.ts +0 -2
  79. package/dist/runtime/entries/router.js +0 -2
  80. package/dist/runtime/entries/ssr.d.ts +0 -1
  81. package/dist/runtime/entries/ssr.js +0 -1
  82. package/dist/runtime/entries/worker.d.ts +0 -9
  83. package/dist/runtime/entries/worker.js +0 -9
  84. package/dist/runtime/error.d.ts +0 -6
  85. package/dist/runtime/error.js +0 -8
  86. package/dist/runtime/imports/ClientOnly.d.ts +0 -3
  87. package/dist/runtime/imports/ClientOnly.js +0 -8
  88. package/dist/runtime/imports/client.d.ts +0 -4
  89. package/dist/runtime/imports/client.js +0 -33
  90. package/dist/runtime/imports/ssr.d.ts +0 -5
  91. package/dist/runtime/imports/ssr.js +0 -20
  92. package/dist/runtime/imports/worker.d.ts +0 -5
  93. package/dist/runtime/imports/worker.js +0 -22
  94. package/dist/runtime/lib/auth/index.d.ts +0 -1
  95. package/dist/runtime/lib/auth/index.js +0 -1
  96. package/dist/runtime/lib/auth/session.d.ts +0 -50
  97. package/dist/runtime/lib/auth/session.js +0 -148
  98. package/dist/runtime/lib/db/DOWorkerDialect.d.ts +0 -29
  99. package/dist/runtime/lib/db/DOWorkerDialect.js +0 -66
  100. package/dist/runtime/lib/db/SqliteDurableObject.d.ts +0 -14
  101. package/dist/runtime/lib/db/SqliteDurableObject.js +0 -42
  102. package/dist/runtime/lib/db/createDb.d.ts +0 -2
  103. package/dist/runtime/lib/db/createDb.js +0 -33
  104. package/dist/runtime/lib/db/index.d.ts +0 -4
  105. package/dist/runtime/lib/db/index.js +0 -3
  106. package/dist/runtime/lib/db/migrations.d.ts +0 -23
  107. package/dist/runtime/lib/db/migrations.js +0 -34
  108. package/dist/runtime/lib/db/typeInference/assert.d.ts +0 -2
  109. package/dist/runtime/lib/db/typeInference/assert.js +0 -1
  110. package/dist/runtime/lib/db/typeInference/builders/alterColumn.d.ts +0 -27
  111. package/dist/runtime/lib/db/typeInference/builders/alterColumn.js +0 -1
  112. package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +0 -53
  113. package/dist/runtime/lib/db/typeInference/builders/alterTable.js +0 -1
  114. package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +0 -26
  115. package/dist/runtime/lib/db/typeInference/builders/columnDefinition.js +0 -1
  116. package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +0 -49
  117. package/dist/runtime/lib/db/typeInference/builders/createTable.js +0 -1
  118. package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +0 -17
  119. package/dist/runtime/lib/db/typeInference/builders/createView.js +0 -1
  120. package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +0 -11
  121. package/dist/runtime/lib/db/typeInference/builders/dropTable.js +0 -1
  122. package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +0 -12
  123. package/dist/runtime/lib/db/typeInference/builders/dropView.js +0 -1
  124. package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +0 -24
  125. package/dist/runtime/lib/db/typeInference/builders/schema.js +0 -1
  126. package/dist/runtime/lib/db/typeInference/database.d.ts +0 -27
  127. package/dist/runtime/lib/db/typeInference/database.js +0 -1
  128. package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.d.ts +0 -1
  129. package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +0 -360
  130. package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.d.ts +0 -1
  131. package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +0 -33
  132. package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.d.ts +0 -1
  133. package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.js +0 -143
  134. package/dist/runtime/lib/db/typeInference/typetests/print.d.ts +0 -3
  135. package/dist/runtime/lib/db/typeInference/typetests/print.js +0 -1
  136. package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +0 -2
  137. package/dist/runtime/lib/db/typeInference/typetests/testUtils.js +0 -1
  138. package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.d.ts +0 -1
  139. package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.js +0 -17
  140. package/dist/runtime/lib/db/typeInference/utils.d.ts +0 -82
  141. package/dist/runtime/lib/db/typeInference/utils.js +0 -2
  142. package/dist/runtime/lib/debug.d.ts +0 -2
  143. package/dist/runtime/lib/debug.js +0 -36
  144. package/dist/runtime/lib/links.d.ts +0 -14
  145. package/dist/runtime/lib/links.js +0 -38
  146. package/dist/runtime/lib/realtime/client.d.ts +0 -7
  147. package/dist/runtime/lib/realtime/client.js +0 -166
  148. package/dist/runtime/lib/realtime/constants.d.ts +0 -1
  149. package/dist/runtime/lib/realtime/constants.js +0 -1
  150. package/dist/runtime/lib/realtime/durableObject.d.ts +0 -29
  151. package/dist/runtime/lib/realtime/durableObject.js +0 -187
  152. package/dist/runtime/lib/realtime/renderRealtimeClients.d.ts +0 -7
  153. package/dist/runtime/lib/realtime/renderRealtimeClients.js +0 -6
  154. package/dist/runtime/lib/realtime/shared.d.ts +0 -10
  155. package/dist/runtime/lib/realtime/shared.js +0 -10
  156. package/dist/runtime/lib/realtime/validateUpgradeRequest.d.ts +0 -6
  157. package/dist/runtime/lib/realtime/validateUpgradeRequest.js +0 -29
  158. package/dist/runtime/lib/realtime/worker.d.ts +0 -3
  159. package/dist/runtime/lib/realtime/worker.js +0 -16
  160. package/dist/runtime/lib/router.d.ts +0 -56
  161. package/dist/runtime/lib/router.js +0 -210
  162. package/dist/runtime/lib/router.test.d.ts +0 -1
  163. package/dist/runtime/lib/router.test.js +0 -58
  164. package/dist/runtime/lib/streams/consumeEventStream.d.ts +0 -4
  165. package/dist/runtime/lib/streams/consumeEventStream.js +0 -13
  166. package/dist/runtime/lib/turnstile/TurnstileScript.d.ts +0 -1
  167. package/dist/runtime/lib/turnstile/TurnstileScript.js +0 -2
  168. package/dist/runtime/lib/turnstile/turnstile.d.ts +0 -3
  169. package/dist/runtime/lib/turnstile/turnstile.js +0 -3
  170. package/dist/runtime/lib/turnstile/useTurnstile.d.ts +0 -4
  171. package/dist/runtime/lib/turnstile/useTurnstile.js +0 -23
  172. package/dist/runtime/lib/turnstile/verifyTurnstileToken.d.ts +0 -4
  173. package/dist/runtime/lib/turnstile/verifyTurnstileToken.js +0 -15
  174. package/dist/runtime/lib/utils.d.ts +0 -1
  175. package/dist/runtime/lib/utils.js +0 -1
  176. package/dist/runtime/register/client.d.ts +0 -1
  177. package/dist/runtime/register/client.js +0 -5
  178. package/dist/runtime/register/ssr.d.ts +0 -3
  179. package/dist/runtime/register/ssr.js +0 -26
  180. package/dist/runtime/register/worker.d.ts +0 -4
  181. package/dist/runtime/register/worker.js +0 -42
  182. package/dist/runtime/render/createClientManifest.d.ts +0 -1
  183. package/dist/runtime/render/createClientManifest.js +0 -7
  184. package/dist/runtime/render/createModuleMap.d.ts +0 -1
  185. package/dist/runtime/render/createModuleMap.js +0 -13
  186. package/dist/runtime/render/renderRscThenableToHtmlStream.d.ts +0 -9
  187. package/dist/runtime/render/renderRscThenableToHtmlStream.js +0 -49
  188. package/dist/runtime/render/renderToRscStream.d.ts +0 -5
  189. package/dist/runtime/render/renderToRscStream.js +0 -46
  190. package/dist/runtime/render/renderToStream.d.ts +0 -9
  191. package/dist/runtime/render/renderToStream.js +0 -27
  192. package/dist/runtime/render/renderToString.d.ts +0 -7
  193. package/dist/runtime/render/renderToString.js +0 -26
  194. package/dist/runtime/render/transformRscToHtmlStream.d.ts +0 -8
  195. package/dist/runtime/render/transformRscToHtmlStream.js +0 -19
  196. package/dist/runtime/requestInfo/types.d.ts +0 -11
  197. package/dist/runtime/requestInfo/types.js +0 -1
  198. package/dist/runtime/requestInfo/worker.d.ts +0 -5
  199. package/dist/runtime/requestInfo/worker.js +0 -33
  200. package/dist/runtime/script.d.ts +0 -5
  201. package/dist/runtime/script.js +0 -8
  202. package/dist/runtime/ssrBridge.d.ts +0 -2
  203. package/dist/runtime/ssrBridge.js +0 -11
  204. package/dist/runtime/worker.d.ts +0 -18
  205. package/dist/runtime/worker.js +0 -173
  206. package/dist/scripts/__sdk.d.mts +0 -1
  207. package/dist/scripts/__sdk.mjs +0 -14
  208. package/dist/scripts/debug-sync.d.mts +0 -6
  209. package/dist/scripts/debug-sync.mjs +0 -224
  210. package/dist/scripts/dev-init.d.mts +0 -1
  211. package/dist/scripts/dev-init.mjs +0 -25
  212. package/dist/scripts/ensure-deploy-env.d.mts +0 -1
  213. package/dist/scripts/ensure-deploy-env.mjs +0 -271
  214. package/dist/scripts/ensure-env.d.mts +0 -1
  215. package/dist/scripts/ensure-env.mjs +0 -9
  216. package/dist/scripts/migrate-new.d.mts +0 -1
  217. package/dist/scripts/migrate-new.mjs +0 -51
  218. package/dist/scripts/smoke-test.d.mts +0 -1
  219. package/dist/scripts/smoke-test.mjs +0 -166
  220. package/dist/scripts/worker-run.d.mts +0 -1
  221. package/dist/scripts/worker-run.mjs +0 -82
  222. package/dist/vite/checkIsUsingPrisma.d.mts +0 -6
  223. package/dist/vite/checkIsUsingPrisma.mjs +0 -18
  224. package/dist/vite/configPlugin.d.mts +0 -9
  225. package/dist/vite/configPlugin.mjs +0 -169
  226. package/dist/vite/createDirectiveLookupPlugin.d.mts +0 -21
  227. package/dist/vite/createDirectiveLookupPlugin.mjs +0 -233
  228. package/dist/vite/devServerTimingPlugin.d.mts +0 -2
  229. package/dist/vite/devServerTimingPlugin.mjs +0 -24
  230. package/dist/vite/directivesPlugin.d.mts +0 -6
  231. package/dist/vite/directivesPlugin.mjs +0 -200
  232. package/dist/vite/ensureAliasArray.d.mts +0 -2
  233. package/dist/vite/ensureAliasArray.mjs +0 -17
  234. package/dist/vite/findSpecifiers.d.mts +0 -31
  235. package/dist/vite/findSpecifiers.mjs +0 -230
  236. package/dist/vite/findSsrSpecifiers.d.mts +0 -11
  237. package/dist/vite/findSsrSpecifiers.mjs +0 -51
  238. package/dist/vite/hasDirective.d.mts +0 -7
  239. package/dist/vite/hasDirective.mjs +0 -54
  240. package/dist/vite/hasOwnCloudflareVitePlugin.d.mts +0 -3
  241. package/dist/vite/hasOwnCloudflareVitePlugin.mjs +0 -14
  242. package/dist/vite/index.d.mts +0 -1
  243. package/dist/vite/index.mjs +0 -1
  244. package/dist/vite/injectVitePreamblePlugin.d.mts +0 -4
  245. package/dist/vite/injectVitePreamblePlugin.mjs +0 -23
  246. package/dist/vite/invalidateCacheIfPrismaClientChanged.d.mts +0 -3
  247. package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +0 -27
  248. package/dist/vite/invalidateModule.d.mts +0 -6
  249. package/dist/vite/invalidateModule.mjs +0 -30
  250. package/dist/vite/isJsFile.d.mts +0 -1
  251. package/dist/vite/isJsFile.mjs +0 -3
  252. package/dist/vite/miniflareHMRPlugin.d.mts +0 -10
  253. package/dist/vite/miniflareHMRPlugin.mjs +0 -171
  254. package/dist/vite/moveStaticAssetsPlugin.d.mts +0 -4
  255. package/dist/vite/moveStaticAssetsPlugin.mjs +0 -12
  256. package/dist/vite/normalizeModulePath.d.mts +0 -1
  257. package/dist/vite/normalizeModulePath.mjs +0 -13
  258. package/dist/vite/prismaPlugin.d.mts +0 -4
  259. package/dist/vite/prismaPlugin.mjs +0 -43
  260. package/dist/vite/reactConditionsResolverPlugin.d.mts +0 -16
  261. package/dist/vite/reactConditionsResolverPlugin.mjs +0 -179
  262. package/dist/vite/redwoodPlugin.d.mts +0 -12
  263. package/dist/vite/redwoodPlugin.mjs +0 -105
  264. package/dist/vite/ssrBridgePlugin.d.mts +0 -7
  265. package/dist/vite/ssrBridgePlugin.mjs +0 -124
  266. package/dist/vite/transformClientComponents.d.mts +0 -12
  267. package/dist/vite/transformClientComponents.mjs +0 -116
  268. package/dist/vite/transformClientComponents.test.d.mts +0 -1
  269. package/dist/vite/transformClientComponents.test.mjs +0 -264
  270. package/dist/vite/transformJsxScriptTagsPlugin.d.mts +0 -8
  271. package/dist/vite/transformJsxScriptTagsPlugin.mjs +0 -315
  272. package/dist/vite/transformJsxScriptTagsPlugin.test.d.mts +0 -1
  273. package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +0 -334
  274. package/dist/vite/transformServerFunctions.d.mts +0 -16
  275. package/dist/vite/transformServerFunctions.mjs +0 -296
  276. package/dist/vite/transformServerFunctions.test.d.mts +0 -1
  277. package/dist/vite/transformServerFunctions.test.mjs +0 -124
  278. package/dist/vite/useClientLookupPlugin.d.mts +0 -5
  279. package/dist/vite/useClientLookupPlugin.mjs +0 -15
  280. package/dist/vite/useServerLookupPlugin.d.mts +0 -5
  281. package/dist/vite/useServerLookupPlugin.mjs +0 -15
  282. package/dist/vite/useServerPlugin.d.mts +0 -1
  283. package/dist/vite/useServerPlugin.mjs +0 -1
  284. package/dist/vite/virtualPlugin.d.mts +0 -2
  285. package/dist/vite/virtualPlugin.mjs +0 -18
  286. package/dist/vite/vitePreamblePlugin.d.mts +0 -1
  287. package/dist/vite/vitePreamblePlugin.mjs +0 -11
@@ -1,17 +0,0 @@
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
- };
@@ -1,31 +0,0 @@
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[];
@@ -1,230 +0,0 @@
1
- import { parse as sgParse, Lang as SgLang, Lang } from "@ast-grep/napi";
2
- import path from "path";
3
- // These patterns are used to match import statements in code for SSR transformations.
4
- export const IMPORT_PATTERNS = [
5
- 'import { $$$ } from "$MODULE"',
6
- "import { $$$ } from '$MODULE'",
7
- 'import $DEFAULT from "$MODULE"',
8
- "import $DEFAULT from '$MODULE'",
9
- 'import * as $NS from "$MODULE"',
10
- "import * as $NS from '$MODULE'",
11
- 'import "$MODULE"',
12
- "import '$MODULE'",
13
- // Static Re-exports
14
- 'export { $$$ } from "$MODULE"',
15
- "export { $$$ } from '$MODULE'",
16
- 'export * from "$MODULE"',
17
- "export * from '$MODULE'",
18
- // Dynamic Imports
19
- 'import("$MODULE")',
20
- "import('$MODULE')",
21
- "import(`$MODULE`)",
22
- // CommonJS require
23
- 'require("$MODULE")',
24
- "require('$MODULE')",
25
- "require(`$MODULE`)",
26
- ];
27
- // These patterns are used to match export statements for client/server component transformations
28
- export const EXPORT_PATTERNS = [
29
- // Named exports
30
- "export const $NAME = $$$",
31
- "export let $NAME = $$$",
32
- "export var $NAME = $$$",
33
- "export function $NAME($$$) { $$$ }",
34
- "export async function $NAME($$$) { $$$ }",
35
- // Default exports
36
- "export default function $NAME($$$) { $$$ }",
37
- "export default function($$$) { $$$ }",
38
- "export default $$$",
39
- // Export declarations
40
- "export { $$$ }",
41
- 'export { $$$ } from "$MODULE"',
42
- "export { $$$ } from '$MODULE'",
43
- ];
44
- /**
45
- * Finds import specifiers and their positions in the code using the provided patterns.
46
- * @param code The code to search for import specifiers.
47
- * @param lang The language parser to use (TypeScript or Tsx).
48
- * @param ignoredImportPatterns Array of regex patterns to ignore.
49
- * @param log Optional logger function for debug output.
50
- * @returns Array of objects with start, end, and raw import string.
51
- */
52
- export function findImportSpecifiers(id, code, ignoredImportPatterns, log) {
53
- const ext = path.extname(id).toLowerCase();
54
- const lang = ext === ".tsx" || ext === ".jsx" ? Lang.Tsx : SgLang.TypeScript;
55
- const logger = process.env.VERBOSE ? (log ?? (() => { })) : () => { };
56
- const results = [];
57
- try {
58
- // sgParse and lang must be provided by the consumer
59
- const root = sgParse(lang, code);
60
- for (const pattern of IMPORT_PATTERNS) {
61
- try {
62
- const matches = root.root().findAll(pattern);
63
- for (const match of matches) {
64
- const moduleCapture = match.getMatch("MODULE");
65
- if (moduleCapture) {
66
- const importPath = moduleCapture.text();
67
- if (importPath.startsWith("virtual:")) {
68
- logger(":findImportSpecifiersWithPositions: Ignoring import because it starts with 'virtual:': importPath=%s", importPath);
69
- }
70
- else if (importPath.includes("__rwsdknossr")) {
71
- logger(":findImportSpecifiersWithPositions: Ignoring import because it includes '__rwsdknossr': importPath=%s", importPath);
72
- }
73
- else if (ignoredImportPatterns.some((pattern) => pattern.test(importPath))) {
74
- logger(":findImportSpecifiersWithPositions: Ignoring import because it matches IGNORED_IMPORT_PATTERNS: importPath=%s", importPath);
75
- }
76
- else {
77
- const { start, end } = moduleCapture.range();
78
- results.push({ s: start.index, e: end.index, raw: importPath });
79
- logger(":findImportSpecifiersWithPositions: Including import specifier: importPath=%s, range=[%d, %d]", importPath, start.index, end.index);
80
- }
81
- }
82
- }
83
- }
84
- catch (err) {
85
- logger(":findImportSpecifiersWithPositions: Error processing pattern: %O", err);
86
- }
87
- }
88
- }
89
- catch (err) {
90
- logger(":findImportSpecifiersWithPositions: Error parsing content: %O", err);
91
- }
92
- return results;
93
- }
94
- /**
95
- * Finds export information in the code using ast-grep patterns.
96
- * @param id The file identifier for language detection.
97
- * @param code The code to search for exports.
98
- * @param log Optional logger function for debug output.
99
- * @returns Array of export information objects.
100
- */
101
- export function findExports(id, code, log) {
102
- const ext = path.extname(id).toLowerCase();
103
- const lang = ext === ".tsx" || ext === ".jsx" ? Lang.Tsx : SgLang.TypeScript;
104
- const logger = process.env.VERBOSE ? (log ?? (() => { })) : () => { };
105
- const results = [];
106
- const seen = new Set(); // Track seen exports to avoid duplicates
107
- try {
108
- const root = sgParse(lang, code);
109
- // Use the existing EXPORT_PATTERNS in a specific order to avoid duplicates
110
- const orderedPatterns = [
111
- // Handle re-exports first (most specific)
112
- ...EXPORT_PATTERNS.filter((p) => p.includes('from "$MODULE"') || p.includes("from '$MODULE'")),
113
- // Then named exports
114
- ...EXPORT_PATTERNS.filter((p) => p.startsWith("export const") ||
115
- p.startsWith("export let") ||
116
- p.startsWith("export var") ||
117
- p.startsWith("export function") ||
118
- p.startsWith("export async function")),
119
- // Then default exports
120
- ...EXPORT_PATTERNS.filter((p) => p.startsWith("export default")),
121
- // Finally export declarations
122
- ...EXPORT_PATTERNS.filter((p) => p === "export { $$$ }"),
123
- ];
124
- for (const pattern of orderedPatterns) {
125
- try {
126
- const matches = root.root().findAll(pattern);
127
- for (const match of matches) {
128
- const nameCapture = match.getMatch("NAME");
129
- const moduleCapture = match.getMatch("MODULE");
130
- const matchText = match.text();
131
- if (pattern.includes('from "$MODULE"') ||
132
- pattern.includes("from '$MODULE'")) {
133
- // Re-export from module
134
- const moduleSpecifier = moduleCapture?.text();
135
- if (!moduleSpecifier)
136
- continue;
137
- if (pattern.includes("export *")) {
138
- // Skip export * for now - too complex
139
- logger("Skipping export * from %s", moduleSpecifier);
140
- continue;
141
- }
142
- // Parse the export list
143
- const exportListMatch = matchText.match(/export\s*\{\s*([^}]+)\s*\}/);
144
- if (exportListMatch) {
145
- const exportList = exportListMatch[1];
146
- const exports = exportList.split(",").map((e) => e.trim());
147
- for (const exp of exports) {
148
- const [originalName, alias] = exp.includes(" as ")
149
- ? exp.split(" as ").map((s) => s.trim())
150
- : [exp.trim(), undefined];
151
- const exportName = alias || originalName;
152
- const key = `${exportName}:${originalName === "default"}:reexport:${moduleSpecifier}`;
153
- if (seen.has(key))
154
- continue;
155
- seen.add(key);
156
- results.push({
157
- name: exportName,
158
- isDefault: originalName === "default",
159
- alias: alias !== originalName ? alias : undefined,
160
- originalName: originalName,
161
- isReExport: true,
162
- moduleSpecifier,
163
- });
164
- logger("Found re-export: %s from %s", exportName, moduleSpecifier);
165
- }
166
- }
167
- }
168
- else if (matchText.startsWith("export default")) {
169
- // Default export
170
- const name = nameCapture?.text() || "default";
171
- const key = `${name}:true:default`;
172
- if (seen.has(key))
173
- continue;
174
- seen.add(key);
175
- results.push({
176
- name,
177
- isDefault: true,
178
- });
179
- logger("Found default export: %s", name);
180
- }
181
- else if (matchText.includes("export {")) {
182
- // Local export declaration
183
- const exportListMatch = matchText.match(/export\s*\{\s*([^}]+)\s*\}/);
184
- if (exportListMatch) {
185
- const exportList = exportListMatch[1];
186
- const exports = exportList.split(",").map((e) => e.trim());
187
- for (const exp of exports) {
188
- const [originalName, alias] = exp.includes(" as ")
189
- ? exp.split(" as ").map((s) => s.trim())
190
- : [exp.trim(), undefined];
191
- const exportName = alias || originalName;
192
- const key = `${exportName}:${originalName === "default"}:local`;
193
- if (seen.has(key))
194
- continue;
195
- seen.add(key);
196
- results.push({
197
- name: exportName,
198
- isDefault: originalName === "default",
199
- alias: alias !== originalName ? alias : undefined,
200
- originalName: originalName,
201
- });
202
- logger("Found local export: %s", exportName);
203
- }
204
- }
205
- }
206
- else if (nameCapture) {
207
- // Named export (function, const, etc.)
208
- const name = nameCapture.text();
209
- const key = `${name}:false:named`;
210
- if (seen.has(key))
211
- continue;
212
- seen.add(key);
213
- results.push({
214
- name,
215
- isDefault: false,
216
- });
217
- logger("Found named export: %s", name);
218
- }
219
- }
220
- }
221
- catch (err) {
222
- logger("Error processing export pattern %s: %O", pattern, err);
223
- }
224
- }
225
- }
226
- catch (err) {
227
- logger("Error parsing code for exports: %O", err);
228
- }
229
- return results;
230
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Finds __vite_ssr_import__ and __vite_ssr_dynamic_import__ specifiers in the code.
3
- * @param id The file identifier for language detection.
4
- * @param code The code to search for SSR imports.
5
- * @param log Optional logger function for debug output.
6
- * @returns Object with arrays of static and dynamic import specifiers.
7
- */
8
- export declare function findSsrImportSpecifiers(id: string, code: string, log?: (...args: any[]) => void): {
9
- imports: string[];
10
- dynamicImports: string[];
11
- };
@@ -1,51 +0,0 @@
1
- import { parse as sgParse, Lang as SgLang, Lang } from "@ast-grep/napi";
2
- import path from "path";
3
- /**
4
- * Finds __vite_ssr_import__ and __vite_ssr_dynamic_import__ specifiers in the code.
5
- * @param id The file identifier for language detection.
6
- * @param code The code to search for SSR imports.
7
- * @param log Optional logger function for debug output.
8
- * @returns Object with arrays of static and dynamic import specifiers.
9
- */
10
- export function findSsrImportSpecifiers(id, code, log) {
11
- const ext = path.extname(id).toLowerCase();
12
- const lang = ext === ".tsx" || ext === ".jsx" ? Lang.Tsx : SgLang.TypeScript;
13
- const logger = process.env.VERBOSE ? (log ?? (() => { })) : () => { };
14
- const imports = [];
15
- const dynamicImports = [];
16
- try {
17
- const root = sgParse(lang, code);
18
- const patterns = [
19
- {
20
- pattern: `__vite_ssr_import__("$SPECIFIER")`,
21
- list: imports,
22
- },
23
- {
24
- pattern: `__vite_ssr_import__('$SPECIFIER')`,
25
- list: imports,
26
- },
27
- {
28
- pattern: `__vite_ssr_dynamic_import__("$SPECIFIER")`,
29
- list: dynamicImports,
30
- },
31
- {
32
- pattern: `__vite_ssr_dynamic_import__('$SPECIFIER')`,
33
- list: dynamicImports,
34
- },
35
- ];
36
- for (const { pattern, list } of patterns) {
37
- const matches = root.root().findAll(pattern);
38
- for (const match of matches) {
39
- const specifier = match.getMatch("SPECIFIER")?.text();
40
- if (specifier) {
41
- list.push(specifier);
42
- logger(`Found SSR import specifier: %s in pattern: %s`, specifier, pattern);
43
- }
44
- }
45
- }
46
- }
47
- catch (err) {
48
- logger("Error parsing code for SSR imports: %O", err);
49
- }
50
- return { imports, dynamicImports };
51
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Efficiently checks if a React directive (e.g., "use server", "use client")
3
- * is present in the code. Optimized for performance with a two-step approach:
4
- * 1. Quick string search to see if directive exists anywhere
5
- * 2. Line-by-line check only if the directive might be present
6
- */
7
- export declare function hasDirective(code: string, directive: string): boolean;
@@ -1,54 +0,0 @@
1
- /**
2
- * Efficiently checks if a React directive (e.g., "use server", "use client")
3
- * is present in the code. Optimized for performance with a two-step approach:
4
- * 1. Quick string search to see if directive exists anywhere
5
- * 2. Line-by-line check only if the directive might be present
6
- */
7
- export function hasDirective(code, directive) {
8
- // Quick performance check: if directive doesn't exist anywhere, skip line checking
9
- const singleQuoteDirective = `'${directive}'`;
10
- const doubleQuoteDirective = `"${directive}"`;
11
- if (!code.includes(singleQuoteDirective) &&
12
- !code.includes(doubleQuoteDirective)) {
13
- return false;
14
- }
15
- // Split into lines and check each one
16
- const lines = code.split("\n");
17
- let inMultiLineComment = false;
18
- for (const line of lines) {
19
- const trimmedLine = line.trim();
20
- // Skip empty lines
21
- if (trimmedLine.length === 0) {
22
- continue;
23
- }
24
- // Handle multi-line comments
25
- if (trimmedLine.startsWith("/*")) {
26
- inMultiLineComment = true;
27
- // Check if the comment ends on the same line
28
- if (trimmedLine.includes("*/")) {
29
- inMultiLineComment = false;
30
- }
31
- continue;
32
- }
33
- if (inMultiLineComment) {
34
- // Check if this line ends the multi-line comment
35
- if (trimmedLine.includes("*/")) {
36
- inMultiLineComment = false;
37
- }
38
- continue;
39
- }
40
- // Skip single-line comments
41
- if (trimmedLine.startsWith("//")) {
42
- continue;
43
- }
44
- // Check if this line starts with the directive
45
- if (trimmedLine.startsWith(doubleQuoteDirective) ||
46
- trimmedLine.startsWith(singleQuoteDirective)) {
47
- return true;
48
- }
49
- // If we hit a non-empty, non-comment line that's not a directive, we can stop
50
- // (directives must be at the top of the file/scope, after comments)
51
- break;
52
- }
53
- return false;
54
- }
@@ -1,3 +0,0 @@
1
- export declare function hasOwnCloudflareVitePlugin({ rootProjectDir, }: {
2
- rootProjectDir: string;
3
- }): Promise<boolean>;
@@ -1,14 +0,0 @@
1
- import { readFile } from "fs/promises";
2
- import path from "path";
3
- export async function hasOwnCloudflareVitePlugin({ rootProjectDir, }) {
4
- const packageJsonPath = path.join(rootProjectDir, "package.json");
5
- try {
6
- const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
7
- return !!(packageJson.dependencies?.["@cloudflare/vite-plugin"] ||
8
- packageJson.devDependencies?.["@cloudflare/vite-plugin"]);
9
- }
10
- catch (error) {
11
- console.error("Error reading package.json:", error);
12
- return false;
13
- }
14
- }
@@ -1 +0,0 @@
1
- export { type RedwoodPluginOptions, redwoodPlugin as redwood, } from "./redwoodPlugin.mjs";
@@ -1 +0,0 @@
1
- export { redwoodPlugin as redwood, } from "./redwoodPlugin.mjs";
@@ -1,4 +0,0 @@
1
- import { type Plugin } from "vite";
2
- export declare const injectVitePreamble: ({ clientEntryPathnames, }: {
3
- clientEntryPathnames: string[];
4
- }) => Plugin;
@@ -1,23 +0,0 @@
1
- import MagicString from "magic-string";
2
- export const injectVitePreamble = ({ clientEntryPathnames, }) => ({
3
- name: "rwsdk:inject-vite-preamble",
4
- apply: "serve",
5
- transform(code, id) {
6
- if (this.environment.name !== "client") {
7
- return;
8
- }
9
- if (!clientEntryPathnames.includes(id)) {
10
- return;
11
- }
12
- // Only inject preamble in development mode
13
- if (process.env.NODE_ENV !== "development") {
14
- return;
15
- }
16
- const s = new MagicString(code);
17
- s.prepend(`import 'virtual:vite-preamble';\n`);
18
- return {
19
- code: s.toString(),
20
- map: s.generateMap({ hires: true }),
21
- };
22
- },
23
- });
@@ -1,3 +0,0 @@
1
- export declare const invalidateCacheIfPrismaClientChanged: ({ projectRootDir, }: {
2
- projectRootDir: string;
3
- }) => Promise<void>;
@@ -1,27 +0,0 @@
1
- import { resolve } from "node:path";
2
- import { remove, pathExists } from "fs-extra";
3
- import { stat } from "node:fs/promises";
4
- export const invalidateCacheIfPrismaClientChanged = async ({ projectRootDir, }) => {
5
- const viteDepsCachePath = resolve(projectRootDir, "node_modules", ".vite", `deps_worker`, `@prisma_client.js`);
6
- // Get mtimes for comparison
7
- try {
8
- const schemaPath = resolve(projectRootDir, "prisma", "schema.prisma");
9
- if (!(await pathExists(schemaPath))) {
10
- return;
11
- }
12
- const [schemaStat, cacheStat] = await Promise.all([
13
- stat(schemaPath).catch(() => null),
14
- stat(viteDepsCachePath).catch(() => null),
15
- ]);
16
- // If schema exists and either cache doesn't exist or schema is newer
17
- if (schemaStat && (!cacheStat || schemaStat.mtime > cacheStat.mtime)) {
18
- // Clear the entire .vite cache directory
19
- await remove(resolve(projectRootDir, "node_modules", ".vite"));
20
- return;
21
- }
22
- }
23
- catch (error) {
24
- // If there's any error reading files, fall back to removing the entire .vite cache dir regardless
25
- await remove(resolve(projectRootDir, "node_modules", ".vite"));
26
- }
27
- };
@@ -1,6 +0,0 @@
1
- import type { EnvironmentModuleNode, ViteDevServer } from "vite";
2
- interface InvalidatableModuleOptions {
3
- invalidateImportersRecursively?: boolean;
4
- }
5
- export declare const invalidateModule: (devServer: ViteDevServer, environment: string, target: string | EnvironmentModuleNode, options?: InvalidatableModuleOptions, seen?: Set<EnvironmentModuleNode>) => void;
6
- export {};
@@ -1,30 +0,0 @@
1
- import debug from "debug";
2
- const log = debug("rwsdk:vite:invalidate-module");
3
- export const invalidateModule = (devServer, environment, target, options = {}, seen = new Set()) => {
4
- let moduleNode;
5
- if (typeof target === "string") {
6
- const id = target;
7
- const [rawId, _query] = id.split("?");
8
- moduleNode =
9
- devServer?.environments[environment]?.moduleGraph.idToModuleMap.get(rawId);
10
- }
11
- else {
12
- moduleNode = target;
13
- }
14
- if (moduleNode) {
15
- if (seen.has(moduleNode)) {
16
- return;
17
- }
18
- seen.add(moduleNode);
19
- devServer.environments[environment]?.moduleGraph.invalidateModule(moduleNode, seen);
20
- log("Invalidating module: id=%s, environment=%s", moduleNode.id, environment);
21
- if (options.invalidateImportersRecursively) {
22
- for (const importer of moduleNode.importers) {
23
- invalidateModule(devServer, environment, importer, options, seen);
24
- }
25
- }
26
- }
27
- else {
28
- log("Module not found: id=%s, environment=%s", typeof target === "string" ? target : target.id, environment);
29
- }
30
- };
@@ -1 +0,0 @@
1
- export declare function isJsFile(filepath: string): boolean;
@@ -1,3 +0,0 @@
1
- export function isJsFile(filepath) {
2
- return /\.(m|c)?(j|t)s(x)?$/.test(filepath);
3
- }
@@ -1,10 +0,0 @@
1
- import { Plugin } from "vite";
2
- export declare const miniflareHMRPlugin: (givenOptions: {
3
- clientFiles: Set<string>;
4
- serverFiles: Set<string>;
5
- rootDir: string;
6
- viteEnvironment: {
7
- name: string;
8
- };
9
- workerEntryPathname: string;
10
- }) => (Plugin | Plugin[])[];