astro 2.0.2 → 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/client-base.d.ts +0 -2
- package/dist/@types/astro.d.ts +2 -1
- package/dist/content/consts.d.ts +2 -1
- package/dist/content/consts.js +4 -2
- package/dist/content/index.d.ts +1 -1
- package/dist/content/index.js +4 -4
- package/dist/content/internal.d.ts +1 -1
- package/dist/content/internal.js +34 -10
- package/dist/content/vite-plugin-content-assets.d.ts +2 -2
- package/dist/content/vite-plugin-content-assets.js +19 -15
- package/dist/core/build/static-build.js +2 -2
- package/dist/core/build/vite-plugin-css.js +4 -4
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +3 -3
- 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 +16 -0
- package/dist/core/errors/errors-data.js +6 -0
- package/dist/core/errors/overlay.js +25 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/render/dev/vite.js +2 -2
- package/dist/runtime/server/astro-component.js +23 -3
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +2 -0
- package/dist/runtime/server/render/astro/head-and-content.d.ts +2 -2
- package/dist/runtime/server/render/common.js +33 -23
- package/dist/runtime/server/render/component.js +3 -1
- package/dist/runtime/server/render/head.d.ts +9 -3
- package/dist/runtime/server/render/head.js +11 -18
- package/dist/runtime/server/render/index.d.ts +1 -1
- package/dist/runtime/server/render/index.js +2 -1
- package/dist/runtime/server/render/slot.js +1 -1
- package/dist/runtime/server/render/tags.d.ts +2 -1
- package/dist/runtime/server/render/tags.js +7 -0
- package/dist/runtime/server/render/types.d.ts +7 -2
- package/dist/vite-plugin-astro/compile.js +6 -1
- package/package.json +1 -1
- package/src/content/template/types.d.ts +4 -0
- package/src/content/template/virtual-mod.mjs +1 -1
package/client-base.d.ts
CHANGED
|
@@ -112,8 +112,6 @@ declare module '*.mdx' {
|
|
|
112
112
|
export const url: MDX['url'];
|
|
113
113
|
export const getHeadings: MDX['getHeadings'];
|
|
114
114
|
export const Content: MDX['Content'];
|
|
115
|
-
export const rawContent: MDX['rawContent'];
|
|
116
|
-
export const compiledContent: MDX['compiledContent'];
|
|
117
115
|
|
|
118
116
|
const load: MDX['default'];
|
|
119
117
|
export default load;
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/s
|
|
|
16
16
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
17
17
|
export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
18
18
|
export type { SSRManifest } from '../core/app/types';
|
|
19
|
+
export type { AstroCookies } from '../core/cookies';
|
|
19
20
|
export interface AstroBuiltinProps {
|
|
20
21
|
'client:load'?: boolean;
|
|
21
22
|
'client:idle'?: boolean;
|
|
@@ -1299,7 +1300,7 @@ export interface SSRResult {
|
|
|
1299
1300
|
links: Set<SSRElement>;
|
|
1300
1301
|
propagation: Map<string, PropagationHint>;
|
|
1301
1302
|
propagators: Map<AstroComponentFactory, AstroComponentInstance>;
|
|
1302
|
-
extraHead: Array<
|
|
1303
|
+
extraHead: Array<string>;
|
|
1303
1304
|
cookies: AstroCookies | undefined;
|
|
1304
1305
|
createAstro(Astro: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null): AstroGlobal;
|
|
1305
1306
|
resolve: (s: string) => Promise<string>;
|
package/dist/content/consts.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const contentFileExts: string[];
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const PROPAGATED_ASSET_FLAG = "astroPropagatedAssets";
|
|
3
3
|
export declare const CONTENT_FLAG = "astroContent";
|
|
4
4
|
export declare const VIRTUAL_MODULE_ID = "astro:content";
|
|
5
5
|
export declare const LINKS_PLACEHOLDER = "@@ASTRO-LINKS@@";
|
|
6
6
|
export declare const STYLES_PLACEHOLDER = "@@ASTRO-STYLES@@";
|
|
7
|
+
export declare const SCRIPTS_PLACEHOLDER = "@@ASTRO-SCRIPTS@@";
|
|
7
8
|
export declare const CONTENT_TYPES_FILE = "types.d.ts";
|
package/dist/content/consts.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const contentFileExts = [".md", ".mdx"];
|
|
2
|
-
const
|
|
2
|
+
const PROPAGATED_ASSET_FLAG = "astroPropagatedAssets";
|
|
3
3
|
const CONTENT_FLAG = "astroContent";
|
|
4
4
|
const VIRTUAL_MODULE_ID = "astro:content";
|
|
5
5
|
const LINKS_PLACEHOLDER = "@@ASTRO-LINKS@@";
|
|
6
6
|
const STYLES_PLACEHOLDER = "@@ASTRO-STYLES@@";
|
|
7
|
+
const SCRIPTS_PLACEHOLDER = "@@ASTRO-SCRIPTS@@";
|
|
7
8
|
const CONTENT_TYPES_FILE = "types.d.ts";
|
|
8
9
|
export {
|
|
9
10
|
CONTENT_FLAG,
|
|
10
11
|
CONTENT_TYPES_FILE,
|
|
11
|
-
DELAYED_ASSET_FLAG,
|
|
12
12
|
LINKS_PLACEHOLDER,
|
|
13
|
+
PROPAGATED_ASSET_FLAG,
|
|
14
|
+
SCRIPTS_PLACEHOLDER,
|
|
13
15
|
STYLES_PLACEHOLDER,
|
|
14
16
|
VIRTUAL_MODULE_ID,
|
|
15
17
|
contentFileExts
|
package/dist/content/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createContentTypesGenerator } from './types-generator.js';
|
|
2
2
|
export { contentObservable, getContentPaths, getDotAstroTypeReference } from './utils.js';
|
|
3
|
-
export {
|
|
3
|
+
export { astroContentAssetPropagationPlugin, astroContentProdBundlePlugin, } from './vite-plugin-content-assets.js';
|
|
4
4
|
export { astroContentServerPlugin } from './vite-plugin-content-server.js';
|
|
5
5
|
export { astroContentVirtualModPlugin } from './vite-plugin-content-virtual-mod.js';
|
package/dist/content/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createContentTypesGenerator } from "./types-generator.js";
|
|
2
2
|
import { contentObservable, getContentPaths, getDotAstroTypeReference } from "./utils.js";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
astroContentAssetPropagationPlugin,
|
|
5
|
+
astroContentProdBundlePlugin
|
|
6
6
|
} from "./vite-plugin-content-assets.js";
|
|
7
7
|
import { astroContentServerPlugin } from "./vite-plugin-content-server.js";
|
|
8
8
|
import { astroContentVirtualModPlugin } from "./vite-plugin-content-virtual-mod.js";
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
astroContentAssetPropagationPlugin,
|
|
11
|
+
astroContentProdBundlePlugin,
|
|
11
12
|
astroContentServerPlugin,
|
|
12
13
|
astroContentVirtualModPlugin,
|
|
13
|
-
astroDelayedAssetPlugin,
|
|
14
14
|
contentObservable,
|
|
15
15
|
createContentTypesGenerator,
|
|
16
16
|
getContentPaths,
|
|
@@ -7,7 +7,7 @@ export declare function createCollectionToGlobResultMap({ globResult, contentDir
|
|
|
7
7
|
export declare function createGetCollection({ collectionToEntryMap, collectionToRenderEntryMap, }: {
|
|
8
8
|
collectionToEntryMap: CollectionToEntryMap;
|
|
9
9
|
collectionToRenderEntryMap: CollectionToEntryMap;
|
|
10
|
-
}): (collection: string, filter?: () =>
|
|
10
|
+
}): (collection: string, filter?: ((entry: any) => unknown) | undefined) => Promise<{
|
|
11
11
|
id: any;
|
|
12
12
|
slug: any;
|
|
13
13
|
body: any;
|
package/dist/content/internal.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
1
2
|
import { prependForwardSlash } from "../core/path.js";
|
|
2
3
|
import {
|
|
3
4
|
createComponent,
|
|
4
5
|
createHeadAndContent,
|
|
5
6
|
renderComponent,
|
|
7
|
+
renderScriptElement,
|
|
6
8
|
renderStyleElement,
|
|
7
9
|
renderTemplate,
|
|
8
10
|
renderUniqueStylesheet,
|
|
@@ -96,25 +98,47 @@ async function render({
|
|
|
96
98
|
collectionToRenderEntryMap
|
|
97
99
|
}) {
|
|
98
100
|
var _a;
|
|
101
|
+
const UnexpectedRenderError = new AstroError({
|
|
102
|
+
...AstroErrorData.UnknownContentCollectionError,
|
|
103
|
+
message: `Unexpected error while rendering ${String(collection)} \u2192 ${String(id)}.`
|
|
104
|
+
});
|
|
99
105
|
const lazyImport = (_a = collectionToRenderEntryMap[collection]) == null ? void 0 : _a[id];
|
|
100
|
-
if (
|
|
101
|
-
throw
|
|
102
|
-
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;
|
|
103
117
|
const Content = createComponent({
|
|
104
|
-
factory(result,
|
|
105
|
-
let styles = "", links = "";
|
|
106
|
-
if (Array.isArray(
|
|
107
|
-
styles =
|
|
118
|
+
factory(result, baseProps, slots) {
|
|
119
|
+
let styles = "", links = "", scripts = "";
|
|
120
|
+
if (Array.isArray(collectedStyles)) {
|
|
121
|
+
styles = collectedStyles.map((style) => renderStyleElement(style)).join("");
|
|
108
122
|
}
|
|
109
|
-
if (Array.isArray(
|
|
110
|
-
links =
|
|
123
|
+
if (Array.isArray(collectedLinks)) {
|
|
124
|
+
links = collectedLinks.map((link) => {
|
|
111
125
|
return renderUniqueStylesheet(result, {
|
|
112
126
|
href: prependForwardSlash(link)
|
|
113
127
|
});
|
|
114
128
|
}).join("");
|
|
115
129
|
}
|
|
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
|
+
};
|
|
139
|
+
}
|
|
116
140
|
return createHeadAndContent(
|
|
117
|
-
unescapeHTML(styles + links),
|
|
141
|
+
unescapeHTML(styles + links + scripts),
|
|
118
142
|
renderTemplate`${renderComponent(result, "Content", mod.Content, props, slots)}`
|
|
119
143
|
);
|
|
120
144
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import { BuildInternals } from '../core/build/internal.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function astroContentAssetPropagationPlugin({ mode }: {
|
|
4
4
|
mode: string;
|
|
5
5
|
}): Plugin;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function astroContentProdBundlePlugin({ internals }: {
|
|
7
7
|
internals: BuildInternals;
|
|
8
8
|
}): Plugin;
|
|
@@ -3,20 +3,22 @@ import { moduleIsTopLevelPage, walkParentInfos } from "../core/build/graph.js";
|
|
|
3
3
|
import { getPageDataByViteID } from "../core/build/internal.js";
|
|
4
4
|
import { createViteLoader } from "../core/module-loader/vite.js";
|
|
5
5
|
import { getStylesForURL } from "../core/render/dev/css.js";
|
|
6
|
+
import { getScriptsForURL } from "../core/render/dev/scripts.js";
|
|
6
7
|
import {
|
|
7
8
|
contentFileExts,
|
|
8
|
-
DELAYED_ASSET_FLAG,
|
|
9
9
|
LINKS_PLACEHOLDER,
|
|
10
|
+
PROPAGATED_ASSET_FLAG,
|
|
11
|
+
SCRIPTS_PLACEHOLDER,
|
|
10
12
|
STYLES_PLACEHOLDER
|
|
11
13
|
} from "./consts.js";
|
|
12
|
-
function
|
|
14
|
+
function isPropagatedAsset(viteId) {
|
|
13
15
|
const url = new URL(viteId, "file://");
|
|
14
|
-
return url.searchParams.has(
|
|
16
|
+
return url.searchParams.has(PROPAGATED_ASSET_FLAG) && contentFileExts.some((ext) => url.pathname.endsWith(ext));
|
|
15
17
|
}
|
|
16
|
-
function
|
|
18
|
+
function astroContentAssetPropagationPlugin({ mode }) {
|
|
17
19
|
let devModuleLoader;
|
|
18
20
|
return {
|
|
19
|
-
name: "astro-
|
|
21
|
+
name: "astro:content-asset-propagation",
|
|
20
22
|
enforce: "pre",
|
|
21
23
|
configureServer(server) {
|
|
22
24
|
if (mode === "dev") {
|
|
@@ -24,12 +26,15 @@ function astroDelayedAssetPlugin({ mode }) {
|
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
load(id) {
|
|
27
|
-
if (
|
|
29
|
+
if (isPropagatedAsset(id)) {
|
|
28
30
|
const basePath = id.split("?")[0];
|
|
29
31
|
const code = `
|
|
30
|
-
export
|
|
32
|
+
export async function getMod() {
|
|
33
|
+
return import(${JSON.stringify(basePath)});
|
|
34
|
+
}
|
|
31
35
|
export const collectedLinks = ${JSON.stringify(LINKS_PLACEHOLDER)};
|
|
32
36
|
export const collectedStyles = ${JSON.stringify(STYLES_PLACEHOLDER)};
|
|
37
|
+
export const collectedScripts = ${JSON.stringify(SCRIPTS_PLACEHOLDER)};
|
|
33
38
|
`;
|
|
34
39
|
return { code };
|
|
35
40
|
}
|
|
@@ -38,7 +43,7 @@ function astroDelayedAssetPlugin({ mode }) {
|
|
|
38
43
|
var _a;
|
|
39
44
|
if (!(options == null ? void 0 : options.ssr))
|
|
40
45
|
return;
|
|
41
|
-
if (devModuleLoader &&
|
|
46
|
+
if (devModuleLoader && isPropagatedAsset(id)) {
|
|
42
47
|
const basePath = id.split("?")[0];
|
|
43
48
|
if (!((_a = devModuleLoader.getModuleById(basePath)) == null ? void 0 : _a.ssrModule)) {
|
|
44
49
|
await devModuleLoader.import(basePath);
|
|
@@ -48,18 +53,17 @@ function astroDelayedAssetPlugin({ mode }) {
|
|
|
48
53
|
devModuleLoader,
|
|
49
54
|
"development"
|
|
50
55
|
);
|
|
56
|
+
const hoistedScripts = await getScriptsForURL(pathToFileURL(basePath), devModuleLoader);
|
|
51
57
|
return {
|
|
52
|
-
code: code.replace(JSON.stringify(LINKS_PLACEHOLDER), JSON.stringify([...urls])).replace(JSON.stringify(STYLES_PLACEHOLDER), JSON.stringify([...stylesMap.values()]))
|
|
58
|
+
code: code.replace(JSON.stringify(LINKS_PLACEHOLDER), JSON.stringify([...urls])).replace(JSON.stringify(STYLES_PLACEHOLDER), JSON.stringify([...stylesMap.values()])).replace(JSON.stringify(SCRIPTS_PLACEHOLDER), JSON.stringify([...hoistedScripts]))
|
|
53
59
|
};
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
|
-
function
|
|
59
|
-
internals
|
|
60
|
-
}) {
|
|
64
|
+
function astroContentProdBundlePlugin({ internals }) {
|
|
61
65
|
return {
|
|
62
|
-
name: "astro-bundle
|
|
66
|
+
name: "astro:content-prod-bundle",
|
|
63
67
|
async generateBundle(_options, bundle) {
|
|
64
68
|
var _a;
|
|
65
69
|
for (const [_, chunk] of Object.entries(bundle)) {
|
|
@@ -87,6 +91,6 @@ function astroBundleDelayedAssetPlugin({
|
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
astroContentAssetPropagationPlugin,
|
|
95
|
+
astroContentProdBundlePlugin
|
|
92
96
|
};
|
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
import { bgGreen, bgMagenta, black, dim } from "kleur/colors";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
6
|
import * as vite from "vite";
|
|
7
|
-
import {
|
|
7
|
+
import { astroContentProdBundlePlugin } from "../../content/index.js";
|
|
8
8
|
import {
|
|
9
9
|
createBuildInternals,
|
|
10
10
|
eachPrerenderedPageData
|
|
@@ -131,7 +131,7 @@ async function ssrBuild(opts, internals, input) {
|
|
|
131
131
|
}),
|
|
132
132
|
vitePluginPrerender(opts, internals),
|
|
133
133
|
...viteConfig.plugins || [],
|
|
134
|
-
|
|
134
|
+
astroContentProdBundlePlugin({ internals }),
|
|
135
135
|
ssr && vitePluginSSR(internals, settings.adapter)
|
|
136
136
|
],
|
|
137
137
|
envPrefix: viteConfig.envPrefix ?? "PUBLIC_",
|
|
@@ -2,7 +2,7 @@ import * as crypto from "node:crypto";
|
|
|
2
2
|
import * as npath from "node:path";
|
|
3
3
|
import { transformWithEsbuild } from "vite";
|
|
4
4
|
import { isCSSRequest } from "../render/util.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PROPAGATED_ASSET_FLAG } from "../../content/consts.js";
|
|
6
6
|
import * as assetName from "./css-asset-name.js";
|
|
7
7
|
import { moduleIsTopLevelPage, walkParentInfos } from "./graph.js";
|
|
8
8
|
import {
|
|
@@ -54,7 +54,7 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
54
54
|
for (const [pageInfo] of walkParentInfos(id, {
|
|
55
55
|
getModuleInfo: args[0].getModuleInfo
|
|
56
56
|
})) {
|
|
57
|
-
if (new URL(pageInfo.id, "file://").searchParams.has(
|
|
57
|
+
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
58
58
|
return createNameHash(id, [id]);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -114,10 +114,10 @@ function rollupPluginAstroBuildCSS(options) {
|
|
|
114
114
|
id,
|
|
115
115
|
this,
|
|
116
116
|
function until(importer) {
|
|
117
|
-
return new URL(importer, "file://").searchParams.has(
|
|
117
|
+
return new URL(importer, "file://").searchParams.has(PROPAGATED_ASSET_FLAG);
|
|
118
118
|
}
|
|
119
119
|
)) {
|
|
120
|
-
if (new URL(pageInfo.id, "file://").searchParams.has(
|
|
120
|
+
if (new URL(pageInfo.id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG)) {
|
|
121
121
|
for (const parent of walkParentInfos(id, this)) {
|
|
122
122
|
const parentInfo = parent[0];
|
|
123
123
|
if (moduleIsTopLevelPage(parentInfo)) {
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -3,9 +3,9 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import * as vite from "vite";
|
|
4
4
|
import { crawlFrameworkPkgs } from "vitefu";
|
|
5
5
|
import {
|
|
6
|
+
astroContentAssetPropagationPlugin,
|
|
6
7
|
astroContentServerPlugin,
|
|
7
|
-
astroContentVirtualModPlugin
|
|
8
|
-
astroDelayedAssetPlugin
|
|
8
|
+
astroContentVirtualModPlugin
|
|
9
9
|
} from "../content/index.js";
|
|
10
10
|
import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.js";
|
|
11
11
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
@@ -74,7 +74,7 @@ async function createVite(commandConfig, { settings, logging, mode, fs = nodeFs
|
|
|
74
74
|
astroInjectEnvTsPlugin({ settings, logging, fs }),
|
|
75
75
|
astroContentVirtualModPlugin({ settings }),
|
|
76
76
|
astroContentServerPlugin({ fs, settings, logging, mode }),
|
|
77
|
-
|
|
77
|
+
astroContentAssetPropagationPlugin({ mode })
|
|
78
78
|
],
|
|
79
79
|
publicDir: fileURLToPath(settings.config.publicDir),
|
|
80
80
|
root: fileURLToPath(settings.config.root),
|
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
|
}
|
|
@@ -359,6 +359,20 @@ export declare const AstroErrorData: {
|
|
|
359
359
|
readonly message: (prefix: string, suffix: string) => string;
|
|
360
360
|
readonly hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`.";
|
|
361
361
|
};
|
|
362
|
+
/**
|
|
363
|
+
* @docs
|
|
364
|
+
* @message
|
|
365
|
+
* **Example error messages:**<br/>
|
|
366
|
+
* InvalidComponentArgs: Invalid arguments passed to `<MyAstroComponent>` component.
|
|
367
|
+
* @description
|
|
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
|
+
*/
|
|
370
|
+
readonly InvalidComponentArgs: {
|
|
371
|
+
readonly title: "Invalid component arguments.";
|
|
372
|
+
readonly code: 3020;
|
|
373
|
+
readonly message: (name: string) => string;
|
|
374
|
+
readonly hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`.";
|
|
375
|
+
};
|
|
362
376
|
readonly UnknownViteError: {
|
|
363
377
|
readonly title: "Unknown Vite Error.";
|
|
364
378
|
readonly code: 4000;
|
|
@@ -544,6 +558,7 @@ export declare const AstroErrorData: {
|
|
|
544
558
|
};
|
|
545
559
|
/**
|
|
546
560
|
* @docs
|
|
561
|
+
* @message `COLLECTION_NAME` → `ENTRY_ID` has an invalid slug. `slug` must be a string.
|
|
547
562
|
* @see
|
|
548
563
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
549
564
|
* @description
|
|
@@ -557,6 +572,7 @@ export declare const AstroErrorData: {
|
|
|
557
572
|
};
|
|
558
573
|
/**
|
|
559
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.
|
|
560
576
|
* @see
|
|
561
577
|
* - [The reserved entry `slug` field](https://docs.astro.build/en/guides/content-collections/)
|
|
562
578
|
* @description
|
|
@@ -133,6 +133,12 @@ Expected \`true\` value but got \`${suffix}\`.`;
|
|
|
133
133
|
},
|
|
134
134
|
hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
|
|
135
135
|
},
|
|
136
|
+
InvalidComponentArgs: {
|
|
137
|
+
title: "Invalid component arguments.",
|
|
138
|
+
code: 3020,
|
|
139
|
+
message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
|
|
140
|
+
hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
|
|
141
|
+
},
|
|
136
142
|
UnknownViteError: {
|
|
137
143
|
title: "Unknown Vite Error.",
|
|
138
144
|
code: 4e3
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import npath from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { PROPAGATED_ASSET_FLAG } from "../../../content/consts.js";
|
|
3
3
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "../../constants.js";
|
|
4
4
|
import { unwrapId } from "../../util.js";
|
|
5
5
|
import { STYLE_EXTENSIONS } from "../util.js";
|
|
@@ -8,7 +8,7 @@ const STRIP_QUERY_PARAMS_REGEX = /\?.*$/;
|
|
|
8
8
|
async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ new Set()) {
|
|
9
9
|
const id = unwrapId(_id);
|
|
10
10
|
const importedModules = /* @__PURE__ */ new Set();
|
|
11
|
-
if (new URL(id, "file://").searchParams.has(
|
|
11
|
+
if (new URL(id, "file://").searchParams.has(PROPAGATED_ASSET_FLAG))
|
|
12
12
|
return;
|
|
13
13
|
const moduleEntriesForId = isRootFile ? loader.getModulesByFile(id) ?? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([loader.getModuleById(id)]);
|
|
14
14
|
for (const entry of moduleEntriesForId) {
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
|
+
function validateArgs(args) {
|
|
3
|
+
if (args.length !== 3)
|
|
4
|
+
return false;
|
|
5
|
+
if (!args[0] || typeof args[0] !== "object")
|
|
6
|
+
return false;
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
1
9
|
function baseCreateComponent(cb, moduleId) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
const name = ((_a = moduleId == null ? void 0 : moduleId.split("/").pop()) == null ? void 0 : _a.replace(".astro", "")) ?? "";
|
|
12
|
+
const fn = (...args) => {
|
|
13
|
+
if (!validateArgs(args)) {
|
|
14
|
+
throw new AstroError({
|
|
15
|
+
...AstroErrorData.InvalidComponentArgs,
|
|
16
|
+
message: AstroErrorData.InvalidComponentArgs.message(name)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return cb(...args);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(fn, "name", { value: name, writable: false });
|
|
22
|
+
fn.isAstroComponentFactory = true;
|
|
23
|
+
fn.moduleId = moduleId;
|
|
24
|
+
return fn;
|
|
5
25
|
}
|
|
6
26
|
function createComponentWithOptions(opts) {
|
|
7
27
|
const cb = baseCreateComponent(opts.factory, opts.moduleId);
|
|
@@ -3,7 +3,7 @@ export { createAstro } from './astro-global.js';
|
|
|
3
3
|
export { renderEndpoint } from './endpoint.js';
|
|
4
4
|
export { escapeHTML, HTMLBytes, HTMLString, markHTMLString, unescapeHTML } from './escape.js';
|
|
5
5
|
export { renderJSX } from './jsx.js';
|
|
6
|
-
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderSlot, renderStyleElement, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
6
|
+
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderStyleElement, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, stringifyChunk, voidElementNames, } from './render/index.js';
|
|
7
7
|
export type { AstroComponentFactory, AstroComponentInstance, AstroComponentSlots, AstroComponentSlotsWithValues, RenderInstruction, } from './render/index.js';
|
|
8
8
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
9
9
|
/** @internal Associate JSX components with a specific renderer (see /src/vite-plugin-jsx/tag.ts) */
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
renderHead,
|
|
17
17
|
renderHTMLElement,
|
|
18
18
|
renderPage,
|
|
19
|
+
renderScriptElement,
|
|
19
20
|
renderSlot,
|
|
20
21
|
renderStyleElement,
|
|
21
22
|
renderTemplate,
|
|
@@ -104,6 +105,7 @@ export {
|
|
|
104
105
|
renderHead,
|
|
105
106
|
renderJSX,
|
|
106
107
|
renderPage,
|
|
108
|
+
renderScriptElement,
|
|
107
109
|
renderSlot,
|
|
108
110
|
renderStyleElement,
|
|
109
111
|
renderTemplate2 as renderTemplate,
|
|
@@ -2,9 +2,9 @@ import type { RenderTemplateResult } from './render-template';
|
|
|
2
2
|
declare const headAndContentSym: unique symbol;
|
|
3
3
|
export type HeadAndContent = {
|
|
4
4
|
[headAndContentSym]: true;
|
|
5
|
-
head: string
|
|
5
|
+
head: string;
|
|
6
6
|
content: RenderTemplateResult;
|
|
7
7
|
};
|
|
8
8
|
export declare function isHeadAndContent(obj: unknown): obj is HeadAndContent;
|
|
9
|
-
export declare function createHeadAndContent(head: string
|
|
9
|
+
export declare function createHeadAndContent(head: string, content: RenderTemplateResult): HeadAndContent;
|
|
10
10
|
export {};
|
|
@@ -4,39 +4,48 @@ import {
|
|
|
4
4
|
determinesIfNeedsDirectiveScript,
|
|
5
5
|
getPrescripts
|
|
6
6
|
} from "../scripts.js";
|
|
7
|
+
import { renderAllHeadContent } from "./head.js";
|
|
7
8
|
import { isSlotString } from "./slot.js";
|
|
8
9
|
const Fragment = Symbol.for("astro:fragment");
|
|
9
10
|
const Renderer = Symbol.for("astro:renderer");
|
|
10
11
|
const encoder = new TextEncoder();
|
|
11
12
|
const decoder = new TextDecoder();
|
|
12
13
|
function stringifyChunk(result, chunk) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
if (typeof chunk.type === "string") {
|
|
15
|
+
const instruction = chunk;
|
|
16
|
+
switch (instruction.type) {
|
|
17
|
+
case "directive": {
|
|
18
|
+
const { hydration } = instruction;
|
|
19
|
+
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
|
20
|
+
let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
|
21
|
+
let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
|
|
22
|
+
if (prescriptType) {
|
|
23
|
+
let prescripts = getPrescripts(prescriptType, hydration.directive);
|
|
24
|
+
return markHTMLString(prescripts);
|
|
25
|
+
} else {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
case "head": {
|
|
30
|
+
if (result._metadata.hasRenderedHead) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
return renderAllHeadContent(result);
|
|
24
34
|
}
|
|
25
35
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
36
|
+
} else {
|
|
37
|
+
if (isSlotString(chunk)) {
|
|
38
|
+
let out = "";
|
|
39
|
+
const c = chunk;
|
|
40
|
+
if (c.instructions) {
|
|
41
|
+
for (const instr of c.instructions) {
|
|
42
|
+
out += stringifyChunk(result, instr);
|
|
34
43
|
}
|
|
35
|
-
out += chunk.toString();
|
|
36
|
-
return out;
|
|
37
44
|
}
|
|
38
|
-
|
|
45
|
+
out += chunk.toString();
|
|
46
|
+
return out;
|
|
39
47
|
}
|
|
48
|
+
return chunk.toString();
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
class HTMLParts {
|
|
@@ -61,7 +70,8 @@ function chunkToByteArray(result, chunk) {
|
|
|
61
70
|
if (chunk instanceof Uint8Array) {
|
|
62
71
|
return chunk;
|
|
63
72
|
}
|
|
64
|
-
|
|
73
|
+
let stringified = stringifyChunk(result, chunk);
|
|
74
|
+
return encoder.encode(stringified.toString());
|
|
65
75
|
}
|
|
66
76
|
export {
|
|
67
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
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare
|
|
4
|
-
|
|
2
|
+
export declare function renderAllHeadContent(result: SSRResult): any;
|
|
3
|
+
export declare function renderHead(result: SSRResult): Generator<{
|
|
4
|
+
readonly type: "head";
|
|
5
|
+
readonly result: SSRResult;
|
|
6
|
+
}, void, unknown>;
|
|
7
|
+
export declare function maybeRenderHead(result: SSRResult): Generator<{
|
|
8
|
+
readonly type: "head";
|
|
9
|
+
readonly result: SSRResult;
|
|
10
|
+
}, void, unknown>;
|
|
@@ -1,44 +1,37 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
|
-
import { renderChild } from "./any.js";
|
|
3
2
|
import { renderElement } from "./util.js";
|
|
4
3
|
const uniqueElements = (item, index, all) => {
|
|
5
4
|
const props = JSON.stringify(item.props);
|
|
6
5
|
const children = item.children;
|
|
7
6
|
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
|
|
8
7
|
};
|
|
9
|
-
async function* renderExtraHead(result, base) {
|
|
10
|
-
yield base;
|
|
11
|
-
for (const part of result.extraHead) {
|
|
12
|
-
yield* renderChild(part);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
8
|
function renderAllHeadContent(result) {
|
|
9
|
+
result._metadata.hasRenderedHead = true;
|
|
16
10
|
const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement("style", style));
|
|
17
11
|
result.styles.clear();
|
|
18
12
|
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script, i) => {
|
|
19
13
|
return renderElement("script", script, false);
|
|
20
14
|
});
|
|
21
15
|
const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
|
|
22
|
-
|
|
16
|
+
let content = links.join("\n") + styles.join("\n") + scripts.join("\n");
|
|
23
17
|
if (result.extraHead.length > 0) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
for (const part of result.extraHead) {
|
|
19
|
+
content += part;
|
|
20
|
+
}
|
|
27
21
|
}
|
|
22
|
+
return markHTMLString(content);
|
|
28
23
|
}
|
|
29
|
-
function
|
|
30
|
-
result
|
|
31
|
-
return renderAllHeadContent.bind(null, result);
|
|
24
|
+
function* renderHead(result) {
|
|
25
|
+
yield { type: "head", result };
|
|
32
26
|
}
|
|
33
|
-
|
|
34
|
-
async function* maybeRenderHead(result) {
|
|
27
|
+
function* maybeRenderHead(result) {
|
|
35
28
|
if (result._metadata.hasRenderedHead) {
|
|
36
29
|
return;
|
|
37
30
|
}
|
|
38
|
-
yield
|
|
31
|
+
yield { type: "head", result };
|
|
39
32
|
}
|
|
40
33
|
export {
|
|
41
|
-
createRenderHead,
|
|
42
34
|
maybeRenderHead,
|
|
35
|
+
renderAllHeadContent,
|
|
43
36
|
renderHead
|
|
44
37
|
};
|
|
@@ -6,6 +6,6 @@ export { renderHTMLElement } from './dom.js';
|
|
|
6
6
|
export { maybeRenderHead, renderHead } from './head.js';
|
|
7
7
|
export { renderPage } from './page.js';
|
|
8
8
|
export { renderSlot } from './slot.js';
|
|
9
|
-
export { renderStyleElement, renderUniqueStylesheet } from './tags.js';
|
|
9
|
+
export { renderScriptElement, renderStyleElement, renderUniqueStylesheet } from './tags.js';
|
|
10
10
|
export type { RenderInstruction } from './types';
|
|
11
11
|
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
|
|
@@ -10,7 +10,7 @@ import { renderHTMLElement } from "./dom.js";
|
|
|
10
10
|
import { maybeRenderHead, renderHead } from "./head.js";
|
|
11
11
|
import { renderPage } from "./page.js";
|
|
12
12
|
import { renderSlot } from "./slot.js";
|
|
13
|
-
import { renderStyleElement, renderUniqueStylesheet } from "./tags.js";
|
|
13
|
+
import { renderScriptElement, renderStyleElement, renderUniqueStylesheet } from "./tags.js";
|
|
14
14
|
import { addAttribute, defineScriptVars, voidElementNames } from "./util.js";
|
|
15
15
|
export {
|
|
16
16
|
Fragment,
|
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
renderHTMLElement,
|
|
26
26
|
renderHead,
|
|
27
27
|
renderPage,
|
|
28
|
+
renderScriptElement,
|
|
28
29
|
renderSlot,
|
|
29
30
|
renderStyleElement,
|
|
30
31
|
renderTemplate,
|
|
@@ -18,7 +18,7 @@ async function renderSlot(_result, slotted, fallback) {
|
|
|
18
18
|
let content = "";
|
|
19
19
|
let instructions = null;
|
|
20
20
|
for await (const chunk of iterator) {
|
|
21
|
-
if (chunk.type === "
|
|
21
|
+
if (typeof chunk.type === "string") {
|
|
22
22
|
if (instructions === null) {
|
|
23
23
|
instructions = [];
|
|
24
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SSRResult } from '../../../@types/astro';
|
|
1
|
+
import { SSRElement, SSRResult } from '../../../@types/astro';
|
|
2
2
|
export declare function renderStyleElement(children: string): string;
|
|
3
|
+
export declare function renderScriptElement({ props, children }: SSRElement): string;
|
|
3
4
|
export declare function renderStylesheet({ href }: {
|
|
4
5
|
href: string;
|
|
5
6
|
}): string;
|
|
@@ -6,6 +6,12 @@ function renderStyleElement(children) {
|
|
|
6
6
|
children
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
+
function renderScriptElement({ props, children }) {
|
|
10
|
+
return renderElement("script", {
|
|
11
|
+
props,
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
9
15
|
function renderStylesheet({ href }) {
|
|
10
16
|
return renderElement(
|
|
11
17
|
"link",
|
|
@@ -28,6 +34,7 @@ function renderUniqueStylesheet(result, link) {
|
|
|
28
34
|
return renderStylesheet(link);
|
|
29
35
|
}
|
|
30
36
|
export {
|
|
37
|
+
renderScriptElement,
|
|
31
38
|
renderStyleElement,
|
|
32
39
|
renderStylesheet,
|
|
33
40
|
renderUniqueStylesheet
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
2
|
import type { HydrationMetadata } from '../hydration.js';
|
|
3
|
-
export
|
|
3
|
+
export type RenderDirectiveInstruction = {
|
|
4
4
|
type: 'directive';
|
|
5
5
|
result: SSRResult;
|
|
6
6
|
hydration: HydrationMetadata;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type RenderHeadInstruction = {
|
|
9
|
+
type: 'head';
|
|
10
|
+
result: SSRResult;
|
|
11
|
+
};
|
|
12
|
+
export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction;
|
|
@@ -65,10 +65,15 @@ async function enhanceCompileError({
|
|
|
65
65
|
config,
|
|
66
66
|
logging
|
|
67
67
|
}) {
|
|
68
|
+
var _a;
|
|
69
|
+
const lineText = (_a = err.loc) == null ? void 0 : _a.lineText;
|
|
68
70
|
const scannedFrontmatter = FRONTMATTER_PARSE_REGEXP.exec(source);
|
|
69
71
|
if (scannedFrontmatter) {
|
|
72
|
+
const frontmatter = scannedFrontmatter[1].replace(/\breturn\b/g, "throw");
|
|
73
|
+
if (lineText && !frontmatter.includes(lineText))
|
|
74
|
+
throw err;
|
|
70
75
|
try {
|
|
71
|
-
await transformWithEsbuild(
|
|
76
|
+
await transformWithEsbuild(frontmatter, id, {
|
|
72
77
|
loader: "ts",
|
|
73
78
|
target: "esnext",
|
|
74
79
|
sourcemap: false
|
package/package.json
CHANGED
|
@@ -48,6 +48,10 @@ declare module 'astro:content' {
|
|
|
48
48
|
collection: C,
|
|
49
49
|
filter?: (entry: CollectionEntry<C>) => entry is E
|
|
50
50
|
): Promise<E[]>;
|
|
51
|
+
export function getCollection<C extends keyof typeof entryMap>(
|
|
52
|
+
collection: C,
|
|
53
|
+
filter?: (entry: CollectionEntry<C>) => unknown
|
|
54
|
+
): Promise<CollectionEntry<C>[]>;
|
|
51
55
|
|
|
52
56
|
type InferEntrySchema<C extends keyof typeof entryMap> = import('astro/zod').infer<
|
|
53
57
|
Required<ContentConfig['collections'][C]>['schema']
|
|
@@ -22,7 +22,7 @@ const collectionToEntryMap = createCollectionToGlobResultMap({
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const renderEntryGlob = import.meta.glob('@@RENDER_ENTRY_GLOB_PATH@@', {
|
|
25
|
-
query: {
|
|
25
|
+
query: { astroPropagatedAssets: true },
|
|
26
26
|
});
|
|
27
27
|
const collectionToRenderEntryMap = createCollectionToGlobResultMap({
|
|
28
28
|
globResult: renderEntryGlob,
|