🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
62
node_modules/astro/dist/integrations/index.d.ts
generated
vendored
Normal file
62
node_modules/astro/dist/integrations/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
/// <reference types="node" />
|
||||
import type { AddressInfo } from 'node:net';
|
||||
import type { InlineConfig, ViteDevServer } from 'vite';
|
||||
import type { AstroConfig, AstroSettings, RouteData } from '../@types/astro.js';
|
||||
import type { SerializedSSRManifest } from '../core/app/types';
|
||||
import type { PageBuildData } from '../core/build/types';
|
||||
import { type LogOptions } from '../core/logger/core.js';
|
||||
export declare function runHookConfigSetup({ settings, command, logging, isRestart, }: {
|
||||
settings: AstroSettings;
|
||||
command: 'dev' | 'build' | 'preview';
|
||||
logging: LogOptions;
|
||||
isRestart?: boolean;
|
||||
}): Promise<AstroSettings>;
|
||||
export declare function runHookConfigDone({ settings, logging, }: {
|
||||
settings: AstroSettings;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
export declare function runHookServerSetup({ config, server, logging, }: {
|
||||
config: AstroConfig;
|
||||
server: ViteDevServer;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
export declare function runHookServerStart({ config, address, logging, }: {
|
||||
config: AstroConfig;
|
||||
address: AddressInfo;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
export declare function runHookServerDone({ config, logging, }: {
|
||||
config: AstroConfig;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
export declare function runHookBuildStart({ config, logging, }: {
|
||||
config: AstroConfig;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
export declare function runHookBuildSetup({ config, vite, pages, target, logging, }: {
|
||||
config: AstroConfig;
|
||||
vite: InlineConfig;
|
||||
pages: Map<string, PageBuildData>;
|
||||
target: 'server' | 'client';
|
||||
logging: LogOptions;
|
||||
}): Promise<InlineConfig>;
|
||||
type RunHookBuildSsr = {
|
||||
config: AstroConfig;
|
||||
manifest: SerializedSSRManifest;
|
||||
logging: LogOptions;
|
||||
entryPoints: Map<RouteData, URL>;
|
||||
middlewareEntryPoint: URL | undefined;
|
||||
};
|
||||
export declare function runHookBuildSsr({ config, manifest, logging, entryPoints, middlewareEntryPoint, }: RunHookBuildSsr): Promise<void>;
|
||||
export declare function runHookBuildGenerated({ config, logging, }: {
|
||||
config: AstroConfig;
|
||||
logging: LogOptions;
|
||||
}): Promise<void>;
|
||||
type RunHookBuildDone = {
|
||||
config: AstroConfig;
|
||||
pages: string[];
|
||||
routes: RouteData[];
|
||||
logging: LogOptions;
|
||||
};
|
||||
export declare function runHookBuildDone({ config, pages, routes, logging }: RunHookBuildDone): Promise<void>;
|
||||
export {};
|
288
node_modules/astro/dist/integrations/index.js
generated
vendored
Normal file
288
node_modules/astro/dist/integrations/index.js
generated
vendored
Normal file
|
@ -0,0 +1,288 @@
|
|||
import { bold } from "kleur/colors";
|
||||
import fs from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { buildClientDirectiveEntrypoint } from "../core/client-directive/index.js";
|
||||
import { mergeConfig } from "../core/config/index.js";
|
||||
import { info } from "../core/logger/core.js";
|
||||
import { isServerLikeOutput } from "../prerender/utils.js";
|
||||
async function withTakingALongTimeMsg({
|
||||
name,
|
||||
hookResult,
|
||||
timeoutMs = 3e3,
|
||||
logging
|
||||
}) {
|
||||
const timeout = setTimeout(() => {
|
||||
info(logging, "build", `Waiting for the ${bold(name)} integration...`);
|
||||
}, timeoutMs);
|
||||
const result = await hookResult;
|
||||
clearTimeout(timeout);
|
||||
return result;
|
||||
}
|
||||
async function runHookConfigSetup({
|
||||
settings,
|
||||
command,
|
||||
logging,
|
||||
isRestart = false
|
||||
}) {
|
||||
var _a;
|
||||
if (settings.config.adapter) {
|
||||
settings.config.integrations.push(settings.config.adapter);
|
||||
}
|
||||
let updatedConfig = { ...settings.config };
|
||||
let updatedSettings = { ...settings, config: updatedConfig };
|
||||
let addedClientDirectives = /* @__PURE__ */ new Map();
|
||||
for (const integration of settings.config.integrations) {
|
||||
if ((_a = integration.hooks) == null ? void 0 : _a["astro:config:setup"]) {
|
||||
let addPageExtension2 = function(...input) {
|
||||
const exts = input.flat(Infinity).map((ext) => `.${ext.replace(/^\./, "")}`);
|
||||
updatedSettings.pageExtensions.push(...exts);
|
||||
}, addContentEntryType2 = function(contentEntryType) {
|
||||
updatedSettings.contentEntryTypes.push(contentEntryType);
|
||||
}, addDataEntryType2 = function(dataEntryType) {
|
||||
updatedSettings.dataEntryTypes.push(dataEntryType);
|
||||
};
|
||||
var addPageExtension = addPageExtension2, addContentEntryType = addContentEntryType2, addDataEntryType = addDataEntryType2;
|
||||
const hooks = {
|
||||
config: updatedConfig,
|
||||
command,
|
||||
isRestart,
|
||||
addRenderer(renderer) {
|
||||
if (!renderer.name) {
|
||||
throw new Error(`Integration ${bold(integration.name)} has an unnamed renderer.`);
|
||||
}
|
||||
if (!renderer.serverEntrypoint) {
|
||||
throw new Error(`Renderer ${bold(renderer.name)} does not provide a serverEntrypoint.`);
|
||||
}
|
||||
updatedSettings.renderers.push(renderer);
|
||||
},
|
||||
injectScript: (stage, content) => {
|
||||
updatedSettings.scripts.push({ stage, content });
|
||||
},
|
||||
updateConfig: (newConfig) => {
|
||||
updatedConfig = mergeConfig(updatedConfig, newConfig);
|
||||
},
|
||||
injectRoute: (injectRoute) => {
|
||||
updatedSettings.injectedRoutes.push(injectRoute);
|
||||
},
|
||||
addWatchFile: (path) => {
|
||||
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
|
||||
},
|
||||
addClientDirective: ({ name, entrypoint }) => {
|
||||
if (updatedSettings.clientDirectives.has(name) || addedClientDirectives.has(name)) {
|
||||
throw new Error(
|
||||
`The "${integration.name}" integration is trying to add the "${name}" client directive, but it already exists.`
|
||||
);
|
||||
}
|
||||
addedClientDirectives.set(name, buildClientDirectiveEntrypoint(name, entrypoint));
|
||||
}
|
||||
};
|
||||
Object.defineProperty(hooks, "addPageExtension", {
|
||||
value: addPageExtension2,
|
||||
writable: false,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(hooks, "addContentEntryType", {
|
||||
value: addContentEntryType2,
|
||||
writable: false,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(hooks, "addDataEntryType", {
|
||||
value: addDataEntryType2,
|
||||
writable: false,
|
||||
enumerable: false
|
||||
});
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:config:setup"](hooks),
|
||||
logging
|
||||
});
|
||||
for (const [name, compiled] of addedClientDirectives) {
|
||||
updatedSettings.clientDirectives.set(name, await compiled);
|
||||
}
|
||||
}
|
||||
}
|
||||
updatedSettings.config = updatedConfig;
|
||||
return updatedSettings;
|
||||
}
|
||||
async function runHookConfigDone({
|
||||
settings,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of settings.config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:config:done"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:config:done"]({
|
||||
config: settings.config,
|
||||
setAdapter(adapter) {
|
||||
if (settings.adapter && settings.adapter.name !== adapter.name) {
|
||||
throw new Error(
|
||||
`Integration "${integration.name}" conflicts with "${settings.adapter.name}". You can only configure one deployment integration.`
|
||||
);
|
||||
}
|
||||
settings.adapter = adapter;
|
||||
}
|
||||
}),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookServerSetup({
|
||||
config,
|
||||
server,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:setup"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:server:setup"]({ server }),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookServerStart({
|
||||
config,
|
||||
address,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:start"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:server:start"]({ address }),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookServerDone({
|
||||
config,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:done"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:server:done"](),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookBuildStart({
|
||||
config,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:start"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:build:start"](),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookBuildSetup({
|
||||
config,
|
||||
vite,
|
||||
pages,
|
||||
target,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
let updatedConfig = vite;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:setup"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:build:setup"]({
|
||||
vite,
|
||||
pages,
|
||||
target,
|
||||
updateConfig: (newConfig) => {
|
||||
updatedConfig = mergeConfig(updatedConfig, newConfig);
|
||||
}
|
||||
}),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
return updatedConfig;
|
||||
}
|
||||
async function runHookBuildSsr({
|
||||
config,
|
||||
manifest,
|
||||
logging,
|
||||
entryPoints,
|
||||
middlewareEntryPoint
|
||||
}) {
|
||||
var _a;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:ssr"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:build:ssr"]({
|
||||
manifest,
|
||||
entryPoints,
|
||||
middlewareEntryPoint
|
||||
}),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookBuildGenerated({
|
||||
config,
|
||||
logging
|
||||
}) {
|
||||
var _a;
|
||||
const dir = isServerLikeOutput(config) ? config.build.client : config.outDir;
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:generated"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:build:generated"]({ dir }),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runHookBuildDone({ config, pages, routes, logging }) {
|
||||
var _a;
|
||||
const dir = isServerLikeOutput(config) ? config.build.client : config.outDir;
|
||||
await fs.promises.mkdir(dir, { recursive: true });
|
||||
for (const integration of config.integrations) {
|
||||
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:done"]) {
|
||||
await withTakingALongTimeMsg({
|
||||
name: integration.name,
|
||||
hookResult: integration.hooks["astro:build:done"]({
|
||||
pages: pages.map((p) => ({ pathname: p })),
|
||||
dir,
|
||||
routes
|
||||
}),
|
||||
logging
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
export {
|
||||
runHookBuildDone,
|
||||
runHookBuildGenerated,
|
||||
runHookBuildSetup,
|
||||
runHookBuildSsr,
|
||||
runHookBuildStart,
|
||||
runHookConfigDone,
|
||||
runHookConfigSetup,
|
||||
runHookServerDone,
|
||||
runHookServerSetup,
|
||||
runHookServerStart
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue