@webflow/cloud-app 0.1.0-beta.7 → 0.1.0-beta.8

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 (48) hide show
  1. package/README.md +68 -0
  2. package/dist/config/webflow-json.d.ts +0 -6
  3. package/dist/config/webflow-json.d.ts.map +1 -1
  4. package/dist/config/webflow-json.js.map +1 -1
  5. package/dist/create-webflow-json.d.ts +2 -5
  6. package/dist/create-webflow-json.d.ts.map +1 -1
  7. package/dist/create-webflow-json.js +7 -9
  8. package/dist/create-webflow-json.js.map +1 -1
  9. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +28 -0
  10. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts.map +1 -0
  11. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +148 -0
  12. package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js.map +1 -0
  13. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.d.ts +2 -2
  14. package/dist/frameworks/astro/adapter-patches/ensure-fixed-cloudflare-adapter.js +2 -2
  15. package/dist/frameworks/astro/astro5.d.ts.map +1 -1
  16. package/dist/frameworks/astro/astro5.js +22 -5
  17. package/dist/frameworks/astro/astro5.js.map +1 -1
  18. package/dist/frameworks/astro/astro6.d.ts.map +1 -1
  19. package/dist/frameworks/astro/astro6.js +27 -10
  20. package/dist/frameworks/astro/astro6.js.map +1 -1
  21. package/dist/frameworks/astro/astro7.d.ts.map +1 -1
  22. package/dist/frameworks/astro/astro7.js +25 -8
  23. package/dist/frameworks/astro/astro7.js.map +1 -1
  24. package/dist/frameworks/astro/templates/v5/webflow-loader.ts +58 -35
  25. package/dist/frameworks/astro/templates/v6/webflow-loader.ts +53 -39
  26. package/dist/frameworks/astro/templates/v7/webflow-loader.ts +51 -39
  27. package/dist/frameworks/astro/templates/webflow-image-url.ts +140 -0
  28. package/dist/frameworks/base.d.ts +1 -1
  29. package/dist/frameworks/base.js +1 -1
  30. package/dist/frameworks/static/index.d.ts +23 -0
  31. package/dist/frameworks/static/index.d.ts.map +1 -1
  32. package/dist/frameworks/static/index.js +51 -9
  33. package/dist/frameworks/static/index.js.map +1 -1
  34. package/dist/frameworks/types.d.ts +6 -6
  35. package/dist/frameworks/types.d.ts.map +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +2 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/pipeline.d.ts +4 -0
  41. package/dist/pipeline.d.ts.map +1 -1
  42. package/dist/pipeline.js +21 -10
  43. package/dist/pipeline.js.map +1 -1
  44. package/dist/ports/command-runner.d.ts +5 -6
  45. package/dist/ports/command-runner.d.ts.map +1 -1
  46. package/dist/ports/command-runner.js +17 -7
  47. package/dist/ports/command-runner.js.map +1 -1
  48. package/package.json +2 -1
@@ -204,7 +204,11 @@ class Astro7Builder extends base_1.FrameworkBuilder {
204
204
  }
205
205
  getAdditionalConfigFiles() {
206
206
  const loader = this.getWebflowLoader();
207
- return [loader.templatePath, path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts')];
207
+ return [
208
+ loader.templatePath,
209
+ path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts'),
210
+ path.join(SHARED_TEMPLATE_BASE, 'webflow-image-url.ts'),
211
+ ];
208
212
  }
209
213
  async prepareConfig() {
210
214
  const { log, cwd, userEnv } = this.ctx;
@@ -221,12 +225,25 @@ class Astro7Builder extends base_1.FrameworkBuilder {
221
225
  log.info('no user astro.config.{mjs,cjs,js,ts} found — writing empty clouduser.astro.config.mjs stub');
222
226
  fs.writeFileSync(path.join(cwd, 'clouduser.astro.config.mjs'), 'export default {};\n');
223
227
  }
224
- // Copy the merge-logic library (real source, not a template).
228
+ // Copy the merge-logic library (real source, not a template). The generated
229
+ // astro.config.mjs statically imports it, so fail loudly if the package did
230
+ // not ship it rather than failing later with an opaque module error.
225
231
  const webflowConfigSrc = path.join(SHARED_TEMPLATE_BASE, 'astro.config.webflow.ts');
226
- if ((0, utils_1.fileExists)(webflowConfigSrc)) {
227
- log.info('Copying astro.config.webflow.ts...');
228
- fs.copyFileSync(webflowConfigSrc, path.join(cwd, 'astro.config.webflow.ts'));
232
+ if (!(0, utils_1.fileExists)(webflowConfigSrc)) {
233
+ throw new Error(`Missing packaged template: ${webflowConfigSrc}`);
234
+ }
235
+ log.info('Copying astro.config.webflow.ts...');
236
+ fs.copyFileSync(webflowConfigSrc, path.join(cwd, 'astro.config.webflow.ts'));
237
+ // Copy the shared image-url helper that webflow-loader.ts imports. It is a
238
+ // hard dependency of the generated loader, so fail loudly if the package did
239
+ // not ship it rather than letting the user's build fail later with an opaque
240
+ // "Cannot find module './webflow-image-url'".
241
+ const imageUrlSrc = path.join(SHARED_TEMPLATE_BASE, 'webflow-image-url.ts');
242
+ if (!(0, utils_1.fileExists)(imageUrlSrc)) {
243
+ throw new Error(`Missing packaged template: ${imageUrlSrc}`);
229
244
  }
245
+ log.info('Copying webflow-image-url.ts...');
246
+ fs.copyFileSync(imageUrlSrc, path.join(cwd, 'webflow-image-url.ts'));
230
247
  // Render the single astro.config.mjs template.
231
248
  const templatePath = path.join(TEMPLATE_BASE, 'astro.config.mjs.template');
232
249
  const destPath = path.join(cwd, 'astro.config.mjs');
@@ -271,9 +288,9 @@ class Astro7Builder extends base_1.FrameworkBuilder {
271
288
  // Astro 7 outputs multiple files (entry.mjs + chunks/*) that need bundling.
272
289
  skipNoBundle: true,
273
290
  // A fixed @astrojs/cloudflare nests the client tree under dist/client/<mount>/
274
- // (base = mountPath), so the copy descends into that mount dir via
275
- // stripCloudflareBaseNesting instead of the blind Astro 5 / Next.js append.
276
- assetsSourceSkipMountPath: true,
291
+ // (base = mountPath), so the copy takes dist/client verbatim into the assets root
292
+ // instead of the blind Astro 5 / Next.js mount append.
293
+ staticAssetsMirrorUrlLayout: true,
277
294
  // After wrangler dry-run, the bundled output is ./entry.mjs
278
295
  dryRunEntryPath: './entry.mjs',
279
296
  };
@@ -1 +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,uGAAiG;AACjG,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,KAAK,IAAI,WAAW,CAAC,eAAe,EAAE,KA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AAO,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;;AAnSH,sCAoSC"}
@@ -1,16 +1,18 @@
1
- import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
1
+ /**
2
+ * Webflow Image Loader for Astro 5
3
+ *
4
+ * A custom Astro image service that resizes images on demand through
5
+ * Cloudflare's zone-level Image Resizing (`/cdn-cgi/image/...`). URL-building
6
+ * and responsive-width logic live in the framework-agnostic ./webflow-image-url
7
+ * helper (unit-tested); this file is the thin Astro-typed glue. Same loader as
8
+ * Astro 6 and 7.
9
+ *
10
+ * We set the adapter's imageService to 'custom' to keep resizing on the zone
11
+ * endpoint rather than the Worker Images binding.
12
+ */
2
13
 
3
- function normalizeSrc(src: string, deployUrl?: string, mountPath?: string) {
4
- // For local assets, include the mount path but not the deploy url, and remove the leading slash
5
- if (deployUrl && src.startsWith(deployUrl)) {
6
- return `${src.slice(deployUrl.length)}`.slice(1);
7
- } else if (mountPath && src.startsWith(mountPath)) {
8
- return src.slice(1);
9
- } else if (src.startsWith('/')) {
10
- return `${mountPath}${src}`.slice(1);
11
- }
12
- return src;
13
- }
14
+ import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
15
+ import { normalizeSrc, isRemote, buildImageUrl, computeSrcSetWidths } from './webflow-image-url';
14
16
 
15
17
  // Default implementation copied from Astro's baseService
16
18
  function getTargetDimensions(options: ImageTransform) {
@@ -38,37 +40,58 @@ function getTargetDimensions(options: ImageTransform) {
38
40
 
39
41
  const cloudflareLoader: ExternalImageService = {
40
42
  getURL(options: ImageTransform, imageConfig: AstroConfig['image']) {
43
+ const { deployUrl, mountPath } = imageConfig.service.config;
41
44
  const normalizedSrc = normalizeSrc(
42
45
  typeof options.src === 'object' ? options.src.src : options.src,
43
- imageConfig.service.config.deployUrl,
44
- imageConfig.service.config.mountPath,
46
+ deployUrl,
47
+ mountPath,
45
48
  );
46
- // Our cloudflare zone doesn't allow optimizing external images for security reasons, so just load the original image
47
- // For now, also skip optimization for images hosted on regular webflow sites (cdn.website-files.com)
48
- // because optimizing them would result in two bandwidth charges: one from the website-files zone (for the full image)
49
- // and one from the cosmic.webflow.services zone (for the resized image)
50
- if (normalizedSrc.startsWith('http://') || normalizedSrc.startsWith('https://')) {
51
- return normalizedSrc;
52
- }
49
+ const isSvg =
50
+ typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
53
51
 
54
- const supportedOptions = ['width', 'height', 'quality', 'format'];
55
- const params = [];
56
- for (const option of supportedOptions) {
57
- if (options[option]) {
58
- params.push(`${option}=${options[option]}`);
59
- }
60
- }
52
+ return buildImageUrl(
53
+ normalizedSrc,
54
+ {
55
+ width: options.width,
56
+ height: options.height,
57
+ quality: options.quality,
58
+ format: options.format,
59
+ },
60
+ deployUrl,
61
+ isSvg,
62
+ );
63
+ },
61
64
 
62
- const workerUrl = imageConfig.service.config.deployUrl;
63
- // Skip resizing svgs, since it doesn't do anything
65
+ // Responsive variants. Astro resolves each entry's URL by calling getURL on
66
+ // its `transform`, so format=auto (set in getURL) flows through here too.
67
+ getSrcSet(options: ImageTransform, imageConfig: AstroConfig['image']) {
68
+ // Mirror getURL's passthrough: remote and SVG sources are not resized, so a
69
+ // srcset of identical URLs would be misleading markup. Normalize first, as
70
+ // getURL does, since build.assetsPrefix makes local asset srcs absolute on
71
+ // the deploy origin.
72
+ const { deployUrl, mountPath } = imageConfig.service.config;
73
+ const srcString = typeof options.src === 'object' ? options.src.src : options.src;
74
+ const normalizedSrc = normalizeSrc(srcString, deployUrl, mountPath);
64
75
  const isSvg =
65
- typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
66
- if (isSvg || params.length === 0) {
67
- return `${workerUrl}/${normalizedSrc}`;
76
+ typeof options.src === 'object' ? options.src.format === 'svg' : srcString.endsWith('.svg');
77
+ if (isSvg || isRemote(normalizedSrc)) {
78
+ return [];
68
79
  }
69
80
 
70
- const paramsString = params.join(',');
71
- return `${workerUrl}/cdn-cgi/image/${paramsString}/${normalizedSrc}`;
81
+ const { targetWidth, targetHeight } = getTargetDimensions(options);
82
+ const maxWidth =
83
+ typeof options.src === 'object' && 'width' in options.src ? options.src.width : undefined;
84
+
85
+ return computeSrcSetWidths(options, targetWidth, targetHeight, maxWidth).map(
86
+ ({ width, height, descriptor }) => ({
87
+ transform: { ...options, width, height },
88
+ descriptor,
89
+ // Only advertise a MIME type when a concrete format was requested. With
90
+ // the default (format=auto) Cloudflare negotiates the output, so
91
+ // `type: "image/auto"` would be an invalid, misleading hint.
92
+ attributes: options.format ? { type: `image/${options.format}` } : {},
93
+ }),
94
+ );
72
95
  },
73
96
 
74
97
  // Default implementation copied from Astro's baseService
@@ -1,25 +1,18 @@
1
1
  /**
2
2
  * Webflow Image Loader for Astro 6
3
3
  *
4
- * This is the same loader as Astro 5 — it handles image optimization through
5
- * Cloudflare's image resizing service.
4
+ * A custom Astro image service that resizes images on demand through
5
+ * Cloudflare's zone-level Image Resizing (`/cdn-cgi/image/...`). URL-building
6
+ * and responsive-width logic live in the framework-agnostic ./webflow-image-url
7
+ * helper (unit-tested); this file is the thin Astro-typed glue. Same loader as
8
+ * Astro 5 and 7.
6
9
  *
7
- * Note: Astro 6 defaults to 'cloudflare-binding' for imageService, but we use
8
- * 'custom' to maintain compatibility with our CDN setup.
10
+ * We set the adapter's imageService to 'custom' to keep resizing on the zone
11
+ * endpoint rather than the Worker Images binding.
9
12
  */
10
- import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
11
13
 
12
- function normalizeSrc(src: string, deployUrl?: string, mountPath?: string) {
13
- // For local assets, include the mount path but not the deploy url, and remove the leading slash
14
- if (deployUrl && src.startsWith(deployUrl)) {
15
- return `${src.slice(deployUrl.length)}`.slice(1);
16
- } else if (mountPath && src.startsWith(mountPath)) {
17
- return src.slice(1);
18
- } else if (src.startsWith('/')) {
19
- return `${mountPath}${src}`.slice(1);
20
- }
21
- return src;
22
- }
14
+ import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
15
+ import { normalizeSrc, isRemote, buildImageUrl, computeSrcSetWidths } from './webflow-image-url';
23
16
 
24
17
  // Default implementation copied from Astro's baseService
25
18
  function getTargetDimensions(options: ImageTransform) {
@@ -47,37 +40,58 @@ function getTargetDimensions(options: ImageTransform) {
47
40
 
48
41
  const cloudflareLoader: ExternalImageService = {
49
42
  getURL(options: ImageTransform, imageConfig: AstroConfig['image']) {
43
+ const { deployUrl, mountPath } = imageConfig.service.config;
50
44
  const normalizedSrc = normalizeSrc(
51
45
  typeof options.src === 'object' ? options.src.src : options.src,
52
- imageConfig.service.config.deployUrl,
53
- imageConfig.service.config.mountPath,
46
+ deployUrl,
47
+ mountPath,
54
48
  );
55
- // Our cloudflare zone doesn't allow optimizing external images for security reasons, so just load the original image
56
- // For now, also skip optimization for images hosted on regular webflow sites (cdn.website-files.com)
57
- // because optimizing them would result in two bandwidth charges: one from the website-files zone (for the full image)
58
- // and one from the cosmic.webflow.services zone (for the resized image)
59
- if (normalizedSrc.startsWith('http://') || normalizedSrc.startsWith('https://')) {
60
- return normalizedSrc;
61
- }
49
+ const isSvg =
50
+ typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
62
51
 
63
- const supportedOptions = ['width', 'height', 'quality', 'format'];
64
- const params = [];
65
- for (const option of supportedOptions) {
66
- if (options[option]) {
67
- params.push(`${option}=${options[option]}`);
68
- }
69
- }
52
+ return buildImageUrl(
53
+ normalizedSrc,
54
+ {
55
+ width: options.width,
56
+ height: options.height,
57
+ quality: options.quality,
58
+ format: options.format,
59
+ },
60
+ deployUrl,
61
+ isSvg,
62
+ );
63
+ },
70
64
 
71
- const workerUrl = imageConfig.service.config.deployUrl;
72
- // Skip resizing svgs, since it doesn't do anything
65
+ // Responsive variants. Astro resolves each entry's URL by calling getURL on
66
+ // its `transform`, so format=auto (set in getURL) flows through here too.
67
+ getSrcSet(options: ImageTransform, imageConfig: AstroConfig['image']) {
68
+ // Mirror getURL's passthrough: remote and SVG sources are not resized, so a
69
+ // srcset of identical URLs would be misleading markup. Normalize first, as
70
+ // getURL does, since build.assetsPrefix makes local asset srcs absolute on
71
+ // the deploy origin.
72
+ const { deployUrl, mountPath } = imageConfig.service.config;
73
+ const srcString = typeof options.src === 'object' ? options.src.src : options.src;
74
+ const normalizedSrc = normalizeSrc(srcString, deployUrl, mountPath);
73
75
  const isSvg =
74
- typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
75
- if (isSvg || params.length === 0) {
76
- return `${workerUrl}/${normalizedSrc}`;
76
+ typeof options.src === 'object' ? options.src.format === 'svg' : srcString.endsWith('.svg');
77
+ if (isSvg || isRemote(normalizedSrc)) {
78
+ return [];
77
79
  }
78
80
 
79
- const paramsString = params.join(',');
80
- return `${workerUrl}/cdn-cgi/image/${paramsString}/${normalizedSrc}`;
81
+ const { targetWidth, targetHeight } = getTargetDimensions(options);
82
+ const maxWidth =
83
+ typeof options.src === 'object' && 'width' in options.src ? options.src.width : undefined;
84
+
85
+ return computeSrcSetWidths(options, targetWidth, targetHeight, maxWidth).map(
86
+ ({ width, height, descriptor }) => ({
87
+ transform: { ...options, width, height },
88
+ descriptor,
89
+ // Only advertise a MIME type when a concrete format was requested. With
90
+ // the default (format=auto) Cloudflare negotiates the output, so
91
+ // `type: "image/auto"` would be an invalid, misleading hint.
92
+ attributes: options.format ? { type: `image/${options.format}` } : {},
93
+ }),
94
+ );
81
95
  },
82
96
 
83
97
  // Default implementation copied from Astro's baseService
@@ -1,26 +1,17 @@
1
1
  /**
2
2
  * Webflow Image Loader for Astro 7
3
3
  *
4
- * This is the same loader as Astro 5 and 6 - it handles image optimization
5
- * through Cloudflare's image resizing service.
4
+ * A custom Astro image service that resizes images on demand through
5
+ * Cloudflare's zone-level Image Resizing (`/cdn-cgi/image/...`). URL-building
6
+ * and responsive-width logic live in the framework-agnostic ./webflow-image-url
7
+ * helper (unit-tested); this file is the thin Astro-typed glue.
6
8
  *
7
- * Note: Astro 7 defaults to 'cloudflare-binding' for imageService,
8
- * but we use 'custom' to maintain compatibility with our CDN setup.
9
+ * Note: Astro 7 defaults to 'cloudflare-binding' for imageService, but we use
10
+ * 'custom' to keep resizing on the zone endpoint rather than the Worker binding.
9
11
  */
10
12
 
11
13
  import type { ExternalImageService, ImageTransform, AstroConfig } from 'astro';
12
-
13
- function normalizeSrc(src: string, deployUrl?: string, mountPath?: string) {
14
- // For local assets, include the mount path but not the deploy url, and remove the leading slash
15
- if (deployUrl && src.startsWith(deployUrl)) {
16
- return `${src.slice(deployUrl.length)}`.slice(1);
17
- } else if (mountPath && src.startsWith(mountPath)) {
18
- return src.slice(1);
19
- } else if (src.startsWith('/')) {
20
- return `${mountPath}${src}`.slice(1);
21
- }
22
- return src;
23
- }
14
+ import { normalizeSrc, isRemote, buildImageUrl, computeSrcSetWidths } from './webflow-image-url';
24
15
 
25
16
  // Default implementation copied from Astro's baseService
26
17
  function getTargetDimensions(options: ImageTransform) {
@@ -48,37 +39,58 @@ function getTargetDimensions(options: ImageTransform) {
48
39
 
49
40
  const cloudflareLoader: ExternalImageService = {
50
41
  getURL(options: ImageTransform, imageConfig: AstroConfig['image']) {
42
+ const { deployUrl, mountPath } = imageConfig.service.config;
51
43
  const normalizedSrc = normalizeSrc(
52
44
  typeof options.src === 'object' ? options.src.src : options.src,
53
- imageConfig.service.config.deployUrl,
54
- imageConfig.service.config.mountPath,
45
+ deployUrl,
46
+ mountPath,
55
47
  );
56
- // Our cloudflare zone doesn't allow optimizing external images for security reasons, so just load the original image
57
- // For now, also skip optimization for images hosted on regular webflow sites (cdn.website-files.com)
58
- // because optimizing them would result in two bandwidth charges: one from the website-files zone (for the full image)
59
- // and one from the cosmic.webflow.services zone (for the resized image)
60
- if (normalizedSrc.startsWith('http://') || normalizedSrc.startsWith('https://')) {
61
- return normalizedSrc;
62
- }
48
+ const isSvg =
49
+ typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
63
50
 
64
- const supportedOptions = ['width', 'height', 'quality', 'format'];
65
- const params = [];
66
- for (const option of supportedOptions) {
67
- if (options[option]) {
68
- params.push(`${option}=${options[option]}`);
69
- }
70
- }
51
+ return buildImageUrl(
52
+ normalizedSrc,
53
+ {
54
+ width: options.width,
55
+ height: options.height,
56
+ quality: options.quality,
57
+ format: options.format,
58
+ },
59
+ deployUrl,
60
+ isSvg,
61
+ );
62
+ },
71
63
 
72
- const workerUrl = imageConfig.service.config.deployUrl;
73
- // Skip resizing svgs, since it doesn't do anything
64
+ // Responsive variants. Astro resolves each entry's URL by calling getURL on
65
+ // its `transform`, so format=auto (set in getURL) flows through here too.
66
+ getSrcSet(options: ImageTransform, imageConfig: AstroConfig['image']) {
67
+ // Mirror getURL's passthrough: remote and SVG sources are not resized, so a
68
+ // srcset of identical URLs would be misleading markup. Normalize first, as
69
+ // getURL does, since build.assetsPrefix makes local asset srcs absolute on
70
+ // the deploy origin.
71
+ const { deployUrl, mountPath } = imageConfig.service.config;
72
+ const srcString = typeof options.src === 'object' ? options.src.src : options.src;
73
+ const normalizedSrc = normalizeSrc(srcString, deployUrl, mountPath);
74
74
  const isSvg =
75
- typeof options.src === 'object' ? options.src.format === 'svg' : options.src.endsWith('.svg');
76
- if (isSvg || params.length === 0) {
77
- return `${workerUrl}/${normalizedSrc}`;
75
+ typeof options.src === 'object' ? options.src.format === 'svg' : srcString.endsWith('.svg');
76
+ if (isSvg || isRemote(normalizedSrc)) {
77
+ return [];
78
78
  }
79
79
 
80
- const paramsString = params.join(',');
81
- return `${workerUrl}/cdn-cgi/image/${paramsString}/${normalizedSrc}`;
80
+ const { targetWidth, targetHeight } = getTargetDimensions(options);
81
+ const maxWidth =
82
+ typeof options.src === 'object' && 'width' in options.src ? options.src.width : undefined;
83
+
84
+ return computeSrcSetWidths(options, targetWidth, targetHeight, maxWidth).map(
85
+ ({ width, height, descriptor }) => ({
86
+ transform: { ...options, width, height },
87
+ descriptor,
88
+ // Only advertise a MIME type when a concrete format was requested. With
89
+ // the default (format=auto) Cloudflare negotiates the output, so
90
+ // `type: "image/auto"` would be an invalid, misleading hint.
91
+ attributes: options.format ? { type: `image/${options.format}` } : {},
92
+ }),
93
+ );
82
94
  },
83
95
 
84
96
  // Default implementation copied from Astro's baseService
@@ -0,0 +1,140 @@
1
+ // Pure helpers for Webflow Cloud's on-demand Cloudflare image URLs.
2
+ //
3
+ // Copied verbatim into the user's project (imported by webflow-loader.ts) and
4
+ // unit-tested directly in @webflow/cloud-app. Deliberately free of any `astro`
5
+ // import so it can be type-checked and tested without the framework installed;
6
+ // the loader supplies the Astro-typed glue. Shared across Astro 5/6/7.
7
+
8
+ export type ImageUrlOptions = {
9
+ width?: number;
10
+ height?: number;
11
+ quality?: number | string;
12
+ format?: string;
13
+ };
14
+
15
+ /**
16
+ * Rewrite an image src to a path relative to the deploy: add the mount path,
17
+ * drop the deploy URL, and remove the leading slash. Remote URLs are returned
18
+ * unchanged so the caller can detect and pass them through.
19
+ */
20
+ export function normalizeSrc(src: string, deployUrl?: string, mountPath?: string): string {
21
+ // For local assets, include the mount path but not the deploy url, and remove the leading slash
22
+ if (deployUrl && src.startsWith(deployUrl)) {
23
+ return `${src.slice(deployUrl.length)}`.slice(1);
24
+ } else if (mountPath && src.startsWith(mountPath)) {
25
+ return src.slice(1);
26
+ } else if (src.startsWith('/')) {
27
+ return `${mountPath}${src}`.slice(1);
28
+ }
29
+ return src;
30
+ }
31
+
32
+ export function isRemote(normalizedSrc: string): boolean {
33
+ return normalizedSrc.startsWith('http://') || normalizedSrc.startsWith('https://');
34
+ }
35
+
36
+ /**
37
+ * Build the on-demand Cloudflare Image Resizing URL (`/cdn-cgi/image/...`) for a
38
+ * local asset. Remote images and SVGs, and requests with nothing to transform,
39
+ * are returned as the plain asset URL.
40
+ *
41
+ * When the caller pins no `format`, default to `auto` so Cloudflare negotiates
42
+ * WebP/AVIF (via the Accept header) instead of serving the heavier source
43
+ * format. An explicit `format` is honored as-is.
44
+ */
45
+ export function buildImageUrl(
46
+ normalizedSrc: string,
47
+ options: ImageUrlOptions,
48
+ deployUrl: string,
49
+ isSvg: boolean,
50
+ ): string {
51
+ // Remote images are served as-is, never routed through Cloudflare resizing:
52
+ // our zone does not optimize external images, and re-optimizing Webflow-hosted
53
+ // images (cdn.website-files.com) would double-bill bandwidth (the origin zone
54
+ // for the full image plus the cosmic zone for the resized one). Astro hands
55
+ // http(s) srcs straight through.
56
+ if (isRemote(normalizedSrc)) {
57
+ return normalizedSrc;
58
+ }
59
+
60
+ const params: string[] = [];
61
+ for (const key of ['width', 'height', 'quality'] as const) {
62
+ const value = options[key];
63
+ if (value) {
64
+ params.push(`${key}=${value}`);
65
+ }
66
+ }
67
+
68
+ // Only route through /cdn-cgi/image when there is something to transform. An
69
+ // explicit format alone still counts (e.g. `<Image format="webp" />`).
70
+ const transforming = params.length > 0 || Boolean(options.format);
71
+ if (isSvg || !transforming) {
72
+ return `${deployUrl}/${normalizedSrc}`;
73
+ }
74
+
75
+ params.push(`format=${options.format || 'auto'}`);
76
+ return `${deployUrl}/cdn-cgi/image/${params.join(',')}/${normalizedSrc}`;
77
+ }
78
+
79
+ export type SrcSetWidth = { width: number; height?: number; descriptor: string };
80
+
81
+ /**
82
+ * Compute the responsive variants Astro's `<Image>` asked for, mirroring
83
+ * Astro's own baseService: `densities` yield `Nx` descriptors, `widths` yield
84
+ * `Nw` descriptors. Each width's height is derived from the target aspect ratio.
85
+ * Variants are de-duplicated and kept within `maxWidth` (the source's intrinsic
86
+ * width, when known): `widths` above it are clamped, and `densities` that would
87
+ * resolve above it are dropped (matching Astro, which never upscales). Returns
88
+ * `[]` when no responsive variants were requested, so the loader can omit
89
+ * `srcset` entirely.
90
+ */
91
+ export function computeSrcSetWidths(
92
+ options: { widths?: number[]; densities?: Array<number | string> },
93
+ targetWidth: number | undefined,
94
+ targetHeight: number | undefined,
95
+ maxWidth?: number,
96
+ ): SrcSetWidth[] {
97
+ if (!targetWidth) {
98
+ return [];
99
+ }
100
+
101
+ const aspectRatio = targetHeight ? targetWidth / targetHeight : undefined;
102
+ const heightFor = (w: number) => (aspectRatio ? Math.round(w / aspectRatio) : undefined);
103
+
104
+ if (options.densities?.length) {
105
+ const seen = new Set<number>();
106
+ const result: SrcSetWidth[] = [];
107
+ for (const d of options.densities) {
108
+ const density = typeof d === 'string' ? parseFloat(d) : d;
109
+ const width = Math.round(targetWidth * density);
110
+ // Drop densities that would upscale past the source's intrinsic width:
111
+ // Astro's baseService ignores them rather than clamping, so an `Nx`
112
+ // descriptor never ends up pointing at a smaller image.
113
+ if (maxWidth && width > maxWidth) {
114
+ continue;
115
+ }
116
+ if (seen.has(width)) {
117
+ continue;
118
+ }
119
+ seen.add(width);
120
+ result.push({ width, height: heightFor(width), descriptor: `${density}x` });
121
+ }
122
+ return result;
123
+ }
124
+
125
+ if (options.widths?.length) {
126
+ const seen = new Set<number>();
127
+ const result: SrcSetWidth[] = [];
128
+ for (const raw of options.widths) {
129
+ const width = maxWidth ? Math.min(raw, maxWidth) : raw;
130
+ if (seen.has(width)) {
131
+ continue;
132
+ }
133
+ seen.add(width);
134
+ result.push({ width, height: heightFor(width), descriptor: `${width}w` });
135
+ }
136
+ return result;
137
+ }
138
+
139
+ return [];
140
+ }
@@ -106,7 +106,7 @@ export declare abstract class FrameworkBuilder {
106
106
  * Subclasses override to point at the correct npm package (`next`, `astro`,
107
107
  * `vite`). The default returns undefined — when that happens the producer
108
108
  * omits `framework_version` from webflow.json (the field is optional under
109
- * the deploy contract). CLD-1785.
109
+ * the deploy contract).
110
110
  */
111
111
  getFrameworkVersion(): string | undefined;
112
112
  /** Check if a dependency exists in package.json (deps or devDeps). */
@@ -120,7 +120,7 @@ class FrameworkBuilder {
120
120
  * Subclasses override to point at the correct npm package (`next`, `astro`,
121
121
  * `vite`). The default returns undefined — when that happens the producer
122
122
  * omits `framework_version` from webflow.json (the field is optional under
123
- * the deploy contract). CLD-1785.
123
+ * the deploy contract).
124
124
  */
125
125
  getFrameworkVersion() {
126
126
  return undefined;
@@ -48,6 +48,29 @@ export declare const RUNTIME_BUILD_INDICATORS: string[];
48
48
  * static assets — so it must not be inferred as static.
49
49
  */
50
50
  export declare const SERVER_ENTRYPOINT_FILES: string[];
51
+ /**
52
+ * Evaluate repo-relative file paths for build/runtime/server indicators,
53
+ * returning matching paths in input order.
54
+ *
55
+ * This helper is filesystem-free so hosts that only have a remote file listing
56
+ * (for example a GitHub recursive tree result) can reuse exactly the same
57
+ * indicator semantics as the local filesystem scanner.
58
+ *
59
+ * Input contract:
60
+ * - `paths` must represent regular file paths only (blob/file entries).
61
+ * - Callers must pre-filter non-file items (directories, submodules, symlinks).
62
+ * For a GitHub recursive tree this means keeping only `type === 'blob'` with
63
+ * `mode !== '120000'` (symlink); submodules arrive as `type === 'commit'`.
64
+ * The local filesystem scanner skips symlinks, so a caller that keeps them
65
+ * would diverge from it.
66
+ * - Exclusion applies to ancestor directory segments only; the final basename
67
+ * is always considered as an indicator candidate.
68
+ * - Leading/duplicate slashes and `.` segments are normalized for matching
69
+ * only. Matches are returned with the caller's original spelling
70
+ * (`./api/server.py` in, `./api/server.py` out), so callers that key off the
71
+ * returned paths must not assume they are canonicalized.
72
+ */
73
+ export declare function findRuntimeBuildIndicatorsInPaths(paths: string[]): string[];
51
74
  /**
52
75
  * Scan the **published tree** (not just the root) for build/runtime/server
53
76
  * indicators, returning their repo-relative paths.
@@ -1 +1 @@
1
- {"version":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