@astrojs/cloudflare 11.0.4 → 12.0.0-beta.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/dist/entrypoints/image-service.js +1 -3
- package/dist/entrypoints/middleware.js +2 -0
- package/dist/index.js +7 -11
- package/dist/utils/generate-routes-json.d.ts +3 -3
- package/dist/utils/generate-routes-json.js +1 -0
- package/dist/utils/image-config.d.ts +18 -3
- package/dist/utils/image-config.js +4 -3
- package/package.json +15 -15
|
@@ -26,9 +26,7 @@ const service = {
|
|
|
26
26
|
// If it's not an imported image, nor is it allowed using the current domains or remote patterns, we'll just return the original URL
|
|
27
27
|
return options.src;
|
|
28
28
|
}
|
|
29
|
-
const imageEndpoint = joinPaths(
|
|
30
|
-
// @ts-expect-error - Property 'env' does not exist on type 'ImportMeta'.ts(2339)
|
|
31
|
-
import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
|
|
29
|
+
const imageEndpoint = joinPaths(import.meta.env.BASE_URL, '/cdn-cgi/image', resizingParams.join(','), imageSource);
|
|
32
30
|
return imageEndpoint;
|
|
33
31
|
},
|
|
34
32
|
};
|
|
@@ -6,7 +6,9 @@ const middlewares = {
|
|
|
6
6
|
[When.DevServer]: (_, next) => next(),
|
|
7
7
|
[When.Server]: (_, next) => next(),
|
|
8
8
|
[When.Prerender]: (ctx, next) => {
|
|
9
|
+
// @ts-expect-error
|
|
9
10
|
if (ctx.locals.runtime === undefined) {
|
|
11
|
+
// @ts-expect-error
|
|
10
12
|
ctx.locals.runtime = {
|
|
11
13
|
env: process.env,
|
|
12
14
|
};
|
package/dist/index.js
CHANGED
|
@@ -15,8 +15,8 @@ function wrapWithSlashes(path) {
|
|
|
15
15
|
}
|
|
16
16
|
function setProcessEnv(config, env) {
|
|
17
17
|
const getEnv = createGetEnv(env);
|
|
18
|
-
if (config.
|
|
19
|
-
for (const key of Object.keys(config.
|
|
18
|
+
if (config.env?.schema) {
|
|
19
|
+
for (const key of Object.keys(config.env.schema)) {
|
|
20
20
|
const value = getEnv(key);
|
|
21
21
|
if (value !== undefined) {
|
|
22
22
|
process.env[key] = value;
|
|
@@ -62,9 +62,9 @@ export default function createIntegration(args) {
|
|
|
62
62
|
order: 'pre',
|
|
63
63
|
});
|
|
64
64
|
},
|
|
65
|
-
'astro:config:done': ({ setAdapter, config }) => {
|
|
66
|
-
if (
|
|
67
|
-
|
|
65
|
+
'astro:config:done': ({ setAdapter, config, buildOutput, logger }) => {
|
|
66
|
+
if (buildOutput === 'static') {
|
|
67
|
+
logger.warn('[@astrojs/cloudflare] This adapter is intended to be used with server rendered pages, which this project does not contain any of. As such, this adapter is unnecessary.');
|
|
68
68
|
}
|
|
69
69
|
_config = config;
|
|
70
70
|
setAdapter({
|
|
@@ -72,19 +72,15 @@ export default function createIntegration(args) {
|
|
|
72
72
|
serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.js',
|
|
73
73
|
exports: ['default'],
|
|
74
74
|
adapterFeatures: {
|
|
75
|
-
functionPerRoute: false,
|
|
76
75
|
edgeMiddleware: false,
|
|
76
|
+
buildOutput: 'server',
|
|
77
77
|
},
|
|
78
78
|
supportedAstroFeatures: {
|
|
79
79
|
serverOutput: 'stable',
|
|
80
80
|
hybridOutput: 'stable',
|
|
81
81
|
staticOutput: 'unsupported',
|
|
82
82
|
i18nDomains: 'experimental',
|
|
83
|
-
|
|
84
|
-
supportKind: 'stable',
|
|
85
|
-
isSharpCompatible: false,
|
|
86
|
-
isSquooshCompatible: false,
|
|
87
|
-
},
|
|
83
|
+
sharpImageService: 'limited',
|
|
88
84
|
envGetSecret: 'experimental',
|
|
89
85
|
},
|
|
90
86
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AstroConfig, AstroIntegrationLogger,
|
|
1
|
+
import type { AstroConfig, AstroIntegrationLogger, IntegrationRouteData, RoutePart } from 'astro';
|
|
2
2
|
export declare function getParts(part: string): RoutePart[];
|
|
3
|
-
export declare function createRoutesFile(_config: AstroConfig, logger: AstroIntegrationLogger, routes:
|
|
3
|
+
export declare function createRoutesFile(_config: AstroConfig, logger: AstroIntegrationLogger, routes: IntegrationRouteData[], pages: {
|
|
4
4
|
pathname: string;
|
|
5
|
-
}[], redirects:
|
|
5
|
+
}[], redirects: IntegrationRouteData['segments'][], includeExtends: {
|
|
6
6
|
pattern: string;
|
|
7
7
|
}[] | undefined, excludeExtends: {
|
|
8
8
|
pattern: string;
|
|
@@ -6,6 +6,7 @@ import { prependForwardSlash, removeLeadingForwardSlash, removeTrailingForwardSl
|
|
|
6
6
|
import glob from 'tiny-glob';
|
|
7
7
|
// Copied from https://github.com/withastro/astro/blob/3776ecf0aa9e08a992d3ae76e90682fd04093721/packages/astro/src/core/routing/manifest/create.ts#L45-L70
|
|
8
8
|
// We're not sure how to improve this regex yet
|
|
9
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
9
10
|
const ROUTE_DYNAMIC_SPLIT = /\[(.+?\(.+?\)|.+?)\]/;
|
|
10
11
|
const ROUTE_SPREAD = /^\.{3}.+$/;
|
|
11
12
|
export function getParts(part) {
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import type { AstroConfig, AstroIntegrationLogger } from 'astro';
|
|
2
|
-
export declare function setImageConfig(service: string, config: AstroConfig['image'], command: '
|
|
1
|
+
import type { AstroConfig, AstroIntegrationLogger, HookParameters } from 'astro';
|
|
2
|
+
export declare function setImageConfig(service: string, config: AstroConfig['image'], command: HookParameters<'astro:config:setup'>['command'], logger: AstroIntegrationLogger): {
|
|
3
3
|
service: import("astro").ImageServiceConfig<Record<string, any>>;
|
|
4
|
+
endpoint: {
|
|
5
|
+
route: string;
|
|
6
|
+
entrypoint?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
domains: string[];
|
|
9
|
+
remotePatterns: {
|
|
10
|
+
port?: string | undefined;
|
|
11
|
+
protocol?: string | undefined;
|
|
12
|
+
hostname?: string | undefined;
|
|
13
|
+
pathname?: string | undefined;
|
|
14
|
+
}[];
|
|
15
|
+
} | {
|
|
16
|
+
service: import("astro").ImageServiceConfig<Record<string, any>>;
|
|
17
|
+
endpoint: {
|
|
18
|
+
entrypoint: string | undefined;
|
|
19
|
+
};
|
|
4
20
|
domains: string[];
|
|
5
21
|
remotePatterns: {
|
|
6
22
|
port?: string | undefined;
|
|
@@ -8,5 +24,4 @@ export declare function setImageConfig(service: string, config: AstroConfig['ima
|
|
|
8
24
|
hostname?: string | undefined;
|
|
9
25
|
pathname?: string | undefined;
|
|
10
26
|
}[];
|
|
11
|
-
endpoint?: string | undefined;
|
|
12
27
|
};
|
|
@@ -14,13 +14,14 @@ export function setImageConfig(service, config, command, logger) {
|
|
|
14
14
|
return {
|
|
15
15
|
...config,
|
|
16
16
|
service: sharpImageService(),
|
|
17
|
-
endpoint:
|
|
17
|
+
endpoint: {
|
|
18
|
+
entrypoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
|
|
19
|
+
},
|
|
18
20
|
};
|
|
19
21
|
case 'custom':
|
|
20
22
|
return { ...config };
|
|
21
23
|
default:
|
|
22
|
-
if (config.service.entrypoint === 'astro/assets/services/sharp'
|
|
23
|
-
config.service.entrypoint === 'astro/assets/services/squoosh') {
|
|
24
|
+
if (config.service.entrypoint === 'astro/assets/services/sharp') {
|
|
24
25
|
logger.warn(`The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`);
|
|
25
26
|
return { ...config, service: passthroughImageService() };
|
|
26
27
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to Cloudflare Workers/Pages",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "12.0.0-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -30,29 +30,29 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@astrojs/internal-helpers": "0.4.1",
|
|
33
|
-
"@astrojs/underscore-redirects": "^0.
|
|
34
|
-
"@cloudflare/workers-types": "^4.
|
|
35
|
-
"esbuild": "^0.
|
|
33
|
+
"@astrojs/underscore-redirects": "^0.4.0-alpha.0",
|
|
34
|
+
"@cloudflare/workers-types": "^4.20240903.0",
|
|
35
|
+
"esbuild": "^0.23.1",
|
|
36
36
|
"estree-walker": "^3.0.3",
|
|
37
|
-
"magic-string": "^0.30.
|
|
38
|
-
"miniflare": "^3.
|
|
37
|
+
"magic-string": "^0.30.11",
|
|
38
|
+
"miniflare": "^3.20240821.1",
|
|
39
39
|
"tiny-glob": "^0.2.9",
|
|
40
|
-
"wrangler": "^3.
|
|
41
|
-
"@inox-tools/astro-when": "^0.2.
|
|
40
|
+
"wrangler": "^3.75.0",
|
|
41
|
+
"@inox-tools/astro-when": "^0.2.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"astro": "^
|
|
44
|
+
"astro": "^5.0.0-alpha.8"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"astro": "^
|
|
48
|
-
"cheerio": "1.0.0
|
|
47
|
+
"astro": "^5.0.0-alpha.8",
|
|
48
|
+
"cheerio": "1.0.0",
|
|
49
49
|
"execa": "^8.0.1",
|
|
50
50
|
"fast-glob": "^3.3.2",
|
|
51
|
-
"rollup": "^4.
|
|
51
|
+
"rollup": "^4.21.2",
|
|
52
52
|
"strip-ansi": "^7.1.0",
|
|
53
|
-
"vite": "^5.3
|
|
54
|
-
"
|
|
55
|
-
"
|
|
53
|
+
"vite": "^5.4.3",
|
|
54
|
+
"@astrojs/test-utils": "0.0.1",
|
|
55
|
+
"astro-scripts": "0.0.14"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"provenance": true
|