astro 2.7.4 → 2.8.0
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/@types/astro.d.ts +47 -13
- package/dist/cli/index.js +54 -5
- package/dist/core/app/index.js +4 -8
- package/dist/core/app/types.d.ts +2 -2
- package/dist/core/build/generate.d.ts +9 -1
- package/dist/core/build/generate.js +45 -46
- package/dist/core/build/index.d.ts +1 -1
- package/dist/core/build/index.js +19 -1
- package/dist/core/build/internal.d.ts +1 -0
- package/dist/core/build/plugins/index.js +1 -1
- package/dist/core/build/plugins/plugin-middleware.d.ts +3 -2
- package/dist/core/build/plugins/plugin-middleware.js +22 -3
- package/dist/core/build/plugins/plugin-pages.js +6 -4
- package/dist/core/build/plugins/plugin-ssr.js +4 -2
- package/dist/core/build/static-build.js +0 -3
- package/dist/core/config/schema.d.ts +12 -0
- package/dist/core/config/schema.js +6 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.d.ts +1 -2
- package/dist/core/endpoint/dev/index.js +2 -3
- package/dist/core/endpoint/index.d.ts +9 -4
- package/dist/core/endpoint/index.js +3 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.d.ts +31 -2
- package/dist/core/middleware/index.js +47 -1
- package/dist/core/render/context.d.ts +2 -6
- package/dist/core/render/context.js +2 -6
- package/dist/core/render/core.d.ts +1 -2
- package/dist/core/render/core.js +2 -11
- package/dist/core/render/dev/environment.js +1 -0
- package/dist/core/render/dev/index.d.ts +0 -2
- package/dist/core/render/dev/index.js +0 -1
- package/dist/core/render/environment.d.ts +1 -0
- package/dist/core/render/result.d.ts +2 -4
- package/dist/core/render/result.js +10 -11
- package/dist/integrations/index.d.ts +8 -4
- package/dist/integrations/index.js +8 -8
- package/dist/runtime/server/hydration.d.ts +1 -1
- package/dist/runtime/server/jsx.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +2 -2
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/runtime/server/render/head.d.ts +3 -9
- package/dist/runtime/server/render/head.js +6 -9
- package/dist/runtime/server/render/page.d.ts +1 -1
- package/dist/runtime/server/render/page.js +9 -9
- package/dist/runtime/server/render/types.d.ts +0 -5
- package/dist/runtime/server/scripts.js +1 -1
- package/dist/vite-plugin-astro-server/route.js +1 -2
- package/package.json +2 -1
|
@@ -57,7 +57,7 @@ async function renderFrameworkComponent(result, displayName, Component, _props,
|
|
|
57
57
|
Did you forget to import the component or is it possible there is a typo?`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const { renderers, clientDirectives } = result
|
|
60
|
+
const { renderers, clientDirectives } = result;
|
|
61
61
|
const metadata = {
|
|
62
62
|
astroStaticSlot: true,
|
|
63
63
|
displayName
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
+
import type { MaybeRenderHeadInstruction, RenderHeadInstruction } from './types';
|
|
2
3
|
export declare function renderAllHeadContent(result: SSRResult): any;
|
|
3
|
-
export declare function renderHead(
|
|
4
|
-
|
|
5
|
-
readonly result: SSRResult;
|
|
6
|
-
}, void, unknown>;
|
|
7
|
-
export declare function maybeRenderHead(result: SSRResult): Generator<{
|
|
8
|
-
readonly type: "maybe-head";
|
|
9
|
-
readonly result: SSRResult;
|
|
10
|
-
readonly scope: number;
|
|
11
|
-
}, void, unknown>;
|
|
4
|
+
export declare function renderHead(): Generator<RenderHeadInstruction>;
|
|
5
|
+
export declare function maybeRenderHead(): Generator<MaybeRenderHeadInstruction>;
|
|
@@ -16,21 +16,18 @@ function renderAllHeadContent(result) {
|
|
|
16
16
|
});
|
|
17
17
|
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
|
|
18
18
|
let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
|
|
19
|
-
if (result.extraHead.length > 0) {
|
|
20
|
-
for (const part of result.extraHead) {
|
|
19
|
+
if (result._metadata.extraHead.length > 0) {
|
|
20
|
+
for (const part of result._metadata.extraHead) {
|
|
21
21
|
content += part;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
return markHTMLString(content);
|
|
25
25
|
}
|
|
26
|
-
function* renderHead(
|
|
27
|
-
yield { type: "head"
|
|
26
|
+
function* renderHead() {
|
|
27
|
+
yield { type: "head" };
|
|
28
28
|
}
|
|
29
|
-
function* maybeRenderHead(
|
|
30
|
-
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
yield { type: "maybe-head", result, scope: result.scope };
|
|
29
|
+
function* maybeRenderHead() {
|
|
30
|
+
yield { type: "maybe-head" };
|
|
34
31
|
}
|
|
35
32
|
export {
|
|
36
33
|
maybeRenderHead,
|
|
@@ -5,5 +5,5 @@ type NonAstroPageComponent = {
|
|
|
5
5
|
name: string;
|
|
6
6
|
[needsHeadRenderingSymbol]: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory | NonAstroPageComponent, props: any, children: any, streaming: boolean,
|
|
8
|
+
export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory | NonAstroPageComponent, props: any, children: any, streaming: boolean, route?: RouteData | undefined): Promise<Response>;
|
|
9
9
|
export {};
|
|
@@ -15,7 +15,7 @@ const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
|
15
15
|
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
16
16
|
return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
|
|
17
17
|
}
|
|
18
|
-
async function iterableToHTMLBytes(result, iterable,
|
|
18
|
+
async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
|
|
19
19
|
const parts = new HTMLParts();
|
|
20
20
|
let i = 0;
|
|
21
21
|
for await (const chunk of iterable) {
|
|
@@ -23,7 +23,7 @@ async function iterableToHTMLBytes(result, iterable, isCompressHTML, onDocTypeIn
|
|
|
23
23
|
if (i === 0) {
|
|
24
24
|
i++;
|
|
25
25
|
if (!/<!doctype html/i.test(String(chunk))) {
|
|
26
|
-
parts.append(`${
|
|
26
|
+
parts.append(`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`, result);
|
|
27
27
|
if (onDocTypeInjection) {
|
|
28
28
|
await onDocTypeInjection(parts);
|
|
29
29
|
}
|
|
@@ -35,7 +35,7 @@ async function iterableToHTMLBytes(result, iterable, isCompressHTML, onDocTypeIn
|
|
|
35
35
|
return parts.toArrayBuffer();
|
|
36
36
|
}
|
|
37
37
|
async function bufferHeadContent(result) {
|
|
38
|
-
const iterator = result.propagators.values();
|
|
38
|
+
const iterator = result._metadata.propagators.values();
|
|
39
39
|
while (true) {
|
|
40
40
|
const { value, done } = iterator.next();
|
|
41
41
|
if (done) {
|
|
@@ -43,11 +43,11 @@ async function bufferHeadContent(result) {
|
|
|
43
43
|
}
|
|
44
44
|
const returnValue = await value.init(result);
|
|
45
45
|
if (isHeadAndContent(returnValue)) {
|
|
46
|
-
result.extraHead.push(returnValue.head);
|
|
46
|
+
result._metadata.extraHead.push(returnValue.head);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
async function renderPage(result, componentFactory, props, children, streaming,
|
|
50
|
+
async function renderPage(result, componentFactory, props, children, streaming, route) {
|
|
51
51
|
var _a, _b;
|
|
52
52
|
if (!isAstroComponentFactory(componentFactory)) {
|
|
53
53
|
result._metadata.headInTree = ((_a = result.componentMetadata.get(componentFactory.moduleId)) == null ? void 0 : _a.containsHead) ?? false;
|
|
@@ -57,7 +57,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
57
57
|
try {
|
|
58
58
|
if (nonAstroPageNeedsHeadInjection(componentFactory)) {
|
|
59
59
|
const parts = new HTMLParts();
|
|
60
|
-
for await (const chunk of maybeRenderHead(
|
|
60
|
+
for await (const chunk of maybeRenderHead()) {
|
|
61
61
|
parts.append(chunk, result);
|
|
62
62
|
}
|
|
63
63
|
head = parts.toString();
|
|
@@ -82,7 +82,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
82
82
|
}
|
|
83
83
|
throw e;
|
|
84
84
|
}
|
|
85
|
-
const bytes = await iterableToHTMLBytes(result, output,
|
|
85
|
+
const bytes = await iterableToHTMLBytes(result, output, async (parts) => {
|
|
86
86
|
parts.append(head, result);
|
|
87
87
|
});
|
|
88
88
|
return new Response(bytes, {
|
|
@@ -114,7 +114,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
114
114
|
if (!/<!doctype html/i.test(String(chunk))) {
|
|
115
115
|
controller.enqueue(
|
|
116
116
|
encoder.encode(
|
|
117
|
-
`${
|
|
117
|
+
`${result.compressHTML ? "<!DOCTYPE html>" : "<!DOCTYPE html>\n"}`
|
|
118
118
|
)
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -143,7 +143,7 @@ async function renderPage(result, componentFactory, props, children, streaming,
|
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
} else {
|
|
146
|
-
body = await iterableToHTMLBytes(result, iterable
|
|
146
|
+
body = await iterableToHTMLBytes(result, iterable);
|
|
147
147
|
headers.set("Content-Length", body.byteLength.toString());
|
|
148
148
|
}
|
|
149
149
|
let response = createResponse(body, { ...init, headers });
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../@types/astro';
|
|
2
1
|
import type { HydrationMetadata } from '../hydration.js';
|
|
3
2
|
export type RenderDirectiveInstruction = {
|
|
4
3
|
type: 'directive';
|
|
5
|
-
result: SSRResult;
|
|
6
4
|
hydration: HydrationMetadata;
|
|
7
5
|
};
|
|
8
6
|
export type RenderHeadInstruction = {
|
|
9
7
|
type: 'head';
|
|
10
|
-
result: SSRResult;
|
|
11
8
|
};
|
|
12
9
|
export type MaybeRenderHeadInstruction = {
|
|
13
10
|
type: 'maybe-head';
|
|
14
|
-
result: SSRResult;
|
|
15
|
-
scope: number;
|
|
16
11
|
};
|
|
17
12
|
export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction;
|
|
@@ -14,7 +14,7 @@ function determinesIfNeedsDirectiveScript(result, directive) {
|
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
function getDirectiveScriptText(result, directive) {
|
|
17
|
-
const clientDirectives = result.
|
|
17
|
+
const clientDirectives = result.clientDirectives;
|
|
18
18
|
const clientDirective = clientDirectives.get(directive);
|
|
19
19
|
if (!clientDirective) {
|
|
20
20
|
throw new Error(`Unknown directive: ${directive}`);
|
|
@@ -113,7 +113,6 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
113
113
|
const options = {
|
|
114
114
|
env,
|
|
115
115
|
filePath,
|
|
116
|
-
origin,
|
|
117
116
|
preload: preloadedComponent,
|
|
118
117
|
pathname,
|
|
119
118
|
request,
|
|
@@ -124,7 +123,7 @@ async function handleRoute(matchedRoute, url, pathname, body, origin, env, manif
|
|
|
124
123
|
options.middleware = middleware;
|
|
125
124
|
}
|
|
126
125
|
if (route.type === "endpoint") {
|
|
127
|
-
const result = await callEndpoint(options
|
|
126
|
+
const result = await callEndpoint(options);
|
|
128
127
|
if (result.type === "response") {
|
|
129
128
|
if (result.response.headers.get("X-Astro-Response") === "Not-Found") {
|
|
130
129
|
const fourOhFourRoute = await matchRoute("/404", env, manifest);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -153,6 +153,7 @@
|
|
|
153
153
|
"vfile": "^5.3.7",
|
|
154
154
|
"vite": "^4.3.9",
|
|
155
155
|
"vitefu": "^0.2.4",
|
|
156
|
+
"which-pm": "^2.0.0",
|
|
156
157
|
"yargs-parser": "^21.1.1",
|
|
157
158
|
"zod": "^3.20.6"
|
|
158
159
|
},
|