astro 5.7.4 → 5.7.5
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.
- package/dist/assets/fonts/config.d.ts +0 -16
- package/dist/assets/fonts/config.js +1 -2
- package/dist/assets/fonts/providers/index.d.ts +1 -1
- package/dist/assets/fonts/providers/index.js +3 -2
- package/dist/assets/fonts/utils.d.ts +0 -1
- package/dist/assets/fonts/utils.js +0 -1
- package/dist/assets/fonts/vite-plugin-fonts.js +11 -8
- package/dist/assets/services/service.d.ts +1 -1
- package/dist/assets/utils/etag.d.ts +0 -11
- package/dist/assets/utils/etag.js +1 -2
- package/dist/assets/utils/vendor/image-size/lookup.d.ts +0 -2
- package/dist/assets/utils/vendor/image-size/lookup.js +0 -10
- package/dist/cli/add/index.d.ts +0 -9
- package/dist/cli/add/index.js +1 -2
- package/dist/cli/info/index.d.ts +0 -1
- package/dist/cli/info/index.js +0 -1
- package/dist/cli/preferences/index.d.ts +0 -2
- package/dist/container/index.js +1 -6
- package/dist/content/content-layer.d.ts +2 -7
- package/dist/content/content-layer.js +4 -6
- package/dist/content/index.d.ts +1 -2
- package/dist/content/index.js +1 -5
- package/dist/content/loaders/file.d.ts +2 -1
- package/dist/content/loaders/glob.d.ts +3 -2
- package/dist/content/utils.d.ts +1 -12
- package/dist/content/utils.js +0 -13
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +0 -16
- package/dist/content/vite-plugin-content-virtual-mod.js +1 -3
- package/dist/core/app/index.js +3 -4
- package/dist/core/app/pipeline.d.ts +2 -3
- package/dist/core/app/pipeline.js +1 -3
- package/dist/core/app/types.d.ts +3 -2
- package/dist/core/build/consts.d.ts +0 -1
- package/dist/core/build/consts.js +1 -3
- package/dist/core/build/index.d.ts +2 -1
- package/dist/core/build/page-data.d.ts +3 -2
- package/dist/core/build/plugin.d.ts +1 -1
- package/dist/core/build/plugins/plugin-analyzer.d.ts +0 -2
- package/dist/core/build/plugins/plugin-analyzer.js +1 -2
- package/dist/core/build/plugins/plugin-chunks.d.ts +0 -2
- package/dist/core/build/plugins/plugin-chunks.js +1 -2
- package/dist/core/build/plugins/plugin-component-entry.d.ts +0 -8
- package/dist/core/build/plugins/plugin-component-entry.js +1 -3
- package/dist/core/build/plugins/plugin-internals.d.ts +0 -2
- package/dist/core/build/plugins/plugin-internals.js +1 -2
- package/dist/core/build/plugins/plugin-renderers.d.ts +0 -2
- package/dist/core/build/plugins/plugin-renderers.js +1 -2
- package/dist/core/build/plugins/plugin-scripts.d.ts +0 -5
- package/dist/core/build/plugins/plugin-scripts.js +1 -2
- package/dist/core/build/plugins/plugin-ssr.d.ts +0 -1
- package/dist/core/build/plugins/plugin-ssr.js +0 -1
- package/dist/core/build/plugins/util.d.ts +0 -9
- package/dist/core/build/plugins/util.js +0 -2
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/config/config.d.ts +0 -1
- package/dist/core/config/config.js +0 -1
- package/dist/core/config/index.d.ts +1 -2
- package/dist/core/config/index.js +0 -2
- package/dist/core/config/schemas/base.d.ts +6 -4
- package/dist/core/config/schemas/relative.d.ts +6 -6
- package/dist/core/config/timer.d.ts +0 -5
- package/dist/core/config/tsconfig.d.ts +1 -1
- package/dist/core/constants.d.ts +0 -4
- package/dist/core/constants.js +1 -3
- package/dist/core/cookies/index.d.ts +1 -1
- package/dist/core/cookies/index.js +2 -4
- package/dist/core/cookies/response.d.ts +0 -1
- package/dist/core/cookies/response.js +1 -5
- package/dist/core/dev/container.d.ts +2 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/index.d.ts +1 -1
- package/dist/core/dev/index.js +1 -2
- package/dist/core/dev/restart.d.ts +1 -1
- package/dist/core/encryption.d.ts +0 -8
- package/dist/core/encryption.js +1 -7
- package/dist/core/errors/index.d.ts +1 -2
- package/dist/core/errors/index.js +0 -2
- package/dist/core/logger/core.d.ts +3 -9
- package/dist/core/logger/core.js +1 -5
- package/dist/core/messages.d.ts +0 -1
- package/dist/core/messages.js +2 -11
- package/dist/core/middleware/sequence.js +3 -0
- package/dist/core/preview/static-preview-server.d.ts +2 -1
- package/dist/core/redirects/index.d.ts +0 -1
- package/dist/core/redirects/index.js +0 -2
- package/dist/core/render/index.d.ts +0 -17
- package/dist/core/render/ssr-element.d.ts +0 -2
- package/dist/core/render/ssr-element.js +0 -2
- package/dist/core/render-context.js +4 -0
- package/dist/core/request.d.ts +1 -1
- package/dist/core/routing/3xx.d.ts +2 -1
- package/dist/core/routing/astro-designed-error-pages.d.ts +0 -1
- package/dist/core/routing/astro-designed-error-pages.js +1 -16
- package/dist/core/routing/index.d.ts +2 -3
- package/dist/core/routing/index.js +3 -8
- package/dist/core/routing/manifest/create.d.ts +2 -3
- package/dist/core/routing/manifest/create.js +0 -1
- package/dist/core/routing/request.d.ts +0 -1
- package/dist/core/routing/request.js +1 -2
- package/dist/core/routing/rewrite.d.ts +3 -2
- package/dist/core/server-islands/vite-plugin-server-islands.d.ts +0 -1
- package/dist/core/server-islands/vite-plugin-server-islands.js +0 -1
- package/dist/core/sync/index.d.ts +2 -1
- package/dist/core/util.d.ts +0 -1
- package/dist/core/util.js +0 -1
- package/dist/events/session.d.ts +1 -1
- package/dist/integrations/features-validation.d.ts +1 -3
- package/dist/integrations/features-validation.js +0 -2
- package/dist/preferences/index.d.ts +4 -4
- package/dist/type-utils.d.ts +0 -4
- package/dist/types/public/config.d.ts +19 -0
- package/dist/types/typed-emitter.d.ts +2 -1
- package/dist/vite-plugin-astro/hmr.d.ts +2 -1
- package/dist/vite-plugin-astro/query.d.ts +3 -2
- package/dist/vite-plugin-astro/types.d.ts +2 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +2 -2
- package/dist/vite-plugin-astro-server/plugin.d.ts +2 -1
- package/dist/vite-plugin-astro-server/response.d.ts +0 -1
- package/dist/vite-plugin-astro-server/response.js +0 -12
- package/dist/vite-plugin-astro-server/route.d.ts +1 -1
- package/dist/vite-plugin-astro-server/server-state.d.ts +3 -3
- package/dist/vite-plugin-astro-server/server-state.js +0 -4
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-scanner/index.d.ts +2 -1
- package/package.json +5 -11
- package/templates/env.mjs +1 -0
|
@@ -3,6 +3,7 @@ import { ForbiddenRewrite } from "../errors/errors-data.js";
|
|
|
3
3
|
import { AstroError } from "../errors/index.js";
|
|
4
4
|
import { apiContextRoutesSymbol } from "../render-context.js";
|
|
5
5
|
import { getParams } from "../render/index.js";
|
|
6
|
+
import { setOriginPathname } from "../routing/rewrite.js";
|
|
6
7
|
import { defineMiddleware } from "./index.js";
|
|
7
8
|
function sequence(...handlers) {
|
|
8
9
|
const filtered = handlers.filter((h) => !!h);
|
|
@@ -31,6 +32,7 @@ function sequence(...handlers) {
|
|
|
31
32
|
handleContext.request
|
|
32
33
|
);
|
|
33
34
|
}
|
|
35
|
+
const oldPathname = handleContext.url.pathname;
|
|
34
36
|
const pipeline = Reflect.get(handleContext, apiContextRoutesSymbol);
|
|
35
37
|
const { routeData, pathname } = await pipeline.tryRewrite(
|
|
36
38
|
payload,
|
|
@@ -52,6 +54,7 @@ function sequence(...handlers) {
|
|
|
52
54
|
handleContext.url = new URL(newRequest.url);
|
|
53
55
|
handleContext.cookies = new AstroCookies(newRequest);
|
|
54
56
|
handleContext.params = getParams(routeData, pathname);
|
|
57
|
+
setOriginPathname(handleContext.request, oldPathname);
|
|
55
58
|
}
|
|
56
59
|
return applyHandle(i + 1, handleContext);
|
|
57
60
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type http from 'node:http';
|
|
2
2
|
import type { AstroSettings } from '../../types/astro.js';
|
|
3
3
|
import type { Logger } from '../logger/core.js';
|
|
4
|
-
|
|
4
|
+
interface PreviewServer {
|
|
5
5
|
host?: string;
|
|
6
6
|
port: number;
|
|
7
7
|
server: http.Server;
|
|
@@ -9,3 +9,4 @@ export interface PreviewServer {
|
|
|
9
9
|
stop(): Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
export default function createStaticPreviewServer(settings: AstroSettings, logger: Logger): Promise<PreviewServer>;
|
|
12
|
+
export {};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { RedirectComponentInstance, RedirectSinglePageBuiltModule } from "./component.js";
|
|
2
2
|
import { routeIsRedirect } from "./helpers.js";
|
|
3
3
|
import { getRedirectLocationOrThrow } from "./validate.js";
|
|
4
|
-
import { renderRedirect } from "./render.js";
|
|
5
4
|
export {
|
|
6
5
|
RedirectComponentInstance,
|
|
7
6
|
RedirectSinglePageBuiltModule,
|
|
8
7
|
getRedirectLocationOrThrow,
|
|
9
|
-
renderRedirect,
|
|
10
8
|
routeIsRedirect
|
|
11
9
|
};
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import type { ComponentInstance } from '../../types/astro.js';
|
|
2
|
-
import type { RouteData } from '../../types/public/internal.js';
|
|
3
|
-
import type { Pipeline } from '../base-pipeline.js';
|
|
4
1
|
export { Pipeline } from '../base-pipeline.js';
|
|
5
2
|
export { getParams, getProps } from './params-and-props.js';
|
|
6
3
|
export { loadRenderer } from './renderer.js';
|
|
7
4
|
export { Slots } from './slots.js';
|
|
8
|
-
export interface SSROptions {
|
|
9
|
-
/** The pipeline instance */
|
|
10
|
-
pipeline: Pipeline;
|
|
11
|
-
/** location of file on disk */
|
|
12
|
-
filePath: URL;
|
|
13
|
-
/** the web request (needed for dynamic routes) */
|
|
14
|
-
pathname: string;
|
|
15
|
-
/** The runtime component instance */
|
|
16
|
-
preload: ComponentInstance;
|
|
17
|
-
/** Request */
|
|
18
|
-
request: Request;
|
|
19
|
-
/** optional, in case we need to render something outside a dev server */
|
|
20
|
-
route: RouteData;
|
|
21
|
-
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { SSRElement } from '../../types/public/internal.js';
|
|
2
2
|
import type { AssetsPrefix, StylesheetAsset } from '../app/types.js';
|
|
3
3
|
export declare function createAssetLink(href: string, base?: string, assetsPrefix?: AssetsPrefix): string;
|
|
4
|
-
export declare function createStylesheetElement(stylesheet: StylesheetAsset, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
|
|
5
4
|
export declare function createStylesheetElementSet(stylesheets: StylesheetAsset[], base?: string, assetsPrefix?: AssetsPrefix): Set<SSRElement>;
|
|
6
5
|
export declare function createModuleScriptElement(script: {
|
|
7
6
|
type: 'inline' | 'external';
|
|
8
7
|
value: string;
|
|
9
8
|
}, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
|
|
10
|
-
export declare function createModuleScriptElementWithSrc(src: string, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
|
|
@@ -124,6 +124,7 @@ class RenderContext {
|
|
|
124
124
|
}
|
|
125
125
|
const lastNext = async (ctx, payload) => {
|
|
126
126
|
if (payload) {
|
|
127
|
+
const oldPathname = this.pathname;
|
|
127
128
|
pipeline.logger.debug("router", "Called rewriting to:", payload);
|
|
128
129
|
const {
|
|
129
130
|
routeData,
|
|
@@ -158,6 +159,7 @@ class RenderContext {
|
|
|
158
159
|
this.params = getParams(routeData, pathname);
|
|
159
160
|
this.pathname = pathname;
|
|
160
161
|
this.status = 200;
|
|
162
|
+
setOriginPathname(this.request, oldPathname);
|
|
161
163
|
}
|
|
162
164
|
let response2;
|
|
163
165
|
if (!ctx.isPrerendered) {
|
|
@@ -235,6 +237,7 @@ class RenderContext {
|
|
|
235
237
|
}
|
|
236
238
|
async #executeRewrite(reroutePayload) {
|
|
237
239
|
this.pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
|
|
240
|
+
const oldPathname = this.pathname;
|
|
238
241
|
const { routeData, componentInstance, newUrl, pathname } = await this.pipeline.tryRewrite(
|
|
239
242
|
reroutePayload,
|
|
240
243
|
this.request
|
|
@@ -265,6 +268,7 @@ class RenderContext {
|
|
|
265
268
|
this.pathname = pathname;
|
|
266
269
|
this.isRewriting = true;
|
|
267
270
|
this.status = 200;
|
|
271
|
+
setOriginPathname(this.request, oldPathname);
|
|
268
272
|
return await this.render(componentInstance);
|
|
269
273
|
}
|
|
270
274
|
createActionAPIContext() {
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
2
|
import type { Logger } from './logger/core.js';
|
|
3
3
|
type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;
|
|
4
|
-
|
|
4
|
+
interface CreateRequestOptions {
|
|
5
5
|
url: URL | string;
|
|
6
6
|
clientAddress?: string | undefined;
|
|
7
7
|
headers: HeaderType;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type RedirectTemplate = {
|
|
2
2
|
from?: string;
|
|
3
3
|
absoluteLocation: string | URL;
|
|
4
4
|
status: number;
|
|
5
5
|
relativeLocation: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function redirectTemplate({ status, absoluteLocation, relativeLocation, from, }: RedirectTemplate): string;
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ComponentInstance, RoutesList } from '../../types/astro.js';
|
|
2
2
|
import type { RouteData } from '../../types/public/internal.js';
|
|
3
3
|
export declare const DEFAULT_404_ROUTE: RouteData;
|
|
4
|
-
export declare const DEFAULT_500_ROUTE: RouteData;
|
|
5
4
|
export declare function ensure404Route(manifest: RoutesList): RoutesList;
|
|
6
5
|
export declare const default404Instance: ComponentInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import notFoundTemplate from "../../template/4xx.js";
|
|
2
|
-
import { DEFAULT_404_COMPONENT
|
|
2
|
+
import { DEFAULT_404_COMPONENT } from "../constants.js";
|
|
3
3
|
const DEFAULT_404_ROUTE = {
|
|
4
4
|
component: DEFAULT_404_COMPONENT,
|
|
5
5
|
generate: () => "",
|
|
@@ -14,20 +14,6 @@ const DEFAULT_404_ROUTE = {
|
|
|
14
14
|
isIndex: false,
|
|
15
15
|
origin: "internal"
|
|
16
16
|
};
|
|
17
|
-
const DEFAULT_500_ROUTE = {
|
|
18
|
-
component: DEFAULT_500_COMPONENT,
|
|
19
|
-
generate: () => "",
|
|
20
|
-
params: [],
|
|
21
|
-
pattern: /\/500/,
|
|
22
|
-
prerender: false,
|
|
23
|
-
pathname: "/500",
|
|
24
|
-
segments: [[{ content: "500", dynamic: false, spread: false }]],
|
|
25
|
-
type: "page",
|
|
26
|
-
route: "/500",
|
|
27
|
-
fallbackRoutes: [],
|
|
28
|
-
isIndex: false,
|
|
29
|
-
origin: "internal"
|
|
30
|
-
};
|
|
31
17
|
function ensure404Route(manifest) {
|
|
32
18
|
if (!manifest.routes.some((route) => route.route === "/404")) {
|
|
33
19
|
manifest.routes.push(DEFAULT_404_ROUTE);
|
|
@@ -51,7 +37,6 @@ const default404Instance = {
|
|
|
51
37
|
};
|
|
52
38
|
export {
|
|
53
39
|
DEFAULT_404_ROUTE,
|
|
54
|
-
DEFAULT_500_ROUTE,
|
|
55
40
|
default404Instance,
|
|
56
41
|
ensure404Route
|
|
57
42
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { createRoutesList } from './manifest/create.js';
|
|
2
|
-
export {
|
|
3
|
-
export { matchAllRoutes
|
|
4
|
-
export { validateDynamicRouteModule, validateGetStaticPathsResult } from './validation.js';
|
|
2
|
+
export { serializeRouteData } from './manifest/serialization.js';
|
|
3
|
+
export { matchAllRoutes } from './match.js';
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createRoutesList } from "./manifest/create.js";
|
|
2
|
-
import {
|
|
3
|
-
import { matchAllRoutes
|
|
4
|
-
import { validateDynamicRouteModule, validateGetStaticPathsResult } from "./validation.js";
|
|
2
|
+
import { serializeRouteData } from "./manifest/serialization.js";
|
|
3
|
+
import { matchAllRoutes } from "./match.js";
|
|
5
4
|
export {
|
|
6
5
|
createRoutesList,
|
|
7
|
-
deserializeRouteData,
|
|
8
6
|
matchAllRoutes,
|
|
9
|
-
|
|
10
|
-
serializeRouteData,
|
|
11
|
-
validateDynamicRouteModule,
|
|
12
|
-
validateGetStaticPathsResult
|
|
7
|
+
serializeRouteData
|
|
13
8
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { AstroSettings, RoutesList } from '../../../types/astro.js';
|
|
2
2
|
import type { Logger } from '../../logger/core.js';
|
|
3
3
|
import nodeFs from 'node:fs';
|
|
4
|
-
|
|
5
|
-
export declare function getParts(part: string, file: string): RoutePart[];
|
|
6
|
-
export interface CreateRouteManifestParams {
|
|
4
|
+
interface CreateRouteManifestParams {
|
|
7
5
|
/** Astro Settings object */
|
|
8
6
|
settings: AstroSettings;
|
|
9
7
|
/** Current working directory */
|
|
@@ -19,3 +17,4 @@ export declare function resolveInjectedRoute(entrypoint: string, root: URL, cwd?
|
|
|
19
17
|
resolved: string;
|
|
20
18
|
component: string;
|
|
21
19
|
};
|
|
20
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import type { RewritePayload } from '../../types/public/common.js';
|
|
|
2
2
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
3
3
|
import type { RouteData } from '../../types/public/internal.js';
|
|
4
4
|
import type { Logger } from '../logger/core.js';
|
|
5
|
-
|
|
5
|
+
type FindRouteToRewrite = {
|
|
6
6
|
payload: RewritePayload;
|
|
7
7
|
routes: RouteData[];
|
|
8
8
|
request: Request;
|
|
@@ -10,7 +10,7 @@ export type FindRouteToRewrite = {
|
|
|
10
10
|
buildFormat: AstroConfig['build']['format'];
|
|
11
11
|
base: AstroConfig['base'];
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
interface FindRouteToRewriteResult {
|
|
14
14
|
routeData: RouteData;
|
|
15
15
|
newUrl: URL;
|
|
16
16
|
pathname: string;
|
|
@@ -33,3 +33,4 @@ export declare function findRouteToRewrite({ payload, routes, request, trailingS
|
|
|
33
33
|
export declare function copyRequest(newUrl: URL, oldRequest: Request, isPrerendered: boolean, logger: Logger, routePattern: string): Request;
|
|
34
34
|
export declare function setOriginPathname(request: Request, pathname: string): void;
|
|
35
35
|
export declare function getOriginPathname(request: Request): string;
|
|
36
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { AstroPluginOptions } from '../../types/astro.js';
|
|
3
3
|
export declare const VIRTUAL_ISLAND_MAP_ID = "@astro-server-islands";
|
|
4
|
-
export declare const RESOLVED_VIRTUAL_ISLAND_MAP_ID: string;
|
|
5
4
|
export declare function vitePluginServerIslands({ settings, logger }: AstroPluginOptions): VitePlugin;
|
|
@@ -4,7 +4,7 @@ import type { AstroSettings, RoutesList } from '../../types/astro.js';
|
|
|
4
4
|
import type { AstroInlineConfig } from '../../types/public/config.js';
|
|
5
5
|
import type { SSRManifest } from '../app/types.js';
|
|
6
6
|
import type { Logger } from '../logger/core.js';
|
|
7
|
-
|
|
7
|
+
type SyncOptions = {
|
|
8
8
|
mode: string;
|
|
9
9
|
logger: Logger;
|
|
10
10
|
settings: AstroSettings;
|
|
@@ -38,3 +38,4 @@ export declare function clearContentLayerCache({ settings, logger, fs, isDev, }:
|
|
|
38
38
|
* @experimental The JavaScript API is experimental
|
|
39
39
|
*/
|
|
40
40
|
export declare function syncInternal({ mode, logger, fs, settings, skip, force, routesList, command, watcher, manifest, }: SyncOptions): Promise<void>;
|
|
41
|
+
export {};
|
package/dist/core/util.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare function parseNpmName(spec: string): {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function viteID(filePath: URL): string;
|
|
34
34
|
export declare const VALID_ID_PREFIX = "/@id/";
|
|
35
|
-
export declare const NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
36
35
|
export declare function unwrapId(id: string): string;
|
|
37
36
|
export declare function resolvePages(config: AstroConfig): URL;
|
|
38
37
|
export declare function isPage(file: URL, settings: AstroSettings): boolean;
|
package/dist/core/util.js
CHANGED
package/dist/events/session.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type ConfigInfoRecord = Record<string, ConfigInfoValue>;
|
|
|
11
11
|
type ConfigInfoBase = {
|
|
12
12
|
[alias in keyof AstroUserConfig]: ConfigInfoValue | ConfigInfoRecord;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
interface ConfigInfo extends ConfigInfoBase {
|
|
15
15
|
build: ConfigInfoRecord;
|
|
16
16
|
image: ConfigInfoRecord;
|
|
17
17
|
markdown: ConfigInfoRecord;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '../core/logger/core.js';
|
|
2
2
|
import type { AstroSettings } from '../types/astro.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroAdapterFeatureMap } from '../types/public/integrations.js';
|
|
4
4
|
export declare const AdapterFeatureStability: {
|
|
5
5
|
readonly STABLE: "stable";
|
|
6
6
|
readonly DEPRECATED: "deprecated";
|
|
@@ -19,7 +19,5 @@ type ValidationResult = {
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
export declare function validateSupportedFeatures(adapterName: string, featureMap: AstroAdapterFeatureMap, settings: AstroSettings, logger: Logger): ValidationResult;
|
|
22
|
-
export declare function unwrapSupportKind(supportKind?: AdapterSupport): AdapterSupportsKind | undefined;
|
|
23
|
-
export declare function getSupportMessage(supportKind: AdapterSupport): string | undefined;
|
|
24
22
|
export declare function getAdapterStaticRecommendation(adapterName: string): string | undefined;
|
|
25
23
|
export {};
|
|
@@ -3,9 +3,9 @@ import { type Preferences, type PublicPreferences } from './defaults.js';
|
|
|
3
3
|
type DotKeys<T> = T extends object ? {
|
|
4
4
|
[K in keyof T]: `${Exclude<K, symbol>}${DotKeys<T[K]> extends never ? '' : `.${DotKeys<T[K]>}`}`;
|
|
5
5
|
}[keyof T] : never;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
type GetDotKey<T extends Record<string | number, any>, K extends string> = K extends `${infer U}.${infer Rest}` ? GetDotKey<T[U], Rest> : T[K];
|
|
7
|
+
type PreferenceLocation = 'global' | 'project';
|
|
8
|
+
interface PreferenceOptions {
|
|
9
9
|
location?: PreferenceLocation;
|
|
10
10
|
/**
|
|
11
11
|
* If `true`, the server will be reloaded after setting the preference.
|
|
@@ -19,7 +19,7 @@ type DeepPartial<T> = T extends object ? {
|
|
|
19
19
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
20
20
|
} : T;
|
|
21
21
|
export type PreferenceKey = DotKeys<Preferences>;
|
|
22
|
-
|
|
22
|
+
interface PreferenceList extends Record<PreferenceLocation, DeepPartial<PublicPreferences>> {
|
|
23
23
|
fromAstroConfig: DeepPartial<Preferences>;
|
|
24
24
|
defaults: PublicPreferences;
|
|
25
25
|
}
|
package/dist/type-utils.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ export type OmitIndexSignature<ObjectType> = {
|
|
|
10
10
|
export type OmitPreservingIndexSignature<T, K extends PropertyKey> = {
|
|
11
11
|
[P in keyof T as Exclude<P, K>]: T[P];
|
|
12
12
|
};
|
|
13
|
-
export type Kebab<T extends string, A extends string = ''> = T extends `${infer F}${infer R}` ? Kebab<R, `${A}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`> : A;
|
|
14
|
-
export type KebabKeys<T> = {
|
|
15
|
-
[K in keyof T as K extends string ? Kebab<K> : K]: T[K];
|
|
16
|
-
};
|
|
17
13
|
export type ValueOf<T> = T[keyof T];
|
|
18
14
|
export type MapValue<T> = T extends Map<any, infer V> ? V : never;
|
|
19
15
|
export type DeepPartial<T> = {
|
|
@@ -837,6 +837,25 @@ export interface ViteUserConfig extends OriginalViteUserConfig {
|
|
|
837
837
|
* }
|
|
838
838
|
* ```
|
|
839
839
|
*/
|
|
840
|
+
/**
|
|
841
|
+
* @docs
|
|
842
|
+
* @name server.allowedHosts
|
|
843
|
+
* @type {string[] | true}
|
|
844
|
+
* @default `[]`
|
|
845
|
+
* @version 5.4.0
|
|
846
|
+
* @description
|
|
847
|
+
*
|
|
848
|
+
* A list of hostnames that Astro is allowed to respond to. When the value is set to `true`, any
|
|
849
|
+
* hostname is allowed.
|
|
850
|
+
*
|
|
851
|
+
* ```js
|
|
852
|
+
* {
|
|
853
|
+
* server: {
|
|
854
|
+
* allowedHosts: ['staging.example.com', 'qa.example.com']
|
|
855
|
+
* }
|
|
856
|
+
* }
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
840
859
|
/**
|
|
841
860
|
* @docs
|
|
842
861
|
* @name server.open
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2018 Andy Wermke
|
|
4
4
|
* https://github.com/andywer/typed-emitter/blob/9a139b6fa0ec6b0db6141b5b756b784e4f7ef4e4/LICENSE
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
type EventMap = {
|
|
7
7
|
[key: string]: (...args: any[]) => void;
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
@@ -39,3 +39,4 @@ export interface TypedEventEmitter<Events extends EventMap> {
|
|
|
39
39
|
getMaxListeners(): number;
|
|
40
40
|
setMaxListeners(maxListeners: number): this;
|
|
41
41
|
}
|
|
42
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { HmrContext } from 'vite';
|
|
2
2
|
import type { Logger } from '../core/logger/core.js';
|
|
3
3
|
import type { CompileMetadata } from './types.js';
|
|
4
|
-
|
|
4
|
+
interface HandleHotUpdateOptions {
|
|
5
5
|
logger: Logger;
|
|
6
6
|
astroFileToCompileMetadata: Map<string, CompileMetadata>;
|
|
7
7
|
}
|
|
8
8
|
export declare function handleHotUpdate(ctx: HmrContext, { logger, astroFileToCompileMetadata }: HandleHotUpdateOptions): Promise<import("vite").ModuleNode[] | undefined>;
|
|
9
9
|
export declare function isStyleOnlyChanged(oldCode: string, newCode: string): boolean;
|
|
10
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface AstroQuery {
|
|
2
2
|
astro?: boolean;
|
|
3
3
|
src?: boolean;
|
|
4
4
|
type?: 'script' | 'template' | 'style' | 'custom';
|
|
@@ -6,8 +6,9 @@ export interface AstroQuery {
|
|
|
6
6
|
lang?: string;
|
|
7
7
|
raw?: boolean;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
interface ParsedRequestResult {
|
|
10
10
|
filename: string;
|
|
11
11
|
query: AstroQuery;
|
|
12
12
|
}
|
|
13
13
|
export declare function parseAstroRequest(id: string): ParsedRequestResult;
|
|
14
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HoistedScript, TransformResult } from '@astrojs/compiler';
|
|
2
2
|
import type { CompileCssResult } from '../core/compile/types.js';
|
|
3
3
|
import type { PropagationHint } from '../types/public/internal.js';
|
|
4
|
-
|
|
4
|
+
interface PageOptions {
|
|
5
5
|
prerender?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface PluginMetadata {
|
|
@@ -43,3 +43,4 @@ export interface CompileMetadata {
|
|
|
43
43
|
/** For Astro scripts virtual module */
|
|
44
44
|
scripts: HoistedScript[];
|
|
45
45
|
}
|
|
46
|
+
export {};
|
|
@@ -6,13 +6,13 @@ export interface DevServerController {
|
|
|
6
6
|
onFileChange: LoaderEvents['file-change'];
|
|
7
7
|
onHMRError: LoaderEvents['hmr-error'];
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type CreateControllerParams = {
|
|
10
10
|
loader: ModuleLoader;
|
|
11
11
|
} | {
|
|
12
12
|
reload: ReloadFn;
|
|
13
13
|
};
|
|
14
14
|
export declare function createController(params: CreateControllerParams): DevServerController;
|
|
15
|
-
|
|
15
|
+
interface RunWithErrorHandlingParams {
|
|
16
16
|
controller: DevServerController;
|
|
17
17
|
pathname: string;
|
|
18
18
|
run: () => Promise<any>;
|
|
@@ -3,7 +3,7 @@ import type * as vite from 'vite';
|
|
|
3
3
|
import type { SSRManifest } from '../core/app/types.js';
|
|
4
4
|
import type { Logger } from '../core/logger/core.js';
|
|
5
5
|
import type { AstroSettings, RoutesList } from '../types/astro.js';
|
|
6
|
-
|
|
6
|
+
interface AstroPluginOptions {
|
|
7
7
|
settings: AstroSettings;
|
|
8
8
|
logger: Logger;
|
|
9
9
|
fs: typeof fs;
|
|
@@ -18,3 +18,4 @@ export default function createVitePluginAstroServer({ settings, logger, fs: fsMo
|
|
|
18
18
|
* @param settings
|
|
19
19
|
*/
|
|
20
20
|
export declare function createDevelopmentManifest(settings: AstroSettings): SSRManifest;
|
|
21
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type http from 'node:http';
|
|
2
2
|
import type { ErrorWithMetadata } from '../core/errors/index.js';
|
|
3
3
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
4
|
-
export declare function handle404Response(origin: string, req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
5
4
|
export declare function handle500Response(loader: ModuleLoader, res: http.ServerResponse, err: ErrorWithMetadata): Promise<void>;
|
|
6
5
|
export declare function writeHtmlResponse(res: http.ServerResponse, statusCode: number, html: string): void;
|
|
7
6
|
export declare function writeRedirectResponse(res: http.ServerResponse, statusCode: number, location: string): void;
|
|
@@ -3,17 +3,6 @@ import { Readable } from "node:stream";
|
|
|
3
3
|
import { getSetCookiesFromResponse } from "../core/cookies/index.js";
|
|
4
4
|
import { getViteErrorPayload } from "../core/errors/dev/index.js";
|
|
5
5
|
import { redirectTemplate } from "../core/routing/3xx.js";
|
|
6
|
-
import notFoundTemplate from "../template/4xx.js";
|
|
7
|
-
async function handle404Response(origin, req, res) {
|
|
8
|
-
const pathname = decodeURI(new URL(origin + req.url).pathname);
|
|
9
|
-
const html = notFoundTemplate({
|
|
10
|
-
statusCode: 404,
|
|
11
|
-
title: "Not found",
|
|
12
|
-
tabTitle: "404: Not Found",
|
|
13
|
-
pathname
|
|
14
|
-
});
|
|
15
|
-
writeHtmlResponse(res, 404, html);
|
|
16
|
-
}
|
|
17
6
|
async function handle500Response(loader, res, err) {
|
|
18
7
|
res.on(
|
|
19
8
|
"close",
|
|
@@ -99,7 +88,6 @@ async function writeSSRResult(webRequest, webResponse, res) {
|
|
|
99
88
|
return writeWebResponse(res, webResponse);
|
|
100
89
|
}
|
|
101
90
|
export {
|
|
102
|
-
handle404Response,
|
|
103
91
|
handle500Response,
|
|
104
92
|
writeHtmlResponse,
|
|
105
93
|
writeRedirectResponse,
|
|
@@ -3,7 +3,7 @@ import type { ComponentInstance, RoutesList } from '../types/astro.js';
|
|
|
3
3
|
import type { RouteData } from '../types/public/internal.js';
|
|
4
4
|
import type { DevPipeline } from './pipeline.js';
|
|
5
5
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
6
|
-
|
|
6
|
+
interface MatchedRoute {
|
|
7
7
|
route: RouteData;
|
|
8
8
|
filePath: URL;
|
|
9
9
|
resolvedPathname: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type ErrorState = 'fresh' | 'error';
|
|
2
|
+
interface RouteState {
|
|
3
3
|
state: ErrorState;
|
|
4
4
|
error?: Error;
|
|
5
5
|
}
|
|
@@ -9,7 +9,7 @@ export interface ServerState {
|
|
|
9
9
|
error?: Error;
|
|
10
10
|
}
|
|
11
11
|
export declare function createServerState(): ServerState;
|
|
12
|
-
export declare function hasAnyFailureState(serverState: ServerState): boolean;
|
|
13
12
|
export declare function setRouteError(serverState: ServerState, pathname: string, error: Error): void;
|
|
14
13
|
export declare function setServerError(serverState: ServerState, error: Error): void;
|
|
15
14
|
export declare function clearRouteError(serverState: ServerState, pathname: string): void;
|
|
15
|
+
export {};
|
|
@@ -4,9 +4,6 @@ function createServerState() {
|
|
|
4
4
|
state: "fresh"
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
|
-
function hasAnyFailureState(serverState) {
|
|
8
|
-
return serverState.state !== "fresh";
|
|
9
|
-
}
|
|
10
7
|
function setRouteError(serverState, pathname, error) {
|
|
11
8
|
if (serverState.routes.has(pathname)) {
|
|
12
9
|
const routeState = serverState.routes.get(pathname);
|
|
@@ -36,7 +33,6 @@ function clearRouteError(serverState, pathname) {
|
|
|
36
33
|
export {
|
|
37
34
|
clearRouteError,
|
|
38
35
|
createServerState,
|
|
39
|
-
hasAnyFailureState,
|
|
40
36
|
setRouteError,
|
|
41
37
|
setServerError
|
|
42
38
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite';
|
|
2
2
|
import type { Logger } from '../core/logger/core.js';
|
|
3
3
|
import type { AstroSettings, RoutesList } from '../types/astro.js';
|
|
4
|
-
|
|
4
|
+
interface AstroPluginScannerOptions {
|
|
5
5
|
settings: AstroSettings;
|
|
6
6
|
logger: Logger;
|
|
7
7
|
routesList: RoutesList;
|
|
8
8
|
}
|
|
9
9
|
export default function astroScannerPlugin({ settings, logger, routesList, }: AstroPluginScannerOptions): VitePlugin;
|
|
10
|
+
export {};
|