astro 4.11.0 → 4.11.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.
Files changed (77) hide show
  1. package/dist/@types/astro.d.ts +5 -4
  2. package/dist/actions/runtime/store.d.ts +0 -1
  3. package/dist/actions/runtime/virtual/server.d.ts +1 -1
  4. package/dist/assets/build/remote.d.ts +0 -1
  5. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.wasm.d.ts +0 -1
  6. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.wasm.d.ts +0 -1
  7. package/dist/assets/services/vendor/squoosh/codecs.d.ts +0 -1
  8. package/dist/assets/services/vendor/squoosh/image.d.ts +0 -1
  9. package/dist/assets/services/vendor/squoosh/image_data.d.ts +0 -1
  10. package/dist/assets/services/vendor/squoosh/impl.d.ts +0 -1
  11. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.wasm.d.ts +0 -1
  12. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.wasm.d.ts +0 -1
  13. package/dist/assets/services/vendor/squoosh/png/squoosh_oxipng_bg.wasm.d.ts +0 -1
  14. package/dist/assets/services/vendor/squoosh/png/squoosh_png_bg.wasm.d.ts +0 -1
  15. package/dist/assets/services/vendor/squoosh/resize/squoosh_resize_bg.wasm.d.ts +0 -1
  16. package/dist/assets/services/vendor/squoosh/rotate/rotate.wasm.d.ts +0 -1
  17. package/dist/assets/services/vendor/squoosh/utils/workerPool.d.ts +0 -1
  18. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.wasm.d.ts +0 -1
  19. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.wasm.d.ts +0 -1
  20. package/dist/cli/add/babel.d.ts +6 -6
  21. package/dist/cli/install-package.d.ts +1 -1
  22. package/dist/cli/install-package.js +1 -30
  23. package/dist/config/index.d.ts +1 -1
  24. package/dist/config/index.js +1 -1
  25. package/dist/config/vite-plugin-content-listen.d.ts +0 -1
  26. package/dist/content/runtime-assets.d.ts +2 -2
  27. package/dist/content/server-listeners.d.ts +0 -1
  28. package/dist/content/types-generator.d.ts +1 -2
  29. package/dist/content/utils.d.ts +0 -1
  30. package/dist/content/vite-plugin-content-imports.d.ts +0 -1
  31. package/dist/content/vite-plugin-content-virtual-mod.d.ts +0 -1
  32. package/dist/core/app/createOutgoingHttpHeaders.d.ts +0 -1
  33. package/dist/core/app/node.d.ts +0 -1
  34. package/dist/core/build/index.js +1 -1
  35. package/dist/core/build/plugins/plugin-analyzer.js +14 -12
  36. package/dist/core/build/plugins/plugin-content.js +3 -1
  37. package/dist/core/config/config.d.ts +0 -1
  38. package/dist/core/config/schema.d.ts +0 -2
  39. package/dist/core/config/vite-load.d.ts +0 -1
  40. package/dist/core/constants.js +1 -1
  41. package/dist/core/cookies/response.d.ts +1 -1
  42. package/dist/core/cookies/response.js +3 -3
  43. package/dist/core/create-vite.d.ts +2 -2
  44. package/dist/core/create-vite.js +2 -2
  45. package/dist/core/dev/container.d.ts +0 -3
  46. package/dist/core/dev/container.js +1 -1
  47. package/dist/core/dev/dev.d.ts +0 -2
  48. package/dist/core/dev/dev.js +1 -1
  49. package/dist/core/dev/restart.d.ts +0 -1
  50. package/dist/core/errors/errors-data.d.ts +1 -1
  51. package/dist/core/messages.js +2 -2
  52. package/dist/core/module-loader/loader.d.ts +0 -1
  53. package/dist/core/preview/static-preview-server.d.ts +0 -1
  54. package/dist/core/render-context.js +3 -2
  55. package/dist/core/request.d.ts +0 -1
  56. package/dist/core/routing/manifest/create.d.ts +0 -1
  57. package/dist/core/sync/index.js +3 -1
  58. package/dist/env/sync.d.ts +3 -0
  59. package/dist/env/sync.js +27 -0
  60. package/dist/env/vite-plugin-env.d.ts +2 -2
  61. package/dist/env/vite-plugin-env.js +19 -66
  62. package/dist/integrations/hooks.d.ts +1 -2
  63. package/dist/jsx/rehype.d.ts +2 -8
  64. package/dist/runtime/client/dev-toolbar/helpers.d.ts +1 -1
  65. package/dist/runtime/client/dev-toolbar/settings.d.ts +1 -1
  66. package/dist/runtime/client/dev-toolbar/ui-library/tooltip.js +1 -1
  67. package/dist/runtime/server/render/page.js +11 -2
  68. package/dist/transitions/events.d.ts +0 -1
  69. package/dist/transitions/router.js +6 -1
  70. package/dist/vite-plugin-astro-server/error.js +0 -3
  71. package/dist/vite-plugin-astro-server/plugin.d.ts +0 -1
  72. package/dist/vite-plugin-astro-server/request.d.ts +0 -1
  73. package/dist/vite-plugin-astro-server/response.d.ts +0 -1
  74. package/dist/vite-plugin-astro-server/route.d.ts +0 -1
  75. package/dist/vite-plugin-inject-env-ts/index.d.ts +0 -1
  76. package/dist/vite-plugin-load-fallback/index.d.ts +0 -1
  77. package/package.json +10 -12
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { OutgoingHttpHeaders } from 'node:http';
4
2
  import type { AddressInfo } from 'node:net';
5
3
  import type { MarkdownHeading, MarkdownVFile, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
@@ -649,8 +647,11 @@ export interface AstroUserConfig {
649
647
  * @type {boolean}
650
648
  * @default `true`
651
649
  * @description
652
- * This is an option to minify your HTML output and reduce the size of your HTML files. By default, Astro removes all whitespace from your HTML, including line breaks, from `.astro` components. This occurs both in development mode and in the final build.
653
- * To disable HTML compression, set the `compressHTML` flag to `false`.
650
+ *
651
+ * This is an option to minify your HTML output and reduce the size of your HTML files, occuring both in development mode and in the final build.
652
+ * By default, Astro removes whitespace from your HTML, including line breaks, from .astro components in a lossless manner.
653
+ * It is important to note that some whitespace may be kept to preserve the visual rendering of your HTML.
654
+ * To disable HTML compression, set the compressHTML flag to false.
654
655
  *
655
656
  * ```js
656
657
  * {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { AsyncLocalStorage } from 'node:async_hooks';
3
2
  import type { APIContext } from '../../@types/astro.js';
4
3
  export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'props'>;
@@ -14,7 +14,7 @@ export type ActionClient<TOutput, TAccept extends Accept, TInputSchema extends I
14
14
  } : ((input?: any) => Promise<Awaited<TOutput>>) & {
15
15
  safe: (input?: any) => Promise<SafeResult<never, Awaited<TOutput>>>;
16
16
  };
17
- export declare function defineAction<TOutput, TAccept extends Accept, TInputSchema extends InputSchema<Accept> | undefined = TAccept extends 'form' ? z.ZodType<FormData> : undefined>({ accept, input: inputSchema, handler, }: {
17
+ export declare function defineAction<TOutput, TAccept extends Accept = 'json', TInputSchema extends InputSchema<Accept> | undefined = TAccept extends 'form' ? z.ZodType<FormData> : undefined>({ accept, input: inputSchema, handler, }: {
18
18
  input?: TInputSchema;
19
19
  accept?: TAccept;
20
20
  handler: Handler<TInputSchema, TOutput>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  export type RemoteCacheEntry = {
3
2
  data: string;
4
3
  expires: number;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  interface DecodeModule extends EmscriptenWasm.Module {
3
2
  decode: (data: Uint8Array) => ImageData;
4
3
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { ImageOutputFormat } from '../../../types.js';
3
2
  type RotateOperation = {
4
3
  type: 'rotate';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  export default class ImageData {
3
2
  static from(input: ImageData): ImageData;
4
3
  private _data;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import ImageData from './image_data.js';
3
2
  export declare function decodeBuffer(_buffer: Buffer | Uint8Array): Promise<ImageData>;
4
3
  export declare function rotate(image: ImageData, numRotations: number): Promise<ImageData>;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { Worker } from 'worker_threads';
3
2
  interface Job<I> {
4
3
  msg: I;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare const _default: Buffer;
3
2
  export default _default;
@@ -2,16 +2,16 @@ import parser from '@babel/parser';
2
2
  import traverse from '@babel/traverse';
3
3
  import * as t from '@babel/types';
4
4
  export declare const visit: {
5
- <S>(parent: traverse.Node, opts: traverse.TraverseOptions<S>, scope: traverse.Scope | undefined, state: S, parentPath?: traverse.NodePath<traverse.Node> | undefined): void;
6
- (parent: traverse.Node, opts?: traverse.TraverseOptions<traverse.Node> | undefined, scope?: traverse.Scope | undefined, state?: any, parentPath?: traverse.NodePath<traverse.Node> | undefined): void;
5
+ <S>(parent: traverse.Node, opts: traverse.TraverseOptions<S>, scope: traverse.Scope | undefined, state: S, parentPath?: traverse.NodePath): void;
6
+ (parent: traverse.Node, opts?: traverse.TraverseOptions, scope?: traverse.Scope, state?: any, parentPath?: traverse.NodePath): void;
7
7
  visitors: typeof traverse.visitors;
8
8
  verify: typeof traverse.visitors.verify;
9
9
  explode: typeof traverse.visitors.explode;
10
10
  cheap: (node: traverse.Node, enter: (node: traverse.Node) => void) => void;
11
- node: (node: traverse.Node, opts: traverse.TraverseOptions<traverse.Node>, scope?: traverse.Scope | undefined, state?: any, path?: traverse.NodePath<traverse.Node> | undefined, skipKeys?: Record<string, boolean> | undefined) => void;
12
- clearNode: (node: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => void;
13
- removeProperties: (tree: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => traverse.Node;
14
- hasType: (tree: traverse.Node, type: "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "JSXIdentifier" | "JSXNamespacedName" | "JSXMemberExpression" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXSpreadAttribute" | "JSXAttribute" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXFragment" | "JSXText" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "File" | "RestProperty" | "SpreadProperty" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BigIntLiteral" | "BindExpression" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "ClassAccessorProperty" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportDefaultSpecifier" | "ExportNamespaceSpecifier" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Import" | "ImportAttribute" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXSpreadChild" | "MixedTypeAnnotation" | "ModuleExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectMethod" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "ThisTypeAnnotation" | "TopicReference" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "Variance" | "VoidTypeAnnotation", denylistTypes?: string[] | undefined) => boolean;
11
+ node: (node: traverse.Node, opts: traverse.TraverseOptions, scope?: traverse.Scope, state?: any, path?: traverse.NodePath, skipKeys?: Record<string, boolean>) => void;
12
+ clearNode: (node: traverse.Node, opts?: traverse.RemovePropertiesOptions) => void;
13
+ removeProperties: (tree: traverse.Node, opts?: traverse.RemovePropertiesOptions) => traverse.Node;
14
+ hasType: (tree: traverse.Node, type: traverse.Node["type"], denylistTypes?: string[]) => boolean;
15
15
  cache: typeof traverse.cache;
16
16
  };
17
17
  export { t };
@@ -1,4 +1,4 @@
1
- import { type Logger } from '../core/logger/core.js';
1
+ import type { Logger } from '../core/logger/core.js';
2
2
  type GetPackageOptions = {
3
3
  skipAsk?: boolean;
4
4
  optional?: boolean;
@@ -1,5 +1,4 @@
1
1
  import { createRequire } from "node:module";
2
- import { pathToFileURL } from "node:url";
3
2
  import boxen from "boxen";
4
3
  import ci from "ci-info";
5
4
  import { execa } from "execa";
@@ -7,21 +6,10 @@ import { bold, cyan, dim, magenta } from "kleur/colors";
7
6
  import ora from "ora";
8
7
  import preferredPM from "preferred-pm";
9
8
  import prompts from "prompts";
10
- import resolvePackage from "resolve";
11
9
  import whichPm from "which-pm";
12
- import {} from "../core/logger/core.js";
13
- const require2 = createRequire(import.meta.url);
14
10
  async function getPackage(packageName, logger, options, otherDeps = []) {
15
11
  try {
16
- if (packageName === "@astrojs/db") {
17
- const packageJsonLoc = require2.resolve(packageName + "/package.json", {
18
- paths: [options.cwd ?? process.cwd()]
19
- });
20
- const packageLoc = pathToFileURL(packageJsonLoc.replace(`package.json`, "dist/index.js"));
21
- const packageImport2 = await import(packageLoc.toString());
22
- return packageImport2;
23
- }
24
- await tryResolve(packageName, options.cwd ?? process.cwd());
12
+ createRequire(options.cwd ?? process.cwd()).resolve(packageName);
25
13
  const packageImport = await import(packageName);
26
14
  return packageImport;
27
15
  } catch (e) {
@@ -45,23 +33,6 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
45
33
  }
46
34
  }
47
35
  }
48
- function tryResolve(packageName, cwd) {
49
- return new Promise((resolve, reject) => {
50
- resolvePackage(
51
- packageName,
52
- {
53
- basedir: cwd
54
- },
55
- (err) => {
56
- if (err) {
57
- reject(err);
58
- } else {
59
- resolve(0);
60
- }
61
- }
62
- );
63
- });
64
- }
65
36
  function getInstallCommand(packages, packageManager) {
66
37
  switch (packageManager) {
67
38
  case "npm":
@@ -3,5 +3,5 @@ import type { AstroInlineConfig, AstroUserConfig } from '../@types/astro.js';
3
3
  export declare function defineConfig(config: AstroUserConfig): AstroUserConfig;
4
4
  export declare function getViteConfig(userViteConfig: ViteUserConfig, inlineAstroConfig?: AstroInlineConfig): ({ mode, command }: {
5
5
  mode: string;
6
- command: 'serve' | 'build';
6
+ command: "serve" | "build";
7
7
  }) => Promise<Record<string, any>>;
@@ -37,7 +37,7 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
37
37
  astroContentListenPlugin({ settings, logger, fs })
38
38
  ]
39
39
  },
40
- { settings, logger, mode }
40
+ { settings, logger, mode, sync: false }
41
41
  );
42
42
  await runHookConfigDone({ settings, logger });
43
43
  return mergeConfig(viteConfig, userViteConfig);
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import type { Plugin } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -2,10 +2,10 @@ import type { PluginContext } from 'rollup';
2
2
  import { z } from 'zod';
3
3
  export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
4
4
  ASTRO_ASSET: string;
5
- format: "jpeg" | "jpg" | "png" | "tiff" | "webp" | "gif" | "svg" | "avif";
5
+ format: import("../assets/types.js").ImageInputFormat;
6
6
  width: number;
7
7
  height: number;
8
8
  src: string;
9
9
  fsPath: string;
10
- orientation?: number | undefined;
10
+ orientation?: number;
11
11
  }, string>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import type { ViteDevServer } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import { type ViteDevServer } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -22,7 +21,7 @@ export declare function createContentTypesGenerator({ contentConfigObserver, fs,
22
21
  typesGenerated: true;
23
22
  } | {
24
23
  typesGenerated: false;
25
- reason: 'no-content-dir';
24
+ reason: "no-content-dir";
26
25
  }>;
27
26
  queueEvent: (rawEvent: RawContentEvent) => void;
28
27
  }>;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import fsMod from 'node:fs';
3
2
  import matter from 'gray-matter';
4
3
  import type { PluginContext } from 'rollup';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import type { Plugin } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import nodeFs from 'node:fs';
3
2
  import { type Plugin } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { OutgoingHttpHeaders } from 'node:http';
3
2
  /**
4
3
  * Takes in a nullable WebAPI Headers object and produces a NodeJS OutgoingHttpHeaders object suitable for usage
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
2
  import type { RouteData } from '../../@types/astro.js';
4
3
  import { App } from './index.js';
@@ -85,7 +85,7 @@ class AstroBuilder {
85
85
  middlewareMode: true
86
86
  }
87
87
  },
88
- { settings: this.settings, logger: this.logger, mode: "build", command: "build" }
88
+ { settings: this.settings, logger: this.logger, mode: "build", command: "build", sync: false }
89
89
  );
90
90
  await runHookConfigDone({ settings: this.settings, logger });
91
91
  const { syncContentCollections } = await import("../sync/index.js");
@@ -20,7 +20,7 @@ function isPropagatedAsset(id) {
20
20
  function vitePluginAnalyzer(options, internals) {
21
21
  function hoistedScriptScanner() {
22
22
  const uniqueHoistedIds = /* @__PURE__ */ new Map();
23
- const pageScripts = /* @__PURE__ */ new Map();
23
+ const pageScriptsMap = /* @__PURE__ */ new Map();
24
24
  return {
25
25
  async scan(scripts, from) {
26
26
  const hoistedScripts = /* @__PURE__ */ new Set();
@@ -31,20 +31,22 @@ function vitePluginAnalyzer(options, internals) {
31
31
  if (hoistedScripts.size) {
32
32
  for (const parentInfo of getParentModuleInfos(from, this, isPropagatedAsset)) {
33
33
  if (isPropagatedAsset(parentInfo.id)) {
34
+ if (!internals.propagatedScriptsMap.has(parentInfo.id)) {
35
+ internals.propagatedScriptsMap.set(parentInfo.id, /* @__PURE__ */ new Set());
36
+ }
37
+ const propagatedScripts = internals.propagatedScriptsMap.get(parentInfo.id);
34
38
  for (const hid of hoistedScripts) {
35
- if (!internals.propagatedScriptsMap.has(parentInfo.id)) {
36
- internals.propagatedScriptsMap.set(parentInfo.id, /* @__PURE__ */ new Set());
37
- }
38
- internals.propagatedScriptsMap.get(parentInfo.id)?.add(hid);
39
+ propagatedScripts.add(hid);
39
40
  }
40
41
  } else if (moduleIsTopLevelPage(parentInfo)) {
42
+ if (!pageScriptsMap.has(parentInfo.id)) {
43
+ pageScriptsMap.set(parentInfo.id, {
44
+ hoistedSet: /* @__PURE__ */ new Set()
45
+ });
46
+ }
47
+ const pageScripts = pageScriptsMap.get(parentInfo.id);
41
48
  for (const hid of hoistedScripts) {
42
- if (!pageScripts.has(parentInfo.id)) {
43
- pageScripts.set(parentInfo.id, {
44
- hoistedSet: /* @__PURE__ */ new Set()
45
- });
46
- }
47
- pageScripts.get(parentInfo.id)?.hoistedSet.add(hid);
49
+ pageScripts.hoistedSet.add(hid);
48
50
  }
49
51
  }
50
52
  }
@@ -56,7 +58,7 @@ function vitePluginAnalyzer(options, internals) {
56
58
  internals.discoveredScripts.add(propagatedScript);
57
59
  }
58
60
  }
59
- for (const [pageId, { hoistedSet }] of pageScripts) {
61
+ for (const [pageId, { hoistedSet }] of pageScriptsMap) {
60
62
  const pageData = getPageDataByViteID(internals, pageId);
61
63
  if (!pageData) continue;
62
64
  const { component } = pageData;
@@ -378,11 +378,13 @@ function pluginContent(opts, internals) {
378
378
  if (!isContentCollectionsCacheEnabled(opts.settings.config)) {
379
379
  return;
380
380
  }
381
+ const promises = [];
381
382
  for (const { cached, dist } of cachedBuildOutput) {
382
383
  if (fsMod.existsSync(dist)) {
383
- await copyFiles(dist, cached, true);
384
+ promises.push(copyFiles(dist, cached, true));
384
385
  }
385
386
  }
387
+ if (promises.length) await Promise.all(promises);
386
388
  }
387
389
  }
388
390
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { Arguments as Flags } from 'yargs-parser';
3
2
  import type { AstroConfig, AstroInlineConfig, AstroUserConfig, CLIFlags } from '../../@types/astro.js';
4
3
  import fs from 'node:fs';
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type { ShikiConfig, RehypePlugin as _RehypePlugin, RemarkPlugin as _RemarkPlugin, RemarkRehype as _RemarkRehype } from '@astrojs/markdown-remark';
4
2
  import type { ViteUserConfig } from '../../@types/astro.js';
5
3
  import type { OutgoingHttpHeaders } from 'node:http';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsType from 'node:fs';
3
2
  interface LoadConfigWithViteOptions {
4
3
  root: string;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.11.0";
1
+ const ASTRO_VERSION = "4.11.2";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -1,5 +1,5 @@
1
1
  import { AstroCookies } from './cookies.js';
2
2
  export declare function attachCookiesToResponse(response: Response, cookies: AstroCookies): void;
3
3
  export declare function responseHasCookies(response: Response): boolean;
4
- export declare function getFromResponse(response: Response): AstroCookies | undefined;
4
+ export declare function getCookiesFromResponse(response: Response): AstroCookies | undefined;
5
5
  export declare function getSetCookiesFromResponse(response: Response): Generator<string, string[]>;
@@ -6,7 +6,7 @@ function attachCookiesToResponse(response, cookies) {
6
6
  function responseHasCookies(response) {
7
7
  return Reflect.has(response, astroCookiesSymbol);
8
8
  }
9
- function getFromResponse(response) {
9
+ function getCookiesFromResponse(response) {
10
10
  let cookies = Reflect.get(response, astroCookiesSymbol);
11
11
  if (cookies != null) {
12
12
  return cookies;
@@ -15,7 +15,7 @@ function getFromResponse(response) {
15
15
  }
16
16
  }
17
17
  function* getSetCookiesFromResponse(response) {
18
- const cookies = getFromResponse(response);
18
+ const cookies = getCookiesFromResponse(response);
19
19
  if (!cookies) {
20
20
  return [];
21
21
  }
@@ -26,7 +26,7 @@ function* getSetCookiesFromResponse(response) {
26
26
  }
27
27
  export {
28
28
  attachCookiesToResponse,
29
- getFromResponse,
29
+ getCookiesFromResponse,
30
30
  getSetCookiesFromResponse,
31
31
  responseHasCookies
32
32
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import nodeFs from 'node:fs';
3
2
  import * as vite from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -9,7 +8,8 @@ interface CreateViteOptions {
9
8
  mode: 'dev' | 'build' | string;
10
9
  command?: 'dev' | 'build';
11
10
  fs?: typeof nodeFs;
11
+ sync: boolean;
12
12
  }
13
13
  /** Return a base vite config as a common starting point for all Vite commands. */
14
- export declare function createVite(commandConfig: vite.InlineConfig, { settings, logger, mode, command, fs }: CreateViteOptions): Promise<vite.InlineConfig>;
14
+ export declare function createVite(commandConfig: vite.InlineConfig, { settings, logger, mode, command, fs, sync }: CreateViteOptions): Promise<vite.InlineConfig>;
15
15
  export {};
@@ -54,7 +54,7 @@ const ONLY_DEV_EXTERNAL = [
54
54
  // Imported by `astro/assets` -> `packages/astro/src/core/logger/core.ts`
55
55
  "string-width"
56
56
  ];
57
- async function createVite(commandConfig, { settings, logger, mode, command, fs = nodeFs }) {
57
+ async function createVite(commandConfig, { settings, logger, mode, command, fs = nodeFs, sync }) {
58
58
  const astroPkgsConfig = await crawlFrameworkPkgs({
59
59
  root: fileURLToPath(settings.config.root),
60
60
  isBuild: mode === "build",
@@ -112,7 +112,7 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
112
112
  // the build to run very slow as the filewatcher is triggered often.
113
113
  mode !== "build" && vitePluginAstroServer({ settings, logger, fs }),
114
114
  envVitePlugin({ settings }),
115
- astroEnv({ settings, mode, fs }),
115
+ astroEnv({ settings, mode, fs, sync }),
116
116
  markdownVitePlugin({ settings, logger }),
117
117
  htmlVitePlugin(),
118
118
  mdxVitePlugin(),
@@ -1,6 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
1
  import type * as http from 'node:http';
5
2
  import type { AddressInfo } from 'node:net';
6
3
  import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
@@ -38,7 +38,7 @@ async function createContainer({
38
38
  include: rendererClientEntries
39
39
  }
40
40
  },
41
- { settings, logger, mode: "dev", command: "dev", fs }
41
+ { settings, logger, mode: "dev", command: "dev", fs, sync: false }
42
42
  );
43
43
  await runHookConfigDone({ settings, logger });
44
44
  const viteServer = await vite.createServer(viteConfig);
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import type http from 'node:http';
4
2
  import type { AddressInfo } from 'node:net';
5
3
  import type * as vite from 'vite';
@@ -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.11.0";
22
+ const currentVersion = "4.11.2";
23
23
  const isPrerelease = currentVersion.includes("-");
24
24
  if (!isPrerelease) {
25
25
  try {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type nodeFs from 'node:fs';
3
2
  import type { AstroInlineConfig } from '../../@types/astro.js';
4
3
  import type { Container } from './container.js';
@@ -478,7 +478,7 @@ export declare const InvalidImageService: {
478
478
  export declare const MissingImageDimension: {
479
479
  name: string;
480
480
  title: string;
481
- message: (missingDimension: 'width' | 'height' | 'both', imageURL: string) => string;
481
+ message: (missingDimension: "width" | "height" | "both", imageURL: string) => string;
482
482
  hint: string;
483
483
  };
484
484
  /**
@@ -37,7 +37,7 @@ function serverStart({
37
37
  host,
38
38
  base
39
39
  }) {
40
- const version = "4.11.0";
40
+ const version = "4.11.2";
41
41
  const localPrefix = `${dim("\u2503")} Local `;
42
42
  const networkPrefix = `${dim("\u2503")} Network `;
43
43
  const emptyPrefix = " ".repeat(11);
@@ -269,7 +269,7 @@ function printHelp({
269
269
  message.push(
270
270
  linebreak(),
271
271
  ` ${bgGreen(black(` ${commandName} `))} ${green(
272
- `v${"4.11.0"}`
272
+ `v${"4.11.2"}`
273
273
  )} ${headline}`
274
274
  );
275
275
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type * as fs from 'node:fs';
3
2
  import type { TypedEventEmitter } from '../../@types/typed-emitter.js';
4
3
  export type LoaderEvents = {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type http from 'node:http';
3
2
  import type { AstroSettings } from '../../@types/astro.js';
4
3
  import type { Logger } from '../logger/core.js';
@@ -15,7 +15,7 @@ import {
15
15
  responseSentSymbol
16
16
  } from "./constants.js";
17
17
  import { AstroCookies, attachCookiesToResponse } from "./cookies/index.js";
18
- import { getFromResponse } from "./cookies/response.js";
18
+ import { getCookiesFromResponse } from "./cookies/response.js";
19
19
  import { AstroError, AstroErrorData } from "./errors/index.js";
20
20
  import { callMiddleware } from "./middleware/callMiddleware.js";
21
21
  import { sequence } from "./middleware/index.js";
@@ -104,6 +104,7 @@ class RenderContext {
104
104
  const lastNext = async (ctx, payload) => {
105
105
  if (payload) {
106
106
  if (this.pipeline.manifest.rewritingEnabled) {
107
+ pipeline.logger.debug("router", "Called rewriting to:", payload);
107
108
  const [routeData, component] = await pipeline.tryRewrite(
108
109
  payload,
109
110
  this.request,
@@ -152,7 +153,7 @@ class RenderContext {
152
153
  return new Response(null, { status: 500, headers: { [ROUTE_TYPE_HEADER]: "fallback" } });
153
154
  }
154
155
  }
155
- const responseCookies = getFromResponse(response2);
156
+ const responseCookies = getCookiesFromResponse(response2);
156
157
  if (responseCookies) {
157
158
  cookies.merge(responseCookies);
158
159
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { IncomingHttpHeaders } from 'node:http';
3
2
  import type { Logger } from './logger/core.js';
4
3
  type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { AstroConfig, AstroSettings, ManifestData, RoutePart } from '../../../@types/astro.js';
3
2
  import type { Logger } from '../../logger/core.js';
4
3
  import nodeFs from 'node:fs';
@@ -6,6 +6,7 @@ import { createServer } from "vite";
6
6
  import { getPackage } from "../../cli/install-package.js";
7
7
  import { createContentTypesGenerator } from "../../content/index.js";
8
8
  import { globalContentConfigObserver } from "../../content/utils.js";
9
+ import { syncAstroEnv } from "../../env/sync.js";
9
10
  import { telemetry } from "../../events/index.js";
10
11
  import { eventCliSession } from "../../events/session.js";
11
12
  import { runHookConfigSetup } from "../../integrations/hooks.js";
@@ -50,6 +51,7 @@ async function sync(inlineConfig, options) {
50
51
  await dbPackage?.typegen?.(astroConfig);
51
52
  const exitCode = await syncContentCollections(settings, { ...options, logger });
52
53
  if (exitCode !== 0) return exitCode;
54
+ syncAstroEnv(settings, options?.fs);
53
55
  logger.info(null, `Types generated ${dim(getTimeStat(timerStart, performance.now()))}`);
54
56
  return 0;
55
57
  } catch (err) {
@@ -70,7 +72,7 @@ async function syncContentCollections(settings, { logger, fs }) {
70
72
  ssr: { external: [] },
71
73
  logLevel: "silent"
72
74
  },
73
- { settings, logger, mode: "build", command: "build", fs }
75
+ { settings, logger, mode: "build", command: "build", fs, sync: true }
74
76
  )
75
77
  );
76
78
  const hotSend = tempViteServer.hot.send;
@@ -0,0 +1,3 @@
1
+ import fsMod from 'node:fs';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
+ export declare function syncAstroEnv(settings: AstroSettings, fs?: typeof fsMod): void;
@@ -0,0 +1,27 @@
1
+ import fsMod from "node:fs";
2
+ import { ENV_TYPES_FILE, TYPES_TEMPLATE_URL } from "./constants.js";
3
+ import { getEnvFieldType } from "./validators.js";
4
+ function syncAstroEnv(settings, fs = fsMod) {
5
+ if (!settings.config.experimental.env) {
6
+ return;
7
+ }
8
+ const schema = settings.config.experimental.env.schema ?? {};
9
+ let client = "";
10
+ let server = "";
11
+ for (const [key, options] of Object.entries(schema)) {
12
+ const str = `export const ${key}: ${getEnvFieldType(options)};
13
+ `;
14
+ if (options.context === "client") {
15
+ client += str;
16
+ } else {
17
+ server += str;
18
+ }
19
+ }
20
+ const template = fs.readFileSync(TYPES_TEMPLATE_URL, "utf-8");
21
+ const dts = template.replace("// @@CLIENT@@", client).replace("// @@SERVER@@", server);
22
+ fs.mkdirSync(settings.dotAstroDir, { recursive: true });
23
+ fs.writeFileSync(new URL(ENV_TYPES_FILE, settings.dotAstroDir), dts, "utf-8");
24
+ }
25
+ export {
26
+ syncAstroEnv
27
+ };
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import { type Plugin } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -6,6 +5,7 @@ interface AstroEnvVirtualModPluginParams {
6
5
  settings: AstroSettings;
7
6
  mode: 'dev' | 'build' | string;
8
7
  fs: typeof fsMod;
8
+ sync: boolean;
9
9
  }
10
- export declare function astroEnv({ settings, mode, fs, }: AstroEnvVirtualModPluginParams): Plugin | undefined;
10
+ export declare function astroEnv({ settings, mode, fs, sync, }: AstroEnvVirtualModPluginParams): Plugin | undefined;
11
11
  export {};
@@ -2,19 +2,18 @@ import { fileURLToPath } from "node:url";
2
2
  import { loadEnv } from "vite";
3
3
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
4
4
  import {
5
- ENV_TYPES_FILE,
6
5
  MODULE_TEMPLATE_URL,
7
- TYPES_TEMPLATE_URL,
8
6
  VIRTUAL_MODULES_IDS,
9
7
  VIRTUAL_MODULES_IDS_VALUES
10
8
  } from "./constants.js";
11
- import { getEnvFieldType, validateEnvVariable } from "./validators.js";
9
+ import { validateEnvVariable } from "./validators.js";
12
10
  function astroEnv({
13
11
  settings,
14
12
  mode,
15
- fs
13
+ fs,
14
+ sync
16
15
  }) {
17
- if (!settings.config.experimental.env) {
16
+ if (!settings.config.experimental.env || sync) {
18
17
  return;
19
18
  }
20
19
  const schema = settings.config.experimental.env.schema ?? {};
@@ -34,22 +33,10 @@ function astroEnv({
34
33
  }
35
34
  }
36
35
  const validatedVariables = validatePublicVariables({ schema, loadedEnv });
37
- const clientTemplates = getClientTemplates({ validatedVariables });
38
- const serverTemplates = getServerTemplates({ validatedVariables, schema, fs });
39
36
  templates = {
40
- client: clientTemplates.module,
41
- server: serverTemplates.module,
37
+ ...getTemplates(schema, fs, validatedVariables),
42
38
  internal: `export const schema = ${JSON.stringify(schema)};`
43
39
  };
44
- generateDts({
45
- settings,
46
- fs,
47
- content: getDts({
48
- fs,
49
- client: clientTemplates.types,
50
- server: serverTemplates.types
51
- })
52
- });
53
40
  },
54
41
  buildEnd() {
55
42
  templates = null;
@@ -81,14 +68,6 @@ function astroEnv({
81
68
  function resolveVirtualModuleId(id) {
82
69
  return `\0${id}`;
83
70
  }
84
- function generateDts({
85
- content,
86
- settings,
87
- fs
88
- }) {
89
- fs.mkdirSync(settings.dotAstroDir, { recursive: true });
90
- fs.writeFileSync(new URL(ENV_TYPES_FILE, settings.dotAstroDir), content, "utf-8");
91
- }
92
71
  function validatePublicVariables({
93
72
  schema,
94
73
  loadedEnv
@@ -117,57 +96,31 @@ function validatePublicVariables({
117
96
  }
118
97
  return valid;
119
98
  }
120
- function getDts({
121
- client,
122
- server,
123
- fs
124
- }) {
125
- const template = fs.readFileSync(TYPES_TEMPLATE_URL, "utf-8");
126
- return template.replace("// @@CLIENT@@", client).replace("// @@SERVER@@", server);
127
- }
128
- function getClientTemplates({
129
- validatedVariables
130
- }) {
131
- let module = "";
132
- let types = "";
133
- for (const { key, type, value } of validatedVariables.filter((e) => e.context === "client")) {
134
- module += `export const ${key} = ${JSON.stringify(value)};`;
135
- types += `export const ${key}: ${type};
136
- `;
137
- }
138
- return {
139
- module,
140
- types
141
- };
142
- }
143
- function getServerTemplates({
144
- validatedVariables,
145
- schema,
146
- fs
147
- }) {
148
- let module = fs.readFileSync(MODULE_TEMPLATE_URL, "utf-8");
149
- let types = "";
99
+ function getTemplates(schema, fs, validatedVariables) {
100
+ let client = "";
101
+ let server = fs.readFileSync(MODULE_TEMPLATE_URL, "utf-8");
150
102
  let onSetGetEnv = "";
151
- for (const { key, type, value } of validatedVariables.filter((e) => e.context === "server")) {
152
- module += `export const ${key} = ${JSON.stringify(value)};`;
153
- types += `export const ${key}: ${type};
154
- `;
103
+ for (const { key, value, context } of validatedVariables) {
104
+ const str = `export const ${key} = ${JSON.stringify(value)};`;
105
+ if (context === "client") {
106
+ client += str;
107
+ } else {
108
+ server += str;
109
+ }
155
110
  }
156
111
  for (const [key, options] of Object.entries(schema)) {
157
112
  if (!(options.context === "server" && options.access === "secret")) {
158
113
  continue;
159
114
  }
160
- types += `export const ${key}: ${getEnvFieldType(options)};
161
- `;
162
- module += `export let ${key} = _internalGetSecret(${JSON.stringify(key)});
115
+ server += `export let ${key} = _internalGetSecret(${JSON.stringify(key)});
163
116
  `;
164
117
  onSetGetEnv += `${key} = reset ? undefined : _internalGetSecret(${JSON.stringify(key)});
165
118
  `;
166
119
  }
167
- module = module.replace("// @@ON_SET_GET_ENV@@", onSetGetEnv);
120
+ server = server.replace("// @@ON_SET_GET_ENV@@", onSetGetEnv);
168
121
  return {
169
- module,
170
- types
122
+ client,
123
+ server
171
124
  };
172
125
  }
173
126
  export {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { AddressInfo } from 'node:net';
3
2
  import type { InlineConfig, ViteDevServer } from 'vite';
4
3
  import type { AstroAdapter, AstroConfig, AstroSettings, RouteData } from '../@types/astro.js';
@@ -17,7 +16,7 @@ export declare function getToolbarServerCommunicationHelpers(server: ViteDevServ
17
16
  * @param event
18
17
  * @param callback
19
18
  */
20
- on: <T_1>(event: string, callback: (data: T_1) => void) => void;
19
+ on: <T>(event: string, callback: (data: T) => void) => void;
21
20
  /**
22
21
  * Fired when an app is initialized.
23
22
  * @param appId - The id of the app that was initialized
@@ -1,11 +1,5 @@
1
1
  import type { RehypePlugin } from '@astrojs/markdown-remark';
2
2
  import type { VFile } from 'vfile';
3
+ import type { PluginMetadata } from '../vite-plugin-astro/types.js';
3
4
  export declare const rehypeAnalyzeAstroMetadata: RehypePlugin;
4
- export declare function getAstroMetadata(file: VFile): {
5
- hydratedComponents: import("@astrojs/compiler/types").HydratedComponent[];
6
- clientOnlyComponents: import("@astrojs/compiler/types").HydratedComponent[];
7
- scripts: import("@astrojs/compiler").HoistedScript[];
8
- containsHead: boolean;
9
- propagation: import("../@types/astro.js").PropagationHint;
10
- pageOptions: import("../vite-plugin-astro/types.js").PageOptions;
11
- } | undefined;
5
+ export declare function getAstroMetadata(file: VFile): PluginMetadata["astro"] | undefined;
@@ -55,7 +55,7 @@ export declare const serverHelpers: {
55
55
  * @param callback - The callback to run when the event is received.
56
56
  * The payload's content will be passed to the callback as an argument
57
57
  */
58
- on: <T_1>(event: string, callback: (data: T_1) => void) => void;
58
+ on: <T>(event: string, callback: (data: T) => void) => void;
59
59
  };
60
60
  export type ToolbarServerHelpers = typeof serverHelpers;
61
61
  export {};
@@ -13,7 +13,7 @@ export declare const settings: {
13
13
  readonly config: Settings;
14
14
  updateSetting: <Key extends keyof Settings>(key: Key, value: Settings[Key]) => void;
15
15
  logger: {
16
- log: (message: string, level?: 'log' | 'warn' | 'error') => void;
16
+ log: (message: string, level?: "log" | "warn" | "error") => void;
17
17
  warn: (message: string) => void;
18
18
  error: (message: string) => void;
19
19
  verboseLog: (message: string) => void;
@@ -33,7 +33,7 @@ class DevToolbarTooltip extends HTMLElement {
33
33
 
34
34
  svg {
35
35
  vertical-align: bottom;
36
- margin-right: 4px;
36
+ margin-inline-end: 4px;
37
37
  }
38
38
 
39
39
  hr {
@@ -53,8 +53,17 @@ async function renderPage(result, componentFactory, props, children, streaming,
53
53
  if (route?.component.endsWith(".md")) {
54
54
  headers.set("Content-Type", "text/html; charset=utf-8");
55
55
  }
56
- const response = new Response(body, { ...init, headers });
57
- return response;
56
+ let status = init.status;
57
+ if (route?.route === "/404") {
58
+ status = 404;
59
+ } else if (route?.route === "/500") {
60
+ status = 500;
61
+ }
62
+ if (status) {
63
+ return new Response(body, { ...init, headers, status });
64
+ } else {
65
+ return new Response(body, { ...init, headers });
66
+ }
58
67
  }
59
68
  export {
60
69
  renderPage
@@ -1,4 +1,3 @@
1
- /// <reference types="@types/dom-view-transitions" />
2
1
  import type { Direction, NavigationTypeString } from './types.js';
3
2
  export declare const TRANSITION_BEFORE_PREPARATION = "astro:before-preparation";
4
3
  export declare const TRANSITION_AFTER_PREPARATION = "astro:after-preparation";
@@ -268,7 +268,12 @@ async function transition(direction, from, to, options, historyState) {
268
268
  return;
269
269
  }
270
270
  if (response.redirected) {
271
- preparationEvent.to = new URL(response.redirected);
271
+ const redirectedTo = new URL(response.redirected);
272
+ if (redirectedTo.origin !== preparationEvent.to.origin) {
273
+ preparationEvent.preventDefault();
274
+ return;
275
+ }
276
+ preparationEvent.to = redirectedTo;
272
277
  }
273
278
  parser ??= new DOMParser();
274
279
  preparationEvent.newDocument = parser.parseFromString(response.html, response.mediaType);
@@ -9,9 +9,6 @@ function recordServerError(loader, config, { logger }, _err) {
9
9
  } catch {
10
10
  }
11
11
  const errorWithMetadata = collectErrorMetadata(err, config.root);
12
- if (errorWithMetadata.name !== AstroErrorData.UnhandledRejection.name) {
13
- telemetry.record(eventError({ cmd: "dev", err: errorWithMetadata, isFatal: false }));
14
- }
15
12
  logger.error(null, formatErrorMessage(errorWithMetadata, logger.level() === "debug"));
16
13
  return {
17
14
  error: err,
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fs from 'node:fs';
3
2
  import type * as vite from 'vite';
4
3
  import type { AstroSettings, SSRManifest } from '../@types/astro.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type http from 'node:http';
3
2
  import type { ManifestData } from '../@types/astro.js';
4
3
  import type { DevServerController } from './controller.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type http from 'node:http';
3
2
  import type { ErrorWithMetadata } from '../core/errors/index.js';
4
3
  import type { ModuleLoader } from '../core/module-loader/index.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type http from 'node:http';
3
2
  import type { ComponentInstance, ManifestData, RouteData } from '../@types/astro.js';
4
3
  import type { DevPipeline } from './pipeline.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type fsMod from 'node:fs';
3
2
  import { type Plugin } from 'vite';
4
3
  import type { AstroSettings } from '../@types/astro.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import nodeFs from 'node:fs';
3
2
  import type * as vite from 'vite';
4
3
  type NodeFileSystemModule = typeof nodeFs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.11.0",
3
+ "version": "4.11.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",
@@ -109,7 +109,7 @@
109
109
  "vendor"
110
110
  ],
111
111
  "dependencies": {
112
- "@astrojs/compiler": "^2.8.0",
112
+ "@astrojs/compiler": "^2.8.1",
113
113
  "@babel/core": "^7.24.7",
114
114
  "@babel/generator": "^7.24.7",
115
115
  "@babel/parser": "^7.24.7",
@@ -134,7 +134,7 @@
134
134
  "diff": "^5.2.0",
135
135
  "dlv": "^1.1.3",
136
136
  "dset": "^3.1.3",
137
- "es-module-lexer": "^1.5.3",
137
+ "es-module-lexer": "^1.5.4",
138
138
  "esbuild": "^0.21.5",
139
139
  "estree-walker": "^3.0.3",
140
140
  "execa": "^8.0.1",
@@ -155,9 +155,8 @@
155
155
  "preferred-pm": "^3.1.3",
156
156
  "prompts": "^2.4.2",
157
157
  "rehype": "^13.0.1",
158
- "resolve": "^1.22.8",
159
158
  "semver": "^7.6.2",
160
- "shiki": "^1.6.5",
159
+ "shiki": "^1.9.0",
161
160
  "string-width": "^7.1.0",
162
161
  "strip-ansi": "^7.1.0",
163
162
  "tsconfck": "^3.1.0",
@@ -168,9 +167,9 @@
168
167
  "which-pm": "^2.2.0",
169
168
  "yargs-parser": "^21.1.1",
170
169
  "zod": "^3.23.8",
171
- "zod-to-json-schema": "^3.23.0",
172
- "@astrojs/markdown-remark": "5.1.0",
173
- "@astrojs/internal-helpers": "0.4.0",
170
+ "zod-to-json-schema": "^3.23.1",
171
+ "@astrojs/internal-helpers": "0.4.1",
172
+ "@astrojs/markdown-remark": "5.1.1",
174
173
  "@astrojs/telemetry": "3.1.0"
175
174
  },
176
175
  "optionalDependencies": {
@@ -195,7 +194,6 @@
195
194
  "@types/js-yaml": "^4.0.9",
196
195
  "@types/probe-image-size": "^7.2.4",
197
196
  "@types/prompts": "^2.4.9",
198
- "@types/resolve": "^1.20.6",
199
197
  "@types/semver": "^7.5.8",
200
198
  "@types/send": "^0.17.4",
201
199
  "@types/unist": "^3.0.2",
@@ -205,17 +203,17 @@
205
203
  "mdast-util-mdx": "^3.0.0",
206
204
  "mdast-util-mdx-jsx": "^3.1.2",
207
205
  "memfs": "^4.9.3",
208
- "node-mocks-http": "^1.14.1",
206
+ "node-mocks-http": "^1.15.0",
209
207
  "parse-srcset": "^1.0.2",
210
208
  "rehype-autolink-headings": "^7.1.0",
211
209
  "rehype-slug": "^6.0.0",
212
210
  "rehype-toc": "^3.0.2",
213
211
  "remark-code-titles": "^0.1.2",
214
212
  "rollup": "^4.18.0",
215
- "sass": "^1.77.5",
213
+ "sass": "^1.77.6",
216
214
  "srcset-parse": "^1.1.0",
217
215
  "undici": "^6.19.2",
218
- "unified": "^11.0.4",
216
+ "unified": "^11.0.5",
219
217
  "astro-scripts": "0.0.14"
220
218
  },
221
219
  "engines": {