Plugin-SDK: Oberflächen für Kunden-Plugins, Generator, Doku (0.20.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m46s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m49s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m7s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m51s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m12s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 04:57:28 +00:00
parent 46b7b05f94
commit ea2200cb3e
353 changed files with 2151 additions and 1542 deletions

View file

@ -0,0 +1,46 @@
import { defineAsyncComponent } from 'vue';
/**
* Oberflächen installierter Kunden-Plugins (plugins/<slug>/dist, gebaut mit dem Plugin-SDK).
* Der Server legt die Liste der aktiven Plugins in window.__inhausPlugins ab:
*
* { "monatsspruch": { "base": "/plugin-assets/monatsspruch/1.1.0/", "components": { "widgets/Verse": "widgets/Verse.js" } } }
*
* „slug::Name“ plus Art (pages, widgets, blocks, profile, profile-panels, editorial)
* ergibt die Datei – geladen als ES-Modul; Vue & Co. kommen über die Import Map.
*/
const plugins = () => window.__inhausPlugins ?? {};
export function pluginModuleUrl(name, kind) {
if (!name?.includes('::')) return null;
const [slug, component] = name.split('::');
const plugin = plugins()[slug];
const file = plugin?.components?.[`${kind}/${component}`];
return file ? plugin.base + file : null;
}
/** Laden einer Seite (für den Inertia-Resolver) – liefert das Modul oder null */
export function loadPluginPage(name) {
const url = pluginModuleUrl(name, 'pages');
return url ? import(/* @vite-ignore */ url) : null;
}
const cache = {};
/** Komponente für Kacheln, Blöcke, Profil- und Redaktionsbereiche – oder null */
export function pluginComponent(name, kind) {
const url = pluginModuleUrl(name, kind);
if (!url) return null;
return (cache[url] ??= defineAsyncComponent({
loader: () => import(/* @vite-ignore */ url).then((m) => m.default ?? m),
onError: (error, retry, fail) => {
console.error(`Plugin-Komponente ${name} (${kind}) konnte nicht geladen werden:`, error);
fail();
},
}));
}