astro 7.2.10 → 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.
- package/dist/assets/build/generate.d.ts +1 -1
- package/dist/assets/build/generate.js +3 -1
- package/dist/assets/endpoint/dev.js +6 -5
- package/dist/assets/endpoint/generic.js +5 -4
- package/dist/assets/endpoint/node.js +3 -3
- package/dist/assets/endpoint/shared.d.ts +3 -1
- package/dist/assets/endpoint/shared.js +9 -3
- package/dist/assets/fonts/config.d.ts +2 -2
- package/dist/assets/internal.d.ts +2 -1
- package/dist/assets/internal.js +11 -10
- package/dist/assets/services/service.d.ts +8 -7
- package/dist/assets/services/sharp.js +5 -5
- package/dist/assets/vite-plugin-assets.js +22 -5
- package/dist/cli/add/index.js +3 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/preferences/index.js +32 -30
- package/dist/cli/preview/index.js +44 -1
- package/dist/cli/telemetry/index.d.ts +2 -1
- package/dist/cli/telemetry/index.js +2 -2
- package/dist/content/content-layer.js +3 -3
- package/dist/content/mutable-data-store.d.ts +2 -1
- package/dist/content/mutable-data-store.js +4 -4
- package/dist/content/runtime.d.ts +8 -3
- package/dist/content/runtime.js +40 -31
- package/dist/content/types-generator.js +2 -1
- package/dist/content/utils.d.ts +5 -35
- package/dist/content/utils.js +71 -65
- package/dist/content/vite-plugin-content-imports.js +2 -1
- package/dist/core/app/entrypoints/index.d.ts +4 -2
- package/dist/core/app/entrypoints/index.js +13 -11
- package/dist/core/app/prerender.d.ts +32 -0
- package/dist/core/app/prerender.js +22 -0
- package/dist/core/build/default-prerenderer.js +5 -2
- package/dist/core/build/generate.d.ts +3 -1
- package/dist/core/build/generate.js +21 -37
- package/dist/core/cache/handler.js +12 -1
- package/dist/core/cache/memory-provider.js +35 -8
- package/dist/core/cache/types.d.ts +2 -0
- package/dist/core/config/schemas/base.d.ts +5 -5
- package/dist/core/config/schemas/relative.d.ts +7 -7
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.d.ts +2 -1
- package/dist/core/cookies/cookies.js +5 -4
- package/dist/core/dev/dev.js +2 -2
- package/dist/core/fetch/fetch-state.d.ts +1 -1
- package/dist/core/fetch/fetch-state.js +4 -23
- package/dist/core/logger/core.d.ts +2 -0
- package/dist/core/logger/core.js +14 -0
- package/dist/core/logger/vite-plugin.d.ts +13 -2
- package/dist/core/logger/vite-plugin.js +8 -7
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +14 -1
- package/dist/core/render-scope/collect.d.ts +24 -0
- package/dist/core/render-scope/collect.js +27 -0
- package/dist/core/render-scope/node-scope.d.ts +10 -0
- package/dist/core/render-scope/node-scope.js +8 -0
- package/dist/core/render-scope/record.d.ts +14 -0
- package/dist/core/render-scope/record.js +12 -0
- package/dist/core/render-scope/scope.d.ts +38 -0
- package/dist/core/render-scope/scope.js +28 -0
- package/dist/core/rewrites/handler.js +1 -1
- package/dist/core/routing/create-manifest.js +5 -1
- package/dist/core/server-islands/endpoint.js +4 -1
- package/dist/core/sync/index.js +1 -1
- package/dist/types/public/integrations.d.ts +20 -13
- package/dist/vite-plugin-routes/index.js +22 -8
- package/package.json +2 -2
- package/templates/content/module.mjs +13 -5
- package/dist/core/build/incremental-content-collector.d.ts +0 -10
- package/dist/core/build/incremental-content-collector.js +0 -33
- package/dist/core/build/incremental-image-collector.d.ts +0 -11
- package/dist/core/build/incremental-image-collector.js +0 -32
|
@@ -35,13 +35,8 @@ async function emitDestination(config, resolveEntrypoint, nameOffset = 0) {
|
|
|
35
35
|
}
|
|
36
36
|
return { expression: `${name}(${JSON.stringify(config.config) ?? "undefined"})`, imports };
|
|
37
37
|
}
|
|
38
|
-
function vitePluginLogger({
|
|
39
|
-
settings
|
|
40
|
-
}) {
|
|
38
|
+
function vitePluginLogger({ settings }) {
|
|
41
39
|
const loggerConfig = settings.config.logger;
|
|
42
|
-
if (!loggerConfig) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
40
|
return {
|
|
46
41
|
name: VIRTUAL_LOGGER_ID,
|
|
47
42
|
enforce: "pre",
|
|
@@ -58,6 +53,12 @@ function vitePluginLogger({
|
|
|
58
53
|
id: new RegExp(`^${RESOLVED_VIRTUAL_LOGGER_ID}$`)
|
|
59
54
|
},
|
|
60
55
|
async handler() {
|
|
56
|
+
const level = `export const level = ${JSON.stringify(settings.logLevel)};
|
|
57
|
+
`;
|
|
58
|
+
if (!loggerConfig) {
|
|
59
|
+
return { code: `${level}export default null;
|
|
60
|
+
` };
|
|
61
|
+
}
|
|
61
62
|
const importerPath = fileURLToPath(new URL("package.json", settings.config.root));
|
|
62
63
|
const { expression, imports } = await emitDestination(
|
|
63
64
|
normalizeLoggerConfig(loggerConfig, settings.config.root),
|
|
@@ -65,7 +66,7 @@ function vitePluginLogger({
|
|
|
65
66
|
);
|
|
66
67
|
return {
|
|
67
68
|
code: `${imports.join("\n")}
|
|
68
|
-
export default ${expression};
|
|
69
|
+
${level}export default ${expression};
|
|
69
70
|
`
|
|
70
71
|
};
|
|
71
72
|
}
|
|
@@ -8,8 +8,21 @@ import { DisabledAstroCache } from "../cache/runtime/noop.js";
|
|
|
8
8
|
import { ASTRO_GENERATOR } from "../constants.js";
|
|
9
9
|
import { AstroCookies } from "../cookies/index.js";
|
|
10
10
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
11
|
+
import { getLogger } from "../logger/manifest-logger.js";
|
|
12
|
+
import { tryGetAmbientManifest } from "../manifest/ambient.js";
|
|
11
13
|
import { getOriginPathname } from "../routing/rewrite.js";
|
|
12
14
|
import { sequence } from "./sequence.js";
|
|
15
|
+
function getMiddlewareLogger() {
|
|
16
|
+
const manifest = tryGetAmbientManifest();
|
|
17
|
+
if (manifest) {
|
|
18
|
+
return getLogger(manifest);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
warn(_label, message) {
|
|
22
|
+
console.warn(message);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
13
26
|
function createContext({
|
|
14
27
|
request,
|
|
15
28
|
params = {},
|
|
@@ -27,7 +40,7 @@ function createContext({
|
|
|
27
40
|
return Promise.resolve(new Response(null));
|
|
28
41
|
};
|
|
29
42
|
const context = {
|
|
30
|
-
cookies: new AstroCookies(request),
|
|
43
|
+
cookies: new AstroCookies(request, getMiddlewareLogger()),
|
|
31
44
|
request,
|
|
32
45
|
params,
|
|
33
46
|
site: void 0,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SerializedStaticImage } from '../../assets/types.js';
|
|
2
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
3
|
+
export interface CollectedPrerenderMetadata {
|
|
4
|
+
contentEntryKeys: string[];
|
|
5
|
+
staticImages: SerializedStaticImage[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Runs `fn` inside a fresh per-render collectors store and returns its value
|
|
9
|
+
* together with a snapshot of everything recorded while it ran.
|
|
10
|
+
*
|
|
11
|
+
* When no render scope is installed, collection degrades to *not collecting*:
|
|
12
|
+
* warn once per process, run `fn` bare, and return `metadata: undefined`
|
|
13
|
+
* ("not tracked") — never wrong attribution.
|
|
14
|
+
*
|
|
15
|
+
* Invariant: `fn` must not resolve until all recordable work is done — in
|
|
16
|
+
* practice, until the response body is fully buffered inside `fn`. The
|
|
17
|
+
* snapshot is taken by copy when `fn` resolves, so a late-arriving record (a
|
|
18
|
+
* floating promise carrying the async context past buffering) mutates only the
|
|
19
|
+
* abandoned store, never the returned metadata.
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectPrerenderMetadata<T>(fn: () => Promise<T>, logger: AstroLogger): Promise<{
|
|
22
|
+
value: T;
|
|
23
|
+
metadata: CollectedPrerenderMetadata | undefined;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getInstalledRenderScope } from "./scope.js";
|
|
2
|
+
let warnedNoScope = false;
|
|
3
|
+
async function collectPrerenderMetadata(fn, logger) {
|
|
4
|
+
const scope = getInstalledRenderScope();
|
|
5
|
+
if (!scope) {
|
|
6
|
+
if (!warnedNoScope) {
|
|
7
|
+
warnedNoScope = true;
|
|
8
|
+
logger.warn(
|
|
9
|
+
"build",
|
|
10
|
+
"A prerenderer requested metadata collection but no render scope is installed; install one with `installRenderScope` from `astro/app` \u2014 incremental metadata will not be collected for prerendered paths."
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return { value: await fn(), metadata: void 0 };
|
|
14
|
+
}
|
|
15
|
+
const store = { contentEntries: /* @__PURE__ */ new Set(), staticImages: [] };
|
|
16
|
+
const value = await scope.run(store, fn);
|
|
17
|
+
return {
|
|
18
|
+
value,
|
|
19
|
+
metadata: {
|
|
20
|
+
contentEntryKeys: [...store.contentEntries],
|
|
21
|
+
staticImages: [...store.staticImages]
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
collectPrerenderMetadata
|
|
27
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RenderCollectorScope } from './scope.js';
|
|
2
|
+
/**
|
|
3
|
+
* Installs (first-wins) an AsyncLocalStorage-backed render scope and returns
|
|
4
|
+
* the installed scope.
|
|
5
|
+
*
|
|
6
|
+
* This module is the ONE static `node:async_hooks` import in core and must be
|
|
7
|
+
* imported ONLY by `core/build/default-prerenderer.ts` — orchestrator-only
|
|
8
|
+
* code that is never bundled into prerender, server, or adapter output.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureAsyncRenderScope(): RenderCollectorScope;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SerializedStaticImage } from '../../assets/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Records that a content entry was rendered, keyed by its root-relative
|
|
4
|
+
* `filePath`. No-op when no scope is installed (dev, production SSR,
|
|
5
|
+
* non-incremental builds) or no render is in scope (`getStaticPaths`, module
|
|
6
|
+
* top-level).
|
|
7
|
+
*/
|
|
8
|
+
export declare function recordContentEntryRender(filePath: string | undefined): void;
|
|
9
|
+
/**
|
|
10
|
+
* Records a resolved image transform, dedup hits included, preserving
|
|
11
|
+
* duplicates (array push, not a set — replay depends on every record
|
|
12
|
+
* arriving).
|
|
13
|
+
*/
|
|
14
|
+
export declare function recordStaticImage(image: SerializedStaticImage): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getInstalledRenderScope } from "./scope.js";
|
|
2
|
+
function recordContentEntryRender(filePath) {
|
|
3
|
+
if (!filePath) return;
|
|
4
|
+
getInstalledRenderScope()?.getStore()?.contentEntries?.add(filePath);
|
|
5
|
+
}
|
|
6
|
+
function recordStaticImage(image) {
|
|
7
|
+
getInstalledRenderScope()?.getStore()?.staticImages?.push(image);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
recordContentEntryRender,
|
|
11
|
+
recordStaticImage
|
|
12
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SerializedStaticImage } from '../../assets/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The per-render store. One instance is created per collecting render and is
|
|
4
|
+
* reachable only through the installed {@link RenderCollectorScope} while that
|
|
5
|
+
* render's async execution is in scope. Fields are optional so record helpers
|
|
6
|
+
* tolerate stores created by a different astro module instance (or version)
|
|
7
|
+
* that only knows a subset of collectors.
|
|
8
|
+
*/
|
|
9
|
+
export interface RenderCollectors {
|
|
10
|
+
/** Root-relative `filePath`s of the content entries rendered. */
|
|
11
|
+
contentEntries?: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Every image transform resolved, dedup hits included; array push,
|
|
14
|
+
* duplicates preserved.
|
|
15
|
+
*/
|
|
16
|
+
staticImages?: SerializedStaticImage[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Structurally satisfied by `AsyncLocalStorage<RenderCollectors>` — deliberate:
|
|
20
|
+
* installing an ALS instance directly IS the only shipped implementation.
|
|
21
|
+
*/
|
|
22
|
+
export interface RenderCollectorScope {
|
|
23
|
+
run<T>(store: RenderCollectors, fn: () => T): T;
|
|
24
|
+
getStore(): RenderCollectors | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Installs a render scope on the process-wide channel and returns the installed
|
|
28
|
+
* scope. First-wins: when a scope is already installed (possibly by another
|
|
29
|
+
* module instance), the existing scope is returned and the argument discarded,
|
|
30
|
+
* so callers that both awaited an import converge on one scope.
|
|
31
|
+
*/
|
|
32
|
+
export declare function installRenderScope(scope: RenderCollectorScope): RenderCollectorScope;
|
|
33
|
+
/** The installed render scope, or `undefined` when none was installed. */
|
|
34
|
+
export declare function getInstalledRenderScope(): RenderCollectorScope | undefined;
|
|
35
|
+
/** Test-only: remove the installed scope so unit tests can reset the channel. */
|
|
36
|
+
export declare function uninstallRenderScope(): void;
|
|
37
|
+
/** The current render's collectors store, or `undefined` when not collecting. */
|
|
38
|
+
export declare function getRenderCollectors(): RenderCollectors | undefined;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 = {
|
package/dist/core/sync/index.js
CHANGED
|
@@ -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);
|
|
@@ -197,21 +197,23 @@ export interface PathWithRoute {
|
|
|
197
197
|
cacheKey?: string;
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
|
-
* Incremental-build data
|
|
201
|
-
*
|
|
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
|
|
207
|
-
/** Optimized-image transforms the page resolved. */
|
|
208
|
-
staticImages
|
|
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.
|
|
214
|
-
*
|
|
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.
|
|
244
|
-
*
|
|
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
|
|
@@ -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 =
|
|
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 =
|
|
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.
|
|
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,7 +152,7 @@
|
|
|
152
152
|
"vitefu": "^1.1.2",
|
|
153
153
|
"xxhash-wasm": "^1.1.0",
|
|
154
154
|
"yargs-parser": "^22.0.0",
|
|
155
|
-
"zod": "^4.
|
|
155
|
+
"zod": "^4.5.4",
|
|
156
156
|
"@astrojs/internal-helpers": "0.11.0",
|
|
157
157
|
"@astrojs/markdown-satteri": "0.4.0",
|
|
158
158
|
"@astrojs/telemetry": "3.3.3"
|
|
@@ -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
|
-
};
|