astro 7.2.2 → 7.2.3
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/actions/handler.d.ts +6 -12
- package/dist/actions/handler.js +30 -40
- package/dist/actions/load.d.ts +12 -0
- package/dist/actions/load.js +55 -0
- package/dist/actions/runtime/entrypoints/server.js +5 -4
- package/dist/actions/runtime/server.js +8 -6
- package/dist/assets/fonts/providers/index.d.ts +1 -1
- package/dist/assets/fonts/providers/index.js +2 -12
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/environment.d.ts +20 -0
- package/dist/container/environment.js +106 -0
- package/dist/container/index.js +65 -32
- package/dist/content/content-layer.js +3 -3
- package/dist/content/data-store-writer.d.ts +7 -10
- package/dist/content/data-store-writer.js +62 -27
- package/dist/content/data-store.d.ts +20 -3
- package/dist/content/data-store.js +28 -7
- package/dist/content/mutable-data-store.js +15 -10
- package/dist/content/runtime.d.ts +3 -2
- package/dist/content/runtime.js +43 -26
- package/dist/core/app/app.d.ts +0 -2
- package/dist/core/app/app.js +0 -7
- package/dist/core/app/base.d.ts +32 -20
- package/dist/core/app/base.js +76 -66
- package/dist/core/app/dev-facade.d.ts +27 -0
- package/dist/core/app/dev-facade.js +51 -0
- package/dist/core/app/entrypoints/index.d.ts +0 -1
- package/dist/core/app/entrypoints/index.js +0 -2
- package/dist/core/app/entrypoints/virtual/dev.js +24 -19
- package/dist/core/app/node.js +13 -14
- package/dist/core/app/prepare-response.d.ts +1 -1
- package/dist/core/app/validate-headers.js +7 -3
- package/dist/core/build/app.d.ts +31 -6
- package/dist/core/build/app.js +31 -13
- package/dist/core/build/environment.d.ts +25 -0
- package/dist/core/build/environment.js +157 -0
- package/dist/core/cache/handler.d.ts +13 -7
- package/dist/core/cache/handler.js +55 -51
- package/dist/core/cache/provider.d.ts +4 -0
- package/dist/core/cache/provider.js +15 -0
- package/dist/core/constants.d.ts +0 -11
- package/dist/core/constants.js +1 -5
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/environment/dev-nonrunnable.d.ts +6 -0
- package/dist/core/environment/dev-nonrunnable.js +170 -0
- package/dist/core/environment/index.d.ts +90 -0
- package/dist/core/environment/index.js +12 -0
- package/dist/core/environment/production.d.ts +6 -0
- package/dist/core/environment/production.js +117 -0
- package/dist/core/errors/build-handler.d.ts +5 -10
- package/dist/core/errors/build-handler.js +11 -17
- package/dist/core/errors/default-handler.d.ts +4 -9
- package/dist/core/errors/default-handler.js +92 -107
- package/dist/core/errors/dev-handler.d.ts +7 -11
- package/dist/core/errors/dev-handler.js +71 -69
- package/dist/core/errors/errors-data.d.ts +18 -0
- package/dist/core/errors/errors-data.js +7 -0
- package/dist/core/errors/handler.d.ts +22 -3
- package/dist/core/errors/handler.js +25 -0
- package/dist/core/fetch/default-handler.d.ts +15 -8
- package/dist/core/fetch/default-handler.js +12 -34
- package/dist/core/fetch/features.d.ts +23 -0
- package/dist/core/fetch/features.js +27 -0
- package/dist/core/fetch/fetch-state.d.ts +52 -7
- package/dist/core/fetch/fetch-state.js +92 -81
- package/dist/core/fetch/index.d.ts +9 -2
- package/dist/core/fetch/index.js +18 -79
- package/dist/core/fetch/vite-plugin.js +2 -1
- package/dist/core/i18n/handler.d.ts +28 -13
- package/dist/core/i18n/handler.js +100 -100
- package/dist/core/logger/manifest-logger.d.ts +31 -0
- package/dist/core/logger/manifest-logger.js +37 -0
- package/dist/core/manifest/ambient-source.d.ts +2 -0
- package/dist/core/manifest/ambient-source.js +4 -0
- package/dist/core/manifest/ambient.d.ts +16 -0
- package/dist/core/manifest/ambient.js +22 -0
- package/dist/core/manifest/derived.d.ts +3 -0
- package/dist/core/manifest/derived.js +10 -0
- package/dist/core/manifest/memo.d.ts +31 -0
- package/dist/core/manifest/memo.js +47 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/astro-middleware.d.ts +25 -35
- package/dist/core/middleware/astro-middleware.js +61 -81
- package/dist/core/middleware/load.d.ts +19 -0
- package/dist/core/middleware/load.js +36 -0
- package/dist/core/middleware/sequence.js +15 -7
- package/dist/core/pages/handler.d.ts +18 -25
- package/dist/core/pages/handler.js +68 -84
- package/dist/core/redirects/render.js +3 -8
- package/dist/core/render/index.d.ts +0 -1
- package/dist/core/render/index.js +0 -2
- package/dist/core/render/route-cache.d.ts +6 -1
- package/dist/core/render/route-cache.js +11 -1
- package/dist/core/rewrites/handler.d.ts +4 -6
- package/dist/core/rewrites/handler.js +19 -20
- package/dist/core/routing/default.d.ts +2 -0
- package/dist/core/routing/default.js +7 -1
- package/dist/core/routing/dev.d.ts +1 -3
- package/dist/core/routing/dev.js +12 -5
- package/dist/core/routing/handler.d.ts +6 -16
- package/dist/core/routing/handler.js +126 -164
- package/dist/core/routing/helpers.d.ts +7 -1
- package/dist/core/routing/helpers.js +21 -0
- package/dist/core/routing/match-request.d.ts +10 -0
- package/dist/core/routing/match-request.js +57 -0
- package/dist/core/routing/route-table.d.ts +34 -0
- package/dist/core/routing/route-table.js +41 -0
- package/dist/core/routing/trailing-slash-handler.d.ts +4 -14
- package/dist/core/routing/trailing-slash-handler.js +39 -50
- package/dist/core/server-islands/mappings.d.ts +6 -0
- package/dist/core/server-islands/mappings.js +12 -0
- package/dist/core/session/driver.d.ts +4 -0
- package/dist/core/session/driver.js +14 -0
- package/dist/core/session/handler.d.ts +1 -1
- package/dist/core/session/handler.js +8 -8
- package/dist/core/session/provider-disabled.js +2 -2
- package/dist/entrypoints/prerender.js +5 -1
- package/dist/i18n/middleware.d.ts +4 -4
- package/dist/i18n/middleware.js +3 -3
- package/dist/manifest/serialized.d.ts +1 -0
- package/dist/manifest/serialized.js +9 -2
- package/dist/runtime/prerender/static-paths.d.ts +14 -2
- package/dist/runtime/prerender/static-paths.js +4 -3
- package/dist/types/public/config.d.ts +433 -241
- package/dist/vite-plugin-app/createAstroServerApp.js +22 -18
- package/dist/vite-plugin-app/environment.d.ts +18 -0
- package/dist/vite-plugin-app/environment.js +210 -0
- package/dist/vite-plugin-app/handle-request.d.ts +30 -0
- package/dist/vite-plugin-app/handle-request.js +129 -0
- package/dist/vite-plugin-app/index.d.ts +1 -1
- package/dist/vite-plugin-app/index.js +1 -1
- package/package.json +14 -7
- package/src/core/README.md +37 -0
- package/src/core/manifest/ambient-source.ts +9 -0
- package/src/types/README.md +5 -0
- package/dist/container/pipeline.d.ts +0 -14
- package/dist/container/pipeline.js +0 -78
- package/dist/core/app/dev/app.d.ts +0 -31
- package/dist/core/app/dev/app.js +0 -80
- package/dist/core/app/dev/pipeline.d.ts +0 -17
- package/dist/core/app/dev/pipeline.js +0 -133
- package/dist/core/app/pipeline.d.ts +0 -14
- package/dist/core/app/pipeline.js +0 -123
- package/dist/core/base-pipeline.d.ts +0 -183
- package/dist/core/base-pipeline.js +0 -293
- package/dist/core/build/pipeline.d.ts +0 -38
- package/dist/core/build/pipeline.js +0 -202
- package/dist/vite-plugin-app/app.d.ts +0 -62
- package/dist/vite-plugin-app/app.js +0 -237
- package/dist/vite-plugin-app/pipeline.d.ts +0 -25
- package/dist/vite-plugin-app/pipeline.js +0 -189
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Pipeline } from "../core/base-pipeline.js";
|
|
2
|
-
import {
|
|
3
|
-
createModuleScriptElement,
|
|
4
|
-
createStylesheetElementSet
|
|
5
|
-
} from "../core/render/ssr-element.js";
|
|
6
|
-
import { findRouteToRewrite } from "../core/routing/rewrite.js";
|
|
7
|
-
class ContainerPipeline extends Pipeline {
|
|
8
|
-
/**
|
|
9
|
-
* Internal cache to store components instances by `RouteData`.
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
#componentsInterner = /* @__PURE__ */ new WeakMap();
|
|
13
|
-
getName() {
|
|
14
|
-
return "ContainerPipeline";
|
|
15
|
-
}
|
|
16
|
-
static create({
|
|
17
|
-
logger,
|
|
18
|
-
manifest,
|
|
19
|
-
renderers,
|
|
20
|
-
resolve,
|
|
21
|
-
streaming
|
|
22
|
-
}) {
|
|
23
|
-
return new ContainerPipeline(logger, manifest, "development", renderers, resolve, streaming);
|
|
24
|
-
}
|
|
25
|
-
componentMetadata(_routeData) {
|
|
26
|
-
}
|
|
27
|
-
headElements(routeData) {
|
|
28
|
-
const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
|
|
29
|
-
const links = /* @__PURE__ */ new Set();
|
|
30
|
-
const scripts = /* @__PURE__ */ new Set();
|
|
31
|
-
const styles = createStylesheetElementSet(routeInfo?.styles ?? []);
|
|
32
|
-
for (const script of routeInfo?.scripts ?? []) {
|
|
33
|
-
if ("stage" in script) {
|
|
34
|
-
if (script.stage === "head-inline") {
|
|
35
|
-
scripts.add({
|
|
36
|
-
props: {},
|
|
37
|
-
children: script.children
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
scripts.add(createModuleScriptElement(script));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { links, styles, scripts };
|
|
45
|
-
}
|
|
46
|
-
async tryRewrite(payload, request) {
|
|
47
|
-
const { newUrl, pathname, routeData } = findRouteToRewrite({
|
|
48
|
-
payload,
|
|
49
|
-
request,
|
|
50
|
-
routes: this.manifest?.routes.map((r) => r.routeData),
|
|
51
|
-
trailingSlash: this.manifest.trailingSlash,
|
|
52
|
-
buildFormat: this.manifest.buildFormat,
|
|
53
|
-
base: this.manifest.base,
|
|
54
|
-
outDir: this.manifest.outDir
|
|
55
|
-
});
|
|
56
|
-
const componentInstance = await this.getComponentByRoute(routeData);
|
|
57
|
-
return { componentInstance, routeData, newUrl, pathname };
|
|
58
|
-
}
|
|
59
|
-
insertRoute(route, componentInstance) {
|
|
60
|
-
this.#componentsInterner.set(route, {
|
|
61
|
-
page() {
|
|
62
|
-
return Promise.resolve(componentInstance);
|
|
63
|
-
},
|
|
64
|
-
onRequest: this.resolvedMiddleware
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// At the moment it's not used by the container via any public API
|
|
68
|
-
async getComponentByRoute(routeData) {
|
|
69
|
-
const page = this.#componentsInterner.get(routeData);
|
|
70
|
-
if (page) {
|
|
71
|
-
return page.page();
|
|
72
|
-
}
|
|
73
|
-
throw new Error("Couldn't find component for route " + routeData.pathname);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export {
|
|
77
|
-
ContainerPipeline
|
|
78
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { RouteData } from '../../../types/public/index.js';
|
|
2
|
-
import type { ErrorHandler } from '../../errors/handler.js';
|
|
3
|
-
import type { AstroLogger } from '../../logger/core.js';
|
|
4
|
-
import { BaseApp, type DevMatch, type LogRequestPayload } from '../base.js';
|
|
5
|
-
import type { SSRManifest } from '../types.js';
|
|
6
|
-
import { NonRunnablePipeline } from './pipeline.js';
|
|
7
|
-
import type { RoutesList } from '../../../types/astro.js';
|
|
8
|
-
export declare class DevApp extends BaseApp<NonRunnablePipeline> {
|
|
9
|
-
constructor(manifest: SSRManifest, streaming: boolean | undefined, logger: AstroLogger);
|
|
10
|
-
createPipeline(streaming: boolean, manifest: SSRManifest, logger: AstroLogger): NonRunnablePipeline;
|
|
11
|
-
isDev(): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Clears the cached middleware so it is re-resolved on the next request.
|
|
14
|
-
* Called via HMR when middleware files change.
|
|
15
|
-
*/
|
|
16
|
-
clearMiddleware(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Clears the cached actions so they are re-resolved on the next request.
|
|
19
|
-
* Called via HMR when action files change.
|
|
20
|
-
*/
|
|
21
|
-
clearActions(): void;
|
|
22
|
-
/**
|
|
23
|
-
* Updates the routes list when files change during development.
|
|
24
|
-
* Called via HMR when new pages are added/removed.
|
|
25
|
-
*/
|
|
26
|
-
updateRoutes(newRoutesList: RoutesList): void;
|
|
27
|
-
match(request: Request): RouteData | undefined;
|
|
28
|
-
devMatch(pathname: string): Promise<DevMatch | undefined>;
|
|
29
|
-
protected createErrorHandler(): ErrorHandler;
|
|
30
|
-
logRequest({ pathname, method, statusCode, isRewrite, reqTime }: LogRequestPayload): void;
|
|
31
|
-
}
|
package/dist/core/app/dev/app.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { DevErrorHandler } from "../../errors/dev-handler.js";
|
|
2
|
-
import { BaseApp } from "../base.js";
|
|
3
|
-
import { NonRunnablePipeline } from "./pipeline.js";
|
|
4
|
-
import { ensure404Route } from "../../routing/astro-designed-error-pages.js";
|
|
5
|
-
import { matchRoute } from "../../routing/dev.js";
|
|
6
|
-
import { req } from "../../messages/runtime.js";
|
|
7
|
-
class DevApp extends BaseApp {
|
|
8
|
-
constructor(manifest, streaming = true, logger) {
|
|
9
|
-
super(manifest, streaming, logger);
|
|
10
|
-
}
|
|
11
|
-
createPipeline(streaming, manifest, logger) {
|
|
12
|
-
return NonRunnablePipeline.create({
|
|
13
|
-
logger,
|
|
14
|
-
manifest,
|
|
15
|
-
streaming
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
isDev() {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Clears the cached middleware so it is re-resolved on the next request.
|
|
23
|
-
* Called via HMR when middleware files change.
|
|
24
|
-
*/
|
|
25
|
-
clearMiddleware() {
|
|
26
|
-
this.pipeline.clearMiddleware();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Clears the cached actions so they are re-resolved on the next request.
|
|
30
|
-
* Called via HMR when action files change.
|
|
31
|
-
*/
|
|
32
|
-
clearActions() {
|
|
33
|
-
this.pipeline.clearActions();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Updates the routes list when files change during development.
|
|
37
|
-
* Called via HMR when new pages are added/removed.
|
|
38
|
-
*/
|
|
39
|
-
updateRoutes(newRoutesList) {
|
|
40
|
-
this.manifestData = newRoutesList;
|
|
41
|
-
ensure404Route(this.manifestData);
|
|
42
|
-
}
|
|
43
|
-
match(request) {
|
|
44
|
-
return super.match(request, true);
|
|
45
|
-
}
|
|
46
|
-
async devMatch(pathname) {
|
|
47
|
-
const matchedRoute = await matchRoute(
|
|
48
|
-
pathname,
|
|
49
|
-
this.manifestData,
|
|
50
|
-
this.pipeline,
|
|
51
|
-
this.manifest
|
|
52
|
-
);
|
|
53
|
-
if (!matchedRoute) return void 0;
|
|
54
|
-
return {
|
|
55
|
-
routeData: matchedRoute.route,
|
|
56
|
-
resolvedPathname: matchedRoute.resolvedPathname
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
createErrorHandler() {
|
|
60
|
-
return new DevErrorHandler(this, { shouldInjectCspMetaTags: false });
|
|
61
|
-
}
|
|
62
|
-
logRequest({ pathname, method, statusCode, isRewrite, reqTime }) {
|
|
63
|
-
if (pathname === "/favicon.ico") {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
this.logger.info(
|
|
67
|
-
null,
|
|
68
|
-
req({
|
|
69
|
-
url: pathname,
|
|
70
|
-
method,
|
|
71
|
-
statusCode,
|
|
72
|
-
isRewrite,
|
|
73
|
-
reqTime
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
DevApp
|
|
80
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ComponentInstance } from '../../../types/astro.js';
|
|
2
|
-
import type { RewritePayload, RouteData } from '../../../types/public/index.js';
|
|
3
|
-
import { type HeadElements, Pipeline, type TryRewriteResult } from '../../base-pipeline.js';
|
|
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 {
|
|
9
|
-
getName(): string;
|
|
10
|
-
static create({ logger, manifest, streaming }: DevPipelineCreate): NonRunnablePipeline;
|
|
11
|
-
headElements(routeData: RouteData): Promise<HeadElements>;
|
|
12
|
-
clearActions(): void;
|
|
13
|
-
componentMetadata(): void;
|
|
14
|
-
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
15
|
-
tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Pipeline } from "../../base-pipeline.js";
|
|
2
|
-
import { ASTRO_VERSION } from "../../constants.js";
|
|
3
|
-
import { createModuleScriptElement, createStylesheetElementSet } from "../../render/ssr-element.js";
|
|
4
|
-
import { findRouteToRewrite } from "../../routing/rewrite.js";
|
|
5
|
-
import { stringifyForScript } from "../../../runtime/server/escape.js";
|
|
6
|
-
class NonRunnablePipeline extends Pipeline {
|
|
7
|
-
getName() {
|
|
8
|
-
return "NonRunnablePipeline";
|
|
9
|
-
}
|
|
10
|
-
static create({ logger, manifest, streaming }) {
|
|
11
|
-
async function resolve(specifier) {
|
|
12
|
-
if (specifier.startsWith("/")) {
|
|
13
|
-
return specifier;
|
|
14
|
-
} else {
|
|
15
|
-
return "/@id/" + specifier;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const pipeline = new NonRunnablePipeline(
|
|
19
|
-
logger,
|
|
20
|
-
manifest,
|
|
21
|
-
"development",
|
|
22
|
-
manifest.renderers,
|
|
23
|
-
resolve,
|
|
24
|
-
streaming,
|
|
25
|
-
void 0,
|
|
26
|
-
void 0,
|
|
27
|
-
void 0,
|
|
28
|
-
void 0,
|
|
29
|
-
void 0,
|
|
30
|
-
void 0,
|
|
31
|
-
void 0,
|
|
32
|
-
void 0
|
|
33
|
-
);
|
|
34
|
-
return pipeline;
|
|
35
|
-
}
|
|
36
|
-
async headElements(routeData) {
|
|
37
|
-
const { componentMetadataEntries } = await import("virtual:astro:component-metadata");
|
|
38
|
-
for (const [id, entry] of componentMetadataEntries) {
|
|
39
|
-
this.manifest.componentMetadata.set(id, entry);
|
|
40
|
-
}
|
|
41
|
-
const { assetsPrefix, base } = this.manifest;
|
|
42
|
-
const routeInfo = this.manifest.routes.find((route) => route.routeData === routeData);
|
|
43
|
-
const links = /* @__PURE__ */ new Set();
|
|
44
|
-
const scripts = /* @__PURE__ */ new Set();
|
|
45
|
-
const styles = createStylesheetElementSet(routeInfo?.styles ?? [], base, assetsPrefix);
|
|
46
|
-
for (const script of routeInfo?.scripts ?? []) {
|
|
47
|
-
if ("stage" in script) {
|
|
48
|
-
if (script.stage === "head-inline") {
|
|
49
|
-
scripts.add({
|
|
50
|
-
props: {},
|
|
51
|
-
children: script.children
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
scripts.add(createModuleScriptElement(script));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
scripts.add({
|
|
59
|
-
props: { type: "module", src: "/@vite/client" },
|
|
60
|
-
children: ""
|
|
61
|
-
});
|
|
62
|
-
if (this.manifest.devToolbar.enabled) {
|
|
63
|
-
scripts.add({
|
|
64
|
-
props: {
|
|
65
|
-
type: "module",
|
|
66
|
-
src: "/@id/astro/runtime/client/dev-toolbar/entrypoint.js"
|
|
67
|
-
},
|
|
68
|
-
children: ""
|
|
69
|
-
});
|
|
70
|
-
const additionalMetadata = {
|
|
71
|
-
root: this.manifest.rootDir.toString(),
|
|
72
|
-
version: ASTRO_VERSION,
|
|
73
|
-
latestAstroVersion: this.manifest.devToolbar.latestAstroVersion,
|
|
74
|
-
debugInfo: this.manifest.devToolbar.debugInfoOutput ?? "",
|
|
75
|
-
placement: this.manifest.devToolbar.placement
|
|
76
|
-
};
|
|
77
|
-
const children = `window.__astro_dev_toolbar__ = ${stringifyForScript(additionalMetadata)}`;
|
|
78
|
-
scripts.add({ props: {}, children });
|
|
79
|
-
}
|
|
80
|
-
const { devCSSMap } = await import("virtual:astro:dev-css-all");
|
|
81
|
-
const importer = devCSSMap.get(routeData.component);
|
|
82
|
-
let css = /* @__PURE__ */ new Set();
|
|
83
|
-
if (importer) {
|
|
84
|
-
const cssModule = await importer();
|
|
85
|
-
css = cssModule.css;
|
|
86
|
-
} else {
|
|
87
|
-
this.logger.warn(
|
|
88
|
-
"assets",
|
|
89
|
-
`Unable to find CSS for ${routeData.component}. This is likely a bug in Astro.`
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
for (const { id, url: src, content } of css) {
|
|
93
|
-
scripts.add({ props: { type: "module", src }, children: "" });
|
|
94
|
-
styles.add({ props: { "data-vite-dev-id": id }, children: content });
|
|
95
|
-
}
|
|
96
|
-
return { scripts, styles, links };
|
|
97
|
-
}
|
|
98
|
-
// Called via HMR when action files change. Not available on production environment.
|
|
99
|
-
clearActions() {
|
|
100
|
-
this.resolvedActions = void 0;
|
|
101
|
-
}
|
|
102
|
-
componentMetadata() {
|
|
103
|
-
}
|
|
104
|
-
async getComponentByRoute(routeData) {
|
|
105
|
-
try {
|
|
106
|
-
const module2 = await this.getModuleForRoute(routeData);
|
|
107
|
-
return module2.page();
|
|
108
|
-
} catch {
|
|
109
|
-
}
|
|
110
|
-
const url = new URL(routeData.component, this.manifest.rootDir);
|
|
111
|
-
const module = await import(
|
|
112
|
-
/* @vite-ignore */
|
|
113
|
-
url.toString()
|
|
114
|
-
);
|
|
115
|
-
return module;
|
|
116
|
-
}
|
|
117
|
-
async tryRewrite(payload, request) {
|
|
118
|
-
const { newUrl, pathname, routeData } = findRouteToRewrite({
|
|
119
|
-
payload,
|
|
120
|
-
request,
|
|
121
|
-
routes: this.manifest?.routes.map((r) => r.routeData),
|
|
122
|
-
trailingSlash: this.manifest.trailingSlash,
|
|
123
|
-
buildFormat: this.manifest.buildFormat,
|
|
124
|
-
base: this.manifest.base,
|
|
125
|
-
outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
|
|
126
|
-
});
|
|
127
|
-
const componentInstance = await this.getComponentByRoute(routeData);
|
|
128
|
-
return { newUrl, pathname, componentInstance, routeData };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
export {
|
|
132
|
-
NonRunnablePipeline
|
|
133
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ComponentInstance } from '../../types/astro.js';
|
|
2
|
-
import type { RewritePayload } from '../../types/public/common.js';
|
|
3
|
-
import type { RouteData } from '../../types/public/internal.js';
|
|
4
|
-
import { type HeadElements, Pipeline, type TryRewriteResult } from '../base-pipeline.js';
|
|
5
|
-
import type { SinglePageBuiltModule } from '../build/types.js';
|
|
6
|
-
export declare class AppPipeline extends Pipeline {
|
|
7
|
-
getName(): string;
|
|
8
|
-
static create({ manifest, streaming }: Pick<AppPipeline, 'manifest' | 'streaming'>): AppPipeline;
|
|
9
|
-
headElements(routeData: RouteData): Promise<HeadElements>;
|
|
10
|
-
componentMetadata(): void;
|
|
11
|
-
getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
12
|
-
getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
|
|
13
|
-
tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
14
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Pipeline } from "../base-pipeline.js";
|
|
2
|
-
import { RedirectSinglePageBuiltModule } from "../redirects/index.js";
|
|
3
|
-
import {
|
|
4
|
-
createAssetLink,
|
|
5
|
-
createModuleScriptElement,
|
|
6
|
-
createStylesheetElementSet
|
|
7
|
-
} from "../render/ssr-element.js";
|
|
8
|
-
import { getFallbackRoute, routeIsFallback, routeIsRedirect } from "../routing/helpers.js";
|
|
9
|
-
import { findRouteToRewrite } from "../routing/rewrite.js";
|
|
10
|
-
import { createConsoleLogger } from "../logger/impls/console.js";
|
|
11
|
-
class AppPipeline extends Pipeline {
|
|
12
|
-
getName() {
|
|
13
|
-
return "AppPipeline";
|
|
14
|
-
}
|
|
15
|
-
static create({ manifest, streaming }) {
|
|
16
|
-
const resolve = async function resolve2(specifier) {
|
|
17
|
-
if (!(specifier in manifest.entryModules)) {
|
|
18
|
-
throw new Error(`Unable to resolve [${specifier}]`);
|
|
19
|
-
}
|
|
20
|
-
const bundlePath = manifest.entryModules[specifier];
|
|
21
|
-
if (bundlePath.startsWith("data:") || bundlePath.length === 0) {
|
|
22
|
-
return bundlePath;
|
|
23
|
-
} else {
|
|
24
|
-
return createAssetLink(bundlePath, manifest.base, manifest.assetsPrefix);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const logger = createConsoleLogger({ level: manifest.logLevel });
|
|
28
|
-
const pipeline = new AppPipeline(
|
|
29
|
-
logger,
|
|
30
|
-
manifest,
|
|
31
|
-
"production",
|
|
32
|
-
manifest.renderers,
|
|
33
|
-
resolve,
|
|
34
|
-
streaming,
|
|
35
|
-
void 0,
|
|
36
|
-
void 0,
|
|
37
|
-
void 0,
|
|
38
|
-
void 0,
|
|
39
|
-
void 0,
|
|
40
|
-
void 0,
|
|
41
|
-
void 0,
|
|
42
|
-
void 0
|
|
43
|
-
);
|
|
44
|
-
return pipeline;
|
|
45
|
-
}
|
|
46
|
-
async headElements(routeData) {
|
|
47
|
-
const { assetsPrefix, base } = this.manifest;
|
|
48
|
-
const routeInfo = this.manifest.routes.find(
|
|
49
|
-
(route) => route.routeData.route === routeData.route
|
|
50
|
-
);
|
|
51
|
-
const links = /* @__PURE__ */ new Set();
|
|
52
|
-
const scripts = /* @__PURE__ */ new Set();
|
|
53
|
-
const styles = createStylesheetElementSet(routeInfo?.styles ?? [], base, assetsPrefix);
|
|
54
|
-
for (const script of routeInfo?.scripts ?? []) {
|
|
55
|
-
if ("stage" in script) {
|
|
56
|
-
if (script.stage === "head-inline") {
|
|
57
|
-
scripts.add({
|
|
58
|
-
props: {},
|
|
59
|
-
children: script.children
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
scripts.add(createModuleScriptElement(script, base, assetsPrefix));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return { links, styles, scripts };
|
|
67
|
-
}
|
|
68
|
-
componentMetadata() {
|
|
69
|
-
}
|
|
70
|
-
async getComponentByRoute(routeData) {
|
|
71
|
-
const module = await this.getModuleForRoute(routeData);
|
|
72
|
-
return module.page();
|
|
73
|
-
}
|
|
74
|
-
async getModuleForRoute(route) {
|
|
75
|
-
for (const defaultRoute of this.defaultRoutes) {
|
|
76
|
-
if (route.component === defaultRoute.component) {
|
|
77
|
-
return {
|
|
78
|
-
page: () => Promise.resolve(defaultRoute.instance)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let routeToProcess = route;
|
|
83
|
-
if (routeIsRedirect(route)) {
|
|
84
|
-
if (route.redirectRoute) {
|
|
85
|
-
routeToProcess = route.redirectRoute;
|
|
86
|
-
} else {
|
|
87
|
-
return RedirectSinglePageBuiltModule;
|
|
88
|
-
}
|
|
89
|
-
} else if (routeIsFallback(route)) {
|
|
90
|
-
routeToProcess = getFallbackRoute(route, this.manifest.routes);
|
|
91
|
-
}
|
|
92
|
-
if (this.manifest.pageMap) {
|
|
93
|
-
const importComponentInstance = this.manifest.pageMap.get(routeToProcess.component);
|
|
94
|
-
if (!importComponentInstance) {
|
|
95
|
-
throw new Error(
|
|
96
|
-
`Unexpectedly unable to find a component instance for route ${route.route}`
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
return await importComponentInstance();
|
|
100
|
-
} else if (this.manifest.pageModule) {
|
|
101
|
-
return this.manifest.pageModule;
|
|
102
|
-
}
|
|
103
|
-
throw new Error(
|
|
104
|
-
"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue."
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
async tryRewrite(payload, request) {
|
|
108
|
-
const { newUrl, pathname, routeData } = findRouteToRewrite({
|
|
109
|
-
payload,
|
|
110
|
-
request,
|
|
111
|
-
routes: this.manifest?.routes.map((r) => r.routeData),
|
|
112
|
-
trailingSlash: this.manifest.trailingSlash,
|
|
113
|
-
buildFormat: this.manifest.buildFormat,
|
|
114
|
-
base: this.manifest.base,
|
|
115
|
-
outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : this.manifest.outDir
|
|
116
|
-
});
|
|
117
|
-
const componentInstance = await this.getComponentByRoute(routeData);
|
|
118
|
-
return { newUrl, pathname, componentInstance, routeData };
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
AppPipeline
|
|
123
|
-
};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import type { $ZodType } from 'zod/v4/core';
|
|
2
|
-
import type { ActionAccept, ActionClient } from '../actions/runtime/types.js';
|
|
3
|
-
import type { ComponentInstance } from '../types/astro.js';
|
|
4
|
-
import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
|
|
5
|
-
import type { RuntimeMode } from '../types/public/config.js';
|
|
6
|
-
import type { RouteData, SSRActions, SSRLoadedRenderer, SSRManifest, SSRResult } from '../types/public/internal.js';
|
|
7
|
-
import type { ServerIslandMappings } from './app/types.js';
|
|
8
|
-
import type { SinglePageBuiltModule } from './build/types.js';
|
|
9
|
-
import { AstroLogger } from './logger/core.js';
|
|
10
|
-
import { RouteCache } from './render/route-cache.js';
|
|
11
|
-
import { type DefaultRouteParams } from './routing/default.js';
|
|
12
|
-
import type { CacheProvider, CacheProviderFactory } from './cache/types.js';
|
|
13
|
-
import type { CompiledCacheRoute } from './cache/runtime/route-matching.js';
|
|
14
|
-
import type { SessionDriverFactory } from './session/types.js';
|
|
15
|
-
/**
|
|
16
|
-
* Bit flags for pipeline features that handler classes register as
|
|
17
|
-
* "used" when a custom `src/fetch.ts` fetch handler is in play. After the
|
|
18
|
-
* first request (dev) or at runtime (prod SSR), we compare against the
|
|
19
|
-
* manifest to warn about features the user configured but forgot to
|
|
20
|
-
* include in their custom pipeline.
|
|
21
|
-
*/
|
|
22
|
-
export declare const PipelineFeatures: {
|
|
23
|
-
readonly redirects: number;
|
|
24
|
-
readonly sessions: number;
|
|
25
|
-
readonly actions: number;
|
|
26
|
-
readonly middleware: number;
|
|
27
|
-
readonly i18n: number;
|
|
28
|
-
readonly cache: number;
|
|
29
|
-
};
|
|
30
|
-
/** All feature bits ORed together. Keep next to `PipelineFeatures` so
|
|
31
|
-
* new flags are hard to forget. */
|
|
32
|
-
export declare const ALL_PIPELINE_FEATURES: number;
|
|
33
|
-
/**
|
|
34
|
-
* The `Pipeline` represents the static parts of rendering that do not change between requests.
|
|
35
|
-
* These are mostly known when the server first starts up and do not change.
|
|
36
|
-
*
|
|
37
|
-
* Thus, a `Pipeline` is created once at process start and then used by every `FetchState`.
|
|
38
|
-
*/
|
|
39
|
-
export declare abstract class Pipeline {
|
|
40
|
-
#private;
|
|
41
|
-
readonly internalMiddleware: MiddlewareHandler[];
|
|
42
|
-
resolvedMiddleware: MiddlewareHandler | undefined;
|
|
43
|
-
resolvedLogger: boolean;
|
|
44
|
-
resolvedActions: SSRActions | undefined;
|
|
45
|
-
resolvedSessionDriver: SessionDriverFactory | null | undefined;
|
|
46
|
-
resolvedCacheProvider: CacheProvider | null | undefined;
|
|
47
|
-
compiledCacheRoutes: CompiledCacheRoute[] | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Bit mask of pipeline features activated by handler classes.
|
|
50
|
-
* Each handler sets its bit via `|=`. Only meaningful when a
|
|
51
|
-
* custom `src/fetch.ts` fetch handler is in use.
|
|
52
|
-
*/
|
|
53
|
-
usedFeatures: number;
|
|
54
|
-
logger: AstroLogger;
|
|
55
|
-
readonly manifest: SSRManifest;
|
|
56
|
-
/**
|
|
57
|
-
* "development" or "production" only
|
|
58
|
-
*/
|
|
59
|
-
readonly runtimeMode: RuntimeMode;
|
|
60
|
-
readonly renderers: SSRLoadedRenderer[];
|
|
61
|
-
readonly resolve: (s: string) => Promise<string>;
|
|
62
|
-
readonly streaming: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Used to provide better error messages for `Astro.clientAddress`
|
|
65
|
-
*/
|
|
66
|
-
readonly adapterName: SSRManifest['adapterName'];
|
|
67
|
-
readonly clientDirectives: SSRManifest['clientDirectives'];
|
|
68
|
-
readonly inlinedScripts: SSRManifest['inlinedScripts'];
|
|
69
|
-
readonly compressHTML: SSRManifest['compressHTML'];
|
|
70
|
-
readonly i18n: SSRManifest['i18n'];
|
|
71
|
-
readonly middleware: SSRManifest['middleware'];
|
|
72
|
-
readonly routeCache: RouteCache;
|
|
73
|
-
/**
|
|
74
|
-
* Used for `Astro.site`.
|
|
75
|
-
*/
|
|
76
|
-
readonly site: URL | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Array of built-in, internal, routes.
|
|
79
|
-
* Used to find the route module
|
|
80
|
-
*/
|
|
81
|
-
readonly defaultRoutes: Array<DefaultRouteParams>;
|
|
82
|
-
readonly actions: SSRManifest['actions'];
|
|
83
|
-
readonly sessionDriver: SSRManifest['sessionDriver'];
|
|
84
|
-
readonly cacheProvider: SSRManifest['cacheProvider'];
|
|
85
|
-
readonly cacheConfig: SSRManifest['cacheConfig'];
|
|
86
|
-
readonly serverIslands: SSRManifest['serverIslandMappings'];
|
|
87
|
-
/** Route data derived from the manifest, used for route matching. */
|
|
88
|
-
manifestData: {
|
|
89
|
-
routes: RouteData[];
|
|
90
|
-
};
|
|
91
|
-
constructor(logger: AstroLogger, manifest: SSRManifest,
|
|
92
|
-
/**
|
|
93
|
-
* "development" or "production" only
|
|
94
|
-
*/
|
|
95
|
-
runtimeMode: RuntimeMode, renderers: SSRLoadedRenderer[], resolve: (s: string) => Promise<string>, streaming: boolean,
|
|
96
|
-
/**
|
|
97
|
-
* Used to provide better error messages for `Astro.clientAddress`
|
|
98
|
-
*/
|
|
99
|
-
adapterName?: string, clientDirectives?: Map<string, string>, inlinedScripts?: Map<string, string>, compressHTML?: boolean | "jsx", i18n?: import("./app/types.js").SSRManifestI18n | undefined, middleware?: (() => Promise<import("../types/public/common.js").AstroMiddlewareInstance> | import("../types/public/common.js").AstroMiddlewareInstance) | undefined, routeCache?: RouteCache,
|
|
100
|
-
/**
|
|
101
|
-
* Used for `Astro.site`.
|
|
102
|
-
*/
|
|
103
|
-
site?: URL | undefined,
|
|
104
|
-
/**
|
|
105
|
-
* Array of built-in, internal, routes.
|
|
106
|
-
* Used to find the route module
|
|
107
|
-
*/
|
|
108
|
-
defaultRoutes?: DefaultRouteParams[], actions?: (() => Promise<SSRActions> | SSRActions) | undefined, sessionDriver?: (() => Promise<{
|
|
109
|
-
default: SessionDriverFactory | null;
|
|
110
|
-
}>) | undefined, cacheProvider?: (() => Promise<{
|
|
111
|
-
default: CacheProviderFactory | null;
|
|
112
|
-
}>) | undefined, cacheConfig?: import("./cache/types.js").SSRManifestCache | undefined, serverIslands?: (() => Promise<ServerIslandMappings> | ServerIslandMappings) | undefined);
|
|
113
|
-
/**
|
|
114
|
-
* Low-level route matching against the manifest routes. Returns the
|
|
115
|
-
* matched `RouteData` or `undefined`. Does not filter prerendered
|
|
116
|
-
* routes or check public assets — use `BaseApp.match()` for that.
|
|
117
|
-
*/
|
|
118
|
-
matchRoute(pathname: string): RouteData | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Returns all routes matching the given pathname, in priority order.
|
|
121
|
-
* Used when the first match cannot serve the request (e.g. a
|
|
122
|
-
* prerendered dynamic route that doesn't cover this specific path)
|
|
123
|
-
* and the caller needs to try subsequent matches.
|
|
124
|
-
*/
|
|
125
|
-
matchAllRoutes(pathname: string): RouteData[];
|
|
126
|
-
/**
|
|
127
|
-
* Rebuilds the internal router after routes have been added or
|
|
128
|
-
* removed (e.g. by the dev server on HMR).
|
|
129
|
-
*/
|
|
130
|
-
rebuildRouter(): void;
|
|
131
|
-
abstract headElements(routeData: RouteData): Promise<HeadElements> | HeadElements;
|
|
132
|
-
abstract componentMetadata(routeData: RouteData): Promise<SSRResult['componentMetadata']> | void;
|
|
133
|
-
/**
|
|
134
|
-
* It attempts to retrieve the `RouteData` that matches the input `url`, and the component that belongs to the `RouteData`.
|
|
135
|
-
*
|
|
136
|
-
* ## Errors
|
|
137
|
-
*
|
|
138
|
-
* - if not `RouteData` is found
|
|
139
|
-
*
|
|
140
|
-
* @param {RewritePayload} rewritePayload The payload provided by the user
|
|
141
|
-
* @param {Request} request The original request
|
|
142
|
-
*/
|
|
143
|
-
abstract tryRewrite(rewritePayload: RewritePayload, request: Request): Promise<TryRewriteResult>;
|
|
144
|
-
/**
|
|
145
|
-
* Tells the pipeline how to retrieve a component give a `RouteData`
|
|
146
|
-
* @param routeData
|
|
147
|
-
*/
|
|
148
|
-
abstract getComponentByRoute(routeData: RouteData): Promise<ComponentInstance>;
|
|
149
|
-
/**
|
|
150
|
-
* The current name of the pipeline. Useful for debugging
|
|
151
|
-
*/
|
|
152
|
-
abstract getName(): string;
|
|
153
|
-
/**
|
|
154
|
-
* Resolves the middleware from the manifest, and returns the `onRequest` function. If `onRequest` isn't there,
|
|
155
|
-
* it returns a no-op function
|
|
156
|
-
*/
|
|
157
|
-
getMiddleware(): Promise<MiddlewareHandler>;
|
|
158
|
-
/**
|
|
159
|
-
* Clears the cached middleware so it is re-resolved on the next request.
|
|
160
|
-
* Called via HMR when middleware files change during development.
|
|
161
|
-
*/
|
|
162
|
-
clearMiddleware(): void;
|
|
163
|
-
/**
|
|
164
|
-
* Resolves the logger destination from the manifest and updates the pipeline logger.
|
|
165
|
-
* If the user configured `logger`, the bundled logger factory is loaded
|
|
166
|
-
* and replaces the default console destination. This is lazy and only resolves once.
|
|
167
|
-
*/
|
|
168
|
-
getLogger(): Promise<AstroLogger>;
|
|
169
|
-
getActions(): Promise<SSRActions>;
|
|
170
|
-
getSessionDriver(): Promise<SessionDriverFactory | null>;
|
|
171
|
-
getCacheProvider(): Promise<CacheProvider | null>;
|
|
172
|
-
getServerIslands(): Promise<ServerIslandMappings>;
|
|
173
|
-
getAction(path: string): Promise<ActionClient<unknown, ActionAccept, $ZodType>>;
|
|
174
|
-
getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule>;
|
|
175
|
-
}
|
|
176
|
-
export interface HeadElements extends Pick<SSRResult, 'scripts' | 'styles' | 'links'> {
|
|
177
|
-
}
|
|
178
|
-
export interface TryRewriteResult {
|
|
179
|
-
routeData: RouteData;
|
|
180
|
-
componentInstance: ComponentInstance;
|
|
181
|
-
newUrl: URL;
|
|
182
|
-
pathname: string;
|
|
183
|
-
}
|