astro 4.12.1 → 4.12.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.
@@ -2089,7 +2089,7 @@ export interface AstroUserConfig {
2089
2089
  * <Avatar server:defer />
2090
2090
  * ```
2091
2091
  *
2092
- * The outer page will be rendered, either at build-time (`hybrid`) or at runtime (`server`) with the island content omitted and a `<script>` tag included in its place.
2092
+ * The outer page will be rendered, either at build time (`hybrid`) or at runtime (`server`) with the island content omitted and a `<script>` tag included in its place.
2093
2093
  *
2094
2094
  * After the page loads in the browser, the script tag will replace itself with the the contents of the island by making a request.
2095
2095
  *
@@ -2108,7 +2108,7 @@ export interface AstroUserConfig {
2108
2108
  *
2109
2109
  * Since your component will not render with the rest of the page, you may want to add generic content (e.g. a loading message) to temporarily show in its place. This content will be displayed when the page first renders but before the island has loaded.
2110
2110
  *
2111
- * Add placeholder content as a child of your Astro component with the `slot="fallback:` attribute. When your island content is available, the fallback content will be replaced.
2111
+ * Add placeholder content as a child of your Astro component with the `slot="fallback"` attribute. When your island content is available, the fallback content will be replaced.
2112
2112
  *
2113
2113
  * The example below displays a generic avatar as fallback content, then animates into a personalized avatar using view transitions:
2114
2114
  *
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.12.1";
1
+ const ASTRO_VERSION = "4.12.2";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
19
19
  await telemetry.record([]);
20
20
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
21
21
  const logger = restart.container.logger;
22
- const currentVersion = "4.12.1";
22
+ const currentVersion = "4.12.2";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -5,11 +5,12 @@ import { type ErrorWithMetadata } from './errors/index.js';
5
5
  * Prestyled messages for the CLI. Used by astro CLI commands.
6
6
  */
7
7
  /** Display each request being served with the path and the status code. */
8
- export declare function req({ url, method, statusCode, reqTime, }: {
8
+ export declare function req({ url, method, statusCode, reqTime, isRewrite, }: {
9
9
  url: string;
10
10
  statusCode: number;
11
11
  method?: string;
12
12
  reqTime?: number;
13
+ isRewrite?: boolean;
13
14
  }): string;
14
15
  /** Display server host and startup time */
15
16
  export declare function serverStart({ startupTime, resolvedUrls, host, base, }: {
@@ -26,10 +26,11 @@ function req({
26
26
  url,
27
27
  method,
28
28
  statusCode,
29
- reqTime
29
+ reqTime,
30
+ isRewrite
30
31
  }) {
31
32
  const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue;
32
- return color(`[${statusCode}]`) + ` ` + (method && method !== "GET" ? color(method) + " " : "") + url + ` ` + (reqTime ? dim(Math.round(reqTime) + "ms") : "");
33
+ return color(`[${statusCode}]`) + ` ${isRewrite ? color("(rewrite) ") : ""}` + (method && method !== "GET" ? color(method) + " " : "") + url + ` ` + (reqTime ? dim(Math.round(reqTime) + "ms") : "");
33
34
  }
34
35
  function serverStart({
35
36
  startupTime,
@@ -37,7 +38,7 @@ function serverStart({
37
38
  host,
38
39
  base
39
40
  }) {
40
- const version = "4.12.1";
41
+ const version = "4.12.2";
41
42
  const localPrefix = `${dim("\u2503")} Local `;
42
43
  const networkPrefix = `${dim("\u2503")} Network `;
43
44
  const emptyPrefix = " ".repeat(11);
@@ -269,7 +270,7 @@ function printHelp({
269
270
  message.push(
270
271
  linebreak(),
271
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"4.12.1"}`
273
+ `v${"4.12.2"}`
273
274
  )} ${headline}`
274
275
  );
275
276
  }
@@ -9,6 +9,9 @@ const internalProps = /* @__PURE__ */ new Set([
9
9
  function containsServerDirective(props) {
10
10
  return "server:component-directive" in props;
11
11
  }
12
+ function safeJsonStringify(obj) {
13
+ return JSON.stringify(obj).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\//g, "\\u002f");
14
+ }
12
15
  function renderServerIsland(result, _displayName, props, slots) {
13
16
  return {
14
17
  async render(destination) {
@@ -35,13 +38,13 @@ function renderServerIsland(result, _displayName, props, slots) {
35
38
  }
36
39
  const hostId = crypto.randomUUID();
37
40
  destination.write(`<script async type="module" data-island-id="${hostId}">
38
- let componentId = ${JSON.stringify(componentId)};
39
- let componentExport = ${JSON.stringify(componentExport)};
41
+ let componentId = ${safeJsonStringify(componentId)};
42
+ let componentExport = ${safeJsonStringify(componentExport)};
40
43
  let script = document.querySelector('script[data-island-id="${hostId}"]');
41
44
  let data = {
42
45
  componentExport,
43
- props: ${JSON.stringify(props)},
44
- slots: ${JSON.stringify(renderedSlots)},
46
+ props: ${safeJsonStringify(props)},
47
+ slots: ${safeJsonStringify(renderedSlots)},
45
48
  };
46
49
 
47
50
  let response = await fetch('/_server-islands/${componentId}', {
@@ -1,8 +1,9 @@
1
- import type { Options } from './types.js';
1
+ import type { Fallback, Options } from './types.js';
2
2
  export declare const updateScrollPosition: (positions: {
3
3
  scrollX: number;
4
4
  scrollY: number;
5
5
  }) => void;
6
6
  export declare const supportsViewTransitions: boolean;
7
7
  export declare const transitionEnabledOnThisPage: () => boolean;
8
+ export declare function getFallback(): Fallback;
8
9
  export declare function navigate(href: string, options?: Options): Promise<void>;
@@ -469,6 +469,7 @@ async function prepareForClientOnlyComponents(newDocument, toLocation, signal) {
469
469
  }
470
470
  }
471
471
  export {
472
+ getFallback,
472
473
  navigate,
473
474
  supportsViewTransitions,
474
475
  transitionEnabledOnThisPage,
@@ -19,7 +19,7 @@ type HandleRoute = {
19
19
  manifestData: ManifestData;
20
20
  incomingRequest: http.IncomingMessage;
21
21
  incomingResponse: http.ServerResponse;
22
- status?: 404 | 500;
22
+ status?: 404 | 500 | 200;
23
23
  pipeline: DevPipeline;
24
24
  };
25
25
  export declare function handleRoute({ matchedRoute, url, pathname, status, body, origin, pipeline, manifestData, incomingRequest, incomingResponse, }: HandleRoute): Promise<void>;
@@ -165,7 +165,8 @@ async function handleRoute({
165
165
  req({
166
166
  url: pathname,
167
167
  method: incomingRequest.method,
168
- statusCode: status ?? response.status,
168
+ statusCode: isRewrite ? response.status : status ?? response.status,
169
+ isRewrite,
169
170
  reqTime: timeEnd - timeStart
170
171
  })
171
172
  );
@@ -216,6 +217,7 @@ function getStatus(matchedRoute) {
216
217
  if (!matchedRoute) return 404;
217
218
  if (matchedRoute.route.route === "/404") return 404;
218
219
  if (matchedRoute.route.route === "/500") return 500;
220
+ return 200;
219
221
  }
220
222
  export {
221
223
  handleRoute,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.12.1",
3
+ "version": "4.12.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",