@astrojs/cloudflare 8.1.0 → 9.0.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.
@@ -26,7 +26,7 @@ export function createExports(manifest) {
26
26
  caches: caches,
27
27
  },
28
28
  };
29
- const response = await app.render(request, routeData, locals);
29
+ const response = await app.render(request, { routeData, locals });
30
30
  if (app.setCookieHeaders) {
31
31
  for (const setCookieHeader of app.setCookieHeaders(response)) {
32
32
  response.headers.append('Set-Cookie', setCookieHeader);
@@ -28,7 +28,7 @@ export function createExports(manifest) {
28
28
  caches: caches,
29
29
  },
30
30
  };
31
- const response = await app.render(request, routeData, locals);
31
+ const response = await app.render(request, { routeData, locals });
32
32
  if (app.setCookieHeaders) {
33
33
  for (const setCookieHeader of app.setCookieHeaders(response)) {
34
34
  response.headers.append('Set-Cookie', setCookieHeader);
package/dist/index.js CHANGED
@@ -417,21 +417,39 @@ export default function createIntegration(args) {
417
417
  include: ['/*'],
418
418
  exclude: deduplicatePatterns(staticPathList.concat(args?.routes?.exclude ?? [])),
419
419
  };
420
- const includeStrategyLength = includeStrategy
421
- ? includeStrategy.include.length + includeStrategy.exclude.length
422
- : Infinity;
423
- const excludeStrategyLength = excludeStrategy
424
- ? excludeStrategy.include.length + excludeStrategy.exclude.length
425
- : Infinity;
426
- const winningStrategy = notFoundIsSSR
427
- ? excludeStrategy
428
- : includeStrategyLength <= excludeStrategyLength
429
- ? includeStrategy
430
- : excludeStrategy;
431
- await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
432
- version: 1,
433
- ...winningStrategy,
434
- }, null, 2));
420
+ switch (args?.routes?.strategy) {
421
+ case 'include':
422
+ await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
423
+ version: 1,
424
+ ...includeStrategy,
425
+ }, null, 2));
426
+ break;
427
+ case 'exclude':
428
+ await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
429
+ version: 1,
430
+ ...excludeStrategy,
431
+ }, null, 2));
432
+ break;
433
+ default:
434
+ {
435
+ const includeStrategyLength = includeStrategy
436
+ ? includeStrategy.include.length + includeStrategy.exclude.length
437
+ : Infinity;
438
+ const excludeStrategyLength = excludeStrategy
439
+ ? excludeStrategy.include.length + excludeStrategy.exclude.length
440
+ : Infinity;
441
+ const winningStrategy = notFoundIsSSR
442
+ ? excludeStrategy
443
+ : includeStrategyLength <= excludeStrategyLength
444
+ ? includeStrategy
445
+ : excludeStrategy;
446
+ await fs.promises.writeFile(new URL('./_routes.json', _config.outDir), JSON.stringify({
447
+ version: 1,
448
+ ...winningStrategy,
449
+ }, null, 2));
450
+ }
451
+ break;
452
+ }
435
453
  }
436
454
  },
437
455
  },
@@ -9,15 +9,17 @@ export function deduplicatePatterns(patterns) {
9
9
  const openPatterns = [];
10
10
  // A value in the set may only occur once; it is unique in the set's collection.
11
11
  // ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
12
- return [...new Set(patterns)]
12
+ const uniquePatterns = [...new Set(patterns)];
13
+ for (const pattern of uniquePatterns) {
14
+ if (pattern.endsWith('*')) {
15
+ openPatterns.push(new RegExp(`^${pattern.replace(/(\*\/)*\*$/g, '[^*\n]*$')}`));
16
+ }
17
+ }
18
+ return uniquePatterns
13
19
  .sort((a, b) => a.length - b.length)
14
20
  .filter((pattern) => {
15
- if (openPatterns.some((p) => p.test(pattern))) {
21
+ if (openPatterns.some((p) => p.test(pattern)))
16
22
  return false;
17
- }
18
- if (pattern.endsWith('*')) {
19
- openPatterns.push(new RegExp(`^${pattern.replace(/(\*\/)*\*$/g, '.*')}`));
20
- }
21
23
  return true;
22
24
  });
23
25
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "//comment": "test changeset-bot",
3
3
  "name": "@astrojs/cloudflare",
4
4
  "description": "Deploy your site to Cloudflare Workers/Pages",
5
- "version": "8.1.0",
5
+ "version": "9.0.0",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "author": "withastro",
@@ -40,14 +40,14 @@
40
40
  "tiny-glob": "^0.2.9"
41
41
  },
42
42
  "peerDependencies": {
43
- "astro": "^3.0.0 || ^4.0.0"
43
+ "astro": "^4.2.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "execa": "^8.0.1",
47
47
  "fast-glob": "^3.3.1",
48
48
  "@types/iarna__toml": "^2.0.2",
49
49
  "strip-ansi": "^7.1.0",
50
- "astro": "^4.0.0",
50
+ "astro": "^4.2.0",
51
51
  "chai": "^4.3.10",
52
52
  "cheerio": "1.0.0-rc.12",
53
53
  "mocha": "^10.2.0",