full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -1,2 +1,2 @@
import type { DevToolbarApp } from '../@types/astro.js';
import type { DevToolbarApp } from '../types/public/toolbar.js';
export declare function defineToolbarApp(app: DevToolbarApp): DevToolbarApp;

View File

@@ -1,3 +1,3 @@
import type * as vite from 'vite';
import type { AstroPluginOptions } from '../@types/astro.js';
import type { AstroPluginOptions } from '../types/astro.js';
export default function astroDevToolbar({ settings, logger }: AstroPluginOptions): vite.Plugin;

View File

@@ -50,58 +50,60 @@ ${args.error}`
},
async load(id) {
if (id === resolvedPrivateVirtualModuleId) {
return `
export const loadDevToolbarApps = async () => {
return (await Promise.all([${settings.devToolbarApps.map(
(plugin) => `safeLoadPlugin(${JSON.stringify(
plugin
)}, async () => (await import(${JSON.stringify(
typeof plugin === "string" ? plugin : plugin.entrypoint
)})).default, ${JSON.stringify(
typeof plugin === "string" ? plugin : plugin.entrypoint
)})`
).join(",")}]));
};
return {
code: `
export const loadDevToolbarApps = async () => {
return (await Promise.all([${settings.devToolbarApps.map(
(plugin) => `safeLoadPlugin(${JSON.stringify(
plugin
)}, async () => (await import(${JSON.stringify(
typeof plugin === "string" ? plugin : plugin.entrypoint.toString()
)})).default, ${JSON.stringify(
typeof plugin === "string" ? plugin : plugin.entrypoint.toString()
)})`
).join(",")}]));
};
async function safeLoadPlugin(appDefinition, importEntrypoint, entrypoint) {
try {
let app;
if (typeof appDefinition === 'string') {
app = await importEntrypoint();
async function safeLoadPlugin(appDefinition, importEntrypoint, entrypoint) {
try {
let app;
if (typeof appDefinition === 'string') {
app = await importEntrypoint();
if (typeof app !== 'object' || !app.id || !app.name) {
throw new Error("Apps must default export an object with an id, and a name.");
}
} else {
app = appDefinition;
if (typeof app !== 'object' || !app.id || !app.name) {
throw new Error("Apps must default export an object with an id, and a name.");
}
} else {
app = appDefinition;
if (typeof app !== 'object' || !app.id || !app.name || !app.entrypoint) {
throw new Error("Apps must be an object with an id, a name and an entrypoint.");
if (typeof app !== 'object' || !app.id || !app.name || !app.entrypoint) {
throw new Error("Apps must be an object with an id, a name and an entrypoint.");
}
const loadedApp = await importEntrypoint();
if (typeof loadedApp !== 'object') {
throw new Error("App entrypoint must default export an object.");
}
app = { ...app, ...loadedApp };
}
const loadedApp = await importEntrypoint();
return app;
} catch (err) {
console.error(\`Failed to load dev toolbar app from \${entrypoint}: \${err.message}\`);
if (typeof loadedApp !== 'object') {
throw new Error("App entrypoint must default export an object.");
if (import.meta.hot) {
import.meta.hot.send('astro:devtoolbar:error:load', { entrypoint: entrypoint, error: err.message })
}
app = { ...app, ...loadedApp };
}
return app;
} catch (err) {
console.error(\`Failed to load dev toolbar app from \${entrypoint}: \${err.message}\`);
if (import.meta.hot) {
import.meta.hot.send('astro:devtoolbar:error:load', { entrypoint: entrypoint, error: err.message })
return undefined;
}
return undefined;
}
return undefined;
}
`;
`
};
}
}
};