astro 1.0.5 → 1.0.6
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/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/util.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/render/astro.js +4 -0
- package/dist/runtime/server/render/component.js +7 -2
- package/dist/runtime/server/render/page.js +13 -6
- package/dist/types/@types/astro.d.ts +1 -2
- package/dist/types/runtime/server/render/astro.d.ts +1 -0
- package/dist/types/runtime/server/render/page.d.ts +7 -1
- package/dist/vite-plugin-astro-server/index.js +0 -6
- package/dist/vite-plugin-markdown/index.js +1 -0
- package/package.json +1 -1
package/dist/core/dev/index.js
CHANGED
|
@@ -46,7 +46,7 @@ async function dev(config, options) {
|
|
|
46
46
|
https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
|
|
47
47
|
})
|
|
48
48
|
);
|
|
49
|
-
const currentVersion = "1.0.
|
|
49
|
+
const currentVersion = "1.0.6";
|
|
50
50
|
if (currentVersion.includes("-")) {
|
|
51
51
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
52
52
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function devStart({
|
|
|
47
47
|
https,
|
|
48
48
|
site
|
|
49
49
|
}) {
|
|
50
|
-
const version = "1.0.
|
|
50
|
+
const version = "1.0.6";
|
|
51
51
|
const rootPath = site ? site.pathname : "/";
|
|
52
52
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
53
53
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
@@ -226,7 +226,7 @@ function printHelp({
|
|
|
226
226
|
message.push(
|
|
227
227
|
linebreak(),
|
|
228
228
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
229
|
-
`v${"1.0.
|
|
229
|
+
`v${"1.0.6"}`
|
|
230
230
|
)} ${headline}`
|
|
231
231
|
);
|
|
232
232
|
}
|
package/dist/core/util.js
CHANGED
|
@@ -5,7 +5,7 @@ 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.0.
|
|
8
|
+
const ASTRO_VERSION = "1.0.6";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -35,6 +35,9 @@ class AstroComponent {
|
|
|
35
35
|
function isAstroComponent(obj) {
|
|
36
36
|
return typeof obj === "object" && Object.prototype.toString.call(obj) === "[object AstroComponent]";
|
|
37
37
|
}
|
|
38
|
+
function isAstroComponentFactory(obj) {
|
|
39
|
+
return obj == null ? false : !!obj.isAstroComponentFactory;
|
|
40
|
+
}
|
|
38
41
|
async function* renderAstroComponent(component) {
|
|
39
42
|
for await (const value of component) {
|
|
40
43
|
if (value || value === 0) {
|
|
@@ -83,6 +86,7 @@ async function renderTemplate(htmlParts, ...expressions) {
|
|
|
83
86
|
export {
|
|
84
87
|
AstroComponent,
|
|
85
88
|
isAstroComponent,
|
|
89
|
+
isAstroComponentFactory,
|
|
86
90
|
renderAstroComponent,
|
|
87
91
|
renderTemplate,
|
|
88
92
|
renderToIterable,
|
|
@@ -3,7 +3,12 @@ import { extractDirectives, generateHydrateScript } from "../hydration.js";
|
|
|
3
3
|
import { serializeProps } from "../serialize.js";
|
|
4
4
|
import { shorthash } from "../shorthash.js";
|
|
5
5
|
import { renderSlot } from "./any.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
isAstroComponentFactory,
|
|
8
|
+
renderAstroComponent,
|
|
9
|
+
renderTemplate,
|
|
10
|
+
renderToIterable
|
|
11
|
+
} from "./astro.js";
|
|
7
12
|
import { Fragment, Renderer } from "./common.js";
|
|
8
13
|
import { componentIsHTMLElement, renderHTMLElement } from "./dom.js";
|
|
9
14
|
import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from "./util.js";
|
|
@@ -29,7 +34,7 @@ function getComponentType(Component) {
|
|
|
29
34
|
if (Component && typeof Component === "object" && Component["astro:html"]) {
|
|
30
35
|
return "html";
|
|
31
36
|
}
|
|
32
|
-
if (Component
|
|
37
|
+
if (isAstroComponentFactory(Component)) {
|
|
33
38
|
return "astro-factory";
|
|
34
39
|
}
|
|
35
40
|
return "unknown";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { createResponse } from "../response.js";
|
|
2
|
-
import { isAstroComponent, renderAstroComponent } from "./astro.js";
|
|
2
|
+
import { isAstroComponent, isAstroComponentFactory, renderAstroComponent } from "./astro.js";
|
|
3
3
|
import { stringifyChunk } from "./common.js";
|
|
4
4
|
import { renderComponent } from "./component.js";
|
|
5
5
|
import { maybeRenderHead } from "./head.js";
|
|
6
6
|
const encoder = new TextEncoder();
|
|
7
|
+
const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
|
|
8
|
+
function nonAstroPageNeedsHeadInjection(pageComponent) {
|
|
9
|
+
return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
|
|
10
|
+
}
|
|
7
11
|
async function renderPage(result, componentFactory, props, children, streaming) {
|
|
8
|
-
if (!componentFactory
|
|
12
|
+
if (!isAstroComponentFactory(componentFactory)) {
|
|
9
13
|
const pageProps = { ...props ?? {}, "server:root": true };
|
|
10
14
|
const output = await renderComponent(
|
|
11
15
|
result,
|
|
@@ -18,15 +22,18 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
18
22
|
if (!/<!doctype html/i.test(html)) {
|
|
19
23
|
let rest = html;
|
|
20
24
|
html = `<!DOCTYPE html>`;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
if (nonAstroPageNeedsHeadInjection(componentFactory)) {
|
|
26
|
+
for await (let chunk of maybeRenderHead(result)) {
|
|
27
|
+
html += chunk;
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
html += rest;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
const bytes = encoder.encode(html);
|
|
33
|
+
return new Response(bytes, {
|
|
27
34
|
headers: new Headers([
|
|
28
35
|
["Content-Type", "text/html; charset=utf-8"],
|
|
29
|
-
["Content-Length",
|
|
36
|
+
["Content-Length", bytes.byteLength.toString()]
|
|
30
37
|
])
|
|
31
38
|
});
|
|
32
39
|
}
|
|
@@ -799,8 +799,7 @@ export interface MarkdownLayoutProps<T extends Record<string, any>> {
|
|
|
799
799
|
rawContent: MarkdownInstance<T>['rawContent'];
|
|
800
800
|
compiledContent: MarkdownInstance<T>['compiledContent'];
|
|
801
801
|
}
|
|
802
|
-
export
|
|
803
|
-
}
|
|
802
|
+
export declare type MDXLayoutProps<T> = Omit<MarkdownLayoutProps<T>, 'rawContent' | 'compiledContent'>;
|
|
804
803
|
export declare type GetHydrateCallback = () => Promise<() => void | Promise<void>>;
|
|
805
804
|
/**
|
|
806
805
|
* getStaticPaths() options
|
|
@@ -9,6 +9,7 @@ export declare class AstroComponent {
|
|
|
9
9
|
[Symbol.asyncIterator](): AsyncGenerator<any, void, undefined>;
|
|
10
10
|
}
|
|
11
11
|
export declare function isAstroComponent(obj: any): obj is AstroComponent;
|
|
12
|
+
export declare function isAstroComponentFactory(obj: any): obj is AstroComponentFactory;
|
|
12
13
|
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | RenderInstruction>;
|
|
13
14
|
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
14
15
|
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | RenderInstruction>>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { AstroComponentFactory } from './index';
|
|
3
|
-
|
|
3
|
+
declare const needsHeadRenderingSymbol: unique symbol;
|
|
4
|
+
declare type NonAstroPageComponent = {
|
|
5
|
+
name: string;
|
|
6
|
+
[needsHeadRenderingSymbol]: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory | NonAstroPageComponent, props: any, children: any, streaming: boolean): Promise<Response>;
|
|
9
|
+
export {};
|
|
@@ -176,12 +176,6 @@ async function handleRequest(routeCache, viteServer, logging, manifest, config,
|
|
|
176
176
|
});
|
|
177
177
|
async function matchRoute() {
|
|
178
178
|
const matches = matchAllRoutes(pathname, manifest);
|
|
179
|
-
if (config.output === "server" && matches.length > 1) {
|
|
180
|
-
throw new Error(`Found multiple matching routes for "${pathname}"! When using \`output: 'server'\`, only one route in \`src/pages\` can match a given URL. Found:
|
|
181
|
-
|
|
182
|
-
${matches.map(({ component }) => `- ${component}`).join("\n")}
|
|
183
|
-
`);
|
|
184
|
-
}
|
|
185
179
|
for await (const maybeRoute of matches) {
|
|
186
180
|
const filePath2 = new URL(`./${maybeRoute.component}`, config.root);
|
|
187
181
|
const preloadedComponent = await preload({ astroConfig: config, filePath: filePath2, viteServer });
|