@webflow/cloud-app 0.1.0-beta.10

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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/dist/bindings.d.ts +190 -0
  4. package/dist/bindings.d.ts.map +1 -0
  5. package/dist/bindings.js +126 -0
  6. package/dist/bindings.js.map +1 -0
  7. package/dist/compat-date.d.ts +68 -0
  8. package/dist/compat-date.d.ts.map +1 -0
  9. package/dist/compat-date.js +169 -0
  10. package/dist/compat-date.js.map +1 -0
  11. package/dist/config/package-json.d.ts +57 -0
  12. package/dist/config/package-json.d.ts.map +1 -0
  13. package/dist/config/package-json.js +94 -0
  14. package/dist/config/package-json.js.map +1 -0
  15. package/dist/config/webflow-json.d.ts +47 -0
  16. package/dist/config/webflow-json.d.ts.map +1 -0
  17. package/dist/config/webflow-json.js +72 -0
  18. package/dist/config/webflow-json.js.map +1 -0
  19. package/dist/create-webflow-json.d.ts +21 -0
  20. package/dist/create-webflow-json.d.ts.map +1 -0
  21. package/dist/create-webflow-json.js +168 -0
  22. package/dist/create-webflow-json.js.map +1 -0
  23. package/dist/diagnostics.d.ts +23 -0
  24. package/dist/diagnostics.d.ts.map +1 -0
  25. package/dist/diagnostics.js +31 -0
  26. package/dist/diagnostics.js.map +1 -0
  27. package/dist/errors.d.ts +13 -0
  28. package/dist/errors.d.ts.map +1 -0
  29. package/dist/errors.js +23 -0
  30. package/dist/errors.js.map +1 -0
  31. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +28 -0
  32. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts.map +1 -0
  33. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +148 -0
  34. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js.map +1 -0
  35. package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts +34 -0
  36. package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts.map +1 -0
  37. package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js +89 -0
  38. package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js.map +1 -0
  39. package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts +39 -0
  40. package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts.map +1 -0
  41. package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js +93 -0
  42. package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js.map +1 -0
  43. package/dist/frameworks/astro/astro5.d.ts +28 -0
  44. package/dist/frameworks/astro/astro5.d.ts.map +1 -0
  45. package/dist/frameworks/astro/astro5.js +276 -0
  46. package/dist/frameworks/astro/astro5.js.map +1 -0
  47. package/dist/frameworks/astro/astro6.d.ts +28 -0
  48. package/dist/frameworks/astro/astro6.d.ts.map +1 -0
  49. package/dist/frameworks/astro/astro6.js +305 -0
  50. package/dist/frameworks/astro/astro6.js.map +1 -0
  51. package/dist/frameworks/astro/astro7.d.ts +28 -0
  52. package/dist/frameworks/astro/astro7.d.ts.map +1 -0
  53. package/dist/frameworks/astro/astro7.js +303 -0
  54. package/dist/frameworks/astro/astro7.js.map +1 -0
  55. package/dist/frameworks/astro/index.d.ts +10 -0
  56. package/dist/frameworks/astro/index.d.ts.map +1 -0
  57. package/dist/frameworks/astro/index.js +16 -0
  58. package/dist/frameworks/astro/index.js.map +1 -0
  59. package/dist/frameworks/astro/session-check.d.ts +24 -0
  60. package/dist/frameworks/astro/session-check.d.ts.map +1 -0
  61. package/dist/frameworks/astro/session-check.js +166 -0
  62. package/dist/frameworks/astro/session-check.js.map +1 -0
  63. package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
  64. package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
  65. package/dist/frameworks/astro/templates/v5/webflow-loader.ts +126 -0
  66. package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
  67. package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
  68. package/dist/frameworks/astro/templates/v6/webflow-loader.ts +126 -0
  69. package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
  70. package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
  71. package/dist/frameworks/astro/templates/v7/webflow-loader.ts +125 -0
  72. package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
  73. package/dist/frameworks/astro/templates/webflow-image-url.ts +140 -0
  74. package/dist/frameworks/base.d.ts +134 -0
  75. package/dist/frameworks/base.d.ts.map +1 -0
  76. package/dist/frameworks/base.js +175 -0
  77. package/dist/frameworks/base.js.map +1 -0
  78. package/dist/frameworks/errors.d.ts +72 -0
  79. package/dist/frameworks/errors.d.ts.map +1 -0
  80. package/dist/frameworks/errors.js +120 -0
  81. package/dist/frameworks/errors.js.map +1 -0
  82. package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
  83. package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
  84. package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
  85. package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
  86. package/dist/frameworks/nextjs/index.d.ts +38 -0
  87. package/dist/frameworks/nextjs/index.d.ts.map +1 -0
  88. package/dist/frameworks/nextjs/index.js +268 -0
  89. package/dist/frameworks/nextjs/index.js.map +1 -0
  90. package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
  91. package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
  92. package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
  93. package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
  94. package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
  95. package/dist/frameworks/registry.d.ts +127 -0
  96. package/dist/frameworks/registry.d.ts.map +1 -0
  97. package/dist/frameworks/registry.js +257 -0
  98. package/dist/frameworks/registry.js.map +1 -0
  99. package/dist/frameworks/static/index.d.ts +116 -0
  100. package/dist/frameworks/static/index.d.ts.map +1 -0
  101. package/dist/frameworks/static/index.js +394 -0
  102. package/dist/frameworks/static/index.js.map +1 -0
  103. package/dist/frameworks/static/templates/wrangler.json +8 -0
  104. package/dist/frameworks/types.d.ts +138 -0
  105. package/dist/frameworks/types.d.ts.map +1 -0
  106. package/dist/frameworks/types.js +3 -0
  107. package/dist/frameworks/types.js.map +1 -0
  108. package/dist/frameworks/vite/index.d.ts +46 -0
  109. package/dist/frameworks/vite/index.d.ts.map +1 -0
  110. package/dist/frameworks/vite/index.js +303 -0
  111. package/dist/frameworks/vite/index.js.map +1 -0
  112. package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
  113. package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
  114. package/dist/frameworks/vite/templates/wrangler.json +10 -0
  115. package/dist/index.d.ts +49 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +136 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/pipeline.d.ts +12 -0
  120. package/dist/pipeline.d.ts.map +1 -0
  121. package/dist/pipeline.js +293 -0
  122. package/dist/pipeline.js.map +1 -0
  123. package/dist/ports/command-runner.d.ts +59 -0
  124. package/dist/ports/command-runner.d.ts.map +1 -0
  125. package/dist/ports/command-runner.js +126 -0
  126. package/dist/ports/command-runner.js.map +1 -0
  127. package/dist/ports/filesystem.d.ts +19 -0
  128. package/dist/ports/filesystem.d.ts.map +1 -0
  129. package/dist/ports/filesystem.js +68 -0
  130. package/dist/ports/filesystem.js.map +1 -0
  131. package/dist/ports/index.d.ts +17 -0
  132. package/dist/ports/index.d.ts.map +1 -0
  133. package/dist/ports/index.js +14 -0
  134. package/dist/ports/index.js.map +1 -0
  135. package/dist/ports/logger.d.ts +22 -0
  136. package/dist/ports/logger.d.ts.map +1 -0
  137. package/dist/ports/logger.js +18 -0
  138. package/dist/ports/logger.js.map +1 -0
  139. package/dist/ports/telemetry.d.ts +23 -0
  140. package/dist/ports/telemetry.d.ts.map +1 -0
  141. package/dist/ports/telemetry.js +12 -0
  142. package/dist/ports/telemetry.js.map +1 -0
  143. package/dist/static-base-href.d.ts +31 -0
  144. package/dist/static-base-href.d.ts.map +1 -0
  145. package/dist/static-base-href.js +183 -0
  146. package/dist/static-base-href.js.map +1 -0
  147. package/dist/toolchain/errors.d.ts +32 -0
  148. package/dist/toolchain/errors.d.ts.map +1 -0
  149. package/dist/toolchain/errors.js +31 -0
  150. package/dist/toolchain/errors.js.map +1 -0
  151. package/dist/toolchain/resolver.d.ts +25 -0
  152. package/dist/toolchain/resolver.d.ts.map +1 -0
  153. package/dist/toolchain/resolver.js +200 -0
  154. package/dist/toolchain/resolver.js.map +1 -0
  155. package/dist/toolchain/types.d.ts +52 -0
  156. package/dist/toolchain/types.d.ts.map +1 -0
  157. package/dist/toolchain/types.js +10 -0
  158. package/dist/toolchain/types.js.map +1 -0
  159. package/dist/types.d.ts +71 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/dist/types.js +3 -0
  162. package/dist/types.js.map +1 -0
  163. package/dist/utils/fs.d.ts +29 -0
  164. package/dist/utils/fs.d.ts.map +1 -0
  165. package/dist/utils/fs.js +126 -0
  166. package/dist/utils/fs.js.map +1 -0
  167. package/dist/utils/index.d.ts +11 -0
  168. package/dist/utils/index.d.ts.map +1 -0
  169. package/dist/utils/index.js +27 -0
  170. package/dist/utils/index.js.map +1 -0
  171. package/dist/utils/node-version.d.ts +20 -0
  172. package/dist/utils/node-version.d.ts.map +1 -0
  173. package/dist/utils/node-version.js +113 -0
  174. package/dist/utils/node-version.js.map +1 -0
  175. package/dist/utils/process.d.ts +25 -0
  176. package/dist/utils/process.d.ts.map +1 -0
  177. package/dist/utils/process.js +40 -0
  178. package/dist/utils/process.js.map +1 -0
  179. package/dist/utils/reserved-env.d.ts +26 -0
  180. package/dist/utils/reserved-env.d.ts.map +1 -0
  181. package/dist/utils/reserved-env.js +51 -0
  182. package/dist/utils/reserved-env.js.map +1 -0
  183. package/dist/utils/template.d.ts +15 -0
  184. package/dist/utils/template.d.ts.map +1 -0
  185. package/dist/utils/template.js +75 -0
  186. package/dist/utils/template.js.map +1 -0
  187. package/dist/utils/version.d.ts +9 -0
  188. package/dist/utils/version.d.ts.map +1 -0
  189. package/dist/utils/version.js +52 -0
  190. package/dist/utils/version.js.map +1 -0
  191. package/dist/wrangler.d.ts +195 -0
  192. package/dist/wrangler.d.ts.map +1 -0
  193. package/dist/wrangler.js +372 -0
  194. package/dist/wrangler.js.map +1 -0
  195. package/package.json +48 -0
@@ -0,0 +1,28 @@
1
+ import { FrameworkBuilder } from '../base';
2
+ import type { BuildOutput, FrameworkInfo, PackageJson, WebflowJson, DetectionResult, AdapterPackage, IntegrationPackage, WebflowLoaderConfig, NodeVersionRequirement } from '../types';
3
+ export declare class Astro7Builder extends FrameworkBuilder {
4
+ static frameworkName: string;
5
+ get info(): FrameworkInfo;
6
+ getFrameworkVersion(): string | undefined;
7
+ /**
8
+ * Detect if this is an Astro 7 project.
9
+ *
10
+ * Version is always determined from package.json, not webflow.json. The
11
+ * registry checks Astro7Builder before Astro6Builder, so Astro 7+ projects
12
+ * are detected here first.
13
+ */
14
+ static detect(packageJson: PackageJson, webflowJson?: WebflowJson): DetectionResult;
15
+ validate(): Promise<void>;
16
+ getCloudflareAdapter(): AdapterPackage;
17
+ getRequiredIntegrations(): IntegrationPackage[];
18
+ installDependencies(): Promise<void>;
19
+ getWebflowLoader(): WebflowLoaderConfig;
20
+ getUserConfigPatterns(): string[];
21
+ getWranglerTemplatePath(): string;
22
+ getAdditionalConfigFiles(): string[];
23
+ prepareConfig(): Promise<void>;
24
+ getBuildCommand(): string;
25
+ getNodeVersionRequirement(): NodeVersionRequirement;
26
+ static getOutputDeployMetadata(): BuildOutput;
27
+ }
28
+ //# sourceMappingURL=astro7.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro7.d.ts","sourceRoot":"","sources":["../../../src/frameworks/astro/astro7.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAiBlB,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAgB,aAAa,SAAW;IAMxC,IAAI,IAAI,IAAI,aAAa,CAOxB;IAEQ,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAQlD;;;;;;OAMG;WACa,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,eAAe;IA2BtF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA6C/B,oBAAoB,IAAI,cAAc;IAWtC,uBAAuB,IAAI,kBAAkB,EAAE;IAUzC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8C1C,gBAAgB,IAAI,mBAAmB;IAQvC,qBAAqB,IAAI,MAAM,EAAE;IAIjC,uBAAuB,IAAI,MAAM;IAIjC,wBAAwB,IAAI,MAAM,EAAE;IAS9B,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAkEpC,eAAe,IAAI,MAAM;IAIzB,yBAAyB,IAAI,sBAAsB;WAWnC,uBAAuB,IAAI,WAAW;CAkBvD"}
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Astro7Builder = void 0;
37
+ /**
38
+ * Astro 7 Framework Builder
39
+ *
40
+ * Builds Astro 7.x projects for Cloudflare Workers deployment.
41
+ *
42
+ * - Node.js 22.12.0+ required
43
+ * - @astrojs/cloudflare@^14.0.0 (uses @cloudflare/vite-plugin)
44
+ * - Vite 8 required
45
+ * - Build output: dist/server/entry.mjs (worker) + dist/client/ (static assets)
46
+ * - Uses workerd natively for dev (no platformProxy)
47
+ * - wrangler.json main: "@astrojs/cloudflare/entrypoints/server"
48
+ *
49
+ * The Cloudflare output shape is unchanged from Astro 6, so the deploy metadata
50
+ * matches astro6.ts. The differences are dependency majors (adapter, React
51
+ * integration) and the underlying Vite 8 / Astro 7 toolchain.
52
+ */
53
+ const path = __importStar(require("node:path"));
54
+ const fs = __importStar(require("node:fs"));
55
+ const base_1 = require("../base");
56
+ const errors_1 = require("../errors");
57
+ const ensure_compatible_cloudflare_adapter_1 = require("./adapter-patches/ensure-compatible-cloudflare-adapter");
58
+ const resolve_cloudflare_adapter_1 = require("./adapter-patches/resolve-cloudflare-adapter");
59
+ const utils_1 = require("../../utils");
60
+ /** Base path for Astro 7 templates. */
61
+ const TEMPLATE_BASE = path.join(__dirname, 'templates', 'v7');
62
+ const SHARED_TEMPLATE_BASE = path.join(__dirname, 'templates');
63
+ class Astro7Builder extends base_1.FrameworkBuilder {
64
+ static frameworkName = 'astro';
65
+ // ───────────────────────────────────────────────────────────────────────────
66
+ // FRAMEWORK INFO
67
+ // ───────────────────────────────────────────────────────────────────────────
68
+ get info() {
69
+ return {
70
+ name: 'astro',
71
+ version: '7.x',
72
+ displayName: 'Astro 7',
73
+ packageName: 'astro',
74
+ };
75
+ }
76
+ getFrameworkVersion() {
77
+ return this.resolveFrameworkVersion('astro');
78
+ }
79
+ // ───────────────────────────────────────────────────────────────────────────
80
+ // DETECTION
81
+ // ───────────────────────────────────────────────────────────────────────────
82
+ /**
83
+ * Detect if this is an Astro 7 project.
84
+ *
85
+ * Version is always determined from package.json, not webflow.json. The
86
+ * registry checks Astro7Builder before Astro6Builder, so Astro 7+ projects
87
+ * are detected here first.
88
+ */
89
+ static detect(packageJson, webflowJson) {
90
+ const specifiedFramework = webflowJson?.cloud?.framework;
91
+ // If webflow.json specifies a DIFFERENT framework, don't match.
92
+ if (specifiedFramework && specifiedFramework !== 'astro') {
93
+ return { detected: false };
94
+ }
95
+ const astroVersion = packageJson.dependencies?.astro || packageJson.devDependencies?.astro;
96
+ if (!astroVersion) {
97
+ return { detected: false };
98
+ }
99
+ const majorVersion = (0, utils_1.getMajorVersion)(astroVersion);
100
+ if (majorVersion !== null && majorVersion >= 7) {
101
+ return { detected: true, reason: `Found astro@${astroVersion} (Astro ${majorVersion}.x)` };
102
+ }
103
+ return { detected: false };
104
+ }
105
+ // ───────────────────────────────────────────────────────────────────────────
106
+ // VALIDATION
107
+ // ───────────────────────────────────────────────────────────────────────────
108
+ async validate() {
109
+ const { log, packageJson } = this.ctx;
110
+ // Astro 7 requires Node 22+.
111
+ const nodeReq = this.getNodeVersionRequirement();
112
+ if (nodeReq) {
113
+ (0, utils_1.validateNodeVersion)(log, nodeReq, this.info.displayName);
114
+ }
115
+ const astroVersion = packageJson.dependencies?.astro || packageJson.devDependencies?.astro;
116
+ if (!astroVersion) {
117
+ throw new errors_1.FrameworkValidationError('Astro is not installed in this project.', {
118
+ remediation: 'Install Astro by running: npm install astro@^7.0.0',
119
+ documentationUrl: 'https://docs.astro.build/en/install/',
120
+ });
121
+ }
122
+ // Reject "latest" explicitly.
123
+ if (astroVersion === 'latest') {
124
+ throw new errors_1.FrameworkValidationError('Astro version "latest" is not supported by Webflow Cloud.', { remediation: 'Please specify a version, e.g.: npm install astro@^7.0.0' });
125
+ }
126
+ const majorVersion = (0, utils_1.getMajorVersion)(astroVersion);
127
+ if (majorVersion !== null && majorVersion < 7) {
128
+ throw new errors_1.FrameworkValidationError(`Astro ${majorVersion}.x detected but Astro7Builder was selected. This is likely a configuration error.`, {
129
+ remediation: 'Use Astro6Builder for Astro 6.x projects, or upgrade: npm install astro@^7.0.0',
130
+ });
131
+ }
132
+ log.info(`Validated Astro 7 project: astro@${astroVersion}`);
133
+ }
134
+ // ───────────────────────────────────────────────────────────────────────────
135
+ // DEPENDENCIES
136
+ // ───────────────────────────────────────────────────────────────────────────
137
+ getCloudflareAdapter() {
138
+ // Range is resolved from the project's Astro version, not hardcoded: 14.2.0+
139
+ // needs an astro@7.2.0-only export while its peerDeps still claim `^7.0.0`,
140
+ // so an unbounded `^14.0.0` breaks Astro 7.0/7.1. See resolve-cloudflare-adapter.
141
+ return {
142
+ name: '@astrojs/cloudflare',
143
+ version: (0, resolve_cloudflare_adapter_1.resolveCloudflareAdapterRange)(this.getDependencyVersion('astro')),
144
+ peerDependencies: ['@cloudflare/vite-plugin'],
145
+ };
146
+ }
147
+ getRequiredIntegrations() {
148
+ return [
149
+ {
150
+ name: '@astrojs/react',
151
+ version: '^6.0.0', // Astro 7 compatible version
152
+ reason: 'Required for Webflow React components',
153
+ },
154
+ ];
155
+ }
156
+ async installDependencies() {
157
+ const { log, cwd, runCommand } = this.ctx;
158
+ // Clamp the adapter into the range compatible with this project's Astro version:
159
+ // install it when absent, and force it back into range when the declared spec
160
+ // floats too high (`^14.0.0` -> 14.2.x on Astro 7.0/7.1) or too low. Shared with
161
+ // Astro 6 so the two paths can't silently diverge.
162
+ const adapter = this.getCloudflareAdapter();
163
+ await (0, ensure_compatible_cloudflare_adapter_1.ensureCompatibleCloudflareAdapter)({
164
+ log,
165
+ runCommand,
166
+ cwd,
167
+ adapterName: adapter.name,
168
+ compatibleRange: adapter.version,
169
+ declaredVersion: this.getDependencyVersion(adapter.name),
170
+ });
171
+ // Install peer dependencies.
172
+ if (adapter.peerDependencies) {
173
+ for (const peer of adapter.peerDependencies) {
174
+ if (!this.hasDependency(peer)) {
175
+ log.warn(`Installing ${peer} (peer dependency of ${adapter.name})...`);
176
+ await (0, utils_1.npm)({ log, runCommand, cwd, args: ['install', '--save', peer] });
177
+ }
178
+ }
179
+ }
180
+ for (const integration of this.getRequiredIntegrations()) {
181
+ if (!this.hasDependency(integration.name)) {
182
+ log.warn(`Installing ${integration.name}@${integration.version} (${integration.reason})...`);
183
+ await (0, utils_1.npm)({
184
+ log,
185
+ runCommand,
186
+ cwd,
187
+ args: ['install', '--save', `${integration.name}@${integration.version}`],
188
+ });
189
+ }
190
+ }
191
+ }
192
+ // ───────────────────────────────────────────────────────────────────────────
193
+ // CONFIGURATION
194
+ // ───────────────────────────────────────────────────────────────────────────
195
+ getWebflowLoader() {
196
+ return {
197
+ templatePath: path.join(TEMPLATE_BASE, 'webflow-loader.ts'),
198
+ destinationName: 'webflow-loader.ts',
199
+ configPath: './webflow-loader.ts',
200
+ };
201
+ }
202
+ getUserConfigPatterns() {
203
+ return ['astro.config.mjs', 'astro.config.cjs', 'astro.config.js', 'astro.config.ts'];
204
+ }
205
+ getWranglerTemplatePath() {
206
+ return path.join(TEMPLATE_BASE, 'wrangler.json');
207
+ }
208
+ getAdditionalConfigFiles() {
209
+ const loader = this.getWebflowLoader();
210
+ return [
211
+ loader.templatePath,
212
+ path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts'),
213
+ path.join(SHARED_TEMPLATE_BASE, 'webflow-image-url.ts'),
214
+ ];
215
+ }
216
+ async prepareConfig() {
217
+ const { log, cwd, userEnv } = this.ctx;
218
+ // Rename user's astro.config.* to clouduser.astro.config.*; if there is no
219
+ // user config, write an empty stub so the generated template's static
220
+ // import always resolves.
221
+ const renamedUserConfig = (0, utils_1.renameUserConfig)(log, cwd, 'astro.config', [
222
+ 'mjs',
223
+ 'cjs',
224
+ 'js',
225
+ 'ts',
226
+ ]);
227
+ if (renamedUserConfig === null) {
228
+ log.info('no user astro.config.{mjs,cjs,js,ts} found — writing empty clouduser.astro.config.mjs stub');
229
+ fs.writeFileSync(path.join(cwd, 'clouduser.astro.config.mjs'), 'export default {};\n');
230
+ }
231
+ // Copy the merge-logic library (real source, not a template). The generated
232
+ // astro.config.mjs statically imports it, so fail loudly if the package did
233
+ // not ship it rather than failing later with an opaque module error.
234
+ const webflowConfigSrc = path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts');
235
+ if (!(0, utils_1.fileExists)(webflowConfigSrc)) {
236
+ throw new Error(`Missing packaged template: ${webflowConfigSrc}`);
237
+ }
238
+ log.info('Copying astro.config.webflow.ts...');
239
+ fs.copyFileSync(webflowConfigSrc, path.join(cwd, 'astro.config.webflow.ts'));
240
+ // Copy the shared image-url helper that webflow-loader.ts imports. It is a
241
+ // hard dependency of the generated loader, so fail loudly if the package did
242
+ // not ship it rather than letting the user's build fail later with an opaque
243
+ // "Cannot find module './webflow-image-url'".
244
+ const imageUrlSrc = path.join(SHARED_TEMPLATE_BASE, 'webflow-image-url.ts');
245
+ if (!(0, utils_1.fileExists)(imageUrlSrc)) {
246
+ throw new Error(`Missing packaged template: ${imageUrlSrc}`);
247
+ }
248
+ log.info('Copying webflow-image-url.ts...');
249
+ fs.copyFileSync(imageUrlSrc, path.join(cwd, 'webflow-image-url.ts'));
250
+ // Render the single astro.config.mjs template.
251
+ const templatePath = path.join(TEMPLATE_BASE, 'astro.config.mjs.template');
252
+ const destPath = path.join(cwd, 'astro.config.mjs');
253
+ log.info('Generating astro.config.mjs from template (Astro 7)...');
254
+ await (0, utils_1.envsubst)(log, templatePath, destPath, {
255
+ ...process.env,
256
+ ...userEnv,
257
+ });
258
+ // Copy webflow-loader.ts.
259
+ const loader = this.getWebflowLoader();
260
+ if ((0, utils_1.fileExists)(loader.templatePath)) {
261
+ log.info(`Copying ${loader.destinationName}...`);
262
+ fs.copyFileSync(loader.templatePath, path.join(cwd, loader.destinationName));
263
+ }
264
+ // wrangler.json is owned exclusively by `handleWranglerJson`, which runs
265
+ // before this hook and is the only function permitted to write
266
+ // /wrangler.json.
267
+ }
268
+ // ───────────────────────────────────────────────────────────────────────────
269
+ // BUILD
270
+ // ───────────────────────────────────────────────────────────────────────────
271
+ getBuildCommand() {
272
+ return 'astro build';
273
+ }
274
+ getNodeVersionRequirement() {
275
+ return {
276
+ minimum: '22.12.0',
277
+ severity: 'error', // Astro 7 will definitely fail without Node 22+
278
+ };
279
+ }
280
+ // ───────────────────────────────────────────────────────────────────────────
281
+ // OUTPUT
282
+ // ───────────────────────────────────────────────────────────────────────────
283
+ static getOutputDeployMetadata() {
284
+ return {
285
+ staticAssetsPath: 'dist/client',
286
+ // No exclude needed — Astro 7 has clean separation.
287
+ workerEntryPath: 'dist/server/entry.mjs',
288
+ wranglerMainOverride: '@astrojs/cloudflare/entrypoints/server',
289
+ deploymentType: 'ssr',
290
+ usesAssetsBinding: true,
291
+ // Astro 7 outputs multiple files (entry.mjs + chunks/*) that need bundling.
292
+ skipNoBundle: true,
293
+ // A fixed @astrojs/cloudflare nests the client tree under dist/client/<mount>/
294
+ // (base = mountPath), so the copy takes dist/client verbatim into the assets root
295
+ // instead of the blind Astro 5 / Next.js mount append.
296
+ staticAssetsMirrorUrlLayout: true,
297
+ // After wrangler dry-run, the bundled output is ./entry.mjs
298
+ dryRunEntryPath: './entry.mjs',
299
+ };
300
+ }
301
+ }
302
+ exports.Astro7Builder = Astro7Builder;
303
+ //# sourceMappingURL=astro7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astro7.js","sourceRoot":"","sources":["../../../src/frameworks/astro/astro7.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,gDAAkC;AAClC,4CAA8B;AAE9B,kCAA2C;AAY3C,sCAAqD;AACrD,iHAA2G;AAC3G,6FAA6F;AAC7F,uCAOqB;AAErB,uCAAuC;AACvC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC9D,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAE/D,MAAa,aAAc,SAAQ,uBAAgB;IACjD,MAAM,CAAU,aAAa,GAAG,OAAO,CAAC;IAExC,8EAA8E;IAC9E,iBAAiB;IACjB,8EAA8E;IAE9E,IAAI,IAAI;QACN,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,OAAO;SACrB,CAAC;IACJ,CAAC;IAEQ,mBAAmB;QAC1B,OAAO,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;;;;;OAMG;IACH,MAAM,CAAU,MAAM,CAAC,WAAwB,EAAE,WAAyB;QACxE,MAAM,kBAAkB,GAAG,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC;QAEzD,gEAAgE;QAChE,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO,EAAE,CAAC;YACzD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC7B,CAAC;QAED,MAAM,YAAY,GAAG,WAAW,CAAC,YAAY,EAAE,KAA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,yEAAyE;QACzE,+DAA+D;QAC/D,kBAAkB;IACpB,CAAC;IAED,8EAA8E;IAC9E,QAAQ;IACR,8EAA8E;IAE9E,eAAe;QACb,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,yBAAyB;QACvB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,OAAO,EAAE,gDAAgD;SACpE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,SAAS;IACT,8EAA8E;IAE9E,MAAM,CAAU,uBAAuB;QACrC,OAAO;YACL,gBAAgB,EAAE,aAAa;YAC/B,oDAAoD;YACpD,eAAe,EAAE,uBAAuB;YACxC,oBAAoB,EAAE,wCAAwC;YAC9D,cAAc,EAAE,KAAK;YACrB,iBAAiB,EAAE,IAAI;YACvB,4EAA4E;YAC5E,YAAY,EAAE,IAAI;YAClB,+EAA+E;YAC/E,kFAAkF;YAClF,uDAAuD;YACvD,2BAA2B,EAAE,IAAI;YACjC,4DAA4D;YAC5D,eAAe,EAAE,aAAa;SAC/B,CAAC;IACJ,CAAC;;AArSH,sCAsSC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Astro Framework Builders.
3
+ *
4
+ * Exports Astro5/6/7 builders for use by the registry. Version detection is
5
+ * handled by each builder's static detect() method.
6
+ */
7
+ export { Astro5Builder } from './astro5';
8
+ export { Astro6Builder } from './astro6';
9
+ export { Astro7Builder } from './astro7';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/astro/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Astro7Builder = exports.Astro6Builder = exports.Astro5Builder = void 0;
4
+ /**
5
+ * Astro Framework Builders.
6
+ *
7
+ * Exports Astro5/6/7 builders for use by the registry. Version detection is
8
+ * handled by each builder's static detect() method.
9
+ */
10
+ var astro5_1 = require("./astro5");
11
+ Object.defineProperty(exports, "Astro5Builder", { enumerable: true, get: function () { return astro5_1.Astro5Builder; } });
12
+ var astro6_1 = require("./astro6");
13
+ Object.defineProperty(exports, "Astro6Builder", { enumerable: true, get: function () { return astro6_1.Astro6Builder; } });
14
+ var astro7_1 = require("./astro7");
15
+ Object.defineProperty(exports, "Astro7Builder", { enumerable: true, get: function () { return astro7_1.Astro7Builder; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/astro/index.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AACtB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AACtB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA"}
@@ -0,0 +1,24 @@
1
+ export declare const ASTRO_SESSION_BINDING = "SESSION";
2
+ /**
3
+ * Returns the project-relative path of the first source file that appears to
4
+ * use Astro sessions, or undefined. Skips dependencies, build output, dot-dirs
5
+ * and symlinks; stops after MAX_FILES files.
6
+ */
7
+ export declare function findAstroSessionUsage(cwd: string): string | undefined;
8
+ /**
9
+ * Returns the ASTRO_SESSION_BINDING_MISSING warning line when an Astro app uses
10
+ * sessions but declares no SESSION KV binding, else undefined. Never throws for
11
+ * scan problems and never provisions anything: detection is a heuristic.
12
+ *
13
+ * `configFile` is the basename of the user's wrangler config, or undefined when
14
+ * the app has none.
15
+ */
16
+ export declare function astroSessionBindingWarning(opts: {
17
+ framework: string;
18
+ cwd: string;
19
+ configFile: string | undefined;
20
+ kvNamespaces: ReadonlyArray<{
21
+ binding: string;
22
+ }>;
23
+ }): string | undefined;
24
+ //# sourceMappingURL=session-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-check.d.ts","sourceRoot":"","sources":["../../../src/frameworks/astro/session-check.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,YAAY,CAAC;AA+B/C;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA4CrE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD,GAAG,MAAM,GAAG,SAAS,CAiCrB"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ASTRO_SESSION_BINDING = void 0;
37
+ exports.findAstroSessionUsage = findAstroSessionUsage;
38
+ exports.astroSessionBindingWarning = astroSessionBindingWarning;
39
+ const fs = __importStar(require("node:fs"));
40
+ const path = __importStar(require("node:path"));
41
+ const diagnostics_1 = require("../../diagnostics");
42
+ // Astro sessions on Cloudflare use the KV binding named SESSION (the
43
+ // @astrojs/cloudflare default, which the platform's Astro config template
44
+ // does not override). Without it the app builds and deploys, then fails on the
45
+ // first session read or write with an error that does not name the binding.
46
+ exports.ASTRO_SESSION_BINDING = 'SESSION';
47
+ const SCAN_EXTENSIONS = new Set([
48
+ '.astro',
49
+ '.ts',
50
+ '.tsx',
51
+ '.mts',
52
+ '.cts',
53
+ '.js',
54
+ '.jsx',
55
+ '.mjs',
56
+ '.cjs',
57
+ ]);
58
+ // Dependencies and build output: matches there are not the user's code.
59
+ const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'clouduser']);
60
+ const MAX_FILES = 5000;
61
+ const MAX_FILE_BYTES = 1024 * 1024;
62
+ // Heuristic (no AST): the forms the Astro docs use for sessions in pages,
63
+ // middleware, endpoints and actions.
64
+ const SESSION_USAGE_PATTERNS = [
65
+ // Astro.session.get(...) in .astro files
66
+ /\bAstro\.session\b/,
67
+ // context.session / ctx.session in middleware, endpoints, actions
68
+ /\b(?:context|ctx)\.session\b/,
69
+ // ({ session }) => / (input, { session }) => / function GET({ session }) {
70
+ /\(\s*(?:[\w$]+\s*,\s*)?\{[^{}()]*\bsession\b[^{}()]*\}\s*(?::\s*[\w$.<>[\]]+\s*)?(?:,[^()]*)?\)\s*(?::\s*[^=>{;]+)?(?:=>|\{)/,
71
+ // const { session } = Astro / context / ctx
72
+ /\{[^{}]*\bsession\b[^{}]*\}\s*=\s*(?:Astro|context|ctx)\b/,
73
+ ];
74
+ /**
75
+ * Returns the project-relative path of the first source file that appears to
76
+ * use Astro sessions, or undefined. Skips dependencies, build output, dot-dirs
77
+ * and symlinks; stops after MAX_FILES files.
78
+ */
79
+ function findAstroSessionUsage(cwd) {
80
+ const stack = [cwd];
81
+ let scanned = 0;
82
+ while (stack.length > 0) {
83
+ const dir = stack.pop();
84
+ let entries;
85
+ try {
86
+ entries = fs.readdirSync(dir, { withFileTypes: true });
87
+ }
88
+ catch {
89
+ continue;
90
+ }
91
+ entries.sort((a, b) => a.name.localeCompare(b.name));
92
+ const subdirs = [];
93
+ for (const entry of entries) {
94
+ const full = path.join(dir, entry.name);
95
+ if (entry.isDirectory()) {
96
+ if (!entry.name.startsWith('.') && !SKIP_DIRS.has(entry.name)) {
97
+ subdirs.push(full);
98
+ }
99
+ continue;
100
+ }
101
+ if (!entry.isFile() || !SCAN_EXTENSIONS.has(path.extname(entry.name))) {
102
+ continue;
103
+ }
104
+ if (++scanned > MAX_FILES) {
105
+ return undefined;
106
+ }
107
+ let source;
108
+ try {
109
+ if (fs.statSync(full).size > MAX_FILE_BYTES)
110
+ continue;
111
+ source = fs.readFileSync(full, 'utf8');
112
+ }
113
+ catch {
114
+ continue;
115
+ }
116
+ if (SESSION_USAGE_PATTERNS.some((pattern) => pattern.test(source))) {
117
+ return path.relative(cwd, full).split(path.sep).join('/');
118
+ }
119
+ }
120
+ // Reverse so the stack visits subdirectories in sorted order.
121
+ stack.push(...subdirs.reverse());
122
+ }
123
+ return undefined;
124
+ }
125
+ /**
126
+ * Returns the ASTRO_SESSION_BINDING_MISSING warning line when an Astro app uses
127
+ * sessions but declares no SESSION KV binding, else undefined. Never throws for
128
+ * scan problems and never provisions anything: detection is a heuristic.
129
+ *
130
+ * `configFile` is the basename of the user's wrangler config, or undefined when
131
+ * the app has none.
132
+ */
133
+ function astroSessionBindingWarning(opts) {
134
+ const { framework, cwd, configFile, kvNamespaces } = opts;
135
+ if (framework !== 'astro') {
136
+ return undefined;
137
+ }
138
+ if (kvNamespaces.some((kv) => kv.binding === exports.ASTRO_SESSION_BINDING)) {
139
+ return undefined;
140
+ }
141
+ const usedIn = findAstroSessionUsage(cwd);
142
+ if (!usedIn) {
143
+ return undefined;
144
+ }
145
+ const binding = `{ "binding": "${exports.ASTRO_SESSION_BINDING}" }`;
146
+ let fix;
147
+ if (!configFile) {
148
+ fix = `create wrangler.json with "name", "compatibility_date" and "kv_namespaces": [${binding}].`;
149
+ }
150
+ else if (kvNamespaces.length > 0) {
151
+ fix = `add ${binding} to "kv_namespaces" in ${configFile}.`;
152
+ }
153
+ else {
154
+ fix = `add "kv_namespaces": [${binding}] to ${configFile}.`;
155
+ }
156
+ const missing = configFile
157
+ ? `${configFile} has no ${exports.ASTRO_SESSION_BINDING} KV binding`
158
+ : `there is no wrangler.json with a ${exports.ASTRO_SESSION_BINDING} KV binding`;
159
+ return (0, diagnostics_1.formatDiagnostic)({
160
+ level: 'warn',
161
+ code: diagnostics_1.DiagnosticCode.ASTRO_SESSION_BINDING_MISSING,
162
+ message: `${usedIn} uses Astro sessions, but ${missing}, so session reads and writes will fail at runtime.`,
163
+ fix,
164
+ });
165
+ }
166
+ //# sourceMappingURL=session-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-check.js","sourceRoot":"","sources":["../../../src/frameworks/astro/session-check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,sDA4CC;AAUD,gEAsCC;AAxID,4CAA8B;AAC9B,gDAAkC;AAClC,mDAAqE;AAErE,qEAAqE;AACrE,0EAA0E;AAC1E,+EAA+E;AAC/E,4EAA4E;AAC/D,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAE/C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,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; types are local to avoid Astro
3
+ // cross-version drift.
4
+
5
+ type AstroIntegration = { name?: string; [key: string]: any };
6
+ type AstroUserConfig = Record<string, any>;
7
+
8
+ export type WebflowOverridesOptions = {
9
+ mountPath: string;
10
+ deployUrl: string;
11
+ /** The result of `cloudflare({ ... })` from `@astrojs/cloudflare`. */
12
+ adapter: any;
13
+ /** The result of `react()` from `@astrojs/react`. Auto-added if the user hasn't already added `@astrojs/react`. */
14
+ reactIntegration: AstroIntegration;
15
+ /** Extra Vite resolve.alias to inject (e.g. react-dom/server -> react-dom/server.edge for React 19+ in prod). Pass `undefined` to skip. */
16
+ reactDomServerAlias: Record<string, string> | undefined;
17
+ };
18
+
19
+ /**
20
+ * Wrap the user's Astro config with Webflow Cloud's required overrides.
21
+ * `userExport` is always provided — `{}` when the user ships no astro.config.*.
22
+ *
23
+ * Top-level keys in the override block REPLACE the user's — our adapter / base /
24
+ * output need to win.
25
+ */
26
+ export function withWebflowOverrides(
27
+ userExport: AstroUserConfig,
28
+ opts: WebflowOverridesOptions,
29
+ ): AstroUserConfig {
30
+ const userIntegrations: AstroIntegration[] = userExport.integrations || [];
31
+ const hasReact = userIntegrations.some((i) => i?.name === '@astrojs/react');
32
+ const integrations = hasReact ? userIntegrations : [...userIntegrations, opts.reactIntegration];
33
+
34
+ return {
35
+ ...userExport,
36
+ base: opts.mountPath,
37
+ output: 'server',
38
+ adapter: opts.adapter,
39
+ integrations,
40
+ vite: {
41
+ ...userExport.vite,
42
+ resolve: {
43
+ ...userExport.vite?.resolve,
44
+ alias: opts.reactDomServerAlias,
45
+ },
46
+ },
47
+ build: {
48
+ assetsPrefix: opts.deployUrl + (opts.mountPath === '/' ? '' : opts.mountPath),
49
+ },
50
+ image: {
51
+ ...userExport.image,
52
+ service: {
53
+ entrypoint: './webflow-loader.ts',
54
+ config: {
55
+ deployUrl: opts.deployUrl,
56
+ mountPath: opts.mountPath,
57
+ },
58
+ },
59
+ },
60
+ };
61
+ }