astro 6.1.5 → 6.1.6
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/actions/integration.js +1 -1
- package/dist/assets/build/generate.d.ts +2 -2
- package/dist/assets/fonts/core/compute-font-families-assets.d.ts +2 -2
- package/dist/assets/fonts/core/get-or-create-font-family-assets.d.ts +2 -2
- package/dist/assets/fonts/vite-plugin-fonts.d.ts +2 -2
- package/dist/assets/vite-plugin-assets.d.ts +2 -2
- package/dist/cli/create-key/core/create-key.d.ts +2 -2
- package/dist/cli/docs/core/open-docs.d.ts +2 -2
- package/dist/cli/flags.d.ts +2 -2
- package/dist/cli/flags.js +1 -1
- package/dist/cli/info/core/info.d.ts +2 -2
- package/dist/cli/info/infra/tinyclip-clipboard.d.ts +2 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/infra/logger-help-display.d.ts +2 -2
- package/dist/cli/install-package.d.ts +2 -2
- package/dist/container/index.js +3 -3
- package/dist/content/content-layer.d.ts +2 -2
- package/dist/content/content-layer.js +3 -3
- package/dist/content/instance.d.ts +2 -2
- package/dist/content/server-listeners.d.ts +2 -2
- package/dist/content/types-generator.d.ts +2 -2
- package/dist/content/utils.d.ts +2 -2
- package/dist/content/vite-plugin-content-imports.d.ts +2 -2
- package/dist/core/app/base.d.ts +2 -2
- package/dist/core/app/base.js +3 -3
- package/dist/core/app/dev/app.d.ts +4 -4
- package/dist/core/app/logging.d.ts +2 -2
- package/dist/core/app/logging.js +3 -3
- package/dist/core/app/types.d.ts +2 -2
- package/dist/core/base-pipeline.d.ts +3 -3
- package/dist/core/build/generate.d.ts +2 -2
- package/dist/core/build/index.d.ts +2 -2
- package/dist/core/build/page-data.d.ts +2 -2
- package/dist/core/build/types.d.ts +2 -2
- package/dist/core/cache/runtime/noop.d.ts +2 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.d.ts +2 -2
- package/dist/core/dev/adapter-validation.d.ts +3 -3
- package/dist/core/dev/container.d.ts +3 -3
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/logger/console.d.ts +2 -2
- package/dist/core/logger/console.js +4 -1
- package/dist/core/logger/core.d.ts +48 -21
- package/dist/core/logger/core.js +8 -4
- package/dist/core/logger/node.d.ts +4 -4
- package/dist/core/logger/node.js +21 -9
- package/dist/core/logger/vite.d.ts +1 -1
- package/dist/core/messages/runtime.d.ts +2 -2
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/preview/static-preview-server.d.ts +2 -2
- package/dist/core/render/params-and-props.d.ts +2 -2
- package/dist/core/render/route-cache.d.ts +3 -3
- package/dist/core/render/slots.d.ts +2 -2
- package/dist/core/request.d.ts +2 -2
- package/dist/core/routing/create-manifest.d.ts +3 -3
- package/dist/core/routing/prerender.d.ts +2 -2
- package/dist/core/routing/rewrite.d.ts +2 -2
- package/dist/core/sync/index.d.ts +3 -3
- package/dist/integrations/features-validation.d.ts +2 -2
- package/dist/integrations/hooks.d.ts +13 -13
- package/dist/runtime/server/endpoint.d.ts +2 -2
- package/dist/runtime/server/escape.d.ts +8 -0
- package/dist/runtime/server/escape.js +4 -0
- package/dist/runtime/server/render/server-islands.js +5 -12
- package/dist/runtime/server/render/util.js +2 -5
- package/dist/types/astro.d.ts +3 -3
- package/dist/types/public/config.d.ts +2 -2
- package/dist/vite-plugin-app/app.d.ts +5 -5
- package/dist/vite-plugin-app/createAstroServerApp.d.ts +2 -2
- package/dist/vite-plugin-app/createAstroServerApp.js +3 -3
- package/dist/vite-plugin-astro/compile.d.ts +2 -2
- package/dist/vite-plugin-astro/hmr.d.ts +2 -2
- package/dist/vite-plugin-astro/index.d.ts +2 -2
- package/dist/vite-plugin-astro-server/base.d.ts +2 -2
- package/dist/vite-plugin-astro-server/error.d.ts +2 -2
- package/dist/vite-plugin-astro-server/plugin.d.ts +2 -2
- package/dist/vite-plugin-astro-server/sec-fetch.d.ts +2 -2
- package/dist/vite-plugin-hmr-reload/index.js +17 -0
- package/dist/vite-plugin-integrations-container/index.d.ts +2 -2
- package/dist/vite-plugin-markdown/index.d.ts +2 -2
- package/dist/vite-plugin-routes/index.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1,50 +1,77 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface AstroLoggerDestination<T> {
|
|
2
2
|
write: (chunk: T) => boolean;
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How the log should be formatted
|
|
6
|
+
* - 'default': how Astro usually format the logs
|
|
7
|
+
* - 'json': logs are formatted in JSON format
|
|
8
|
+
*/
|
|
9
|
+
export type AstroLoggerFormat = 'default' | 'json';
|
|
10
|
+
/**
|
|
11
|
+
* The level of logging. Priority is the following:
|
|
12
|
+
* 1. debug
|
|
13
|
+
* 2. error
|
|
14
|
+
* 3. warn
|
|
15
|
+
* 4. info
|
|
16
|
+
* 5. silent
|
|
17
|
+
*/
|
|
18
|
+
export type AstroLoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
5
19
|
/**
|
|
6
20
|
* Defined logger labels. Add more as needed, but keep them high-level & reusable,
|
|
7
21
|
* rather than specific to a single command, function, use, etc. The label will be
|
|
8
22
|
* shown in the log message to the user, so it should be relevant.
|
|
9
23
|
*/
|
|
10
|
-
type
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
-
level:
|
|
24
|
+
type AstroLoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'crypto' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'sync' | 'session' | 'toolbar' | 'assets' | 'env' | 'update' | 'adapter' | 'islands' | 'cache' | 'csp' | 'SKIP_FORMAT';
|
|
25
|
+
export interface AstroLogOptions {
|
|
26
|
+
destination: AstroLoggerDestination<AstroLogMessage>;
|
|
27
|
+
level: AstroLoggerLevel;
|
|
28
|
+
_format?: AstroLoggerFormat;
|
|
14
29
|
}
|
|
15
30
|
/** @lintignore */
|
|
16
31
|
export declare const dateTimeFormat: Intl.DateTimeFormat;
|
|
17
|
-
export interface
|
|
32
|
+
export interface AstroLogMessage {
|
|
33
|
+
/**
|
|
34
|
+
* Label associated to the message. Used by Astro for pretty logging
|
|
35
|
+
*/
|
|
18
36
|
label: string | null;
|
|
19
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The level of the log
|
|
39
|
+
*/
|
|
40
|
+
level: AstroLoggerLevel;
|
|
41
|
+
/**
|
|
42
|
+
* The message of the log
|
|
43
|
+
*/
|
|
20
44
|
message: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a newline should be appended to the end of the message i.e. message + '\n'
|
|
47
|
+
*/
|
|
21
48
|
newLine: boolean;
|
|
22
49
|
}
|
|
23
|
-
export declare const levels: Record<
|
|
24
|
-
export declare function isLogLevelEnabled(configuredLogLevel:
|
|
50
|
+
export declare const levels: Record<AstroLoggerLevel, number>;
|
|
51
|
+
export declare function isLogLevelEnabled(configuredLogLevel: AstroLoggerLevel, level: AstroLoggerLevel): boolean;
|
|
25
52
|
export declare function debug(...args: any[]): void;
|
|
26
53
|
/**
|
|
27
54
|
* Get the prefix for a log message.
|
|
28
55
|
* This includes the timestamp, log level, and label all properly formatted
|
|
29
56
|
* with colors. This is shared across different loggers, so it's defined here.
|
|
30
57
|
*/
|
|
31
|
-
export declare function getEventPrefix({ level, label }:
|
|
58
|
+
export declare function getEventPrefix({ level, label }: AstroLogMessage): string;
|
|
32
59
|
/** Print out a timer message for debug() */
|
|
33
60
|
export declare function timerMessage(message: string, startTime?: number): string;
|
|
34
|
-
export declare class
|
|
35
|
-
options:
|
|
36
|
-
constructor(options:
|
|
37
|
-
info(label:
|
|
38
|
-
warn(label:
|
|
39
|
-
error(label:
|
|
40
|
-
debug(label:
|
|
41
|
-
level():
|
|
61
|
+
export declare class AstroLogger {
|
|
62
|
+
options: AstroLogOptions;
|
|
63
|
+
constructor(options: AstroLogOptions);
|
|
64
|
+
info(label: AstroLoggerLabel | null, message: string, newLine?: boolean): void;
|
|
65
|
+
warn(label: AstroLoggerLabel | null, message: string, newLine?: boolean): void;
|
|
66
|
+
error(label: AstroLoggerLabel | null, message: string, newLine?: boolean): void;
|
|
67
|
+
debug(label: AstroLoggerLabel, ...messages: any[]): void;
|
|
68
|
+
level(): AstroLoggerLevel;
|
|
42
69
|
forkIntegrationLogger(label: string): AstroIntegrationLogger;
|
|
43
70
|
}
|
|
44
71
|
export declare class AstroIntegrationLogger {
|
|
45
|
-
options:
|
|
72
|
+
options: AstroLogOptions;
|
|
46
73
|
label: string;
|
|
47
|
-
constructor(logging:
|
|
74
|
+
constructor(logging: AstroLogOptions, label: string);
|
|
48
75
|
/**
|
|
49
76
|
* Creates a new logger instance with a new label, but the same log options.
|
|
50
77
|
*/
|
package/dist/core/logger/core.js
CHANGED
|
@@ -14,12 +14,13 @@ const levels = {
|
|
|
14
14
|
};
|
|
15
15
|
function log(opts, level, label, message, newLine = true) {
|
|
16
16
|
const logLevel = opts.level;
|
|
17
|
-
const dest = opts.
|
|
17
|
+
const dest = opts.destination;
|
|
18
18
|
const event = {
|
|
19
19
|
label,
|
|
20
20
|
level,
|
|
21
21
|
message,
|
|
22
|
-
newLine
|
|
22
|
+
newLine,
|
|
23
|
+
_format: opts._format
|
|
23
24
|
};
|
|
24
25
|
if (!isLogLevelEnabled(logLevel, level)) {
|
|
25
26
|
return;
|
|
@@ -71,9 +72,12 @@ function timerMessage(message, startTime = Date.now()) {
|
|
|
71
72
|
let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1e3).toFixed(1)}s`;
|
|
72
73
|
return `${message} ${colors.dim(timeDisplay)}`;
|
|
73
74
|
}
|
|
74
|
-
class
|
|
75
|
+
class AstroLogger {
|
|
75
76
|
options;
|
|
76
77
|
constructor(options) {
|
|
78
|
+
if (!options._format) {
|
|
79
|
+
options._format = "default";
|
|
80
|
+
}
|
|
77
81
|
this.options = options;
|
|
78
82
|
}
|
|
79
83
|
info(label, message, newLine = true) {
|
|
@@ -123,7 +127,7 @@ class AstroIntegrationLogger {
|
|
|
123
127
|
}
|
|
124
128
|
export {
|
|
125
129
|
AstroIntegrationLogger,
|
|
126
|
-
|
|
130
|
+
AstroLogger,
|
|
127
131
|
dateTimeFormat,
|
|
128
132
|
debug,
|
|
129
133
|
getEventPrefix,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AstroInlineConfig } from '../../types/public/config.js';
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
4
|
-
export declare const nodeLogDestination:
|
|
2
|
+
import { AstroLogger } from './core.js';
|
|
3
|
+
import { type AstroLogMessage, type AstroLoggerDestination } from './core.js';
|
|
4
|
+
export declare const nodeLogDestination: AstroLoggerDestination<AstroLogMessage>;
|
|
5
5
|
export declare function enableVerboseLogging(): void;
|
|
6
|
-
export declare function createNodeLogger(inlineConfig: AstroInlineConfig):
|
|
6
|
+
export declare function createNodeLogger(inlineConfig: AstroInlineConfig): AstroLogger;
|
package/dist/core/logger/node.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { createDebug, enable as obugEnable } from "obug";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AstroLogger } from "./core.js";
|
|
3
|
+
import {
|
|
4
|
+
getEventPrefix,
|
|
5
|
+
levels
|
|
6
|
+
} from "./core.js";
|
|
4
7
|
const nodeLogDestination = {
|
|
5
8
|
write(event) {
|
|
6
9
|
let dest = process.stderr;
|
|
7
10
|
if (levels[event.level] < levels["error"]) {
|
|
8
11
|
dest = process.stdout;
|
|
9
12
|
}
|
|
13
|
+
let format = event._format ?? "default";
|
|
10
14
|
let trailingLine = event.newLine ? "\n" : "";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
switch (format) {
|
|
16
|
+
case "json": {
|
|
17
|
+
dest.write(JSON.stringify({ message: event.message, label: event.label }) + trailingLine);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
case "default": {
|
|
21
|
+
if (event.label === "SKIP_FORMAT") {
|
|
22
|
+
dest.write(event.message + trailingLine);
|
|
23
|
+
} else {
|
|
24
|
+
dest.write(getEventPrefix(event) + " " + event.message + trailingLine);
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
15
28
|
}
|
|
16
|
-
return true;
|
|
17
29
|
}
|
|
18
30
|
};
|
|
19
31
|
const debuggers = {};
|
|
@@ -33,8 +45,8 @@ function enableVerboseLogging() {
|
|
|
33
45
|
}
|
|
34
46
|
function createNodeLogger(inlineConfig) {
|
|
35
47
|
if (inlineConfig.logger) return inlineConfig.logger;
|
|
36
|
-
return new
|
|
37
|
-
|
|
48
|
+
return new AstroLogger({
|
|
49
|
+
destination: nodeLogDestination,
|
|
38
50
|
level: inlineConfig.logLevel ?? "info"
|
|
39
51
|
});
|
|
40
52
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LogLevel, Logger as ViteLogger } from 'vite';
|
|
2
|
-
import { type
|
|
2
|
+
import { type AstroLogger as AstroLogger } from './core.js';
|
|
3
3
|
export declare function createViteLogger(astroLogger: AstroLogger, viteLogLevel?: LogLevel): ViteLogger;
|
|
@@ -3,7 +3,7 @@ import type { $ZodError } from 'zod/v4/core';
|
|
|
3
3
|
import { type ErrorWithMetadata } from '../errors/index.js';
|
|
4
4
|
import type { AstroVersionProvider, TextStyler } from '../../cli/definitions.js';
|
|
5
5
|
import type { AstroConfig } from '../../types/public/index.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
7
7
|
/**
|
|
8
8
|
* Prestyled messages for the CLI. Used by astro CLI commands.
|
|
9
9
|
*/
|
|
@@ -60,4 +60,4 @@ export declare function printHelp({ commandName, headline, usage, tables, descri
|
|
|
60
60
|
tables?: Record<string, [command: string, help: string][]>;
|
|
61
61
|
description?: string;
|
|
62
62
|
}): void;
|
|
63
|
-
export declare function warnIfCspWithShiki(config: AstroConfig, logger:
|
|
63
|
+
export declare function warnIfCspWithShiki(config: AstroConfig, logger: AstroLogger): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type http from 'node:http';
|
|
2
2
|
import type { AstroSettings } from '../../types/astro.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
4
4
|
interface PreviewServer {
|
|
5
5
|
host?: string;
|
|
6
6
|
port: number;
|
|
@@ -8,5 +8,5 @@ interface PreviewServer {
|
|
|
8
8
|
closed(): Promise<void>;
|
|
9
9
|
stop(): Promise<void>;
|
|
10
10
|
}
|
|
11
|
-
export default function createStaticPreviewServer(settings: AstroSettings, logger:
|
|
11
|
+
export default function createStaticPreviewServer(settings: AstroSettings, logger: AstroLogger): Promise<PreviewServer>;
|
|
12
12
|
export {};
|
|
@@ -2,14 +2,14 @@ import type { ComponentInstance } from '../../types/astro.js';
|
|
|
2
2
|
import type { Params, Props } from '../../types/public/common.js';
|
|
3
3
|
import type { AstroConfig } from '../../types/public/index.js';
|
|
4
4
|
import type { RouteData } from '../../types/public/internal.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
6
6
|
import type { RouteCache } from './route-cache.js';
|
|
7
7
|
interface GetParamsAndPropsOptions {
|
|
8
8
|
mod: ComponentInstance | undefined;
|
|
9
9
|
routeData?: RouteData | undefined;
|
|
10
10
|
routeCache: RouteCache;
|
|
11
11
|
pathname: string;
|
|
12
|
-
logger:
|
|
12
|
+
logger: AstroLogger;
|
|
13
13
|
serverLike: boolean;
|
|
14
14
|
base: string;
|
|
15
15
|
trailingSlash: AstroConfig['trailingSlash'];
|
|
@@ -2,7 +2,7 @@ import type { ComponentInstance } from '../../types/astro.js';
|
|
|
2
2
|
import type { GetStaticPathsItem, GetStaticPathsResultKeyed, Params } from '../../types/public/common.js';
|
|
3
3
|
import type { AstroConfig, RuntimeMode } from '../../types/public/config.js';
|
|
4
4
|
import type { RouteData } from '../../types/public/internal.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
6
6
|
interface CallGetStaticPathsOptions {
|
|
7
7
|
mod: ComponentInstance | undefined;
|
|
8
8
|
route: RouteData;
|
|
@@ -24,12 +24,12 @@ export declare class RouteCache {
|
|
|
24
24
|
private logger;
|
|
25
25
|
private cache;
|
|
26
26
|
private runtimeMode;
|
|
27
|
-
constructor(logger:
|
|
27
|
+
constructor(logger: AstroLogger, runtimeMode?: RuntimeMode);
|
|
28
28
|
/** Clear the cache. */
|
|
29
29
|
clearAll(): void;
|
|
30
30
|
set(route: RouteData, entry: RouteCacheEntry): void;
|
|
31
31
|
get(route: RouteData): RouteCacheEntry | undefined;
|
|
32
32
|
key(route: RouteData): string;
|
|
33
33
|
}
|
|
34
|
-
export declare function findPathItemByKey(staticPaths: GetStaticPathsResultKeyed, params: Params, route: RouteData, logger:
|
|
34
|
+
export declare function findPathItemByKey(staticPaths: GetStaticPathsResultKeyed, params: Params, route: RouteData, logger: AstroLogger, trailingSlash: AstroConfig['trailingSlash']): GetStaticPathsItem | undefined;
|
|
35
35
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ComponentSlots } from '../../runtime/server/index.js';
|
|
2
2
|
import type { SSRResult } from '../../types/public/internal.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
4
4
|
export declare class Slots {
|
|
5
5
|
#private;
|
|
6
|
-
constructor(result: SSRResult, slots: ComponentSlots | null, logger:
|
|
6
|
+
constructor(result: SSRResult, slots: ComponentSlots | null, logger: AstroLogger);
|
|
7
7
|
has(name: string): boolean;
|
|
8
8
|
render(name: string, args?: any[]): Promise<any>;
|
|
9
9
|
}
|
package/dist/core/request.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AstroLogger } from './logger/core.js';
|
|
3
3
|
type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;
|
|
4
4
|
interface CreateRequestOptions {
|
|
5
5
|
url: URL | string;
|
|
@@ -7,7 +7,7 @@ interface CreateRequestOptions {
|
|
|
7
7
|
headers: HeaderType;
|
|
8
8
|
method?: string;
|
|
9
9
|
body?: RequestInit['body'];
|
|
10
|
-
logger:
|
|
10
|
+
logger: AstroLogger;
|
|
11
11
|
locals?: object | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Whether the request is being created for a static build or for a prerendered page within a hybrid/SSR build, or for emulating one of those in dev mode.
|
|
@@ -2,7 +2,7 @@ import nodeFs from 'node:fs';
|
|
|
2
2
|
import type { AstroSettings, RoutesList } from '../../types/astro.js';
|
|
3
3
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
4
4
|
import type { RouteData } from '../../types/public/internal.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
6
6
|
export interface RouteEntry {
|
|
7
7
|
path: string;
|
|
8
8
|
isDir: boolean;
|
|
@@ -16,11 +16,11 @@ interface CreateRouteManifestParams {
|
|
|
16
16
|
/** fs module, for testing */
|
|
17
17
|
fsMod?: typeof nodeFs;
|
|
18
18
|
}
|
|
19
|
-
export declare function createRoutesFromEntries(entries: RouteEntry[], settings: RoutingSettings, logger:
|
|
19
|
+
export declare function createRoutesFromEntries(entries: RouteEntry[], settings: RoutingSettings, logger: AstroLogger, pagesDirRelative?: string): RouteData[];
|
|
20
20
|
/**
|
|
21
21
|
* Create a full route manifest from filesystem and injected routes.
|
|
22
22
|
*/
|
|
23
|
-
export declare function createRoutesList(params: CreateRouteManifestParams, logger:
|
|
23
|
+
export declare function createRoutesList(params: CreateRouteManifestParams, logger: AstroLogger, { dev, }?: {
|
|
24
24
|
dev?: boolean;
|
|
25
25
|
}): Promise<RoutesList>;
|
|
26
26
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AstroSettings } from '../../types/astro.js';
|
|
2
2
|
import type { RouteData } from '../../types/public/internal.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parses the `export const prerender = true|false` declaration from a route's
|
|
6
6
|
* source content. Returns `true`, `false`, or `undefined` if not present.
|
|
7
7
|
*/
|
|
8
8
|
export declare function parsePrerenderExport(content: string): boolean | undefined;
|
|
9
|
-
export declare function getRoutePrerenderOption(content: string, route: RouteData, settings: AstroSettings, logger:
|
|
9
|
+
export declare function getRoutePrerenderOption(content: string, route: RouteData, settings: AstroSettings, logger: AstroLogger): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RewritePayload } from '../../types/public/common.js';
|
|
2
2
|
import type { AstroConfig } from '../../types/public/config.js';
|
|
3
3
|
import type { RouteData } from '../../types/public/internal.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
5
5
|
type FindRouteToRewrite = {
|
|
6
6
|
payload: RewritePayload;
|
|
7
7
|
routes: RouteData[];
|
|
@@ -31,7 +31,7 @@ export declare function findRouteToRewrite({ payload, routes, request, trailingS
|
|
|
31
31
|
* @param logger
|
|
32
32
|
* @param routePattern
|
|
33
33
|
*/
|
|
34
|
-
export declare function copyRequest(newUrl: URL, oldRequest: Request, isPrerendered: boolean, logger:
|
|
34
|
+
export declare function copyRequest(newUrl: URL, oldRequest: Request, isPrerendered: boolean, logger: AstroLogger, routePattern: string): Request;
|
|
35
35
|
export declare function setOriginPathname(request: Request, pathname: string, trailingSlash: AstroConfig['trailingSlash'], buildFormat: AstroConfig['build']['format']): void;
|
|
36
36
|
export declare function getOriginPathname(request: Request): string;
|
|
37
37
|
/**
|
|
@@ -2,10 +2,10 @@ import fsMod from 'node:fs';
|
|
|
2
2
|
import { type FSWatcher } from 'vite';
|
|
3
3
|
import type { AstroSettings } from '../../types/astro.js';
|
|
4
4
|
import type { AstroInlineConfig } from '../../types/public/config.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AstroLogger } from '../logger/core.js';
|
|
6
6
|
type SyncOptions = {
|
|
7
7
|
mode: string;
|
|
8
|
-
logger:
|
|
8
|
+
logger: AstroLogger;
|
|
9
9
|
settings: AstroSettings;
|
|
10
10
|
force?: boolean;
|
|
11
11
|
skip?: {
|
|
@@ -24,7 +24,7 @@ export default function sync(inlineConfig: AstroInlineConfig, { fs, telemetry: _
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function clearContentLayerCache({ settings, logger, fs, isDev, }: {
|
|
26
26
|
settings: AstroSettings;
|
|
27
|
-
logger:
|
|
27
|
+
logger: AstroLogger;
|
|
28
28
|
fs?: typeof fsMod;
|
|
29
29
|
isDev: boolean;
|
|
30
30
|
}): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstroLogger } from '../core/logger/core.js';
|
|
2
2
|
import type { AstroSettings } from '../types/astro.js';
|
|
3
3
|
import type { AdapterSupport, AdapterSupportsKind, AstroAdapterFeatureMap } from '../types/public/integrations.js';
|
|
4
4
|
export declare const AdapterFeatureStability: {
|
|
@@ -18,7 +18,7 @@ type ValidationResult = {
|
|
|
18
18
|
* will throw a runtime error.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare function validateSupportedFeatures(adapterName: string, featureMap: AstroAdapterFeatureMap, settings: AstroSettings, logger:
|
|
21
|
+
export declare function validateSupportedFeatures(adapterName: string, featureMap: AstroAdapterFeatureMap, settings: AstroSettings, logger: AstroLogger): ValidationResult;
|
|
22
22
|
export declare function unwrapSupportKind(supportKind?: AdapterSupport): AdapterSupportsKind | undefined;
|
|
23
23
|
export declare function getSupportMessage(supportKind: AdapterSupport): string | undefined;
|
|
24
24
|
export declare function getAdapterStaticRecommendation(adapterName: string): string | undefined;
|
|
@@ -3,7 +3,7 @@ import type { AddressInfo } from 'node:net';
|
|
|
3
3
|
import type { InlineConfig, ViteDevServer } from 'vite';
|
|
4
4
|
import type { SerializedSSRManifest } from '../core/app/types.js';
|
|
5
5
|
import type { PageBuildData } from '../core/build/types.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { AstroLogger } from '../core/logger/core.js';
|
|
7
7
|
import type { AstroSettings } from '../types/astro.js';
|
|
8
8
|
import type { AstroConfig } from '../types/public/config.js';
|
|
9
9
|
import type { IntegrationResolvedRoute, RouteOptions, RouteToHeaders } from '../types/public/integrations.js';
|
|
@@ -41,69 +41,69 @@ export declare function normalizeInjectedTypeFilename(filename: string, integrat
|
|
|
41
41
|
interface RunHookConfigSetup {
|
|
42
42
|
settings: AstroSettings;
|
|
43
43
|
command: 'dev' | 'build' | 'preview' | 'sync';
|
|
44
|
-
logger:
|
|
44
|
+
logger: AstroLogger;
|
|
45
45
|
isRestart?: boolean;
|
|
46
46
|
fs?: typeof fsMod;
|
|
47
47
|
}
|
|
48
48
|
export declare function runHookConfigSetup({ settings, command, logger, isRestart, fs, }: RunHookConfigSetup): Promise<AstroSettings>;
|
|
49
49
|
export declare function runHookConfigDone({ settings, logger, command, }: {
|
|
50
50
|
settings: AstroSettings;
|
|
51
|
-
logger:
|
|
51
|
+
logger: AstroLogger;
|
|
52
52
|
command?: 'dev' | 'build' | 'preview' | 'sync';
|
|
53
53
|
}): Promise<void>;
|
|
54
54
|
export declare function runHookServerSetup({ config, server, logger, }: {
|
|
55
55
|
config: AstroConfig;
|
|
56
56
|
server: ViteDevServer;
|
|
57
|
-
logger:
|
|
57
|
+
logger: AstroLogger;
|
|
58
58
|
}): Promise<void>;
|
|
59
59
|
export declare function runHookServerStart({ config, address, logger, }: {
|
|
60
60
|
config: AstroConfig;
|
|
61
61
|
address: AddressInfo;
|
|
62
|
-
logger:
|
|
62
|
+
logger: AstroLogger;
|
|
63
63
|
}): Promise<void>;
|
|
64
64
|
export declare function runHookServerDone({ config, logger, }: {
|
|
65
65
|
config: AstroConfig;
|
|
66
|
-
logger:
|
|
66
|
+
logger: AstroLogger;
|
|
67
67
|
}): Promise<void>;
|
|
68
68
|
export declare function runHookBuildStart({ settings, logger, }: {
|
|
69
69
|
settings: AstroSettings;
|
|
70
|
-
logger:
|
|
70
|
+
logger: AstroLogger;
|
|
71
71
|
}): Promise<void>;
|
|
72
72
|
export declare function runHookBuildSetup({ config, vite, pages, target, logger, }: {
|
|
73
73
|
config: AstroConfig;
|
|
74
74
|
vite: InlineConfig;
|
|
75
75
|
pages: Map<string, PageBuildData>;
|
|
76
76
|
target: 'server' | 'client';
|
|
77
|
-
logger:
|
|
77
|
+
logger: AstroLogger;
|
|
78
78
|
}): Promise<InlineConfig>;
|
|
79
79
|
type RunHookBuildSsr = {
|
|
80
80
|
config: AstroConfig;
|
|
81
81
|
manifest: SerializedSSRManifest;
|
|
82
|
-
logger:
|
|
82
|
+
logger: AstroLogger;
|
|
83
83
|
middlewareEntryPoint: URL | undefined;
|
|
84
84
|
};
|
|
85
85
|
export declare function runHookBuildSsr({ config, manifest, logger, middlewareEntryPoint, }: RunHookBuildSsr): Promise<void>;
|
|
86
86
|
export declare function runHookBuildGenerated({ settings, logger, routeToHeaders, }: {
|
|
87
87
|
settings: AstroSettings;
|
|
88
|
-
logger:
|
|
88
|
+
logger: AstroLogger;
|
|
89
89
|
routeToHeaders: RouteToHeaders;
|
|
90
90
|
}): Promise<void>;
|
|
91
91
|
type RunHookBuildDone = {
|
|
92
92
|
settings: AstroSettings;
|
|
93
93
|
pages: string[];
|
|
94
94
|
routes: RouteData[];
|
|
95
|
-
logger:
|
|
95
|
+
logger: AstroLogger;
|
|
96
96
|
};
|
|
97
97
|
export declare function runHookBuildDone({ settings, pages, routes, logger }: RunHookBuildDone): Promise<void>;
|
|
98
98
|
export declare function runHookRouteSetup({ route, settings, logger, }: {
|
|
99
99
|
route: RouteOptions;
|
|
100
100
|
settings: AstroSettings;
|
|
101
|
-
logger:
|
|
101
|
+
logger: AstroLogger;
|
|
102
102
|
}): Promise<void>;
|
|
103
103
|
export declare function runHookRoutesResolved({ routes, settings, logger, }: {
|
|
104
104
|
routes: Array<RouteData>;
|
|
105
105
|
settings: AstroSettings;
|
|
106
|
-
logger:
|
|
106
|
+
logger: AstroLogger;
|
|
107
107
|
}): Promise<void>;
|
|
108
108
|
export declare function toIntegrationResolvedRoute(route: RouteData, trailingSlash: AstroConfig['trailingSlash']): IntegrationResolvedRoute;
|
|
109
109
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AstroLogger } from '../../core/logger/core.js';
|
|
2
2
|
import type { APIRoute } from '../../types/public/common.js';
|
|
3
3
|
import type { APIContext } from '../../types/public/context.js';
|
|
4
4
|
/** Renders an endpoint request to completion, returning the body. */
|
|
5
5
|
export declare function renderEndpoint(mod: {
|
|
6
6
|
[method: string]: APIRoute;
|
|
7
|
-
}, context: APIContext, isPrerendered: boolean, logger:
|
|
7
|
+
}, context: APIContext, isPrerendered: boolean, logger: AstroLogger): Promise<Response>;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export declare const escapeHTML: (str: string) => string;
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a value to a JSON string that is safe to embed inside a `<script>` tag.
|
|
4
|
+
* All `<` characters are escaped to `\u003c` so the browser's HTML parser cannot be
|
|
5
|
+
* tricked into closing the script block early via `</script>` variants (case-insensitive,
|
|
6
|
+
* whitespace, or self-closing forms) or `<!--` comment injection.
|
|
7
|
+
* @see https://mathiasbynens.be/notes/etago
|
|
8
|
+
*/
|
|
9
|
+
export declare function stringifyForScript(value: any): string;
|
|
2
10
|
export declare class HTMLBytes extends Uint8Array {
|
|
3
11
|
}
|
|
4
12
|
declare const htmlStringSymbol: unique symbol;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { escape } from "html-escaper";
|
|
2
2
|
import { streamAsyncIterator } from "./util.js";
|
|
3
3
|
const escapeHTML = escape;
|
|
4
|
+
function stringifyForScript(value) {
|
|
5
|
+
return JSON.stringify(value)?.replace(/</g, "\\u003c");
|
|
6
|
+
}
|
|
4
7
|
class HTMLBytes extends Uint8Array {
|
|
5
8
|
}
|
|
6
9
|
Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
|
|
@@ -77,5 +80,6 @@ export {
|
|
|
77
80
|
isHTMLBytes,
|
|
78
81
|
isHTMLString,
|
|
79
82
|
markHTMLString,
|
|
83
|
+
stringifyForScript,
|
|
80
84
|
unescapeHTML
|
|
81
85
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encryptString, generateCspDigest } from "../../../core/encryption.js";
|
|
2
|
-
import { markHTMLString } from "../escape.js";
|
|
2
|
+
import { markHTMLString, stringifyForScript } from "../escape.js";
|
|
3
3
|
import { renderChild } from "./any.js";
|
|
4
4
|
import { createThinHead } from "./astro/head-and-content.js";
|
|
5
5
|
import { createRenderInstruction } from "./instruction.js";
|
|
@@ -13,13 +13,6 @@ const internalProps = /* @__PURE__ */ new Set([
|
|
|
13
13
|
function containsServerDirective(props) {
|
|
14
14
|
return "server:component-directive" in props;
|
|
15
15
|
}
|
|
16
|
-
const SCRIPT_RE = /<\/script/giu;
|
|
17
|
-
const COMMENT_RE = /<!--/gu;
|
|
18
|
-
const SCRIPT_REPLACER = "<\\/script";
|
|
19
|
-
const COMMENT_REPLACER = "\\u003C!--";
|
|
20
|
-
function safeJsonStringify(obj) {
|
|
21
|
-
return JSON.stringify(obj).replace(SCRIPT_RE, SCRIPT_REPLACER).replace(COMMENT_RE, COMMENT_REPLACER);
|
|
22
|
-
}
|
|
23
16
|
function createSearchParams(encryptedComponentExport, encryptedProps, slots) {
|
|
24
17
|
const params = new URLSearchParams();
|
|
25
18
|
params.set("e", encryptedComponentExport);
|
|
@@ -154,7 +147,7 @@ class ServerIslandComponent {
|
|
|
154
147
|
);
|
|
155
148
|
}
|
|
156
149
|
const adapterHeaders = this.result.internalFetchHeaders || {};
|
|
157
|
-
const headersJson =
|
|
150
|
+
const headersJson = stringifyForScript(adapterHeaders);
|
|
158
151
|
const method = useGETRequest ? (
|
|
159
152
|
// GET request
|
|
160
153
|
`const headers = new Headers(${headersJson});
|
|
@@ -162,9 +155,9 @@ let response = await fetch('${serverIslandUrl}', { headers });`
|
|
|
162
155
|
) : (
|
|
163
156
|
// POST request
|
|
164
157
|
`let data = {
|
|
165
|
-
encryptedComponentExport: ${
|
|
166
|
-
encryptedProps: ${
|
|
167
|
-
encryptedSlots: ${
|
|
158
|
+
encryptedComponentExport: ${stringifyForScript(componentExportEncrypted)},
|
|
159
|
+
encryptedProps: ${stringifyForScript(propsEncrypted)},
|
|
160
|
+
encryptedSlots: ${stringifyForScript(slotsEncrypted)},
|
|
168
161
|
};
|
|
169
162
|
const headers = new Headers({ 'Content-Type': 'application/json', ...${headersJson} });
|
|
170
163
|
let response = await fetch('${serverIslandUrl}', {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
|
-
import { HTMLString, markHTMLString } from "../escape.js";
|
|
2
|
+
import { HTMLString, markHTMLString, stringifyForScript } from "../escape.js";
|
|
3
3
|
import { isPromise } from "../util.js";
|
|
4
4
|
const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
|
|
5
5
|
const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|inert|loop|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|selected|itemscope)$/i;
|
|
@@ -19,10 +19,7 @@ const toStyleString = (obj) => Object.entries(obj).filter(([_, v]) => typeof v =
|
|
|
19
19
|
function defineScriptVars(vars) {
|
|
20
20
|
let output = "";
|
|
21
21
|
for (const [key, value] of Object.entries(vars)) {
|
|
22
|
-
output += `const ${toIdent(key)} = ${
|
|
23
|
-
/<\/script>/g,
|
|
24
|
-
"\\x3C/script>"
|
|
25
|
-
)};
|
|
22
|
+
output += `const ${toIdent(key)} = ${stringifyForScript(value)};
|
|
26
23
|
`;
|
|
27
24
|
}
|
|
28
25
|
return markHTMLString(output);
|
package/dist/types/astro.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AstroTimer } from '../core/config/timer.js';
|
|
2
2
|
import type { TSConfig } from '../core/config/tsconfig.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AstroLogger, AstroLoggerLevel } from '../core/logger/core.js';
|
|
4
4
|
import type { AstroPreferences } from '../preferences/index.js';
|
|
5
5
|
import type { AstroComponentFactory } from '../runtime/server/index.js';
|
|
6
6
|
import type { GetStaticPaths } from './public/common.js';
|
|
@@ -65,7 +65,7 @@ export interface AstroSettings {
|
|
|
65
65
|
fontResources: Set<string>;
|
|
66
66
|
styleHashes: Required<CspObject['styleDirective']>['hashes'];
|
|
67
67
|
};
|
|
68
|
-
logLevel:
|
|
68
|
+
logLevel: AstroLoggerLevel;
|
|
69
69
|
}
|
|
70
70
|
/** Generic interface for a component (Astro, Svelte, React, etc.) */
|
|
71
71
|
export interface ComponentInstance {
|
|
@@ -80,7 +80,7 @@ export interface RoutesList {
|
|
|
80
80
|
}
|
|
81
81
|
export interface AstroPluginOptions {
|
|
82
82
|
settings: AstroSettings;
|
|
83
|
-
logger:
|
|
83
|
+
logger: AstroLogger;
|
|
84
84
|
}
|
|
85
85
|
export interface ImportedDevStyle {
|
|
86
86
|
id: string;
|