astro 1.4.7 → 1.5.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/astro-jsx.d.ts +8 -6
- package/components/Code.astro +1 -1
- package/config.d.ts +1 -1
- package/dist/@types/astro.d.ts +200 -19
- package/dist/cli/index.js +35 -36
- package/dist/config/index.js +2 -7
- package/dist/core/add/index.js +141 -24
- package/dist/core/app/index.js +45 -43
- package/dist/core/build/generate.js +14 -12
- package/dist/core/build/index.js +3 -3
- package/dist/core/config/config.d.ts +1 -1
- package/dist/core/config/config.js +6 -2
- package/dist/core/config/index.d.ts +1 -1
- package/dist/core/config/index.js +2 -1
- package/dist/core/config/schema.d.ts +139 -1
- package/dist/core/config/schema.js +36 -3
- package/dist/core/config/settings.d.ts +1 -7
- package/dist/core/config/settings.js +7 -4
- package/dist/core/config/tsconfig.d.ts +10 -1
- package/dist/core/config/tsconfig.js +72 -7
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +4 -0
- package/dist/core/cookies/cookies.d.ts +1 -1
- package/dist/core/dev/index.js +7 -2
- package/dist/core/endpoint/dev/index.d.ts +2 -1
- package/dist/core/endpoint/dev/index.js +13 -6
- package/dist/core/endpoint/index.d.ts +4 -3
- package/dist/core/endpoint/index.js +57 -9
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.d.ts +2 -11
- package/dist/core/preview/index.js +31 -125
- package/dist/core/preview/static-preview-server.d.ts +17 -0
- package/dist/core/preview/static-preview-server.js +127 -0
- package/dist/core/render/context.d.ts +20 -0
- package/dist/core/render/context.js +15 -0
- package/dist/core/render/core.d.ts +4 -24
- package/dist/core/render/core.js +26 -47
- package/dist/core/render/dev/environment.d.ts +9 -0
- package/dist/core/render/dev/environment.js +30 -0
- package/dist/core/render/dev/index.d.ts +22 -5
- package/dist/core/render/dev/index.js +38 -69
- package/dist/core/render/dev/resolve.d.ts +2 -0
- package/dist/core/render/dev/resolve.js +14 -0
- package/dist/core/render/environment.d.ts +29 -0
- package/dist/core/render/environment.js +21 -0
- package/dist/core/render/index.d.ts +6 -0
- package/dist/core/render/index.js +13 -0
- package/dist/core/render/renderer.d.ts +9 -0
- package/dist/core/render/renderer.js +23 -0
- package/dist/core/render/result.js +3 -3
- package/dist/core/routing/manifest/create.js +14 -5
- package/dist/core/routing/manifest/generator.js +8 -3
- package/dist/core/util.d.ts +3 -14
- package/dist/core/util.js +4 -2
- package/dist/events/index.js +1 -1
- package/dist/integrations/index.d.ts +3 -2
- package/dist/integrations/index.js +39 -2
- package/dist/jsx/component.d.ts +1 -0
- package/dist/jsx/component.js +10 -0
- package/dist/jsx/index.d.ts +2 -0
- package/dist/jsx/index.js +6 -0
- package/dist/jsx-runtime/index.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/index.d.ts +1 -0
- package/dist/runtime/server/index.js +2 -0
- package/dist/vite-plugin-astro-server/index.js +35 -60
- package/dist/vite-plugin-jsx/index.js +9 -5
- package/dist/vite-plugin-jsx/tag.d.ts +3 -2
- package/dist/vite-plugin-jsx/tag.js +10 -4
- package/env.d.ts +1 -1
- package/package.json +8 -3
|
@@ -1,50 +1,35 @@
|
|
|
1
1
|
import { fileURLToPath } from "url";
|
|
2
2
|
import { PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
|
|
3
3
|
import { isPage, resolveIdToUrl } from "../../util.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createRenderContext, renderPage as coreRenderPage } from "../index.js";
|
|
5
|
+
import { filterFoundRenderers, loadRenderer } from "../renderer.js";
|
|
5
6
|
import { collectMdMetadata } from "../util.js";
|
|
6
7
|
import { getStylesForURL } from "./css.js";
|
|
7
8
|
import { getScriptsForURL } from "./scripts.js";
|
|
8
|
-
|
|
9
|
-
async function loadRenderer(viteServer, renderer) {
|
|
10
|
-
const mod = await viteServer.ssrLoadModule(renderer.serverEntrypoint);
|
|
11
|
-
return { ...renderer, ssr: mod.default };
|
|
12
|
-
}
|
|
9
|
+
import { createDevelopmentEnvironment } from "./environment.js";
|
|
13
10
|
async function loadRenderers(viteServer, settings) {
|
|
14
|
-
|
|
11
|
+
const loader = (entry) => viteServer.ssrLoadModule(entry);
|
|
12
|
+
const renderers = await Promise.all(settings.renderers.map((r) => loadRenderer(r, loader)));
|
|
13
|
+
return filterFoundRenderers(renderers);
|
|
15
14
|
}
|
|
16
15
|
async function preload({
|
|
17
|
-
|
|
18
|
-
filePath
|
|
19
|
-
viteServer
|
|
16
|
+
env,
|
|
17
|
+
filePath
|
|
20
18
|
}) {
|
|
21
|
-
const renderers = await loadRenderers(viteServer, settings);
|
|
22
|
-
const mod = await viteServer.ssrLoadModule(fileURLToPath(filePath));
|
|
23
|
-
if (viteServer.config.mode === "development" || !(mod == null ? void 0 : mod.$$metadata)) {
|
|
19
|
+
const renderers = await loadRenderers(env.viteServer, env.settings);
|
|
20
|
+
const mod = await env.viteServer.ssrLoadModule(fileURLToPath(filePath));
|
|
21
|
+
if (env.viteServer.config.mode === "development" || !(mod == null ? void 0 : mod.$$metadata)) {
|
|
24
22
|
return [renderers, mod];
|
|
25
23
|
}
|
|
26
|
-
const modGraph = await viteServer.moduleGraph.getModuleByUrl(fileURLToPath(filePath));
|
|
24
|
+
const modGraph = await env.viteServer.moduleGraph.getModuleByUrl(fileURLToPath(filePath));
|
|
27
25
|
if (modGraph) {
|
|
28
|
-
await collectMdMetadata(mod.$$metadata, modGraph, viteServer);
|
|
26
|
+
await collectMdMetadata(mod.$$metadata, modGraph, env.viteServer);
|
|
29
27
|
}
|
|
30
28
|
return [renderers, mod];
|
|
31
29
|
}
|
|
32
|
-
async function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
settings,
|
|
36
|
-
filePath,
|
|
37
|
-
logging,
|
|
38
|
-
mode,
|
|
39
|
-
origin,
|
|
40
|
-
pathname,
|
|
41
|
-
request,
|
|
42
|
-
route,
|
|
43
|
-
routeCache,
|
|
44
|
-
viteServer
|
|
45
|
-
} = ssrOpts;
|
|
46
|
-
const scripts = await getScriptsForURL(filePath, viteServer);
|
|
47
|
-
if (isPage(filePath, settings) && mode === "development") {
|
|
30
|
+
async function getScriptsAndStyles({ env, filePath }) {
|
|
31
|
+
const scripts = await getScriptsForURL(filePath, env.viteServer);
|
|
32
|
+
if (isPage(filePath, env.settings) && env.mode === "development") {
|
|
48
33
|
scripts.add({
|
|
49
34
|
props: { type: "module", src: "/@vite/client" },
|
|
50
35
|
children: ""
|
|
@@ -52,25 +37,25 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
52
37
|
scripts.add({
|
|
53
38
|
props: {
|
|
54
39
|
type: "module",
|
|
55
|
-
src: await resolveIdToUrl(viteServer, "astro/runtime/client/hmr.js")
|
|
40
|
+
src: await resolveIdToUrl(env.viteServer, "astro/runtime/client/hmr.js")
|
|
56
41
|
},
|
|
57
42
|
children: ""
|
|
58
43
|
});
|
|
59
44
|
}
|
|
60
|
-
for (const script of settings.scripts) {
|
|
45
|
+
for (const script of env.settings.scripts) {
|
|
61
46
|
if (script.stage === "head-inline") {
|
|
62
47
|
scripts.add({
|
|
63
48
|
props: {},
|
|
64
49
|
children: script.content
|
|
65
50
|
});
|
|
66
|
-
} else if (script.stage === "page" && isPage(filePath, settings)) {
|
|
51
|
+
} else if (script.stage === "page" && isPage(filePath, env.settings)) {
|
|
67
52
|
scripts.add({
|
|
68
53
|
props: { type: "module", src: `/@id/${PAGE_SCRIPT_ID}` },
|
|
69
54
|
children: ""
|
|
70
55
|
});
|
|
71
56
|
}
|
|
72
57
|
}
|
|
73
|
-
const { urls: styleUrls, stylesMap } = await getStylesForURL(filePath, viteServer, mode);
|
|
58
|
+
const { urls: styleUrls, stylesMap } = await getStylesForURL(filePath, env.viteServer, env.mode);
|
|
74
59
|
let links = /* @__PURE__ */ new Set();
|
|
75
60
|
[...styleUrls].forEach((href) => {
|
|
76
61
|
links.add({
|
|
@@ -95,45 +80,29 @@ async function render(renderers, mod, ssrOpts) {
|
|
|
95
80
|
children: content
|
|
96
81
|
});
|
|
97
82
|
});
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
return { scripts, styles, links };
|
|
84
|
+
}
|
|
85
|
+
async function renderPage(options) {
|
|
86
|
+
const [renderers, mod] = options.preload;
|
|
87
|
+
options.env.renderers = renderers;
|
|
88
|
+
const { scripts, links, styles } = await getScriptsAndStyles({
|
|
89
|
+
env: options.env,
|
|
90
|
+
filePath: options.filePath
|
|
91
|
+
});
|
|
92
|
+
const ctx = createRenderContext({
|
|
93
|
+
request: options.request,
|
|
94
|
+
origin: options.origin,
|
|
95
|
+
pathname: options.pathname,
|
|
96
|
+
scripts,
|
|
100
97
|
links,
|
|
101
98
|
styles,
|
|
102
|
-
|
|
103
|
-
markdown: {
|
|
104
|
-
...settings.config.markdown,
|
|
105
|
-
isAstroFlavoredMd: settings.config.legacy.astroFlavoredMarkdown
|
|
106
|
-
},
|
|
107
|
-
mod,
|
|
108
|
-
mode,
|
|
109
|
-
origin,
|
|
110
|
-
pathname,
|
|
111
|
-
scripts,
|
|
112
|
-
async resolve(s) {
|
|
113
|
-
const url = await resolveIdToUrl(viteServer, s);
|
|
114
|
-
if (url.startsWith("/@fs") && url.endsWith(".jsx")) {
|
|
115
|
-
return url.slice(0, -4);
|
|
116
|
-
} else {
|
|
117
|
-
return url;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
renderers,
|
|
121
|
-
request,
|
|
122
|
-
route,
|
|
123
|
-
routeCache,
|
|
124
|
-
site: settings.config.site ? new URL(settings.config.base, settings.config.site).toString() : void 0,
|
|
125
|
-
ssr: settings.config.output === "server",
|
|
126
|
-
streaming: true
|
|
99
|
+
route: options.route
|
|
127
100
|
});
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
async function ssr(preloadedComponent, ssrOpts) {
|
|
131
|
-
const [renderers, mod] = preloadedComponent;
|
|
132
|
-
return await render(renderers, mod, ssrOpts);
|
|
101
|
+
return await coreRenderPage(mod, ctx, options.env);
|
|
133
102
|
}
|
|
134
103
|
export {
|
|
104
|
+
createDevelopmentEnvironment,
|
|
135
105
|
loadRenderers,
|
|
136
106
|
preload,
|
|
137
|
-
|
|
138
|
-
ssr
|
|
107
|
+
renderPage
|
|
139
108
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveIdToUrl } from "../../util.js";
|
|
2
|
+
function createResolve(viteServer) {
|
|
3
|
+
return async function(s) {
|
|
4
|
+
const url = await resolveIdToUrl(viteServer, s);
|
|
5
|
+
if (url.startsWith("/@fs") && url.endsWith(".jsx")) {
|
|
6
|
+
return url.slice(0, -4);
|
|
7
|
+
} else {
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
createResolve
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
|
2
|
+
import type { RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
|
|
3
|
+
import type { LogOptions } from '../logger/core.js';
|
|
4
|
+
import { RouteCache } from './route-cache.js';
|
|
5
|
+
/**
|
|
6
|
+
* An environment represents the static parts of rendering that do not change
|
|
7
|
+
* 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
|
+
*/
|
|
10
|
+
export interface Environment {
|
|
11
|
+
adapterName?: string;
|
|
12
|
+
/** logging options */
|
|
13
|
+
logging: LogOptions;
|
|
14
|
+
markdown: MarkdownRenderingOptions;
|
|
15
|
+
/** "development" or "production" */
|
|
16
|
+
mode: RuntimeMode;
|
|
17
|
+
renderers: SSRLoadedRenderer[];
|
|
18
|
+
resolve: (s: string) => Promise<string>;
|
|
19
|
+
routeCache: RouteCache;
|
|
20
|
+
site?: string;
|
|
21
|
+
ssr: boolean;
|
|
22
|
+
streaming: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare type CreateEnvironmentArgs = Environment;
|
|
25
|
+
export declare function createEnvironment(options: CreateEnvironmentArgs): Environment;
|
|
26
|
+
export declare type CreateBasicEnvironmentArgs = Partial<Environment> & {
|
|
27
|
+
logging: CreateEnvironmentArgs['logging'];
|
|
28
|
+
};
|
|
29
|
+
export declare function createBasicEnvironment(options: CreateBasicEnvironmentArgs): Environment;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RouteCache } from "./route-cache.js";
|
|
2
|
+
function createEnvironment(options) {
|
|
3
|
+
return options;
|
|
4
|
+
}
|
|
5
|
+
function createBasicEnvironment(options) {
|
|
6
|
+
const mode = options.mode ?? "development";
|
|
7
|
+
return createEnvironment({
|
|
8
|
+
...options,
|
|
9
|
+
markdown: options.markdown ?? {},
|
|
10
|
+
mode,
|
|
11
|
+
renderers: options.renderers ?? [],
|
|
12
|
+
resolve: options.resolve ?? ((s) => Promise.resolve(s)),
|
|
13
|
+
routeCache: new RouteCache(options.logging, mode),
|
|
14
|
+
ssr: options.ssr ?? true,
|
|
15
|
+
streaming: options.streaming ?? true
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
createBasicEnvironment,
|
|
20
|
+
createEnvironment
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { RenderContext } from './context';
|
|
2
|
+
export { createRenderContext } from './context.js';
|
|
3
|
+
export { getParamsAndProps, GetParamsAndPropsError, renderPage } from './core.js';
|
|
4
|
+
export type { Environment } from './environment';
|
|
5
|
+
export { createBasicEnvironment, createEnvironment } from './environment.js';
|
|
6
|
+
export { loadRenderer } from './renderer.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRenderContext } from "./context.js";
|
|
2
|
+
import { getParamsAndProps, GetParamsAndPropsError, renderPage } from "./core.js";
|
|
3
|
+
import { createBasicEnvironment, createEnvironment } from "./environment.js";
|
|
4
|
+
import { loadRenderer } from "./renderer.js";
|
|
5
|
+
export {
|
|
6
|
+
GetParamsAndPropsError,
|
|
7
|
+
createBasicEnvironment,
|
|
8
|
+
createEnvironment,
|
|
9
|
+
createRenderContext,
|
|
10
|
+
getParamsAndProps,
|
|
11
|
+
loadRenderer,
|
|
12
|
+
renderPage
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AstroRenderer, SSRLoadedRenderer } from '../../@types/astro';
|
|
2
|
+
export declare type RendererServerEntrypointModule = {
|
|
3
|
+
default: SSRLoadedRenderer['ssr'];
|
|
4
|
+
};
|
|
5
|
+
export declare type MaybeRendererServerEntrypointModule = Partial<RendererServerEntrypointModule>;
|
|
6
|
+
export declare type RendererLoader = (entryPoint: string) => Promise<MaybeRendererServerEntrypointModule>;
|
|
7
|
+
export declare function loadRenderer(renderer: AstroRenderer, loader: RendererLoader): Promise<SSRLoadedRenderer | undefined>;
|
|
8
|
+
export declare function filterFoundRenderers(renderers: Array<SSRLoadedRenderer | undefined>): SSRLoadedRenderer[];
|
|
9
|
+
export declare function createLoadedRenderer(renderer: AstroRenderer, mod: RendererServerEntrypointModule): SSRLoadedRenderer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
async function loadRenderer(renderer, loader) {
|
|
2
|
+
const mod = await loader(renderer.serverEntrypoint);
|
|
3
|
+
if (typeof mod.default !== "undefined") {
|
|
4
|
+
return createLoadedRenderer(renderer, mod);
|
|
5
|
+
}
|
|
6
|
+
return void 0;
|
|
7
|
+
}
|
|
8
|
+
function filterFoundRenderers(renderers) {
|
|
9
|
+
return renderers.filter((renderer) => {
|
|
10
|
+
return !!renderer;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function createLoadedRenderer(renderer, mod) {
|
|
14
|
+
return {
|
|
15
|
+
...renderer,
|
|
16
|
+
ssr: mod.default
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
createLoadedRenderer,
|
|
21
|
+
filterFoundRenderers,
|
|
22
|
+
loadRenderer
|
|
23
|
+
};
|
|
@@ -116,7 +116,7 @@ _slots = new WeakMap();
|
|
|
116
116
|
_loggingOpts = new WeakMap();
|
|
117
117
|
let renderMarkdown = null;
|
|
118
118
|
function createResult(args) {
|
|
119
|
-
const { markdown, params, pathname,
|
|
119
|
+
const { markdown, params, pathname, renderers, request, resolve } = args;
|
|
120
120
|
const url = new URL(request.url);
|
|
121
121
|
const headers = new Headers();
|
|
122
122
|
headers.set("Content-Type", "text/html");
|
|
@@ -166,9 +166,9 @@ function createResult(args) {
|
|
|
166
166
|
props,
|
|
167
167
|
request,
|
|
168
168
|
url,
|
|
169
|
-
redirect: args.ssr ? (path) => {
|
|
169
|
+
redirect: args.ssr ? (path, status) => {
|
|
170
170
|
return new Response(null, {
|
|
171
|
-
status: 302,
|
|
171
|
+
status: status || 302,
|
|
172
172
|
headers: {
|
|
173
173
|
Location: path
|
|
174
174
|
}
|
|
@@ -36,10 +36,19 @@ function getParts(part, file) {
|
|
|
36
36
|
}
|
|
37
37
|
function getPattern(segments, addTrailingSlash) {
|
|
38
38
|
const pathname = segments.map((segment) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
if (segment.length === 1 && segment[0].spread) {
|
|
40
|
+
return "(?:\\/(.*?))?";
|
|
41
|
+
} else {
|
|
42
|
+
return "\\/" + segment.map((part) => {
|
|
43
|
+
if (part.spread) {
|
|
44
|
+
return "(.*?)";
|
|
45
|
+
} else if (part.dynamic) {
|
|
46
|
+
return "([^/]+?)";
|
|
47
|
+
} else {
|
|
48
|
+
return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49
|
+
}
|
|
50
|
+
}).join("");
|
|
51
|
+
}
|
|
43
52
|
}).join("");
|
|
44
53
|
const trailing = addTrailingSlash && segments.length ? getTrailingSlashPattern(addTrailingSlash) : "$";
|
|
45
54
|
return new RegExp(`^${pathname || "\\/"}${trailing}`);
|
|
@@ -71,7 +80,7 @@ function validateSegment(segment, file = "") {
|
|
|
71
80
|
if (countOccurrences("[", segment) !== countOccurrences("]", segment)) {
|
|
72
81
|
throw new Error(`Invalid route ${file} \u2014 brackets are unbalanced`);
|
|
73
82
|
}
|
|
74
|
-
if (/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) {
|
|
83
|
+
if ((/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) && file.endsWith(".astro")) {
|
|
75
84
|
throw new Error(`Invalid route ${file} \u2014 rest parameter must be a standalone segment`);
|
|
76
85
|
}
|
|
77
86
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { compile } from "path-to-regexp";
|
|
2
2
|
function getRouteGenerator(segments, addTrailingSlash) {
|
|
3
3
|
const template = segments.map((segment) => {
|
|
4
|
-
return
|
|
5
|
-
if (part)
|
|
6
|
-
return
|
|
4
|
+
return "/" + segment.map((part) => {
|
|
5
|
+
if (part.spread) {
|
|
6
|
+
return `:${part.content.slice(3)}(.*)?`;
|
|
7
|
+
} else if (part.dynamic) {
|
|
8
|
+
return `:${part.content}`;
|
|
9
|
+
} else {
|
|
10
|
+
return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11
|
+
}
|
|
7
12
|
}).join("");
|
|
8
13
|
}).join("");
|
|
9
14
|
let trailing = "";
|
package/dist/core/util.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ErrorPayload, ViteDevServer } from 'vite';
|
|
3
2
|
import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro';
|
|
4
|
-
export declare const ASTRO_VERSION: string;
|
|
5
3
|
/** Returns true if argument is an object of any prototype/class (but not null). */
|
|
6
4
|
export declare function isObject(value: unknown): value is Record<string, any>;
|
|
5
|
+
/** Cross-realm compatible URL */
|
|
6
|
+
export declare function isURL(value: unknown): value is URL;
|
|
7
7
|
/** Wraps an object in an array. If an array is passed, ignore it. */
|
|
8
8
|
export declare function arraify<T>(target: T | T[]): T[];
|
|
9
9
|
export declare function padMultilineString(source: string, n?: number): string;
|
|
@@ -45,15 +45,4 @@ export declare function getLocalAddress(serverAddress: string, host: string | bo
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function resolveIdToUrl(viteServer: ViteDevServer, id: string): Promise<string>;
|
|
47
47
|
export declare function resolveJsToTs(filePath: string): string;
|
|
48
|
-
export declare const AggregateError:
|
|
49
|
-
new (errors: Iterable<any>, message?: string | undefined): {
|
|
50
|
-
errors: Array<any>;
|
|
51
|
-
name: string;
|
|
52
|
-
message: string;
|
|
53
|
-
stack?: string | undefined;
|
|
54
|
-
cause?: unknown;
|
|
55
|
-
};
|
|
56
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
57
|
-
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
58
|
-
stackTraceLimit: number;
|
|
59
|
-
};
|
|
48
|
+
export declare const AggregateError: any;
|
package/dist/core/util.js
CHANGED
|
@@ -5,10 +5,12 @@ import resolve from "resolve";
|
|
|
5
5
|
import slash from "slash";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
7
|
import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
|
|
8
|
-
const ASTRO_VERSION = "1.4.7";
|
|
9
8
|
function isObject(value) {
|
|
10
9
|
return typeof value === "object" && value != null;
|
|
11
10
|
}
|
|
11
|
+
function isURL(value) {
|
|
12
|
+
return Object.prototype.toString.call(value) === "[object URL]";
|
|
13
|
+
}
|
|
12
14
|
function arraify(target) {
|
|
13
15
|
return Array.isArray(target) ? target : [target];
|
|
14
16
|
}
|
|
@@ -175,7 +177,6 @@ const AggregateError = typeof globalThis.AggregateError !== "undefined" ? global
|
|
|
175
177
|
}
|
|
176
178
|
};
|
|
177
179
|
export {
|
|
178
|
-
ASTRO_VERSION,
|
|
179
180
|
AggregateError,
|
|
180
181
|
VALID_ID_PREFIX,
|
|
181
182
|
arraify,
|
|
@@ -187,6 +188,7 @@ export {
|
|
|
187
188
|
isModeServerWithNoAdapter,
|
|
188
189
|
isObject,
|
|
189
190
|
isPage,
|
|
191
|
+
isURL,
|
|
190
192
|
padMultilineString,
|
|
191
193
|
parseNpmName,
|
|
192
194
|
relativeToSrcDir,
|
package/dist/events/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstroTelemetry } from "@astrojs/telemetry";
|
|
2
2
|
import { createRequire } from "module";
|
|
3
|
-
import { ASTRO_VERSION } from "../core/
|
|
3
|
+
import { ASTRO_VERSION } from "../core/constants.js";
|
|
4
4
|
const require2 = createRequire(import.meta.url);
|
|
5
5
|
function getViteVersion() {
|
|
6
6
|
try {
|
|
@@ -5,10 +5,11 @@ import { AstroConfig, AstroSettings, BuildConfig, RouteData } from '../@types/as
|
|
|
5
5
|
import type { SerializedSSRManifest } from '../core/app/types';
|
|
6
6
|
import type { PageBuildData } from '../core/build/types';
|
|
7
7
|
import { LogOptions } from '../core/logger/core.js';
|
|
8
|
-
export declare function runHookConfigSetup({ settings, command, logging, }: {
|
|
8
|
+
export declare function runHookConfigSetup({ settings, command, logging, isRestart, }: {
|
|
9
9
|
settings: AstroSettings;
|
|
10
|
-
command: 'dev' | 'build';
|
|
10
|
+
command: 'dev' | 'build' | 'preview';
|
|
11
11
|
logging: LogOptions;
|
|
12
|
+
isRestart?: boolean;
|
|
12
13
|
}): Promise<AstroSettings>;
|
|
13
14
|
export declare function runHookConfigDone({ settings, logging, }: {
|
|
14
15
|
settings: AstroSettings;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { bold } from "kleur/colors";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { mergeConfig } from "../core/config/config.js";
|
|
3
|
-
import { info } from "../core/logger/core.js";
|
|
4
|
+
import { info, warn } from "../core/logger/core.js";
|
|
4
5
|
async function withTakingALongTimeMsg({
|
|
5
6
|
name,
|
|
6
7
|
hookResult,
|
|
@@ -17,7 +18,8 @@ async function withTakingALongTimeMsg({
|
|
|
17
18
|
async function runHookConfigSetup({
|
|
18
19
|
settings,
|
|
19
20
|
command,
|
|
20
|
-
logging
|
|
21
|
+
logging,
|
|
22
|
+
isRestart = false
|
|
21
23
|
}) {
|
|
22
24
|
var _a;
|
|
23
25
|
if (settings.config.adapter) {
|
|
@@ -35,6 +37,7 @@ async function runHookConfigSetup({
|
|
|
35
37
|
const hooks = {
|
|
36
38
|
config: updatedConfig,
|
|
37
39
|
command,
|
|
40
|
+
isRestart,
|
|
38
41
|
addRenderer(renderer) {
|
|
39
42
|
if (!renderer.name) {
|
|
40
43
|
throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
|
|
@@ -52,6 +55,9 @@ async function runHookConfigSetup({
|
|
|
52
55
|
},
|
|
53
56
|
injectRoute: (injectRoute) => {
|
|
54
57
|
updatedSettings.injectedRoutes.push(injectRoute);
|
|
58
|
+
},
|
|
59
|
+
addWatchFile: (path) => {
|
|
60
|
+
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
Object.defineProperty(hooks, "addPageExtension", {
|
|
@@ -147,13 +153,44 @@ async function runHookBuildStart({
|
|
|
147
153
|
logging
|
|
148
154
|
}) {
|
|
149
155
|
var _a;
|
|
156
|
+
function warnDeprecated(integration, prop) {
|
|
157
|
+
let value = Reflect.get(buildConfig, prop);
|
|
158
|
+
Object.defineProperty(buildConfig, prop, {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get() {
|
|
161
|
+
return value;
|
|
162
|
+
},
|
|
163
|
+
set(newValue) {
|
|
164
|
+
value = newValue;
|
|
165
|
+
warn(
|
|
166
|
+
logging,
|
|
167
|
+
"astro:build:start",
|
|
168
|
+
`Your adapter ${bold(integration.name)} is using a deprecated API, buildConfig. ${bold(
|
|
169
|
+
prop
|
|
170
|
+
)} config should be set via config.build.${prop} instead.`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return () => {
|
|
175
|
+
Object.defineProperty(buildConfig, prop, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
value
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
}
|
|
150
181
|
for (const integration of config.integrations) {
|
|
151
182
|
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:start"]) {
|
|
183
|
+
const undoClientWarning = warnDeprecated(integration, "client");
|
|
184
|
+
const undoServerWarning = warnDeprecated(integration, "server");
|
|
185
|
+
const undoServerEntryWarning = warnDeprecated(integration, "serverEntry");
|
|
152
186
|
await withTakingALongTimeMsg({
|
|
153
187
|
name: integration.name,
|
|
154
188
|
hookResult: integration.hooks["astro:build:start"]({ buildConfig }),
|
|
155
189
|
logging
|
|
156
190
|
});
|
|
191
|
+
undoClientWarning();
|
|
192
|
+
undoServerEntryWarning();
|
|
193
|
+
undoServerWarning();
|
|
157
194
|
}
|
|
158
195
|
}
|
|
159
196
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createAstroJSXComponent(factory: (...args: any[]) => any): (...args: any[]) => any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __astro_tag_component__ } from "../runtime/server/index.js";
|
|
2
|
+
import renderer from "./renderer.js";
|
|
3
|
+
const ASTRO_JSX_RENDERER_NAME = renderer.name;
|
|
4
|
+
function createAstroJSXComponent(factory) {
|
|
5
|
+
__astro_tag_component__(factory, ASTRO_JSX_RENDERER_NAME);
|
|
6
|
+
return factory;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
createAstroJSXComponent
|
|
10
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, markHTMLString, Renderer } from "../runtime/server/index.js";
|
|
2
2
|
const AstroJSX = "astro:jsx";
|
|
3
3
|
const Empty = Symbol("empty");
|
|
4
|
-
const toSlotName = (
|
|
4
|
+
const toSlotName = (slotAttr) => slotAttr;
|
|
5
5
|
function isVNode(vnode) {
|
|
6
6
|
return vnode && typeof vnode === "object" && vnode[AstroJSX];
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createAstro } from './astro-global.js';
|
|
2
2
|
export { renderEndpoint } from './endpoint.js';
|
|
3
3
|
export { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from './escape.js';
|
|
4
|
+
export { renderJSX } from './jsx.js';
|
|
4
5
|
export type { Metadata } from './metadata';
|
|
5
6
|
export { createMetadata } from './metadata.js';
|
|
6
7
|
export { addAttribute, defineScriptVars, Fragment, maybeRenderHead, renderAstroComponent, renderComponent, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderSlot, renderTemplate as render, renderTemplate, renderToString, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createAstro } from "./astro-global.js";
|
|
2
2
|
import { renderEndpoint } from "./endpoint.js";
|
|
3
3
|
import { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from "./escape.js";
|
|
4
|
+
import { renderJSX } from "./jsx.js";
|
|
4
5
|
import { createMetadata } from "./metadata.js";
|
|
5
6
|
import {
|
|
6
7
|
addAttribute,
|
|
@@ -101,6 +102,7 @@ export {
|
|
|
101
102
|
renderEndpoint,
|
|
102
103
|
renderHTMLElement,
|
|
103
104
|
renderHead,
|
|
105
|
+
renderJSX,
|
|
104
106
|
renderPage,
|
|
105
107
|
renderSlot,
|
|
106
108
|
renderTemplate2 as renderTemplate,
|