@replohq/canopy-sdk 0.7.1 → 0.8.0
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.
- package/next/image-loader.js +14 -0
- package/next/image-loader.js.map +2 -2
- package/package.json +1 -1
package/next/image-loader.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const REPLO_IMAGE_CDN = "https://assets.replocdn.com";
|
|
1
2
|
function cloudflareLoader({
|
|
2
3
|
src,
|
|
3
4
|
width,
|
|
@@ -7,6 +8,19 @@ function cloudflareLoader({
|
|
|
7
8
|
return src;
|
|
8
9
|
}
|
|
9
10
|
const params = [`width=${width}`, `quality=${quality ?? 75}`, "format=auto"];
|
|
11
|
+
if (/^https:\/\//i.test(src)) {
|
|
12
|
+
let hostname;
|
|
13
|
+
try {
|
|
14
|
+
hostname = new URL(src).hostname;
|
|
15
|
+
} catch {
|
|
16
|
+
return src;
|
|
17
|
+
}
|
|
18
|
+
if (/(^|\.)replocdn\.com$/i.test(hostname)) {
|
|
19
|
+
return `/cdn-cgi/image/${params.join(",")}/${src}`;
|
|
20
|
+
}
|
|
21
|
+
const passthroughUrl = `${REPLO_IMAGE_CDN}/images/external?url=${encodeURIComponent(src)}`;
|
|
22
|
+
return `${REPLO_IMAGE_CDN}/cdn-cgi/image/${[...params, "onerror=redirect"].join(",")}/${passthroughUrl}`;
|
|
23
|
+
}
|
|
10
24
|
const normalizedSrc = src.startsWith("/") ? src.slice(1) : src;
|
|
11
25
|
return `/cdn-cgi/image/${params.join(",")}/${normalizedSrc}`;
|
|
12
26
|
}
|
package/next/image-loader.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../next/image-loader.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ImageLoaderProps } from \"next/image\";\n\nexport default function cloudflareLoader({\n src,\n width,\n quality,\n}: ImageLoaderProps): string {\n // NOTE (Cole, 2026-05-15, REPL-27122): /cdn-cgi/image/ only exists on\n // Cloudflare's edge. During `next dev` in the sandbox the preview is served\n // through the Daytona proxy, so rewritten URLs would 404.\n if (process.env.NODE_ENV === \"development\") {\n return src;\n }\n\n const params = [`width=${width}`, `quality=${quality ?? 75}`, \"format=auto\"];\n const normalizedSrc = src.startsWith(\"/\") ? src.slice(1) : src;\n return `/cdn-cgi/image/${params.join(\",\")}/${normalizedSrc}`;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { ImageLoaderProps } from \"next/image\";\n\nconst REPLO_IMAGE_CDN = \"https://assets.replocdn.com\";\n\nexport default function cloudflareLoader({\n src,\n width,\n quality,\n}: ImageLoaderProps): string {\n // NOTE (Cole, 2026-05-15, REPL-27122): /cdn-cgi/image/ only exists on\n // Cloudflare's edge. During `next dev` in the sandbox the preview is served\n // through the Daytona proxy, so rewritten URLs would 404.\n if (process.env.NODE_ENV === \"development\") {\n return src;\n }\n\n const params = [`width=${width}`, `quality=${quality ?? 75}`, \"format=auto\"];\n\n if (/^https:\\/\\//i.test(src)) {\n let hostname: string;\n try {\n hostname = new URL(src).hostname;\n } catch {\n return src;\n }\n if (/(^|\\.)replocdn\\.com$/i.test(hostname)) {\n return `/cdn-cgi/image/${params.join(\",\")}/${src}`;\n }\n // NOTE (Cole, 2026-07-02, REPL-28680): commerce CDNs (Shopify, BigCommerce)\n // reject the Cloudflare resizer's own fetches, so third-party images resize\n // on the replocdn zone from our passthrough endpoint, which re-fetches them\n // with an ordinary request. The replocdn zone only resizes same-zone\n // sources, so the passthrough URL must stay on assets.replocdn.com.\n // onerror=redirect serves the unoptimized original if the transform fails.\n const passthroughUrl = `${REPLO_IMAGE_CDN}/images/external?url=${encodeURIComponent(src)}`;\n return `${REPLO_IMAGE_CDN}/cdn-cgi/image/${[...params, \"onerror=redirect\"].join(\",\")}/${passthroughUrl}`;\n }\n\n const normalizedSrc = src.startsWith(\"/\") ? src.slice(1) : src;\n return `/cdn-cgi/image/${params.join(\",\")}/${normalizedSrc}`;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,kBAAkB;AAET,SAAR,iBAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAI3B,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,CAAC,SAAS,KAAK,IAAI,WAAW,WAAW,EAAE,IAAI,aAAa;AAE3E,MAAI,eAAe,KAAK,GAAG,GAAG;AAC5B,QAAI;AACJ,QAAI;AACF,iBAAW,IAAI,IAAI,GAAG,EAAE;AAAA,IAC1B,QAAQ;AACN,aAAO;AAAA,IACT;AACA,QAAI,wBAAwB,KAAK,QAAQ,GAAG;AAC1C,aAAO,kBAAkB,OAAO,KAAK,GAAG,CAAC,IAAI,GAAG;AAAA,IAClD;AAOA,UAAM,iBAAiB,GAAG,eAAe,wBAAwB,mBAAmB,GAAG,CAAC;AACxF,WAAO,GAAG,eAAe,kBAAkB,CAAC,GAAG,QAAQ,kBAAkB,EAAE,KAAK,GAAG,CAAC,IAAI,cAAc;AAAA,EACxG;AAEA,QAAM,gBAAgB,IAAI,WAAW,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI;AAC3D,SAAO,kBAAkB,OAAO,KAAK,GAAG,CAAC,IAAI,aAAa;AAC5D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED