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.
Files changed (57) hide show
  1. package/dist/@types/astro.d.ts +7 -2
  2. package/dist/assets/index.d.ts +1 -0
  3. package/dist/assets/index.js +2 -0
  4. package/dist/assets/utils/emitAsset.d.ts +2 -1
  5. package/dist/assets/utils/emitAsset.js +18 -3
  6. package/dist/cli/index.js +7 -1
  7. package/dist/content/runtime-assets.js +3 -3
  8. package/dist/content/runtime.js +1 -8
  9. package/dist/content/utils.d.ts +2 -2
  10. package/dist/content/utils.js +27 -1
  11. package/dist/content/vite-plugin-content-imports.js +6 -2
  12. package/dist/core/app/common.js +2 -2
  13. package/dist/core/app/index.js +1 -1
  14. package/dist/core/app/node.d.ts +10 -3
  15. package/dist/core/app/node.js +15 -0
  16. package/dist/core/app/types.d.ts +4 -4
  17. package/dist/core/build/generate.js +1 -1
  18. package/dist/core/build/internal.d.ts +1 -1
  19. package/dist/core/build/internal.js +1 -1
  20. package/dist/core/build/plugins/index.js +2 -2
  21. package/dist/core/build/plugins/plugin-ssr.js +1 -1
  22. package/dist/core/constants.js +1 -1
  23. package/dist/core/create-vite.js +2 -2
  24. package/dist/core/dev/dev.js +1 -1
  25. package/dist/core/messages.js +2 -2
  26. package/dist/core/render/context.d.ts +1 -1
  27. package/dist/core/render/core.js +1 -1
  28. package/dist/core/render/dev/index.js +5 -5
  29. package/dist/core/render/dev/metadata.d.ts +3 -0
  30. package/dist/core/render/dev/metadata.js +36 -0
  31. package/dist/core/render/result.d.ts +1 -1
  32. package/dist/core/render/result.js +11 -14
  33. package/dist/jsx/babel.js +1 -0
  34. package/dist/runtime/server/index.d.ts +1 -1
  35. package/dist/runtime/server/index.js +0 -8
  36. package/dist/runtime/server/jsx.js +1 -3
  37. package/dist/runtime/server/render/astro/factory.js +3 -5
  38. package/dist/runtime/server/render/astro/instance.js +1 -3
  39. package/dist/runtime/server/render/common.js +1 -34
  40. package/dist/runtime/server/render/index.d.ts +0 -1
  41. package/dist/runtime/server/render/index.js +0 -5
  42. package/dist/runtime/server/render/page.js +12 -8
  43. package/dist/runtime/server/render/slot.js +1 -3
  44. package/dist/vite-plugin-astro/index.js +1 -0
  45. package/dist/vite-plugin-astro/types.d.ts +1 -0
  46. package/dist/vite-plugin-config-alias/index.d.ts +7 -2
  47. package/dist/vite-plugin-config-alias/index.js +41 -32
  48. package/dist/vite-plugin-head/index.d.ts +9 -0
  49. package/dist/vite-plugin-head/index.js +95 -0
  50. package/dist/vite-plugin-markdown/index.js +1 -0
  51. package/package.json +2 -2
  52. package/dist/core/render/dev/head.d.ts +0 -3
  53. package/dist/core/render/dev/head.js +0 -26
  54. package/dist/runtime/server/render/scope.d.ts +0 -14
  55. package/dist/runtime/server/render/scope.js +0 -40
  56. package/dist/vite-plugin-head-propagation/index.d.ts +0 -15
  57. package/dist/vite-plugin-head-propagation/index.js +0 -86
@@ -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
- propagation: Map<string, PropagationHint>;
1446
+ componentMetadata: Map<string, SSRComponentMetadata>;
1442
1447
  propagators: Map<AstroComponentFactory, AstroComponentInstance>;
1443
1448
  extraHead: Array<string>;
1444
1449
  cookies: AstroCookies | undefined;
@@ -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';
@@ -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 { rootRelativePath } from "../../core/util.js";
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, { flags, logging, telemetry, teardownCompiler: true });
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
- const fullPath = new URL(imagePath, options.assetsDir);
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
  }
@@ -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"
@@ -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[];
@@ -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({ id, collection, slug, _internal, unvalidatedData }, collectionConfig) : unvalidatedData;
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,
@@ -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 propagation = new Map(serializedManifest.propagation);
13
+ const componentMetadata = new Map(serializedManifest.componentMetadata);
14
14
  return {
15
15
  ...serializedManifest,
16
16
  assets,
17
- propagation,
17
+ componentMetadata,
18
18
  routes
19
19
  };
20
20
  }
@@ -161,7 +161,7 @@ class App {
161
161
  request,
162
162
  origin: url.origin,
163
163
  pathname,
164
- propagation: this.#manifest.propagation,
164
+ componentMetadata: this.#manifest.componentMetadata,
165
165
  scripts,
166
166
  links,
167
167
  route: routeData,
@@ -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 type { IncomingMessage } from 'http';
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: IncomingMessage | Request, opts?: MatchOptions): RouteData | undefined;
8
- render(req: IncomingMessage | Request, routeData?: RouteData): Promise<Response>;
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 {};
@@ -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) => {
@@ -1,5 +1,5 @@
1
1
  import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
2
- import type { ComponentInstance, PropagationHint, RouteData, SerializedRouteData, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
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
- propagation: SSRResult['propagation'];
29
+ componentMetadata: SSRResult['componentMetadata'];
30
30
  }
31
- export type SerializedSSRManifest = Omit<SSRManifest, 'routes' | 'assets' | 'propagation'> & {
31
+ export type SerializedSSRManifest = Omit<SSRManifest, 'routes' | 'assets' | 'componentMetadata'> & {
32
32
  routes: SerializedRouteInfo[];
33
33
  assets: string[];
34
- propagation: readonly [string, PropagationHint][];
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
- propagation: internals.propagation,
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
- propagation: SSRResult['propagation'];
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
- propagation: /* @__PURE__ */ new Map()
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 { astroHeadPropagationBuildPlugin } from "../../../vite-plugin-head-propagation/index.js";
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(astroHeadPropagationBuildPlugin(options, internals));
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
- propagation: Array.from(internals.propagation),
171
+ componentMetadata: Array.from(internals.componentMetadata),
172
172
  renderers: [],
173
173
  entryModules,
174
174
  assets: staticFiles.map((s) => settings.config.base + s)
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "2.1.5";
1
+ const ASTRO_VERSION = "2.1.7";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -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 astroHeadPropagationPlugin from "../vite-plugin-head-propagation/index.js";
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
- astroHeadPropagationPlugin({ settings }),
98
+ astroHeadPlugin({ settings }),
99
99
  astroScannerPlugin({ settings }),
100
100
  astroInjectEnvTsPlugin({ settings, logging, fs }),
101
101
  astroContentVirtualModPlugin({ settings }),
@@ -52,7 +52,7 @@ async function dev(settings, options) {
52
52
  isRestart: options.isRestart
53
53
  })
54
54
  );
55
- const currentVersion = "2.1.5";
55
+ const currentVersion = "2.1.7";
56
56
  if (currentVersion.includes("-")) {
57
57
  warn(options.logging, null, msg.prerelease({ currentVersion }));
58
58
  }
@@ -47,7 +47,7 @@ function serverStart({
47
47
  base,
48
48
  isRestart = false
49
49
  }) {
50
- const version = "2.1.5";
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.5"}`
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
- propagation?: SSRResult['propagation'];
13
+ componentMetadata?: SSRResult['componentMetadata'];
14
14
  route?: RouteData;
15
15
  status?: number;
16
16
  }
@@ -66,7 +66,7 @@ async function renderPage(mod, ctx, env) {
66
66
  params,
67
67
  props: pageProps,
68
68
  pathname: ctx.pathname,
69
- propagation: ctx.propagation,
69
+ componentMetadata: ctx.componentMetadata,
70
70
  resolve: env.resolve,
71
71
  renderers: env.renderers,
72
72
  request: ctx.request,
@@ -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 { getPropagationMap } from "./head.js";
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 propagationMap = await getPropagationMap(filePath, env.loader);
90
- return { scripts, styles, links, propagationMap };
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, propagationMap } = await getScriptsAndStyles({
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
- propagation: propagationMap,
106
+ componentMetadata: metadata,
107
107
  route: options.route
108
108
  });
109
109
  return await coreRenderPage(mod, ctx, options.env);
@@ -0,0 +1,3 @@
1
+ import type { SSRResult } from '../../../@types/astro';
2
+ import type { ModuleLoader } from '../../module-loader/index';
3
+ export declare function getComponentMetadata(filePath: URL, loader: ModuleLoader): Promise<SSRResult['componentMetadata']>;
@@ -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
- propagation?: SSRResult['propagation'];
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 scoped = createScopedResult(this.#result, ScopeFlags.RenderSlot);
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(scoped) : 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(scoped, slot).then((res) => res != null ? String(res) : res);
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(scoped, component(...args)).then(
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(scoped, this.#slots[name]);
83
- const outHTML = stringifyChunk(scoped, content);
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
- propagation: args.propagation ?? /* @__PURE__ */ new Map(),
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
@@ -123,6 +123,7 @@ function astroJSX() {
123
123
  clientOnlyComponents: [],
124
124
  hydratedComponents: [],
125
125
  scripts: [],
126
+ containsHead: false,
126
127
  propagation: "none",
127
128
  pageOptions: {}
128
129
  };
@@ -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, addScopeFlag, createHeadAndContent, createScopedResult, defineScriptVars, Fragment, maybeRenderHead, removeScopeFlag, renderAstroTemplateResult as renderAstroComponent, renderComponent, renderComponentToIterable, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScriptElement, renderSlot, renderStyleElement, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, ScopeFlags, 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, 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) */