astro 2.8.5 → 2.9.1
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/client-base.d.ts +9 -0
- package/components/ViewTransitions.astro +175 -0
- package/components/index.ts +1 -0
- package/components/viewtransitions.css +56 -0
- package/dist/@types/astro.d.ts +28 -10
- package/dist/assets/services/vendor/squoosh/impl.js +1 -1
- package/dist/content/runtime.js +1 -1
- package/dist/content/vite-plugin-content-assets.js +2 -2
- package/dist/core/app/index.js +115 -95
- package/dist/core/build/generate.js +18 -33
- package/dist/core/build/graph.js +1 -1
- package/dist/core/build/plugins/plugin-analyzer.js +101 -3
- package/dist/core/build/plugins/plugin-css.js +1 -1
- package/dist/core/build/types.d.ts +1 -1
- package/dist/core/compile/compile.js +2 -0
- package/dist/core/config/config.js +3 -5
- package/dist/core/config/schema.d.ts +85 -48
- package/dist/core/config/schema.js +36 -10
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +2 -11
- package/dist/core/endpoint/index.d.ts +2 -3
- package/dist/core/endpoint/index.js +1 -11
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/index.js +3 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.d.ts +1 -1
- package/dist/core/render/core.d.ts +9 -3
- package/dist/core/render/core.js +42 -18
- package/dist/core/render/environment.d.ts +7 -2
- package/dist/core/render/index.d.ts +22 -1
- package/dist/core/render/index.js +2 -2
- package/dist/core/render/route-cache.js +1 -1
- package/dist/core/routing/validation.d.ts +2 -3
- package/dist/core/routing/validation.js +0 -9
- package/dist/jsx-runtime/index.d.ts +1 -1
- package/dist/prerender/routing.d.ts +1 -1
- package/dist/prerender/routing.js +1 -1
- package/dist/runtime/server/astro-component.d.ts +1 -1
- package/dist/runtime/server/astro-component.js +5 -5
- package/dist/runtime/server/index.d.ts +2 -1
- package/dist/runtime/server/index.js +3 -1
- package/dist/runtime/server/jsx.js +6 -2
- package/dist/runtime/server/render/astro/factory.d.ts +0 -1
- package/dist/runtime/server/render/astro/factory.js +1 -18
- package/dist/runtime/server/render/astro/index.d.ts +2 -1
- package/dist/runtime/server/render/astro/index.js +3 -1
- package/dist/runtime/server/render/astro/render.d.ts +4 -0
- package/dist/runtime/server/render/astro/render.js +119 -0
- package/dist/runtime/server/render/common.d.ts +8 -0
- package/dist/runtime/server/render/common.js +11 -3
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/runtime/server/render/page.js +18 -89
- package/dist/runtime/server/transition.d.ts +2 -0
- package/dist/runtime/server/transition.js +133 -0
- package/dist/transitions/index.d.ts +7 -0
- package/dist/transitions/index.js +67 -0
- package/dist/transitions/vite-plugin-transitions.d.ts +5 -0
- package/dist/transitions/vite-plugin-transitions.js +36 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/css.js +1 -1
- package/dist/vite-plugin-astro-server/environment.d.ts +5 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/environment.js +3 -3
- package/dist/vite-plugin-astro-server/index.d.ts +6 -0
- package/dist/vite-plugin-astro-server/index.js +21 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.d.ts +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/metadata.js +2 -2
- package/dist/vite-plugin-astro-server/plugin.js +1 -1
- package/dist/vite-plugin-astro-server/request.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/resolve.js +1 -1
- package/dist/vite-plugin-astro-server/route.d.ts +1 -1
- package/dist/vite-plugin-astro-server/route.js +93 -20
- package/dist/vite-plugin-astro-server/scripts.d.ts +3 -0
- package/dist/{core/render/dev → vite-plugin-astro-server}/scripts.js +2 -2
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.d.ts +1 -1
- package/dist/{core/render/dev → vite-plugin-astro-server}/vite.js +2 -2
- package/dist/vite-plugin-markdown/index.js +1 -1
- package/dist/vite-plugin-scanner/index.d.ts +6 -3
- package/dist/vite-plugin-scanner/index.js +21 -4
- package/dist/vite-plugin-scanner/scan.d.ts +2 -1
- package/dist/vite-plugin-scanner/scan.js +6 -2
- package/package.json +6 -3
- package/dist/core/render/dev/environment.d.ts +0 -9
- package/dist/core/render/dev/index.d.ts +0 -27
- package/dist/core/render/dev/index.js +0 -112
- package/dist/core/render/dev/scripts.d.ts +0 -3
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.d.ts +0 -0
- /package/dist/{core/render/dev → vite-plugin-astro-server}/util.js +0 -0
package/dist/core/create-vite.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
astroContentImportPlugin,
|
|
9
9
|
astroContentVirtualModPlugin
|
|
10
10
|
} from "../content/index.js";
|
|
11
|
+
import astroTransitions from "../transitions/vite-plugin-transitions.js";
|
|
11
12
|
import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.js";
|
|
12
13
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
13
14
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
@@ -99,13 +100,14 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
99
100
|
mode === "dev" && astroIntegrationsContainerPlugin({ settings, logging }),
|
|
100
101
|
astroScriptsPageSSRPlugin({ settings }),
|
|
101
102
|
astroHeadPlugin(),
|
|
102
|
-
astroScannerPlugin({ settings }),
|
|
103
|
+
astroScannerPlugin({ settings, logging }),
|
|
103
104
|
astroInjectEnvTsPlugin({ settings, logging, fs }),
|
|
104
105
|
astroContentVirtualModPlugin({ settings }),
|
|
105
106
|
astroContentImportPlugin({ fs, settings }),
|
|
106
107
|
astroContentAssetPropagationPlugin({ mode, settings }),
|
|
107
108
|
vitePluginSSRManifest(),
|
|
108
|
-
settings.config.experimental.assets ? [astroAssetsPlugin({ settings, logging, mode })] : []
|
|
109
|
+
settings.config.experimental.assets ? [astroAssetsPlugin({ settings, logging, mode })] : [],
|
|
110
|
+
astroTransitions({ config: settings.config })
|
|
109
111
|
],
|
|
110
112
|
publicDir: fileURLToPath(settings.config.publicDir),
|
|
111
113
|
root: fileURLToPath(settings.config.root),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -54,7 +54,7 @@ async function dev(settings, options) {
|
|
|
54
54
|
isRestart: options.isRestart
|
|
55
55
|
})
|
|
56
56
|
);
|
|
57
|
-
const currentVersion = "2.
|
|
57
|
+
const currentVersion = "2.9.1";
|
|
58
58
|
if (currentVersion.includes("-")) {
|
|
59
59
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
60
60
|
}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare function call(options: SSROptions): Promise<{
|
|
4
|
-
type: "simple";
|
|
5
|
-
body: string;
|
|
6
|
-
encoding?: BufferEncoding | undefined;
|
|
7
|
-
cookies: import("../../cookies/cookies").AstroCookies;
|
|
8
|
-
} | {
|
|
9
|
-
type: "response";
|
|
10
|
-
response: Response;
|
|
11
|
-
}>;
|
|
1
|
+
import { type SSROptions } from '../../render/index.js';
|
|
2
|
+
export declare function call(options: SSROptions): Promise<import("../index.js").EndpointCallResult>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { APIContext,
|
|
2
|
+
import type { APIContext, EndpointHandler, EndpointOutput, MiddlewareHandler, Params } from '../../@types/astro';
|
|
3
3
|
import type { Environment, RenderContext } from '../render/index';
|
|
4
4
|
import { AstroCookies } from '../cookies/index.js';
|
|
5
|
-
type EndpointCallResult = {
|
|
5
|
+
export type EndpointCallResult = {
|
|
6
6
|
type: 'simple';
|
|
7
7
|
body: string;
|
|
8
8
|
encoding?: BufferEncoding;
|
|
@@ -25,5 +25,4 @@ type CreateAPIContext = {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function createAPIContext({ request, params, site, props, adapterName, }: CreateAPIContext): APIContext;
|
|
27
27
|
export declare function callEndpoint<MiddlewareResult = Response | EndpointOutput>(mod: EndpointHandler, env: Environment, ctx: RenderContext, onRequest?: MiddlewareHandler<MiddlewareResult> | undefined): Promise<EndpointCallResult>;
|
|
28
|
-
export declare function throwIfRedirectNotAllowed(response: Response, config: AstroConfig): void;
|
|
29
28
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
2
1
|
import { renderEndpoint } from "../../runtime/server/index.js";
|
|
3
2
|
import { ASTRO_VERSION } from "../constants.js";
|
|
4
3
|
import { AstroCookies, attachToResponse } from "../cookies/index.js";
|
|
@@ -111,16 +110,7 @@ async function callEndpoint(mod, env, ctx, onRequest) {
|
|
|
111
110
|
cookies: context.cookies
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
|
-
function isRedirect(statusCode) {
|
|
115
|
-
return statusCode >= 300 && statusCode < 400;
|
|
116
|
-
}
|
|
117
|
-
function throwIfRedirectNotAllowed(response, config) {
|
|
118
|
-
if (!isServerLikeOutput(config) && isRedirect(response.status) && !config.experimental.redirects) {
|
|
119
|
-
throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
113
|
export {
|
|
123
114
|
callEndpoint,
|
|
124
|
-
createAPIContext
|
|
125
|
-
throwIfRedirectNotAllowed
|
|
115
|
+
createAPIContext
|
|
126
116
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { ErrorLocation, ErrorWithMetadata } from './errors';
|
|
2
2
|
export { AstroErrorData } from './errors-data.js';
|
|
3
|
-
export { AggregateError, AstroError, CompilerError,
|
|
3
|
+
export { AggregateError, AstroError, CSSError, CompilerError, MarkdownError, isAstroError, } from './errors.js';
|
|
4
4
|
export { codeFrame } from './printer.js';
|
|
5
5
|
export { createSafeError, positionAt } from './utils.js';
|
|
@@ -2,10 +2,10 @@ import { AstroErrorData } from "./errors-data.js";
|
|
|
2
2
|
import {
|
|
3
3
|
AggregateError,
|
|
4
4
|
AstroError,
|
|
5
|
-
CompilerError,
|
|
6
5
|
CSSError,
|
|
7
|
-
|
|
8
|
-
MarkdownError
|
|
6
|
+
CompilerError,
|
|
7
|
+
MarkdownError,
|
|
8
|
+
isAstroError
|
|
9
9
|
} from "./errors.js";
|
|
10
10
|
import { codeFrame } from "./printer.js";
|
|
11
11
|
import { createSafeError, positionAt } from "./utils.js";
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.
|
|
50
|
+
const version = "2.9.1";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.
|
|
236
|
+
`v${"2.9.1"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -30,4 +30,4 @@ declare function createContext({ request, params }: CreateContext): import("../.
|
|
|
30
30
|
* @param value
|
|
31
31
|
*/
|
|
32
32
|
declare function trySerializeLocals(value: unknown): string;
|
|
33
|
-
export {
|
|
33
|
+
export { createContext, defineMiddleware, sequence, trySerializeLocals };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AstroCookies, ComponentInstance, MiddlewareHandler } from '../../@types/astro';
|
|
1
|
+
import type { AstroCookies, ComponentInstance, MiddlewareHandler, RouteType } from '../../@types/astro';
|
|
2
|
+
import { type EndpointCallResult } from '../endpoint/index.js';
|
|
2
3
|
import type { RenderContext } from './context.js';
|
|
3
4
|
import type { Environment } from './environment.js';
|
|
4
5
|
export type RenderPage = {
|
|
@@ -8,10 +9,15 @@ export type RenderPage = {
|
|
|
8
9
|
cookies: AstroCookies;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
|
-
* It attempts to render a
|
|
12
|
+
* It attempts to render a route. A route can be a:
|
|
13
|
+
* - page
|
|
14
|
+
* - redirect
|
|
15
|
+
* - endpoint
|
|
12
16
|
*
|
|
13
17
|
* ## Errors
|
|
14
18
|
*
|
|
15
19
|
* It throws an error if the page can't be rendered.
|
|
16
20
|
*/
|
|
17
|
-
export declare function
|
|
21
|
+
export declare function tryRenderRoute<MiddlewareReturnType = Response>(routeType: RouteType, renderContext: Readonly<RenderContext>, env: Readonly<Environment>, mod: Readonly<ComponentInstance>, onRequest?: MiddlewareHandler<MiddlewareReturnType>): Promise<Response | EndpointCallResult>;
|
|
22
|
+
export declare function isEndpointResult(result: any, routeType: RouteType): result is EndpointCallResult;
|
|
23
|
+
export declare function isResponse(result: any, routeType: RouteType): result is Response;
|
package/dist/core/render/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderPage as runtimeRenderPage } from "../../runtime/server/index.js";
|
|
2
2
|
import { attachToResponse } from "../cookies/index.js";
|
|
3
|
-
import { createAPIContext } from "../endpoint/index.js";
|
|
3
|
+
import { callEndpoint, createAPIContext } from "../endpoint/index.js";
|
|
4
4
|
import { callMiddleware } from "../middleware/callMiddleware.js";
|
|
5
5
|
import { redirectRouteGenerate, redirectRouteStatus, routeIsRedirect } from "../redirects/index.js";
|
|
6
6
|
import { createResult } from "./result.js";
|
|
@@ -53,7 +53,7 @@ async function renderPage({ mod, renderContext, env, cookies }) {
|
|
|
53
53
|
}
|
|
54
54
|
return response;
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
56
|
+
async function tryRenderRoute(routeType, renderContext, env, mod, onRequest) {
|
|
57
57
|
const apiContext = createAPIContext({
|
|
58
58
|
request: renderContext.request,
|
|
59
59
|
params: renderContext.params,
|
|
@@ -61,29 +61,53 @@ async function tryRenderPage(renderContext, env, mod, onRequest) {
|
|
|
61
61
|
site: env.site,
|
|
62
62
|
adapterName: env.adapterName
|
|
63
63
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
onRequest
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
switch (routeType) {
|
|
65
|
+
case "page":
|
|
66
|
+
case "redirect": {
|
|
67
|
+
if (onRequest) {
|
|
68
|
+
return await callMiddleware(
|
|
69
|
+
env.logging,
|
|
70
|
+
onRequest,
|
|
71
|
+
apiContext,
|
|
72
|
+
() => {
|
|
73
|
+
return renderPage({
|
|
74
|
+
mod,
|
|
75
|
+
renderContext,
|
|
76
|
+
env,
|
|
77
|
+
cookies: apiContext.cookies
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
return await renderPage({
|
|
71
83
|
mod,
|
|
72
84
|
renderContext,
|
|
73
85
|
env,
|
|
74
86
|
cookies: apiContext.cookies
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
}
|
|
90
|
+
case "endpoint": {
|
|
91
|
+
const result = await callEndpoint(
|
|
92
|
+
mod,
|
|
93
|
+
env,
|
|
94
|
+
renderContext,
|
|
95
|
+
onRequest
|
|
96
|
+
);
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
default:
|
|
100
|
+
throw new Error(`Couldn't find route of type [${routeType}]`);
|
|
85
101
|
}
|
|
86
102
|
}
|
|
103
|
+
function isEndpointResult(result, routeType) {
|
|
104
|
+
return !(result instanceof Response) && routeType === "endpoint";
|
|
105
|
+
}
|
|
106
|
+
function isResponse(result, routeType) {
|
|
107
|
+
return result instanceof Response && (routeType === "page" || routeType === "redirect");
|
|
108
|
+
}
|
|
87
109
|
export {
|
|
88
|
-
|
|
110
|
+
isEndpointResult,
|
|
111
|
+
isResponse,
|
|
112
|
+
tryRenderRoute
|
|
89
113
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
|
2
|
-
import type { RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
|
|
2
|
+
import type { AstroSettings, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
|
|
3
3
|
import type { LogOptions } from '../logger/core.js';
|
|
4
|
+
import type { ModuleLoader } from '../module-loader';
|
|
4
5
|
import type { RouteCache } from './route-cache.js';
|
|
5
6
|
/**
|
|
6
7
|
* An environment represents the static parts of rendering that do not change
|
|
7
8
|
* between requests. These are mostly known when the server first starts up and do not change.
|
|
8
|
-
* Thus they can be created once and passed through to renderPage on each request.
|
|
9
|
+
* Thus, they can be created once and passed through to renderPage on each request.
|
|
9
10
|
*/
|
|
10
11
|
export interface Environment {
|
|
11
12
|
/**
|
|
@@ -37,3 +38,7 @@ export interface Environment {
|
|
|
37
38
|
}
|
|
38
39
|
export type CreateEnvironmentArgs = Environment;
|
|
39
40
|
export declare function createEnvironment(options: CreateEnvironmentArgs): Environment;
|
|
41
|
+
export type DevelopmentEnvironment = Environment & {
|
|
42
|
+
loader: ModuleLoader;
|
|
43
|
+
settings: AstroSettings;
|
|
44
|
+
};
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
import type { AstroMiddlewareInstance, ComponentInstance, RouteData } from '../../@types/astro';
|
|
2
|
+
import type { DevelopmentEnvironment } from './environment';
|
|
1
3
|
export { createRenderContext } from './context.js';
|
|
2
4
|
export type { RenderContext } from './context.js';
|
|
3
|
-
export {
|
|
5
|
+
export { tryRenderRoute } from './core.js';
|
|
4
6
|
export type { Environment } from './environment';
|
|
5
7
|
export { createEnvironment } from './environment.js';
|
|
6
8
|
export { getParamsAndProps } from './params-and-props.js';
|
|
7
9
|
export { loadRenderer, loadRenderers } from './renderer.js';
|
|
10
|
+
export type { DevelopmentEnvironment };
|
|
11
|
+
export interface SSROptions {
|
|
12
|
+
/** The environment instance */
|
|
13
|
+
env: DevelopmentEnvironment;
|
|
14
|
+
/** location of file on disk */
|
|
15
|
+
filePath: URL;
|
|
16
|
+
/** the web request (needed for dynamic routes) */
|
|
17
|
+
pathname: string;
|
|
18
|
+
/** The runtime component instance */
|
|
19
|
+
preload: ComponentInstance;
|
|
20
|
+
/** Request */
|
|
21
|
+
request: Request;
|
|
22
|
+
/** optional, in case we need to render something outside of a dev server */
|
|
23
|
+
route?: RouteData;
|
|
24
|
+
/**
|
|
25
|
+
* Optional middlewares
|
|
26
|
+
*/
|
|
27
|
+
middleware?: AstroMiddlewareInstance<unknown>;
|
|
28
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRenderContext } from "./context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { tryRenderRoute } from "./core.js";
|
|
3
3
|
import { createEnvironment } from "./environment.js";
|
|
4
4
|
import { getParamsAndProps } from "./params-and-props.js";
|
|
5
5
|
import { loadRenderer, loadRenderers } from "./renderer.js";
|
|
@@ -9,5 +9,5 @@ export {
|
|
|
9
9
|
getParamsAndProps,
|
|
10
10
|
loadRenderer,
|
|
11
11
|
loadRenderers,
|
|
12
|
-
|
|
12
|
+
tryRenderRoute
|
|
13
13
|
};
|
|
@@ -14,7 +14,7 @@ async function callGetStaticPaths({
|
|
|
14
14
|
const cached = routeCache.get(route);
|
|
15
15
|
if (cached == null ? void 0 : cached.staticPaths)
|
|
16
16
|
return cached.staticPaths;
|
|
17
|
-
validateDynamicRouteModule(mod, { ssr,
|
|
17
|
+
validateDynamicRouteModule(mod, { ssr, route });
|
|
18
18
|
if (ssr && !route.prerender) {
|
|
19
19
|
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
20
20
|
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
@@ -2,10 +2,9 @@ import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@
|
|
|
2
2
|
import type { LogOptions } from '../logger/core';
|
|
3
3
|
/** Throws error for invalid parameter in getStaticPaths() response */
|
|
4
4
|
export declare function validateGetStaticPathsParameter([key, value]: [string, any], route: string): void;
|
|
5
|
-
/**
|
|
6
|
-
export declare function validateDynamicRouteModule(mod: ComponentInstance, { ssr,
|
|
5
|
+
/** Error for deprecated or malformed route components */
|
|
6
|
+
export declare function validateDynamicRouteModule(mod: ComponentInstance, { ssr, route, }: {
|
|
7
7
|
ssr: boolean;
|
|
8
|
-
logging: LogOptions;
|
|
9
8
|
route: RouteData;
|
|
10
9
|
}): void;
|
|
11
10
|
/** Throw error and log warnings for malformed getStaticPaths() response */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { bold } from "kleur/colors";
|
|
2
1
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
3
2
|
import { warn } from "../logger/core.js";
|
|
4
3
|
const VALID_PARAM_TYPES = ["string", "number", "undefined"];
|
|
@@ -15,16 +14,8 @@ function validateGetStaticPathsParameter([key, value], route) {
|
|
|
15
14
|
}
|
|
16
15
|
function validateDynamicRouteModule(mod, {
|
|
17
16
|
ssr,
|
|
18
|
-
logging,
|
|
19
17
|
route
|
|
20
18
|
}) {
|
|
21
|
-
if (ssr && mod.getStaticPaths && !route.prerender) {
|
|
22
|
-
warn(
|
|
23
|
-
logging,
|
|
24
|
-
"getStaticPaths",
|
|
25
|
-
`getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
19
|
if ((!ssr || route.prerender) && !mod.getStaticPaths) {
|
|
29
20
|
throw new AstroError({
|
|
30
21
|
...AstroErrorData.GetStaticPathsRequired,
|
|
@@ -9,4 +9,4 @@ export interface AstroVNode {
|
|
|
9
9
|
export declare function isVNode(vnode: any): vnode is AstroVNode;
|
|
10
10
|
export declare function transformSlots(vnode: AstroVNode): AstroVNode | undefined;
|
|
11
11
|
declare function createVNode(type: any, props: Record<string, any>): AstroVNode;
|
|
12
|
-
export { AstroJSX, createVNode as jsx, createVNode as
|
|
12
|
+
export { AstroJSX, Fragment, createVNode as jsx, createVNode as jsxDEV, createVNode as jsxs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroSettings, ComponentInstance, RouteData } from '../@types/astro';
|
|
2
|
-
import {
|
|
2
|
+
import type { DevelopmentEnvironment } from '../core/render';
|
|
3
3
|
type GetSortedPreloadedMatchesParams = {
|
|
4
4
|
env: DevelopmentEnvironment;
|
|
5
5
|
matches: RouteData[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedirectComponentInstance, routeIsRedirect } from "../core/redirects/index.js";
|
|
2
|
-
import { preload } from "../
|
|
2
|
+
import { preload } from "../vite-plugin-astro-server/index.js";
|
|
3
3
|
import { getPrerenderStatus } from "./metadata.js";
|
|
4
4
|
async function getSortedPreloadedMatches({
|
|
5
5
|
env,
|
|
@@ -5,5 +5,5 @@ interface CreateComponentOptions {
|
|
|
5
5
|
moduleId?: string;
|
|
6
6
|
propagation?: PropagationHint;
|
|
7
7
|
}
|
|
8
|
-
export declare function createComponent(arg1: AstroComponentFactory | CreateComponentOptions, moduleId?: string): AstroComponentFactory;
|
|
8
|
+
export declare function createComponent(arg1: AstroComponentFactory | CreateComponentOptions, moduleId?: string, propagation?: PropagationHint): AstroComponentFactory;
|
|
9
9
|
export {};
|
|
@@ -6,7 +6,7 @@ function validateArgs(args) {
|
|
|
6
6
|
return false;
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
|
-
function baseCreateComponent(cb, moduleId) {
|
|
9
|
+
function baseCreateComponent(cb, moduleId, propagation) {
|
|
10
10
|
var _a;
|
|
11
11
|
const name = ((_a = moduleId == null ? void 0 : moduleId.split("/").pop()) == null ? void 0 : _a.replace(".astro", "")) ?? "";
|
|
12
12
|
const fn = (...args) => {
|
|
@@ -21,16 +21,16 @@ function baseCreateComponent(cb, moduleId) {
|
|
|
21
21
|
Object.defineProperty(fn, "name", { value: name, writable: false });
|
|
22
22
|
fn.isAstroComponentFactory = true;
|
|
23
23
|
fn.moduleId = moduleId;
|
|
24
|
+
fn.propagation = propagation;
|
|
24
25
|
return fn;
|
|
25
26
|
}
|
|
26
27
|
function createComponentWithOptions(opts) {
|
|
27
|
-
const cb = baseCreateComponent(opts.factory, opts.moduleId);
|
|
28
|
-
cb.propagation = opts.propagation;
|
|
28
|
+
const cb = baseCreateComponent(opts.factory, opts.moduleId, opts.propagation);
|
|
29
29
|
return cb;
|
|
30
30
|
}
|
|
31
|
-
function createComponent(arg1, moduleId) {
|
|
31
|
+
function createComponent(arg1, moduleId, propagation) {
|
|
32
32
|
if (typeof arg1 === "function") {
|
|
33
|
-
return baseCreateComponent(arg1, moduleId);
|
|
33
|
+
return baseCreateComponent(arg1, moduleId, propagation);
|
|
34
34
|
} else {
|
|
35
35
|
return createComponentWithOptions(arg1);
|
|
36
36
|
}
|
|
@@ -3,8 +3,9 @@ export { createAstro } from './astro-global.js';
|
|
|
3
3
|
export { renderEndpoint } from './endpoint.js';
|
|
4
4
|
export { escapeHTML, HTMLBytes, HTMLString, isHTMLString, markHTMLString, unescapeHTML, } from './escape.js';
|
|
5
5
|
export { renderJSX } from './jsx.js';
|
|
6
|
-
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderSlotToString, renderTemplate
|
|
6
|
+
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderTemplate as render, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderSlotToString, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
7
7
|
export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
|
|
8
|
+
export { renderTransition } from './transition.js';
|
|
8
9
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
9
10
|
/** @internal Associate JSX components with a specific renderer (see /src/vite-plugin-jsx/tag.ts) */
|
|
10
11
|
export declare function __astro_tag_component__(Component: unknown, rendererName: string): void;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
defineScriptVars,
|
|
17
17
|
Fragment,
|
|
18
18
|
maybeRenderHead,
|
|
19
|
+
renderTemplate,
|
|
19
20
|
renderAstroTemplateResult,
|
|
20
21
|
renderComponent,
|
|
21
22
|
renderComponentToIterable,
|
|
@@ -26,13 +27,13 @@ import {
|
|
|
26
27
|
renderScriptElement,
|
|
27
28
|
renderSlot,
|
|
28
29
|
renderSlotToString,
|
|
29
|
-
renderTemplate,
|
|
30
30
|
renderTemplate as renderTemplate2,
|
|
31
31
|
renderToString,
|
|
32
32
|
renderUniqueStylesheet,
|
|
33
33
|
stringifyChunk,
|
|
34
34
|
voidElementNames
|
|
35
35
|
} from "./render/index.js";
|
|
36
|
+
import { renderTransition } from "./transition.js";
|
|
36
37
|
import { markHTMLString as markHTMLString2 } from "./escape.js";
|
|
37
38
|
import { addAttribute as addAttribute2, Renderer as Renderer2 } from "./render/index.js";
|
|
38
39
|
function mergeSlots(...slotted) {
|
|
@@ -118,6 +119,7 @@ export {
|
|
|
118
119
|
renderSlotToString,
|
|
119
120
|
renderTemplate2 as renderTemplate,
|
|
120
121
|
renderToString,
|
|
122
|
+
renderTransition,
|
|
121
123
|
renderUniqueStylesheet,
|
|
122
124
|
spreadAttributes,
|
|
123
125
|
stringifyChunk,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AstroJSX, isVNode } from "../../jsx-runtime/index.js";
|
|
2
2
|
import {
|
|
3
|
-
escapeHTML,
|
|
4
3
|
HTMLString,
|
|
4
|
+
escapeHTML,
|
|
5
5
|
markHTMLString,
|
|
6
6
|
renderComponentToIterable,
|
|
7
7
|
renderToString,
|
|
@@ -77,7 +77,11 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
77
77
|
props[key] = value;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const str = await renderToString(result, vnode.type, props, slots);
|
|
81
|
+
if (str instanceof Response) {
|
|
82
|
+
throw str;
|
|
83
|
+
}
|
|
84
|
+
const html = markHTMLString(str);
|
|
81
85
|
return html;
|
|
82
86
|
}
|
|
83
87
|
case (!vnode.type && vnode.type !== 0):
|
|
@@ -9,5 +9,4 @@ export interface AstroComponentFactory {
|
|
|
9
9
|
propagation?: PropagationHint;
|
|
10
10
|
}
|
|
11
11
|
export declare function isAstroComponentFactory(obj: any): obj is AstroComponentFactory;
|
|
12
|
-
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
13
12
|
export declare function isAPropagatingComponent(result: SSRResult, factory: AstroComponentFactory): boolean;
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import { HTMLParts } from "../common.js";
|
|
2
|
-
import { isHeadAndContent } from "./head-and-content.js";
|
|
3
|
-
import { renderAstroTemplateResult } from "./render-template.js";
|
|
4
1
|
function isAstroComponentFactory(obj) {
|
|
5
2
|
return obj == null ? false : obj.isAstroComponentFactory === true;
|
|
6
3
|
}
|
|
7
|
-
async function renderToString(result, componentFactory, props, children) {
|
|
8
|
-
const factoryResult = await componentFactory(result, props, children);
|
|
9
|
-
if (factoryResult instanceof Response) {
|
|
10
|
-
const response = factoryResult;
|
|
11
|
-
throw response;
|
|
12
|
-
}
|
|
13
|
-
let parts = new HTMLParts();
|
|
14
|
-
const templateResult = isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
|
|
15
|
-
for await (const chunk of renderAstroTemplateResult(templateResult)) {
|
|
16
|
-
parts.append(chunk, result);
|
|
17
|
-
}
|
|
18
|
-
return parts.toString();
|
|
19
|
-
}
|
|
20
4
|
function isAPropagatingComponent(result, factory) {
|
|
21
5
|
let hint = factory.propagation || "none";
|
|
22
6
|
if (factory.moduleId && result.componentMetadata.has(factory.moduleId) && hint === "none") {
|
|
@@ -26,6 +10,5 @@ function isAPropagatingComponent(result, factory) {
|
|
|
26
10
|
}
|
|
27
11
|
export {
|
|
28
12
|
isAPropagatingComponent,
|
|
29
|
-
isAstroComponentFactory
|
|
30
|
-
renderToString
|
|
13
|
+
isAstroComponentFactory
|
|
31
14
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { AstroComponentFactory } from './factory';
|
|
2
|
-
export { isAstroComponentFactory
|
|
2
|
+
export { isAstroComponentFactory } from './factory.js';
|
|
3
3
|
export { createHeadAndContent, isHeadAndContent } from './head-and-content.js';
|
|
4
4
|
export type { AstroComponentInstance } from './instance';
|
|
5
5
|
export { createAstroComponentInstance, isAstroComponentInstance } from './instance.js';
|
|
6
6
|
export { isRenderTemplateResult, renderAstroTemplateResult, renderTemplate, } from './render-template.js';
|
|
7
|
+
export { renderToReadableStream, renderToString } from './render.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAstroComponentFactory
|
|
1
|
+
import { isAstroComponentFactory } from "./factory.js";
|
|
2
2
|
import { createHeadAndContent, isHeadAndContent } from "./head-and-content.js";
|
|
3
3
|
import { createAstroComponentInstance, isAstroComponentInstance } from "./instance.js";
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
renderAstroTemplateResult,
|
|
7
7
|
renderTemplate
|
|
8
8
|
} from "./render-template.js";
|
|
9
|
+
import { renderToReadableStream, renderToString } from "./render.js";
|
|
9
10
|
export {
|
|
10
11
|
createAstroComponentInstance,
|
|
11
12
|
createHeadAndContent,
|
|
@@ -15,5 +16,6 @@ export {
|
|
|
15
16
|
isRenderTemplateResult,
|
|
16
17
|
renderAstroTemplateResult,
|
|
17
18
|
renderTemplate,
|
|
19
|
+
renderToReadableStream,
|
|
18
20
|
renderToString
|
|
19
21
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RouteData, SSRResult } from '../../../../@types/astro';
|
|
2
|
+
import type { AstroComponentFactory } from './factory.js';
|
|
3
|
+
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, isPage?: boolean, route?: RouteData): Promise<string | Response>;
|
|
4
|
+
export declare function renderToReadableStream(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, isPage?: boolean, route?: RouteData): Promise<ReadableStream | Response>;
|