astro 4.6.4 → 4.7.1
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/@types/astro.d.ts +48 -6
- package/dist/cli/add/index.js +1 -41
- package/dist/cli/install-package.d.ts +9 -0
- package/dist/cli/install-package.js +64 -1
- package/dist/config/index.js +1 -1
- package/dist/content/index.d.ts +0 -1
- package/dist/content/index.js +0 -2
- package/dist/content/utils.js +1 -3
- package/dist/core/build/generate.js +1 -1
- package/dist/core/build/index.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +1 -1
- package/dist/core/build/plugins/plugin-ssr.js +1 -1
- package/dist/core/build/static-build.js +5 -1
- package/dist/core/compile/compile.js +1 -1
- package/dist/core/config/settings.js +3 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +1 -1
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.js +34 -2
- package/dist/core/dev/restart.js +5 -1
- package/dist/core/dev/update-check.d.ts +4 -0
- package/dist/core/dev/update-check.js +36 -0
- package/dist/core/errors/errors-data.d.ts +1 -1
- package/dist/core/errors/errors-data.js +2 -2
- package/dist/core/errors/index.d.ts +1 -0
- package/dist/core/errors/index.js +2 -0
- package/dist/core/errors/overlay.js +2 -2
- package/dist/core/logger/core.d.ts +1 -1
- package/dist/core/messages.d.ts +3 -0
- package/dist/core/messages.js +11 -2
- package/dist/core/preview/index.js +1 -1
- package/dist/core/routing/priority.d.ts +1 -1
- package/dist/core/sync/index.js +1 -1
- package/dist/integrations/{index.d.ts → hooks.d.ts} +28 -0
- package/dist/integrations/{index.js → hooks.js} +41 -2
- package/dist/preferences/defaults.d.ts +9 -0
- package/dist/preferences/defaults.js +9 -0
- package/dist/preferences/index.d.ts +12 -4
- package/dist/preferences/index.js +11 -4
- package/dist/prerender/utils.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/astro.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/astro.js +3 -0
- package/dist/runtime/client/dev-toolbar/apps/audit/index.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/settings.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/apps/xray.d.ts +1 -1
- package/dist/runtime/client/dev-toolbar/entrypoint.js +3 -2
- package/dist/runtime/client/dev-toolbar/helpers.d.ts +61 -0
- package/dist/runtime/client/dev-toolbar/helpers.js +87 -0
- package/dist/runtime/client/dev-toolbar/toolbar.d.ts +3 -2
- package/dist/runtime/client/dev-toolbar/toolbar.js +2 -1
- package/dist/runtime/server/astro-global.js +1 -1
- package/dist/runtime/server/render/astro/instance.js +10 -10
- package/dist/runtime/server/render/util.js +3 -1
- package/dist/toolbar/index.d.ts +2 -0
- package/dist/toolbar/index.js +6 -0
- package/dist/{vite-plugin-dev-toolbar → toolbar}/vite-plugin-dev-toolbar.js +33 -12
- package/dist/transitions/events.d.ts +5 -4
- package/dist/transitions/events.js +13 -7
- package/dist/transitions/router.js +93 -34
- package/dist/vite-plugin-astro-server/pipeline.js +1 -0
- package/dist/vite-plugin-astro-server/vite.js +4 -5
- package/dist/vite-plugin-integrations-container/index.js +1 -1
- package/package.json +14 -13
- package/tsconfigs/strictest.json +1 -3
- /package/dist/{content/error-map.d.ts → core/errors/zod-error-map.d.ts} +0 -0
- /package/dist/{content/error-map.js → core/errors/zod-error-map.js} +0 -0
- /package/dist/integrations/{astroFeaturesValidation.d.ts → features-validation.d.ts} +0 -0
- /package/dist/integrations/{astroFeaturesValidation.js → features-validation.js} +0 -0
- /package/dist/{vite-plugin-dev-toolbar → toolbar}/vite-plugin-dev-toolbar.d.ts +0 -0
package/dist/@types/astro.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ import type { AstroTimer } from '../core/config/timer.js';
|
|
|
14
14
|
import type { TSConfig } from '../core/config/tsconfig.js';
|
|
15
15
|
import type { AstroCookies } from '../core/cookies/index.js';
|
|
16
16
|
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js';
|
|
17
|
+
import type { getToolbarServerCommunicationHelpers } from '../integrations/hooks.js';
|
|
17
18
|
import type { AstroPreferences } from '../preferences/index.js';
|
|
19
|
+
import type { ToolbarAppEventTarget, ToolbarServerHelpers } from '../runtime/client/dev-toolbar/helpers.js';
|
|
18
20
|
import type { AstroDevToolbar, DevToolbarCanvas } from '../runtime/client/dev-toolbar/toolbar.js';
|
|
19
21
|
import type { Icon } from '../runtime/client/dev-toolbar/ui-library/icons.js';
|
|
20
22
|
import type { DevToolbarBadge, DevToolbarButton, DevToolbarCard, DevToolbarHighlight, DevToolbarIcon, DevToolbarSelect, DevToolbarToggle, DevToolbarTooltip, DevToolbarWindow } from '../runtime/client/dev-toolbar/ui-library/index.js';
|
|
@@ -22,7 +24,7 @@ import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/s
|
|
|
22
24
|
import type { TransitionBeforePreparationEvent, TransitionBeforeSwapEvent } from '../transitions/events.js';
|
|
23
25
|
import type { DeepPartial, OmitIndexSignature, Simplify } from '../type-utils.js';
|
|
24
26
|
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
|
|
25
|
-
export {
|
|
27
|
+
export type { AstroIntegrationLogger, ToolbarServerHelpers };
|
|
26
28
|
export type { MarkdownHeading, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
|
|
27
29
|
export type { ExternalImageService, ImageService, LocalImageService, } from '../assets/services/service.js';
|
|
28
30
|
export type { GetImageResult, ImageInputFormat, ImageMetadata, ImageOutputFormat, ImageQuality, ImageQualityPreset, ImageTransform, UnresolvedImageTransform, } from '../assets/types.js';
|
|
@@ -1939,7 +1941,7 @@ export interface AstroSettings {
|
|
|
1939
1941
|
* Map of directive name (e.g. `load`) to the directive script code
|
|
1940
1942
|
*/
|
|
1941
1943
|
clientDirectives: Map<string, string>;
|
|
1942
|
-
devToolbarApps: string[];
|
|
1944
|
+
devToolbarApps: (DevToolbarAppEntry | string)[];
|
|
1943
1945
|
middlewares: {
|
|
1944
1946
|
pre: string[];
|
|
1945
1947
|
post: string[];
|
|
@@ -1948,6 +1950,14 @@ export interface AstroSettings {
|
|
|
1948
1950
|
tsConfigPath: string | undefined;
|
|
1949
1951
|
watchFiles: string[];
|
|
1950
1952
|
timer: AstroTimer;
|
|
1953
|
+
/**
|
|
1954
|
+
* Latest version of Astro, will be undefined if:
|
|
1955
|
+
* - unable to check
|
|
1956
|
+
* - the user has disabled the check
|
|
1957
|
+
* - the check has not completed yet
|
|
1958
|
+
* - the user is on the latest version already
|
|
1959
|
+
*/
|
|
1960
|
+
latestAstroVersion: string | undefined;
|
|
1951
1961
|
}
|
|
1952
1962
|
export type AsyncRendererComponentFn<U> = (Component: any, props: any, slots: Record<string, string>, metadata?: AstroComponentMetadata) => Promise<U>;
|
|
1953
1963
|
/** Generic interface for a component (Astro, Svelte, React, etc.) */
|
|
@@ -2470,7 +2480,7 @@ export interface AstroIntegration {
|
|
|
2470
2480
|
* TODO: Fully remove in Astro 5.0
|
|
2471
2481
|
*/
|
|
2472
2482
|
addDevOverlayPlugin: (entrypoint: string) => void;
|
|
2473
|
-
addDevToolbarApp: (entrypoint: string) => void;
|
|
2483
|
+
addDevToolbarApp: (entrypoint: DevToolbarAppEntry | string) => void;
|
|
2474
2484
|
addMiddleware: (mid: AstroIntegrationMiddleware) => void;
|
|
2475
2485
|
logger: AstroIntegrationLogger;
|
|
2476
2486
|
}) => void | Promise<void>;
|
|
@@ -2482,6 +2492,7 @@ export interface AstroIntegration {
|
|
|
2482
2492
|
'astro:server:setup'?: (options: {
|
|
2483
2493
|
server: vite.ViteDevServer;
|
|
2484
2494
|
logger: AstroIntegrationLogger;
|
|
2495
|
+
toolbar: ReturnType<typeof getToolbarServerCommunicationHelpers>;
|
|
2485
2496
|
}) => void | Promise<void>;
|
|
2486
2497
|
'astro:server:start'?: (options: {
|
|
2487
2498
|
address: AddressInfo;
|
|
@@ -2694,18 +2705,49 @@ export interface ClientDirectiveConfig {
|
|
|
2694
2705
|
name: string;
|
|
2695
2706
|
entrypoint: string;
|
|
2696
2707
|
}
|
|
2697
|
-
|
|
2708
|
+
type DevToolbarAppMeta = {
|
|
2698
2709
|
id: string;
|
|
2699
2710
|
name: string;
|
|
2700
2711
|
icon?: Icon;
|
|
2701
|
-
|
|
2712
|
+
};
|
|
2713
|
+
export type DevToolbarAppEntry = DevToolbarAppMeta & {
|
|
2714
|
+
entrypoint: string;
|
|
2715
|
+
};
|
|
2716
|
+
export type DevToolbarApp = {
|
|
2717
|
+
/**
|
|
2718
|
+
* @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
|
|
2719
|
+
*
|
|
2720
|
+
* Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
|
|
2721
|
+
*
|
|
2722
|
+
* In the future, putting these properties directly on the app object will be removed.
|
|
2723
|
+
*/
|
|
2724
|
+
id?: string;
|
|
2725
|
+
/**
|
|
2726
|
+
* @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
|
|
2727
|
+
*
|
|
2728
|
+
* Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
|
|
2729
|
+
*
|
|
2730
|
+
* In the future, putting these properties directly on the app object will be removed.
|
|
2731
|
+
*/
|
|
2732
|
+
name?: string;
|
|
2733
|
+
/**
|
|
2734
|
+
* @deprecated The `id`, `name`, and `icon` properties should now be defined when using `addDevToolbarApp`.
|
|
2735
|
+
*
|
|
2736
|
+
* Ex: `addDevToolbarApp({ id: 'my-app', name: 'My App', icon: '🚀', entrypoint: '/path/to/app' })`
|
|
2737
|
+
*
|
|
2738
|
+
* In the future, putting these properties directly on the app object will be removed.
|
|
2739
|
+
*/
|
|
2740
|
+
icon?: Icon;
|
|
2741
|
+
init?(canvas: ShadowRoot, app: ToolbarAppEventTarget, server: ToolbarServerHelpers): void | Promise<void>;
|
|
2702
2742
|
beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise<boolean>;
|
|
2703
|
-
}
|
|
2743
|
+
};
|
|
2744
|
+
export type ResolvedDevToolbarApp = DevToolbarAppMeta & Omit<DevToolbarApp, 'id' | 'name' | 'icon'>;
|
|
2704
2745
|
export type DevOverlayPlugin = DevToolbarApp;
|
|
2705
2746
|
export type DevToolbarMetadata = Window & typeof globalThis & {
|
|
2706
2747
|
__astro_dev_toolbar__: {
|
|
2707
2748
|
root: string;
|
|
2708
2749
|
version: string;
|
|
2750
|
+
latestAstroVersion: AstroSettings['latestAstroVersion'];
|
|
2709
2751
|
debugInfo: string;
|
|
2710
2752
|
};
|
|
2711
2753
|
};
|
package/dist/cli/add/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
|
27
27
|
import { ensureProcessNodeEnv, parseNpmName } from "../../core/util.js";
|
|
28
28
|
import { eventCliSession, telemetry } from "../../events/index.js";
|
|
29
29
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
30
|
+
import { fetchPackageJson, fetchPackageVersions } from "../install-package.js";
|
|
30
31
|
import { generate, parse, t, visit } from "./babel.js";
|
|
31
32
|
import { ensureImport } from "./imports.js";
|
|
32
33
|
import { wrapDefaultExport } from "./wrapper.js";
|
|
@@ -77,22 +78,6 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
|
77
78
|
cloudflare: "@astrojs/cloudflare",
|
|
78
79
|
node: "@astrojs/node"
|
|
79
80
|
};
|
|
80
|
-
let _registry;
|
|
81
|
-
async function getRegistry() {
|
|
82
|
-
if (_registry)
|
|
83
|
-
return _registry;
|
|
84
|
-
const fallback = "https://registry.npmjs.org";
|
|
85
|
-
const packageManager = (await preferredPM(process.cwd()))?.name || "npm";
|
|
86
|
-
try {
|
|
87
|
-
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
88
|
-
_registry = stdout?.trim()?.replace(/\/$/, "") || fallback;
|
|
89
|
-
if (!new URL(_registry).host)
|
|
90
|
-
_registry = fallback;
|
|
91
|
-
} catch (e) {
|
|
92
|
-
_registry = fallback;
|
|
93
|
-
}
|
|
94
|
-
return _registry;
|
|
95
|
-
}
|
|
96
81
|
async function add(names, { flags }) {
|
|
97
82
|
ensureProcessNodeEnv("production");
|
|
98
83
|
applyPolyfill();
|
|
@@ -683,31 +668,6 @@ ${message}`
|
|
|
683
668
|
}
|
|
684
669
|
}
|
|
685
670
|
}
|
|
686
|
-
async function fetchPackageJson(scope, name, tag) {
|
|
687
|
-
const packageName = `${scope ? `${scope}/` : ""}${name}`;
|
|
688
|
-
const registry = await getRegistry();
|
|
689
|
-
const res = await fetch(`${registry}/${packageName}/${tag}`);
|
|
690
|
-
if (res.status >= 200 && res.status < 300) {
|
|
691
|
-
return await res.json();
|
|
692
|
-
} else if (res.status === 404) {
|
|
693
|
-
return new Error();
|
|
694
|
-
} else {
|
|
695
|
-
return new Error(`Failed to fetch ${registry}/${packageName}/${tag} - GET ${res.status}`);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
async function fetchPackageVersions(packageName) {
|
|
699
|
-
const registry = await getRegistry();
|
|
700
|
-
const res = await fetch(`${registry}/${packageName}`, {
|
|
701
|
-
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
702
|
-
});
|
|
703
|
-
if (res.status >= 200 && res.status < 300) {
|
|
704
|
-
return await res.json().then((data) => Object.keys(data.versions));
|
|
705
|
-
} else if (res.status === 404) {
|
|
706
|
-
return new Error();
|
|
707
|
-
} else {
|
|
708
|
-
return new Error(`Failed to fetch ${registry}/${packageName} - GET ${res.status}`);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
671
|
async function validateIntegrations(integrations) {
|
|
712
672
|
const spinner = ora("Resolving packages...").start();
|
|
713
673
|
try {
|
|
@@ -5,4 +5,13 @@ type GetPackageOptions = {
|
|
|
5
5
|
cwd?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function getPackage<T>(packageName: string, logger: Logger, options: GetPackageOptions, otherDeps?: string[]): Promise<T | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the command to execute and download a package (e.g. `npx`, `yarn dlx`, `pnpx`, etc.)
|
|
10
|
+
* @param packageManager - Optional package manager to use. If not provided, Astro will attempt to detect the preferred package manager.
|
|
11
|
+
* @returns The command to execute and download a package
|
|
12
|
+
*/
|
|
13
|
+
export declare function getExecCommand(packageManager?: string): Promise<string>;
|
|
14
|
+
export declare function fetchPackageJson(scope: string | undefined, name: string, tag: string): Promise<Record<string, any> | Error>;
|
|
15
|
+
export declare function fetchPackageVersions(packageName: string): Promise<string[] | Error>;
|
|
16
|
+
export declare function getRegistry(): Promise<string>;
|
|
8
17
|
export {};
|
|
@@ -5,6 +5,7 @@ import ci from "ci-info";
|
|
|
5
5
|
import { execa } from "execa";
|
|
6
6
|
import { bold, cyan, dim, magenta } from "kleur/colors";
|
|
7
7
|
import ora from "ora";
|
|
8
|
+
import preferredPM from "preferred-pm";
|
|
8
9
|
import prompts from "prompts";
|
|
9
10
|
import resolvePackage from "resolve";
|
|
10
11
|
import whichPm from "which-pm";
|
|
@@ -76,6 +77,23 @@ function getInstallCommand(packages, packageManager) {
|
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
async function getExecCommand(packageManager) {
|
|
81
|
+
if (!packageManager) {
|
|
82
|
+
packageManager = (await preferredPM(process.cwd()))?.name ?? "npm";
|
|
83
|
+
}
|
|
84
|
+
switch (packageManager) {
|
|
85
|
+
case "npm":
|
|
86
|
+
return "npx";
|
|
87
|
+
case "yarn":
|
|
88
|
+
return "yarn dlx";
|
|
89
|
+
case "pnpm":
|
|
90
|
+
return "pnpx";
|
|
91
|
+
case "bun":
|
|
92
|
+
return "bunx";
|
|
93
|
+
default:
|
|
94
|
+
return "npx";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
79
97
|
async function installPackage(packageNames, options, logger) {
|
|
80
98
|
const cwd = options.cwd ?? process.cwd();
|
|
81
99
|
const packageManager = (await whichPm(cwd))?.name ?? "npm";
|
|
@@ -133,6 +151,51 @@ ${message}`
|
|
|
133
151
|
return false;
|
|
134
152
|
}
|
|
135
153
|
}
|
|
154
|
+
async function fetchPackageJson(scope, name, tag) {
|
|
155
|
+
const packageName = `${scope ? `${scope}/` : ""}${name}`;
|
|
156
|
+
const registry = await getRegistry();
|
|
157
|
+
const res = await fetch(`${registry}/${packageName}/${tag}`);
|
|
158
|
+
if (res.status >= 200 && res.status < 300) {
|
|
159
|
+
return await res.json();
|
|
160
|
+
} else if (res.status === 404) {
|
|
161
|
+
return new Error();
|
|
162
|
+
} else {
|
|
163
|
+
return new Error(`Failed to fetch ${registry}/${packageName}/${tag} - GET ${res.status}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function fetchPackageVersions(packageName) {
|
|
167
|
+
const registry = await getRegistry();
|
|
168
|
+
const res = await fetch(`${registry}/${packageName}`, {
|
|
169
|
+
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
170
|
+
});
|
|
171
|
+
if (res.status >= 200 && res.status < 300) {
|
|
172
|
+
return await res.json().then((data) => Object.keys(data.versions));
|
|
173
|
+
} else if (res.status === 404) {
|
|
174
|
+
return new Error();
|
|
175
|
+
} else {
|
|
176
|
+
return new Error(`Failed to fetch ${registry}/${packageName} - GET ${res.status}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
let _registry;
|
|
180
|
+
async function getRegistry() {
|
|
181
|
+
if (_registry)
|
|
182
|
+
return _registry;
|
|
183
|
+
const fallback = "https://registry.npmjs.org";
|
|
184
|
+
const packageManager = (await preferredPM(process.cwd()))?.name || "npm";
|
|
185
|
+
try {
|
|
186
|
+
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
187
|
+
_registry = stdout?.trim()?.replace(/\/$/, "") || fallback;
|
|
188
|
+
if (!new URL(_registry).host)
|
|
189
|
+
_registry = fallback;
|
|
190
|
+
} catch (e) {
|
|
191
|
+
_registry = fallback;
|
|
192
|
+
}
|
|
193
|
+
return _registry;
|
|
194
|
+
}
|
|
136
195
|
export {
|
|
137
|
-
|
|
196
|
+
fetchPackageJson,
|
|
197
|
+
fetchPackageVersions,
|
|
198
|
+
getExecCommand,
|
|
199
|
+
getPackage,
|
|
200
|
+
getRegistry
|
|
138
201
|
};
|
package/dist/config/index.js
CHANGED
|
@@ -19,7 +19,7 @@ function getViteConfig(inlineConfig) {
|
|
|
19
19
|
import("../core/logger/node.js"),
|
|
20
20
|
import("../core/config/index.js"),
|
|
21
21
|
import("../core/create-vite.js"),
|
|
22
|
-
import("../integrations/
|
|
22
|
+
import("../integrations/hooks.js"),
|
|
23
23
|
import("./vite-plugin-content-listen.js")
|
|
24
24
|
]);
|
|
25
25
|
const logger = new Logger({
|
package/dist/content/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from './consts.js';
|
|
2
|
-
export { errorMap } from './error-map.js';
|
|
3
2
|
export { attachContentServerListeners } from './server-listeners.js';
|
|
4
3
|
export { createContentTypesGenerator } from './types-generator.js';
|
|
5
4
|
export { contentObservable, getContentPaths, getDotAstroTypeReference, hasAssetPropagationFlag, } from './utils.js';
|
package/dist/content/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from "./consts.js";
|
|
2
|
-
import { errorMap } from "./error-map.js";
|
|
3
2
|
import { attachContentServerListeners } from "./server-listeners.js";
|
|
4
3
|
import { createContentTypesGenerator } from "./types-generator.js";
|
|
5
4
|
import {
|
|
@@ -20,7 +19,6 @@ export {
|
|
|
20
19
|
attachContentServerListeners,
|
|
21
20
|
contentObservable,
|
|
22
21
|
createContentTypesGenerator,
|
|
23
|
-
errorMap,
|
|
24
22
|
getContentPaths,
|
|
25
23
|
getDotAstroTypeReference,
|
|
26
24
|
hasAssetPropagationFlag
|
package/dist/content/utils.js
CHANGED
|
@@ -5,11 +5,9 @@ import { slug as githubSlug } from "github-slugger";
|
|
|
5
5
|
import matter from "gray-matter";
|
|
6
6
|
import { normalizePath } from "vite";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
9
|
-
import { MarkdownError } from "../core/errors/index.js";
|
|
8
|
+
import { AstroError, AstroErrorData, MarkdownError, errorMap } from "../core/errors/index.js";
|
|
10
9
|
import { isYAMLException } from "../core/errors/utils.js";
|
|
11
10
|
import { CONTENT_FLAGS, CONTENT_TYPES_FILE, PROPAGATED_ASSET_FLAG } from "./consts.js";
|
|
12
|
-
import { errorMap } from "./error-map.js";
|
|
13
11
|
import { createImage } from "./runtime-assets.js";
|
|
14
12
|
const collectionConfigParser = z.union([
|
|
15
13
|
z.object({
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
removeTrailingForwardSlash
|
|
18
18
|
} from "../../core/path.js";
|
|
19
19
|
import { toRoutingStrategy } from "../../i18n/utils.js";
|
|
20
|
-
import { runHookBuildGenerated } from "../../integrations/
|
|
20
|
+
import { runHookBuildGenerated } from "../../integrations/hooks.js";
|
|
21
21
|
import { getOutputDirectory, isServerLikeOutput } from "../../prerender/utils.js";
|
|
22
22
|
import { NoPrerenderedRoutesWithDomains } from "../errors/errors-data.js";
|
|
23
23
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
package/dist/core/build/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
runHookBuildStart,
|
|
11
11
|
runHookConfigDone,
|
|
12
12
|
runHookConfigSetup
|
|
13
|
-
} from "../../integrations/
|
|
13
|
+
} from "../../integrations/hooks.js";
|
|
14
14
|
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
15
15
|
import { resolveConfig } from "../config/config.js";
|
|
16
16
|
import { createNodeLogger } from "../config/logging.js";
|
|
@@ -4,7 +4,7 @@ import {} from "vite";
|
|
|
4
4
|
import { getAssetsPrefix } from "../../../assets/utils/getAssetsPrefix.js";
|
|
5
5
|
import { normalizeTheLocale } from "../../../i18n/index.js";
|
|
6
6
|
import { toRoutingStrategy } from "../../../i18n/utils.js";
|
|
7
|
-
import { runHookBuildSsr } from "../../../integrations/
|
|
7
|
+
import { runHookBuildSsr } from "../../../integrations/hooks.js";
|
|
8
8
|
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from "../../../vite-plugin-scripts/index.js";
|
|
9
9
|
import { fileExtension, joinPaths, prependForwardSlash } from "../../path.js";
|
|
10
10
|
import { serializeRouteData } from "../../routing/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
-
import { isFunctionPerRouteEnabled } from "../../../integrations/
|
|
3
|
+
import { isFunctionPerRouteEnabled } from "../../../integrations/hooks.js";
|
|
4
4
|
import { isServerLikeOutput } from "../../../prerender/utils.js";
|
|
5
5
|
import { routeIsRedirect } from "../../redirects/index.js";
|
|
6
6
|
import { addRollupInput } from "../add-rollup-input.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { emptyDir, removeEmptyDirs } from "../../core/fs/index.js";
|
|
16
16
|
import { appendForwardSlash, prependForwardSlash, removeFileExtension } from "../../core/path.js";
|
|
17
17
|
import { isModeServerWithNoAdapter } from "../../core/util.js";
|
|
18
|
-
import { runHookBuildSetup } from "../../integrations/
|
|
18
|
+
import { runHookBuildSetup } from "../../integrations/hooks.js";
|
|
19
19
|
import { getOutputDirectory, isServerLikeOutput } from "../../prerender/utils.js";
|
|
20
20
|
import { PAGE_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
|
|
21
21
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
@@ -334,6 +334,10 @@ async function cleanServerOutput(opts, ssrOutputChunkNames, internals) {
|
|
|
334
334
|
removeEmptyDirs(out);
|
|
335
335
|
}
|
|
336
336
|
if (out.toString() !== opts.settings.config.outDir.toString()) {
|
|
337
|
+
const fileNames = await fs.promises.readdir(out);
|
|
338
|
+
await Promise.all(
|
|
339
|
+
fileNames.filter((fileName) => fileName.endsWith(".d.ts")).map((fileName) => fs.promises.rm(new URL(fileName, out)))
|
|
340
|
+
);
|
|
337
341
|
await copyFiles(out, opts.settings.config.outDir, true);
|
|
338
342
|
await fs.promises.rm(out, { recursive: true });
|
|
339
343
|
return;
|
|
@@ -22,7 +22,7 @@ async function compile({
|
|
|
22
22
|
normalizedFilename: normalizeFilename(filename, astroConfig.root),
|
|
23
23
|
sourcemap: "both",
|
|
24
24
|
internalURL: "astro/compiler-runtime",
|
|
25
|
-
// TODO: this is no longer
|
|
25
|
+
// TODO: this is no longer necessary for `Astro.site`
|
|
26
26
|
// but it somehow allows working around caching issues in content collections for some tests
|
|
27
27
|
astroGlobalArgs: JSON.stringify(astroConfig.site),
|
|
28
28
|
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
|
@@ -92,7 +92,9 @@ function createBaseSettings(config) {
|
|
|
92
92
|
middlewares: { pre: [], post: [] },
|
|
93
93
|
watchFiles: [],
|
|
94
94
|
devToolbarApps: [],
|
|
95
|
-
timer: new AstroTimer()
|
|
95
|
+
timer: new AstroTimer(),
|
|
96
|
+
latestAstroVersion: void 0
|
|
97
|
+
// Will be set later if applicable when the dev server starts
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
async function createSettings(config, cwd) {
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const DEFAULT_404_COMPONENT = "astro-default-404";
|
|
|
34
34
|
export declare const REROUTABLE_STATUS_CODES: number[];
|
|
35
35
|
/**
|
|
36
36
|
* The symbol which is used as a field on the request object to store the client address.
|
|
37
|
-
* The
|
|
37
|
+
* The clientAddress provided by the adapter (or the dev server) is stored on this field.
|
|
38
38
|
*/
|
|
39
39
|
export declare const clientAddressSymbol: unique symbol;
|
|
40
40
|
/**
|
package/dist/core/constants.js
CHANGED
package/dist/core/create-vite.js
CHANGED
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
} from "../content/index.js";
|
|
13
13
|
import astroInternationalization from "../i18n/vite-plugin-i18n.js";
|
|
14
14
|
import astroPrefetch from "../prefetch/vite-plugin-prefetch.js";
|
|
15
|
+
import astroDevToolbar from "../toolbar/vite-plugin-dev-toolbar.js";
|
|
15
16
|
import astroTransitions from "../transitions/vite-plugin-transitions.js";
|
|
16
17
|
import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.js";
|
|
17
18
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
18
19
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
19
20
|
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
|
20
|
-
import astroDevToolbar from "../vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js";
|
|
21
21
|
import envVitePlugin from "../vite-plugin-env/index.js";
|
|
22
22
|
import vitePluginFileURL from "../vite-plugin-fileurl/index.js";
|
|
23
23
|
import astroHeadPlugin from "../vite-plugin-head/index.js";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
runHookConfigSetup,
|
|
7
7
|
runHookServerDone,
|
|
8
8
|
runHookServerStart
|
|
9
|
-
} from "../../integrations/
|
|
9
|
+
} from "../../integrations/hooks.js";
|
|
10
10
|
import { createVite } from "../create-vite.js";
|
|
11
11
|
import { apply as applyPolyfill } from "../polyfill.js";
|
|
12
12
|
async function createContainer({
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -1,18 +1,51 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { green } from "kleur/colors";
|
|
3
3
|
import { performance } from "perf_hooks";
|
|
4
|
+
import { gt, major, minor, patch } from "semver";
|
|
4
5
|
import { attachContentServerListeners } from "../../content/index.js";
|
|
5
6
|
import { telemetry } from "../../events/index.js";
|
|
6
7
|
import * as msg from "../messages.js";
|
|
7
8
|
import { ensureProcessNodeEnv } from "../util.js";
|
|
8
9
|
import { startContainer } from "./container.js";
|
|
9
10
|
import { createContainerWithAutomaticRestart } from "./restart.js";
|
|
11
|
+
import {
|
|
12
|
+
MAX_PATCH_DISTANCE,
|
|
13
|
+
fetchLatestAstroVersion,
|
|
14
|
+
shouldCheckForUpdates
|
|
15
|
+
} from "./update-check.js";
|
|
10
16
|
async function dev(inlineConfig) {
|
|
11
17
|
ensureProcessNodeEnv("development");
|
|
12
18
|
const devStart = performance.now();
|
|
13
19
|
await telemetry.record([]);
|
|
14
20
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
15
21
|
const logger = restart.container.logger;
|
|
22
|
+
const currentVersion = "4.7.1";
|
|
23
|
+
const isPrerelease = currentVersion.includes("-");
|
|
24
|
+
if (!isPrerelease) {
|
|
25
|
+
try {
|
|
26
|
+
shouldCheckForUpdates(restart.container.settings.preferences).then(async (shouldCheck) => {
|
|
27
|
+
if (shouldCheck) {
|
|
28
|
+
const version = await fetchLatestAstroVersion(restart.container.settings.preferences);
|
|
29
|
+
if (gt(version, currentVersion)) {
|
|
30
|
+
restart.container.settings.latestAstroVersion = version;
|
|
31
|
+
const sameMajor = major(version) === major(currentVersion);
|
|
32
|
+
const sameMinor = minor(version) === minor(currentVersion);
|
|
33
|
+
const patchDistance = patch(version) - patch(currentVersion);
|
|
34
|
+
if (sameMajor && sameMinor && patchDistance < MAX_PATCH_DISTANCE) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
logger.warn(
|
|
38
|
+
"SKIP_FORMAT",
|
|
39
|
+
msg.newVersionAvailable({
|
|
40
|
+
latestVersion: version
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
16
49
|
const devServerAddressInfo = await startContainer(restart.container);
|
|
17
50
|
logger.info(
|
|
18
51
|
"SKIP_FORMAT",
|
|
@@ -23,8 +56,7 @@ async function dev(inlineConfig) {
|
|
|
23
56
|
base: restart.container.settings.config.base
|
|
24
57
|
})
|
|
25
58
|
);
|
|
26
|
-
|
|
27
|
-
if (currentVersion.includes("-")) {
|
|
59
|
+
if (isPrerelease) {
|
|
28
60
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
61
|
}
|
|
30
62
|
if (restart.container.viteServer.config.server?.fs?.strict === false) {
|
package/dist/core/dev/restart.js
CHANGED
|
@@ -29,7 +29,11 @@ function shouldRestartContainer({ settings, inlineConfig, restartInFlight }, cha
|
|
|
29
29
|
shouldRestart = vite.normalizePath(inlineConfig.configFile) === vite.normalizePath(changedFile);
|
|
30
30
|
} else {
|
|
31
31
|
const normalizedChangedFile = vite.normalizePath(changedFile);
|
|
32
|
-
shouldRestart = configRE.test(normalizedChangedFile)
|
|
32
|
+
shouldRestart = configRE.test(normalizedChangedFile);
|
|
33
|
+
if (preferencesRE.test(normalizedChangedFile)) {
|
|
34
|
+
shouldRestart = settings.preferences.ignoreNextPreferenceReload ? false : true;
|
|
35
|
+
settings.preferences.ignoreNextPreferenceReload = false;
|
|
36
|
+
}
|
|
33
37
|
}
|
|
34
38
|
if (!shouldRestart && settings.watchFiles.length > 0) {
|
|
35
39
|
shouldRestart = settings.watchFiles.some(
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AstroPreferences } from '../../preferences/index.js';
|
|
2
|
+
export declare const MAX_PATCH_DISTANCE = 5;
|
|
3
|
+
export declare function fetchLatestAstroVersion(preferences: AstroPreferences | undefined): Promise<string>;
|
|
4
|
+
export declare function shouldCheckForUpdates(preferences: AstroPreferences): Promise<boolean>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import ci from "ci-info";
|
|
2
|
+
import { fetchPackageJson } from "../../cli/install-package.js";
|
|
3
|
+
const MAX_PATCH_DISTANCE = 5;
|
|
4
|
+
const CHECK_MS_INTERVAL = 10368e5;
|
|
5
|
+
let _latestVersion = void 0;
|
|
6
|
+
async function fetchLatestAstroVersion(preferences) {
|
|
7
|
+
if (_latestVersion) {
|
|
8
|
+
return _latestVersion;
|
|
9
|
+
}
|
|
10
|
+
const packageJson = await fetchPackageJson(void 0, "astro", "latest");
|
|
11
|
+
if (packageJson instanceof Error) {
|
|
12
|
+
throw packageJson;
|
|
13
|
+
}
|
|
14
|
+
const version = packageJson?.version;
|
|
15
|
+
if (!version) {
|
|
16
|
+
throw new Error("Failed to fetch latest Astro version");
|
|
17
|
+
}
|
|
18
|
+
if (preferences) {
|
|
19
|
+
await preferences.set("_variables.lastUpdateCheck", Date.now(), { reloadServer: false });
|
|
20
|
+
}
|
|
21
|
+
_latestVersion = version;
|
|
22
|
+
return version;
|
|
23
|
+
}
|
|
24
|
+
async function shouldCheckForUpdates(preferences) {
|
|
25
|
+
if (ci.isCI) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const timeSinceLastCheck = Date.now() - await preferences.get("_variables.lastUpdateCheck");
|
|
29
|
+
const hasCheckUpdatesEnabled = await preferences.get("checkUpdates.enabled");
|
|
30
|
+
return timeSinceLastCheck > CHECK_MS_INTERVAL && process.env.ASTRO_DISABLE_UPDATE_CHECK !== "true" && hasCheckUpdatesEnabled;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
MAX_PATCH_DISTANCE,
|
|
34
|
+
fetchLatestAstroVersion,
|
|
35
|
+
shouldCheckForUpdates
|
|
36
|
+
};
|
|
@@ -389,7 +389,7 @@ export declare const NoMatchingImport: {
|
|
|
389
389
|
export declare const InvalidPrerenderExport: {
|
|
390
390
|
name: string;
|
|
391
391
|
title: string;
|
|
392
|
-
message(prefix: string, suffix: string,
|
|
392
|
+
message(prefix: string, suffix: string, isHydridOutput: boolean): string;
|
|
393
393
|
hint: string;
|
|
394
394
|
};
|
|
395
395
|
/**
|
|
@@ -125,8 +125,8 @@ const NoMatchingImport = {
|
|
|
125
125
|
const InvalidPrerenderExport = {
|
|
126
126
|
name: "InvalidPrerenderExport",
|
|
127
127
|
title: "Invalid prerender export.",
|
|
128
|
-
message(prefix, suffix,
|
|
129
|
-
const defaultExpectedValue =
|
|
128
|
+
message(prefix, suffix, isHydridOutput) {
|
|
129
|
+
const defaultExpectedValue = isHydridOutput ? "false" : "true";
|
|
130
130
|
let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
|
|
131
131
|
if (prefix !== "const")
|
|
132
132
|
msg += `
|
|
@@ -3,3 +3,4 @@ export { AggregateError, AstroError, AstroUserError, CSSError, CompilerError, Ma
|
|
|
3
3
|
export type { ErrorLocation, ErrorWithMetadata } from './errors.js';
|
|
4
4
|
export { codeFrame } from './printer.js';
|
|
5
5
|
export { createSafeError, positionAt } from './utils.js';
|
|
6
|
+
export { errorMap } from './zod-error-map.js';
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "./errors.js";
|
|
11
11
|
import { codeFrame } from "./printer.js";
|
|
12
12
|
import { createSafeError, positionAt } from "./utils.js";
|
|
13
|
+
import { errorMap } from "./zod-error-map.js";
|
|
13
14
|
export {
|
|
14
15
|
AggregateError,
|
|
15
16
|
AstroError,
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
MarkdownError,
|
|
21
22
|
codeFrame,
|
|
22
23
|
createSafeError,
|
|
24
|
+
errorMap,
|
|
23
25
|
isAstroError,
|
|
24
26
|
positionAt
|
|
25
27
|
};
|
|
@@ -62,7 +62,7 @@ const style = (
|
|
|
62
62
|
|
|
63
63
|
/* Theme toggle */
|
|
64
64
|
--toggle-ball-color: var(--accent);
|
|
65
|
-
--toggle-
|
|
65
|
+
--toggle-table-background: var(--background);
|
|
66
66
|
--sun-icon-color: #ffffff;
|
|
67
67
|
--moon-icon-color: #a3acc8;
|
|
68
68
|
--toggle-border-color: #C3CADB;
|
|
@@ -150,7 +150,7 @@ const style = (
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
#theme-toggle-label {
|
|
153
|
-
background-color: var(--toggle-
|
|
153
|
+
background-color: var(--toggle-table-background);
|
|
154
154
|
border-radius: 50px;
|
|
155
155
|
cursor: pointer;
|
|
156
156
|
display: flex;
|
|
@@ -7,7 +7,7 @@ export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
|
7
7
|
* rather than specific to a single command, function, use, etc. The label will be
|
|
8
8
|
* shown in the log message to the user, so it should be relevant.
|
|
9
9
|
*/
|
|
10
|
-
export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'toolbar' | 'assets' | 'SKIP_FORMAT';
|
|
10
|
+
export type LoggerLabel = 'add' | 'build' | 'check' | 'config' | 'content' | 'deprecated' | 'markdown' | 'router' | 'types' | 'vite' | 'watch' | 'middleware' | 'preferences' | 'redirects' | 'toolbar' | 'assets' | 'update' | 'SKIP_FORMAT';
|
|
11
11
|
export interface LogOptions {
|
|
12
12
|
dest: LogWritable<LogMessage>;
|
|
13
13
|
level: LoggerLevel;
|
package/dist/core/messages.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export declare function serverShortcuts({ key, label }: {
|
|
|
23
23
|
key: string;
|
|
24
24
|
label: string;
|
|
25
25
|
}): string;
|
|
26
|
+
export declare function newVersionAvailable({ latestVersion }: {
|
|
27
|
+
latestVersion: string;
|
|
28
|
+
}): string;
|
|
26
29
|
export declare function telemetryNotice(): string;
|
|
27
30
|
export declare function telemetryEnabled(): string;
|
|
28
31
|
export declare function preferenceEnabled(name: string): string;
|