astro 2.0.5 → 2.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/@types/astro.d.ts +1 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/result.js +1 -0
- package/dist/runtime/server/jsx.js +2 -0
- package/dist/runtime/server/render/astro/factory.js +2 -0
- package/dist/runtime/server/render/head.js +6 -1
- package/dist/runtime/server/render/slot.d.ts +1 -1
- package/dist/runtime/server/render/slot.js +4 -1
- package/dist/runtime/server/render/util.d.ts +5 -0
- package/dist/runtime/server/render/util.js +6 -0
- package/package.json +1 -1
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1305,6 +1305,7 @@ export interface SSRResult {
|
|
|
1305
1305
|
createAstro(Astro: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null): AstroGlobal;
|
|
1306
1306
|
resolve: (s: string) => Promise<string>;
|
|
1307
1307
|
response: ResponseInit;
|
|
1308
|
+
scope: number;
|
|
1308
1309
|
_metadata: SSRMetadata;
|
|
1309
1310
|
}
|
|
1310
1311
|
export interface PreviewServer {
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -29,7 +29,7 @@ async function dev(settings, options) {
|
|
|
29
29
|
isRestart: options.isRestart
|
|
30
30
|
})
|
|
31
31
|
);
|
|
32
|
-
const currentVersion = "2.0.
|
|
32
|
+
const currentVersion = "2.0.6";
|
|
33
33
|
if (currentVersion.includes("-")) {
|
|
34
34
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
35
35
|
}
|
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.0.
|
|
50
|
+
const version = "2.0.6";
|
|
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.0.
|
|
236
|
+
`v${"2.0.6"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -126,6 +126,7 @@ function createResult(args) {
|
|
|
126
126
|
propagation: args.propagation ?? /* @__PURE__ */ new Map(),
|
|
127
127
|
propagators: /* @__PURE__ */ new Map(),
|
|
128
128
|
extraHead: [],
|
|
129
|
+
scope: 0,
|
|
129
130
|
cookies,
|
|
130
131
|
createAstro(astroGlobal, props, slots) {
|
|
131
132
|
const astroSlots = new Slots(result, slots, args.logging);
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
voidElementNames
|
|
10
10
|
} from "./index.js";
|
|
11
11
|
import { HTMLParts } from "./render/common.js";
|
|
12
|
+
import { ScopeFlags } from "./render/util.js";
|
|
12
13
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
13
14
|
class Skip {
|
|
14
15
|
constructor(vnode) {
|
|
@@ -77,6 +78,7 @@ Did you forget to import the component or is it possible there is a typo?`);
|
|
|
77
78
|
props[key] = value;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
result.scope |= ScopeFlags.JSX;
|
|
80
82
|
return markHTMLString(await renderToString(result, vnode.type, props, slots));
|
|
81
83
|
}
|
|
82
84
|
case (!vnode.type && vnode.type !== 0):
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { HTMLParts } from "../common.js";
|
|
2
|
+
import { ScopeFlags } from "../util.js";
|
|
2
3
|
import { isHeadAndContent } from "./head-and-content.js";
|
|
3
4
|
import { renderAstroTemplateResult } from "./render-template.js";
|
|
4
5
|
function isAstroComponentFactory(obj) {
|
|
5
6
|
return obj == null ? false : obj.isAstroComponentFactory === true;
|
|
6
7
|
}
|
|
7
8
|
async function renderToString(result, componentFactory, props, children) {
|
|
9
|
+
result.scope |= ScopeFlags.Astro;
|
|
8
10
|
const factoryResult = await componentFactory(result, props, children);
|
|
9
11
|
if (factoryResult instanceof Response) {
|
|
10
12
|
const response = factoryResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
|
-
import { renderElement } from "./util.js";
|
|
2
|
+
import { renderElement, ScopeFlags } from "./util.js";
|
|
3
3
|
const uniqueElements = (item, index, all) => {
|
|
4
4
|
const props = JSON.stringify(item.props);
|
|
5
5
|
const children = item.children;
|
|
@@ -28,6 +28,11 @@ function* maybeRenderHead(result) {
|
|
|
28
28
|
if (result._metadata.hasRenderedHead) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
+
switch (result.scope) {
|
|
32
|
+
case ScopeFlags.JSX | ScopeFlags.Slot | ScopeFlags.Astro: {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
31
36
|
yield { type: "head", result };
|
|
32
37
|
}
|
|
33
38
|
export {
|
|
@@ -8,7 +8,7 @@ export declare class SlotString extends HTMLString {
|
|
|
8
8
|
constructor(content: string, instructions: null | RenderInstruction[]);
|
|
9
9
|
}
|
|
10
10
|
export declare function isSlotString(str: string): str is any;
|
|
11
|
-
export declare function renderSlot(
|
|
11
|
+
export declare function renderSlot(result: SSRResult, slotted: string, fallback?: any): Promise<string>;
|
|
12
12
|
interface RenderSlotsResult {
|
|
13
13
|
slotInstructions: null | RenderInstruction[];
|
|
14
14
|
children: Record<string, string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HTMLString, markHTMLString } from "../escape.js";
|
|
2
2
|
import { renderChild } from "./any.js";
|
|
3
|
+
import { ScopeFlags } from "./util.js";
|
|
3
4
|
const slotString = Symbol.for("astro:slot-string");
|
|
4
5
|
class SlotString extends HTMLString {
|
|
5
6
|
constructor(content, instructions) {
|
|
@@ -12,8 +13,9 @@ slotString;
|
|
|
12
13
|
function isSlotString(str) {
|
|
13
14
|
return !!str[slotString];
|
|
14
15
|
}
|
|
15
|
-
async function renderSlot(
|
|
16
|
+
async function renderSlot(result, slotted, fallback) {
|
|
16
17
|
if (slotted) {
|
|
18
|
+
result.scope |= ScopeFlags.Slot;
|
|
17
19
|
let iterator = renderChild(slotted);
|
|
18
20
|
let content = "";
|
|
19
21
|
let instructions = null;
|
|
@@ -27,6 +29,7 @@ async function renderSlot(_result, slotted, fallback) {
|
|
|
27
29
|
content += chunk;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
result.scope &= ~ScopeFlags.Slot;
|
|
30
33
|
return markHTMLString(new SlotString(content, instructions));
|
|
31
34
|
}
|
|
32
35
|
return fallback;
|
|
@@ -6,3 +6,8 @@ export declare function formatList(values: string[]): string;
|
|
|
6
6
|
export declare function addAttribute(value: any, key: string, shouldEscape?: boolean): any;
|
|
7
7
|
export declare function internalSpreadAttributes(values: Record<any, any>, shouldEscape?: boolean): any;
|
|
8
8
|
export declare function renderElement(name: string, { props: _props, children }: SSRElement, shouldEscape?: boolean): string;
|
|
9
|
+
export declare const ScopeFlags: {
|
|
10
|
+
Astro: number;
|
|
11
|
+
JSX: number;
|
|
12
|
+
Slot: number;
|
|
13
|
+
};
|
|
@@ -86,7 +86,13 @@ function renderElement(name, { props: _props, children = "" }, shouldEscape = tr
|
|
|
86
86
|
}
|
|
87
87
|
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
|
88
88
|
}
|
|
89
|
+
const ScopeFlags = {
|
|
90
|
+
Astro: 1 << 0,
|
|
91
|
+
JSX: 1 << 1,
|
|
92
|
+
Slot: 1 << 2
|
|
93
|
+
};
|
|
89
94
|
export {
|
|
95
|
+
ScopeFlags,
|
|
90
96
|
addAttribute,
|
|
91
97
|
defineScriptVars,
|
|
92
98
|
formatList,
|