astro 7.2.9 → 7.3.0

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 (88) hide show
  1. package/dist/assets/build/generate.d.ts +1 -1
  2. package/dist/assets/build/generate.js +3 -1
  3. package/dist/assets/endpoint/dev.js +6 -5
  4. package/dist/assets/endpoint/generic.js +5 -4
  5. package/dist/assets/endpoint/node.js +3 -3
  6. package/dist/assets/endpoint/shared.d.ts +3 -1
  7. package/dist/assets/endpoint/shared.js +9 -3
  8. package/dist/assets/fonts/config.d.ts +2 -2
  9. package/dist/assets/internal.d.ts +2 -1
  10. package/dist/assets/internal.js +11 -10
  11. package/dist/assets/services/service.d.ts +8 -7
  12. package/dist/assets/services/sharp.js +5 -5
  13. package/dist/assets/vite-plugin-assets.js +22 -5
  14. package/dist/cli/add/index.js +3 -1
  15. package/dist/cli/index.js +1 -1
  16. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  17. package/dist/cli/preferences/index.js +32 -30
  18. package/dist/cli/preview/index.js +44 -1
  19. package/dist/cli/telemetry/index.d.ts +2 -1
  20. package/dist/cli/telemetry/index.js +2 -2
  21. package/dist/content/content-layer.js +3 -3
  22. package/dist/content/data-store-writer.d.ts +18 -5
  23. package/dist/content/data-store-writer.js +11 -3
  24. package/dist/content/index.d.ts +1 -1
  25. package/dist/content/index.js +5 -1
  26. package/dist/content/mutable-data-store.d.ts +13 -1
  27. package/dist/content/mutable-data-store.js +35 -5
  28. package/dist/content/runtime.d.ts +8 -3
  29. package/dist/content/runtime.js +43 -32
  30. package/dist/content/types-generator.js +2 -1
  31. package/dist/content/utils.d.ts +5 -35
  32. package/dist/content/utils.js +71 -65
  33. package/dist/content/vite-plugin-content-imports.js +2 -1
  34. package/dist/content/vite-plugin-content-virtual-mod.d.ts +11 -1
  35. package/dist/content/vite-plugin-content-virtual-mod.js +36 -3
  36. package/dist/core/app/entrypoints/index.d.ts +4 -2
  37. package/dist/core/app/entrypoints/index.js +13 -11
  38. package/dist/core/app/entrypoints/virtual/dev.js +2 -2
  39. package/dist/core/app/prerender.d.ts +32 -0
  40. package/dist/core/app/prerender.js +22 -0
  41. package/dist/core/build/default-prerenderer.js +5 -2
  42. package/dist/core/build/generate.d.ts +3 -1
  43. package/dist/core/build/generate.js +40 -62
  44. package/dist/core/build/plugins/plugin-manifest.js +1 -1
  45. package/dist/core/cache/handler.js +12 -1
  46. package/dist/core/cache/memory-provider.js +35 -8
  47. package/dist/core/cache/runtime/cache.js +3 -0
  48. package/dist/core/cache/types.d.ts +2 -0
  49. package/dist/core/config/schemas/base.d.ts +5 -5
  50. package/dist/core/config/schemas/relative.d.ts +7 -7
  51. package/dist/core/constants.js +1 -1
  52. package/dist/core/cookies/cookies.d.ts +2 -1
  53. package/dist/core/cookies/cookies.js +5 -4
  54. package/dist/core/dev/dev.js +5 -3
  55. package/dist/core/fetch/fetch-state.d.ts +1 -1
  56. package/dist/core/fetch/fetch-state.js +4 -23
  57. package/dist/core/logger/core.d.ts +2 -0
  58. package/dist/core/logger/core.js +14 -0
  59. package/dist/core/logger/vite-plugin.d.ts +13 -2
  60. package/dist/core/logger/vite-plugin.js +8 -7
  61. package/dist/core/messages/runtime.js +1 -1
  62. package/dist/core/middleware/index.js +14 -1
  63. package/dist/core/render-scope/collect.d.ts +24 -0
  64. package/dist/core/render-scope/collect.js +27 -0
  65. package/dist/core/render-scope/node-scope.d.ts +10 -0
  66. package/dist/core/render-scope/node-scope.js +8 -0
  67. package/dist/core/render-scope/record.d.ts +14 -0
  68. package/dist/core/render-scope/record.js +12 -0
  69. package/dist/core/render-scope/scope.d.ts +38 -0
  70. package/dist/core/render-scope/scope.js +28 -0
  71. package/dist/core/rewrites/handler.js +1 -1
  72. package/dist/core/routing/create-manifest.js +5 -1
  73. package/dist/core/server-islands/endpoint.js +4 -1
  74. package/dist/core/server-islands/vite-plugin-server-islands.js +2 -2
  75. package/dist/core/sync/index.js +1 -1
  76. package/dist/core/util.d.ts +0 -9
  77. package/dist/core/util.js +0 -34
  78. package/dist/core/viteUtils.d.ts +1 -13
  79. package/dist/core/viteUtils.js +3 -33
  80. package/dist/types/public/integrations.d.ts +20 -13
  81. package/dist/vite-plugin-app/createAstroServerApp.js +1 -1
  82. package/dist/vite-plugin-routes/index.js +22 -8
  83. package/package.json +6 -6
  84. package/templates/content/module.mjs +13 -5
  85. package/dist/core/build/incremental-content-collector.d.ts +0 -10
  86. package/dist/core/build/incremental-content-collector.js +0 -33
  87. package/dist/core/build/incremental-image-collector.d.ts +0 -11
  88. package/dist/core/build/incremental-image-collector.js +0 -32
@@ -0,0 +1,28 @@
1
+ const SCOPE_KEY = /* @__PURE__ */ Symbol.for("astro:render-scope");
2
+ function installRenderScope(scope) {
3
+ const host = globalThis;
4
+ const existing = host[SCOPE_KEY];
5
+ if (existing) return existing;
6
+ Object.defineProperty(host, SCOPE_KEY, {
7
+ value: scope,
8
+ configurable: true,
9
+ writable: false,
10
+ enumerable: false
11
+ });
12
+ return scope;
13
+ }
14
+ function getInstalledRenderScope() {
15
+ return globalThis[SCOPE_KEY];
16
+ }
17
+ function uninstallRenderScope() {
18
+ delete globalThis[SCOPE_KEY];
19
+ }
20
+ function getRenderCollectors() {
21
+ return getInstalledRenderScope()?.getStore();
22
+ }
23
+ export {
24
+ getInstalledRenderScope,
25
+ getRenderCollectors,
26
+ installRenderScope,
27
+ uninstallRenderScope
28
+ };
@@ -32,7 +32,7 @@ function applyRewriteToState(state, payload, { routeData, componentInstance, new
32
32
  }
33
33
  state.url = createNormalizedUrl(state.request.url);
34
34
  if (mergeCookies) {
35
- const newCookies = new AstroCookies(state.request);
35
+ const newCookies = new AstroCookies(state.request, state.logger);
36
36
  if (state.cookies) {
37
37
  newCookies.merge(state.cookies);
38
38
  }
@@ -683,7 +683,11 @@ function joinSegments(segments) {
683
683
  }
684
684
  function replaceOrKeep(original, from, to) {
685
685
  if (original.startsWith(`/${to}/`) || original === `/${to}`) return original;
686
- return original.replace(`/${from}/`, `/${to}/`).replace(`/${from}`, `/${to}`);
686
+ const segments = original.split("/");
687
+ const index = segments.indexOf(from);
688
+ if (index === -1) return original;
689
+ segments[index] = to;
690
+ return segments.join("/");
687
691
  }
688
692
  export {
689
693
  createI18nFallbackRoutes,
@@ -1,4 +1,5 @@
1
1
  import {
2
+ markHTMLString,
2
3
  renderComponent,
3
4
  renderTemplate
4
5
  } from "../../runtime/server/index.js";
@@ -155,7 +156,9 @@ function createEndpoint(manifest) {
155
156
  Object.assign(Component, ServerIsland);
156
157
  Component.propagation = "self";
157
158
  }
158
- return renderTemplate`${renderComponent(result, "Component", Component, props, slots)}`;
159
+ result._metadata.routeHasPropagation = true;
160
+ const renderPropagatedHead = () => markHTMLString(result._metadata.extraHead.join(""));
161
+ return renderTemplate`${renderPropagatedHead}${renderComponent(result, "Component", Component, props, slots)}`;
159
162
  };
160
163
  page.isAstroComponentFactory = true;
161
164
  const instance = {
@@ -5,8 +5,8 @@ const RESOLVED_SERVER_ISLAND_MANIFEST = "\0" + SERVER_ISLAND_MANIFEST;
5
5
  const serverIslandPlaceholderMap = "'$$server-islands-map$$'";
6
6
  const serverIslandPlaceholderNameMap = "'$$server-islands-name-map$$'";
7
7
  const SERVER_ISLAND_MAP_MARKER = "$$server-islands-map$$";
8
- const serverIslandMapReplaceExp = /['"]\$\$server-islands-map\$\$['"]/g;
9
- const serverIslandNameMapReplaceExp = /['"]\$\$server-islands-name-map\$\$['"]/g;
8
+ const serverIslandMapReplaceExp = /['"`]\$\$server-islands-map\$\$['"`]/g;
9
+ const serverIslandNameMapReplaceExp = /['"`]\$\$server-islands-name-map\$\$['"`]/g;
10
10
  function vitePluginServerIslands({
11
11
  settings,
12
12
  serverIslandsState
@@ -101,7 +101,7 @@ async function syncInternal({
101
101
  const chunkSize = getDataStoreChunkSize(settings);
102
102
  if (chunkSize !== void 0) {
103
103
  const dataStoreDir = getDataStoreDir(settings, isDev);
104
- store = await MutableDataStore.fromDir(dataStoreDir, chunkSize);
104
+ store = await MutableDataStore.fromDir(dataStoreDir, chunkSize, logger);
105
105
  } else {
106
106
  const dataStoreFile = getDataStoreFile(settings, isDev);
107
107
  store = await MutableDataStore.fromFile(dataStoreFile);
@@ -23,15 +23,6 @@ export declare function wrapId(id: string): string;
23
23
  export declare function resolvePages(config: AstroConfig): URL;
24
24
  export declare function isPage(file: URL, settings: AstroSettings): boolean;
25
25
  export declare function isEndpoint(file: URL, settings: AstroSettings): boolean;
26
- export declare function resolveJsToTs(filePath: string): string;
27
- /**
28
- * Resolve a path that doesn't name a file on disk (e.g. produced by an
29
- * extensionless import like `import { Counter } from './Counter'`) to the file
30
- * Vite would load, by probing Vite's default extension order and directory
31
- * `index` files. Returns the path unchanged when it already exists as a file
32
- * or when no candidate is found.
33
- */
34
- export declare function resolveExtensionlessPath(filePath: string): string;
35
26
  /**
36
27
  * Set a default NODE_ENV so Vite doesn't set an incorrect default when loading the Astro config
37
28
  */
package/dist/core/util.js CHANGED
@@ -1,4 +1,3 @@
1
- import fs from "node:fs";
2
1
  import { fileURLToPath } from "node:url";
3
2
  import { hasSpecialQueries } from "../vite-plugin-utils/index.js";
4
3
  import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./constants.js";
@@ -85,37 +84,6 @@ function isEndpoint(file, settings) {
85
84
  if (!isPublicRoute(file, settings.config)) return false;
86
85
  return !endsWithPageExt(file, settings) && !file.toString().includes("?astro");
87
86
  }
88
- function resolveJsToTs(filePath) {
89
- if (filePath.endsWith(".jsx") && !fs.existsSync(filePath)) {
90
- const tryPath = filePath.slice(0, -4) + ".tsx";
91
- if (fs.existsSync(tryPath)) {
92
- return tryPath;
93
- }
94
- }
95
- return filePath;
96
- }
97
- const VITE_DEFAULT_RESOLVE_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
98
- function resolveExtensionlessPath(filePath) {
99
- const stat = fs.statSync(filePath, { throwIfNoEntry: false });
100
- if (stat?.isFile()) {
101
- return filePath;
102
- }
103
- for (const ext of VITE_DEFAULT_RESOLVE_EXTENSIONS) {
104
- const tryPath = filePath + ext;
105
- if (fs.existsSync(tryPath)) {
106
- return tryPath;
107
- }
108
- }
109
- if (stat?.isDirectory()) {
110
- for (const ext of VITE_DEFAULT_RESOLVE_EXTENSIONS) {
111
- const tryPath = `${filePath}/index${ext}`;
112
- if (fs.existsSync(tryPath)) {
113
- return tryPath;
114
- }
115
- }
116
- }
117
- return filePath;
118
- }
119
87
  function ensureProcessNodeEnv(defaultNodeEnv) {
120
88
  if (!process.env.NODE_ENV) {
121
89
  process.env.NODE_ENV = defaultNodeEnv;
@@ -128,8 +96,6 @@ export {
128
96
  isMarkdownFile,
129
97
  isPage,
130
98
  parseNpmName,
131
- resolveExtensionlessPath,
132
- resolveJsToTs,
133
99
  resolvePages,
134
100
  unwrapId,
135
101
  viteID,
@@ -1,21 +1,9 @@
1
1
  import type { ModuleLoader } from './module-loader/index.js';
2
+ export { resolvePath } from '@astrojs/internal-helpers/mdx';
2
3
  /**
3
4
  * Re-implementation of Vite's normalizePath that can be used without Vite
4
5
  */
5
6
  export declare function normalizePath(id: string): string;
6
- /**
7
- * Resolve island component specifiers to stable paths for hydration metadata.
8
- *
9
- * Examples:
10
- * - `./components/Button.jsx` from `/app/src/pages/index.astro`
11
- * -> `/app/src/pages/components/Button.tsx` (when `.tsx` exists)
12
- * - `../components/Counter` from `/app/src/pages/index.astro`
13
- * -> `/app/src/components/Counter.tsx` (extensionless imports probe Vite's
14
- * default extension order, then directory `index` files)
15
- * - `#components/react/Counter.tsx`
16
- * -> `/app/src/components/react/Counter.tsx` via package `imports`
17
- */
18
- export declare function resolvePath(specifier: string, importer: string): string;
19
7
  export declare function rootRelativePath(root: URL, idOrUrl: URL | string, shouldPrependForwardSlash?: boolean): string;
20
8
  /**
21
9
  * Simulate Vite's resolve and import analysis so we can import the id as an URL
@@ -1,42 +1,12 @@
1
- import { createRequire } from "node:module";
2
1
  import path from "node:path";
3
- import { fileURLToPath, pathToFileURL } from "node:url";
2
+ import { fileURLToPath } from "node:url";
4
3
  import { prependForwardSlash, slash } from "../core/path.js";
5
- import {
6
- resolveExtensionlessPath,
7
- resolveJsToTs,
8
- unwrapId,
9
- VALID_ID_PREFIX,
10
- viteID
11
- } from "./util.js";
4
+ import { unwrapId, VALID_ID_PREFIX, viteID } from "./util.js";
5
+ import { resolvePath } from "@astrojs/internal-helpers/mdx";
12
6
  const isWindows = typeof process !== "undefined" && process.platform === "win32";
13
7
  function normalizePath(id) {
14
8
  return path.posix.normalize(isWindows ? slash(id) : id);
15
9
  }
16
- function resolvePath(specifier, importer) {
17
- if (specifier.startsWith(".")) {
18
- const absoluteSpecifier = path.resolve(path.dirname(importer), specifier);
19
- return resolveExtensionlessPath(resolveJsToTs(normalizePath(absoluteSpecifier)));
20
- } else if (specifier.startsWith("#")) {
21
- try {
22
- const resolved = createRequire(pathToFileURL(importer)).resolve(specifier);
23
- return resolveJsToTs(normalizePath(resolved));
24
- } catch {
25
- try {
26
- const importerURL = pathToFileURL(importer).toString();
27
- const resolved = import.meta.resolve(specifier, importerURL);
28
- const resolvedUrl = new URL(resolved);
29
- if (resolvedUrl.protocol === "file:") {
30
- return resolveJsToTs(normalizePath(fileURLToPath(resolvedUrl)));
31
- }
32
- } catch {
33
- }
34
- }
35
- return specifier;
36
- } else {
37
- return specifier;
38
- }
39
- }
40
10
  function rootRelativePath(root, idOrUrl, shouldPrependForwardSlash = true) {
41
11
  let id;
42
12
  if (typeof idOrUrl !== "string") {
@@ -197,21 +197,23 @@ export interface PathWithRoute {
197
197
  cacheKey?: string;
198
198
  }
199
199
  /**
200
- * Incremental-build data an out-of-process prerenderer collects while rendering
201
- * a page, reported back to the build process so skipped pages can be tracked and
202
- * replayed without a re-render.
200
+ * Incremental-build data a prerenderer collects while rendering a page,
201
+ * reported back to the build orchestrator so skipped pages can be tracked and
202
+ * replayed without a re-render. This is the only attribution channel: every
203
+ * prerenderer — in-process and out-of-process — collects in its own rendering
204
+ * runtime and reports the result by value here.
203
205
  */
204
206
  export interface PrerenderRenderMetadata {
205
- /** Root-relative `filePath`s of the content entries the page rendered. */
206
- contentEntryKeys?: string[];
207
- /** Optimized-image transforms the page resolved. */
208
- staticImages?: SerializedStaticImage[];
207
+ /** Root-relative `filePath`s of the content entries the page rendered, or an empty array. */
208
+ contentEntryKeys: string[];
209
+ /** Optimized-image transforms the page resolved, or an empty array. */
210
+ staticImages: SerializedStaticImage[];
209
211
  }
210
212
  /**
211
213
  * The richer result a prerenderer's `render()` may return instead of a bare
212
214
  * `Response`, pairing the rendered response with the incremental-build metadata
213
- * collected for that page. Used by out-of-process prerenderers, which collect
214
- * the metadata in their own runtime rather than in the build's collectors.
215
+ * collected for that page. `metadata` is `undefined` when the page was not
216
+ * tracked (collection was not requested, or the prerenderer could not collect).
215
217
  */
216
218
  export interface PrerenderResult {
217
219
  response: Response;
@@ -239,14 +241,19 @@ export interface AstroPrerenderer {
239
241
  * use the `pathname` from the `PathWithRoute` entry returned by `getStaticPaths`.
240
242
  * @param options - Render options
241
243
  * @param options.routeData - The matched route for this path
244
+ * @param options.collectMetadata - True exactly when the incremental build
245
+ * cache is active. The prerenderer should collect the page's per-render
246
+ * incremental metadata in its rendering runtime and report it on a
247
+ * {@link PrerenderResult}. A prerenderer that cannot collect may ignore the
248
+ * flag and return a bare `Response`; its paths are then recorded as
249
+ * "not tracked".
242
250
  * @returns A `Response`, or a {@link PrerenderResult} pairing the response with
243
- * the incremental-build metadata the page resolved. Out-of-process
244
- * prerenderers return the latter to report metadata they collect in their own
245
- * runtime; in-process prerenderers populate the build's collectors directly
246
- * and return a bare `Response`.
251
+ * the incremental-build metadata the page resolved. Metadata is the only
252
+ * attribution channel for all prerenderers.
247
253
  */
248
254
  render: (request: Request, options: {
249
255
  routeData: RouteData;
256
+ collectMetadata?: boolean;
250
257
  }) => Promise<Response | PrerenderResult>;
251
258
  /**
252
259
  * Returns images collected in the adapter's runtime (e.g. workerd) to be merged
@@ -47,7 +47,7 @@ async function createAstroServerApp(controller, settings, loader, logger) {
47
47
  const { routes: newRoutes } = await import("virtual:astro:routes");
48
48
  updateRouteTable(
49
49
  manifest,
50
- newRoutes.map((r) => r.routeData)
50
+ newRoutes.map((route) => route.routeData)
51
51
  );
52
52
  actualLogger.debug("router", "Routes updated via HMR");
53
53
  } catch (e) {
@@ -53,6 +53,26 @@ async function astroPluginRoutes({
53
53
  }
54
54
  );
55
55
  const normalizedSrcDir = normalizePath(fileURLToPath(settings.config.srcDir));
56
+ function findRouteByFilename(filename) {
57
+ return initialRoutesList.routes.find(
58
+ (route) => normalizePath(fileURLToPath(new URL(`./${route.component}`, settings.config.root))) === filename
59
+ );
60
+ }
61
+ let routeByFilename = null;
62
+ function getRouteByFilename() {
63
+ if (routeByFilename === null) {
64
+ routeByFilename = /* @__PURE__ */ new Map();
65
+ for (const route of initialRoutesList.routes) {
66
+ const filename = normalizePath(
67
+ fileURLToPath(new URL(`./${route.component}`, settings.config.root))
68
+ );
69
+ if (!routeByFilename.has(filename)) {
70
+ routeByFilename.set(filename, route);
71
+ }
72
+ }
73
+ }
74
+ return routeByFilename;
75
+ }
56
76
  async function rebuildRoutes(path = null, server) {
57
77
  if (path != null && normalizePath(path).startsWith(normalizedSrcDir)) {
58
78
  logger.debug(
@@ -157,10 +177,7 @@ async function astroPluginRoutes({
157
177
  const fileIsPage = isPage(fileURL, settings);
158
178
  const fileIsEndpoint = isEndpoint(fileURL, settings);
159
179
  if (!(fileIsPage || fileIsEndpoint)) return;
160
- const route = initialRoutesList.routes.find((r) => {
161
- const filePath = new URL(`./${r.component}`, settings.config.root);
162
- return normalizePath(fileURLToPath(filePath)) === filename;
163
- });
180
+ const route = this.environment.mode === "build" ? getRouteByFilename().get(filename) : findRouteByFilename(filename);
164
181
  if (!route) {
165
182
  return;
166
183
  }
@@ -200,10 +217,7 @@ async function astroPluginRoutes({
200
217
  const fileIsPage = isPage(fileURL, settings);
201
218
  const fileIsEndpoint = isEndpoint(fileURL, settings);
202
219
  if (!(fileIsPage || fileIsEndpoint)) return;
203
- const route = initialRoutesList.routes.find((r) => {
204
- const filePath = new URL(`./${r.component}`, settings.config.root);
205
- return normalizePath(fileURLToPath(filePath)) === filename;
206
- });
220
+ const route = findRouteByFilename(filename);
207
221
  if (!route) {
208
222
  return;
209
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.2.9",
3
+ "version": "7.3.0",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -152,16 +152,16 @@
152
152
  "vitefu": "^1.1.2",
153
153
  "xxhash-wasm": "^1.1.0",
154
154
  "yargs-parser": "^22.0.0",
155
- "zod": "^4.3.6",
156
- "@astrojs/markdown-satteri": "0.3.8",
157
- "@astrojs/internal-helpers": "0.10.4",
155
+ "zod": "^4.5.4",
156
+ "@astrojs/internal-helpers": "0.11.0",
157
+ "@astrojs/markdown-satteri": "0.4.0",
158
158
  "@astrojs/telemetry": "3.3.3"
159
159
  },
160
160
  "optionalDependencies": {
161
161
  "sharp": "^0.35.4"
162
162
  },
163
163
  "peerDependencies": {
164
- "@astrojs/markdown-remark": "7.2.4"
164
+ "@astrojs/markdown-remark": "^7.3.0"
165
165
  },
166
166
  "peerDependenciesMeta": {
167
167
  "@astrojs/markdown-remark": {
@@ -193,8 +193,8 @@
193
193
  "typescript": "^6.0.3",
194
194
  "undici": "^7.22.0",
195
195
  "vitest": "^4.1.0",
196
- "@astrojs/markdown-remark": "7.2.4",
197
196
  "@astrojs/check": "0.9.10",
197
+ "@astrojs/markdown-remark": "7.3.0",
198
198
  "astro-scripts": "0.0.14"
199
199
  },
200
200
  "engines": {
@@ -1,3 +1,5 @@
1
+ import { createConsoleLogger } from 'astro/logger/console';
2
+ import loggerDestination, { level } from 'virtual:astro:logger';
1
3
  import {
2
4
  createDeprecatedFunction,
3
5
  createGetCollection,
@@ -6,26 +8,32 @@ import {
6
8
  createGetLiveCollection,
7
9
  createGetLiveEntry,
8
10
  createReference,
11
+ createRenderEntry,
9
12
  } from 'astro/content/runtime';
10
13
 
11
- export {
12
- defineCollection,
13
- defineLiveCollection,
14
- renderEntry as render,
15
- } from 'astro/content/runtime';
14
+ export { defineCollection, defineLiveCollection } from 'astro/content/runtime';
16
15
  // TODO: remove in Astro 8
17
16
  export { z } from 'astro/zod';
18
17
 
19
18
  /* @@LIVE_CONTENT_CONFIG@@ */
20
19
 
20
+ const logger = createConsoleLogger({ level });
21
+ if (loggerDestination) {
22
+ logger.setDestination(loggerDestination);
23
+ }
24
+
21
25
  export const getCollection = createGetCollection({
22
26
  liveCollections,
27
+ logger,
23
28
  });
24
29
 
25
30
  export const getEntry = createGetEntry({
26
31
  liveCollections,
32
+ logger,
27
33
  });
28
34
 
35
+ export const render = createRenderEntry({ logger });
36
+
29
37
  export const getEntries = createGetEntries(getEntry);
30
38
 
31
39
  export const reference = createReference();
@@ -1,10 +0,0 @@
1
- /** Start collecting the content entries rendered on the current path. */
2
- export declare function beginContentEntryCollection(): void;
3
- /** Record that a content entry was rendered, keyed by its root-relative `filePath`. */
4
- export declare function recordContentEntryRender(filePath: string | undefined): void;
5
- /**
6
- * Finish collection and return the rendered entries, or `undefined` when no
7
- * collection was active (so callers can distinguish "nothing rendered" from
8
- * "not tracked").
9
- */
10
- export declare function endContentEntryCollection(): string[] | undefined;
@@ -1,33 +0,0 @@
1
- const COLLECTOR_KEY = /* @__PURE__ */ Symbol.for("astro:incremental-content-entries");
2
- function collector() {
3
- const host = globalThis;
4
- let value = host[COLLECTOR_KEY];
5
- if (!value) {
6
- value = { current: void 0 };
7
- Object.defineProperty(host, COLLECTOR_KEY, {
8
- value,
9
- configurable: false,
10
- writable: false,
11
- enumerable: false
12
- });
13
- }
14
- return value;
15
- }
16
- function beginContentEntryCollection() {
17
- collector().current = /* @__PURE__ */ new Set();
18
- }
19
- function recordContentEntryRender(filePath) {
20
- if (!filePath) return;
21
- collector().current?.add(filePath);
22
- }
23
- function endContentEntryCollection() {
24
- const c = collector();
25
- const entries = c.current;
26
- c.current = void 0;
27
- return entries ? [...entries] : void 0;
28
- }
29
- export {
30
- beginContentEntryCollection,
31
- endContentEntryCollection,
32
- recordContentEntryRender
33
- };
@@ -1,11 +0,0 @@
1
- import type { SerializedStaticImage } from '../../assets/types.js';
2
- /** Start collecting the image transforms resolved on the current path. */
3
- export declare function beginImageCollection(): void;
4
- /** Record an image transform resolved while rendering the current path. */
5
- export declare function recordStaticImage(image: SerializedStaticImage): void;
6
- /**
7
- * Finish collection and return the collected transforms, or `undefined` when no
8
- * collection was active (so callers can distinguish "no images" from
9
- * "not tracked").
10
- */
11
- export declare function endImageCollection(): SerializedStaticImage[] | undefined;
@@ -1,32 +0,0 @@
1
- const COLLECTOR_KEY = /* @__PURE__ */ Symbol.for("astro:incremental-static-images");
2
- function collector() {
3
- const host = globalThis;
4
- let value = host[COLLECTOR_KEY];
5
- if (!value) {
6
- value = { current: void 0 };
7
- Object.defineProperty(host, COLLECTOR_KEY, {
8
- value,
9
- configurable: false,
10
- writable: false,
11
- enumerable: false
12
- });
13
- }
14
- return value;
15
- }
16
- function beginImageCollection() {
17
- collector().current = [];
18
- }
19
- function recordStaticImage(image) {
20
- collector().current?.push(image);
21
- }
22
- function endImageCollection() {
23
- const c = collector();
24
- const images = c.current;
25
- c.current = void 0;
26
- return images;
27
- }
28
- export {
29
- beginImageCollection,
30
- endImageCollection,
31
- recordStaticImage
32
- };