astro 4.4.5 → 4.4.7

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.
Files changed (83) hide show
  1. package/components/Code.astro +3 -3
  2. package/components/ViewTransitions.astro +5 -0
  3. package/dist/@types/astro.d.ts +10 -4
  4. package/dist/assets/build/generate.js +1 -1
  5. package/dist/assets/endpoint/generic.js +1 -1
  6. package/dist/assets/endpoint/node.js +39 -9
  7. package/dist/assets/utils/metadata.js +1 -1
  8. package/dist/assets/utils/transformToPath.js +1 -1
  9. package/dist/assets/vite-plugin-assets.js +2 -1
  10. package/dist/cli/add/index.js +4 -4
  11. package/dist/cli/check/index.js +1 -1
  12. package/dist/cli/db/index.js +2 -2
  13. package/dist/cli/info/index.js +2 -2
  14. package/dist/cli/install-package.js +2 -2
  15. package/dist/cli/preferences/index.js +5 -5
  16. package/dist/content/server-listeners.js +1 -1
  17. package/dist/content/types-generator.js +2 -2
  18. package/dist/content/utils.d.ts +1 -1
  19. package/dist/content/utils.js +2 -2
  20. package/dist/content/vite-plugin-content-imports.js +1 -1
  21. package/dist/content/vite-plugin-content-virtual-mod.js +1 -1
  22. package/dist/core/app/common.d.ts +1 -1
  23. package/dist/core/app/index.js +10 -10
  24. package/dist/core/app/node.d.ts +1 -1
  25. package/dist/core/app/node.js +1 -1
  26. package/dist/core/app/types.d.ts +2 -2
  27. package/dist/core/base-pipeline.js +1 -1
  28. package/dist/core/build/generate.js +14 -13
  29. package/dist/core/build/index.js +2 -2
  30. package/dist/core/build/pipeline.js +1 -1
  31. package/dist/core/build/plugins/plugin-manifest.js +3 -3
  32. package/dist/core/build/plugins/plugin-ssr.js +1 -1
  33. package/dist/core/build/plugins/util.d.ts +1 -1
  34. package/dist/core/build/static-build.js +3 -3
  35. package/dist/core/client-directive/build.js +1 -1
  36. package/dist/core/compile/compile.js +1 -1
  37. package/dist/core/config/config.js +1 -1
  38. package/dist/core/config/settings.js +1 -1
  39. package/dist/core/constants.js +1 -1
  40. package/dist/core/dev/dev.d.ts +1 -1
  41. package/dist/core/dev/dev.js +3 -3
  42. package/dist/core/endpoint/index.d.ts +1 -1
  43. package/dist/core/endpoint/index.js +2 -2
  44. package/dist/core/errors/dev/utils.js +2 -2
  45. package/dist/core/errors/errors-data.js +1 -1
  46. package/dist/core/logger/vite.d.ts +1 -1
  47. package/dist/core/logger/vite.js +1 -1
  48. package/dist/core/messages.js +2 -2
  49. package/dist/core/middleware/index.js +4 -4
  50. package/dist/core/middleware/loadMiddleware.js +1 -1
  51. package/dist/core/preview/index.js +2 -2
  52. package/dist/core/render/result.d.ts +1 -1
  53. package/dist/core/render/result.js +5 -5
  54. package/dist/core/render/route-cache.d.ts +1 -0
  55. package/dist/core/render/route-cache.js +8 -4
  56. package/dist/core/render-context.js +11 -11
  57. package/dist/core/request.d.ts +10 -3
  58. package/dist/core/request.js +9 -6
  59. package/dist/core/routing/manifest/create.js +2 -2
  60. package/dist/core/sync/index.js +3 -3
  61. package/dist/i18n/middleware.js +1 -1
  62. package/dist/integrations/index.js +1 -1
  63. package/dist/jsx-runtime/index.js +1 -1
  64. package/dist/preferences/store.js +2 -2
  65. package/dist/runtime/server/index.js +1 -1
  66. package/dist/runtime/server/render/astro/render.js +1 -1
  67. package/dist/runtime/server/render/page.js +1 -1
  68. package/dist/runtime/server/scripts.js +1 -1
  69. package/dist/runtime/server/transition.js +2 -1
  70. package/dist/vite-plugin-astro-server/base.js +1 -1
  71. package/dist/vite-plugin-astro-server/error.d.ts +1 -1
  72. package/dist/vite-plugin-astro-server/error.js +1 -1
  73. package/dist/vite-plugin-astro-server/pipeline.d.ts +1 -1
  74. package/dist/vite-plugin-astro-server/pipeline.js +6 -6
  75. package/dist/vite-plugin-astro-server/plugin.js +6 -6
  76. package/dist/vite-plugin-astro-server/request.js +1 -1
  77. package/dist/vite-plugin-astro-server/route.js +10 -11
  78. package/dist/vite-plugin-env/index.js +1 -1
  79. package/dist/vite-plugin-inject-env-ts/index.js +1 -1
  80. package/dist/vite-plugin-markdown/index.js +5 -5
  81. package/dist/vite-plugin-scanner/index.js +1 -1
  82. package/dist/vite-plugin-utils/index.js +1 -1
  83. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  ---
2
+ import type { ThemePresets } from '@astrojs/markdown-remark';
2
3
  import type {
3
4
  BuiltinLanguage,
4
- BuiltinTheme,
5
5
  LanguageRegistration,
6
6
  SpecialLanguage,
7
7
  ThemeRegistration,
@@ -28,12 +28,12 @@ interface Props {
28
28
  *
29
29
  * @default "github-dark"
30
30
  */
31
- theme?: BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw;
31
+ theme?: ThemePresets | ThemeRegistration | ThemeRegistrationRaw;
32
32
  /**
33
33
  * Multiple themes to style with -- alternative to "theme" option.
34
34
  * Supports all themes found above; see https://github.com/antfu/shikiji#lightdark-dual-themes for more information.
35
35
  */
36
- experimentalThemes?: Record<string, BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw>;
36
+ experimentalThemes?: Record<string, ThemePresets | ThemeRegistration | ThemeRegistrationRaw>;
37
37
  /**
38
38
  * Enable word wrapping.
39
39
  * - true: enabled.
@@ -51,6 +51,11 @@ const { fallback = 'animate' } = Astro.props;
51
51
  }
52
52
 
53
53
  if (supportsViewTransitions || getFallback() !== 'none') {
54
+ if (import.meta.env.DEV && window.matchMedia('(prefers-reduced-motion)').matches) {
55
+ console.warn(
56
+ `[transitions]: all view transition animations, including fallback animation, are disabled as this device has the prefer-reduced-motion setting enabled.`
57
+ );
58
+ }
54
59
  document.addEventListener('click', (ev) => {
55
60
  let link = ev.target;
56
61
  if (ev.composed) {
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
4
- import type * as babel from '@babel/core';
5
3
  import type { OutgoingHttpHeaders } from 'node:http';
6
4
  import type { AddressInfo } from 'node:net';
5
+ import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
6
+ import type * as babel from '@babel/core';
7
7
  import type * as rollup from 'rollup';
8
8
  import type * as vite from 'vite';
9
9
  import type { RemotePattern } from '../assets/utils/remotePattern.js';
@@ -19,6 +19,7 @@ import type { AstroDevToolbar, DevToolbarCanvas } from '../runtime/client/dev-to
19
19
  import type { Icon } from '../runtime/client/dev-toolbar/ui-library/icons.js';
20
20
  import type { DevToolbarBadge, DevToolbarButton, DevToolbarCard, DevToolbarHighlight, DevToolbarIcon, DevToolbarToggle, DevToolbarTooltip, DevToolbarWindow } from '../runtime/client/dev-toolbar/ui-library/index.js';
21
21
  import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
22
+ import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from '../transitions/events.js';
22
23
  import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
23
24
  import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
24
25
  export { type AstroIntegrationLogger };
@@ -2520,9 +2521,14 @@ declare global {
2520
2521
  'astro-dev-overlay-icon': DevToolbarIcon;
2521
2522
  'astro-dev-overlay-card': DevToolbarCard;
2522
2523
  }
2523
- }
2524
- declare global {
2525
2524
  namespace Config {
2526
2525
  type Database = Record<string, any>;
2527
2526
  }
2527
+ interface DocumentEventMap {
2528
+ 'astro:before-preparation': TransitionBeforePreparationEvent;
2529
+ 'astro:after-preparation': Event;
2530
+ 'astro:before-swap': TransitionBeforeSwapEvent;
2531
+ 'astro:after-swap': Event;
2532
+ 'astro:page-load': Event;
2533
+ }
2528
2534
  }
@@ -1,6 +1,6 @@
1
- import { dim, green } from "kleur/colors";
2
1
  import fs, { readFileSync } from "node:fs";
3
2
  import { basename, join } from "node:path/posix";
3
+ import { dim, green } from "kleur/colors";
4
4
  import { getOutDirWithinCwd } from "../../core/build/common.js";
5
5
  import { getTimeStat } from "../../core/build/util.js";
6
6
  import { AstroError } from "../../core/errors/errors.js";
@@ -2,8 +2,8 @@ import { isRemotePath } from "@astrojs/internal-helpers/path";
2
2
  import mime from "mime/lite.js";
3
3
  import { getConfiguredImageService } from "../internal.js";
4
4
  import { etag } from "../utils/etag.js";
5
- import { imageConfig } from "astro:assets";
6
5
  import { isRemoteAllowed } from "../utils/remotePattern.js";
6
+ import { imageConfig } from "astro:assets";
7
7
  async function loadRemoteImage(src) {
8
8
  try {
9
9
  const res = await fetch(src);
@@ -1,22 +1,43 @@
1
+ import os from "node:os";
2
+ import { isAbsolute } from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
1
4
  import { isRemotePath, removeQueryString } from "@astrojs/internal-helpers/path";
2
5
  import { readFile } from "fs/promises";
3
6
  import mime from "mime/lite.js";
4
- import os from "os";
5
7
  import { getConfiguredImageService } from "../internal.js";
6
8
  import { etag } from "../utils/etag.js";
7
- import { assetsDir, imageConfig } from "astro:assets";
8
9
  import { isRemoteAllowed } from "../utils/remotePattern.js";
10
+ import { assetsDir, imageConfig, outDir } from "astro:assets";
9
11
  function replaceFileSystemReferences(src) {
10
12
  return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
11
13
  }
12
14
  async function loadLocalImage(src, url) {
13
- const filePath = import.meta.env.DEV ? removeQueryString(replaceFileSystemReferences(src)) : new URL("." + src, assetsDir);
15
+ const assetsDirPath = fileURLToPath(assetsDir);
16
+ let fileUrl;
17
+ if (import.meta.env.DEV) {
18
+ fileUrl = pathToFileURL(removeQueryString(replaceFileSystemReferences(src)));
19
+ } else {
20
+ try {
21
+ fileUrl = new URL("." + src, outDir);
22
+ const filePath = fileURLToPath(fileUrl);
23
+ if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
24
+ return void 0;
25
+ }
26
+ } catch (err) {
27
+ return void 0;
28
+ }
29
+ }
14
30
  let buffer = void 0;
15
31
  try {
16
- buffer = await readFile(filePath);
32
+ buffer = await readFile(fileUrl);
17
33
  } catch (e) {
18
- const sourceUrl = new URL(src, url.origin);
19
- buffer = await loadRemoteImage(sourceUrl);
34
+ try {
35
+ const sourceUrl = new URL(src, url.origin);
36
+ buffer = await loadRemoteImage(sourceUrl);
37
+ } catch (err) {
38
+ console.error("Could not process image request:", err);
39
+ return void 0;
40
+ }
20
41
  }
21
42
  return buffer;
22
43
  }
@@ -40,7 +61,11 @@ const GET = async ({ request }) => {
40
61
  const url = new URL(request.url);
41
62
  const transform = await imageService.parseURL(url, imageConfig);
42
63
  if (!transform?.src) {
43
- throw new Error("Incorrect transform returned by `parseURL`");
64
+ const err = new Error(
65
+ "Incorrect transform returned by `parseURL`. Expected a transform with a `src` property."
66
+ );
67
+ console.error("Could not parse image transform from URL:", err);
68
+ return new Response("Internal Server Error", { status: 500 });
44
69
  }
45
70
  let inputBuffer = void 0;
46
71
  if (isRemotePath(transform.src)) {
@@ -52,7 +77,7 @@ const GET = async ({ request }) => {
52
77
  inputBuffer = await loadLocalImage(transform.src, url);
53
78
  }
54
79
  if (!inputBuffer) {
55
- return new Response("Not Found", { status: 404 });
80
+ return new Response("Internal Server Error", { status: 500 });
56
81
  }
57
82
  const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
58
83
  return new Response(data, {
@@ -66,7 +91,12 @@ const GET = async ({ request }) => {
66
91
  });
67
92
  } catch (err) {
68
93
  console.error("Could not process image request:", err);
69
- return new Response(`Server Error: ${err}`, { status: 500 });
94
+ return new Response(
95
+ import.meta.env.DEV ? `Could not process image request: ${err}` : `Internal Server Error`,
96
+ {
97
+ status: 500
98
+ }
99
+ );
70
100
  }
71
101
  };
72
102
  export {
@@ -1,5 +1,5 @@
1
- import { lookup as probe } from "../utils/vendor/image-size/lookup.js";
2
1
  import { AstroError, AstroErrorData } from "../../core/errors/index.js";
2
+ import { lookup as probe } from "../utils/vendor/image-size/lookup.js";
3
3
  async function imageMetadata(data, src) {
4
4
  const result = probe(data);
5
5
  if (!result.height || !result.width || !result.type) {
@@ -1,5 +1,5 @@
1
- import { deterministicString } from "deterministic-object-hash";
2
1
  import { basename, extname } from "node:path";
2
+ import { deterministicString } from "deterministic-object-hash";
3
3
  import { removeQueryString } from "../../core/path.js";
4
4
  import { shorthash } from "../../runtime/server/shorthash.js";
5
5
  import { isESMImportedImage } from "./imageKind.js";
@@ -55,11 +55,12 @@ function assets({
55
55
  export { default as Picture } from "astro/components/Picture.astro";
56
56
 
57
57
  export const imageConfig = ${JSON.stringify(settings.config.image)};
58
- export const assetsDir = new URL(${JSON.stringify(
58
+ export const outDir = new URL(${JSON.stringify(
59
59
  new URL(
60
60
  isServerLikeOutput(settings.config) ? settings.config.build.client : settings.config.outDir
61
61
  )
62
62
  )});
63
+ export const assetsDir = new URL(${JSON.stringify(settings.config.build.assets)}, outDir);
63
64
  export const getImage = async (options) => await getImageInternal(options, imageConfig);
64
65
  `;
65
66
  }
@@ -1,14 +1,14 @@
1
+ import fsMod, { existsSync, promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
1
4
  import boxen from "boxen";
2
5
  import { diffWords } from "diff";
3
6
  import { execa } from "execa";
4
7
  import { bold, cyan, dim, green, magenta, red, yellow } from "kleur/colors";
5
- import fsMod, { existsSync, promises as fs } from "node:fs";
6
- import path from "node:path";
7
- import { fileURLToPath, pathToFileURL } from "node:url";
8
- import maxSatisfying from "semver/ranges/max-satisfying.js";
9
8
  import ora from "ora";
10
9
  import preferredPM from "preferred-pm";
11
10
  import prompts from "prompts";
11
+ import maxSatisfying from "semver/ranges/max-satisfying.js";
12
12
  import {
13
13
  loadTSConfig,
14
14
  resolveConfig,
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
+ import { ensureProcessNodeEnv } from "../../core/util.js";
2
3
  import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
3
4
  import { getPackage } from "../install-package.js";
4
- import { ensureProcessNodeEnv } from "../../core/util.js";
5
5
  async function check(flags) {
6
6
  ensureProcessNodeEnv("production");
7
7
  const logger = createLoggerFromFlags(flags);
@@ -1,7 +1,7 @@
1
- import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
2
- import { getPackage } from "../install-package.js";
3
1
  import { resolveConfig } from "../../core/config/config.js";
4
2
  import { apply as applyPolyfill } from "../../core/polyfill.js";
3
+ import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
4
+ import { getPackage } from "../install-package.js";
5
5
  async function db({ flags }) {
6
6
  applyPolyfill();
7
7
  const logger = createLoggerFromFlags(flags);
@@ -1,11 +1,11 @@
1
- import * as colors from "kleur/colors";
2
1
  import { execSync } from "node:child_process";
3
2
  import { arch, platform } from "node:os";
3
+ import * as colors from "kleur/colors";
4
4
  import prompts from "prompts";
5
5
  import { resolveConfig } from "../../core/config/index.js";
6
6
  import { ASTRO_VERSION } from "../../core/constants.js";
7
- import { flagsToAstroInlineConfig } from "../flags.js";
8
7
  import { apply as applyPolyfill } from "../../core/polyfill.js";
8
+ import { flagsToAstroInlineConfig } from "../flags.js";
9
9
  async function getInfoOutput({
10
10
  userConfig,
11
11
  print
@@ -1,3 +1,5 @@
1
+ import { createRequire } from "node:module";
2
+ import { sep } from "node:path";
1
3
  import boxen from "boxen";
2
4
  import { execa } from "execa";
3
5
  import { bold, cyan, dim, magenta } from "kleur/colors";
@@ -6,8 +8,6 @@ import prompts from "prompts";
6
8
  import resolvePackage from "resolve";
7
9
  import whichPm from "which-pm";
8
10
  import {} from "../core/logger/core.js";
9
- import { createRequire } from "node:module";
10
- import { sep } from "node:path";
11
11
  const require2 = createRequire(import.meta.url);
12
12
  async function getPackage(packageName, logger, options, otherDeps = []) {
13
13
  try {
@@ -1,16 +1,16 @@
1
- import { bgGreen, black, bold, dim, yellow } from "kleur/colors";
2
1
  import { fileURLToPath } from "node:url";
2
+ import { bgGreen, black, bold, dim, yellow } from "kleur/colors";
3
+ import { formatWithOptions } from "node:util";
3
4
  import dlv from "dlv";
5
+ import { flattie } from "flattie";
4
6
  import { resolveConfig } from "../../core/config/config.js";
5
7
  import { createSettings } from "../../core/config/settings.js";
8
+ import { collectErrorMetadata } from "../../core/errors/dev/utils.js";
6
9
  import * as msg from "../../core/messages.js";
10
+ import { apply as applyPolyfill } from "../../core/polyfill.js";
7
11
  import { DEFAULT_PREFERENCES } from "../../preferences/defaults.js";
8
12
  import { coerce, isValidKey } from "../../preferences/index.js";
9
13
  import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
10
- import { flattie } from "flattie";
11
- import { formatWithOptions } from "node:util";
12
- import { collectErrorMetadata } from "../../core/errors/dev/utils.js";
13
- import { apply as applyPolyfill } from "../../core/polyfill.js";
14
14
  const PREFERENCES_SUBCOMMANDS = [
15
15
  "get",
16
16
  "set",
@@ -1,6 +1,6 @@
1
- import { bold, cyan, underline } from "kleur/colors";
2
1
  import path from "node:path";
3
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
+ import { bold, cyan, underline } from "kleur/colors";
4
4
  import { loadTSConfig } from "../core/config/tsconfig.js";
5
5
  import { appendForwardSlash } from "../core/path.js";
6
6
  import { createContentTypesGenerator } from "./types-generator.js";
@@ -1,7 +1,7 @@
1
- import glob from "fast-glob";
2
- import { bold, cyan } from "kleur/colors";
3
1
  import * as path from "node:path";
4
2
  import { fileURLToPath, pathToFileURL } from "node:url";
3
+ import glob from "fast-glob";
4
+ import { bold, cyan } from "kleur/colors";
5
5
  import { normalizePath } from "vite";
6
6
  import { AstroError } from "../core/errors/errors.js";
7
7
  import { AstroErrorData } from "../core/errors/index.js";
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import matter from 'gray-matter';
3
2
  import fsMod from 'node:fs';
3
+ import matter from 'gray-matter';
4
4
  import type { PluginContext } from 'rollup';
5
5
  import { type ViteDevServer } from 'vite';
6
6
  import { z } from 'zod';
@@ -1,8 +1,8 @@
1
- import { slug as githubSlug } from "github-slugger";
2
- import matter from "gray-matter";
3
1
  import fsMod from "node:fs";
4
2
  import path from "node:path";
5
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { slug as githubSlug } from "github-slugger";
5
+ import matter from "gray-matter";
6
6
  import { normalizePath } from "vite";
7
7
  import { z } from "zod";
8
8
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
@@ -1,6 +1,6 @@
1
- import * as devalue from "devalue";
2
1
  import { extname } from "node:path";
3
2
  import { pathToFileURL } from "node:url";
3
+ import * as devalue from "devalue";
4
4
  import { getProxyCode } from "../assets/utils/proxy.js";
5
5
  import { AstroError } from "../core/errors/errors.js";
6
6
  import { AstroErrorData } from "../core/errors/index.js";
@@ -1,7 +1,7 @@
1
- import glob from "fast-glob";
2
1
  import nodeFs from "node:fs";
3
2
  import { extname } from "node:path";
4
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import glob from "fast-glob";
5
5
  import pLimit from "p-limit";
6
6
  import {} from "vite";
7
7
  import { encodeName } from "../core/build/util.js";
@@ -1,2 +1,2 @@
1
- import type { SerializedSSRManifest, SSRManifest } from './types.js';
1
+ import type { SSRManifest, SerializedSSRManifest } from './types.js';
2
2
  export declare function deserializeManifest(serializedManifest: SerializedSSRManifest): SSRManifest;
@@ -1,4 +1,13 @@
1
+ import { normalizeTheLocale } from "../../i18n/index.js";
2
+ import {
3
+ REROUTABLE_STATUS_CODES,
4
+ REROUTE_DIRECTIVE_HEADER,
5
+ clientAddressSymbol,
6
+ clientLocalsSymbol,
7
+ responseSentSymbol
8
+ } from "../constants.js";
1
9
  import { getSetCookiesFromResponse } from "../cookies/index.js";
10
+ import { AstroError, AstroErrorData } from "../errors/index.js";
2
11
  import { consoleLogDestination } from "../logger/console.js";
3
12
  import { AstroIntegrationLogger, Logger } from "../logger/core.js";
4
13
  import {
@@ -9,19 +18,10 @@ import {
9
18
  removeTrailingForwardSlash
10
19
  } from "../path.js";
11
20
  import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
21
+ import { RenderContext } from "../render-context.js";
12
22
  import { createAssetLink } from "../render/ssr-element.js";
13
23
  import { matchRoute } from "../routing/match.js";
14
24
  import { AppPipeline } from "./pipeline.js";
15
- import { normalizeTheLocale } from "../../i18n/index.js";
16
- import { RenderContext } from "../render-context.js";
17
- import {
18
- clientAddressSymbol,
19
- clientLocalsSymbol,
20
- responseSentSymbol,
21
- REROUTABLE_STATUS_CODES,
22
- REROUTE_DIRECTIVE_HEADER
23
- } from "../constants.js";
24
- import { AstroError, AstroErrorData } from "../errors/index.js";
25
25
  import { deserializeManifest } from "./common.js";
26
26
  class App {
27
27
  #manifest;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import { App } from './index.js';
3
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
4
3
  import type { RouteData } from '../../@types/astro.js';
4
+ import { App } from './index.js';
5
5
  import type { RenderOptions } from './index.js';
6
6
  import type { SSRManifest } from './types.js';
7
7
  export { apply as applyPolyfills } from '../polyfill.js';
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
- import { App } from "./index.js";
3
2
  import { deserializeManifest } from "./common.js";
4
3
  import { createOutgoingHttpHeaders } from "./createOutgoingHttpHeaders.js";
4
+ import { App } from "./index.js";
5
5
  import { apply } from "../polyfill.js";
6
6
  const clientAddressSymbol = Symbol.for("astro.clientAddress");
7
7
  class NodeApp extends App {
@@ -1,6 +1,6 @@
1
- import type { Locales, MiddlewareHandler, RouteData, SerializedRouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../@types/astro.js';
2
- import type { SinglePageBuiltModule } from '../build/types.js';
1
+ import type { Locales, MiddlewareHandler, RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult, SerializedRouteData } from '../../@types/astro.js';
3
2
  import type { RoutingStrategies } from '../../i18n/utils.js';
3
+ import type { SinglePageBuiltModule } from '../build/types.js';
4
4
  export type ComponentPath = string;
5
5
  export type StylesheetAsset = {
6
6
  type: 'inline';
@@ -1,5 +1,5 @@
1
- import { RouteCache } from "./render/route-cache.js";
2
1
  import { createI18nMiddleware } from "../i18n/middleware.js";
2
+ import { RouteCache } from "./render/route-cache.js";
3
3
  class Pipeline {
4
4
  constructor(logger, manifest, mode, renderers, resolve, serverLike, streaming, adapterName = manifest.adapterName, clientDirectives = manifest.clientDirectives, compressHTML = manifest.compressHTML, i18n = manifest.i18n, middleware = manifest.middleware, routeCache = new RouteCache(logger, mode), site = manifest.site) {
5
5
  this.logger = logger;
@@ -1,7 +1,7 @@
1
- import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
2
1
  import fs from "node:fs";
3
2
  import os from "node:os";
4
3
  import { fileURLToPath } from "node:url";
4
+ import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
5
5
  import PQueue from "p-queue";
6
6
  import {
7
7
  generateImagesForPath,
@@ -16,8 +16,10 @@ import {
16
16
  removeLeadingForwardSlash,
17
17
  removeTrailingForwardSlash
18
18
  } from "../../core/path.js";
19
+ import { toRoutingStrategy } from "../../i18n/utils.js";
19
20
  import { runHookBuildGenerated } from "../../integrations/index.js";
20
21
  import { getOutputDirectory, isServerLikeOutput } from "../../prerender/utils.js";
22
+ import { NoPrerenderedRoutesWithDomains } from "../errors/errors-data.js";
21
23
  import { AstroError, AstroErrorData } from "../errors/index.js";
22
24
  import { routeIsFallback } from "../redirects/helpers.js";
23
25
  import {
@@ -25,11 +27,11 @@ import {
25
27
  getRedirectLocationOrThrow,
26
28
  routeIsRedirect
27
29
  } from "../redirects/index.js";
30
+ import { RenderContext } from "../render-context.js";
28
31
  import { callGetStaticPaths } from "../render/route-cache.js";
29
32
  import { createRequest } from "../request.js";
30
33
  import { matchRoute } from "../routing/match.js";
31
34
  import { getOutputFilename } from "../util.js";
32
- import { BuildPipeline } from "./pipeline.js";
33
35
  import { getOutDirWithinCwd, getOutFile, getOutFolder } from "./common.js";
34
36
  import {
35
37
  cssOrder,
@@ -37,10 +39,8 @@ import {
37
39
  getPageDataByComponent,
38
40
  mergeInlineCss
39
41
  } from "./internal.js";
42
+ import { BuildPipeline } from "./pipeline.js";
40
43
  import { getTimeStat, shouldAppendForwardSlash } from "./util.js";
41
- import { NoPrerenderedRoutesWithDomains } from "../errors/errors-data.js";
42
- import { RenderContext } from "../render-context.js";
43
- import { toRoutingStrategy } from "../../i18n/utils.js";
44
44
  function createEntryURL(filePath, outFolder) {
45
45
  return new URL("./" + filePath + `?time=${Date.now()}`, outFolder);
46
46
  }
@@ -242,12 +242,6 @@ async function getPathsForRoute(route, mod, pipeline, builtPaths) {
242
242
  if (route.pathname) {
243
243
  paths.push(route.pathname);
244
244
  builtPaths.add(route.pathname);
245
- for (const virtualRoute of route.fallbackRoutes) {
246
- if (virtualRoute.pathname) {
247
- paths.push(virtualRoute.pathname);
248
- builtPaths.add(virtualRoute.pathname);
249
- }
250
- }
251
245
  } else {
252
246
  const staticPaths = await callGetStaticPaths({
253
247
  mod,
@@ -332,11 +326,17 @@ function getUrlForPath(pathname, base, origin, format, trailingSlash, routeType)
332
326
  }
333
327
  async function generatePath(pathname, pipeline, gopts, route) {
334
328
  const { mod } = gopts;
335
- const { config, logger, options, serverLike } = pipeline;
329
+ const { config, logger, options } = pipeline;
336
330
  logger.debug("build", `Generating: ${pathname}`);
337
331
  if (route.type === "page") {
338
332
  addPageName(pathname, options);
339
333
  }
334
+ if (route.type === "fallback" && // If route is index page, continue rendering. The index page should
335
+ // always be rendered
336
+ route.pathname !== "/" && // Check if there is a translated page with the same path
337
+ Object.values(options.allPages).some((val) => pathname.match(val.route.pattern))) {
338
+ return;
339
+ }
340
340
  const url = getUrlForPath(
341
341
  pathname,
342
342
  config.base,
@@ -346,10 +346,11 @@ async function generatePath(pathname, pipeline, gopts, route) {
346
346
  route.type
347
347
  );
348
348
  const request = createRequest({
349
+ base: config.base,
349
350
  url,
350
351
  headers: new Headers(),
351
352
  logger,
352
- ssr: serverLike
353
+ staticLike: true
353
354
  });
354
355
  const renderContext = RenderContext.create({ pipeline, pathname, request, routeData: route });
355
356
  let body;
@@ -1,7 +1,7 @@
1
- import { blue, bold, green } from "kleur/colors";
2
1
  import fs from "node:fs";
3
2
  import { performance } from "node:perf_hooks";
4
3
  import { fileURLToPath } from "node:url";
4
+ import { blue, bold, green } from "kleur/colors";
5
5
  import { injectImageEndpoint } from "../../assets/endpoint/config.js";
6
6
  import { telemetry } from "../../events/index.js";
7
7
  import { eventCliSession } from "../../events/session.js";
@@ -19,10 +19,10 @@ import { createVite } from "../create-vite.js";
19
19
  import { levels, timerMessage } from "../logger/core.js";
20
20
  import { apply as applyPolyfill } from "../polyfill.js";
21
21
  import { createRouteManifest } from "../routing/index.js";
22
+ import { ensureProcessNodeEnv } from "../util.js";
22
23
  import { collectPagesData } from "./page-data.js";
23
24
  import { staticBuild, viteBuild } from "./static-build.js";
24
25
  import { getTimeStat } from "./util.js";
25
- import { ensureProcessNodeEnv } from "../util.js";
26
26
  async function build(inlineConfig, options = {}) {
27
27
  ensureProcessNodeEnv("production");
28
28
  applyPolyfill();
@@ -8,8 +8,8 @@ import {
8
8
  createStylesheetElementSet
9
9
  } from "../render/ssr-element.js";
10
10
  import {
11
- getPageDataByComponent,
12
11
  cssOrder,
12
+ getPageDataByComponent,
13
13
  mergeInlineCss
14
14
  } from "./internal.js";
15
15
  import {
@@ -1,6 +1,8 @@
1
- import glob from "fast-glob";
2
1
  import { fileURLToPath } from "node:url";
2
+ import glob from "fast-glob";
3
3
  import {} from "vite";
4
+ import { normalizeTheLocale } from "../../../i18n/index.js";
5
+ import { toRoutingStrategy } from "../../../i18n/utils.js";
4
6
  import { runHookBuildSsr } from "../../../integrations/index.js";
5
7
  import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
6
8
  import { joinPaths, prependForwardSlash } from "../../path.js";
@@ -8,8 +10,6 @@ import { serializeRouteData } from "../../routing/index.js";
8
10
  import { addRollupInput } from "../add-rollup-input.js";
9
11
  import { getOutFile, getOutFolder } from "../common.js";
10
12
  import { cssOrder, mergeInlineCss } from "../internal.js";
11
- import { normalizeTheLocale } from "../../../i18n/index.js";
12
- import { toRoutingStrategy } from "../../../i18n/utils.js";
13
13
  const manifestReplace = "@@ASTRO_MANIFEST_REPLACE@@";
14
14
  const replaceExp = new RegExp(`['"]${manifestReplace}['"]`, "g");
15
15
  const SSR_MANIFEST_VIRTUAL_MODULE_ID = "@astrojs-manifest";
@@ -6,10 +6,10 @@ import { routeIsRedirect } from "../../redirects/index.js";
6
6
  import { addRollupInput } from "../add-rollup-input.js";
7
7
  import { eachPageFromAllPages } from "../internal.js";
8
8
  import { SSR_MANIFEST_VIRTUAL_MODULE_ID } from "./plugin-manifest.js";
9
+ import { MIDDLEWARE_MODULE_ID } from "./plugin-middleware.js";
9
10
  import { ASTRO_PAGE_MODULE_ID } from "./plugin-pages.js";
10
11
  import { RENDERERS_MODULE_ID } from "./plugin-renderers.js";
11
12
  import { getPathFromVirtualModulePageName, getVirtualModulePageNameFromPath } from "./util.js";
12
- import { MIDDLEWARE_MODULE_ID } from "./plugin-middleware.js";
13
13
  const SSR_VIRTUAL_MODULE_ID = "@astrojs-ssr-virtual-entry";
14
14
  const RESOLVED_SSR_VIRTUAL_MODULE_ID = "\0" + SSR_VIRTUAL_MODULE_ID;
15
15
  function vitePluginSSR(internals, adapter, options) {
@@ -1,4 +1,4 @@
1
- import type { BuildOptions, Rollup, Plugin as VitePlugin } from 'vite';
1
+ import type { BuildOptions, Plugin as VitePlugin, Rollup } from 'vite';
2
2
  type OutputOptionsHook = Extract<VitePlugin['outputOptions'], Function>;
3
3
  type OutputOptions = Parameters<OutputOptionsHook>[0];
4
4
  type ExtendManualChunksHooks = {
@@ -1,10 +1,10 @@
1
+ import fs from "node:fs";
2
+ import path, { extname } from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
1
4
  import { teardown } from "@astrojs/compiler";
2
5
  import * as eslexer from "es-module-lexer";
3
6
  import glob from "fast-glob";
4
7
  import { bgGreen, bgMagenta, black, green } from "kleur/colors";
5
- import fs from "node:fs";
6
- import path, { extname } from "node:path";
7
- import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import * as vite from "vite";
9
9
  import { PROPAGATED_ASSET_FLAG } from "../../content/consts.js";
10
10
  import { hasAnyContentFlag } from "../../content/utils.js";
@@ -1,5 +1,5 @@
1
- import { build } from "esbuild";
2
1
  import { fileURLToPath } from "node:url";
2
+ import { build } from "esbuild";
3
3
  async function buildClientDirectiveEntrypoint(name, entrypoint, root) {
4
4
  const stringifiedName = JSON.stringify(name);
5
5
  const stringifiedEntrypoint = JSON.stringify(entrypoint);
@@ -1,5 +1,5 @@
1
- import { transform } from "@astrojs/compiler";
2
1
  import { fileURLToPath } from "node:url";
2
+ import { transform } from "@astrojs/compiler";
3
3
  import { normalizePath } from "vite";
4
4
  import { AggregateError, CompilerError } from "../errors/errors.js";
5
5
  import { AstroErrorData } from "../errors/index.js";