@astrojs/cloudflare 11.0.4 → 11.1.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.
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { writeFile } from 'node:fs/promises';
|
|
3
|
-
import
|
|
3
|
+
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { prependForwardSlash, removeLeadingForwardSlash, removeTrailingForwardSlash, } from '@astrojs/internal-helpers/path';
|
|
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) {
|
|
@@ -95,6 +96,28 @@ class PathTrie {
|
|
|
95
96
|
this.dfs(childNode, [...path, segment], allPaths);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The reduce function is used to remove unnecessary paths from the trie.
|
|
101
|
+
* It receives a trie node to compare with the current node.
|
|
102
|
+
*/
|
|
103
|
+
reduce(compNode, node) {
|
|
104
|
+
if (node.hasWildcardChild || compNode.hasWildcardChild)
|
|
105
|
+
return;
|
|
106
|
+
for (const [segment, childNode] of node.children) {
|
|
107
|
+
if (childNode.children.size === 0)
|
|
108
|
+
continue;
|
|
109
|
+
const compChildNode = compNode.children.get(segment);
|
|
110
|
+
if (compChildNode === undefined) {
|
|
111
|
+
childNode.hasWildcardChild = true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
this.reduce(compChildNode, childNode);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
reduceAllPaths(compTrie) {
|
|
118
|
+
this.reduce(compTrie.root, this.root);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
98
121
|
getAllPaths() {
|
|
99
122
|
const allPaths = [];
|
|
100
123
|
this.dfs(this.root, [], allPaths);
|
|
@@ -128,7 +151,7 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
128
151
|
continue;
|
|
129
152
|
const staticPath = staticFile;
|
|
130
153
|
const segments = removeLeadingForwardSlash(staticPath)
|
|
131
|
-
.split(
|
|
154
|
+
.split(path.sep)
|
|
132
155
|
.filter(Boolean)
|
|
133
156
|
.map((s) => {
|
|
134
157
|
return getParts(s);
|
|
@@ -169,7 +192,7 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
169
192
|
if (page.pathname === '404')
|
|
170
193
|
hasPrerendered404 = true;
|
|
171
194
|
const pageSegments = removeLeadingForwardSlash(page.pathname)
|
|
172
|
-
.split(posix.sep)
|
|
195
|
+
.split(path.posix.sep)
|
|
173
196
|
.filter(Boolean)
|
|
174
197
|
.map((s) => {
|
|
175
198
|
return getParts(s);
|
|
@@ -180,7 +203,6 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
180
203
|
for (const includePath of includePaths) {
|
|
181
204
|
includeTrie.insert(includePath);
|
|
182
205
|
}
|
|
183
|
-
const [deduplicatedIncludePaths, includedPathsHaveWildcard] = includeTrie.getAllPaths();
|
|
184
206
|
const excludeTrie = new PathTrie();
|
|
185
207
|
for (const excludePath of excludePaths) {
|
|
186
208
|
/**
|
|
@@ -192,7 +214,12 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
192
214
|
continue;
|
|
193
215
|
excludeTrie.insert(excludePath);
|
|
194
216
|
}
|
|
195
|
-
const [
|
|
217
|
+
const [deduplicatedIncludePaths, includedPathsHaveWildcard] = includeTrie
|
|
218
|
+
.reduceAllPaths(excludeTrie)
|
|
219
|
+
.getAllPaths();
|
|
220
|
+
const [deduplicatedExcludePaths, _excludedPathsHaveWildcard] = excludeTrie
|
|
221
|
+
.reduceAllPaths(includeTrie)
|
|
222
|
+
.getAllPaths();
|
|
196
223
|
/**
|
|
197
224
|
* Cloudflare allows no more than 100 include/exclude rules combined
|
|
198
225
|
* https://developers.cloudflare.com/pages/functions/routing/#limits
|
|
@@ -1,5 +1,5 @@
|
|
|
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
4
|
domains: string[];
|
|
5
5
|
remotePatterns: {
|
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": "11.0
|
|
4
|
+
"version": "11.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -31,26 +31,26 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@astrojs/internal-helpers": "0.4.1",
|
|
33
33
|
"@astrojs/underscore-redirects": "^0.3.4",
|
|
34
|
-
"@cloudflare/workers-types": "^4.
|
|
35
|
-
"esbuild": "^0.
|
|
34
|
+
"@cloudflare/workers-types": "^4.20240909.0",
|
|
35
|
+
"esbuild": "^0.21.5",
|
|
36
36
|
"estree-walker": "^3.0.3",
|
|
37
|
-
"magic-string": "^0.30.
|
|
38
|
-
"miniflare": "^3.
|
|
37
|
+
"magic-string": "^0.30.11",
|
|
38
|
+
"miniflare": "^3.20240909.2",
|
|
39
39
|
"tiny-glob": "^0.2.9",
|
|
40
|
-
"wrangler": "^3.
|
|
41
|
-
"@inox-tools/astro-when": "^0.2.
|
|
40
|
+
"wrangler": "^3.78.3",
|
|
41
|
+
"@inox-tools/astro-when": "^0.2.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"astro": "^4.10.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"astro": "^4.
|
|
48
|
-
"cheerio": "1.0.0
|
|
47
|
+
"astro": "^4.15.6",
|
|
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.3",
|
|
52
52
|
"strip-ansi": "^7.1.0",
|
|
53
|
-
"vite": "^5.
|
|
53
|
+
"vite": "^5.4.6",
|
|
54
54
|
"astro-scripts": "0.0.14",
|
|
55
55
|
"@astrojs/test-utils": "0.0.1"
|
|
56
56
|
},
|