astro 6.4.1 → 6.4.2

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,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.4.1";
3
+ version = "6.4.2";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
197
197
  logger.info("Content config changed");
198
198
  shouldClear = true;
199
199
  }
200
- if (previousAstroVersion && previousAstroVersion !== "6.4.1") {
200
+ if (previousAstroVersion && previousAstroVersion !== "6.4.2") {
201
201
  logger.info("Astro version changed");
202
202
  shouldClear = true;
203
203
  }
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
205
205
  logger.info("Clearing content store");
206
206
  this.#store.clearAll();
207
207
  }
208
- if ("6.4.1") {
209
- this.#store.metaStore().set("astro-version", "6.4.1");
208
+ if ("6.4.2") {
209
+ this.#store.metaStore().set("astro-version", "6.4.2");
210
210
  }
211
211
  if (currentConfigDigest) {
212
212
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -151,6 +151,10 @@ class BaseApp {
151
151
  return routeData;
152
152
  }
153
153
  if (routeData.prerender) {
154
+ if (routeData.params.length > 0) {
155
+ const allMatches = this.pipeline.matchAllRoutes(decodeURI(pathname));
156
+ return allMatches.find((r) => !r.prerender);
157
+ }
154
158
  return void 0;
155
159
  }
156
160
  return routeData;
@@ -117,6 +117,13 @@ export declare abstract class Pipeline {
117
117
  * routes or check public assets — use `BaseApp.match()` for that.
118
118
  */
119
119
  matchRoute(pathname: string): RouteData | undefined;
120
+ /**
121
+ * Returns all routes matching the given pathname, in priority order.
122
+ * Used when the first match cannot serve the request (e.g. a
123
+ * prerendered dynamic route that doesn't cover this specific path)
124
+ * and the caller needs to try subsequent matches.
125
+ */
126
+ matchAllRoutes(pathname: string): RouteData[];
120
127
  /**
121
128
  * Rebuilds the internal router after routes have been added or
122
129
  * removed (e.g. by the dev server on HMR).
@@ -123,6 +123,15 @@ class Pipeline {
123
123
  if (match.type !== "match") return void 0;
124
124
  return match.route;
125
125
  }
126
+ /**
127
+ * Returns all routes matching the given pathname, in priority order.
128
+ * Used when the first match cannot serve the request (e.g. a
129
+ * prerendered dynamic route that doesn't cover this specific path)
130
+ * and the caller needs to try subsequent matches.
131
+ */
132
+ matchAllRoutes(pathname) {
133
+ return this.#router.matchAll(pathname, { allowWithoutBase: true });
134
+ }
126
135
  /**
127
136
  * Rebuilds the internal router after routes have been added or
128
137
  * removed (e.g. by the dev server on HMR).
@@ -35,6 +35,7 @@ function warnDeprecatedMarkdownOptions(config) {
35
35
  }
36
36
  let didWarnAboutLegacyMarkdownPlugins = false;
37
37
  let didWarnAboutProcessorMismatch = false;
38
+ const migratedLegacyPluginCounts = /* @__PURE__ */ new WeakMap();
38
39
  async function coerceLegacyMarkdownPlugins(config) {
39
40
  const md = config?.markdown;
40
41
  if (!md) return;
@@ -48,18 +49,24 @@ async function coerceLegacyMarkdownPlugins(config) {
48
49
  const current = md.processor;
49
50
  if (!current || isUnifiedProcessor(current)) {
50
51
  const target = current ?? (md.processor = unified());
51
- target.options.remarkPlugins.push(...remarkPlugins);
52
- target.options.rehypePlugins.push(...rehypePlugins);
52
+ const counts = migratedLegacyPluginCounts.get(target.options) ?? { remark: 0, rehype: 0 };
53
+ if (remarkPlugins.length > counts.remark) {
54
+ target.options.remarkPlugins.push(...remarkPlugins.slice(counts.remark));
55
+ }
56
+ if (rehypePlugins.length > counts.rehype) {
57
+ target.options.rehypePlugins.push(...rehypePlugins.slice(counts.rehype));
58
+ }
53
59
  Object.assign(target.options.remarkRehype, remarkRehype);
60
+ migratedLegacyPluginCounts.set(target.options, {
61
+ remark: remarkPlugins.length,
62
+ rehype: rehypePlugins.length
63
+ });
54
64
  if (!didWarnAboutLegacyMarkdownPlugins) {
55
65
  didWarnAboutLegacyMarkdownPlugins = true;
56
66
  console.warn(
57
67
  "[astro] `markdown.remarkPlugins`, `markdown.rehypePlugins`, and `markdown.remarkRehype` are deprecated. Pass them to `unified({...})` from `@astrojs/markdown-remark` directly instead."
58
68
  );
59
69
  }
60
- delete md.remarkPlugins;
61
- delete md.rehypePlugins;
62
- delete md.remarkRehype;
63
70
  } else if (!didWarnAboutProcessorMismatch) {
64
71
  didWarnAboutProcessorMismatch = true;
65
72
  console.warn(
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.4.1";
1
+ const ASTRO_VERSION = "6.4.2";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
4
4
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
@@ -37,7 +37,7 @@ async function dev(inlineConfig) {
37
37
  await telemetry.record([]);
38
38
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
39
39
  const logger = restart.container.logger;
40
- const currentVersion = "6.4.1";
40
+ const currentVersion = "6.4.2";
41
41
  const isPrerelease = currentVersion.includes("-");
42
42
  if (!isPrerelease) {
43
43
  try {
@@ -608,7 +608,12 @@ class FetchState {
608
608
  }
609
609
  const matched = pipeline.matchRoute(this.pathname);
610
610
  if (matched && matched.prerender && pipeline.manifest.serverLike) {
611
- this.routeData = void 0;
611
+ if (matched.params.length > 0) {
612
+ const allMatches = pipeline.matchAllRoutes(this.pathname);
613
+ this.routeData = allMatches.find((r) => !r.prerender);
614
+ } else {
615
+ this.routeData = void 0;
616
+ }
612
617
  } else {
613
618
  this.routeData = matched;
614
619
  }
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"6.4.1"}`
279
+ `v${"6.4.2"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -46,5 +46,13 @@ export declare class Router {
46
46
  match(inputPathname: string, { allowWithoutBase }?: {
47
47
  allowWithoutBase?: boolean;
48
48
  }): RouterMatch;
49
+ /**
50
+ * Returns all routes that match the given pathname, in priority order.
51
+ * Used when the first match (e.g. a prerendered route) cannot serve
52
+ * the request and subsequent matches need to be tried.
53
+ */
54
+ matchAll(inputPathname: string, { allowWithoutBase }?: {
55
+ allowWithoutBase?: boolean;
56
+ }): RouteData[];
49
57
  }
50
58
  export {};
@@ -57,6 +57,34 @@ class Router {
57
57
  const params = getParams(route, pathname);
58
58
  return { type: "match", route, params, pathname };
59
59
  }
60
+ /**
61
+ * Returns all routes that match the given pathname, in priority order.
62
+ * Used when the first match (e.g. a prerendered route) cannot serve
63
+ * the request and subsequent matches need to be tried.
64
+ */
65
+ matchAll(inputPathname, { allowWithoutBase = false } = {}) {
66
+ const normalized = getRedirectForPathname(inputPathname);
67
+ if (normalized.redirect) {
68
+ return [];
69
+ }
70
+ const baseResult = stripBase(
71
+ normalized.pathname,
72
+ this.#base,
73
+ this.#baseWithoutTrailingSlash,
74
+ this.#trailingSlash
75
+ );
76
+ if (!baseResult && !allowWithoutBase) {
77
+ return [];
78
+ }
79
+ let pathname = baseResult ?? normalized.pathname;
80
+ if (this.#buildFormat === "file") {
81
+ pathname = normalizeFileFormatPathname(pathname);
82
+ }
83
+ return this.#routes.filter((candidate) => {
84
+ if (candidate.pattern.test(pathname)) return true;
85
+ return candidate.fallbackRoutes.some((fallbackRoute) => fallbackRoute.pattern.test(pathname));
86
+ });
87
+ }
60
88
  }
61
89
  function normalizeBase(base) {
62
90
  if (!base) return "/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.4.1",
3
+ "version": "6.4.2",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",