astro 6.1.10 → 6.2.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/client.d.ts +1 -0
- package/dist/actions/runtime/types.d.ts +1 -1
- package/dist/assets/fonts/constants.d.ts +2 -0
- package/dist/assets/fonts/constants.js +4 -0
- package/dist/assets/fonts/core/create-get-font-file-url.d.ts +2 -0
- package/dist/assets/fonts/core/create-get-font-file-url.js +23 -0
- package/dist/assets/fonts/core/font-file-middleware.d.ts +21 -0
- package/dist/assets/fonts/core/font-file-middleware.js +59 -0
- package/dist/assets/fonts/definitions.d.ts +13 -0
- package/dist/assets/fonts/infra/build-url-resolver.d.ts +1 -0
- package/dist/assets/fonts/infra/build-url-resolver.js +7 -1
- package/dist/assets/fonts/infra/dev-url-resolver.d.ts +1 -0
- package/dist/assets/fonts/infra/dev-url-resolver.js +7 -1
- package/dist/assets/fonts/infra/remote-runtime-font-file-url-resolver.d.ts +19 -0
- package/dist/assets/fonts/infra/remote-runtime-font-file-url-resolver.js +27 -0
- package/dist/assets/fonts/infra/ssr-runtime-font-file-url-resolver.d.ts +12 -0
- package/dist/assets/fonts/infra/ssr-runtime-font-file-url-resolver.js +25 -0
- package/dist/assets/fonts/runtime.d.ts +1 -0
- package/dist/assets/fonts/runtime.js +4 -0
- package/dist/assets/fonts/vite-plugin-fonts.js +88 -49
- package/dist/assets/index.d.ts +1 -1
- package/dist/assets/index.js +3 -2
- package/dist/assets/svg/config.d.ts +5 -0
- package/dist/assets/svg/config.js +8 -0
- package/dist/assets/svg/svgo.d.ts +4 -0
- package/dist/assets/svg/svgo.js +10 -0
- package/dist/assets/svg/types.d.ts +4 -0
- package/dist/assets/svg/types.js +0 -0
- package/dist/assets/svg/utils.d.ts +3 -0
- package/dist/assets/{utils/svg.js → svg/utils.js} +11 -14
- package/dist/assets/vite-plugin-assets.js +8 -4
- package/dist/cli/flags.js +19 -9
- package/dist/cli/help/index.js +2 -1
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/preferences/index.js +3 -2
- package/dist/config/entrypoint.d.ts +2 -0
- package/dist/config/entrypoint.js +4 -0
- package/dist/config/index.js +9 -7
- package/dist/container/index.js +4 -7
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/base.d.ts +18 -4
- package/dist/core/app/base.js +29 -12
- package/dist/core/app/dev/app.d.ts +0 -1
- package/dist/core/app/dev/app.js +0 -2
- package/dist/core/app/entrypoints/index.d.ts +1 -1
- package/dist/core/app/entrypoints/index.js +1 -1
- package/dist/core/app/entrypoints/virtual/dev.js +1 -1
- package/dist/core/app/pipeline.js +2 -2
- package/dist/core/app/types.d.ts +10 -3
- package/dist/core/base-pipeline.d.ts +9 -2
- package/dist/core/base-pipeline.js +17 -0
- package/dist/core/build/app.js +2 -1
- package/dist/core/build/index.js +13 -2
- package/dist/core/build/internal.d.ts +1 -0
- package/dist/core/build/internal.js +1 -0
- package/dist/core/build/pipeline.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +6 -1
- package/dist/core/cache/types.d.ts +2 -0
- package/dist/core/config/schemas/base.d.ts +12 -4
- package/dist/core/config/schemas/base.js +11 -4
- package/dist/core/config/schemas/relative.d.ts +27 -6
- package/dist/core/config/schemas/relative.js +1 -1
- package/dist/core/config/settings.js +2 -1
- package/dist/core/config/vite-load.js +4 -17
- package/dist/core/constants.js +1 -1
- package/dist/core/createMinimalViteDevServer.d.ts +8 -0
- package/dist/core/createMinimalViteDevServer.js +15 -0
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +2 -2
- package/dist/core/errors/errors-data.d.ts +48 -2
- package/dist/core/errors/errors-data.js +26 -2
- package/dist/core/logger/config.d.ts +6 -0
- package/dist/core/logger/config.js +0 -0
- package/dist/core/logger/core.d.ts +33 -13
- package/dist/core/logger/core.js +50 -5
- package/dist/core/logger/handlers.d.ts +60 -0
- package/dist/core/logger/handlers.js +81 -0
- package/dist/core/logger/impls/compose.d.ts +2 -0
- package/dist/core/logger/impls/compose.js +26 -0
- package/dist/core/logger/impls/console.d.ts +9 -0
- package/dist/core/logger/impls/console.js +38 -0
- package/dist/core/logger/impls/json.d.ts +15 -0
- package/dist/core/logger/impls/json.js +42 -0
- package/dist/core/logger/impls/node.d.ts +7 -0
- package/dist/core/logger/impls/node.js +40 -0
- package/dist/core/logger/load.d.ts +11 -0
- package/dist/core/logger/load.js +88 -0
- package/dist/core/logger/node.d.ts +0 -5
- package/dist/core/logger/node.js +1 -39
- package/dist/core/logger/public.d.ts +17 -0
- package/dist/core/logger/public.js +7 -0
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +2 -1
- package/dist/core/preview/index.js +4 -3
- package/dist/core/render-context.js +35 -1
- package/dist/core/sync/index.js +2 -2
- package/dist/core/wait-until.d.ts +1 -0
- package/dist/core/wait-until.js +0 -0
- package/dist/manifest/serialized.js +6 -1
- package/dist/runtime/compiler/index.d.ts +1 -1
- package/dist/runtime/compiler/index.js +4 -0
- package/dist/runtime/server/astro-global.js +3 -0
- package/dist/runtime/server/index.d.ts +1 -0
- package/dist/runtime/server/index.js +3 -0
- package/dist/runtime/server/render/common.js +16 -0
- package/dist/runtime/server/render/instruction.d.ts +7 -1
- package/dist/runtime/server/render/template-depth.d.ts +13 -0
- package/dist/runtime/server/render/template-depth.js +11 -0
- package/dist/types/astro.d.ts +2 -0
- package/dist/types/public/common.d.ts +1 -0
- package/dist/types/public/config.d.ts +54 -42
- package/dist/types/public/context.d.ts +17 -0
- package/dist/types/public/index.d.ts +1 -0
- package/dist/types/public/internal.d.ts +7 -1
- package/dist/types/public/preview.d.ts +5 -0
- package/dist/vite-plugin-app/app.d.ts +0 -1
- package/dist/vite-plugin-app/app.js +0 -2
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +1 -1
- package/dist/vite-plugin-app/createAstroServerApp.js +2 -6
- package/dist/vite-plugin-load-fallback/index.d.ts +1 -1
- package/dist/vite-plugin-load-fallback/index.js +2 -5
- package/package.json +12 -7
- package/dist/assets/utils/svg.d.ts +0 -3
- package/dist/core/app/logging.d.ts +0 -3
- package/dist/core/app/logging.js +0 -11
- package/dist/core/logger/console.d.ts +0 -2
- package/dist/core/logger/console.js +0 -21
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import { AstroIntegrationLogger } from "
|
|
4
|
+
import { AstroIntegrationLogger } from "../logger/core.js";
|
|
5
5
|
import { telemetry } from "../../events/index.js";
|
|
6
6
|
import { eventCliSession } from "../../events/session.js";
|
|
7
7
|
import { runHookConfigDone, runHookConfigSetup } from "../../integrations/hooks.js";
|
|
8
8
|
import { resolveConfig } from "../config/config.js";
|
|
9
|
-
import {
|
|
9
|
+
import { loadOrCreateNodeLogger } from "../logger/load.js";
|
|
10
10
|
import { createSettings } from "../config/settings.js";
|
|
11
11
|
import { createRoutesList } from "../routing/create-manifest.js";
|
|
12
12
|
import { getPrerenderDefault } from "../../prerender/utils.js";
|
|
@@ -15,8 +15,8 @@ import createStaticPreviewServer from "./static-preview-server.js";
|
|
|
15
15
|
import { getResolvedHostForHttpServer } from "./util.js";
|
|
16
16
|
async function preview(inlineConfig) {
|
|
17
17
|
ensureProcessNodeEnv("production");
|
|
18
|
-
const logger = createNodeLogger(inlineConfig);
|
|
19
18
|
const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, "preview");
|
|
19
|
+
const logger = await loadOrCreateNodeLogger(astroConfig, inlineConfig ?? {});
|
|
20
20
|
telemetry.record(eventCliSession("preview", userConfig));
|
|
21
21
|
const _settings = await createSettings(
|
|
22
22
|
astroConfig,
|
|
@@ -67,6 +67,7 @@ async function preview(inlineConfig) {
|
|
|
67
67
|
base: settings.config.base,
|
|
68
68
|
logger: new AstroIntegrationLogger(logger.options, settings.adapter.name),
|
|
69
69
|
headers: settings.config.server.headers,
|
|
70
|
+
allowedHosts: settings.config.server.allowedHosts,
|
|
70
71
|
root: settings.config.root
|
|
71
72
|
});
|
|
72
73
|
return server;
|
|
@@ -467,6 +467,26 @@ class RenderContext {
|
|
|
467
467
|
renderContext.result?.scriptHashes.push(hash);
|
|
468
468
|
}
|
|
469
469
|
};
|
|
470
|
+
},
|
|
471
|
+
get logger() {
|
|
472
|
+
if (!pipeline.manifest.experimentalLogger) {
|
|
473
|
+
pipeline.logger.warn(
|
|
474
|
+
null,
|
|
475
|
+
"The Astro.logger is available only when experimental.logger is defined."
|
|
476
|
+
);
|
|
477
|
+
return void 0;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
info(msg) {
|
|
481
|
+
pipeline.logger.info(null, msg);
|
|
482
|
+
},
|
|
483
|
+
warn(msg) {
|
|
484
|
+
pipeline.logger.warn(null, msg);
|
|
485
|
+
},
|
|
486
|
+
error(msg) {
|
|
487
|
+
pipeline.logger.error(null, msg);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
470
490
|
}
|
|
471
491
|
};
|
|
472
492
|
}
|
|
@@ -544,7 +564,8 @@ class RenderContext {
|
|
|
544
564
|
extraHead: [],
|
|
545
565
|
extraStyleHashes,
|
|
546
566
|
extraScriptHashes,
|
|
547
|
-
propagators: /* @__PURE__ */ new Set()
|
|
567
|
+
propagators: /* @__PURE__ */ new Set(),
|
|
568
|
+
templateDepth: 0
|
|
548
569
|
},
|
|
549
570
|
cspDestination: manifest.csp?.cspDestination ?? (routeData.prerender ? "meta" : "header"),
|
|
550
571
|
shouldInjectCspMetaTags,
|
|
@@ -698,6 +719,19 @@ class RenderContext {
|
|
|
698
719
|
renderContext.result?.scriptHashes.push(hash);
|
|
699
720
|
}
|
|
700
721
|
};
|
|
722
|
+
},
|
|
723
|
+
get logger() {
|
|
724
|
+
return {
|
|
725
|
+
info(msg) {
|
|
726
|
+
pipeline.logger.info(null, msg);
|
|
727
|
+
},
|
|
728
|
+
warn(msg) {
|
|
729
|
+
pipeline.logger.warn(null, msg);
|
|
730
|
+
},
|
|
731
|
+
error(msg) {
|
|
732
|
+
pipeline.logger.error(null, msg);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
701
735
|
}
|
|
702
736
|
};
|
|
703
737
|
}
|
package/dist/core/sync/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { eventCliSession } from "../../events/session.js";
|
|
|
17
17
|
import { runHookConfigDone, runHookConfigSetup } from "../../integrations/hooks.js";
|
|
18
18
|
import { getTimeStat } from "../build/util.js";
|
|
19
19
|
import { resolveConfig } from "../config/config.js";
|
|
20
|
-
import {
|
|
20
|
+
import { loadOrCreateNodeLogger } from "../logger/load.js";
|
|
21
21
|
import { createSettings } from "../config/settings.js";
|
|
22
22
|
import { createVite } from "../create-vite.js";
|
|
23
23
|
import {
|
|
@@ -32,8 +32,8 @@ import { ensureProcessNodeEnv } from "../util.js";
|
|
|
32
32
|
import { normalizePath } from "../viteUtils.js";
|
|
33
33
|
async function sync(inlineConfig, { fs, telemetry: _telemetry = false } = {}) {
|
|
34
34
|
ensureProcessNodeEnv("production");
|
|
35
|
-
const logger = createNodeLogger(inlineConfig);
|
|
36
35
|
const { astroConfig, userConfig } = await resolveConfig(inlineConfig ?? {}, "sync");
|
|
36
|
+
const logger = await loadOrCreateNodeLogger(astroConfig, inlineConfig ?? {});
|
|
37
37
|
if (_telemetry) {
|
|
38
38
|
telemetry.record(eventCliSession("sync", userConfig));
|
|
39
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type WaitUntilHook = (this: void, promise: Promise<unknown>) => void;
|
|
File without changes
|
|
@@ -142,6 +142,10 @@ async function createSerializedManifest(settings, encodedKey) {
|
|
|
142
142
|
isStrictDynamic: getStrictDynamic(settings.config.security.csp)
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
+
let experimentalLogger = void 0;
|
|
146
|
+
if (settings.config.experimental.logger) {
|
|
147
|
+
experimentalLogger = settings.config.experimental.logger;
|
|
148
|
+
}
|
|
145
149
|
return {
|
|
146
150
|
rootDir: settings.config.root.toString(),
|
|
147
151
|
srcDir: settings.config.srcDir.toString(),
|
|
@@ -195,7 +199,8 @@ async function createSerializedManifest(settings, encodedKey) {
|
|
|
195
199
|
},
|
|
196
200
|
logLevel: settings.logLevel,
|
|
197
201
|
shouldInjectCspMetaTags: false,
|
|
198
|
-
experimentalQueuedRendering: settings.config.experimental?.queuedRendering
|
|
202
|
+
experimentalQueuedRendering: settings.config.experimental?.queuedRendering,
|
|
203
|
+
experimentalLogger
|
|
199
204
|
};
|
|
200
205
|
}
|
|
201
206
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { addAttribute, createAstro, createComponent, createTransitionScope, defineScriptVars, defineStyleVars, Fragment, maybeRenderHead, mergeSlots, render, renderComponent, renderHead, renderScript, renderSlot, renderTransition, spreadAttributes, unescapeHTML, } from '../server/index.js';
|
|
1
|
+
export { addAttribute, createAstro, createComponent, createTransitionScope, defineScriptVars, defineStyleVars, Fragment, maybeRenderHead, mergeSlots, render, renderComponent, renderHead, renderScript, renderSlot, renderTransition, templateEnter, templateExit, spreadAttributes, unescapeHTML, } from '../server/index.js';
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
renderScript,
|
|
15
15
|
renderSlot,
|
|
16
16
|
renderTransition,
|
|
17
|
+
templateEnter,
|
|
18
|
+
templateExit,
|
|
17
19
|
spreadAttributes,
|
|
18
20
|
unescapeHTML
|
|
19
21
|
} from "../server/index.js";
|
|
@@ -34,5 +36,7 @@ export {
|
|
|
34
36
|
renderSlot,
|
|
35
37
|
renderTransition,
|
|
36
38
|
spreadAttributes,
|
|
39
|
+
templateEnter,
|
|
40
|
+
templateExit,
|
|
37
41
|
unescapeHTML
|
|
38
42
|
};
|
|
@@ -6,6 +6,7 @@ export { renderJSX } from './jsx.js';
|
|
|
6
6
|
export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
|
|
7
7
|
export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, Renderer as Renderer, renderComponent, renderHead, renderHTMLElement, renderPage, renderScript, renderScriptElement, renderSlot, renderSlotToString, renderTemplate as render, renderTemplate, renderToString, renderUniqueStylesheet, voidElementNames, } from './render/index.js';
|
|
8
8
|
export type { ServerIslandComponent } from './render/server-islands.js';
|
|
9
|
+
export { templateEnter, templateExit } from './render/template-depth.js';
|
|
9
10
|
export { createTransitionScope, renderTransition } from './transition.js';
|
|
10
11
|
export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
|
|
11
12
|
export declare function spreadAttributes(values?: Record<any, any>, _name?: string, { class: scopedClassName }?: {
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
renderUniqueStylesheet,
|
|
32
32
|
voidElementNames
|
|
33
33
|
} from "./render/index.js";
|
|
34
|
+
import { templateEnter, templateExit } from "./render/template-depth.js";
|
|
34
35
|
import { createTransitionScope, renderTransition } from "./transition.js";
|
|
35
36
|
import { markHTMLString as markHTMLString2 } from "./escape.js";
|
|
36
37
|
import { addAttribute as addAttribute2, Renderer as Renderer2 } from "./render/index.js";
|
|
@@ -117,6 +118,8 @@ export {
|
|
|
117
118
|
renderTransition,
|
|
118
119
|
renderUniqueStylesheet,
|
|
119
120
|
spreadAttributes,
|
|
121
|
+
templateEnter,
|
|
122
|
+
templateExit,
|
|
120
123
|
unescapeHTML,
|
|
121
124
|
voidElementNames
|
|
122
125
|
};
|
|
@@ -61,12 +61,28 @@ function stringifyChunk(result, chunk) {
|
|
|
61
61
|
}
|
|
62
62
|
case "script": {
|
|
63
63
|
const { id, content } = instruction;
|
|
64
|
+
if (result._metadata.templateDepth > 0) {
|
|
65
|
+
return content;
|
|
66
|
+
}
|
|
64
67
|
if (result._metadata.renderedScripts.has(id)) {
|
|
65
68
|
return "";
|
|
66
69
|
}
|
|
67
70
|
result._metadata.renderedScripts.add(id);
|
|
68
71
|
return content;
|
|
69
72
|
}
|
|
73
|
+
case "template-enter": {
|
|
74
|
+
result._metadata.templateDepth++;
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
case "template-exit": {
|
|
78
|
+
if (result._metadata.templateDepth <= 0) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"Unexpected template-exit instruction without a matching template-enter. This may indicate that the compiler emitted unbalanced template boundaries, or that a component manually injected a template-exit render instruction."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
result._metadata.templateDepth--;
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
70
86
|
default: {
|
|
71
87
|
throw new Error(`Unknown chunk type: ${chunk.type}`);
|
|
72
88
|
}
|
|
@@ -26,6 +26,12 @@ export type RenderScriptInstruction = {
|
|
|
26
26
|
id: string;
|
|
27
27
|
content: string;
|
|
28
28
|
};
|
|
29
|
-
export type
|
|
29
|
+
export type TemplateEnterInstruction = {
|
|
30
|
+
type: 'template-enter';
|
|
31
|
+
};
|
|
32
|
+
export type TemplateExitInstruction = {
|
|
33
|
+
type: 'template-exit';
|
|
34
|
+
};
|
|
35
|
+
export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction | RendererHydrationScriptInstruction | ServerIslandRuntimeInstruction | RenderScriptInstruction | TemplateEnterInstruction | TemplateExitInstruction;
|
|
30
36
|
export declare function createRenderInstruction<T extends RenderInstruction>(instruction: T): T;
|
|
31
37
|
export declare function isRenderInstruction(chunk: any): chunk is RenderInstruction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SSRResult } from '../../../types/public/internal.js';
|
|
2
|
+
/**
|
|
3
|
+
* Emitted by the compiler when entering an HTML `<template>` element.
|
|
4
|
+
*/
|
|
5
|
+
export declare function templateEnter(_result: SSRResult): {
|
|
6
|
+
type: "template-enter";
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Emitted by the compiler when exiting an HTML `<template>` element.
|
|
10
|
+
*/
|
|
11
|
+
export declare function templateExit(_result: SSRResult): {
|
|
12
|
+
type: "template-exit";
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRenderInstruction } from "./instruction.js";
|
|
2
|
+
function templateEnter(_result) {
|
|
3
|
+
return createRenderInstruction({ type: "template-enter" });
|
|
4
|
+
}
|
|
5
|
+
function templateExit(_result) {
|
|
6
|
+
return createRenderInstruction({ type: "template-exit" });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
templateEnter,
|
|
10
|
+
templateExit
|
|
11
|
+
};
|
package/dist/types/astro.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
1
2
|
import type { AstroTimer } from '../core/config/timer.js';
|
|
2
3
|
import type { TSConfig } from '../core/config/tsconfig.js';
|
|
3
4
|
import type { AstroLogger, AstroLoggerLevel } from '../core/logger/core.js';
|
|
@@ -66,6 +67,7 @@ export interface AstroSettings {
|
|
|
66
67
|
styleHashes: Required<CspObject['styleDirective']>['hashes'];
|
|
67
68
|
};
|
|
68
69
|
logLevel: AstroLoggerLevel;
|
|
70
|
+
fontsHttpServer: Server | null;
|
|
69
71
|
}
|
|
70
72
|
/** Generic interface for a component (Astro, Svelte, React, etc.) */
|
|
71
73
|
export interface ComponentInstance {
|
|
@@ -137,3 +137,4 @@ export type InferGetStaticPropsType<T> = T extends (opts: GetStaticPathsOptions)
|
|
|
137
137
|
export type Params = Record<string, string | undefined>;
|
|
138
138
|
export type Props = Record<string, unknown>;
|
|
139
139
|
export type CodeLanguage = BundledLanguage | LanguageRegistration | SpecialLanguage;
|
|
140
|
+
export type { AstroLoggerDestination, AstroLoggerLevel, AstroLoggerMessage, } from '../../core/logger/core.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { OutgoingHttpHeaders } from 'node:http';
|
|
2
2
|
import type { RemotePattern } from '@astrojs/internal-helpers/remote';
|
|
3
3
|
import type { RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig, Smartypants, SyntaxHighlightConfigType } from '@astrojs/markdown-remark';
|
|
4
|
-
import type { Config as SvgoConfig } from 'svgo';
|
|
5
4
|
import type { UserConfig as OriginalViteUserConfig, SSROptions as ViteSSROptions } from 'vite';
|
|
6
5
|
import type { FontFamily, FontProvider } from '../../assets/fonts/types.js';
|
|
7
6
|
import type { ImageFit, ImageLayout } from '../../assets/types.js';
|
|
@@ -14,6 +13,8 @@ import type { AstroLoggerLevel } from '../../core/logger/core.js';
|
|
|
14
13
|
import type { SessionConfig, SessionDriverConfig, SessionDriverName } from '../../core/session/types.js';
|
|
15
14
|
import type { EnvSchema } from '../../env/schema.js';
|
|
16
15
|
import type { AstroIntegration } from './integrations.js';
|
|
16
|
+
import type { SvgOptimizer } from '../../assets/svg/types.js';
|
|
17
|
+
import type { LoggerHandlerConfig } from '../../core/logger/config.js';
|
|
17
18
|
export type Locales = (string | {
|
|
18
19
|
codes: [string, ...string[]];
|
|
19
20
|
path: string;
|
|
@@ -21,6 +22,7 @@ export type Locales = (string | {
|
|
|
21
22
|
export type { FontProvider };
|
|
22
23
|
export type { CspAlgorithm, CspHash };
|
|
23
24
|
export type { RemotePattern };
|
|
25
|
+
export type { SvgOptimizer };
|
|
24
26
|
export type CspStyleDirective = {
|
|
25
27
|
hashes?: CspHash[];
|
|
26
28
|
resources?: string[];
|
|
@@ -416,24 +418,27 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
416
418
|
/**
|
|
417
419
|
* @docs
|
|
418
420
|
* @name compressHTML
|
|
419
|
-
* @type {boolean}
|
|
421
|
+
* @type {boolean | "jsx"}
|
|
420
422
|
* @default `true`
|
|
421
423
|
* @description
|
|
422
424
|
*
|
|
423
|
-
*
|
|
425
|
+
* Controls how Astro handles whitespace in your HTML. This affects both development mode and the final build output.
|
|
426
|
+
*
|
|
427
|
+
* By default, Astro removes whitespace from your HTML, including line breaks, in a lossless manner from `.astro` components. Some whitespace may be preserved as needed to maintain the visual rendering of your HTML.
|
|
424
428
|
*
|
|
425
|
-
*
|
|
426
|
-
* Some whitespace may be kept as needed to preserve the visual rendering of your HTML. This occurs both in development mode and in the final build.
|
|
429
|
+
* Setting this option to `"jsx"` instead applies the JSX whitespace stripping rules used by frameworks like React. Leading and trailing whitespace is only preserved when explicitly included in the source code through constructs such as `{" "}`, and is otherwise removed entirely.
|
|
427
430
|
*
|
|
428
|
-
*
|
|
431
|
+
* Setting this option to false disables HTML compression and preserves all whitespace.
|
|
429
432
|
*
|
|
430
433
|
* ```js
|
|
431
434
|
* {
|
|
432
435
|
* compressHTML: false
|
|
436
|
+
* // or:
|
|
437
|
+
* // compressHTML: 'jsx'
|
|
433
438
|
* }
|
|
434
439
|
* ```
|
|
435
440
|
*/
|
|
436
|
-
compressHTML?: boolean;
|
|
441
|
+
compressHTML?: boolean | 'jsx';
|
|
437
442
|
/**
|
|
438
443
|
* @docs
|
|
439
444
|
* @name scopedStyleStrategy
|
|
@@ -1752,14 +1757,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
1752
1757
|
* }
|
|
1753
1758
|
* ```
|
|
1754
1759
|
*
|
|
1755
|
-
* You can use wildcards to define the permitted `hostname` and `pathname` values as described below. Otherwise, only the exact values provided will be configured
|
|
1756
|
-
* `hostname`:
|
|
1757
|
-
* - Start with '**.' to allow all subdomains ('endsWith').
|
|
1758
|
-
* - Start with '*.' to allow only one level of subdomain.
|
|
1760
|
+
* You can use wildcards to define the permitted `hostname` and `pathname` values as described below. Otherwise, only the exact values provided will be configured.
|
|
1759
1761
|
*
|
|
1760
|
-
* `
|
|
1761
|
-
* -
|
|
1762
|
-
* -
|
|
1762
|
+
* `hostname` patterns:
|
|
1763
|
+
* - Start with `**.` to allow all subdomains (like `endsWith`).
|
|
1764
|
+
* - Start with `*.` to allow only one level of subdomain.
|
|
1765
|
+
*
|
|
1766
|
+
* `pathname` patterns:
|
|
1767
|
+
* - End with `/**` to allow all sub-routes (like `startsWith`).
|
|
1768
|
+
* - End with `/*` to allow only one level of sub-route.
|
|
1763
1769
|
|
|
1764
1770
|
*/
|
|
1765
1771
|
remotePatterns?: Partial<RemotePattern>[];
|
|
@@ -2706,14 +2712,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
2706
2712
|
*/
|
|
2707
2713
|
chromeDevtoolsWorkspace?: boolean;
|
|
2708
2714
|
/**
|
|
2709
|
-
* @name experimental.
|
|
2710
|
-
* @type {
|
|
2711
|
-
* @default `
|
|
2715
|
+
* @name experimental.svgOptimizer
|
|
2716
|
+
* @type {SvgOptimizer}
|
|
2717
|
+
* @default `undefined`
|
|
2718
|
+
* @version 6.2.0
|
|
2712
2719
|
* @description
|
|
2713
|
-
* Enable SVG optimization
|
|
2714
|
-
*
|
|
2715
|
-
* Set to `true` to enable optimization with default settings, or pass a configuration
|
|
2716
|
-
* object to customize SVGO behavior.
|
|
2720
|
+
* Enable SVG optimization at build time.
|
|
2717
2721
|
*
|
|
2718
2722
|
* When enabled, all imported SVG files will be optimized for smaller file sizes
|
|
2719
2723
|
* and better performance while maintaining visual quality.
|
|
@@ -2722,32 +2726,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
2722
2726
|
* {
|
|
2723
2727
|
* experimental: {
|
|
2724
2728
|
* // Enable with defaults
|
|
2725
|
-
*
|
|
2726
|
-
* }
|
|
2727
|
-
* }
|
|
2728
|
-
* ```
|
|
2729
|
-
*
|
|
2730
|
-
* To customize optimization, pass a [SVGO configuration object](https://svgo.dev/):
|
|
2731
|
-
*
|
|
2732
|
-
* ```js
|
|
2733
|
-
* {
|
|
2734
|
-
* experimental: {
|
|
2735
|
-
* svgo: {
|
|
2736
|
-
* plugins: [
|
|
2737
|
-
* 'preset-default',
|
|
2738
|
-
* {
|
|
2739
|
-
* name: 'removeViewBox',
|
|
2740
|
-
* active: false
|
|
2741
|
-
* }
|
|
2742
|
-
* ]
|
|
2743
|
-
* }
|
|
2729
|
+
* svgOptimizer: svgoOptimizer()
|
|
2744
2730
|
* }
|
|
2745
2731
|
* }
|
|
2746
2732
|
* ```
|
|
2747
2733
|
*
|
|
2748
|
-
* See the [experimental
|
|
2734
|
+
* See the [experimental SVG optimization docs](https://docs.astro.build/en/reference/experimental-flags/svg-optimization/) for more information.
|
|
2749
2735
|
*/
|
|
2750
|
-
|
|
2736
|
+
svgOptimizer?: SvgOptimizer;
|
|
2751
2737
|
/**
|
|
2752
2738
|
* @name experimental.cache
|
|
2753
2739
|
* @type {object}
|
|
@@ -2887,6 +2873,32 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
2887
2873
|
*/
|
|
2888
2874
|
contentCache?: boolean;
|
|
2889
2875
|
};
|
|
2876
|
+
/**
|
|
2877
|
+
* @name experimental.logger
|
|
2878
|
+
* @type {{ entrypoint: string; config?: Record<string, unknown> }}
|
|
2879
|
+
* @default `undefined`
|
|
2880
|
+
* @version 6.2.0
|
|
2881
|
+
* @description
|
|
2882
|
+
*
|
|
2883
|
+
* Configure a custom logger by defining its entrypoint and, optionally, providing a serializable configuration:
|
|
2884
|
+
*
|
|
2885
|
+
* ```js
|
|
2886
|
+
* // astro.config.mjs
|
|
2887
|
+
* import { defineConfig } from 'astro/config';
|
|
2888
|
+
*
|
|
2889
|
+
* export default defineConfig({
|
|
2890
|
+
* experimental: {
|
|
2891
|
+
* logger: {
|
|
2892
|
+
* entrypoint: "@org/astro-logger",
|
|
2893
|
+
* config: {
|
|
2894
|
+
* level: "error"
|
|
2895
|
+
* }
|
|
2896
|
+
* }
|
|
2897
|
+
* }
|
|
2898
|
+
* });
|
|
2899
|
+
* ```
|
|
2900
|
+
*/
|
|
2901
|
+
logger?: LoggerHandlerConfig;
|
|
2890
2902
|
};
|
|
2891
2903
|
}
|
|
2892
2904
|
/**
|
|
@@ -530,6 +530,23 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
|
|
530
530
|
*/
|
|
531
531
|
insertScriptHash: (hash: CspHash) => void;
|
|
532
532
|
} | undefined;
|
|
533
|
+
/**
|
|
534
|
+
* It exposes utilities for logging messages.
|
|
535
|
+
*/
|
|
536
|
+
logger: {
|
|
537
|
+
/**
|
|
538
|
+
* Logs a message with `info` level.
|
|
539
|
+
*/
|
|
540
|
+
info: (msg: string) => void;
|
|
541
|
+
/**
|
|
542
|
+
* Logs a message with `warn` level.
|
|
543
|
+
*/
|
|
544
|
+
warn: (msg: string) => void;
|
|
545
|
+
/**
|
|
546
|
+
* Logs a message with `error` level.
|
|
547
|
+
*/
|
|
548
|
+
error: (msg: string) => void;
|
|
549
|
+
} | undefined;
|
|
533
550
|
/**
|
|
534
551
|
* The route currently rendered. It's stripped of the `srcDir` and the `pages` folder, and it doesn't contain the extension.
|
|
535
552
|
*
|
|
@@ -23,3 +23,4 @@ export type * from './manifest.js';
|
|
|
23
23
|
export type * from './preview.js';
|
|
24
24
|
export type * from './toolbar.js';
|
|
25
25
|
export type * from './view-transitions.js';
|
|
26
|
+
export type { AstroLoggerDestination, AstroLoggerMessage, AstroLoggerLevel, } from '../../core/logger/core.js';
|
|
@@ -200,7 +200,7 @@ export interface SSRResult {
|
|
|
200
200
|
* Map of directive name (e.g. `load`) to the directive script code
|
|
201
201
|
*/
|
|
202
202
|
clientDirectives: Map<string, string>;
|
|
203
|
-
compressHTML: boolean;
|
|
203
|
+
compressHTML: boolean | 'jsx';
|
|
204
204
|
partial: boolean;
|
|
205
205
|
/**
|
|
206
206
|
* Only used for logging
|
|
@@ -295,6 +295,12 @@ export interface SSRMetadata {
|
|
|
295
295
|
extraStyleHashes: string[];
|
|
296
296
|
extraScriptHashes: string[];
|
|
297
297
|
propagators: Set<AstroComponentInstance | ServerIslandComponent>;
|
|
298
|
+
/**
|
|
299
|
+
* Tracks nesting depth of HTML `<template>` elements during rendering.
|
|
300
|
+
* Scripts rendered inside `<template>` tags should not be deduplicated,
|
|
301
|
+
* because template content is inert and scripts inside don't execute.
|
|
302
|
+
*/
|
|
303
|
+
templateDepth: number;
|
|
298
304
|
}
|
|
299
305
|
export type SSRError = Error & ViteErrorPayload['err'];
|
|
300
306
|
export interface InternalInjectedRoute {
|
|
@@ -16,6 +16,11 @@ export interface PreviewServerParams {
|
|
|
16
16
|
base: string;
|
|
17
17
|
logger: AstroIntegrationLogger;
|
|
18
18
|
headers?: OutgoingHttpHeaders;
|
|
19
|
+
/**
|
|
20
|
+
* Configures allowed hosts that the preview server can respond to.
|
|
21
|
+
* If the `Host` header doesn't match one of the allowed hosts, the server will return a 403 response.
|
|
22
|
+
*/
|
|
23
|
+
allowedHosts?: string[] | true;
|
|
19
24
|
root: URL;
|
|
20
25
|
}
|
|
21
26
|
export type CreatePreviewServer = (params: PreviewServerParams) => PreviewServer | Promise<PreviewServer>;
|
|
@@ -10,7 +10,6 @@ import { RunnablePipeline } from './pipeline.js';
|
|
|
10
10
|
import type { DevMatch, LogRequestPayload } from '../core/app/base.js';
|
|
11
11
|
export declare class AstroServerApp extends BaseApp<RunnablePipeline> {
|
|
12
12
|
settings: AstroSettings;
|
|
13
|
-
logger: AstroLogger;
|
|
14
13
|
loader: ModuleLoader;
|
|
15
14
|
manifestData: RoutesList;
|
|
16
15
|
currentRenderContext: RenderContext | undefined;
|
|
@@ -19,14 +19,12 @@ import { matchRoute } from "../core/routing/dev.js";
|
|
|
19
19
|
import { req } from "../core/messages/runtime.js";
|
|
20
20
|
class AstroServerApp extends BaseApp {
|
|
21
21
|
settings;
|
|
22
|
-
logger;
|
|
23
22
|
loader;
|
|
24
23
|
manifestData;
|
|
25
24
|
currentRenderContext = void 0;
|
|
26
25
|
constructor(manifest, streaming = true, logger, manifestData, loader, settings, getDebugInfo) {
|
|
27
26
|
super(manifest, streaming, settings, logger, loader, manifestData, getDebugInfo);
|
|
28
27
|
this.settings = settings;
|
|
29
|
-
this.logger = logger;
|
|
30
28
|
this.loader = loader;
|
|
31
29
|
this.manifestData = manifestData;
|
|
32
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type http from 'node:http';
|
|
2
|
-
import { AstroLogger } from '../core/logger/core.js';
|
|
2
|
+
import type { AstroLogger } from '../core/logger/core.js';
|
|
3
3
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
4
4
|
import type { AstroSettings } from '../types/astro.js';
|
|
5
5
|
import type { DevServerController } from '../vite-plugin-astro-server/controller.js';
|
|
@@ -9,14 +9,10 @@ import { BuildTimeAstroVersionProvider } from "../cli/infra/build-time-astro-ver
|
|
|
9
9
|
import { PassthroughTextStyler } from "../cli/infra/passthrough-text-styler.js";
|
|
10
10
|
import { ProcessOperatingSystemProvider } from "../cli/infra/process-operating-system-provider.js";
|
|
11
11
|
import { TinyexecCommandExecutor } from "../cli/infra/tinyexec-command-executor.js";
|
|
12
|
-
import { AstroLogger } from "../core/logger/core.js";
|
|
13
|
-
import { nodeLogDestination } from "../core/logger/node.js";
|
|
14
12
|
import { AstroServerApp } from "./app.js";
|
|
13
|
+
import { createNodeLoggerFromFlags } from "../core/logger/impls/node.js";
|
|
15
14
|
async function createAstroServerApp(controller, settings, loader, logger) {
|
|
16
|
-
const actualLogger = logger ??
|
|
17
|
-
destination: nodeLogDestination,
|
|
18
|
-
level: settings.logLevel
|
|
19
|
-
});
|
|
15
|
+
const actualLogger = logger ?? createNodeLoggerFromFlags({});
|
|
20
16
|
const routesList = { routes: routes.map((r) => r.routeData) };
|
|
21
17
|
const debugInfoProvider = new DevDebugInfoProvider({
|
|
22
18
|
config: settings.config,
|
|
@@ -5,5 +5,5 @@ interface LoadFallbackPluginParams {
|
|
|
5
5
|
fs?: NodeFileSystemModule;
|
|
6
6
|
root: URL;
|
|
7
7
|
}
|
|
8
|
-
export default function loadFallbackPlugin({ fs, root
|
|
8
|
+
export default function loadFallbackPlugin({ fs, root }: LoadFallbackPluginParams): vite.Plugin[];
|
|
9
9
|
export {};
|
|
@@ -3,12 +3,9 @@ import npath from "node:path";
|
|
|
3
3
|
import { slash } from "../core/path.js";
|
|
4
4
|
import { cleanUrl } from "../vite-plugin-utils/index.js";
|
|
5
5
|
const FALLBACK_FLAG = "astroFallbackFlag";
|
|
6
|
-
function loadFallbackPlugin({
|
|
7
|
-
fs,
|
|
8
|
-
root
|
|
9
|
-
}) {
|
|
6
|
+
function loadFallbackPlugin({ fs, root }) {
|
|
10
7
|
if (!fs || fs === nodeFs || fs.default === nodeFs) {
|
|
11
|
-
return
|
|
8
|
+
return [];
|
|
12
9
|
}
|
|
13
10
|
const tryLoadModule = async (id) => {
|
|
14
11
|
try {
|