astro 2.1.5 → 2.1.7
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 +7 -2
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.js +2 -0
- package/dist/assets/utils/emitAsset.d.ts +2 -1
- package/dist/assets/utils/emitAsset.js +18 -3
- package/dist/cli/index.js +7 -1
- package/dist/content/runtime-assets.js +3 -3
- package/dist/content/runtime.js +1 -8
- package/dist/content/utils.d.ts +2 -2
- package/dist/content/utils.js +27 -1
- package/dist/content/vite-plugin-content-imports.js +6 -2
- package/dist/core/app/common.js +2 -2
- package/dist/core/app/index.js +1 -1
- package/dist/core/app/node.d.ts +10 -3
- package/dist/core/app/node.js +15 -0
- package/dist/core/app/types.d.ts +4 -4
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/internal.d.ts +1 -1
- package/dist/core/build/internal.js +1 -1
- package/dist/core/build/plugins/index.js +2 -2
- package/dist/core/build/plugins/plugin-ssr.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +2 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/context.d.ts +1 -1
- package/dist/core/render/core.js +1 -1
- package/dist/core/render/dev/index.js +5 -5
- package/dist/core/render/dev/metadata.d.ts +3 -0
- package/dist/core/render/dev/metadata.js +36 -0
- package/dist/core/render/result.d.ts +1 -1
- package/dist/core/render/result.js +11 -14
- package/dist/jsx/babel.js +1 -0
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +0 -8
- package/dist/runtime/server/jsx.js +1 -3
- package/dist/runtime/server/render/astro/factory.js +3 -5
- package/dist/runtime/server/render/astro/instance.js +1 -3
- package/dist/runtime/server/render/common.js +1 -34
- package/dist/runtime/server/render/index.d.ts +0 -1
- package/dist/runtime/server/render/index.js +0 -5
- package/dist/runtime/server/render/page.js +12 -8
- package/dist/runtime/server/render/slot.js +1 -3
- package/dist/vite-plugin-astro/index.js +1 -0
- package/dist/vite-plugin-astro/types.d.ts +1 -0
- package/dist/vite-plugin-config-alias/index.d.ts +7 -2
- package/dist/vite-plugin-config-alias/index.js +41 -32
- package/dist/vite-plugin-head/index.d.ts +9 -0
- package/dist/vite-plugin-head/index.js +95 -0
- package/dist/vite-plugin-markdown/index.js +1 -0
- package/package.json +2 -2
- package/dist/core/render/dev/head.d.ts +0 -3
- package/dist/core/render/dev/head.js +0 -26
- package/dist/runtime/server/render/scope.d.ts +0 -14
- package/dist/runtime/server/render/scope.js +0 -40
- package/dist/vite-plugin-head-propagation/index.d.ts +0 -15
- package/dist/vite-plugin-head-propagation/index.js +0 -86
package/dist/@types/astro.d.ts
CHANGED
|
@@ -974,7 +974,7 @@ export interface ContentEntryType {
|
|
|
974
974
|
fileUrl: URL;
|
|
975
975
|
contents: string;
|
|
976
976
|
}): GetEntryInfoReturnType | Promise<GetEntryInfoReturnType>;
|
|
977
|
-
getRenderModule?(params: {
|
|
977
|
+
getRenderModule?(this: rollup.PluginContext, params: {
|
|
978
978
|
entry: ContentEntryModule;
|
|
979
979
|
}): rollup.LoadResult | Promise<rollup.LoadResult>;
|
|
980
980
|
contentModuleTypes?: string;
|
|
@@ -1422,6 +1422,7 @@ export interface SSRMetadata {
|
|
|
1422
1422
|
hasHydrationScript: boolean;
|
|
1423
1423
|
hasDirectives: Set<string>;
|
|
1424
1424
|
hasRenderedHead: boolean;
|
|
1425
|
+
headInTree: boolean;
|
|
1425
1426
|
}
|
|
1426
1427
|
/**
|
|
1427
1428
|
* A hint on whether the Astro runtime needs to wait on a component to render head
|
|
@@ -1434,11 +1435,15 @@ export interface SSRMetadata {
|
|
|
1434
1435
|
* These are used within the runtime to know whether or not a component should be waited on.
|
|
1435
1436
|
*/
|
|
1436
1437
|
export type PropagationHint = 'none' | 'self' | 'in-tree';
|
|
1438
|
+
export type SSRComponentMetadata = {
|
|
1439
|
+
propagation: PropagationHint;
|
|
1440
|
+
containsHead: boolean;
|
|
1441
|
+
};
|
|
1437
1442
|
export interface SSRResult {
|
|
1438
1443
|
styles: Set<SSRElement>;
|
|
1439
1444
|
scripts: Set<SSRElement>;
|
|
1440
1445
|
links: Set<SSRElement>;
|
|
1441
|
-
|
|
1446
|
+
componentMetadata: Map<string, SSRComponentMetadata>;
|
|
1442
1447
|
propagators: Map<AstroComponentFactory, AstroComponentInstance>;
|
|
1443
1448
|
extraHead: Array<string>;
|
|
1444
1449
|
cookies: AstroCookies | undefined;
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getConfiguredImageService, getImage } from './internal.js';
|
|
2
2
|
export { baseService } from './services/service.js';
|
|
3
3
|
export { type LocalImageProps, type RemoteImageProps } from './types.js';
|
|
4
|
+
export { emitESMImage } from './utils/emitAsset.js';
|
|
4
5
|
export { imageMetadata } from './utils/metadata.js';
|
package/dist/assets/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { getConfiguredImageService, getImage } from "./internal.js";
|
|
2
2
|
import { baseService } from "./services/service.js";
|
|
3
3
|
import {} from "./types.js";
|
|
4
|
+
import { emitESMImage } from "./utils/emitAsset.js";
|
|
4
5
|
import { imageMetadata } from "./utils/metadata.js";
|
|
5
6
|
export {
|
|
6
7
|
baseService,
|
|
8
|
+
emitESMImage,
|
|
7
9
|
getConfiguredImageService,
|
|
8
10
|
getImage,
|
|
9
11
|
imageMetadata
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { AstroSettings } from '../../@types/astro';
|
|
2
|
-
export declare function emitESMImage(id: string, watchMode: boolean, fileEmitter: any, settings: AstroSettings): Promise<import("./metadata.js").Metadata | undefined>;
|
|
2
|
+
export declare function emitESMImage(id: string, watchMode: boolean, fileEmitter: any, settings: Pick<AstroSettings, 'config'>): Promise<import("./metadata.js").Metadata | undefined>;
|
|
3
|
+
export declare function emoji(char: string, fallback: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
4
|
-
import
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import slash from "slash";
|
|
5
5
|
import { imageMetadata } from "./metadata.js";
|
|
6
6
|
async function emitESMImage(id, watchMode, fileEmitter, settings) {
|
|
7
7
|
const url = pathToFileURL(id);
|
|
@@ -26,6 +26,21 @@ async function emitESMImage(id, watchMode, fileEmitter, settings) {
|
|
|
26
26
|
}
|
|
27
27
|
return meta;
|
|
28
28
|
}
|
|
29
|
+
function rootRelativePath(config, url) {
|
|
30
|
+
const basePath = fileURLToNormalizedPath(url);
|
|
31
|
+
const rootPath = fileURLToNormalizedPath(config.root);
|
|
32
|
+
return prependForwardSlash(basePath.slice(rootPath.length));
|
|
33
|
+
}
|
|
34
|
+
function prependForwardSlash(filePath) {
|
|
35
|
+
return filePath[0] === "/" ? filePath : "/" + filePath;
|
|
36
|
+
}
|
|
37
|
+
function fileURLToNormalizedPath(filePath) {
|
|
38
|
+
return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
|
|
39
|
+
}
|
|
40
|
+
function emoji(char, fallback) {
|
|
41
|
+
return process.platform !== "win32" ? char : fallback;
|
|
42
|
+
}
|
|
29
43
|
export {
|
|
30
|
-
emitESMImage
|
|
44
|
+
emitESMImage,
|
|
45
|
+
emoji
|
|
31
46
|
};
|
package/dist/cli/index.js
CHANGED
|
@@ -165,7 +165,13 @@ async function runCommand(cmd, flags) {
|
|
|
165
165
|
}
|
|
166
166
|
case "build": {
|
|
167
167
|
const { default: build } = await import("../core/build/index.js");
|
|
168
|
-
return await build(settings, {
|
|
168
|
+
return await build(settings, {
|
|
169
|
+
flags,
|
|
170
|
+
logging,
|
|
171
|
+
telemetry,
|
|
172
|
+
teardownCompiler: true,
|
|
173
|
+
mode: flags.mode
|
|
174
|
+
});
|
|
169
175
|
}
|
|
170
176
|
case "check": {
|
|
171
177
|
const checkServer = await check(settings, { flags, logging });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pathToFileURL } from "url";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { imageMetadata } from "../assets/utils/metadata.js";
|
|
3
4
|
function createImage(options) {
|
|
@@ -5,9 +6,8 @@ function createImage(options) {
|
|
|
5
6
|
if (options.assetsDir === "undefined") {
|
|
6
7
|
throw new Error("Enable `experimental.assets` in your Astro config to use image()");
|
|
7
8
|
}
|
|
8
|
-
return z.string().transform(async (imagePath) => {
|
|
9
|
-
|
|
10
|
-
return await getImageMetadata(fullPath);
|
|
9
|
+
return z.string({ description: "__image" }).transform(async (imagePath) => {
|
|
10
|
+
return await getImageMetadata(pathToFileURL(imagePath));
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
}
|
package/dist/content/runtime.js
CHANGED
|
@@ -3,7 +3,6 @@ import { prependForwardSlash } from "../core/path.js";
|
|
|
3
3
|
import {
|
|
4
4
|
createComponent,
|
|
5
5
|
createHeadAndContent,
|
|
6
|
-
createScopedResult,
|
|
7
6
|
renderComponent,
|
|
8
7
|
renderScriptElement,
|
|
9
8
|
renderStyleElement,
|
|
@@ -147,13 +146,7 @@ async function render({
|
|
|
147
146
|
}
|
|
148
147
|
return createHeadAndContent(
|
|
149
148
|
unescapeHTML(styles + links + scripts),
|
|
150
|
-
renderTemplate`${renderComponent(
|
|
151
|
-
createScopedResult(result),
|
|
152
|
-
"Content",
|
|
153
|
-
mod.Content,
|
|
154
|
-
props,
|
|
155
|
-
slots
|
|
156
|
-
)}`
|
|
149
|
+
renderTemplate`${renderComponent(result, "Content", mod.Content, props, slots)}`
|
|
157
150
|
);
|
|
158
151
|
},
|
|
159
152
|
propagation: "self"
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import matter from 'gray-matter';
|
|
3
3
|
import fsMod from 'node:fs';
|
|
4
|
-
import type { EmitFile } from 'rollup';
|
|
4
|
+
import type { EmitFile, PluginContext } from 'rollup';
|
|
5
5
|
import { type ViteDevServer } from 'vite';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import type { AstroConfig, AstroSettings } from '../@types/astro.js';
|
|
@@ -57,7 +57,7 @@ export declare function getEntrySlug({ id, collection, slug, unvalidatedSlug, }:
|
|
|
57
57
|
export declare function getEntryData(entry: EntryInfo & {
|
|
58
58
|
unvalidatedData: Record<string, unknown>;
|
|
59
59
|
_internal: EntryInternal;
|
|
60
|
-
}, collectionConfig: CollectionConfig): Promise<{
|
|
60
|
+
}, collectionConfig: CollectionConfig, resolver: (idToResolve: string) => ReturnType<PluginContext['resolve']>): Promise<{
|
|
61
61
|
[x: string]: unknown;
|
|
62
62
|
}>;
|
|
63
63
|
export declare function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>): string[];
|
package/dist/content/utils.js
CHANGED
|
@@ -56,7 +56,7 @@ function getEntrySlug({
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
async function getEntryData(entry, collectionConfig) {
|
|
59
|
+
async function getEntryData(entry, collectionConfig, resolver) {
|
|
60
60
|
let { slug, ...data } = entry.unvalidatedData;
|
|
61
61
|
if (collectionConfig.schema) {
|
|
62
62
|
if (typeof collectionConfig.schema === "object" && !("safeParseAsync" in collectionConfig.schema)) {
|
|
@@ -73,6 +73,32 @@ async function getEntryData(entry, collectionConfig) {
|
|
|
73
73
|
message: AstroErrorData.ContentSchemaContainsSlugError.message(entry.collection)
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
async function preprocessAssetPaths(object) {
|
|
77
|
+
if (typeof object !== "object" || object === null)
|
|
78
|
+
return;
|
|
79
|
+
for (let [schemaName, schema] of Object.entries(object)) {
|
|
80
|
+
if (schema._def.description === "__image") {
|
|
81
|
+
object[schemaName] = z.preprocess(
|
|
82
|
+
async (value) => {
|
|
83
|
+
var _a;
|
|
84
|
+
if (!value || typeof value !== "string")
|
|
85
|
+
return value;
|
|
86
|
+
return (_a = await resolver(value)) == null ? void 0 : _a.id;
|
|
87
|
+
},
|
|
88
|
+
schema,
|
|
89
|
+
{ description: void 0 }
|
|
90
|
+
);
|
|
91
|
+
} else if ("shape" in schema) {
|
|
92
|
+
await preprocessAssetPaths(schema.shape);
|
|
93
|
+
} else if ("unwrap" in schema) {
|
|
94
|
+
const unwrapped = schema.unwrap().shape;
|
|
95
|
+
if (unwrapped) {
|
|
96
|
+
await preprocessAssetPaths(unwrapped);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
await preprocessAssetPaths(collectionConfig.schema.shape);
|
|
76
102
|
const parsed = await collectionConfig.schema.safeParseAsync(entry.unvalidatedData, {
|
|
77
103
|
errorMap
|
|
78
104
|
});
|
|
@@ -106,7 +106,7 @@ export const _internal = {
|
|
|
106
106
|
)}. Did you import this module directly without using a content collection query?`
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
return contentRenderer({ entry });
|
|
109
|
+
return contentRenderer.bind(this)({ entry });
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -161,7 +161,11 @@ export const _internal = {
|
|
|
161
161
|
const _internal = { filePath: fileId, rawData };
|
|
162
162
|
const slug = getEntrySlug({ id, collection, slug: generatedSlug, unvalidatedSlug });
|
|
163
163
|
const collectionConfig = contentConfig == null ? void 0 : contentConfig.collections[collection];
|
|
164
|
-
let data = collectionConfig ? await getEntryData(
|
|
164
|
+
let data = collectionConfig ? await getEntryData(
|
|
165
|
+
{ id, collection, slug, _internal, unvalidatedData },
|
|
166
|
+
collectionConfig,
|
|
167
|
+
(idToResolve) => pluginContext.resolve(idToResolve, fileId)
|
|
168
|
+
) : unvalidatedData;
|
|
165
169
|
await patchAssets(data, pluginContext.meta.watchMode, pluginContext.emitFile, settings);
|
|
166
170
|
const contentEntryModule = {
|
|
167
171
|
id,
|
package/dist/core/app/common.js
CHANGED
|
@@ -10,11 +10,11 @@ function deserializeManifest(serializedManifest) {
|
|
|
10
10
|
route.routeData = deserializeRouteData(serializedRoute.routeData);
|
|
11
11
|
}
|
|
12
12
|
const assets = new Set(serializedManifest.assets);
|
|
13
|
-
const
|
|
13
|
+
const componentMetadata = new Map(serializedManifest.componentMetadata);
|
|
14
14
|
return {
|
|
15
15
|
...serializedManifest,
|
|
16
16
|
assets,
|
|
17
|
-
|
|
17
|
+
componentMetadata,
|
|
18
18
|
routes
|
|
19
19
|
};
|
|
20
20
|
}
|
package/dist/core/app/index.js
CHANGED
package/dist/core/app/node.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { RouteData } from '../../@types/astro';
|
|
3
3
|
import type { SSRManifest } from './types';
|
|
4
|
-
import
|
|
4
|
+
import { IncomingMessage } from 'http';
|
|
5
5
|
import { App, type MatchOptions } from './index.js';
|
|
6
|
+
declare class NodeIncomingMessage extends IncomingMessage {
|
|
7
|
+
/**
|
|
8
|
+
* The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request.
|
|
9
|
+
*/
|
|
10
|
+
body?: any | undefined;
|
|
11
|
+
}
|
|
6
12
|
export declare class NodeApp extends App {
|
|
7
|
-
match(req:
|
|
8
|
-
render(req:
|
|
13
|
+
match(req: NodeIncomingMessage | Request, opts?: MatchOptions): RouteData | undefined;
|
|
14
|
+
render(req: NodeIncomingMessage | Request, routeData?: RouteData): Promise<Response>;
|
|
9
15
|
}
|
|
10
16
|
export declare function loadManifest(rootFolder: URL): Promise<SSRManifest>;
|
|
11
17
|
export declare function loadApp(rootFolder: URL): Promise<NodeApp>;
|
|
18
|
+
export {};
|
package/dist/core/app/node.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
|
+
import { IncomingMessage } from "http";
|
|
2
3
|
import { TLSSocket } from "tls";
|
|
3
4
|
import { deserializeManifest } from "./common.js";
|
|
4
5
|
import { App } from "./index.js";
|
|
@@ -20,11 +21,25 @@ function createRequestFromNodeRequest(req, body) {
|
|
|
20
21
|
}
|
|
21
22
|
return request;
|
|
22
23
|
}
|
|
24
|
+
class NodeIncomingMessage extends IncomingMessage {
|
|
25
|
+
}
|
|
23
26
|
class NodeApp extends App {
|
|
24
27
|
match(req, opts = {}) {
|
|
25
28
|
return super.match(req instanceof Request ? req : createRequestFromNodeRequest(req), opts);
|
|
26
29
|
}
|
|
27
30
|
render(req, routeData) {
|
|
31
|
+
if (typeof req.body === "string" && req.body.length > 0) {
|
|
32
|
+
return super.render(
|
|
33
|
+
req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(req.body)),
|
|
34
|
+
routeData
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (typeof req.body === "object" && Object.keys(req.body).length > 0) {
|
|
38
|
+
return super.render(
|
|
39
|
+
req instanceof Request ? req : createRequestFromNodeRequest(req, Buffer.from(JSON.stringify(req.body))),
|
|
40
|
+
routeData
|
|
41
|
+
);
|
|
42
|
+
}
|
|
28
43
|
if ("on" in req) {
|
|
29
44
|
let body = Buffer.from([]);
|
|
30
45
|
let reqBodyComplete = new Promise((resolve, reject) => {
|
package/dist/core/app/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
|
|
2
|
-
import type { ComponentInstance,
|
|
2
|
+
import type { ComponentInstance, RouteData, SerializedRouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
|
3
3
|
export type ComponentPath = string;
|
|
4
4
|
export interface RouteInfo {
|
|
5
5
|
routeData: RouteData;
|
|
@@ -26,11 +26,11 @@ export interface SSRManifest {
|
|
|
26
26
|
renderers: SSRLoadedRenderer[];
|
|
27
27
|
entryModules: Record<string, string>;
|
|
28
28
|
assets: Set<string>;
|
|
29
|
-
|
|
29
|
+
componentMetadata: SSRResult['componentMetadata'];
|
|
30
30
|
}
|
|
31
|
-
export type SerializedSSRManifest = Omit<SSRManifest, 'routes' | 'assets' | '
|
|
31
|
+
export type SerializedSSRManifest = Omit<SSRManifest, 'routes' | 'assets' | 'componentMetadata'> & {
|
|
32
32
|
routes: SerializedRouteInfo[];
|
|
33
33
|
assets: string[];
|
|
34
|
-
|
|
34
|
+
componentMetadata: [string, SSRComponentMetadata][];
|
|
35
35
|
};
|
|
36
36
|
export type AdapterCreateExports<T = any> = (manifest: SSRManifest, args?: T) => Record<string, any>;
|
|
@@ -291,7 +291,7 @@ async function generatePath(pathname, opts, gopts) {
|
|
|
291
291
|
origin,
|
|
292
292
|
pathname,
|
|
293
293
|
request: createRequest({ url, headers: new Headers(), logging, ssr }),
|
|
294
|
-
|
|
294
|
+
componentMetadata: internals.componentMetadata,
|
|
295
295
|
scripts,
|
|
296
296
|
links,
|
|
297
297
|
route: pageData.route
|
|
@@ -58,7 +58,7 @@ export interface BuildInternals {
|
|
|
58
58
|
discoveredScripts: Set<string>;
|
|
59
59
|
staticFiles: Set<string>;
|
|
60
60
|
ssrEntryChunk?: OutputChunk;
|
|
61
|
-
|
|
61
|
+
componentMetadata: SSRResult['componentMetadata'];
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Creates internal maps used to coordinate the CSS and HTML plugins.
|
|
@@ -17,7 +17,7 @@ function createBuildInternals() {
|
|
|
17
17
|
discoveredClientOnlyComponents: /* @__PURE__ */ new Map(),
|
|
18
18
|
discoveredScripts: /* @__PURE__ */ new Set(),
|
|
19
19
|
staticFiles: /* @__PURE__ */ new Set(),
|
|
20
|
-
|
|
20
|
+
componentMetadata: /* @__PURE__ */ new Map()
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
function trackPageData(internals, component, pageData, componentModuleId, componentURL) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { astroConfigBuildPlugin } from "../../../content/vite-plugin-content-assets.js";
|
|
2
|
-
import {
|
|
2
|
+
import { astroHeadBuildPlugin } from "../../../vite-plugin-head/index.js";
|
|
3
3
|
import { pluginAliasResolve } from "./plugin-alias-resolve.js";
|
|
4
4
|
import { pluginAnalyzer } from "./plugin-analyzer.js";
|
|
5
5
|
import { pluginComponentEntry } from "./plugin-component-entry.js";
|
|
@@ -16,7 +16,7 @@ function registerAllPlugins({ internals, options, register }) {
|
|
|
16
16
|
register(pluginInternals(internals));
|
|
17
17
|
register(pluginPages(options, internals));
|
|
18
18
|
register(pluginCSS(options, internals));
|
|
19
|
-
register(
|
|
19
|
+
register(astroHeadBuildPlugin(options, internals));
|
|
20
20
|
register(pluginPrerender(options, internals));
|
|
21
21
|
register(astroConfigBuildPlugin(options, internals));
|
|
22
22
|
register(pluginHoistedScripts(options, internals));
|
|
@@ -168,7 +168,7 @@ function buildManifest(opts, internals, staticFiles) {
|
|
|
168
168
|
base: settings.config.base,
|
|
169
169
|
markdown: settings.config.markdown,
|
|
170
170
|
pageMap: null,
|
|
171
|
-
|
|
171
|
+
componentMetadata: Array.from(internals.componentMetadata),
|
|
172
172
|
renderers: [],
|
|
173
173
|
entryModules,
|
|
174
174
|
assets: staticFiles.map((s) => settings.config.base + s)
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -13,7 +13,7 @@ import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
|
13
13
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
14
14
|
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
|
15
15
|
import envVitePlugin from "../vite-plugin-env/index.js";
|
|
16
|
-
import
|
|
16
|
+
import astroHeadPlugin from "../vite-plugin-head/index.js";
|
|
17
17
|
import htmlVitePlugin from "../vite-plugin-html/index.js";
|
|
18
18
|
import { astroInjectEnvTsPlugin } from "../vite-plugin-inject-env-ts/index.js";
|
|
19
19
|
import astroIntegrationsContainerPlugin from "../vite-plugin-integrations-container/index.js";
|
|
@@ -95,7 +95,7 @@ async function createVite(commandConfig, { settings, logging, mode, command, fs
|
|
|
95
95
|
astroPostprocessVitePlugin({ settings }),
|
|
96
96
|
astroIntegrationsContainerPlugin({ settings, logging }),
|
|
97
97
|
astroScriptsPageSSRPlugin({ settings }),
|
|
98
|
-
|
|
98
|
+
astroHeadPlugin({ settings }),
|
|
99
99
|
astroScannerPlugin({ settings }),
|
|
100
100
|
astroInjectEnvTsPlugin({ settings, logging, fs }),
|
|
101
101
|
astroContentVirtualModPlugin({ settings }),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -52,7 +52,7 @@ async function dev(settings, options) {
|
|
|
52
52
|
isRestart: options.isRestart
|
|
53
53
|
})
|
|
54
54
|
);
|
|
55
|
-
const currentVersion = "2.1.
|
|
55
|
+
const currentVersion = "2.1.7";
|
|
56
56
|
if (currentVersion.includes("-")) {
|
|
57
57
|
warn(options.logging, null, msg.prerelease({ currentVersion }));
|
|
58
58
|
}
|
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.1.
|
|
50
|
+
const version = "2.1.7";
|
|
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.1.
|
|
236
|
+
`v${"2.1.7"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -10,7 +10,7 @@ export interface RenderContext {
|
|
|
10
10
|
scripts?: Set<SSRElement>;
|
|
11
11
|
links?: Set<SSRElement>;
|
|
12
12
|
styles?: Set<SSRElement>;
|
|
13
|
-
|
|
13
|
+
componentMetadata?: SSRResult['componentMetadata'];
|
|
14
14
|
route?: RouteData;
|
|
15
15
|
status?: number;
|
|
16
16
|
}
|
package/dist/core/render/core.js
CHANGED
|
@@ -6,7 +6,7 @@ import { isPage, resolveIdToUrl, viteID } from "../../util.js";
|
|
|
6
6
|
import { createRenderContext, renderPage as coreRenderPage } from "../index.js";
|
|
7
7
|
import { filterFoundRenderers, loadRenderer } from "../renderer.js";
|
|
8
8
|
import { getStylesForURL } from "./css.js";
|
|
9
|
-
import {
|
|
9
|
+
import { getComponentMetadata } from "./metadata.js";
|
|
10
10
|
import { getScriptsForURL } from "./scripts.js";
|
|
11
11
|
import { createDevelopmentEnvironment } from "./environment.js";
|
|
12
12
|
async function loadRenderers(moduleLoader, settings) {
|
|
@@ -86,13 +86,13 @@ async function getScriptsAndStyles({ env, filePath }) {
|
|
|
86
86
|
children: content
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
|
-
const
|
|
90
|
-
return { scripts, styles, links,
|
|
89
|
+
const metadata = await getComponentMetadata(filePath, env.loader);
|
|
90
|
+
return { scripts, styles, links, metadata };
|
|
91
91
|
}
|
|
92
92
|
async function renderPage(options) {
|
|
93
93
|
const [renderers, mod] = options.preload;
|
|
94
94
|
options.env.renderers = renderers;
|
|
95
|
-
const { scripts, links, styles,
|
|
95
|
+
const { scripts, links, styles, metadata } = await getScriptsAndStyles({
|
|
96
96
|
env: options.env,
|
|
97
97
|
filePath: options.filePath
|
|
98
98
|
});
|
|
@@ -103,7 +103,7 @@ async function renderPage(options) {
|
|
|
103
103
|
scripts,
|
|
104
104
|
links,
|
|
105
105
|
styles,
|
|
106
|
-
|
|
106
|
+
componentMetadata: metadata,
|
|
107
107
|
route: options.route
|
|
108
108
|
});
|
|
109
109
|
return await coreRenderPage(mod, ctx, options.env);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getAstroMetadata } from "../../../vite-plugin-astro/index.js";
|
|
2
|
+
import { viteID } from "../../util.js";
|
|
3
|
+
import { crawlGraph } from "./vite.js";
|
|
4
|
+
async function getComponentMetadata(filePath, loader) {
|
|
5
|
+
const map = /* @__PURE__ */ new Map();
|
|
6
|
+
const rootID = viteID(filePath);
|
|
7
|
+
addMetadata(map, loader.getModuleInfo(rootID));
|
|
8
|
+
for await (const moduleNode of crawlGraph(loader, rootID, true)) {
|
|
9
|
+
const id = moduleNode.id;
|
|
10
|
+
if (id) {
|
|
11
|
+
addMetadata(map, loader.getModuleInfo(id));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return map;
|
|
15
|
+
}
|
|
16
|
+
function addMetadata(map, modInfo) {
|
|
17
|
+
if (modInfo) {
|
|
18
|
+
const astro = getAstroMetadata(modInfo);
|
|
19
|
+
if (astro) {
|
|
20
|
+
let metadata = {
|
|
21
|
+
containsHead: false,
|
|
22
|
+
propagation: "none"
|
|
23
|
+
};
|
|
24
|
+
if (astro.propagation) {
|
|
25
|
+
metadata.propagation = astro.propagation;
|
|
26
|
+
}
|
|
27
|
+
if (astro.containsHead) {
|
|
28
|
+
metadata.containsHead = astro.containsHead;
|
|
29
|
+
}
|
|
30
|
+
map.set(modInfo.id, metadata);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
getComponentMetadata
|
|
36
|
+
};
|
|
@@ -17,7 +17,7 @@ export interface CreateResultArgs {
|
|
|
17
17
|
links?: Set<SSRElement>;
|
|
18
18
|
scripts?: Set<SSRElement>;
|
|
19
19
|
styles?: Set<SSRElement>;
|
|
20
|
-
|
|
20
|
+
componentMetadata?: SSRResult['componentMetadata'];
|
|
21
21
|
request: Request;
|
|
22
22
|
status: number;
|
|
23
23
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createScopedResult,
|
|
3
|
-
renderSlot,
|
|
4
|
-
ScopeFlags,
|
|
5
|
-
stringifyChunk
|
|
6
|
-
} from "../../runtime/server/index.js";
|
|
1
|
+
import { renderSlot, stringifyChunk } from "../../runtime/server/index.js";
|
|
7
2
|
import { renderJSX } from "../../runtime/server/jsx.js";
|
|
8
3
|
import { AstroCookies } from "../cookies/index.js";
|
|
9
4
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
@@ -58,7 +53,7 @@ class Slots {
|
|
|
58
53
|
async render(name, args = []) {
|
|
59
54
|
if (!this.#slots || !this.has(name))
|
|
60
55
|
return;
|
|
61
|
-
const
|
|
56
|
+
const result = this.#result;
|
|
62
57
|
if (!Array.isArray(args)) {
|
|
63
58
|
warn(
|
|
64
59
|
this.#loggingOpts,
|
|
@@ -67,20 +62,20 @@ class Slots {
|
|
|
67
62
|
);
|
|
68
63
|
} else if (args.length > 0) {
|
|
69
64
|
const slotValue = this.#slots[name];
|
|
70
|
-
const component = typeof slotValue === "function" ? await slotValue(
|
|
65
|
+
const component = typeof slotValue === "function" ? await slotValue(result) : await slotValue;
|
|
71
66
|
const expression = getFunctionExpression(component);
|
|
72
67
|
if (expression) {
|
|
73
68
|
const slot = () => expression(...args);
|
|
74
|
-
return await renderSlot(
|
|
69
|
+
return await renderSlot(result, slot).then((res) => res != null ? String(res) : res);
|
|
75
70
|
}
|
|
76
71
|
if (typeof component === "function") {
|
|
77
|
-
return await renderJSX(
|
|
72
|
+
return await renderJSX(result, component(...args)).then(
|
|
78
73
|
(res) => res != null ? String(res) : res
|
|
79
74
|
);
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
|
-
const content = await renderSlot(
|
|
83
|
-
const outHTML = stringifyChunk(
|
|
77
|
+
const content = await renderSlot(result, this.#slots[name]);
|
|
78
|
+
const outHTML = stringifyChunk(result, content);
|
|
84
79
|
return outHTML;
|
|
85
80
|
}
|
|
86
81
|
}
|
|
@@ -101,11 +96,12 @@ function createResult(args) {
|
|
|
101
96
|
writable: false
|
|
102
97
|
});
|
|
103
98
|
let cookies = void 0;
|
|
99
|
+
let componentMetadata = args.componentMetadata ?? /* @__PURE__ */ new Map();
|
|
104
100
|
const result = {
|
|
105
101
|
styles: args.styles ?? /* @__PURE__ */ new Set(),
|
|
106
102
|
scripts: args.scripts ?? /* @__PURE__ */ new Set(),
|
|
107
103
|
links: args.links ?? /* @__PURE__ */ new Set(),
|
|
108
|
-
|
|
104
|
+
componentMetadata,
|
|
109
105
|
propagators: /* @__PURE__ */ new Map(),
|
|
110
106
|
extraHead: [],
|
|
111
107
|
scope: 0,
|
|
@@ -178,7 +174,8 @@ function createResult(args) {
|
|
|
178
174
|
pathname,
|
|
179
175
|
hasHydrationScript: false,
|
|
180
176
|
hasRenderedHead: false,
|
|
181
|
-
hasDirectives: /* @__PURE__ */ new Set()
|
|
177
|
+
hasDirectives: /* @__PURE__ */ new Set(),
|
|
178
|
+
headInTree: false
|
|
182
179
|
},
|
|
183
180
|
response
|
|
184
181
|
};
|
package/dist/jsx/babel.js
CHANGED
|
@@ -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,
|
|
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, ComponentSlots, 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) */
|