astro 1.0.4 → 1.0.5
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/cli/index.js +1 -1
- package/dist/core/dev/index.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/preview/index.js +5 -0
- package/dist/core/render/result.js +1 -2
- package/dist/core/util.js +1 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/render/any.js +2 -1
- package/dist/runtime/server/render/page.js +2 -13
- package/dist/runtime/server/render/types.js +0 -0
- package/dist/types/@types/astro.d.ts +0 -14
- package/dist/types/runtime/server/hydration.d.ts +10 -2
- package/dist/types/runtime/server/index.d.ts +1 -1
- package/dist/types/runtime/server/render/any.d.ts +1 -2
- package/dist/types/runtime/server/render/astro.d.ts +4 -3
- package/dist/types/runtime/server/render/common.d.ts +3 -2
- package/dist/types/runtime/server/render/component.d.ts +3 -2
- package/dist/types/runtime/server/render/index.d.ts +1 -0
- package/dist/types/runtime/server/render/types.d.ts +7 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
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.5";
|
|
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.5";
|
|
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.5"}`
|
|
230
230
|
)} ${headline}`
|
|
231
231
|
);
|
|
232
232
|
}
|
|
@@ -9,6 +9,11 @@ import * as msg from "../messages.js";
|
|
|
9
9
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
10
10
|
const HAS_FILE_EXTENSION_REGEXP = /^.*\.[^\\]+$/;
|
|
11
11
|
async function preview(config, { logging }) {
|
|
12
|
+
if (config.output === "server") {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`[preview] 'output: server' not supported. Use your deploy platform's preview command directly instead, if one exists. (ex: 'netlify dev', 'vercel dev', 'wrangler', etc.)`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
12
17
|
const startServerTime = performance.now();
|
|
13
18
|
const defaultOrigin = "http://localhost";
|
|
14
19
|
const trailingSlash = config.trailingSlash;
|
|
@@ -223,8 +223,7 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
|
|
223
223
|
renderers,
|
|
224
224
|
pathname,
|
|
225
225
|
hasHydrationScript: false,
|
|
226
|
-
hasDirectives: /* @__PURE__ */ new Set()
|
|
227
|
-
pendingInstructions: /* @__PURE__ */ new Set()
|
|
226
|
+
hasDirectives: /* @__PURE__ */ new Set()
|
|
228
227
|
},
|
|
229
228
|
response
|
|
230
229
|
};
|
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.5";
|
|
9
9
|
function isObject(value) {
|
|
10
10
|
return typeof value === "object" && value != null;
|
|
11
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { escapeHTML, HTMLString, markHTMLString } from "../escape.js";
|
|
2
2
|
import { AstroComponent, renderAstroComponent } from "./astro.js";
|
|
3
|
+
import { stringifyChunk } from "./common.js";
|
|
3
4
|
async function* renderChild(child) {
|
|
4
5
|
child = await child;
|
|
5
6
|
if (child instanceof HTMLString) {
|
|
@@ -27,7 +28,7 @@ async function renderSlot(result, slotted, fallback) {
|
|
|
27
28
|
let content = "";
|
|
28
29
|
for await (const chunk of iterator) {
|
|
29
30
|
if (chunk.type === "directive") {
|
|
30
|
-
result
|
|
31
|
+
content += stringifyChunk(result, chunk);
|
|
31
32
|
} else {
|
|
32
33
|
content += chunk;
|
|
33
34
|
}
|
|
@@ -36,24 +36,13 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
36
36
|
let init = result.response;
|
|
37
37
|
let headers = new Headers(init.headers);
|
|
38
38
|
let body;
|
|
39
|
-
async function* eachChunk() {
|
|
40
|
-
for await (const chunk of iterable) {
|
|
41
|
-
if (result._metadata.pendingInstructions.size) {
|
|
42
|
-
for (const instr of result._metadata.pendingInstructions) {
|
|
43
|
-
result._metadata.pendingInstructions.delete(instr);
|
|
44
|
-
yield instr;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
yield chunk;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
39
|
if (streaming) {
|
|
51
40
|
body = new ReadableStream({
|
|
52
41
|
start(controller) {
|
|
53
42
|
async function read() {
|
|
54
43
|
let i = 0;
|
|
55
44
|
try {
|
|
56
|
-
for await (const chunk of
|
|
45
|
+
for await (const chunk of iterable) {
|
|
57
46
|
let html = stringifyChunk(result, chunk);
|
|
58
47
|
if (i === 0) {
|
|
59
48
|
if (!/<!doctype html/i.test(html)) {
|
|
@@ -74,7 +63,7 @@ async function renderPage(result, componentFactory, props, children, streaming)
|
|
|
74
63
|
} else {
|
|
75
64
|
body = "";
|
|
76
65
|
let i = 0;
|
|
77
|
-
for await (const chunk of
|
|
66
|
+
for await (const chunk of iterable) {
|
|
78
67
|
let html = stringifyChunk(result, chunk);
|
|
79
68
|
if (i === 0) {
|
|
80
69
|
if (!/<!doctype html/i.test(html)) {
|
|
File without changes
|
|
@@ -1016,25 +1016,11 @@ export interface SSRElement {
|
|
|
1016
1016
|
props: Record<string, any>;
|
|
1017
1017
|
children: string;
|
|
1018
1018
|
}
|
|
1019
|
-
export interface HydrationMetadata {
|
|
1020
|
-
directive: string;
|
|
1021
|
-
value: string;
|
|
1022
|
-
componentUrl: string;
|
|
1023
|
-
componentExport: {
|
|
1024
|
-
value: string;
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
export interface SSRRenderInstruction {
|
|
1028
|
-
type: 'directive';
|
|
1029
|
-
result: SSRResult;
|
|
1030
|
-
hydration: HydrationMetadata;
|
|
1031
|
-
}
|
|
1032
1019
|
export interface SSRMetadata {
|
|
1033
1020
|
renderers: SSRLoadedRenderer[];
|
|
1034
1021
|
pathname: string;
|
|
1035
1022
|
hasHydrationScript: boolean;
|
|
1036
1023
|
hasDirectives: Set<string>;
|
|
1037
|
-
pendingInstructions: Set<SSRRenderInstruction>;
|
|
1038
1024
|
}
|
|
1039
1025
|
export interface SSRResult {
|
|
1040
1026
|
styles: Set<SSRElement>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type { AstroComponentMetadata,
|
|
1
|
+
import type { AstroComponentMetadata, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
|
2
2
|
export declare const HydrationDirectiveProps: Set<string>;
|
|
3
|
-
export
|
|
3
|
+
export interface HydrationMetadata {
|
|
4
|
+
directive: string;
|
|
5
|
+
value: string;
|
|
6
|
+
componentUrl: string;
|
|
7
|
+
componentExport: {
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
4
11
|
interface ExtractedProps {
|
|
5
12
|
isPage: boolean;
|
|
6
13
|
hydration: HydrationMetadata | null;
|
|
@@ -16,3 +23,4 @@ interface HydrateScriptOptions {
|
|
|
16
23
|
}
|
|
17
24
|
/** For hydrated components, generate a <script type="module"> to load the component */
|
|
18
25
|
export declare function generateHydrateScript(scriptOptions: HydrateScriptOptions, metadata: Required<AstroComponentMetadata>): Promise<SSRElement>;
|
|
26
|
+
export {};
|
|
@@ -4,7 +4,7 @@ export { escapeHTML, HTMLString, markHTMLString, markHTMLString as unescapeHTML,
|
|
|
4
4
|
export type { Metadata } from './metadata';
|
|
5
5
|
export { createMetadata } from './metadata.js';
|
|
6
6
|
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';
|
|
7
|
-
export type { AstroComponentFactory } from './render/index.js';
|
|
7
|
+
export type { AstroComponentFactory, RenderInstruction } from './render/index.js';
|
|
8
8
|
import type { AstroComponentFactory } from './render/index.js';
|
|
9
9
|
export declare function createComponent(cb: AstroComponentFactory): AstroComponentFactory;
|
|
10
10
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { SSRResult } from '../../../@types/astro';
|
|
2
1
|
export declare function renderChild(child: any): AsyncIterable<any>;
|
|
3
|
-
export declare function renderSlot(result:
|
|
2
|
+
export declare function renderSlot(result: any, slotted: string, fallback?: any): Promise<string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { AstroComponentFactory } from './index';
|
|
3
|
+
import type { RenderInstruction } from './types';
|
|
3
4
|
export declare class AstroComponent {
|
|
4
5
|
private htmlParts;
|
|
5
6
|
private expressions;
|
|
@@ -8,7 +9,7 @@ export declare class AstroComponent {
|
|
|
8
9
|
[Symbol.asyncIterator](): AsyncGenerator<any, void, undefined>;
|
|
9
10
|
}
|
|
10
11
|
export declare function isAstroComponent(obj: any): obj is AstroComponent;
|
|
11
|
-
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string |
|
|
12
|
+
export declare function renderAstroComponent(component: InstanceType<typeof AstroComponent>): AsyncIterable<string | RenderInstruction>;
|
|
12
13
|
export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any): Promise<string>;
|
|
13
|
-
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string |
|
|
14
|
+
export declare function renderToIterable(result: SSRResult, componentFactory: AstroComponentFactory, displayName: string, props: any, children: any): Promise<AsyncIterable<string | RenderInstruction>>;
|
|
14
15
|
export declare function renderTemplate(htmlParts: TemplateStringsArray, ...expressions: any[]): Promise<AstroComponent>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
+
import type { RenderInstruction } from './types.js';
|
|
2
3
|
export declare const Fragment: unique symbol;
|
|
3
4
|
export declare const Renderer: unique symbol;
|
|
4
|
-
export declare function stringifyChunk(result: SSRResult, chunk: string |
|
|
5
|
+
export declare function stringifyChunk(result: SSRResult, chunk: string | RenderInstruction): any;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
+
import type { RenderInstruction } from './types.js';
|
|
3
|
+
export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, _props: Record<string | number, any>, slots?: any): Promise<string | AsyncIterable<string | RenderInstruction>>;
|
|
@@ -6,6 +6,7 @@ export { renderComponent } from './component.js';
|
|
|
6
6
|
export { renderHTMLElement } from './dom.js';
|
|
7
7
|
export { maybeRenderHead, renderHead } from './head.js';
|
|
8
8
|
export { renderPage } from './page.js';
|
|
9
|
+
export type { RenderInstruction } from './types';
|
|
9
10
|
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
|
|
10
11
|
export interface AstroComponentFactory {
|
|
11
12
|
(result: any, props: any, slots: any): ReturnType<typeof renderTemplate> | Response;
|