@astrojs/cloudflare 13.1.9 → 13.2.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.
|
@@ -87,7 +87,7 @@ function serverStart({
|
|
|
87
87
|
host,
|
|
88
88
|
base
|
|
89
89
|
}) {
|
|
90
|
-
const version = "13.
|
|
90
|
+
const version = "13.2.0";
|
|
91
91
|
const localPrefix = `${colors.dim("\u2503")} Local `;
|
|
92
92
|
const networkPrefix = `${colors.dim("\u2503")} Network `;
|
|
93
93
|
const emptyPrefix = " ".repeat(11);
|
package/dist/prerenderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { preview } from "vite";
|
|
1
|
+
import { preview, createLogger } from "vite";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { mkdir } from "node:fs/promises";
|
|
4
4
|
import { cloudflare as cfVitePlugin } from "@cloudflare/vite-plugin";
|
|
@@ -23,6 +23,16 @@ function createCloudflarePrerenderer({
|
|
|
23
23
|
name: "@astrojs/cloudflare:prerenderer",
|
|
24
24
|
async setup() {
|
|
25
25
|
await mkdir(clientDir, { recursive: true });
|
|
26
|
+
const defaultLogger = createLogger("info");
|
|
27
|
+
const ansiRe = /\x1b\[[0-9;]*m/g;
|
|
28
|
+
const astroRequestLogRe = /^(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+\/__astro_/;
|
|
29
|
+
const customLogger = {
|
|
30
|
+
...defaultLogger,
|
|
31
|
+
info(msg, opts) {
|
|
32
|
+
if (astroRequestLogRe.test(msg.replace(ansiRe, ""))) return;
|
|
33
|
+
defaultLogger.info(msg, opts);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
26
36
|
previewServer = await preview({
|
|
27
37
|
configFile: false,
|
|
28
38
|
base,
|
|
@@ -31,7 +41,7 @@ function createCloudflarePrerenderer({
|
|
|
31
41
|
outDir: fileURLToPath(serverDir)
|
|
32
42
|
},
|
|
33
43
|
root: fileURLToPath(root),
|
|
34
|
-
|
|
44
|
+
customLogger,
|
|
35
45
|
preview: {
|
|
36
46
|
host: "localhost",
|
|
37
47
|
port: 0,
|
|
@@ -14,7 +14,10 @@ async function transform(rawUrl, images, assets) {
|
|
|
14
14
|
return new Response("Forbidden", { status: 403 });
|
|
15
15
|
}
|
|
16
16
|
const imageSrc = new URL(href, url.origin);
|
|
17
|
-
const content = await (isRemotePath(href) ? fetch(imageSrc) : assets.fetch(imageSrc));
|
|
17
|
+
const content = await (isRemotePath(href) ? fetch(imageSrc, { redirect: "manual" }) : assets.fetch(imageSrc));
|
|
18
|
+
if (content.status >= 300 && content.status < 400) {
|
|
19
|
+
return new Response("Not Found", { status: 404 });
|
|
20
|
+
}
|
|
18
21
|
if (!content.body) {
|
|
19
22
|
return new Response(null, { status: 404 });
|
|
20
23
|
}
|
package/dist/wrangler.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WorkerConfig } from '@cloudflare/vite-plugin';
|
|
2
2
|
export declare const DEFAULT_SESSION_KV_BINDING_NAME = "SESSION";
|
|
3
3
|
export declare const DEFAULT_IMAGES_BINDING_NAME = "IMAGES";
|
|
4
4
|
export declare const DEFAULT_ASSETS_BINDING_NAME = "ASSETS";
|
|
5
5
|
interface CloudflareConfigOptions {
|
|
6
|
-
sessionKVBindingName
|
|
6
|
+
sessionKVBindingName?: string | undefined;
|
|
7
7
|
needsSessionKVBinding?: boolean;
|
|
8
|
-
imagesBindingName
|
|
8
|
+
imagesBindingName?: string | false | undefined;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Returns a config customizer that sets up the Astro Cloudflare defaults.
|
|
12
12
|
* Sets the main entrypoint and adds bindings for auto-provisioning.
|
|
13
13
|
*/
|
|
14
|
-
export declare function cloudflareConfigCustomizer(options
|
|
14
|
+
export declare function cloudflareConfigCustomizer(options?: CloudflareConfigOptions): (config: Partial<WorkerConfig>) => Partial<WorkerConfig>;
|
|
15
15
|
export {};
|
package/dist/wrangler.js
CHANGED
|
@@ -5,27 +5,34 @@ function cloudflareConfigCustomizer(options) {
|
|
|
5
5
|
const sessionKVBindingName = options?.sessionKVBindingName ?? DEFAULT_SESSION_KV_BINDING_NAME;
|
|
6
6
|
const needsSessionKVBinding = options?.needsSessionKVBinding ?? true;
|
|
7
7
|
const imagesBindingName = options?.imagesBindingName === false ? void 0 : options?.imagesBindingName ?? DEFAULT_IMAGES_BINDING_NAME;
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const customizer = (config) => {
|
|
9
|
+
const getNonInheritableBindings = (nonInheritableConfig) => {
|
|
10
|
+
const hasSessionBinding = nonInheritableConfig?.kv_namespaces?.some(
|
|
11
|
+
(kv) => kv.binding === sessionKVBindingName
|
|
12
|
+
);
|
|
13
|
+
const hasImagesBinding = nonInheritableConfig?.images?.binding !== void 0;
|
|
14
|
+
return {
|
|
15
|
+
kv_namespaces: !needsSessionKVBinding || hasSessionBinding ? void 0 : [
|
|
16
|
+
{
|
|
17
|
+
binding: sessionKVBindingName
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
images: hasImagesBinding || !imagesBindingName ? void 0 : {
|
|
21
|
+
binding: imagesBindingName
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
13
25
|
const hasAssetsBinding = config.assets?.binding !== void 0;
|
|
14
26
|
return {
|
|
27
|
+
...getNonInheritableBindings(config),
|
|
15
28
|
main: config.main ?? "@astrojs/cloudflare/entrypoints/server",
|
|
16
|
-
kv_namespaces: !needsSessionKVBinding || hasSessionBinding ? void 0 : [
|
|
17
|
-
{
|
|
18
|
-
binding: sessionKVBindingName
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
images: hasImagesBinding || !imagesBindingName ? void 0 : {
|
|
22
|
-
binding: imagesBindingName
|
|
23
|
-
},
|
|
24
29
|
assets: hasAssetsBinding ? void 0 : {
|
|
25
30
|
binding: DEFAULT_ASSETS_BINDING_NAME
|
|
26
|
-
}
|
|
31
|
+
},
|
|
32
|
+
previews: getNonInheritableBindings(config.previews)
|
|
27
33
|
};
|
|
28
34
|
};
|
|
35
|
+
return customizer;
|
|
29
36
|
}
|
|
30
37
|
export {
|
|
31
38
|
DEFAULT_ASSETS_BINDING_NAME,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to Cloudflare Workers",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
"types.d.ts"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@cloudflare/vite-plugin": "^1.
|
|
38
|
+
"@cloudflare/vite-plugin": "^1.32.3",
|
|
39
39
|
"piccolore": "^0.1.3",
|
|
40
40
|
"tinyglobby": "^0.2.15",
|
|
41
|
-
"vite": "^7.3.
|
|
42
|
-
"@astrojs/internal-helpers": "0.
|
|
41
|
+
"vite": "^7.3.2",
|
|
42
|
+
"@astrojs/internal-helpers": "0.9.0",
|
|
43
43
|
"@astrojs/underscore-redirects": "1.0.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"astro": "^6.0.0",
|
|
47
|
-
"wrangler": "^4.
|
|
47
|
+
"wrangler": "^4.83.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@cloudflare/workers-types": "^4.20260228.0",
|
|
51
51
|
"@types/node": "^25.2.2",
|
|
52
52
|
"cheerio": "1.2.0",
|
|
53
53
|
"devalue": "^5.6.3",
|
|
54
|
-
"astro": "6.1.
|
|
54
|
+
"astro": "6.1.9",
|
|
55
55
|
"astro-scripts": "0.0.14"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
62
62
|
"build": "astro-scripts build \"src/**/*.ts\" --clean-dts && tsc",
|
|
63
63
|
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
64
|
-
"test": "astro-scripts test --force-exit \"test/**/*.test.
|
|
64
|
+
"test": "astro-scripts test --force-exit \"test/**/*.test.ts\"",
|
|
65
|
+
"typecheck:tests": "tsc --build tsconfig.test.json"
|
|
65
66
|
}
|
|
66
67
|
}
|