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,19 @@
<?php
namespace {{namespace}}\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class IndexController extends Controller
{
public function __invoke(Request $request): Response
{
// „{{slug}}::Index“ → resources/js/pages/Index.vue dieses Plugins
return Inertia::render('{{slug}}::Index', [
'greeting' => 'Hallo '.($request->user()->first_name ?: $request->user()->name).'!',
]);
}
}

13
sdk/stubs/Hello.vue.stub Normal file
View file

@ -0,0 +1,13 @@
<script setup>
import { Panel } from '@inhaus/ui';
defineProps({
name: { type: String, required: true },
});
</script>
<template>
<Panel title="{{name}}" action-label="Öffnen" action-href="/{{slug}}">
<p class="ih:text-sm">Hallo {{ name }} – diese Kachel kommt aus dem Plugin „{{name}}“.</p>
</Panel>
</template>

26
sdk/stubs/Index.vue.stub Normal file
View file

@ -0,0 +1,26 @@
<script setup>
import { ref } from 'vue';
import { AppLayout, Button, PageHeader, Panel, toast } from '@inhaus/ui';
defineProps({
greeting: { type: String, required: true },
});
const clicks = ref(0);
</script>
<template>
<AppLayout title="{{name}}">
<PageHeader title="{{name}}" description="Ein Plugin, gebaut mit dem Inhaus-Plugin-SDK." />
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-2">
<Panel :title="greeting">
<p class="ih:text-sm ih:text-muted-foreground">
Diese Seite liegt in <code>resources/js/pages/Index.vue</code>. Bausteine wie Panel, Button oder
PageHeader kommen aus <code>@inhaus/ui</code> – Farben und Ecken folgen dem Erscheinungsbild.
</p>
<Button class="ih:mt-4" @click="clicks++; toast.success(`Schon ${clicks}× geklickt`)">Klick mich</Button>
</Panel>
</div>
</AppLayout>
</template>

30
sdk/stubs/Plugin.php.stub Normal file
View file

@ -0,0 +1,30 @@
<?php
namespace {{namespace}};
use App\Dashboard\Widgets;
use App\Models\User;
use App\Plugins\Plugin;
use App\Support\Navigation;
/**
* {{name}}
*
* register(): Menüpunkte, Kacheln, Rechte, Blöcke anmelden (läuft bei jedem Aufruf).
* boot(): nach dem Laden aller Plugins – z. B. Hooks, geplante Aufgaben.
* Routen (routes/web.php) und Migrationen (database/migrations) lädt das Portal selbst.
* Mehr dazu: docs/PLUGINS.md im Portal.
*/
class {{studly}}Plugin extends Plugin
{
public function register(): void
{
// Menüpunkt im Portal („Mehr“ bzw. unter „Menü“ im Backend frei anordenbar)
$this->app->make(Navigation::class)->add('{{slug}}', '{{name}}', '/{{slug}}', active: '{{slug}}.*', sort: 80);
// Kachel auf der Startseite – Vue-Komponente resources/js/widgets/Hello.vue
$this->app->make(Widgets::class)->add('{{slug}}.hello', '{{slug}}::Hello', 'aside', sort: 90,
props: fn (User $user) => ['name' => $user->first_name ?: $user->name],
label: '{{name}}: Hallo-Kachel');
}
}

27
sdk/stubs/README.md.stub Normal file
View file

@ -0,0 +1,27 @@
# {{name}}
Inhaus-Plugin, erzeugt mit `php artisan inhaus:make-plugin`.
## Entwickeln
```bash
npm install
npm run build # Oberfläche nach dist/ bauen
npm run package # ZIP zum Hochladen erzeugen
```
Das Plugin liegt dafür am besten direkt unter `plugins/{{slug}}` einer Entwicklungsinstallation
des Portals; nach `npm run build` die Seite neu laden.
## Aufbau
- `plugin.json` – Name, Version, Voraussetzungen
- `src/{{studly}}Plugin.php` – Menüpunkt, Kachel, Rechte (Registries des Portals)
- `routes/web.php`, `src/Http/Controllers/` – Seiten
- `resources/js/pages/` – Inertia-Seiten (`{{slug}}::Name`)
- `resources/js/widgets/`, `blocks/`, `profile/`, `profile-panels/`, `editorial/` – Kacheln, Pagebuilder-Blöcke, Profil- und Redaktionsbereiche
- `resources/css/style.css` – Tailwind mit den Design-Tokens des Portals
- `inhaus-sdk/` – Build-Voreinstellung (Kopie aus dem Portal, Version {{coreVersion}})
Oberflächen importieren `vue`, `@inertiajs/vue3` und `@inhaus/ui` – das Portal stellt
sie zur Laufzeit bereit. Übersicht der Bausteine und Registries: `docs/PLUGINS.md` im Portal.

View file

@ -0,0 +1,17 @@
{
"name": "inhaus-plugin-{{slug}}",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite build --watch",
"package": "vite build && php bin/package"
},
"devDependencies": {
"@tailwindcss/vite": "{{v_tailwind_vite}}",
"@vitejs/plugin-vue": "{{v_plugin_vue}}",
"tailwindcss": "{{v_tailwind}}",
"vite": "{{v_vite}}",
"vue": "{{v_vue}}"
}
}

29
sdk/stubs/package.stub Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
* Baut {{slug}}-<version>.zip zum Hochladen unter Administration → Plugins.
* Enthält alles außer Quelltexten fürs Frontend-Build und node_modules.
*/
$root = dirname(__DIR__);
$manifest = json_decode(file_get_contents("{$root}/plugin.json"), true);
$target = "{$root}/{{slug}}-{$manifest['version']}.zip";
$skip = ['node_modules', '.git', 'inhaus-sdk', 'package.json', 'package-lock.json', 'vite.config.js', basename($target)];
@unlink($target);
$zip = new ZipArchive;
$zip->open($target, ZipArchive::CREATE);
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS));
foreach ($files as $file) {
$relative = substr($file->getPathname(), strlen($root) + 1);
if (in_array(explode(DIRECTORY_SEPARATOR, $relative)[0], $skip, true) || str_ends_with($relative, '.zip')) {
continue;
}
$zip->addFile($file->getPathname(), '{{slug}}/'.$relative);
}
$zip->close();
echo "Paket: {$target}\n";

View file

@ -0,0 +1,13 @@
{
"slug": "{{slug}}",
"name": "{{name}}",
"version": "1.0.0",
"description": "{{description}}",
"author": "{{author}}",
"namespace": "{{namespaceJson}}\\",
"class": "{{namespaceJson}}\\{{studly}}Plugin",
"requires": {
"core": ">={{coreVersion}}",
"php": ">=8.3"
}
}

3
sdk/stubs/style.css.stub Normal file
View file

@ -0,0 +1,3 @@
/* Tailwind mit den Design-Tokens des Portals – Klassen mit Präfix „ih:“, z. B. ih:bg-brand, ih:text-muted-foreground, ih:rounded-lg */
@import "../../inhaus-sdk/theme.css";
@source "../js";

View file

@ -0,0 +1,5 @@
import { defineConfig } from 'vite';
import { inhausPlugin } from './inhaus-sdk/vite.js';
// Baut resources/js/{pages,widgets,blocks,…} nach dist/ (siehe inhaus-sdk/vite.js)
export default defineConfig(inhausPlugin());

8
sdk/stubs/web.php.stub Normal file
View file

@ -0,0 +1,8 @@
<?php
use Illuminate\Support\Facades\Route;
use {{namespace}}\Http\Controllers\IndexController;
Route::middleware('auth')->prefix('{{slug}}')->name('{{slug}}.')->group(function () {
Route::get('/', IndexController::class)->name('index');
});

63
sdk/theme.css Normal file
View file

@ -0,0 +1,63 @@
/*
* Automatisch erzeugt (scripts/generate-sdk-shims.mjs) – Design-Tokens des Portals.
* In der style.css eines Plugins: @import "../../inhaus-sdk/theme.css";
* Farben, Ecken und Schrift folgen so dem Erscheinungsbild der Installation.
*
* Tailwind-Klassen in Plugins tragen das Präfix „ih:“ (z. B. ih:grid, ih:lg:grid-cols-2, ih:bg-brand).
* So kann das CSS eines Plugins nie die Klassen des Portals überschreiben.
* Nur Hilfsklassen – Grundstile (Preflight) bringt das Portal selbst mit.
*/
@import "tailwindcss/theme" layer(theme) prefix(ih);
@import "tailwindcss/utilities" layer(utilities);
@custom-variant dark (&:is(.dark *));
@theme inline {
--font-sans: var(--font-body);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) * 1.5);
--radius-2xl: calc(var(--radius) * 2);
/* „Pille“: voll gerundet – außer bei „Eckig“ im Erscheinungsbild (dann 0) */
--radius-pill: calc(var(--radius) * 1000);
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
--color-brand-text: var(--brand-text);
--color-accent2: var(--accent2);
--color-accent2-foreground: var(--accent2-foreground);
--color-accent2-text: var(--accent2-text);
--color-brand-soft: var(--brand-soft);
--color-brand-soft-foreground: var(--brand-soft-foreground);
--color-brand-50: var(--brand-50);
--color-brand-100: var(--brand-100);
--color-brand-200: var(--brand-200);
--color-brand-300: var(--brand-300);
--color-brand-400: var(--brand-400);
--color-brand-500: var(--brand-500);
--color-brand-600: var(--brand-600);
--color-brand-700: var(--brand-700);
--color-brand-800: var(--brand-800);
--color-brand-900: var(--brand-900);
--color-brand-950: var(--brand-950);
}

88
sdk/vite.js Normal file
View file

@ -0,0 +1,88 @@
/**
* Vite-Voreinstellung für Inhaus-Plugins (Plugin-SDK).
*
* // vite.config.js im Plugin
* import { defineConfig } from 'vite';
* import { inhausPlugin } from './inhaus-sdk/vite.js';
* export default defineConfig(inhausPlugin());
*
* Baut jede Vue-Datei unter resources/js/{pages,widgets,blocks,profile,profile-panels,editorial}/
* als eigenes ES-Modul nach dist/ und schreibt dist/inhaus.json. Vue, Inertia und @inhaus/ui
* bleiben extern – das Portal stellt sie per Import Map bereit.
*/
import { existsSync, globSync } from 'node:fs';
import { resolve } from 'node:path';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
export const KINDS = ['pages', 'widgets', 'blocks', 'profile', 'profile-panels', 'editorial'];
export const EXTERNAL = ['vue', '@inertiajs/vue3', '@inhaus/ui'];
export function inhausPlugin({ root = process.cwd() } = {}) {
const input = {};
for (const kind of KINDS) {
for (const file of globSync(`resources/js/${kind}/**/*.vue`, { cwd: root })) {
const name = file.replace(`resources/js/${kind}/`, '').replace(/\.vue$/, '');
input[`${kind}/${name}`] = resolve(root, file);
}
}
if (existsSync(resolve(root, 'resources/css/style.css'))) {
input.style = resolve(root, 'resources/css/style.css');
}
if (Object.keys(input).length === 0) {
throw new Error('Keine Oberfläche gefunden: Vue-Dateien gehören nach resources/js/<pages|widgets|blocks|profile|profile-panels|editorial>/.');
}
return {
plugins: [vue(), tailwindcss(), manifest(Object.keys(input))],
// Plugins laufen unter /plugin-assets/<slug>/<version>/ – Pfade relativ halten
base: './',
build: {
outDir: 'dist',
emptyOutDir: true,
target: 'es2022',
rollupOptions: {
input,
external: EXTERNAL,
preserveEntrySignatures: 'strict',
output: {
format: 'es',
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
},
},
};
}
/** dist/inhaus.json: welche Komponente in welcher Datei steckt, welches CSS dazugehört */
function manifest(entries) {
return {
name: 'inhaus-manifest',
generateBundle(_, bundle) {
const components = {};
const css = [];
for (const file of Object.values(bundle)) {
if (file.type === 'chunk' && file.isEntry && entries.includes(file.name) && file.name !== 'style') {
components[file.name] = file.fileName;
}
if (file.type === 'asset' && file.fileName.endsWith('.css')) {
css.push(file.fileName);
}
}
// Leere Hülle des CSS-Einstiegs nicht ausliefern
for (const [key, file] of Object.entries(bundle)) {
if (file.type === 'chunk' && file.name === 'style') delete bundle[key];
}
this.emitFile({ type: 'asset', fileName: 'inhaus.json', source: JSON.stringify({ components, css: [...new Set(css)] }, null, 4) });
},
};
}