astro 4.13.0 → 4.13.2
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/astro-jsx.d.ts +0 -1
- package/astro.js +2 -1
- package/client.d.ts +1 -1
- package/components/Picture.astro +2 -2
- package/components/ViewTransitions.astro +1 -1
- package/config.d.ts +1 -1
- package/dist/@types/astro.d.ts +21 -2
- package/dist/actions/runtime/middleware.d.ts +3 -3
- package/dist/actions/runtime/middleware.js +39 -72
- package/dist/actions/runtime/route.js +16 -23
- package/dist/actions/runtime/utils.d.ts +2 -8
- package/dist/actions/runtime/utils.js +0 -15
- package/dist/actions/runtime/virtual/client.d.ts +0 -1
- package/dist/actions/runtime/virtual/client.js +0 -4
- package/dist/actions/runtime/virtual/get-action.d.ts +8 -0
- package/dist/actions/runtime/virtual/get-action.js +17 -0
- package/dist/actions/runtime/virtual/server.d.ts +1 -4
- package/dist/actions/runtime/virtual/server.js +20 -13
- package/dist/actions/runtime/virtual/shared.d.ts +18 -1
- package/dist/actions/runtime/virtual/shared.js +56 -8
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +13 -8
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/endpoint/generic.js +1 -1
- package/dist/assets/endpoint/node.js +3 -3
- package/dist/assets/services/sharp.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1 -1
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1 -1
- package/dist/assets/utils/metadata.js +1 -1
- package/dist/assets/utils/node/emitAsset.js +1 -1
- package/dist/assets/utils/remoteProbe.js +1 -1
- package/dist/assets/utils/vendor/image-size/lookup.js +1 -1
- package/dist/assets/utils/vendor/image-size/types/svg.js +4 -4
- package/dist/cli/add/index.d.ts +0 -7
- package/dist/cli/add/index.js +1 -2
- package/dist/cli/info/index.js +2 -2
- package/dist/cli/install-package.d.ts +0 -1
- package/dist/cli/install-package.js +3 -4
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/utils.d.ts +2 -11
- package/dist/content/utils.js +0 -8
- package/dist/core/app/index.js +1 -1
- package/dist/core/build/css-asset-name.d.ts +3 -3
- package/dist/core/build/css-asset-name.js +15 -8
- package/dist/core/build/generate.d.ts +0 -4
- package/dist/core/build/generate.js +4 -24
- package/dist/core/build/index.js +8 -2
- package/dist/core/build/internal.d.ts +0 -18
- package/dist/core/build/internal.js +0 -17
- package/dist/core/build/page-data.d.ts +1 -1
- package/dist/core/build/page-data.js +1 -18
- package/dist/core/build/plugins/plugin-analyzer.js +0 -4
- package/dist/core/build/plugins/plugin-css.js +2 -2
- package/dist/core/build/plugins/plugin-internals.js +0 -7
- package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
- package/dist/core/build/plugins/plugin-manifest.js +0 -2
- package/dist/core/build/plugins/plugin-ssr.js +0 -1
- package/dist/core/build/types.d.ts +1 -8
- package/dist/core/compile/index.d.ts +0 -1
- package/dist/core/compile/types.d.ts +0 -7
- package/dist/core/config/schema.d.ts +55 -55
- package/dist/core/config/tsconfig.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +2 -2
- package/dist/core/dev/restart.d.ts +0 -2
- package/dist/core/dev/restart.js +1 -3
- package/dist/core/errors/dev/vite.d.ts +0 -13
- package/dist/core/errors/dev/vite.js +5 -6
- package/dist/core/errors/errors-data.d.ts +21 -5
- package/dist/core/errors/errors-data.js +13 -6
- package/dist/core/fs/index.d.ts +0 -2
- package/dist/core/fs/index.js +0 -5
- package/dist/core/logger/core.d.ts +0 -1
- package/dist/core/logger/core.js +0 -18
- package/dist/core/messages.d.ts +0 -1
- package/dist/core/messages.js +2 -3
- package/dist/core/middleware/index.js +3 -2
- package/dist/core/render/ssr-element.d.ts +0 -1
- package/dist/core/render/ssr-element.js +0 -6
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +9 -4
- package/dist/core/routing/manifest/create.js +2 -2
- package/dist/core/util.d.ts +0 -2
- package/dist/core/util.js +0 -14
- package/dist/events/error.js +1 -1
- package/dist/preferences/index.d.ts +0 -1
- package/dist/preferences/index.js +0 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +1 -1
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +4 -2
- package/dist/runtime/server/render/component.d.ts +0 -3
- package/dist/runtime/server/render/component.js +1 -3
- package/dist/transitions/router.js +2 -2
- package/dist/type-utils.d.ts +1 -1
- package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
- package/dist/vite-plugin-astro-server/controller.js +0 -2
- package/dist/vite-plugin-astro-server/vite.js +1 -2
- package/dist/vite-plugin-env/index.js +0 -1
- package/dist/vite-plugin-load-fallback/index.js +3 -3
- package/dist/vite-plugin-scanner/index.js +1 -1
- package/dist/vite-plugin-scripts/page-ssr.js +1 -1
- package/package.json +8 -17
- package/templates/actions.mjs +25 -18
- package/templates/content/types.d.ts +12 -10
- package/types/content.d.ts +1 -1
- package/dist/actions/runtime/store.d.ts +0 -5
- package/dist/actions/runtime/store.js +0 -18
|
@@ -3,7 +3,7 @@ import type { CompilerOptions, TypeAcquisition } from 'typescript';
|
|
|
3
3
|
export declare const defaultTSConfig: TSConfig;
|
|
4
4
|
export type frameworkWithTSSettings = 'vue' | 'react' | 'preact' | 'solid-js';
|
|
5
5
|
export declare const presets: Map<frameworkWithTSSettings, TSConfig>;
|
|
6
|
-
type TSConfigResult<T =
|
|
6
|
+
type TSConfigResult<T = object> = Promise<(TSConfckParseResult & T) | 'invalid-config' | 'missing-config' | 'unknown-error'>;
|
|
7
7
|
/**
|
|
8
8
|
* Load a tsconfig.json or jsconfig.json is the former is not found
|
|
9
9
|
* @param root The root directory to search in, defaults to `process.cwd()`.
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -19,7 +19,7 @@ async function dev(inlineConfig) {
|
|
|
19
19
|
await telemetry.record([]);
|
|
20
20
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
21
21
|
const logger = restart.container.logger;
|
|
22
|
-
const currentVersion = "4.13.
|
|
22
|
+
const currentVersion = "4.13.2";
|
|
23
23
|
const isPrerelease = currentVersion.includes("-");
|
|
24
24
|
if (!isPrerelease) {
|
|
25
25
|
try {
|
|
@@ -44,7 +44,7 @@ async function dev(inlineConfig) {
|
|
|
44
44
|
}
|
|
45
45
|
}).catch(() => {
|
|
46
46
|
});
|
|
47
|
-
} catch
|
|
47
|
+
} catch {
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const devServerAddressInfo = await startContainer(restart.container);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type nodeFs from 'node:fs';
|
|
2
2
|
import type { AstroInlineConfig } from '../../@types/astro.js';
|
|
3
3
|
import type { Container } from './container.js';
|
|
4
|
-
export declare function shouldRestartContainer({ settings, inlineConfig, restartInFlight }: Container, changedFile: string): boolean;
|
|
5
|
-
export declare function restartContainer(container: Container): Promise<Container | Error>;
|
|
6
4
|
export interface CreateContainerWithAutomaticRestart {
|
|
7
5
|
inlineConfig?: AstroInlineConfig;
|
|
8
6
|
fs: typeof nodeFs;
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ShikiTransformer } from 'shiki';
|
|
2
1
|
import type { ErrorPayload } from 'vite';
|
|
3
2
|
import type { ModuleLoader } from '../../module-loader/index.js';
|
|
4
3
|
import { type ErrorWithMetadata } from '../errors.js';
|
|
@@ -29,15 +28,3 @@ export interface AstroErrorPayload {
|
|
|
29
28
|
* Generate a payload for Vite's error overlay
|
|
30
29
|
*/
|
|
31
30
|
export declare function getViteErrorPayload(err: ErrorWithMetadata): Promise<AstroErrorPayload>;
|
|
32
|
-
/**
|
|
33
|
-
* Transformer for `shiki`'s legacy `lineOptions`, allows to add classes to specific lines
|
|
34
|
-
* FROM: https://github.com/shikijs/shiki/blob/4a58472070a9a359a4deafec23bb576a73e24c6a/packages/transformers/src/transformers/compact-line-options.ts
|
|
35
|
-
* LICENSE: https://github.com/shikijs/shiki/blob/4a58472070a9a359a4deafec23bb576a73e24c6a/LICENSE
|
|
36
|
-
*/
|
|
37
|
-
export declare function transformerCompactLineOptions(lineOptions?: {
|
|
38
|
-
/**
|
|
39
|
-
* 1-based line number.
|
|
40
|
-
*/
|
|
41
|
-
line: number;
|
|
42
|
-
classes?: string[];
|
|
43
|
-
}[]): ShikiTransformer;
|
|
@@ -23,7 +23,7 @@ function enhanceViteSSRError({
|
|
|
23
23
|
const content = fs.readFileSync(path).toString();
|
|
24
24
|
const lns = content.split("\n");
|
|
25
25
|
let importName;
|
|
26
|
-
if (importName =
|
|
26
|
+
if (importName = /Failed to load url (.*?) \(resolved id:/.exec(safeError.message)?.[1]) {
|
|
27
27
|
safeError.title = FailedToLoadModuleSSR.title;
|
|
28
28
|
safeError.name = "FailedToLoadModuleSSR";
|
|
29
29
|
safeError.message = FailedToLoadModuleSSR.message(importName);
|
|
@@ -39,7 +39,7 @@ function enhanceViteSSRError({
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
const fileId = safeError.id ?? safeError.loc?.file;
|
|
42
|
-
if (!renderers?.find((r) => r.name === "@astrojs/mdx") && safeError.message.
|
|
42
|
+
if (fileId && !renderers?.find((r) => r.name === "@astrojs/mdx") && safeError.message.includes("Syntax error") && /.mdx$/.test(fileId)) {
|
|
43
43
|
safeError = new AstroError({
|
|
44
44
|
...MdxIntegrationMissingError,
|
|
45
45
|
message: MdxIntegrationMissingError.message(JSON.stringify(fileId)),
|
|
@@ -47,8 +47,8 @@ function enhanceViteSSRError({
|
|
|
47
47
|
stack: safeError.stack
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
if (
|
|
51
|
-
const globPattern =
|
|
50
|
+
if (safeError.message.includes("Invalid glob")) {
|
|
51
|
+
const globPattern = /glob: "(.+)" \(/.exec(safeError.message)?.[1];
|
|
52
52
|
if (globPattern) {
|
|
53
53
|
safeError.message = InvalidGlob.message(globPattern);
|
|
54
54
|
safeError.name = "InvalidGlob";
|
|
@@ -128,6 +128,5 @@ function transformerCompactLineOptions(lineOptions = []) {
|
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
130
|
enhanceViteSSRError,
|
|
131
|
-
getViteErrorPayload
|
|
132
|
-
transformerCompactLineOptions
|
|
131
|
+
getViteErrorPayload
|
|
133
132
|
};
|
|
@@ -1427,6 +1427,24 @@ export declare const DuplicateContentEntrySlugError: {
|
|
|
1427
1427
|
title: string;
|
|
1428
1428
|
message(collection: string, slug: string, preExisting: string, alsoFound: string): string;
|
|
1429
1429
|
};
|
|
1430
|
+
/**
|
|
1431
|
+
* @docs
|
|
1432
|
+
* @see
|
|
1433
|
+
* - [devalue library](https://github.com/rich-harris/devalue)
|
|
1434
|
+
* @description
|
|
1435
|
+
* `transform()` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
|
|
1436
|
+
*/
|
|
1437
|
+
export declare const UnsupportedConfigTransformError: {
|
|
1438
|
+
name: string;
|
|
1439
|
+
title: string;
|
|
1440
|
+
message: (parseError: string) => string;
|
|
1441
|
+
hint: string;
|
|
1442
|
+
};
|
|
1443
|
+
/**
|
|
1444
|
+
* @docs
|
|
1445
|
+
* @kind heading
|
|
1446
|
+
* @name Action Errors
|
|
1447
|
+
*/
|
|
1430
1448
|
/**
|
|
1431
1449
|
* @docs
|
|
1432
1450
|
* @see
|
|
@@ -1468,15 +1486,13 @@ export declare const ActionQueryStringInvalidError: {
|
|
|
1468
1486
|
};
|
|
1469
1487
|
/**
|
|
1470
1488
|
* @docs
|
|
1471
|
-
* @see
|
|
1472
|
-
* - [devalue library](https://github.com/rich-harris/devalue)
|
|
1473
1489
|
* @description
|
|
1474
|
-
*
|
|
1490
|
+
* Action called from a server page or endpoint without using `Astro.callAction()`.
|
|
1475
1491
|
*/
|
|
1476
|
-
export declare const
|
|
1492
|
+
export declare const ActionCalledFromServerError: {
|
|
1477
1493
|
name: string;
|
|
1478
1494
|
title: string;
|
|
1479
|
-
message:
|
|
1495
|
+
message: string;
|
|
1480
1496
|
hint: string;
|
|
1481
1497
|
};
|
|
1482
1498
|
export declare const UnknownError: {
|
|
@@ -541,6 +541,13 @@ Entries:
|
|
|
541
541
|
- ${alsoFound}`;
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
|
+
const UnsupportedConfigTransformError = {
|
|
545
|
+
name: "UnsupportedConfigTransformError",
|
|
546
|
+
title: "Unsupported transform in content config.",
|
|
547
|
+
message: (parseError) => `\`transform()\` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
|
|
548
|
+
Full error: ${parseError}`,
|
|
549
|
+
hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
|
|
550
|
+
};
|
|
544
551
|
const ActionsWithoutServerOutputError = {
|
|
545
552
|
name: "ActionsWithoutServerOutputError",
|
|
546
553
|
title: "Actions must be used with server output.",
|
|
@@ -559,15 +566,15 @@ const ActionQueryStringInvalidError = {
|
|
|
559
566
|
message: (actionName) => `The server received the query string \`?_astroAction=${actionName}\`, but could not find an action with that name. If you changed an action's name in development, remove this query param from your URL and refresh.`,
|
|
560
567
|
hint: "Actions are experimental. Visit the RFC for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md"
|
|
561
568
|
};
|
|
562
|
-
const
|
|
563
|
-
name: "
|
|
564
|
-
title: "
|
|
565
|
-
message:
|
|
566
|
-
|
|
567
|
-
hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
|
|
569
|
+
const ActionCalledFromServerError = {
|
|
570
|
+
name: "ActionCalledFromServerError",
|
|
571
|
+
title: "Action unexpected called from the server.",
|
|
572
|
+
message: "Action called from a server page or endpoint without using `Astro.callAction()`.",
|
|
573
|
+
hint: "See the RFC section on server calls for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md#call-actions-directly-from-server-code"
|
|
568
574
|
};
|
|
569
575
|
const UnknownError = { name: "UnknownError", title: "Unknown Error." };
|
|
570
576
|
export {
|
|
577
|
+
ActionCalledFromServerError,
|
|
571
578
|
ActionQueryStringInvalidError,
|
|
572
579
|
ActionsUsedWithForGetError,
|
|
573
580
|
ActionsWithoutServerOutputError,
|
package/dist/core/fs/index.d.ts
CHANGED
package/dist/core/fs/index.js
CHANGED
|
@@ -3,10 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { appendForwardSlash } from "../path.js";
|
|
5
5
|
const isWindows = process.platform === "win32";
|
|
6
|
-
function removeDir(_dir) {
|
|
7
|
-
const dir = fileURLToPath(_dir);
|
|
8
|
-
fs.rmSync(dir, { recursive: true, force: true, maxRetries: 3 });
|
|
9
|
-
}
|
|
10
6
|
function removeEmptyDirs(root) {
|
|
11
7
|
const dir = fileURLToPath(root);
|
|
12
8
|
if (!fs.statSync(dir).isDirectory()) return;
|
|
@@ -90,6 +86,5 @@ const fixWinEPERMSync = (p, options, er) => {
|
|
|
90
86
|
};
|
|
91
87
|
export {
|
|
92
88
|
emptyDir,
|
|
93
|
-
removeDir,
|
|
94
89
|
removeEmptyDirs
|
|
95
90
|
};
|
|
@@ -38,7 +38,6 @@ export declare function debug(...args: any[]): void;
|
|
|
38
38
|
* with colors. This is shared across different loggers, so it's defined here.
|
|
39
39
|
*/
|
|
40
40
|
export declare function getEventPrefix({ level, label }: LogMessage): string;
|
|
41
|
-
export declare let defaultLogLevel: LoggerLevel;
|
|
42
41
|
/** Print out a timer message for debug() */
|
|
43
42
|
export declare function timerMessage(message: string, startTime?: number): string;
|
|
44
43
|
export declare class Logger {
|
package/dist/core/logger/core.js
CHANGED
|
@@ -81,23 +81,6 @@ function getEventPrefix({ level, label }) {
|
|
|
81
81
|
}
|
|
82
82
|
return dim(prefix[0]) + " " + blue(prefix.splice(1).join(" "));
|
|
83
83
|
}
|
|
84
|
-
let defaultLogLevel;
|
|
85
|
-
if (typeof process !== "undefined") {
|
|
86
|
-
let proc = process;
|
|
87
|
-
if ("argv" in proc && Array.isArray(proc.argv)) {
|
|
88
|
-
if (proc.argv.includes("--verbose")) {
|
|
89
|
-
defaultLogLevel = "debug";
|
|
90
|
-
} else if (proc.argv.includes("--silent")) {
|
|
91
|
-
defaultLogLevel = "silent";
|
|
92
|
-
} else {
|
|
93
|
-
defaultLogLevel = "info";
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
defaultLogLevel = "info";
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
defaultLogLevel = "info";
|
|
100
|
-
}
|
|
101
84
|
function timerMessage(message, startTime = Date.now()) {
|
|
102
85
|
let timeDiff = Date.now() - startTime;
|
|
103
86
|
let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1e3).toFixed(1)}s`;
|
|
@@ -158,7 +141,6 @@ export {
|
|
|
158
141
|
Logger,
|
|
159
142
|
dateTimeFormat,
|
|
160
143
|
debug,
|
|
161
|
-
defaultLogLevel,
|
|
162
144
|
error,
|
|
163
145
|
getEventPrefix,
|
|
164
146
|
info,
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -45,7 +45,6 @@ export declare function prerelease({ currentVersion }: {
|
|
|
45
45
|
export declare function success(message: string, tip?: string): string;
|
|
46
46
|
export declare function failure(message: string, tip?: string): string;
|
|
47
47
|
export declare function cancelled(message: string, tip?: string): string;
|
|
48
|
-
export declare function getNetworkLogging(host: string | boolean): 'none' | 'host-to-expose' | 'visible';
|
|
49
48
|
export declare function formatConfigErrorMessage(err: ZodError): string;
|
|
50
49
|
export declare function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string;
|
|
51
50
|
export declare function printHelp({ commandName, headline, usage, tables, description, }: {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "4.13.
|
|
41
|
+
const version = "4.13.2";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -270,7 +270,7 @@ function printHelp({
|
|
|
270
270
|
message.push(
|
|
271
271
|
linebreak(),
|
|
272
272
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
273
|
-
`v${"4.13.
|
|
273
|
+
`v${"4.13.2"}`
|
|
274
274
|
)} ${headline}`
|
|
275
275
|
);
|
|
276
276
|
}
|
|
@@ -299,7 +299,6 @@ export {
|
|
|
299
299
|
formatConfigErrorMessage,
|
|
300
300
|
formatErrorMessage,
|
|
301
301
|
fsStrictWarning,
|
|
302
|
-
getNetworkLogging,
|
|
303
302
|
newVersionAvailable,
|
|
304
303
|
preferenceDefault,
|
|
305
304
|
preferenceDefaultIntro,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createGetActionResult } from "../../actions/utils.js";
|
|
1
|
+
import { createCallAction, createGetActionResult } from "../../actions/utils.js";
|
|
2
2
|
import {
|
|
3
3
|
computeCurrentLocale,
|
|
4
4
|
computePreferredLocale,
|
|
@@ -77,7 +77,8 @@ function createContext({
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
return Object.assign(context, {
|
|
80
|
-
getActionResult: createGetActionResult(context.locals)
|
|
80
|
+
getActionResult: createGetActionResult(context.locals),
|
|
81
|
+
callAction: createCallAction(context)
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
function isLocalsSerializable(value) {
|
|
@@ -8,7 +8,6 @@ export declare function createModuleScriptElement(script: {
|
|
|
8
8
|
value: string;
|
|
9
9
|
}, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
|
|
10
10
|
export declare function createModuleScriptElementWithSrc(src: string, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
|
|
11
|
-
export declare function createModuleScriptElementWithSrcSet(srces: string[], site?: string, assetsPrefix?: AssetsPrefix): Set<SSRElement>;
|
|
12
11
|
export declare function createModuleScriptsSet(scripts: {
|
|
13
12
|
type: 'inline' | 'external';
|
|
14
13
|
value: string;
|
|
@@ -50,11 +50,6 @@ function createModuleScriptElementWithSrc(src, base, assetsPrefix) {
|
|
|
50
50
|
children: ""
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function createModuleScriptElementWithSrcSet(srces, site, assetsPrefix) {
|
|
54
|
-
return new Set(
|
|
55
|
-
srces.map((src) => createModuleScriptElementWithSrc(src, site, assetsPrefix))
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
53
|
function createModuleScriptsSet(scripts, base, assetsPrefix) {
|
|
59
54
|
return new Set(
|
|
60
55
|
scripts.map((script) => createModuleScriptElement(script, base, assetsPrefix))
|
|
@@ -64,7 +59,6 @@ export {
|
|
|
64
59
|
createAssetLink,
|
|
65
60
|
createModuleScriptElement,
|
|
66
61
|
createModuleScriptElementWithSrc,
|
|
67
|
-
createModuleScriptElementWithSrcSet,
|
|
68
62
|
createModuleScriptsSet,
|
|
69
63
|
createStylesheetElement,
|
|
70
64
|
createStylesheetElementSet
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIContext, AstroGlobal, AstroGlobalPartial, ComponentInstance, MiddlewareHandler, Props, RouteData, SSRResult } from '../@types/astro.js';
|
|
2
|
-
import type { ActionAPIContext } from '../actions/runtime/
|
|
2
|
+
import type { ActionAPIContext } from '../actions/runtime/utils.js';
|
|
3
3
|
import { AstroCookies } from './cookies/index.js';
|
|
4
4
|
import { type Pipeline } from './render/index.js';
|
|
5
5
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deserializeActionResult } from "../actions/runtime/virtual/shared.js";
|
|
2
|
+
import { createCallAction, createGetActionResult, hasActionsInternal } from "../actions/utils.js";
|
|
2
3
|
import {
|
|
3
4
|
computeCurrentLocale,
|
|
4
5
|
computePreferredLocale,
|
|
@@ -169,7 +170,8 @@ class RenderContext {
|
|
|
169
170
|
const context = this.createActionAPIContext();
|
|
170
171
|
return Object.assign(context, {
|
|
171
172
|
props,
|
|
172
|
-
getActionResult: createGetActionResult(context.locals)
|
|
173
|
+
getActionResult: createGetActionResult(context.locals),
|
|
174
|
+
callAction: createCallAction(context)
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
177
|
async #executeRewrite(reroutePayload) {
|
|
@@ -254,7 +256,7 @@ class RenderContext {
|
|
|
254
256
|
throw new AstroError(AstroErrorData.AstroResponseHeadersReassigned);
|
|
255
257
|
}
|
|
256
258
|
};
|
|
257
|
-
const actionResult = hasActionsInternal(this.locals) ? this.locals._actionsInternal
|
|
259
|
+
const actionResult = hasActionsInternal(this.locals) ? deserializeActionResult(this.locals._actionsInternal.actionResult) : void 0;
|
|
258
260
|
const result = {
|
|
259
261
|
base: manifest.base,
|
|
260
262
|
cancelled: false,
|
|
@@ -369,9 +371,12 @@ class RenderContext {
|
|
|
369
371
|
redirect,
|
|
370
372
|
rewrite,
|
|
371
373
|
request: this.request,
|
|
372
|
-
getActionResult: createGetActionResult(locals),
|
|
373
374
|
response,
|
|
374
375
|
site: pipeline.site,
|
|
376
|
+
getActionResult: createGetActionResult(locals),
|
|
377
|
+
get callAction() {
|
|
378
|
+
return createCallAction(this);
|
|
379
|
+
},
|
|
375
380
|
url
|
|
376
381
|
};
|
|
377
382
|
}
|
|
@@ -42,7 +42,7 @@ function getParts(part, file) {
|
|
|
42
42
|
}
|
|
43
43
|
function validateSegment(segment, file = "") {
|
|
44
44
|
if (!file) file = segment;
|
|
45
|
-
if (
|
|
45
|
+
if (segment.includes("][")) {
|
|
46
46
|
throw new Error(`Invalid route ${file} \u2014 parameters must be separated`);
|
|
47
47
|
}
|
|
48
48
|
if (countOccurrences("[", segment) !== countOccurrences("]", segment)) {
|
|
@@ -198,7 +198,7 @@ function createInjectedRoutes({ settings, cwd }) {
|
|
|
198
198
|
let resolved;
|
|
199
199
|
try {
|
|
200
200
|
resolved = require2.resolve(entrypoint, { paths: [cwd || fileURLToPath(config.root)] });
|
|
201
|
-
} catch
|
|
201
|
+
} catch {
|
|
202
202
|
resolved = fileURLToPath(new URL(entrypoint, config.root));
|
|
203
203
|
}
|
|
204
204
|
const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved));
|
package/dist/core/util.d.ts
CHANGED
|
@@ -38,8 +38,6 @@ export declare function isEndpoint(file: URL, settings: AstroSettings): boolean;
|
|
|
38
38
|
export declare function isServerLikeOutput(config: AstroConfig): boolean;
|
|
39
39
|
export declare function isModeServerWithNoAdapter(settings: AstroSettings): boolean;
|
|
40
40
|
export declare function isContentCollectionsCacheEnabled(config: AstroConfig): boolean;
|
|
41
|
-
export declare function relativeToSrcDir(config: AstroConfig, idOrUrl: URL | string): string;
|
|
42
|
-
export declare function emoji(char: string, fallback: string): string;
|
|
43
41
|
export declare function resolveJsToTs(filePath: string): string;
|
|
44
42
|
/**
|
|
45
43
|
* Set a default NODE_ENV so Vite doesn't set an incorrect default when loading the Astro config
|
package/dist/core/util.js
CHANGED
|
@@ -113,18 +113,6 @@ function isContentCollectionsCacheEnabled(config) {
|
|
|
113
113
|
return config.experimental.contentCollectionCache && // contentCollectionsCache is an SSG only feature
|
|
114
114
|
!isServerLikeOutput(config);
|
|
115
115
|
}
|
|
116
|
-
function relativeToSrcDir(config, idOrUrl) {
|
|
117
|
-
let id;
|
|
118
|
-
if (typeof idOrUrl !== "string") {
|
|
119
|
-
id = unwrapId(viteID(idOrUrl));
|
|
120
|
-
} else {
|
|
121
|
-
id = idOrUrl;
|
|
122
|
-
}
|
|
123
|
-
return id.slice(slash(fileURLToPath(config.srcDir)).length);
|
|
124
|
-
}
|
|
125
|
-
function emoji(char, fallback) {
|
|
126
|
-
return process.platform !== "win32" ? char : fallback;
|
|
127
|
-
}
|
|
128
116
|
function resolveJsToTs(filePath) {
|
|
129
117
|
if (filePath.endsWith(".jsx") && !fs.existsSync(filePath)) {
|
|
130
118
|
const tryPath = filePath.slice(0, -4) + ".tsx";
|
|
@@ -143,7 +131,6 @@ export {
|
|
|
143
131
|
NULL_BYTE_PLACEHOLDER,
|
|
144
132
|
VALID_ID_PREFIX,
|
|
145
133
|
arraify,
|
|
146
|
-
emoji,
|
|
147
134
|
ensureProcessNodeEnv,
|
|
148
135
|
getOutputFilename,
|
|
149
136
|
isContentCollectionsCacheEnabled,
|
|
@@ -156,7 +143,6 @@ export {
|
|
|
156
143
|
isURL,
|
|
157
144
|
padMultilineString,
|
|
158
145
|
parseNpmName,
|
|
159
|
-
relativeToSrcDir,
|
|
160
146
|
resolveJsToTs,
|
|
161
147
|
resolvePages,
|
|
162
148
|
unwrapId,
|
package/dist/events/error.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
|
2
2
|
const EVENT_ERROR = "ASTRO_CLI_ERROR";
|
|
3
3
|
const ANONYMIZE_MESSAGE_REGEX = /^(?:\w| )+/;
|
|
4
4
|
function anonymizeErrorMessage(msg) {
|
|
5
|
-
const matchedMessage =
|
|
5
|
+
const matchedMessage = ANONYMIZE_MESSAGE_REGEX.exec(msg);
|
|
6
6
|
if (!matchedMessage?.[0]) {
|
|
7
7
|
return void 0;
|
|
8
8
|
}
|
|
@@ -33,5 +33,4 @@ export interface AstroPreferences {
|
|
|
33
33
|
export declare function isValidKey(key: string): key is PreferenceKey;
|
|
34
34
|
export declare function coerce(key: string, value: unknown): any;
|
|
35
35
|
export default function createPreferences(config: AstroConfig): AstroPreferences;
|
|
36
|
-
export declare function getGlobalPreferenceDir(): string;
|
|
37
36
|
export {};
|
|
@@ -9,7 +9,7 @@ const icon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 1 2
|
|
|
9
9
|
try {
|
|
10
10
|
customElements.define("astro-dev-toolbar-audit-window", DevToolbarAuditListWindow);
|
|
11
11
|
customElements.define("astro-dev-toolbar-audit-list-item", DevToolbarAuditListItem);
|
|
12
|
-
} catch
|
|
12
|
+
} catch {
|
|
13
13
|
}
|
|
14
14
|
let showState = false;
|
|
15
15
|
var audit_default = {
|
|
@@ -23,7 +23,8 @@ const perf = [
|
|
|
23
23
|
selector: 'img:not([loading]), img[loading="eager"], iframe:not([loading]), iframe[loading="eager"]',
|
|
24
24
|
match(element) {
|
|
25
25
|
const htmlElement = element;
|
|
26
|
-
|
|
26
|
+
const elementYPosition = htmlElement.getBoundingClientRect().y + window.scrollY;
|
|
27
|
+
if (elementYPosition < window.innerHeight) return false;
|
|
27
28
|
if (htmlElement.src.startsWith("data:")) return false;
|
|
28
29
|
return true;
|
|
29
30
|
}
|
|
@@ -35,7 +36,8 @@ const perf = [
|
|
|
35
36
|
selector: 'img[loading="lazy"], iframe[loading="lazy"]',
|
|
36
37
|
match(element) {
|
|
37
38
|
const htmlElement = element;
|
|
38
|
-
|
|
39
|
+
const elementYPosition = htmlElement.getBoundingClientRect().y + window.scrollY;
|
|
40
|
+
if (elementYPosition > window.innerHeight) return false;
|
|
39
41
|
if (htmlElement.src.startsWith("data:")) return false;
|
|
40
42
|
return true;
|
|
41
43
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { RouteData, SSRResult } from '../../../@types/astro.js';
|
|
2
|
-
import { type RenderInstruction } from './instruction.js';
|
|
3
|
-
import type { HTMLBytes } from '../escape.js';
|
|
4
2
|
import { type RenderInstance } from './common.js';
|
|
5
3
|
import { type ComponentSlots } from './slot.js';
|
|
6
4
|
declare const needsHeadRenderingSymbol: unique symbol;
|
|
7
|
-
export type ComponentIterable = AsyncIterable<string | HTMLBytes | RenderInstruction>;
|
|
8
5
|
export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, props: Record<string | number, any>, slots?: ComponentSlots): Promise<RenderInstance>;
|
|
9
6
|
export declare function renderComponentToString(result: SSRResult, displayName: string, Component: unknown, props: Record<string | number, any>, slots?: any, isPage?: boolean, route?: RouteData): Promise<string>;
|
|
10
7
|
export type NonAstroPageComponent = {
|
|
@@ -136,9 +136,7 @@ Did you forget to import the component or is it possible there is a typo?`
|
|
|
136
136
|
}
|
|
137
137
|
if (!renderer) {
|
|
138
138
|
const extname = metadata.componentUrl?.split(".").pop();
|
|
139
|
-
renderer = renderers.
|
|
140
|
-
({ name }) => name === `@astrojs/${extname}` || name === extname
|
|
141
|
-
)[0];
|
|
139
|
+
renderer = renderers.find(({ name }) => name === `@astrojs/${extname}` || name === extname);
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
let componentServerRenderEndTime;
|
|
@@ -62,7 +62,7 @@ async function fetchHTML(href, init) {
|
|
|
62
62
|
redirected: res.redirected ? res.url : void 0,
|
|
63
63
|
mediaType
|
|
64
64
|
};
|
|
65
|
-
} catch
|
|
65
|
+
} catch {
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -189,7 +189,7 @@ async function updateDOM(preparationEvent, options, currentTransition, historySt
|
|
|
189
189
|
if (fallback === "animate" && !currentTransition.transitionSkipped && !preparationEvent.signal.aborted) {
|
|
190
190
|
try {
|
|
191
191
|
await animate("old");
|
|
192
|
-
} catch
|
|
192
|
+
} catch {
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
const pageTitleForBrowserHistory = document.title;
|
package/dist/type-utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type WithRequired<T, K extends keyof T> = T & {
|
|
|
5
5
|
[P in K]-?: T[P];
|
|
6
6
|
};
|
|
7
7
|
export type OmitIndexSignature<ObjectType> = {
|
|
8
|
-
[KeyType in keyof ObjectType as
|
|
8
|
+
[KeyType in keyof ObjectType as object extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
|
|
9
9
|
};
|
|
10
10
|
export type Kebab<T extends string, A extends string = ''> = T extends `${infer F}${infer R}` ? Kebab<R, `${A}${F extends Lowercase<F> ? '' : '-'}${Lowercase<F>}`> : A;
|
|
11
11
|
export type KebabKeys<T> = {
|
|
@@ -12,10 +12,6 @@ export type CreateControllerParams = {
|
|
|
12
12
|
reload: ReloadFn;
|
|
13
13
|
};
|
|
14
14
|
export declare function createController(params: CreateControllerParams): DevServerController;
|
|
15
|
-
export declare function createBaseController({ reload }: {
|
|
16
|
-
reload: ReloadFn;
|
|
17
|
-
}): DevServerController;
|
|
18
|
-
export declare function createLoaderController(loader: ModuleLoader): DevServerController;
|
|
19
15
|
export interface RunWithErrorHandlingParams {
|
|
20
16
|
controller: DevServerController;
|
|
21
17
|
pathname: string;
|
|
@@ -5,7 +5,6 @@ import { hasSpecialQueries } from "../vite-plugin-utils/index.js";
|
|
|
5
5
|
import { isCSSRequest } from "./util.js";
|
|
6
6
|
const fileExtensionsToSSR = /* @__PURE__ */ new Set([".astro", ".mdoc", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS]);
|
|
7
7
|
const STRIP_QUERY_PARAMS_REGEX = /\?.*$/;
|
|
8
|
-
const ASTRO_PROPAGATED_ASSET_REGEX = /\?astroPropagatedAssets/;
|
|
9
8
|
async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ new Set()) {
|
|
10
9
|
const id = unwrapId(_id);
|
|
11
10
|
const importedModules = /* @__PURE__ */ new Set();
|
|
@@ -35,7 +34,7 @@ async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ ne
|
|
|
35
34
|
if (!importedModule.id) continue;
|
|
36
35
|
const importedModulePathname = importedModule.id.replace(STRIP_QUERY_PARAMS_REGEX, "");
|
|
37
36
|
const isFileTypeNeedingSSR = fileExtensionsToSSR.has(npath.extname(importedModulePathname));
|
|
38
|
-
const isPropagationStoppingPoint =
|
|
37
|
+
const isPropagationStoppingPoint = importedModule.id.includes("?astroPropagatedAssets");
|
|
39
38
|
if (isFileTypeNeedingSSR && // Should not SSR a module with ?astroPropagatedAssets
|
|
40
39
|
!isPropagationStoppingPoint) {
|
|
41
40
|
const mod = loader.getModuleById(importedModule.id);
|
|
@@ -50,7 +50,6 @@ async function replaceDefine(code, id, define, config) {
|
|
|
50
50
|
if (env) {
|
|
51
51
|
const marker = `__astro_import_meta_env${"_".repeat(
|
|
52
52
|
env.length - 23
|
|
53
|
-
/* length of preceding string */
|
|
54
53
|
)}`;
|
|
55
54
|
replacementMarkers[marker] = env;
|
|
56
55
|
define = { ...define, "import.meta.env": marker };
|
|
@@ -12,14 +12,14 @@ function loadFallbackPlugin({
|
|
|
12
12
|
const tryLoadModule = async (id) => {
|
|
13
13
|
try {
|
|
14
14
|
return await fs.promises.readFile(cleanUrl(id), "utf-8");
|
|
15
|
-
} catch
|
|
15
|
+
} catch {
|
|
16
16
|
try {
|
|
17
17
|
return await fs.promises.readFile(id, "utf-8");
|
|
18
|
-
} catch
|
|
18
|
+
} catch {
|
|
19
19
|
try {
|
|
20
20
|
const fullpath = new URL("." + id, root);
|
|
21
21
|
return await fs.promises.readFile(fullpath, "utf-8");
|
|
22
|
-
} catch
|
|
22
|
+
} catch {
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|