astro 6.0.0-alpha.2 → 6.0.0-alpha.4

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 (55) hide show
  1. package/dist/cli/add/index.js +7 -10
  2. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  3. package/dist/config/entrypoint.d.ts +1 -0
  4. package/dist/config/entrypoint.js +2 -0
  5. package/dist/config/index.d.ts +3 -2
  6. package/dist/content/content-layer.js +3 -3
  7. package/dist/core/app/base.js +1 -1
  8. package/dist/core/app/dev/app.d.ts +6 -3
  9. package/dist/core/app/dev/app.js +6 -12
  10. package/dist/core/app/dev/pipeline.d.ts +6 -3
  11. package/dist/core/app/dev/pipeline.js +4 -4
  12. package/dist/core/app/types.d.ts +8 -4
  13. package/dist/core/base-pipeline.d.ts +5 -5
  14. package/dist/core/build/plugins/plugin-manifest.js +2 -1
  15. package/dist/core/config/schemas/base.d.ts +10 -20
  16. package/dist/core/config/schemas/base.js +2 -19
  17. package/dist/core/config/schemas/relative.d.ts +26 -25
  18. package/dist/core/constants.js +1 -1
  19. package/dist/core/dev/dev.js +1 -1
  20. package/dist/core/errors/zod-error-map.js +6 -3
  21. package/dist/core/messages.d.ts +0 -8
  22. package/dist/core/messages.js +2 -13
  23. package/dist/core/preview/index.js +2 -13
  24. package/dist/core/render-context.d.ts +1 -1
  25. package/dist/core/render-context.js +7 -6
  26. package/dist/core/routing/helpers.d.ts +3 -0
  27. package/dist/core/routing/helpers.js +9 -0
  28. package/dist/core/session/config.d.ts +27 -0
  29. package/dist/core/session/config.js +33 -0
  30. package/dist/core/session/drivers.d.ts +34 -0
  31. package/dist/core/session/drivers.js +20 -0
  32. package/dist/core/{session.d.ts → session/runtime.d.ts} +13 -6
  33. package/dist/core/{session.js → session/runtime.js} +25 -19
  34. package/dist/core/session/types.d.ts +67 -0
  35. package/dist/core/session/types.js +0 -0
  36. package/dist/core/session/utils.d.ts +7 -0
  37. package/dist/core/session/utils.js +48 -0
  38. package/dist/core/session/vite-plugin.js +22 -27
  39. package/dist/manifest/serialized.js +2 -1
  40. package/dist/prerender/routing.d.ts +2 -2
  41. package/dist/runtime/server/render/page.js +2 -1
  42. package/dist/types/public/config.d.ts +22 -49
  43. package/dist/types/public/context.d.ts +1 -1
  44. package/dist/types/public/index.d.ts +2 -1
  45. package/dist/types/public/index.js +0 -4
  46. package/dist/types/public/preview.d.ts +1 -5
  47. package/dist/vite-plugin-app/app.d.ts +4 -20
  48. package/dist/vite-plugin-app/app.js +73 -231
  49. package/dist/vite-plugin-app/pipeline.d.ts +5 -2
  50. package/dist/vite-plugin-app/pipeline.js +4 -4
  51. package/dist/vite-plugin-astro-server/plugin.js +2 -1
  52. package/dist/vite-plugin-astro-server/response.d.ts +0 -1
  53. package/dist/vite-plugin-astro-server/response.js +1 -2
  54. package/dist/vite-plugin-environment/index.js +1 -0
  55. package/package.json +3 -3
@@ -63,20 +63,17 @@ export default async function seed() {
63
63
  }
64
64
  `,
65
65
  CLOUDFLARE_WRANGLER_CONFIG: (name) => `{
66
- "main": "dist/_worker.js/index.js",
66
+ "compatibility_date": ${JSON.stringify((/* @__PURE__ */ new Date()).toISOString().slice(0, 10))},
67
+ "compatibility_flags": ["global_fetch_strictly_public"],
67
68
  "name": ${JSON.stringify(name)},
68
- "compatibility_date": ${JSON.stringify((/* @__PURE__ */ new Date()).toISOString().slice(0, 10))},
69
- "compatibility_flags": [
70
- "nodejs_compat",
71
- "global_fetch_strictly_public"
72
- ],
69
+ "main": "@astrojs/cloudflare/entrypoints/server",
73
70
  "assets": {
74
- "binding": "ASSETS",
75
- "directory": "./dist"
71
+ "directory": "./dist",
72
+ "binding": "ASSETS"
76
73
  },
77
74
  "observability": {
78
- "enabled": true
79
- }
75
+ "enabled": true
76
+ }
80
77
  }`,
81
78
  CLOUDFLARE_ASSETSIGNORE: `_worker.js
82
79
  _routes.json`
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "6.0.0-alpha.2";
3
+ version = "6.0.0-alpha.4";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -6,6 +6,7 @@ export { mergeConfig } from '../core/config/merge.js';
6
6
  export { validateConfig } from '../core/config/validate.js';
7
7
  export { envField } from '../env/config.js';
8
8
  export { defineConfig, getViteConfig } from './index.js';
9
+ export { sessionDrivers } from '../core/session/drivers.js';
9
10
  /**
10
11
  * Return the configuration needed to use the Sharp-based image service
11
12
  */
@@ -3,6 +3,7 @@ import { mergeConfig } from "../core/config/merge.js";
3
3
  import { validateConfig } from "../core/config/validate.js";
4
4
  import { envField } from "../env/config.js";
5
5
  import { defineConfig, getViteConfig } from "./index.js";
6
+ import { sessionDrivers } from "../core/session/drivers.js";
6
7
  function sharpImageService(config = {}) {
7
8
  return {
8
9
  entrypoint: "astro/assets/services/sharp",
@@ -23,6 +24,7 @@ export {
23
24
  getViteConfig,
24
25
  mergeConfig,
25
26
  passthroughImageService,
27
+ sessionDrivers,
26
28
  sharpImageService,
27
29
  validateConfig
28
30
  };
@@ -1,10 +1,11 @@
1
1
  import type { UserConfig as ViteUserConfig, UserConfigFn as ViteUserConfigFn } from 'vite';
2
- import type { AstroInlineConfig, AstroUserConfig, Locales, SessionDriverName } from '../types/public/config.js';
2
+ import type { AstroInlineConfig, AstroUserConfig, Locales } from '../types/public/config.js';
3
+ import type { SessionDriverConfig, SessionDriverName } from '../core/session/types.js';
3
4
  /**
4
5
  * See the full Astro Configuration API Documentation
5
6
  * https://astro.build/config
6
7
  */
7
- export declare function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName = never>(config: AstroUserConfig<TLocales, TDriver>): AstroUserConfig<TLocales, TDriver>;
8
+ export declare function defineConfig<const TLocales extends Locales = never, const TDriver extends SessionDriverName | SessionDriverConfig = never>(config: AstroUserConfig<TLocales, TDriver>): AstroUserConfig<TLocales, TDriver>;
8
9
  /**
9
10
  * Use Astro to generate a fully resolved Vite config
10
11
  */
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
164
164
  logger.info("Content config changed");
165
165
  shouldClear = true;
166
166
  }
167
- if (previousAstroVersion && previousAstroVersion !== "6.0.0-alpha.2") {
167
+ if (previousAstroVersion && previousAstroVersion !== "6.0.0-alpha.4") {
168
168
  logger.info("Astro version changed");
169
169
  shouldClear = true;
170
170
  }
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
172
172
  logger.info("Clearing content store");
173
173
  this.#store.clearAll();
174
174
  }
175
- if ("6.0.0-alpha.2") {
176
- await this.#store.metaStore().set("astro-version", "6.0.0-alpha.2");
175
+ if ("6.0.0-alpha.4") {
176
+ await this.#store.metaStore().set("astro-version", "6.0.0-alpha.4");
177
177
  }
178
178
  if (currentConfigDigest) {
179
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -24,7 +24,7 @@ import { RenderContext } from "../render-context.js";
24
24
  import { redirectTemplate } from "../routing/3xx.js";
25
25
  import { ensure404Route } from "../routing/astro-designed-error-pages.js";
26
26
  import { matchRoute } from "../routing/match.js";
27
- import { PERSIST_SYMBOL } from "../session.js";
27
+ import { PERSIST_SYMBOL } from "../session/runtime.js";
28
28
  class BaseApp {
29
29
  manifest;
30
30
  manifestData;
@@ -3,12 +3,15 @@ import type { Logger } from '../../logger/core.js';
3
3
  import type { CreateRenderContext, RenderContext } from '../../render-context.js';
4
4
  import { BaseApp, type RenderErrorOptions } from '../base.js';
5
5
  import type { SSRManifest } from '../types.js';
6
- import { DevPipeline } from './pipeline.js';
7
- export declare class DevApp extends BaseApp<DevPipeline> {
6
+ import { NonRunnablePipeline } from './pipeline.js';
7
+ /**
8
+ *
9
+ */
10
+ export declare class DevApp extends BaseApp<NonRunnablePipeline> {
8
11
  logger: Logger;
9
12
  currentRenderContext: RenderContext | undefined;
10
13
  constructor(manifest: SSRManifest, streaming: boolean | undefined, logger: Logger);
11
- createPipeline(streaming: boolean, manifest: SSRManifest, logger: Logger): DevPipeline;
14
+ createPipeline(streaming: boolean, manifest: SSRManifest, logger: Logger): NonRunnablePipeline;
12
15
  match(request: Request): RouteData | undefined;
13
16
  createRenderContext(payload: CreateRenderContext): Promise<RenderContext>;
14
17
  renderError(request: Request, { locals, skipMiddleware, error, clientAddress, status }: RenderErrorOptions): Promise<Response>;
@@ -1,8 +1,8 @@
1
1
  import { MiddlewareNoDataOrNextCalled, MiddlewareNotAResponse } from "../../errors/errors-data.js";
2
2
  import { isAstroError } from "../../errors/index.js";
3
- import { isRoute404, isRoute500 } from "../../routing/match.js";
4
3
  import { BaseApp } from "../base.js";
5
- import { DevPipeline } from "./pipeline.js";
4
+ import { NonRunnablePipeline } from "./pipeline.js";
5
+ import { getCustom404Route, getCustom500Route } from "../../routing/helpers.js";
6
6
  class DevApp extends BaseApp {
7
7
  logger;
8
8
  currentRenderContext = void 0;
@@ -11,7 +11,7 @@ class DevApp extends BaseApp {
11
11
  this.logger = logger;
12
12
  }
13
13
  createPipeline(streaming, manifest, logger) {
14
- return DevPipeline.create({
14
+ return NonRunnablePipeline.create({
15
15
  logger,
16
16
  manifest,
17
17
  streaming
@@ -62,9 +62,9 @@ class DevApp extends BaseApp {
62
62
  }
63
63
  };
64
64
  if (status === 404) {
65
- const custom400 = getCustom400Route(this.manifestData);
66
- if (custom400) {
67
- return renderRoute(custom400);
65
+ const custom404 = getCustom404Route(this.manifestData);
66
+ if (custom404) {
67
+ return renderRoute(custom404);
68
68
  }
69
69
  }
70
70
  const custom500 = getCustom500Route(this.manifestData);
@@ -75,12 +75,6 @@ class DevApp extends BaseApp {
75
75
  }
76
76
  }
77
77
  }
78
- function getCustom500Route(manifestData) {
79
- return manifestData.routes.find((r) => isRoute500(r.route));
80
- }
81
- function getCustom400Route(manifestData) {
82
- return manifestData.routes.find((r) => isRoute404(r.route));
83
- }
84
78
  export {
85
79
  DevApp
86
80
  };
@@ -1,10 +1,13 @@
1
1
  import type { ComponentInstance } from '../../../types/astro.js';
2
2
  import type { RewritePayload, RouteData } from '../../../types/public/index.js';
3
3
  import { type HeadElements, Pipeline, type TryRewriteResult } from '../../base-pipeline.js';
4
- type DevPipelineCreate = Pick<DevPipeline, 'logger' | 'manifest' | 'streaming'>;
5
- export declare class DevPipeline extends Pipeline {
4
+ type DevPipelineCreate = Pick<NonRunnablePipeline, 'logger' | 'manifest' | 'streaming'>;
5
+ /**
6
+ * A pipeline that can't load modules at runtime using the vite environment APIs
7
+ */
8
+ export declare class NonRunnablePipeline extends Pipeline {
6
9
  getName(): string;
7
- static create({ logger, manifest, streaming }: DevPipelineCreate): DevPipeline;
10
+ static create({ logger, manifest, streaming }: DevPipelineCreate): NonRunnablePipeline;
8
11
  headElements(routeData: RouteData): Promise<HeadElements>;
9
12
  componentMetadata(): void;
10
13
  getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
@@ -2,9 +2,9 @@ import { Pipeline } from "../../base-pipeline.js";
2
2
  import { ASTRO_VERSION } from "../../constants.js";
3
3
  import { createModuleScriptElement, createStylesheetElementSet } from "../../render/ssr-element.js";
4
4
  import { findRouteToRewrite } from "../../routing/rewrite.js";
5
- class DevPipeline extends Pipeline {
5
+ class NonRunnablePipeline extends Pipeline {
6
6
  getName() {
7
- return "DevPipeline";
7
+ return "NonRunnablePipeline";
8
8
  }
9
9
  static create({ logger, manifest, streaming }) {
10
10
  async function resolve(specifier) {
@@ -14,7 +14,7 @@ class DevPipeline extends Pipeline {
14
14
  return "/@id/" + specifier;
15
15
  }
16
16
  }
17
- const pipeline = new DevPipeline(
17
+ const pipeline = new NonRunnablePipeline(
18
18
  logger,
19
19
  manifest,
20
20
  "development",
@@ -119,5 +119,5 @@ class DevPipeline extends Pipeline {
119
119
  }
120
120
  }
121
121
  export {
122
- DevPipeline
122
+ NonRunnablePipeline
123
123
  };
@@ -1,13 +1,13 @@
1
1
  import type { ActionClient } from '../../actions/runtime/types.js';
2
2
  import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
3
3
  import type { AstroMiddlewareInstance } from '../../types/public/common.js';
4
- import type { AstroConfig, CspAlgorithm, Locales, RemotePattern, ResolvedSessionConfig } from '../../types/public/config.js';
4
+ import type { AstroConfig, CspAlgorithm, Locales, RemotePattern } from '../../types/public/config.js';
5
5
  import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
6
6
  import type { SinglePageBuiltModule } from '../build/types.js';
7
7
  import type { CspDirective } from '../csp/config.js';
8
8
  import type { LoggerLevel } from '../logger/core.js';
9
- import type { SessionDriver } from '../session.js';
10
9
  import type { RoutingStrategies } from './common.js';
10
+ import type { BaseSessionConfig, SessionDriverFactory } from '../session/types.js';
11
11
  type ComponentPath = string;
12
12
  export type StylesheetAsset = {
13
13
  type: 'inline';
@@ -81,11 +81,11 @@ export type SSRManifest = {
81
81
  middleware?: () => Promise<AstroMiddlewareInstance> | AstroMiddlewareInstance;
82
82
  actions?: () => Promise<SSRActions> | SSRActions;
83
83
  sessionDriver?: () => Promise<{
84
- default: SessionDriver | null;
84
+ default: SessionDriverFactory | null;
85
85
  }>;
86
86
  checkOrigin: boolean;
87
87
  allowedDomains?: Partial<RemotePattern>[];
88
- sessionConfig?: ResolvedSessionConfig<any>;
88
+ sessionConfig?: SSRManifestSession;
89
89
  cacheDir: URL;
90
90
  srcDir: URL;
91
91
  outDir: URL;
@@ -132,6 +132,10 @@ export type SSRManifestCSP = {
132
132
  styleResources: string[];
133
133
  directives: CspDirective[];
134
134
  };
135
+ export interface SSRManifestSession extends BaseSessionConfig {
136
+ driver: string;
137
+ options?: Record<string, any> | undefined;
138
+ }
135
139
  /** Public type exposed through the `astro:build:ssr` integration hook */
136
140
  export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key' | 'rootDir' | 'srcDir' | 'cacheDir' | 'outDir' | 'publicDir' | 'buildClientDir' | 'buildServerDir'> & {
137
141
  rootDir: string;
@@ -8,7 +8,7 @@ import type { ServerIslandMappings } from './app/types.js';
8
8
  import type { SinglePageBuiltModule } from './build/types.js';
9
9
  import type { Logger } from './logger/core.js';
10
10
  import { RouteCache } from './render/route-cache.js';
11
- import type { SessionDriver } from './session.js';
11
+ import type { SessionDriverFactory } from './session/types.js';
12
12
  /**
13
13
  * The `Pipeline` represents the static parts of rendering that do not change between requests.
14
14
  * These are mostly known when the server first starts up and do not change.
@@ -51,13 +51,13 @@ export declare abstract class Pipeline {
51
51
  }[];
52
52
  readonly actions: (() => Promise<SSRActions> | SSRActions) | undefined;
53
53
  readonly sessionDriver: (() => Promise<{
54
- default: SessionDriver | null;
54
+ default: SessionDriverFactory | null;
55
55
  }>) | undefined;
56
56
  readonly serverIslands: (() => Promise<ServerIslandMappings> | ServerIslandMappings) | undefined;
57
57
  readonly internalMiddleware: MiddlewareHandler[];
58
58
  resolvedMiddleware: MiddlewareHandler | undefined;
59
59
  resolvedActions: SSRActions | undefined;
60
- resolvedSessionDriver: SessionDriver | null | undefined;
60
+ resolvedSessionDriver: SessionDriverFactory | null | undefined;
61
61
  constructor(logger: Logger, manifest: SSRManifest,
62
62
  /**
63
63
  * "development" or "production" only
@@ -81,7 +81,7 @@ export declare abstract class Pipeline {
81
81
  route: string;
82
82
  component: string;
83
83
  }[], actions?: (() => Promise<SSRActions> | SSRActions) | undefined, sessionDriver?: (() => Promise<{
84
- default: SessionDriver | null;
84
+ default: SessionDriverFactory | null;
85
85
  }>) | undefined, serverIslands?: (() => Promise<ServerIslandMappings> | ServerIslandMappings) | undefined);
86
86
  abstract headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
87
87
  abstract componentMetadata(routeData: RouteData): Promise<SSRResult['componentMetadata']> | void;
@@ -111,7 +111,7 @@ export declare abstract class Pipeline {
111
111
  */
112
112
  getMiddleware(): Promise<MiddlewareHandler>;
113
113
  getActions(): Promise<SSRActions>;
114
- getSessionDriver(): Promise<SessionDriver | null>;
114
+ getSessionDriver(): Promise<SessionDriverFactory | null>;
115
115
  getServerIslands(): Promise<ServerIslandMappings>;
116
116
  getAction(path: string): Promise<ActionClient<unknown, ActionAccept, $ZodType>>;
117
117
  getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
@@ -25,6 +25,7 @@ import { DEFAULT_COMPONENTS } from "../../routing/default.js";
25
25
  import { getOutFile, getOutFolder } from "../common.js";
26
26
  import { cssOrder, mergeInlineCss } from "../runtime.js";
27
27
  import { makePageDataKey } from "./util.js";
28
+ import { sessionConfigToManifest } from "../../session/utils.js";
28
29
  const MANIFEST_REPLACE = "@@ASTRO_MANIFEST_REPLACE@@";
29
30
  const replaceExp = new RegExp(`['"]${MANIFEST_REPLACE}['"]`, "g");
30
31
  async function manifestBuildPostHook(options, internals, {
@@ -255,7 +256,7 @@ async function buildManifest(opts, internals, staticFiles, encodedKey) {
255
256
  checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
256
257
  allowedDomains: settings.config.security?.allowedDomains,
257
258
  key: encodedKey,
258
- sessionConfig: settings.config.session,
259
+ sessionConfig: sessionConfigToManifest(settings.config.session),
259
260
  csp,
260
261
  devToolbar: {
261
262
  enabled: false,
@@ -68,7 +68,6 @@ export declare const ASTRO_CONFIG_DEFAULTS: {
68
68
  schema: {};
69
69
  validateSecrets: false;
70
70
  };
71
- session: undefined;
72
71
  prerenderConflictBehavior: "warn";
73
72
  experimental: {
74
73
  clientPrerender: false;
@@ -152,9 +151,9 @@ export declare const AstroConfigSchema: z.ZodObject<{
152
151
  }, z.core.$strip>>>;
153
152
  layout: z.ZodOptional<z.ZodEnum<{
154
153
  fixed: "fixed";
154
+ none: "none";
155
155
  constrained: "constrained";
156
156
  "full-width": "full-width";
157
- none: "none";
158
157
  }>>;
159
158
  objectFit: z.ZodOptional<z.ZodString>;
160
159
  objectPosition: z.ZodOptional<z.ZodString>;
@@ -401,34 +400,25 @@ export declare const AstroConfigSchema: z.ZodObject<{
401
400
  validateSecrets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
402
401
  }, z.core.$strict>>>;
403
402
  session: z.ZodOptional<z.ZodObject<{
404
- driver: z.ZodOptional<z.ZodString>;
403
+ driver: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
404
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
405
+ entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
406
+ }, z.core.$strip>]>;
405
407
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
406
- cookie: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodObject<{
408
+ cookie: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
407
409
  name: z.ZodOptional<z.ZodString>;
408
410
  domain: z.ZodOptional<z.ZodString>;
409
411
  path: z.ZodOptional<z.ZodString>;
410
412
  maxAge: z.ZodOptional<z.ZodNumber>;
411
413
  sameSite: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
412
414
  strict: "strict";
413
- none: "none";
414
415
  lax: "lax";
416
+ none: "none";
415
417
  }>, z.ZodBoolean]>>;
416
418
  secure: z.ZodOptional<z.ZodBoolean>;
417
- }, z.core.$strip>, z.ZodString]>, z.ZodTransform<{
418
- name?: string | undefined;
419
- domain?: string | undefined;
420
- path?: string | undefined;
421
- maxAge?: number | undefined;
422
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
423
- secure?: boolean | undefined;
424
- }, string | {
425
- name?: string | undefined;
426
- domain?: string | undefined;
427
- path?: string | undefined;
428
- maxAge?: number | undefined;
429
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
430
- secure?: boolean | undefined;
431
- }>>>;
419
+ }, z.core.$strip>, z.ZodPipe<z.ZodString, z.ZodTransform<{
420
+ name: string;
421
+ }, string>>]>>;
432
422
  ttl: z.ZodOptional<z.ZodNumber>;
433
423
  }, z.core.$strip>>;
434
424
  prerenderConflictBehavior: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
@@ -4,6 +4,7 @@ import * as z from "zod/v4";
4
4
  import { localFontFamilySchema, remoteFontFamilySchema } from "../../../assets/fonts/config.js";
5
5
  import { EnvSchema } from "../../../env/schema.js";
6
6
  import { allowedDirectivesSchema, cspAlgorithmSchema, cspHashSchema } from "../../csp/config.js";
7
+ import { SessionSchema } from "../../session/config.js";
7
8
  const ASTRO_CONFIG_DEFAULTS = {
8
9
  root: ".",
9
10
  srcDir: "./src",
@@ -51,7 +52,6 @@ const ASTRO_CONFIG_DEFAULTS = {
51
52
  schema: {},
52
53
  validateSecrets: false
53
54
  },
54
- session: void 0,
55
55
  prerenderConflictBehavior: "warn",
56
56
  experimental: {
57
57
  clientPrerender: false,
@@ -267,24 +267,7 @@ const AstroConfigSchema = z.object({
267
267
  schema: EnvSchema.optional().default(ASTRO_CONFIG_DEFAULTS.env.schema),
268
268
  validateSecrets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.env.validateSecrets)
269
269
  }).strict().optional().default(ASTRO_CONFIG_DEFAULTS.env),
270
- session: z.object({
271
- driver: z.string().optional(),
272
- options: z.record(z.string(), z.any()).optional(),
273
- cookie: z.object({
274
- name: z.string().optional(),
275
- domain: z.string().optional(),
276
- path: z.string().optional(),
277
- maxAge: z.number().optional(),
278
- sameSite: z.union([z.enum(["strict", "lax", "none"]), z.boolean()]).optional(),
279
- secure: z.boolean().optional()
280
- }).or(z.string()).transform((val) => {
281
- if (typeof val === "string") {
282
- return { name: val };
283
- }
284
- return val;
285
- }).optional(),
286
- ttl: z.number().optional()
287
- }).optional(),
270
+ session: SessionSchema.optional(),
288
271
  prerenderConflictBehavior: z.enum(["error", "warn", "ignore"]).optional().default(ASTRO_CONFIG_DEFAULTS.prerenderConflictBehavior),
289
272
  experimental: z.strictObject({
290
273
  clientPrerender: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.clientPrerender),
@@ -45,9 +45,9 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
45
45
  }, z.core.$strip>>>;
46
46
  layout: z.ZodOptional<z.ZodEnum<{
47
47
  fixed: "fixed";
48
+ none: "none";
48
49
  constrained: "constrained";
49
50
  "full-width": "full-width";
50
- none: "none";
51
51
  }>>;
52
52
  objectFit: z.ZodOptional<z.ZodString>;
53
53
  objectPosition: z.ZodOptional<z.ZodString>;
@@ -294,34 +294,25 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
294
294
  validateSecrets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
295
295
  }, z.core.$strict>>>;
296
296
  session: z.ZodOptional<z.ZodObject<{
297
- driver: z.ZodOptional<z.ZodString>;
297
+ driver: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
298
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
299
+ entrypoint: z.ZodUnion<readonly [z.ZodString, z.ZodCustom<URL, URL>]>;
300
+ }, z.core.$strip>]>;
298
301
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
299
- cookie: z.ZodOptional<z.ZodPipe<z.ZodUnion<[z.ZodObject<{
302
+ cookie: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
300
303
  name: z.ZodOptional<z.ZodString>;
301
304
  domain: z.ZodOptional<z.ZodString>;
302
305
  path: z.ZodOptional<z.ZodString>;
303
306
  maxAge: z.ZodOptional<z.ZodNumber>;
304
307
  sameSite: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
305
308
  strict: "strict";
306
- none: "none";
307
309
  lax: "lax";
310
+ none: "none";
308
311
  }>, z.ZodBoolean]>>;
309
312
  secure: z.ZodOptional<z.ZodBoolean>;
310
- }, z.core.$strip>, z.ZodString]>, z.ZodTransform<{
311
- name?: string | undefined;
312
- domain?: string | undefined;
313
- path?: string | undefined;
314
- maxAge?: number | undefined;
315
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
316
- secure?: boolean | undefined;
317
- }, string | {
318
- name?: string | undefined;
319
- domain?: string | undefined;
320
- path?: string | undefined;
321
- maxAge?: number | undefined;
322
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
323
- secure?: boolean | undefined;
324
- }>>>;
313
+ }, z.core.$strip>, z.ZodPipe<z.ZodString, z.ZodTransform<{
314
+ name: string;
315
+ }, string>>]>>;
325
316
  ttl: z.ZodOptional<z.ZodNumber>;
326
317
  }, z.core.$strip>>;
327
318
  prerenderConflictBehavior: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
@@ -488,7 +479,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
488
479
  pathname?: string | undefined;
489
480
  }[];
490
481
  responsiveStyles: boolean;
491
- layout?: "fixed" | "constrained" | "full-width" | "none" | undefined;
482
+ layout?: "fixed" | "none" | "constrained" | "full-width" | undefined;
492
483
  objectFit?: string | undefined;
493
484
  objectPosition?: string | undefined;
494
485
  breakpoints?: number[] | undefined;
@@ -696,14 +687,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
696
687
  fallback?: Record<string, string> | undefined;
697
688
  } | undefined;
698
689
  session?: {
699
- driver?: string | undefined;
690
+ driver: string | {
691
+ entrypoint: string | URL;
692
+ config?: Record<string, any> | undefined;
693
+ };
700
694
  options?: Record<string, any> | undefined;
701
695
  cookie?: {
696
+ name: string;
697
+ } | {
702
698
  name?: string | undefined;
703
699
  domain?: string | undefined;
704
700
  path?: string | undefined;
705
701
  maxAge?: number | undefined;
706
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
702
+ sameSite?: boolean | "strict" | "lax" | "none" | undefined;
707
703
  secure?: boolean | undefined;
708
704
  } | undefined;
709
705
  ttl?: number | undefined;
@@ -740,7 +736,7 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
740
736
  pathname?: string | undefined;
741
737
  }[];
742
738
  responsiveStyles: boolean;
743
- layout?: "fixed" | "constrained" | "full-width" | "none" | undefined;
739
+ layout?: "fixed" | "none" | "constrained" | "full-width" | undefined;
744
740
  objectFit?: string | undefined;
745
741
  objectPosition?: string | undefined;
746
742
  breakpoints?: number[] | undefined;
@@ -948,14 +944,19 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
948
944
  fallback?: Record<string, string> | undefined;
949
945
  } | undefined;
950
946
  session?: {
951
- driver?: string | undefined;
947
+ driver: string | {
948
+ entrypoint: string | URL;
949
+ config?: Record<string, any> | undefined;
950
+ };
952
951
  options?: Record<string, any> | undefined;
953
952
  cookie?: {
953
+ name: string;
954
+ } | {
954
955
  name?: string | undefined;
955
956
  domain?: string | undefined;
956
957
  path?: string | undefined;
957
958
  maxAge?: number | undefined;
958
- sameSite?: boolean | "strict" | "none" | "lax" | undefined;
959
+ sameSite?: boolean | "strict" | "lax" | "none" | undefined;
959
960
  secure?: boolean | undefined;
960
961
  } | undefined;
961
962
  ttl?: number | undefined;
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "6.0.0-alpha.2";
1
+ const ASTRO_VERSION = "6.0.0-alpha.4";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
4
4
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "6.0.0-alpha.2";
25
+ const currentVersion = "6.0.0-alpha.4";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -11,7 +11,8 @@ const errorMap = (issue) => {
11
11
  typeOrLiteralErrByPath.set(flattenedErrorPath, {
12
12
  code: unionError.code,
13
13
  received: unionError.received,
14
- expected: [unionError.expected]
14
+ expected: [unionError.expected],
15
+ message: unionError.message
15
16
  });
16
17
  }
17
18
  }
@@ -65,7 +66,8 @@ const errorMap = (issue) => {
65
66
  getTypeOrLiteralMsg({
66
67
  code: issue.code,
67
68
  received: typeof issue.input,
68
- expected: [issue.expected]
69
+ expected: [issue.expected],
70
+ message: issue.message
69
71
  })
70
72
  )
71
73
  };
@@ -74,7 +76,8 @@ const errorMap = (issue) => {
74
76
  }
75
77
  };
76
78
  const getTypeOrLiteralMsg = (error) => {
77
- if (typeof error.received === "undefined" || error.received === "undefined") return "Required";
79
+ if (typeof error.received === "undefined" || error.received === "undefined")
80
+ return error.message ?? "Required";
78
81
  const expectedDeduped = new Set(error.expected);
79
82
  switch (error.code) {
80
83
  case "invalid_type":
@@ -4,14 +4,6 @@ import { type ErrorWithMetadata } from './errors/index.js';
4
4
  /**
5
5
  * Prestyled messages for the CLI. Used by astro CLI commands.
6
6
  */
7
- /** Display each request being served with the path and the status code. */
8
- export declare function req({ url, method, statusCode, reqTime, isRewrite, }: {
9
- url: string;
10
- statusCode: number;
11
- method?: string;
12
- reqTime?: number;
13
- isRewrite?: boolean;
14
- }): string;
15
7
  /** Display server host and startup time */
16
8
  export declare function serverStart({ startupTime, resolvedUrls, host, base, }: {
17
9
  startupTime: number;
@@ -22,23 +22,13 @@ const {
22
22
  underline,
23
23
  yellow
24
24
  } = colors;
25
- function req({
26
- url,
27
- method,
28
- statusCode,
29
- reqTime,
30
- isRewrite
31
- }) {
32
- const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue;
33
- return color(`[${statusCode}]`) + ` ${isRewrite ? color("(rewrite) ") : ""}` + (method && method !== "GET" ? color(method) + " " : "") + url + ` ` + (reqTime ? dim(Math.round(reqTime) + "ms") : "");
34
- }
35
25
  function serverStart({
36
26
  startupTime,
37
27
  resolvedUrls,
38
28
  host,
39
29
  base
40
30
  }) {
41
- const version = "6.0.0-alpha.2";
31
+ const version = "6.0.0-alpha.4";
42
32
  const localPrefix = `${dim("\u2503")} Local `;
43
33
  const networkPrefix = `${dim("\u2503")} Network `;
44
34
  const emptyPrefix = " ".repeat(11);
@@ -275,7 +265,7 @@ function printHelp({
275
265
  message.push(
276
266
  linebreak(),
277
267
  ` ${bgGreen(black(` ${commandName} `))} ${green(
278
- `v${"6.0.0-alpha.2"}`
268
+ `v${"6.0.0-alpha.4"}`
279
269
  )} ${headline}`
280
270
  );
281
271
  }
@@ -314,7 +304,6 @@ export {
314
304
  preferenceSet,
315
305
  prerelease,
316
306
  printHelp,
317
- req,
318
307
  serverShortcuts,
319
308
  serverStart,
320
309
  success,