🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

40
node_modules/astro/dist/core/config/config.d.ts generated vendored Normal file
View file

@ -0,0 +1,40 @@
/// <reference types="node" />
import type { Arguments as Flags } from 'yargs-parser';
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro';
import fs from 'node:fs';
export declare const LEGACY_ASTRO_CONFIG_KEYS: Set<string>;
/** Turn raw config values into normalized values */
export declare function validateConfig(userConfig: any, root: string, cmd: string): Promise<AstroConfig>;
/** Convert the generic "yargs" flag object into our own, custom TypeScript object. */
export declare function resolveFlags(flags: Partial<Flags>): CLIFlags;
export declare function resolveRoot(cwd?: string | URL): string;
interface LoadConfigOptions {
cwd?: string;
flags?: Flags;
cmd: string;
validate?: boolean;
/** Invalidate when reloading a previously loaded config */
isRestart?: boolean;
fsMod?: typeof fs;
}
interface ResolveConfigPathOptions {
cwd?: string;
flags?: Flags;
fs: typeof fs;
}
/**
* Resolve the file URL of the user's `astro.config.js|cjs|mjs|ts` file
*/
export declare function resolveConfigPath(configOptions: ResolveConfigPathOptions): Promise<string | undefined>;
interface OpenConfigResult {
userConfig: AstroUserConfig;
astroConfig: AstroConfig;
flags: CLIFlags;
root: string;
}
/** Load a configuration file, returning both the userConfig and astroConfig */
export declare function openConfig(configOptions: LoadConfigOptions): Promise<OpenConfigResult>;
/** Attempt to resolve an Astro configuration object. Normalize, validate, and return. */
export declare function resolveConfig(userConfig: AstroUserConfig, root: string, flags: CLIFlags | undefined, cmd: string): Promise<AstroConfig>;
export declare function createDefaultDevConfig(userConfig?: AstroUserConfig, root?: string): Promise<AstroConfig>;
export {};

178
node_modules/astro/dist/core/config/config.js generated vendored Normal file
View file

@ -0,0 +1,178 @@
import * as colors from "kleur/colors";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { AstroError, AstroErrorData } from "../errors/index.js";
import { mergeConfig } from "./merge.js";
import { createRelativeSchema } from "./schema.js";
import { loadConfigWithVite } from "./vite-load.js";
const LEGACY_ASTRO_CONFIG_KEYS = /* @__PURE__ */ new Set([
"projectRoot",
"src",
"pages",
"public",
"dist",
"styleOptions",
"markdownOptions",
"buildOptions",
"devOptions"
]);
async function validateConfig(userConfig, root, cmd) {
const fileProtocolRoot = pathToFileURL(root + path.sep);
if (userConfig.hasOwnProperty("renderers")) {
console.error('Astro "renderers" are now "integrations"!');
console.error("Update your configuration and install new dependencies:");
try {
const rendererKeywords = userConfig.renderers.map(
(r) => r.replace("@astrojs/renderer-", "")
);
const rendererImports = rendererKeywords.map((r) => ` import ${r} from '@astrojs/${r === "solid" ? "solid-js" : r}';`).join("\n");
const rendererIntegrations = rendererKeywords.map((r) => ` ${r}(),`).join("\n");
console.error("");
console.error(colors.dim(" // astro.config.js"));
if (rendererImports.length > 0) {
console.error(colors.green(rendererImports));
}
console.error("");
console.error(colors.dim(" // ..."));
if (rendererIntegrations.length > 0) {
console.error(colors.green(" integrations: ["));
console.error(colors.green(rendererIntegrations));
console.error(colors.green(" ],"));
} else {
console.error(colors.green(" integrations: [],"));
}
console.error("");
} catch (err) {
}
process.exit(1);
}
let legacyConfigKey;
for (const key of Object.keys(userConfig)) {
if (LEGACY_ASTRO_CONFIG_KEYS.has(key)) {
legacyConfigKey = key;
break;
}
}
if (legacyConfigKey) {
throw new AstroError({
...AstroErrorData.ConfigLegacyKey,
message: AstroErrorData.ConfigLegacyKey.message(legacyConfigKey)
});
}
const AstroConfigRelativeSchema = createRelativeSchema(cmd, fileProtocolRoot);
const result = await AstroConfigRelativeSchema.parseAsync(userConfig);
return result;
}
function resolveFlags(flags) {
return {
root: typeof flags.root === "string" ? flags.root : void 0,
site: typeof flags.site === "string" ? flags.site : void 0,
base: typeof flags.base === "string" ? flags.base : void 0,
port: typeof flags.port === "number" ? flags.port : void 0,
open: typeof flags.open === "boolean" ? flags.open : void 0,
config: typeof flags.config === "string" ? flags.config : void 0,
host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
drafts: typeof flags.drafts === "boolean" ? flags.drafts : void 0,
experimentalAssets: typeof flags.experimentalAssets === "boolean" ? flags.experimentalAssets : void 0,
experimentalRedirects: typeof flags.experimentalRedirects === "boolean" ? flags.experimentalRedirects : void 0
};
}
function resolveRoot(cwd) {
if (cwd instanceof URL) {
cwd = fileURLToPath(cwd);
}
return cwd ? path.resolve(cwd) : process.cwd();
}
function mergeCLIFlags(astroConfig, flags) {
return mergeConfig(astroConfig, {
site: flags.site,
base: flags.base,
markdown: {
drafts: flags.drafts
},
server: {
port: flags.port,
host: flags.host,
open: flags.open
}
});
}
async function search(fsMod, root) {
const paths = [
"astro.config.mjs",
"astro.config.js",
"astro.config.ts",
"astro.config.mts",
"astro.config.cjs",
"astro.config.cts"
].map((p) => path.join(root, p));
for (const file of paths) {
if (fsMod.existsSync(file)) {
return file;
}
}
}
async function resolveConfigPath(configOptions) {
const root = resolveRoot(configOptions.cwd);
const flags = resolveFlags(configOptions.flags || {});
let userConfigPath;
if (flags == null ? void 0 : flags.config) {
userConfigPath = /^\.*\//.test(flags.config) ? flags.config : `./${flags.config}`;
userConfigPath = fileURLToPath(new URL(userConfigPath, `file://${root}/`));
if (!configOptions.fs.existsSync(userConfigPath)) {
throw new AstroError({
...AstroErrorData.ConfigNotFound,
message: AstroErrorData.ConfigNotFound.message(flags.config)
});
}
} else {
userConfigPath = await search(configOptions.fs, root);
}
return userConfigPath;
}
async function openConfig(configOptions) {
const root = resolveRoot(configOptions.cwd);
const flags = resolveFlags(configOptions.flags || {});
const userConfig = await loadConfig(configOptions, root);
const astroConfig = await resolveConfig(userConfig, root, flags, configOptions.cmd);
return {
astroConfig,
userConfig,
flags,
root
};
}
async function loadConfig(configOptions, root) {
const fsMod = configOptions.fsMod ?? fs;
const configPath = await resolveConfigPath({
cwd: configOptions.cwd,
flags: configOptions.flags,
fs: fsMod
});
if (!configPath)
return {};
return await loadConfigWithVite({
configPath,
fs: fsMod,
root
});
}
async function resolveConfig(userConfig, root, flags = {}, cmd) {
const mergedConfig = mergeCLIFlags(userConfig, flags);
const validatedConfig = await validateConfig(mergedConfig, root, cmd);
return validatedConfig;
}
function createDefaultDevConfig(userConfig = {}, root = process.cwd()) {
return resolveConfig(userConfig, root, void 0, "dev");
}
export {
LEGACY_ASTRO_CONFIG_KEYS,
createDefaultDevConfig,
openConfig,
resolveConfig,
resolveConfigPath,
resolveFlags,
resolveRoot,
validateConfig
};

5
node_modules/astro/dist/core/config/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
export { createDefaultDevConfig, openConfig, resolveConfigPath, resolveFlags, resolveRoot, validateConfig, } from './config.js';
export { mergeConfig } from './merge.js';
export type { AstroConfigSchema } from './schema';
export { createDefaultDevSettings, createSettings } from './settings.js';
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';

24
node_modules/astro/dist/core/config/index.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
import {
createDefaultDevConfig,
openConfig,
resolveConfigPath,
resolveFlags,
resolveRoot,
validateConfig
} from "./config.js";
import { mergeConfig } from "./merge.js";
import { createDefaultDevSettings, createSettings } from "./settings.js";
import { loadTSConfig, updateTSConfigForFramework } from "./tsconfig.js";
export {
createDefaultDevConfig,
createDefaultDevSettings,
createSettings,
loadTSConfig,
mergeConfig,
openConfig,
resolveConfigPath,
resolveFlags,
resolveRoot,
updateTSConfigForFramework,
validateConfig
};

1
node_modules/astro/dist/core/config/merge.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export declare function mergeConfig(defaults: Record<string, any>, overrides: Record<string, any>, isRoot?: boolean): Record<string, any>;

50
node_modules/astro/dist/core/config/merge.js generated vendored Normal file
View file

@ -0,0 +1,50 @@
import { mergeConfig as mergeViteConfig } from "vite";
import { arraify, isObject, isURL } from "../util.js";
function mergeConfigRecursively(defaults, overrides, rootPath) {
const merged = { ...defaults };
for (const key in overrides) {
const value = overrides[key];
if (value == null) {
continue;
}
const existing = merged[key];
if (existing == null) {
merged[key] = value;
continue;
}
if (key === "vite" && rootPath === "") {
merged[key] = mergeViteConfig(existing, value);
continue;
}
if (key === "server" && rootPath === "") {
if (typeof existing === "function" || typeof value === "function") {
merged[key] = (...args) => {
const existingConfig = typeof existing === "function" ? existing(...args) : existing;
const valueConfig = typeof value === "function" ? value(...args) : value;
return mergeConfigRecursively(existingConfig, valueConfig, key);
};
continue;
}
}
if (Array.isArray(existing) || Array.isArray(value)) {
merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
continue;
}
if (isURL(existing) && isURL(value)) {
merged[key] = value;
continue;
}
if (isObject(existing) && isObject(value)) {
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
continue;
}
merged[key] = value;
}
return merged;
}
function mergeConfig(defaults, overrides, isRoot = true) {
return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
}
export {
mergeConfig
};

738
node_modules/astro/dist/core/config/schema.d.ts generated vendored Normal file
View file

@ -0,0 +1,738 @@
/// <reference types="node" />
import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
import type { ViteUserConfig } from '../../@types/astro';
import type { OutgoingHttpHeaders } from 'node:http';
import { z } from 'zod';
export declare const AstroConfigSchema: z.ZodObject<{
root: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
srcDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
publicDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
outDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
cacheDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
site: z.ZodOptional<z.ZodString>;
compressHTML: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
base: z.ZodDefault<z.ZodOptional<z.ZodString>>;
trailingSlash: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"never">, z.ZodLiteral<"ignore">]>>>;
output: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"server">, z.ZodLiteral<"hybrid">]>>>;
scopedStyleStrategy: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"where">, z.ZodLiteral<"class">]>>>;
adapter: z.ZodOptional<z.ZodObject<{
name: z.ZodString;
hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
name: string;
hooks: {};
}, {
hooks?: {} | undefined;
name: string;
}>>;
integrations: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
name: string;
hooks: {};
}, {
hooks?: {} | undefined;
name: string;
}>, "many">>, {
name: string;
hooks: {};
}[], unknown>;
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
assetsPrefix: z.ZodOptional<z.ZodString>;
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
split: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
excludeMiddleware: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
assetsPrefix?: string | undefined;
format: "file" | "directory";
client: URL;
server: URL;
assets: string;
serverEntry: string;
redirects: boolean;
inlineStylesheets: "always" | "never" | "auto";
split: boolean;
excludeMiddleware: boolean;
}, {
format?: "file" | "directory" | undefined;
client?: string | undefined;
server?: string | undefined;
assets?: string | undefined;
serverEntry?: string | undefined;
redirects?: boolean | undefined;
inlineStylesheets?: "always" | "never" | "auto" | undefined;
split?: boolean | undefined;
excludeMiddleware?: boolean | undefined;
assetsPrefix?: string | undefined;
}>>>;
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
open: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
headers: z.ZodOptional<z.ZodType<OutgoingHttpHeaders, z.ZodTypeDef, OutgoingHttpHeaders>>;
}, "strip", z.ZodTypeAny, {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
}, {
host?: string | boolean | undefined;
port?: number | undefined;
headers?: OutgoingHttpHeaders | undefined;
open?: boolean | undefined;
}>>>, {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
}, unknown>;
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
image: z.ZodDefault<z.ZodObject<{
service: z.ZodObject<{
entrypoint: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
entrypoint: string;
config: Record<string, any>;
}, {
config?: Record<string, any> | undefined;
entrypoint: string;
}>;
}, "strip", z.ZodTypeAny, {
service: {
entrypoint: string;
config: Record<string, any>;
};
}, {
service: {
config?: Record<string, any> | undefined;
entrypoint: string;
};
}>>;
markdown: z.ZodDefault<z.ZodObject<{
drafts: z.ZodDefault<z.ZodBoolean>;
syntaxHighlight: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>;
shikiConfig: z.ZodDefault<z.ZodObject<{
langs: z.ZodDefault<z.ZodArray<z.ZodType<ILanguageRegistration, z.ZodTypeDef, ILanguageRegistration>, "many">>;
theme: z.ZodDefault<z.ZodUnion<[z.ZodEnum<[Theme, ...Theme[]]>, z.ZodType<IThemeRegistration, z.ZodTypeDef, IThemeRegistration>]>>;
wrap: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
}, "strip", z.ZodTypeAny, {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
}, {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
}>>;
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodTuple<[z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodAny], null>]>, "many">>;
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodTuple<[z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodAny], null>]>, "many">>;
remarkRehype: z.ZodDefault<z.ZodOptional<z.ZodType<RemarkRehype, z.ZodTypeDef, RemarkRehype>>>;
gfm: z.ZodDefault<z.ZodBoolean>;
smartypants: z.ZodDefault<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
drafts: boolean;
syntaxHighlight: false | "shiki" | "prism";
shikiConfig: {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
};
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
remarkRehype: RemarkRehype;
gfm: boolean;
smartypants: boolean;
}, {
drafts?: boolean | undefined;
syntaxHighlight?: false | "shiki" | "prism" | undefined;
shikiConfig?: {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
} | undefined;
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
remarkRehype?: RemarkRehype | undefined;
gfm?: boolean | undefined;
smartypants?: boolean | undefined;
}>>;
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "passthrough", z.ZodTypeAny, {
assets: boolean;
redirects: boolean;
}, {
assets?: boolean | undefined;
redirects?: boolean | undefined;
}>, {
assets: boolean;
redirects: boolean;
}, {
assets?: boolean | undefined;
redirects?: boolean | undefined;
}>>>;
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
}, "strip", z.ZodTypeAny, {
site?: string | undefined;
adapter?: {
name: string;
hooks: {};
} | undefined;
output: "server" | "static" | "hybrid";
server: {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
};
redirects: Record<string, string>;
root: URL;
srcDir: URL;
publicDir: URL;
outDir: URL;
cacheDir: URL;
compressHTML: boolean;
base: string;
trailingSlash: "ignore" | "always" | "never";
scopedStyleStrategy: "where" | "class";
integrations: {
name: string;
hooks: {};
}[];
build: {
assetsPrefix?: string | undefined;
format: "file" | "directory";
client: URL;
server: URL;
assets: string;
serverEntry: string;
redirects: boolean;
inlineStylesheets: "always" | "never" | "auto";
split: boolean;
excludeMiddleware: boolean;
};
image: {
service: {
entrypoint: string;
config: Record<string, any>;
};
};
markdown: {
drafts: boolean;
syntaxHighlight: false | "shiki" | "prism";
shikiConfig: {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
};
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
remarkRehype: RemarkRehype;
gfm: boolean;
smartypants: boolean;
};
vite: ViteUserConfig;
experimental: {
assets: boolean;
redirects: boolean;
};
legacy: {};
}, {
output?: "server" | "static" | "hybrid" | undefined;
server?: unknown;
redirects?: Record<string, string> | undefined;
root?: string | undefined;
srcDir?: string | undefined;
publicDir?: string | undefined;
outDir?: string | undefined;
cacheDir?: string | undefined;
site?: string | undefined;
compressHTML?: boolean | undefined;
base?: string | undefined;
trailingSlash?: "ignore" | "always" | "never" | undefined;
scopedStyleStrategy?: "where" | "class" | undefined;
adapter?: {
hooks?: {} | undefined;
name: string;
} | undefined;
integrations?: unknown;
build?: {
format?: "file" | "directory" | undefined;
client?: string | undefined;
server?: string | undefined;
assets?: string | undefined;
serverEntry?: string | undefined;
redirects?: boolean | undefined;
inlineStylesheets?: "always" | "never" | "auto" | undefined;
split?: boolean | undefined;
excludeMiddleware?: boolean | undefined;
assetsPrefix?: string | undefined;
} | undefined;
image?: {
service: {
config?: Record<string, any> | undefined;
entrypoint: string;
};
} | undefined;
markdown?: {
drafts?: boolean | undefined;
syntaxHighlight?: false | "shiki" | "prism" | undefined;
shikiConfig?: {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
} | undefined;
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
remarkRehype?: RemarkRehype | undefined;
gfm?: boolean | undefined;
smartypants?: boolean | undefined;
} | undefined;
vite?: ViteUserConfig | undefined;
experimental?: {
assets?: boolean | undefined;
redirects?: boolean | undefined;
} | undefined;
legacy?: {} | undefined;
}>;
export declare function createRelativeSchema(cmd: string, fileProtocolRoot: URL): z.ZodEffects<z.ZodObject<{
output: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"server">, z.ZodLiteral<"hybrid">]>>>;
redirects: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
site: z.ZodOptional<z.ZodString>;
base: z.ZodDefault<z.ZodOptional<z.ZodString>>;
trailingSlash: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"never">, z.ZodLiteral<"ignore">]>>>;
scopedStyleStrategy: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"where">, z.ZodLiteral<"class">]>>>;
adapter: z.ZodOptional<z.ZodObject<{
name: z.ZodString;
hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
name: string;
hooks: {};
}, {
hooks?: {} | undefined;
name: string;
}>>;
integrations: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
hooks: z.ZodDefault<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
}, "strip", z.ZodTypeAny, {
name: string;
hooks: {};
}, {
hooks?: {} | undefined;
name: string;
}>, "many">>, {
name: string;
hooks: {};
}[], unknown>;
image: z.ZodDefault<z.ZodObject<{
service: z.ZodObject<{
entrypoint: z.ZodUnion<[z.ZodLiteral<"astro/assets/services/sharp">, z.ZodLiteral<"astro/assets/services/squoosh">, z.ZodString]>;
config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
entrypoint: string;
config: Record<string, any>;
}, {
config?: Record<string, any> | undefined;
entrypoint: string;
}>;
}, "strip", z.ZodTypeAny, {
service: {
entrypoint: string;
config: Record<string, any>;
};
}, {
service: {
config?: Record<string, any> | undefined;
entrypoint: string;
};
}>>;
markdown: z.ZodDefault<z.ZodObject<{
drafts: z.ZodDefault<z.ZodBoolean>;
syntaxHighlight: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"shiki">, z.ZodLiteral<"prism">, z.ZodLiteral<false>]>>;
shikiConfig: z.ZodDefault<z.ZodObject<{
langs: z.ZodDefault<z.ZodArray<z.ZodType<ILanguageRegistration, z.ZodTypeDef, ILanguageRegistration>, "many">>;
theme: z.ZodDefault<z.ZodUnion<[z.ZodEnum<[Theme, ...Theme[]]>, z.ZodType<IThemeRegistration, z.ZodTypeDef, IThemeRegistration>]>>;
wrap: z.ZodDefault<z.ZodUnion<[z.ZodBoolean, z.ZodNull]>>;
}, "strip", z.ZodTypeAny, {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
}, {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
}>>;
remarkPlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodTuple<[z.ZodType<RemarkPlugin, z.ZodTypeDef, RemarkPlugin>, z.ZodAny], null>]>, "many">>;
rehypePlugins: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodAny], null>, z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodTuple<[z.ZodType<RehypePlugin, z.ZodTypeDef, RehypePlugin>, z.ZodAny], null>]>, "many">>;
remarkRehype: z.ZodDefault<z.ZodOptional<z.ZodType<RemarkRehype, z.ZodTypeDef, RemarkRehype>>>;
gfm: z.ZodDefault<z.ZodBoolean>;
smartypants: z.ZodDefault<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
drafts: boolean;
syntaxHighlight: false | "shiki" | "prism";
shikiConfig: {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
};
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
remarkRehype: RemarkRehype;
gfm: boolean;
smartypants: boolean;
}, {
drafts?: boolean | undefined;
syntaxHighlight?: false | "shiki" | "prism" | undefined;
shikiConfig?: {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
} | undefined;
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
remarkRehype?: RemarkRehype | undefined;
gfm?: boolean | undefined;
smartypants?: boolean | undefined;
}>>;
vite: z.ZodDefault<z.ZodType<ViteUserConfig, z.ZodTypeDef, ViteUserConfig>>;
experimental: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodObject<{
assets: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "passthrough", z.ZodTypeAny, {
assets: boolean;
redirects: boolean;
}, {
assets?: boolean | undefined;
redirects?: boolean | undefined;
}>, {
assets: boolean;
redirects: boolean;
}, {
assets?: boolean | undefined;
redirects?: boolean | undefined;
}>>>;
legacy: z.ZodDefault<z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>>;
root: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
srcDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
compressHTML: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
publicDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
outDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
cacheDir: z.ZodEffects<z.ZodDefault<z.ZodString>, URL, string | undefined>;
build: z.ZodDefault<z.ZodOptional<z.ZodObject<{
format: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"file">, z.ZodLiteral<"directory">]>>>;
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, URL, string | undefined>;
assets: z.ZodDefault<z.ZodOptional<z.ZodString>>;
assetsPrefix: z.ZodOptional<z.ZodString>;
serverEntry: z.ZodDefault<z.ZodOptional<z.ZodString>>;
redirects: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
inlineStylesheets: z.ZodDefault<z.ZodOptional<z.ZodEnum<["always", "auto", "never"]>>>;
split: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
excludeMiddleware: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
assetsPrefix?: string | undefined;
format: "file" | "directory";
client: URL;
server: URL;
assets: string;
serverEntry: string;
redirects: boolean;
inlineStylesheets: "always" | "never" | "auto";
split: boolean;
excludeMiddleware: boolean;
}, {
format?: "file" | "directory" | undefined;
client?: string | undefined;
server?: string | undefined;
assets?: string | undefined;
serverEntry?: string | undefined;
redirects?: boolean | undefined;
inlineStylesheets?: "always" | "never" | "auto" | undefined;
split?: boolean | undefined;
excludeMiddleware?: boolean | undefined;
assetsPrefix?: string | undefined;
}>>>;
server: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodObject<{
host: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
open: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
headers: z.ZodOptional<z.ZodType<OutgoingHttpHeaders, z.ZodTypeDef, OutgoingHttpHeaders>>;
streaming: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
streaming: boolean;
}, {
host?: string | boolean | undefined;
port?: number | undefined;
headers?: OutgoingHttpHeaders | undefined;
open?: boolean | undefined;
streaming?: boolean | undefined;
}>>>, {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
streaming: boolean;
}, unknown>;
}, "strip", z.ZodTypeAny, {
site?: string | undefined;
adapter?: {
name: string;
hooks: {};
} | undefined;
output: "server" | "static" | "hybrid";
server: {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
streaming: boolean;
};
redirects: Record<string, string>;
root: URL;
srcDir: URL;
publicDir: URL;
outDir: URL;
cacheDir: URL;
compressHTML: boolean;
base: string;
trailingSlash: "ignore" | "always" | "never";
scopedStyleStrategy: "where" | "class";
integrations: {
name: string;
hooks: {};
}[];
build: {
assetsPrefix?: string | undefined;
format: "file" | "directory";
client: URL;
server: URL;
assets: string;
serverEntry: string;
redirects: boolean;
inlineStylesheets: "always" | "never" | "auto";
split: boolean;
excludeMiddleware: boolean;
};
image: {
service: {
entrypoint: string;
config: Record<string, any>;
};
};
markdown: {
drafts: boolean;
syntaxHighlight: false | "shiki" | "prism";
shikiConfig: {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
};
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
remarkRehype: RemarkRehype;
gfm: boolean;
smartypants: boolean;
};
vite: ViteUserConfig;
experimental: {
assets: boolean;
redirects: boolean;
};
legacy: {};
}, {
output?: "server" | "static" | "hybrid" | undefined;
server?: unknown;
redirects?: Record<string, string> | undefined;
root?: string | undefined;
srcDir?: string | undefined;
publicDir?: string | undefined;
outDir?: string | undefined;
cacheDir?: string | undefined;
site?: string | undefined;
compressHTML?: boolean | undefined;
base?: string | undefined;
trailingSlash?: "ignore" | "always" | "never" | undefined;
scopedStyleStrategy?: "where" | "class" | undefined;
adapter?: {
hooks?: {} | undefined;
name: string;
} | undefined;
integrations?: unknown;
build?: {
format?: "file" | "directory" | undefined;
client?: string | undefined;
server?: string | undefined;
assets?: string | undefined;
serverEntry?: string | undefined;
redirects?: boolean | undefined;
inlineStylesheets?: "always" | "never" | "auto" | undefined;
split?: boolean | undefined;
excludeMiddleware?: boolean | undefined;
assetsPrefix?: string | undefined;
} | undefined;
image?: {
service: {
config?: Record<string, any> | undefined;
entrypoint: string;
};
} | undefined;
markdown?: {
drafts?: boolean | undefined;
syntaxHighlight?: false | "shiki" | "prism" | undefined;
shikiConfig?: {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
} | undefined;
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
remarkRehype?: RemarkRehype | undefined;
gfm?: boolean | undefined;
smartypants?: boolean | undefined;
} | undefined;
vite?: ViteUserConfig | undefined;
experimental?: {
assets?: boolean | undefined;
redirects?: boolean | undefined;
} | undefined;
legacy?: {} | undefined;
}>, {
site?: string | undefined;
adapter?: {
name: string;
hooks: {};
} | undefined;
output: "server" | "static" | "hybrid";
server: {
headers?: OutgoingHttpHeaders | undefined;
host: string | boolean;
port: number;
open: boolean;
streaming: boolean;
};
redirects: Record<string, string>;
root: URL;
srcDir: URL;
publicDir: URL;
outDir: URL;
cacheDir: URL;
compressHTML: boolean;
base: string;
trailingSlash: "ignore" | "always" | "never";
scopedStyleStrategy: "where" | "class";
integrations: {
name: string;
hooks: {};
}[];
build: {
assetsPrefix?: string | undefined;
format: "file" | "directory";
client: URL;
server: URL;
assets: string;
serverEntry: string;
redirects: boolean;
inlineStylesheets: "always" | "never" | "auto";
split: boolean;
excludeMiddleware: boolean;
};
image: {
service: {
entrypoint: string;
config: Record<string, any>;
};
};
markdown: {
drafts: boolean;
syntaxHighlight: false | "shiki" | "prism";
shikiConfig: {
langs: ILanguageRegistration[];
theme: string | import("shiki").IShikiTheme;
wrap: boolean | null;
};
remarkPlugins: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
rehypePlugins: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
remarkRehype: RemarkRehype;
gfm: boolean;
smartypants: boolean;
};
vite: ViteUserConfig;
experimental: {
assets: boolean;
redirects: boolean;
};
legacy: {};
}, {
output?: "server" | "static" | "hybrid" | undefined;
server?: unknown;
redirects?: Record<string, string> | undefined;
root?: string | undefined;
srcDir?: string | undefined;
publicDir?: string | undefined;
outDir?: string | undefined;
cacheDir?: string | undefined;
site?: string | undefined;
compressHTML?: boolean | undefined;
base?: string | undefined;
trailingSlash?: "ignore" | "always" | "never" | undefined;
scopedStyleStrategy?: "where" | "class" | undefined;
adapter?: {
hooks?: {} | undefined;
name: string;
} | undefined;
integrations?: unknown;
build?: {
format?: "file" | "directory" | undefined;
client?: string | undefined;
server?: string | undefined;
assets?: string | undefined;
serverEntry?: string | undefined;
redirects?: boolean | undefined;
inlineStylesheets?: "always" | "never" | "auto" | undefined;
split?: boolean | undefined;
excludeMiddleware?: boolean | undefined;
assetsPrefix?: string | undefined;
} | undefined;
image?: {
service: {
config?: Record<string, any> | undefined;
entrypoint: string;
};
} | undefined;
markdown?: {
drafts?: boolean | undefined;
syntaxHighlight?: false | "shiki" | "prism" | undefined;
shikiConfig?: {
langs?: ILanguageRegistration[] | undefined;
theme?: string | import("shiki").IShikiTheme | undefined;
wrap?: boolean | null | undefined;
} | undefined;
remarkPlugins?: (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[] | undefined;
rehypePlugins?: (string | [string, any] | RehypePlugin | [RehypePlugin, any])[] | undefined;
remarkRehype?: RemarkRehype | undefined;
gfm?: boolean | undefined;
smartypants?: boolean | undefined;
} | undefined;
vite?: ViteUserConfig | undefined;
experimental?: {
assets?: boolean | undefined;
redirects?: boolean | undefined;
} | undefined;
legacy?: {} | undefined;
}>;

215
node_modules/astro/dist/core/config/schema.js generated vendored Normal file
View file

@ -0,0 +1,215 @@
import { markdownConfigDefaults } from "@astrojs/markdown-remark";
import { BUNDLED_THEMES } from "shiki";
import { z } from "zod";
import { appendForwardSlash, prependForwardSlash, trimSlashes } from "../path.js";
const ASTRO_CONFIG_DEFAULTS = {
root: ".",
srcDir: "./src",
publicDir: "./public",
outDir: "./dist",
cacheDir: "./node_modules/.astro",
base: "/",
trailingSlash: "ignore",
build: {
format: "directory",
client: "./dist/client/",
server: "./dist/server/",
assets: "_astro",
serverEntry: "entry.mjs",
redirects: true,
inlineStylesheets: "never",
split: false,
excludeMiddleware: false
},
compressHTML: false,
server: {
host: false,
port: 3e3,
open: false
},
integrations: [],
markdown: {
drafts: false,
...markdownConfigDefaults
},
vite: {},
legacy: {},
redirects: {},
experimental: {
assets: false,
redirects: false
}
};
const AstroConfigSchema = z.object({
root: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => new URL(val)),
srcDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => new URL(val)),
publicDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => new URL(val)),
outDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => new URL(val)),
cacheDir: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => new URL(val)),
site: z.string().url().optional(),
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
base: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.base),
trailingSlash: z.union([z.literal("always"), z.literal("never"), z.literal("ignore")]).optional().default(ASTRO_CONFIG_DEFAULTS.trailingSlash),
output: z.union([z.literal("static"), z.literal("server"), z.literal("hybrid")]).optional().default("static"),
scopedStyleStrategy: z.union([z.literal("where"), z.literal("class")]).optional().default("where"),
adapter: z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) }).optional(),
integrations: z.preprocess(
// preprocess
(val) => Array.isArray(val) ? val.flat(Infinity).filter(Boolean) : val,
// validate
z.array(z.object({ name: z.string(), hooks: z.object({}).passthrough().default({}) })).default(ASTRO_CONFIG_DEFAULTS.integrations)
),
build: z.object({
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val)),
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val)),
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
assetsPrefix: z.string().optional(),
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
split: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.split),
excludeMiddleware: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.excludeMiddleware)
}).optional().default({}),
server: z.preprocess(
// preprocess
// NOTE: Uses the "error" command here because this is overwritten by the
// individualized schema parser with the correct command.
(val) => typeof val === "function" ? val({ command: "error" }) : val,
// validate
z.object({
open: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.server.open),
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
headers: z.custom().optional()
}).optional().default({})
),
redirects: z.record(z.string(), z.string()).default(ASTRO_CONFIG_DEFAULTS.redirects),
image: z.object({
service: z.object({
entrypoint: z.union([
z.literal("astro/assets/services/sharp"),
z.literal("astro/assets/services/squoosh"),
z.string()
]),
config: z.record(z.any()).default({})
})
}).default({
service: { entrypoint: "astro/assets/services/squoosh", config: {} }
}),
markdown: z.object({
drafts: z.boolean().default(false),
syntaxHighlight: z.union([z.literal("shiki"), z.literal("prism"), z.literal(false)]).default(ASTRO_CONFIG_DEFAULTS.markdown.syntaxHighlight),
shikiConfig: z.object({
langs: z.custom().array().default([]),
theme: z.enum(BUNDLED_THEMES).or(z.custom()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.theme),
wrap: z.boolean().or(z.null()).default(ASTRO_CONFIG_DEFAULTS.markdown.shikiConfig.wrap)
}).default({}),
remarkPlugins: z.union([
z.string(),
z.tuple([z.string(), z.any()]),
z.custom((data) => typeof data === "function"),
z.tuple([z.custom((data) => typeof data === "function"), z.any()])
]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.remarkPlugins),
rehypePlugins: z.union([
z.string(),
z.tuple([z.string(), z.any()]),
z.custom((data) => typeof data === "function"),
z.tuple([z.custom((data) => typeof data === "function"), z.any()])
]).array().default(ASTRO_CONFIG_DEFAULTS.markdown.rehypePlugins),
remarkRehype: z.custom((data) => data instanceof Object && !Array.isArray(data)).optional().default(ASTRO_CONFIG_DEFAULTS.markdown.remarkRehype),
gfm: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.gfm),
smartypants: z.boolean().default(ASTRO_CONFIG_DEFAULTS.markdown.smartypants)
}).default({}),
vite: z.custom((data) => data instanceof Object && !Array.isArray(data)).default(ASTRO_CONFIG_DEFAULTS.vite),
experimental: z.object({
assets: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.assets),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.redirects)
}).passthrough().refine(
(d) => {
const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
const invalidKeys = Object.keys(d).filter((key) => !validKeys.includes(key));
if (invalidKeys.length > 0)
return false;
return true;
},
(d) => {
const validKeys = Object.keys(ASTRO_CONFIG_DEFAULTS.experimental);
const invalidKeys = Object.keys(d).filter((key) => !validKeys.includes(key));
return {
message: `Invalid experimental key: \`${invalidKeys.join(
", "
)}\`.
Make sure the spelling is correct, and that your Astro version supports this experiment.
See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags for more information.`
};
}
).optional().default({}),
legacy: z.object({}).optional().default({})
});
function createRelativeSchema(cmd, fileProtocolRoot) {
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
root: z.string().default(ASTRO_CONFIG_DEFAULTS.root).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
srcDir: z.string().default(ASTRO_CONFIG_DEFAULTS.srcDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
publicDir: z.string().default(ASTRO_CONFIG_DEFAULTS.publicDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
outDir: z.string().default(ASTRO_CONFIG_DEFAULTS.outDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
cacheDir: z.string().default(ASTRO_CONFIG_DEFAULTS.cacheDir).transform((val) => new URL(appendForwardSlash(val), fileProtocolRoot)),
build: z.object({
format: z.union([z.literal("file"), z.literal("directory")]).optional().default(ASTRO_CONFIG_DEFAULTS.build.format),
client: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.client).transform((val) => new URL(val, fileProtocolRoot)),
server: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.server).transform((val) => new URL(val, fileProtocolRoot)),
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
assetsPrefix: z.string().optional(),
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
inlineStylesheets: z.enum(["always", "auto", "never"]).optional().default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
split: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.split),
excludeMiddleware: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.excludeMiddleware)
}).optional().default({}),
server: z.preprocess(
// preprocess
(val) => {
if (typeof val === "function") {
return val({ command: cmd === "dev" ? "dev" : "preview" });
} else {
return val;
}
},
// validate
z.object({
host: z.union([z.string(), z.boolean()]).optional().default(ASTRO_CONFIG_DEFAULTS.server.host),
port: z.number().optional().default(ASTRO_CONFIG_DEFAULTS.server.port),
open: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.server.open),
headers: z.custom().optional(),
streaming: z.boolean().optional().default(true)
}).optional().default({})
)
}).transform((config) => {
if (!config.build.server.toString().startsWith(config.outDir.toString()) && config.build.server.toString().endsWith("dist/server/")) {
config.build.server = new URL("./dist/server/", config.outDir);
}
if (!config.build.client.toString().startsWith(config.outDir.toString()) && config.build.client.toString().endsWith("dist/client/")) {
config.build.client = new URL("./dist/client/", config.outDir);
}
const trimmedBase = trimSlashes(config.base);
const sitePathname = config.site && new URL(config.site).pathname;
if (!trimmedBase.length && sitePathname && sitePathname !== "/") {
config.base = sitePathname;
console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
}
if (trimmedBase.length && config.trailingSlash === "never") {
config.base = prependForwardSlash(trimmedBase);
} else {
config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
}
return config;
});
return AstroConfigRelativeSchema;
}
export {
AstroConfigSchema,
createRelativeSchema
};

4
node_modules/astro/dist/core/config/settings.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro';
export declare function createBaseSettings(config: AstroConfig): AstroSettings;
export declare function createSettings(config: AstroConfig, cwd?: string): AstroSettings;
export declare function createDefaultDevSettings(userConfig?: AstroUserConfig, root?: string | URL): Promise<AstroSettings>;

118
node_modules/astro/dist/core/config/settings.js generated vendored Normal file
View file

@ -0,0 +1,118 @@
import yaml from "js-yaml";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { getContentPaths } from "../../content/index.js";
import jsxRenderer from "../../jsx/renderer.js";
import { isServerLikeOutput } from "../../prerender/utils.js";
import { markdownContentEntryType } from "../../vite-plugin-markdown/content-entry-type.js";
import { getDefaultClientDirectives } from "../client-directive/index.js";
import { AstroError, AstroErrorData } from "../errors/index.js";
import { formatYAMLException, isYAMLException } from "../errors/utils.js";
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./../constants.js";
import { createDefaultDevConfig } from "./config.js";
import { AstroTimer } from "./timer.js";
import { loadTSConfig } from "./tsconfig.js";
function createBaseSettings(config) {
const { contentDir } = getContentPaths(config);
return {
config,
tsConfig: void 0,
tsConfigPath: void 0,
adapter: void 0,
injectedRoutes: config.experimental.assets && isServerLikeOutput(config) ? [{ pattern: "/_image", entryPoint: "astro/assets/image-endpoint", prerender: false }] : [],
pageExtensions: [".astro", ".html", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS],
contentEntryTypes: [markdownContentEntryType],
dataEntryTypes: [
{
extensions: [".json"],
getEntryInfo({ contents, fileUrl }) {
if (contents === void 0 || contents === "")
return { data: {} };
const pathRelToContentDir = path.relative(
fileURLToPath(contentDir),
fileURLToPath(fileUrl)
);
let data;
try {
data = JSON.parse(contents);
} catch (e) {
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
e instanceof Error ? e.message : "contains invalid JSON."
),
location: { file: fileUrl.pathname },
stack: e instanceof Error ? e.stack : void 0
});
}
if (data == null || typeof data !== "object") {
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
"data is not an object."
),
location: { file: fileUrl.pathname }
});
}
return { data };
}
},
{
extensions: [".yaml", ".yml"],
getEntryInfo({ contents, fileUrl }) {
try {
const data = yaml.load(contents, { filename: fileURLToPath(fileUrl) });
const rawData = contents;
return { data, rawData };
} catch (e) {
const pathRelToContentDir = path.relative(
fileURLToPath(contentDir),
fileURLToPath(fileUrl)
);
const formattedError = isYAMLException(e) ? formatYAMLException(e) : new Error("contains invalid YAML.");
throw new AstroError({
...AstroErrorData.DataCollectionEntryParseError,
message: AstroErrorData.DataCollectionEntryParseError.message(
pathRelToContentDir,
formattedError.message
),
stack: formattedError.stack,
location: "loc" in formattedError ? { file: fileUrl.pathname, ...formattedError.loc } : { file: fileUrl.pathname }
});
}
}
}
],
renderers: [jsxRenderer],
scripts: [],
clientDirectives: getDefaultClientDirectives(),
watchFiles: [],
timer: new AstroTimer()
};
}
function createSettings(config, cwd) {
const tsconfig = loadTSConfig(cwd);
const settings = createBaseSettings(config);
const watchFiles = (tsconfig == null ? void 0 : tsconfig.exists) ? [tsconfig.path, ...tsconfig.extendedPaths] : [];
if (cwd) {
watchFiles.push(fileURLToPath(new URL("./package.json", pathToFileURL(cwd))));
}
settings.tsConfig = tsconfig == null ? void 0 : tsconfig.config;
settings.tsConfigPath = tsconfig == null ? void 0 : tsconfig.path;
settings.watchFiles = watchFiles;
return settings;
}
async function createDefaultDevSettings(userConfig = {}, root) {
if (root && typeof root !== "string") {
root = fileURLToPath(root);
}
const config = await createDefaultDevConfig(userConfig, root);
return createBaseSettings(config);
}
export {
createBaseSettings,
createDefaultDevSettings,
createSettings
};

27
node_modules/astro/dist/core/config/timer.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
export interface Stat {
elapsedTime: number;
heapUsedChange: number;
heapUsedTotal: number;
}
/**
* Timer to track certain operations' performance. Used by Astro's scripts only.
* Set `process.env.ASTRO_TIMER_PATH` truthy to enable.
*/
export declare class AstroTimer {
private enabled;
private ongoingTimers;
private stats;
constructor();
/**
* Start a timer for a scope with a given name.
*/
start(name: string): void;
/**
* End a timer for a scope with a given name.
*/
end(name: string): void;
/**
* Write stats to `process.env.ASTRO_TIMER_PATH`
*/
writeStats(): void;
}

51
node_modules/astro/dist/core/config/timer.js generated vendored Normal file
View file

@ -0,0 +1,51 @@
import fs from "node:fs";
class AstroTimer {
constructor() {
this.ongoingTimers = /* @__PURE__ */ new Map();
this.stats = {};
this.enabled = !!process.env.ASTRO_TIMER_PATH;
}
/**
* Start a timer for a scope with a given name.
*/
start(name) {
var _a;
if (!this.enabled)
return;
(_a = globalThis.gc) == null ? void 0 : _a.call(globalThis);
this.ongoingTimers.set(name, {
startTime: performance.now(),
startHeap: process.memoryUsage().heapUsed
});
}
/**
* End a timer for a scope with a given name.
*/
end(name) {
var _a;
if (!this.enabled)
return;
const stat = this.ongoingTimers.get(name);
if (!stat)
return;
(_a = globalThis.gc) == null ? void 0 : _a.call(globalThis);
const endHeap = process.memoryUsage().heapUsed;
this.stats[name] = {
elapsedTime: performance.now() - stat.startTime,
heapUsedChange: endHeap - stat.startHeap,
heapUsedTotal: endHeap
};
this.ongoingTimers.delete(name);
}
/**
* Write stats to `process.env.ASTRO_TIMER_PATH`
*/
writeStats() {
if (!this.enabled)
return;
fs.writeFileSync(process.env.ASTRO_TIMER_PATH, JSON.stringify(this.stats, null, 2));
}
}
export {
AstroTimer
};

11
node_modules/astro/dist/core/config/tsconfig.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import * as tsr from 'tsconfig-resolver';
export declare const defaultTSConfig: tsr.TsConfigJson;
export type frameworkWithTSSettings = 'vue' | 'react' | 'preact' | 'solid-js';
export declare const presets: Map<frameworkWithTSSettings, tsr.TsConfigJson>;
/**
* Load a tsconfig.json or jsconfig.json is the former is not found
* @param cwd Directory to start from
* @param resolve Determine if the function should go up directories like TypeScript would
*/
export declare function loadTSConfig(cwd: string | undefined, resolve?: boolean): tsr.TsConfigResult;
export declare function updateTSConfigForFramework(target: tsr.TsConfigJson, framework: frameworkWithTSSettings): tsr.TsConfigJson;

82
node_modules/astro/dist/core/config/tsconfig.js generated vendored Normal file
View file

@ -0,0 +1,82 @@
import { deepmerge } from "deepmerge-ts";
import { existsSync } from "node:fs";
import { join } from "node:path";
import * as tsr from "tsconfig-resolver";
const defaultTSConfig = { extends: "astro/tsconfigs/base" };
const presets = /* @__PURE__ */ new Map([
[
"vue",
// Settings needed for template intellisense when using Volar
{
compilerOptions: {
jsx: "preserve"
}
}
],
[
"react",
// Default TypeScript settings, but we need to redefine them in case the users changed them previously
{
compilerOptions: {
jsx: "react-jsx",
jsxImportSource: "react"
}
}
],
[
"preact",
// https://preactjs.com/guide/v10/typescript/#typescript-configuration
{
compilerOptions: {
jsx: "react-jsx",
jsxImportSource: "preact"
}
}
],
[
"solid-js",
// https://www.solidjs.com/guides/typescript#configuring-typescript
{
compilerOptions: {
jsx: "preserve",
jsxImportSource: "solid-js"
}
}
]
]);
function loadTSConfig(cwd, resolve = true) {
cwd = cwd ?? process.cwd();
let config = tsr.tsconfigResolverSync({
cwd,
filePath: resolve ? void 0 : cwd,
ignoreExtends: !resolve
});
if (!resolve && config.reason === "invalid-config" && !existsSync(join(cwd, "tsconfig.json"))) {
config = { reason: "not-found", path: void 0, exists: false };
}
if (config.reason === "not-found") {
const jsconfig = tsr.tsconfigResolverSync({
cwd,
filePath: resolve ? void 0 : cwd,
searchName: "jsconfig.json",
ignoreExtends: !resolve
});
if (!resolve && jsconfig.reason === "invalid-config" && !existsSync(join(cwd, "jsconfig.json"))) {
return { reason: "not-found", path: void 0, exists: false };
}
return jsconfig;
}
return config;
}
function updateTSConfigForFramework(target, framework) {
if (!presets.has(framework)) {
return target;
}
return deepmerge(target, presets.get(framework));
}
export {
defaultTSConfig,
loadTSConfig,
presets,
updateTSConfigForFramework
};

9
node_modules/astro/dist/core/config/vite-load.d.ts generated vendored Normal file
View file

@ -0,0 +1,9 @@
/// <reference types="node" />
import type fsType from 'node:fs';
interface LoadConfigWithViteOptions {
root: string;
configPath: string;
fs: typeof fsType;
}
export declare function loadConfigWithVite({ configPath, fs, root, }: LoadConfigWithViteOptions): Promise<Record<string, any>>;
export {};

54
node_modules/astro/dist/core/config/vite-load.js generated vendored Normal file
View file

@ -0,0 +1,54 @@
import { pathToFileURL } from "node:url";
import { createServer } from "vite";
import loadFallbackPlugin from "../../vite-plugin-load-fallback/index.js";
import { debug } from "../logger/core.js";
async function createViteServer(root, fs) {
const viteServer = await createServer({
server: { middlewareMode: true, hmr: false, watch: { ignored: ["**"] } },
optimizeDeps: { disabled: true },
clearScreen: false,
appType: "custom",
ssr: {
// NOTE: Vite doesn't externalize linked packages by default. During testing locally,
// these dependencies trip up Vite's dev SSR transform. Awaiting upstream feature:
// https://github.com/vitejs/vite/pull/10939
external: [
"@astrojs/tailwind",
"@astrojs/mdx",
"@astrojs/react",
"@astrojs/preact",
"@astrojs/sitemap",
"@astrojs/markdoc"
]
},
plugins: [loadFallbackPlugin({ fs, root: pathToFileURL(root) })]
});
return viteServer;
}
async function loadConfigWithVite({
configPath,
fs,
root
}) {
if (/\.[cm]?js$/.test(configPath)) {
try {
const config = await import(pathToFileURL(configPath).toString() + "?t=" + Date.now());
return config.default ?? {};
} catch (e) {
debug("Failed to load config with Node", e);
}
}
let server;
try {
server = await createViteServer(root, fs);
const mod = await server.ssrLoadModule(configPath, { fixStacktrace: true });
return mod.default ?? {};
} finally {
if (server) {
await server.close();
}
}
}
export {
loadConfigWithVite
};