@emberbox/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -0
- package/README.md +17 -2
- package/dist/vite/logo.d.ts +9 -0
- package/dist/vite/logo.js +44 -0
- package/dist/vite/vorrendern.d.ts +17 -0
- package/dist/vite/vorrendern.js +57 -0
- package/dist/vite.d.ts +39 -0
- package/dist/vite.js +121 -0
- package/logos/alarmzettel-180.png +0 -0
- package/logos/alarmzettel-512.png +0 -0
- package/logos/alarmzettel.svg +1 -0
- package/logos/calltaker-180.png +0 -0
- package/logos/calltaker-512.png +0 -0
- package/logos/calltaker.svg +1 -0
- package/logos/emberbox-180.png +0 -0
- package/logos/emberbox-512.png +0 -0
- package/logos/emberbox.svg +1 -0
- package/logos/statussim-180.png +0 -0
- package/logos/statussim-512.png +0 -0
- package/logos/statussim.svg +1 -0
- package/package.json +62 -4
- package/src/adressen.ts +8 -0
- package/src/app.ts +11 -0
- package/src/composables/useNeueFassung.ts +45 -0
- package/src/composables/usePolling.ts +93 -0
- package/src/composables/useRueckfrage.ts +27 -0
- package/src/fassung.ts +23 -0
- package/src/index.ts +33 -0
- package/src/komponenten/AppFuss.vue +58 -0
- package/src/komponenten/AppKopf.vue +45 -0
- package/src/komponenten/CodeAnzeige.vue +79 -0
- package/src/komponenten/EmberboxApp.vue +22 -0
- package/src/komponenten/HilfeAbschnitt.vue +11 -0
- package/src/komponenten/HilfeMockup.vue +15 -0
- package/src/komponenten/HilfeSeite.vue +16 -0
- package/src/komponenten/HilfeThema.vue +20 -0
- package/src/komponenten/NeueFassung.vue +24 -0
- package/src/komponenten/Rueckfrage.vue +24 -0
- package/src/seite.ts +81 -0
- package/src/stil.css +172 -0
- package/src/vite/logo.ts +50 -0
- package/src/vite/vorrendern.ts +72 -0
- package/src/vite.ts +145 -0
- package/src/vorrendern.ts +24 -0
- package/src/zwischenablage.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RainbowDashLabs and Contributor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The pictograms in logos/ are derived from Lucide (https://lucide.dev) and are
|
|
26
|
+
distributed under the following license:
|
|
27
|
+
|
|
28
|
+
ISC License
|
|
29
|
+
|
|
30
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of
|
|
31
|
+
Feather (MIT). All other copyright (c) for Lucide are held by Lucide
|
|
32
|
+
Contributors 2022.
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
36
|
+
copyright notice and this permission notice appear in all copies.
|
|
37
|
+
|
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
39
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
40
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
41
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
42
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
43
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
44
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @emberbox/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Gemeinsamer Stil und gemeinsame Bausteine der [Emberbox](https://emberbox.app)-Werkzeuge für
|
|
4
|
+
Ausbildung und Übung in der Feuerwehr. Baut auf [Nuxt UI](https://ui.nuxt.com) auf und bringt
|
|
5
|
+
dessen Komponenten im Emberbox-Stil mit, dazu Kopf, Fuß, Code-Anzeige, Rückfragen, Hilfe-Seiten,
|
|
6
|
+
SEO und Vorrendern.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @emberbox/ui
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Einrichtung und Beispiele stehen im
|
|
13
|
+
[README des Repositorys](https://github.com/rainbowdashlabs/emberbox#readme).
|
|
14
|
+
|
|
15
|
+
## Lizenz
|
|
16
|
+
|
|
17
|
+
MIT. Die Piktogramme der Logos in `logos/` stammen aus [Lucide](https://lucide.dev) (ISC); beide
|
|
18
|
+
Lizenztexte stehen in `LICENSE`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/** Die Werkzeuge, für die `@emberbox/ui` ein Logo mitbringt. */
|
|
3
|
+
export type Logo = 'emberbox' | 'alarmzettel' | 'statussim' | 'calltaker';
|
|
4
|
+
/**
|
|
5
|
+
* Liefert das Logo eines Werkzeugs als `favicon.svg`, `apple-touch-icon.png` und `logo-512.png`
|
|
6
|
+
* im Wurzelverzeichnis aus, im Entwicklungsserver wie im Build, und verlinkt die ersten beiden im
|
|
7
|
+
* Kopf jeder Seite.
|
|
8
|
+
*/
|
|
9
|
+
export declare function logoPlugin(logo: Logo): Plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
const LOGOS = fileURLToPath(new URL('../../logos/', import.meta.url));
|
|
4
|
+
/** Welche Datei unter welchem Namen im Wurzelverzeichnis des Werkzeugs liegt. */
|
|
5
|
+
function dateien(logo) {
|
|
6
|
+
return {
|
|
7
|
+
'favicon.svg': `${LOGOS}${logo}.svg`,
|
|
8
|
+
'apple-touch-icon.png': `${LOGOS}${logo}-180.png`,
|
|
9
|
+
'logo-512.png': `${LOGOS}${logo}-512.png`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const TYPEN = { svg: 'image/svg+xml', png: 'image/png' };
|
|
13
|
+
/**
|
|
14
|
+
* Liefert das Logo eines Werkzeugs als `favicon.svg`, `apple-touch-icon.png` und `logo-512.png`
|
|
15
|
+
* im Wurzelverzeichnis aus, im Entwicklungsserver wie im Build, und verlinkt die ersten beiden im
|
|
16
|
+
* Kopf jeder Seite.
|
|
17
|
+
*/
|
|
18
|
+
export function logoPlugin(logo) {
|
|
19
|
+
const liste = dateien(logo);
|
|
20
|
+
return {
|
|
21
|
+
name: 'emberbox:logo',
|
|
22
|
+
configureServer(server) {
|
|
23
|
+
server.middlewares.use((anfrage, antwort, weiter) => {
|
|
24
|
+
const name = anfrage.url?.split('?')[0]?.slice(1) ?? '';
|
|
25
|
+
const datei = liste[name];
|
|
26
|
+
if (!datei)
|
|
27
|
+
return weiter();
|
|
28
|
+
antwort.setHeader('Content-Type', TYPEN[name.split('.').pop() ?? ''] ?? 'application/octet-stream');
|
|
29
|
+
antwort.end(readFileSync(datei));
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
generateBundle() {
|
|
33
|
+
if (this.environment?.config.build.ssr)
|
|
34
|
+
return;
|
|
35
|
+
for (const [name, datei] of Object.entries(liste)) {
|
|
36
|
+
this.emitFile({ type: 'asset', fileName: name, source: readFileSync(datei) });
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
transformIndexHtml: () => [
|
|
40
|
+
{ tag: 'link', attrs: { rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' }, injectTo: 'head' },
|
|
41
|
+
{ tag: 'link', attrs: { rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }, injectTo: 'head' },
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
2
|
+
/** Welche Seiten eines Werkzeugs beim Bauen als fertiges HTML entstehen. */
|
|
3
|
+
export interface VorrendernOptionen {
|
|
4
|
+
/** Modul, das `render(pfad, vorlage)` exportiert, etwa `src/vorrendern.ts`. */
|
|
5
|
+
eintrag: string;
|
|
6
|
+
/** Die öffentlichen Pfade, etwa `['/', '/hilfe']`. */
|
|
7
|
+
pfade: string[];
|
|
8
|
+
}
|
|
9
|
+
/** Das Verzeichnis unter dem Build, in dem die vorgerenderten Seiten liegen. */
|
|
10
|
+
export declare const SEITEN_VERZEICHNIS = "seiten";
|
|
11
|
+
/**
|
|
12
|
+
* Rendert nach dem Client-Build die öffentlichen Seiten vor. Dazu baut es den Eintrag als
|
|
13
|
+
* SSR-Bündel, ruft für jeden Pfad `render` mit der gebauten `index.html` als Vorlage auf und legt
|
|
14
|
+
* das Ergebnis unter `seiten/<pfad>/index.html` ab. Die `index.html` selbst bleibt die leere Hülle
|
|
15
|
+
* für alle übrigen Routen. Daneben entstehen `sitemap.xml` und `robots.txt`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function vorrenderPlugin(optionen: VorrendernOptionen, adresse: string): Plugin;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, extname, join, resolve } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { build } from 'vite';
|
|
5
|
+
/** Das Verzeichnis unter dem Build, in dem die vorgerenderten Seiten liegen. */
|
|
6
|
+
export const SEITEN_VERZEICHNIS = 'seiten';
|
|
7
|
+
function seitenDatei(ausgabe, pfad) {
|
|
8
|
+
return join(ausgabe, SEITEN_VERZEICHNIS, pfad.replace(/^\/+|\/+$/g, ''), 'index.html');
|
|
9
|
+
}
|
|
10
|
+
function sitemap(adresse, pfade) {
|
|
11
|
+
const eintraege = pfade.map(pfad => ` <url><loc>${adresse}${pfad}</loc></url>`).join('\n');
|
|
12
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${eintraege}\n</urlset>\n`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Rendert nach dem Client-Build die öffentlichen Seiten vor. Dazu baut es den Eintrag als
|
|
16
|
+
* SSR-Bündel, ruft für jeden Pfad `render` mit der gebauten `index.html` als Vorlage auf und legt
|
|
17
|
+
* das Ergebnis unter `seiten/<pfad>/index.html` ab. Die `index.html` selbst bleibt die leere Hülle
|
|
18
|
+
* für alle übrigen Routen. Daneben entstehen `sitemap.xml` und `robots.txt`.
|
|
19
|
+
*/
|
|
20
|
+
export function vorrenderPlugin(optionen, adresse) {
|
|
21
|
+
let config;
|
|
22
|
+
return {
|
|
23
|
+
name: 'emberbox:vorrendern',
|
|
24
|
+
apply: 'build',
|
|
25
|
+
configResolved(aufgeloest) {
|
|
26
|
+
config = aufgeloest;
|
|
27
|
+
},
|
|
28
|
+
async writeBundle() {
|
|
29
|
+
if (config.build.ssr)
|
|
30
|
+
return;
|
|
31
|
+
const ausgabe = resolve(config.root, config.build.outDir);
|
|
32
|
+
const ssrAusgabe = resolve(config.root, 'node_modules', '.emberbox-vorrendern');
|
|
33
|
+
await build({
|
|
34
|
+
configFile: config.configFile,
|
|
35
|
+
root: config.root,
|
|
36
|
+
mode: config.mode,
|
|
37
|
+
logLevel: 'warn',
|
|
38
|
+
build: { ssr: optionen.eintrag, outDir: ssrAusgabe, emptyOutDir: true, copyPublicDir: false },
|
|
39
|
+
});
|
|
40
|
+
const name = basename(optionen.eintrag, extname(optionen.eintrag));
|
|
41
|
+
const datei = readdirSync(ssrAusgabe).find(kandidat => /^(.+)\.m?js$/.exec(kandidat)?.[1] === name);
|
|
42
|
+
if (!datei)
|
|
43
|
+
throw new Error(`Das SSR-Bündel von ${optionen.eintrag} fehlt in ${ssrAusgabe}.`);
|
|
44
|
+
const eintrag = await import(pathToFileURL(join(ssrAusgabe, datei)).href);
|
|
45
|
+
const vorlage = readFileSync(join(ausgabe, 'index.html'), 'utf8');
|
|
46
|
+
for (const pfad of optionen.pfade) {
|
|
47
|
+
const ziel = seitenDatei(ausgabe, pfad);
|
|
48
|
+
mkdirSync(join(ziel, '..'), { recursive: true });
|
|
49
|
+
writeFileSync(ziel, await eintrag.render(pfad, vorlage));
|
|
50
|
+
}
|
|
51
|
+
writeFileSync(join(ausgabe, 'sitemap.xml'), sitemap(adresse, optionen.pfade));
|
|
52
|
+
writeFileSync(join(ausgabe, 'robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${adresse}/sitemap.xml\n`);
|
|
53
|
+
rmSync(ssrAusgabe, { recursive: true, force: true });
|
|
54
|
+
config.logger.info(`emberbox: ${optionen.pfade.length} Seiten vorgerendert`);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NuxtUIOptions } from '@nuxt/ui/unplugin';
|
|
2
|
+
import type { PluginOption } from 'vite';
|
|
3
|
+
import { type Logo } from './vite/logo.js';
|
|
4
|
+
import { type VorrendernOptionen } from './vite/vorrendern.js';
|
|
5
|
+
export { SEITEN_VERZEICHNIS, type VorrendernOptionen } from './vite/vorrendern.js';
|
|
6
|
+
export type { Logo } from './vite/logo.js';
|
|
7
|
+
/** Einstellungen, mit denen ein Werkzeug `emberbox()` an seine Lage anpasst. */
|
|
8
|
+
export interface EmberboxOptionen {
|
|
9
|
+
/** `false` für Werkzeuge ohne vue-router; Links werden dann als einfache Anker gerendert. */
|
|
10
|
+
router?: boolean;
|
|
11
|
+
/** Zusätzliche Nuxt-UI-Einstellungen des Werkzeugs, die über die Emberbox-Vorgaben gelegt werden. */
|
|
12
|
+
ui?: NuxtUIOptions['ui'];
|
|
13
|
+
/** Die öffentliche Adresse, etwa `https://calltaker.emberbox.app`; ein `/` am Ende fällt weg. */
|
|
14
|
+
adresse?: string;
|
|
15
|
+
/** Welches Emberbox-Logo als Favicon, Touch-Icon und Vorschaubild ausgeliefert wird. */
|
|
16
|
+
logo?: Logo;
|
|
17
|
+
/** Welche öffentlichen Seiten beim Bauen vorgerendert werden; braucht `adresse`. */
|
|
18
|
+
vorrendern?: VorrendernOptionen;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
|
|
22
|
+
* stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
|
|
23
|
+
*/
|
|
24
|
+
export declare const EIGENE_ICONS: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
|
|
27
|
+
* denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FARBMODUS_SKRIPT = "(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()";
|
|
30
|
+
/**
|
|
31
|
+
* Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
|
|
32
|
+
* Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
|
|
33
|
+
* installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
|
|
34
|
+
*
|
|
35
|
+
* Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
|
|
36
|
+
* `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
|
|
37
|
+
* neueren Build erkennen.
|
|
38
|
+
*/
|
|
39
|
+
export declare function emberbox(optionen?: EmberboxOptionen): PluginOption[];
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import ui from '@nuxt/ui/vite';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { logoPlugin } from './vite/logo.js';
|
|
5
|
+
import { vorrenderPlugin } from './vite/vorrendern.js';
|
|
6
|
+
export { SEITEN_VERZEICHNIS } from './vite/vorrendern.js';
|
|
7
|
+
const FARBEN = ['primary', 'signal', 'success', 'info', 'warning', 'error'];
|
|
8
|
+
/**
|
|
9
|
+
* Die Vorgaben, mit denen jede Nuxt-UI-Komponente im Emberbox-Stil erscheint. Die Farbnamen zeigen
|
|
10
|
+
* auf die Paletten aus `stil.css`; `primary` ist dort die Tinte, Rot bleibt Signalen und Fehlern.
|
|
11
|
+
*/
|
|
12
|
+
const VORGABEN = {
|
|
13
|
+
colors: {
|
|
14
|
+
primary: 'stahl',
|
|
15
|
+
signal: 'signal',
|
|
16
|
+
success: 'green',
|
|
17
|
+
info: 'blue',
|
|
18
|
+
warning: 'amber',
|
|
19
|
+
error: 'signal',
|
|
20
|
+
neutral: 'slate',
|
|
21
|
+
},
|
|
22
|
+
formField: {
|
|
23
|
+
slots: {
|
|
24
|
+
label: 'feld-label',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Wo nach benutzten Icons gesucht wird. Anders als die Vorgabe von `@nuxt/icon` auch in `.ts`- und
|
|
30
|
+
* `.js`-Dateien, weil Werkzeuge Icons in Menü- und Routentabellen eintragen.
|
|
31
|
+
*/
|
|
32
|
+
const ICON_SUCHE = {
|
|
33
|
+
globInclude: ['**/*.{vue,ts,tsx,js,jsx}'],
|
|
34
|
+
globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*', '**/*.d.ts'],
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
|
|
38
|
+
* stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
|
|
39
|
+
*/
|
|
40
|
+
export const EIGENE_ICONS = [
|
|
41
|
+
'i-lucide-check',
|
|
42
|
+
'i-lucide-copy',
|
|
43
|
+
'i-lucide-github',
|
|
44
|
+
'i-lucide-layout-grid',
|
|
45
|
+
'i-lucide-link',
|
|
46
|
+
'i-lucide-qr-code',
|
|
47
|
+
'i-lucide-rotate-cw',
|
|
48
|
+
'i-lucide-x',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
|
|
52
|
+
* denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
|
|
53
|
+
*/
|
|
54
|
+
export const FARBMODUS_SKRIPT = `(function(){try{var w=localStorage.getItem('vueuse-color-scheme');var d=w==='dark'||((!w||w==='auto')&&matchMedia('(prefers-color-scheme: dark)').matches);document.documentElement.classList.toggle('dark',d)}catch(e){}})()`;
|
|
55
|
+
/**
|
|
56
|
+
* Der kurze Commit, aus dem gebaut wird. Ein Image-Build ohne `.git` reicht ihn als Umgebungsvariable
|
|
57
|
+
* `COMMIT` herein; ohne beides heißt er `dev`.
|
|
58
|
+
*/
|
|
59
|
+
function commit() {
|
|
60
|
+
if (process.env.COMMIT)
|
|
61
|
+
return process.env.COMMIT;
|
|
62
|
+
try {
|
|
63
|
+
return execSync('git rev-parse --short HEAD', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return 'dev';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Commit und Bauzeit dieses Bauvorgangs. Einmal je Prozess bestimmt, damit Client- und SSR-Build
|
|
71
|
+
* eines Werkzeugs dieselbe Fassung tragen.
|
|
72
|
+
*/
|
|
73
|
+
const FASSUNG = { commit: commit(), gebaut: process.env.GEBAUT || new Date().toISOString() };
|
|
74
|
+
/**
|
|
75
|
+
* Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
|
|
76
|
+
* Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
|
|
77
|
+
* installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
|
|
78
|
+
*
|
|
79
|
+
* Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
|
|
80
|
+
* `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
|
|
81
|
+
* neueren Build erkennen.
|
|
82
|
+
*/
|
|
83
|
+
export function emberbox(optionen = {}) {
|
|
84
|
+
const adresse = optionen.adresse?.replace(/\/+$/, '') ?? '';
|
|
85
|
+
if (optionen.vorrendern && !adresse) {
|
|
86
|
+
throw new Error('emberbox(): Zum Vorrendern fehlt die adresse.');
|
|
87
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
ui({
|
|
90
|
+
router: optionen.router ?? true,
|
|
91
|
+
theme: { colors: FARBEN },
|
|
92
|
+
ui: defu(optionen.ui, VORGABEN),
|
|
93
|
+
icon: { clientBundle: { scan: ICON_SUCHE, icons: EIGENE_ICONS } },
|
|
94
|
+
scanPackages: ['@emberbox/ui'],
|
|
95
|
+
}),
|
|
96
|
+
{
|
|
97
|
+
name: 'emberbox',
|
|
98
|
+
config: () => ({
|
|
99
|
+
define: {
|
|
100
|
+
__EMBERBOX_COMMIT__: JSON.stringify(FASSUNG.commit),
|
|
101
|
+
__EMBERBOX_GEBAUT__: JSON.stringify(FASSUNG.gebaut),
|
|
102
|
+
__EMBERBOX_ADRESSE__: JSON.stringify(adresse),
|
|
103
|
+
__EMBERBOX_BILD__: JSON.stringify(optionen.logo ? '/logo-512.png' : ''),
|
|
104
|
+
},
|
|
105
|
+
optimizeDeps: { exclude: ['@emberbox/ui', '@iconify/vue'] },
|
|
106
|
+
resolve: { dedupe: ['vue', 'vue-router', '@nuxt/ui'] },
|
|
107
|
+
ssr: { noExternal: ['@emberbox/ui', '@nuxt/ui'] },
|
|
108
|
+
}),
|
|
109
|
+
transformIndexHtml: () => [
|
|
110
|
+
{ tag: 'script', children: FARBMODUS_SKRIPT, injectTo: 'head' },
|
|
111
|
+
],
|
|
112
|
+
generateBundle(ausgabe) {
|
|
113
|
+
if (ausgabe.format === 'es' && !this.environment?.config.build.ssr) {
|
|
114
|
+
this.emitFile({ type: 'asset', fileName: 'fassung.json', source: JSON.stringify(FASSUNG) });
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
optionen.logo ? logoPlugin(optionen.logo) : false,
|
|
119
|
+
optionen.vorrendern && adresse ? vorrenderPlugin(optionen.vorrendern, adresse) : false,
|
|
120
|
+
];
|
|
121
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2m4 7h4m-4 5h4m-8-5h.01M8 16h.01"/></g></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2z"/><path d="M21 16v2a4 4 0 0 1-4 4h-5"/></g></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12v4m0-10V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2m9 0a2 2 0 0 1 1.414.586l3 3A2 2 0 0 1 22 11v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 .586-1.414l3-3A2 2 0 0 1 7 6zM2 14h20M8 12v4"/></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="8" fill="#d5271b"/><g transform="translate(14 14) scale(1.5)" color="#fff"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M4.9 16.1C1 12.2 1 5.8 4.9 1.9m2.9 2.8a6.14 6.14 0 0 0-.8 7.5"/><circle cx="12" cy="9" r="2"/><path d="M16.2 4.8c2 2 2.26 5.11.8 7.47M19.1 1.9a9.96 9.96 0 0 1 0 14.1m-9.6 2h5M8 22l4-11l4 11"/></g></g></svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emberbox/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Gemeinsamer Stil und gemeinsame Bausteine der Emberbox-Werkzeuge, auf Basis von Nuxt UI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/rainbowdashlabs/emberbox.git",
|
|
10
|
+
"directory": "packages/ui"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"dist",
|
|
15
|
+
"logos"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/index.ts",
|
|
19
|
+
"./vorrendern": "./src/vorrendern.ts",
|
|
20
|
+
"./vite": {
|
|
21
|
+
"types": "./dist/vite.d.ts",
|
|
22
|
+
"import": "./dist/vite.js"
|
|
23
|
+
},
|
|
24
|
+
"./stil.css": "./src/stil.css",
|
|
25
|
+
"./logos/*": "./logos/*"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.vite.json",
|
|
29
|
+
"typecheck": "vue-tsc -b",
|
|
30
|
+
"icons": "node scripts/icons-pruefen.mjs",
|
|
31
|
+
"logos": "node scripts/logos-bauen.mjs",
|
|
32
|
+
"prepack": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@fontsource/barlow": "^5.3.0",
|
|
36
|
+
"@fontsource/barlow-condensed": "^5.3.0",
|
|
37
|
+
"@fontsource/ibm-plex-mono": "^5.3.0",
|
|
38
|
+
"@iconify-json/lucide": "^1.2.159",
|
|
39
|
+
"@iconify/vue": "^5.0.5",
|
|
40
|
+
"@internationalized/date": "^3.12.4",
|
|
41
|
+
"@nuxt/ui": "^4.13.1",
|
|
42
|
+
"@unhead/vue": "^3.4.3",
|
|
43
|
+
"@vueuse/core": "^14.4.0",
|
|
44
|
+
"defu": "^6.1.7",
|
|
45
|
+
"tailwindcss": "^4.3.5",
|
|
46
|
+
"uqr": "^0.1.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"vite": "^7.0.0 || ^8.0.0",
|
|
50
|
+
"vue": "^3.5.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^24.0.0",
|
|
54
|
+
"@vue/tsconfig": "^0.9.1",
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"vite": "^8.3.8",
|
|
57
|
+
"vue": "^3.5.46",
|
|
58
|
+
"vue-tsc": "^3.3.14"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"provenance": true
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/adressen.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Die Startseite aller Emberbox-Werkzeuge. */
|
|
2
|
+
export const HUB_URL = 'https://emberbox.app'
|
|
3
|
+
|
|
4
|
+
/** Das gemeinsame Impressum aller Werkzeuge. */
|
|
5
|
+
export const IMPRESSUM_URL = `${HUB_URL}/impressum`
|
|
6
|
+
|
|
7
|
+
/** Die gemeinsame Datenschutzerklärung aller Werkzeuge. */
|
|
8
|
+
export const DATENSCHUTZ_URL = `${HUB_URL}/datenschutz`
|
package/src/app.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {type Component, createApp, createSSRApp} from 'vue'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Erzeugt die App eines Werkzeugs im Browser. Ist die Seite vorgerendert, übernimmt Vue das
|
|
5
|
+
* vorhandene HTML (Hydration), sonst baut es die Seite neu auf. Vor `mount` muss der Router bereit
|
|
6
|
+
* sein (`await router.isReady()`), damit die Hydration dieselbe Seite trifft.
|
|
7
|
+
*/
|
|
8
|
+
export function appErzeugen(wurzel: Component) {
|
|
9
|
+
const vorgerendert = (document.getElementById('app')?.childElementCount ?? 0) > 0
|
|
10
|
+
return vorgerendert ? createSSRApp(wurzel) : createApp(wurzel)
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {onBeforeUnmount, onMounted, ref} from 'vue'
|
|
2
|
+
import {fassung} from '../fassung'
|
|
3
|
+
|
|
4
|
+
/** Wie oft eine offene Seite nachfragt, welchen Build der Server ausliefert. */
|
|
5
|
+
export const PRUEFEN_ALLE_MS = 60_000
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Ob der Server einen neueren Build ausliefert als den, in dem diese Seite läuft. Die Seite fragt
|
|
9
|
+
* dazu ab und zu und bei jeder Rückkehr in den Vordergrund die `fassung.json` ab, die `emberbox()`
|
|
10
|
+
* neben jeden Build legt. Eine über ein Deployment offen gebliebene Seite liefe sonst mit dem alten
|
|
11
|
+
* Frontend gegen den neuen Server.
|
|
12
|
+
*/
|
|
13
|
+
export function useNeueFassung() {
|
|
14
|
+
const neu = ref(false)
|
|
15
|
+
let zeitgeber: ReturnType<typeof setInterval> | undefined
|
|
16
|
+
|
|
17
|
+
async function pruefen(): Promise<void> {
|
|
18
|
+
if (neu.value) return
|
|
19
|
+
try {
|
|
20
|
+
const antwort = await fetch('/fassung.json', {cache: 'no-store'})
|
|
21
|
+
if (!antwort.ok) return
|
|
22
|
+
const {gebaut} = await antwort.json() as {gebaut?: string}
|
|
23
|
+
neu.value = Boolean(gebaut) && gebaut !== fassung.gebaut
|
|
24
|
+
} catch {
|
|
25
|
+
neu.value = false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function sichtbar(): void {
|
|
30
|
+
if (document.visibilityState === 'visible') void pruefen()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
zeitgeber = setInterval(() => void pruefen(), PRUEFEN_ALLE_MS)
|
|
35
|
+
document.addEventListener('visibilitychange', sichtbar)
|
|
36
|
+
void pruefen()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
onBeforeUnmount(() => {
|
|
40
|
+
clearInterval(zeitgeber)
|
|
41
|
+
document.removeEventListener('visibilitychange', sichtbar)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return neu
|
|
45
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {onBeforeUnmount, onMounted, ref} from 'vue'
|
|
2
|
+
|
|
3
|
+
/** Wie ein Werkzeug den Server abfragt. */
|
|
4
|
+
export interface PollingOptionen {
|
|
5
|
+
/** Abstand zwischen zwei Abfragen, solange der Server antwortet. */
|
|
6
|
+
intervallMs?: number
|
|
7
|
+
/** Längster Abstand, auf den das Warten nach Fehlern anwächst. */
|
|
8
|
+
hoechstensMs?: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Fragt regelmäßig ab, solange die Seite sichtbar ist. Scheitert eine Abfrage, verdoppelt sich der
|
|
13
|
+
* Abstand bis `hoechstensMs`, damit ein ausgefallener Server nicht im Sekundentakt angefragt wird;
|
|
14
|
+
* die erste gelungene Abfrage setzt ihn zurück. Ein verdeckter Tab fragt nicht, und beim
|
|
15
|
+
* Zurückkehren wird sofort abgefragt.
|
|
16
|
+
*
|
|
17
|
+
* Es läuft nie mehr als eine Abfrage zugleich, damit eine spät eintreffende ältere Antwort keine
|
|
18
|
+
* neuere überschreibt. Wird während einer laufenden Abfrage erneut angestoßen, folgt genau eine
|
|
19
|
+
* weitere, sobald sie fertig ist.
|
|
20
|
+
*
|
|
21
|
+
* @param abfrage holt den Stand; ein Fehler gilt als verlorene Verbindung
|
|
22
|
+
* @returns ob die letzte Abfrage gelang, und `jetzt`, das sofort neu abfragt
|
|
23
|
+
*/
|
|
24
|
+
export function usePolling(abfrage: () => Promise<unknown>, optionen: PollingOptionen = {}) {
|
|
25
|
+
const intervallMs = optionen.intervallMs ?? 2_000
|
|
26
|
+
const hoechstensMs = optionen.hoechstensMs ?? 30_000
|
|
27
|
+
const verbunden = ref(false)
|
|
28
|
+
let abstand = intervallMs
|
|
29
|
+
let zeitgeber: ReturnType<typeof setTimeout> | undefined
|
|
30
|
+
let aktiv = false
|
|
31
|
+
let laeuft = false
|
|
32
|
+
let nochmal = false
|
|
33
|
+
|
|
34
|
+
function planen(): void {
|
|
35
|
+
clearTimeout(zeitgeber)
|
|
36
|
+
if (aktiv && document.visibilityState === 'visible') {
|
|
37
|
+
zeitgeber = setTimeout(() => void runde(), abstand)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function runde(): Promise<void> {
|
|
42
|
+
if (laeuft) {
|
|
43
|
+
nochmal = true
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
laeuft = true
|
|
47
|
+
clearTimeout(zeitgeber)
|
|
48
|
+
try {
|
|
49
|
+
await abfrage()
|
|
50
|
+
verbunden.value = true
|
|
51
|
+
abstand = intervallMs
|
|
52
|
+
} catch {
|
|
53
|
+
verbunden.value = false
|
|
54
|
+
abstand = Math.min(abstand * 2, hoechstensMs)
|
|
55
|
+
} finally {
|
|
56
|
+
laeuft = false
|
|
57
|
+
}
|
|
58
|
+
if (nochmal && aktiv) {
|
|
59
|
+
nochmal = false
|
|
60
|
+
void runde()
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
planen()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function sichtbar(): void {
|
|
67
|
+
if (document.visibilityState === 'visible') {
|
|
68
|
+
void runde()
|
|
69
|
+
} else {
|
|
70
|
+
clearTimeout(zeitgeber)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function jetzt(): void {
|
|
75
|
+
abstand = intervallMs
|
|
76
|
+
void runde()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onMounted(() => {
|
|
80
|
+
aktiv = true
|
|
81
|
+
document.addEventListener('visibilitychange', sichtbar)
|
|
82
|
+
void runde()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
onBeforeUnmount(() => {
|
|
86
|
+
aktiv = false
|
|
87
|
+
nochmal = false
|
|
88
|
+
clearTimeout(zeitgeber)
|
|
89
|
+
document.removeEventListener('visibilitychange', sichtbar)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return {verbunden, jetzt}
|
|
93
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {useOverlay} from '@nuxt/ui/composables'
|
|
2
|
+
import Rueckfrage from '../komponenten/Rueckfrage.vue'
|
|
3
|
+
|
|
4
|
+
/** Was eine Rückfrage außer der Frage selbst zeigt. */
|
|
5
|
+
export interface RueckfrageOptionen {
|
|
6
|
+
/** Ein Satz unter der Frage, etwa was die Handlung auslöst. */
|
|
7
|
+
erklaerung?: string
|
|
8
|
+
/** Die Beschriftung des bestätigenden Knopfs. */
|
|
9
|
+
bestaetigung?: string
|
|
10
|
+
/** Ob die Handlung etwas zerstört; der Knopf erscheint dann in Signalrot. */
|
|
11
|
+
gefahr?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Eine Bestätigung im Seiteninneren statt `window.confirm`, das die ganze Seite blockiert und
|
|
16
|
+
* damit auch jede laufende Abfrage anhält. Muss im `setup` einer Komponente unter `EmberboxApp`
|
|
17
|
+
* aufgerufen werden. Jede Rückfrage legt ihr Fenster neu an und räumt es nach dem Schließen weg.
|
|
18
|
+
*
|
|
19
|
+
* @returns eine Funktion, die die Rückfrage öffnet und mit `true` auflöst, wenn bestätigt wurde
|
|
20
|
+
*/
|
|
21
|
+
export function useRueckfrage() {
|
|
22
|
+
const overlay = useOverlay()
|
|
23
|
+
return async (frage: string, optionen: RueckfrageOptionen = {}): Promise<boolean> => {
|
|
24
|
+
const fenster = overlay.create(Rueckfrage, {destroyOnClose: true})
|
|
25
|
+
return Boolean(await fenster.open({frage, ...optionen}).result)
|
|
26
|
+
}
|
|
27
|
+
}
|