astro 2.0.4 → 2.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/content/internal.js +30 -10
- package/dist/content/vite-plugin-content-assets.js +3 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.d.ts +1 -0
- package/dist/core/errors/dev/vite.js +2 -1
- package/dist/core/errors/errors-data.d.ts +3 -1
- package/dist/core/errors/overlay.js +25 -3
- package/dist/core/messages.js +2 -2
- package/dist/runtime/server/render/common.js +2 -1
- package/dist/runtime/server/render/component.js +3 -1
- package/package.json +1 -1
package/dist/content/internal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
1
2
|
import { prependForwardSlash } from "../core/path.js";
|
|
2
3
|
import {
|
|
3
4
|
createComponent,
|
|
@@ -97,25 +98,44 @@ async function render({
|
|
|
97
98
|
collectionToRenderEntryMap
|
|
98
99
|
}) {
|
|
99
100
|
var _a;
|
|
101
|
+
const UnexpectedRenderError = new AstroError({
|
|
102
|
+
...AstroErrorData.UnknownContentCollectionError,
|
|
103
|
+
message: `Unexpected error while rendering ${String(collection)} \u2192 ${String(id)}.`
|
|
104
|
+
});
|
|
100
105
|
const lazyImport = (_a = collectionToRenderEntryMap[collection]) == null ? void 0 : _a[id];
|
|
101
|
-
if (
|
|
102
|
-
throw
|
|
103
|
-
const
|
|
106
|
+
if (typeof lazyImport !== "function")
|
|
107
|
+
throw UnexpectedRenderError;
|
|
108
|
+
const baseMod = await lazyImport();
|
|
109
|
+
if (baseMod == null || typeof baseMod !== "object")
|
|
110
|
+
throw UnexpectedRenderError;
|
|
111
|
+
const { collectedStyles, collectedLinks, collectedScripts, getMod } = baseMod;
|
|
112
|
+
if (typeof getMod !== "function")
|
|
113
|
+
throw UnexpectedRenderError;
|
|
114
|
+
const mod = await getMod();
|
|
115
|
+
if (mod == null || typeof mod !== "object")
|
|
116
|
+
throw UnexpectedRenderError;
|
|
104
117
|
const Content = createComponent({
|
|
105
|
-
factory(result,
|
|
118
|
+
factory(result, baseProps, slots) {
|
|
106
119
|
let styles = "", links = "", scripts = "";
|
|
107
|
-
if (Array.isArray(
|
|
108
|
-
styles =
|
|
120
|
+
if (Array.isArray(collectedStyles)) {
|
|
121
|
+
styles = collectedStyles.map((style) => renderStyleElement(style)).join("");
|
|
109
122
|
}
|
|
110
|
-
if (Array.isArray(
|
|
111
|
-
links =
|
|
123
|
+
if (Array.isArray(collectedLinks)) {
|
|
124
|
+
links = collectedLinks.map((link) => {
|
|
112
125
|
return renderUniqueStylesheet(result, {
|
|
113
126
|
href: prependForwardSlash(link)
|
|
114
127
|
});
|
|
115
128
|
}).join("");
|
|
116
129
|
}
|
|
117
|
-
if (Array.isArray(
|
|
118
|
-
scripts =
|
|
130
|
+
if (Array.isArray(collectedScripts)) {
|
|
131
|
+
scripts = collectedScripts.map((script) => renderScriptElement(script)).join("");
|
|
132
|
+
}
|
|
133
|
+
let props = baseProps;
|
|
134
|
+
if (id.endsWith("mdx")) {
|
|
135
|
+
props = {
|
|
136
|
+
components: mod.components ?? {},
|
|
137
|
+
...baseProps
|
|
138
|
+
};
|
|
119
139
|
}
|
|
120
140
|
return createHeadAndContent(
|
|
121
141
|
unescapeHTML(styles + links + scripts),
|
|
@@ -29,7 +29,9 @@ function astroContentAssetPropagationPlugin({ mode }) {
|
|
|
29
29
|
if (isPropagatedAsset(id)) {
|
|
30
30
|
const basePath = id.split("?")[0];
|
|
31
31
|
const code = `
|
|
32
|
-
export
|
|
32
|
+
export async function getMod() {
|
|
33
|
+
return import(${JSON.stringify(basePath)});
|
|
34
|
+
}
|
|
33
35
|
export const collectedLinks = ${JSON.stringify(LINKS_PLACEHOLDER)};
|
|
34
36
|
export const collectedStyles = ${JSON.stringify(STYLES_PLACEHOLDER)};
|
|
35
37
|
export const collectedScripts = ${JSON.stringify(SCRIPTS_PLACEHOLDER)};
|
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.5";
|
|
33
33
|
if (currentVersion.includes("-")) {
|
|
34
34
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
35
35
|
}
|
|
@@ -363,7 +363,7 @@ export declare const AstroErrorData: {
|
|
|
363
363
|
* @docs
|
|
364
364
|
* @message
|
|
365
365
|
* **Example error messages:**<br/>
|
|
366
|
-
* InvalidComponentArgs: Invalid arguments passed to
|
|
366
|
+
* InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component.
|
|
367
367
|
* @description
|
|
368
368
|
* Astro components cannot be rendered manually via a function call, such as `Component()` or `{items.map(Component)}`. Prefer the component syntax `<Component />` or `{items.map(item => <Component {...item} />)}`.
|
|
369
369
|
*/
|
|
@@ -558,6 +558,7 @@ export declare const AstroErrorData: {
|
|
|
558
558
|
};
|
|
559
559
|
/**
|
|
560
560
|
* @docs
|
|
561
|
+
* @message `COLLECTION_NAME` → `ENTRY_ID` has an invalid slug. `slug` must be a string.
|
|
561
562
|
* @see
|
|
562
563
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
563
564
|
* @description
|
|
@@ -571,6 +572,7 @@ export declare const AstroErrorData: {
|
|
|
571
572
|
};
|
|
572
573
|
/**
|
|
573
574
|
* @docs
|
|
575
|
+
* @message A content collection schema should not contain `slug` since it is reserved for slug generation. Remove this from your `COLLECTION_NAME` collection schema.
|
|
574
576
|
* @see
|
|
575
577
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
576
578
|
* @description
|
|
@@ -318,7 +318,8 @@ const style = `
|
|
|
318
318
|
|
|
319
319
|
#message-hints,
|
|
320
320
|
#stack,
|
|
321
|
-
#code
|
|
321
|
+
#code,
|
|
322
|
+
#cause {
|
|
322
323
|
border-radius: var(--roundiness);
|
|
323
324
|
background-color: var(--box-background);
|
|
324
325
|
}
|
|
@@ -468,7 +469,8 @@ const style = `
|
|
|
468
469
|
color: var(--error-text);
|
|
469
470
|
}
|
|
470
471
|
|
|
471
|
-
#stack h2
|
|
472
|
+
#stack h2,
|
|
473
|
+
#cause h2 {
|
|
472
474
|
color: var(--title-text);
|
|
473
475
|
font-family: var(--font-normal);
|
|
474
476
|
font-size: 22px;
|
|
@@ -477,7 +479,8 @@ const style = `
|
|
|
477
479
|
border-bottom: 1px solid var(--border);
|
|
478
480
|
}
|
|
479
481
|
|
|
480
|
-
#stack-content
|
|
482
|
+
#stack-content,
|
|
483
|
+
#cause-content {
|
|
481
484
|
font-size: 14px;
|
|
482
485
|
white-space: pre;
|
|
483
486
|
line-height: 21px;
|
|
@@ -485,6 +488,10 @@ const style = `
|
|
|
485
488
|
padding: 24px;
|
|
486
489
|
color: var(--stack-text);
|
|
487
490
|
}
|
|
491
|
+
|
|
492
|
+
#cause {
|
|
493
|
+
display: none;
|
|
494
|
+
}
|
|
488
495
|
`;
|
|
489
496
|
const overlayTemplate = `
|
|
490
497
|
<style>
|
|
@@ -548,6 +555,11 @@ ${style.trim()}
|
|
|
548
555
|
<h2>Stack Trace</h2>
|
|
549
556
|
<div id="stack-content"></div>
|
|
550
557
|
</section>
|
|
558
|
+
|
|
559
|
+
<section id="cause">
|
|
560
|
+
<h2>Cause</h2>
|
|
561
|
+
<div id="cause-content"></div>
|
|
562
|
+
</section>
|
|
551
563
|
</div>
|
|
552
564
|
</div>
|
|
553
565
|
`;
|
|
@@ -575,6 +587,16 @@ class ErrorOverlay extends HTMLElement {
|
|
|
575
587
|
this.text("#name", err.name);
|
|
576
588
|
this.text("#title", err.title);
|
|
577
589
|
this.text("#message-content", err.message, true);
|
|
590
|
+
const cause = this.root.querySelector("#cause");
|
|
591
|
+
if (cause && err.cause) {
|
|
592
|
+
if (typeof err.cause === "string") {
|
|
593
|
+
this.text("#cause-content", err.cause);
|
|
594
|
+
cause.style.display = "block";
|
|
595
|
+
} else {
|
|
596
|
+
this.text("#cause-content", JSON.stringify(err.cause, null, 2));
|
|
597
|
+
cause.style.display = "block";
|
|
598
|
+
}
|
|
599
|
+
}
|
|
578
600
|
const hint = this.root.querySelector("#hint");
|
|
579
601
|
if (hint && err.hint) {
|
|
580
602
|
this.text("#hint-content", err.hint, true);
|
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.5";
|
|
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.5"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -70,7 +70,8 @@ function chunkToByteArray(result, chunk) {
|
|
|
70
70
|
if (chunk instanceof Uint8Array) {
|
|
71
71
|
return chunk;
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
let stringified = stringifyChunk(result, chunk);
|
|
74
|
+
return encoder.encode(stringified.toString());
|
|
74
75
|
}
|
|
75
76
|
export {
|
|
76
77
|
Fragment,
|
|
@@ -206,8 +206,10 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
|
|
|
206
206
|
}
|
|
207
207
|
if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
|
|
208
208
|
yield html;
|
|
209
|
-
} else {
|
|
209
|
+
} else if (html && html.length > 0) {
|
|
210
210
|
yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ""));
|
|
211
|
+
} else {
|
|
212
|
+
yield "";
|
|
211
213
|
}
|
|
212
214
|
}();
|
|
213
215
|
}
|