@emberbox/ui 0.1.0 → 0.2.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.
Files changed (49) hide show
  1. package/README.md +9 -9
  2. package/dist/vite/logo.d.ts +3 -4
  3. package/dist/vite/logo.js +15 -16
  4. package/dist/vite/prerender.d.ts +17 -0
  5. package/dist/vite/prerender.js +57 -0
  6. package/dist/vite.d.ts +24 -24
  7. package/dist/vite.js +46 -46
  8. package/package.json +6 -6
  9. package/src/build-info.ts +23 -0
  10. package/src/clipboard.ts +34 -0
  11. package/src/components/AppFooter.vue +66 -0
  12. package/src/{komponenten/AppKopf.vue → components/AppHeader.vue} +13 -13
  13. package/src/components/CodeDisplay.vue +78 -0
  14. package/src/components/ConfirmDialog.vue +25 -0
  15. package/src/{komponenten → components}/EmberboxApp.vue +4 -4
  16. package/src/{komponenten/HilfeMockup.vue → components/HelpMockup.vue} +3 -3
  17. package/src/components/HelpPage.vue +16 -0
  18. package/src/components/HelpSection.vue +11 -0
  19. package/src/components/HelpTopic.vue +20 -0
  20. package/src/{komponenten/NeueFassung.vue → components/NewBuildBanner.vue} +8 -8
  21. package/src/composables/useConfirm.ts +27 -0
  22. package/src/composables/useNewBuild.ts +45 -0
  23. package/src/composables/usePolling.ts +55 -57
  24. package/src/create-app.ts +11 -0
  25. package/src/index.ts +22 -21
  26. package/src/page.ts +81 -0
  27. package/src/prerender.ts +23 -0
  28. package/src/{stil.css → style.css} +58 -58
  29. package/src/urls.ts +8 -0
  30. package/src/vite/logo.ts +16 -17
  31. package/src/vite/prerender.ts +72 -0
  32. package/src/vite.ts +55 -55
  33. package/dist/vite/vorrendern.d.ts +0 -17
  34. package/dist/vite/vorrendern.js +0 -57
  35. package/src/adressen.ts +0 -8
  36. package/src/app.ts +0 -11
  37. package/src/composables/useNeueFassung.ts +0 -45
  38. package/src/composables/useRueckfrage.ts +0 -27
  39. package/src/fassung.ts +0 -23
  40. package/src/komponenten/AppFuss.vue +0 -58
  41. package/src/komponenten/CodeAnzeige.vue +0 -79
  42. package/src/komponenten/HilfeAbschnitt.vue +0 -11
  43. package/src/komponenten/HilfeSeite.vue +0 -16
  44. package/src/komponenten/HilfeThema.vue +0 -20
  45. package/src/komponenten/Rueckfrage.vue +0 -24
  46. package/src/seite.ts +0 -81
  47. package/src/vite/vorrendern.ts +0 -72
  48. package/src/vorrendern.ts +0 -24
  49. package/src/zwischenablage.ts +0 -34
@@ -27,62 +27,62 @@
27
27
  --color-signal-900: #721914;
28
28
  --color-signal-950: #2a1614;
29
29
 
30
- --color-stahl-50: #f4f6f8;
31
- --color-stahl-100: #eef1f4;
32
- --color-stahl-200: #dce1e7;
33
- --color-stahl-300: #c1c8d1;
34
- --color-stahl-400: #8a94a2;
35
- --color-stahl-500: #5c6775;
36
- --color-stahl-600: #444e5b;
37
- --color-stahl-700: #2a333e;
38
- --color-stahl-800: #212932;
39
- --color-stahl-900: #1a2027;
40
- --color-stahl-950: #12161c;
41
-
42
- --color-tinte: #10141a;
43
- --color-band: #4fa3e3;
30
+ --color-steel-50: #f4f6f8;
31
+ --color-steel-100: #eef1f4;
32
+ --color-steel-200: #dce1e7;
33
+ --color-steel-300: #c1c8d1;
34
+ --color-steel-400: #8a94a2;
35
+ --color-steel-500: #5c6775;
36
+ --color-steel-600: #444e5b;
37
+ --color-steel-700: #2a333e;
38
+ --color-steel-800: #212932;
39
+ --color-steel-900: #1a2027;
40
+ --color-steel-950: #12161c;
41
+
42
+ --color-ink: #10141a;
43
+ --color-sky: #4fa3e3;
44
44
  }
45
45
 
46
46
  :root {
47
47
  --ui-radius: 4px;
48
48
 
49
- --ui-color-neutral-50: var(--color-stahl-50);
50
- --ui-color-neutral-100: var(--color-stahl-100);
51
- --ui-color-neutral-200: var(--color-stahl-200);
52
- --ui-color-neutral-300: var(--color-stahl-300);
53
- --ui-color-neutral-400: var(--color-stahl-400);
54
- --ui-color-neutral-500: var(--color-stahl-500);
55
- --ui-color-neutral-600: var(--color-stahl-600);
56
- --ui-color-neutral-700: var(--color-stahl-700);
57
- --ui-color-neutral-800: var(--color-stahl-800);
58
- --ui-color-neutral-900: var(--color-stahl-900);
59
- --ui-color-neutral-950: var(--color-stahl-950);
60
-
61
- --ui-primary: var(--color-tinte);
49
+ --ui-color-neutral-50: var(--color-steel-50);
50
+ --ui-color-neutral-100: var(--color-steel-100);
51
+ --ui-color-neutral-200: var(--color-steel-200);
52
+ --ui-color-neutral-300: var(--color-steel-300);
53
+ --ui-color-neutral-400: var(--color-steel-400);
54
+ --ui-color-neutral-500: var(--color-steel-500);
55
+ --ui-color-neutral-600: var(--color-steel-600);
56
+ --ui-color-neutral-700: var(--color-steel-700);
57
+ --ui-color-neutral-800: var(--color-steel-800);
58
+ --ui-color-neutral-900: var(--color-steel-900);
59
+ --ui-color-neutral-950: var(--color-steel-950);
60
+
61
+ --ui-primary: var(--color-ink);
62
62
  --ui-signal: var(--color-signal-500);
63
63
  --ui-error: var(--color-signal-500);
64
64
 
65
65
  --ui-bg: #ffffff;
66
- --ui-bg-muted: var(--color-stahl-50);
67
- --ui-bg-elevated: var(--color-stahl-100);
68
- --ui-bg-accented: var(--color-stahl-200);
69
- --ui-bg-inverted: var(--color-tinte);
70
-
71
- --ui-text-dimmed: var(--color-stahl-400);
72
- --ui-text-muted: var(--color-stahl-500);
73
- --ui-text-toned: var(--color-stahl-600);
74
- --ui-text: var(--color-tinte);
75
- --ui-text-highlighted: var(--color-tinte);
66
+ --ui-bg-muted: var(--color-steel-50);
67
+ --ui-bg-elevated: var(--color-steel-100);
68
+ --ui-bg-accented: var(--color-steel-200);
69
+ --ui-bg-inverted: var(--color-ink);
70
+
71
+ --ui-text-dimmed: var(--color-steel-400);
72
+ --ui-text-muted: var(--color-steel-500);
73
+ --ui-text-toned: var(--color-steel-600);
74
+ --ui-text: var(--color-ink);
75
+ --ui-text-highlighted: var(--color-ink);
76
76
  --ui-text-inverted: #ffffff;
77
77
 
78
- --ui-border: var(--color-stahl-200);
79
- --ui-border-muted: var(--color-stahl-100);
80
- --ui-border-accented: var(--color-stahl-300);
81
- --ui-border-inverted: var(--color-tinte);
78
+ --ui-border: var(--color-steel-200);
79
+ --ui-border-muted: var(--color-steel-100);
80
+ --ui-border-accented: var(--color-steel-300);
81
+ --ui-border-inverted: var(--color-ink);
82
82
 
83
- --eb-seite: var(--color-stahl-50);
83
+ --eb-page: var(--color-steel-50);
84
84
  --eb-signal-text: var(--color-signal-700);
85
- --eb-fokus: var(--color-signal-500);
85
+ --eb-focus: var(--color-signal-500);
86
86
  }
87
87
 
88
88
  :root.dark {
@@ -90,32 +90,32 @@
90
90
  --ui-signal: var(--color-signal-400);
91
91
  --ui-error: #ff6a58;
92
92
 
93
- --ui-bg: var(--color-stahl-900);
94
- --ui-bg-muted: var(--color-stahl-950);
95
- --ui-bg-elevated: var(--color-stahl-800);
96
- --ui-bg-accented: var(--color-stahl-700);
93
+ --ui-bg: var(--color-steel-900);
94
+ --ui-bg-muted: var(--color-steel-950);
95
+ --ui-bg-elevated: var(--color-steel-800);
96
+ --ui-bg-accented: var(--color-steel-700);
97
97
  --ui-bg-inverted: #edf0f3;
98
98
 
99
- --ui-text-dimmed: var(--color-stahl-500);
99
+ --ui-text-dimmed: var(--color-steel-500);
100
100
  --ui-text-muted: #8892a0;
101
- --ui-text-toned: var(--color-stahl-300);
101
+ --ui-text-toned: var(--color-steel-300);
102
102
  --ui-text: #edf0f3;
103
103
  --ui-text-highlighted: #ffffff;
104
- --ui-text-inverted: var(--color-stahl-950);
104
+ --ui-text-inverted: var(--color-steel-950);
105
105
 
106
- --ui-border: var(--color-stahl-700);
107
- --ui-border-muted: var(--color-stahl-800);
108
- --ui-border-accented: var(--color-stahl-600);
106
+ --ui-border: var(--color-steel-700);
107
+ --ui-border-muted: var(--color-steel-800);
108
+ --ui-border-accented: var(--color-steel-600);
109
109
  --ui-border-inverted: #edf0f3;
110
110
 
111
- --eb-seite: var(--color-stahl-950);
111
+ --eb-page: var(--color-steel-950);
112
112
  --eb-signal-text: #ff6a58;
113
- --eb-fokus: var(--color-band);
113
+ --eb-focus: var(--color-sky);
114
114
  }
115
115
 
116
116
  html,
117
117
  body {
118
- background-color: var(--eb-seite);
118
+ background-color: var(--eb-page);
119
119
  }
120
120
 
121
121
  body {
@@ -128,7 +128,7 @@ body {
128
128
 
129
129
  @layer base {
130
130
  :where(button, a, input, select, textarea, [tabindex]):focus-visible {
131
- outline: 2px solid var(--eb-fokus);
131
+ outline: 2px solid var(--eb-focus);
132
132
  outline-offset: 2px;
133
133
  }
134
134
  }
@@ -161,7 +161,7 @@ body {
161
161
  }
162
162
  }
163
163
 
164
- @utility feld-label {
164
+ @utility field-label {
165
165
  font-family: var(--font-condensed);
166
166
  font-weight: 600;
167
167
  font-size: 12px;
package/src/urls.ts ADDED
@@ -0,0 +1,8 @@
1
+ /** The start page of all Emberbox tools. */
2
+ export const HUB_URL = 'https://emberbox.app'
3
+
4
+ /** The imprint shared by all tools. */
5
+ export const IMPRINT_URL = `${HUB_URL}/impressum`
6
+
7
+ /** The privacy policy shared by all tools. */
8
+ export const PRIVACY_URL = `${HUB_URL}/datenschutz`
package/src/vite/logo.ts CHANGED
@@ -2,13 +2,15 @@ import {readFileSync} from 'node:fs'
2
2
  import {fileURLToPath} from 'node:url'
3
3
  import type {Plugin} from 'vite'
4
4
 
5
- /** Die Werkzeuge, für die `@emberbox/ui` ein Logo mitbringt. */
5
+ /** The tools for which `@emberbox/ui` ships a logo. */
6
6
  export type Logo = 'emberbox' | 'alarmzettel' | 'statussim' | 'calltaker'
7
7
 
8
8
  const LOGOS = fileURLToPath(new URL('../../logos/', import.meta.url))
9
9
 
10
- /** Welche Datei unter welchem Namen im Wurzelverzeichnis des Werkzeugs liegt. */
11
- function dateien(logo: Logo): Record<string, string> {
10
+ const CONTENT_TYPES: Record<string, string> = {svg: 'image/svg+xml', png: 'image/png'}
11
+
12
+ /** Which file is served under which name at the tool's root. */
13
+ function logoFiles(logo: Logo): Record<string, string> {
12
14
  return {
13
15
  'favicon.svg': `${LOGOS}${logo}.svg`,
14
16
  'apple-touch-icon.png': `${LOGOS}${logo}-180.png`,
@@ -16,30 +18,27 @@ function dateien(logo: Logo): Record<string, string> {
16
18
  }
17
19
  }
18
20
 
19
- const TYPEN: Record<string, string> = {svg: 'image/svg+xml', png: 'image/png'}
20
-
21
21
  /**
22
- * Liefert das Logo eines Werkzeugs als `favicon.svg`, `apple-touch-icon.png` und `logo-512.png`
23
- * im Wurzelverzeichnis aus, im Entwicklungsserver wie im Build, und verlinkt die ersten beiden im
24
- * Kopf jeder Seite.
22
+ * Serves a tool's logo as `favicon.svg`, `apple-touch-icon.png` and `logo-512.png` at the root, in
23
+ * the dev server as in the build, and links the first two in the head of every page.
25
24
  */
26
25
  export function logoPlugin(logo: Logo): Plugin {
27
- const liste = dateien(logo)
26
+ const files = logoFiles(logo)
28
27
  return {
29
28
  name: 'emberbox:logo',
30
29
  configureServer(server) {
31
- server.middlewares.use((anfrage, antwort, weiter) => {
32
- const name = anfrage.url?.split('?')[0]?.slice(1) ?? ''
33
- const datei = liste[name]
34
- if (!datei) return weiter()
35
- antwort.setHeader('Content-Type', TYPEN[name.split('.').pop() ?? ''] ?? 'application/octet-stream')
36
- antwort.end(readFileSync(datei))
30
+ server.middlewares.use((request, response, next) => {
31
+ const name = request.url?.split('?')[0]?.slice(1) ?? ''
32
+ const file = files[name]
33
+ if (!file) return next()
34
+ response.setHeader('Content-Type', CONTENT_TYPES[name.split('.').pop() ?? ''] ?? 'application/octet-stream')
35
+ response.end(readFileSync(file))
37
36
  })
38
37
  },
39
38
  generateBundle() {
40
39
  if (this.environment?.config.build.ssr) return
41
- for (const [name, datei] of Object.entries(liste)) {
42
- this.emitFile({type: 'asset', fileName: name, source: readFileSync(datei)})
40
+ for (const [name, file] of Object.entries(files)) {
41
+ this.emitFile({type: 'asset', fileName: name, source: readFileSync(file)})
43
42
  }
44
43
  },
45
44
  transformIndexHtml: () => [
@@ -0,0 +1,72 @@
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, type Plugin, type ResolvedConfig} from 'vite'
5
+
6
+ /** Which pages of a tool become finished HTML at build time. */
7
+ export interface PrerenderOptions {
8
+ /** Module that exports `render(path, template)`, such as `src/prerender.ts`. */
9
+ entry: string
10
+ /** The public paths, such as `['/', '/hilfe']`. */
11
+ paths: string[]
12
+ }
13
+
14
+ /** What a tool's entry module provides. */
15
+ interface PrerenderEntry {
16
+ render(path: string, template: string): Promise<string>
17
+ }
18
+
19
+ /** The directory below the build output that holds the prerendered pages. */
20
+ export const PAGES_DIR = 'pages'
21
+
22
+ function pageFile(outDir: string, path: string): string {
23
+ return join(outDir, PAGES_DIR, path.replace(/^\/+|\/+$/g, ''), 'index.html')
24
+ }
25
+
26
+ function sitemap(url: string, paths: string[]): string {
27
+ const entries = paths.map(path => ` <url><loc>${url}${path}</loc></url>`).join('\n')
28
+ return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${entries}\n</urlset>\n`
29
+ }
30
+
31
+ /**
32
+ * Prerenders the public pages once the client build is written. It builds the entry as an SSR
33
+ * bundle, calls `render` for every path with the built `index.html` as template and writes the
34
+ * result to `pages/<path>/index.html`. `index.html` itself stays the empty shell for all other
35
+ * routes. `sitemap.xml` and `robots.txt` are written next to it.
36
+ */
37
+ export function prerenderPlugin(options: PrerenderOptions, url: string): Plugin {
38
+ let config: ResolvedConfig
39
+ return {
40
+ name: 'emberbox:prerender',
41
+ apply: 'build',
42
+ configResolved(resolved) {
43
+ config = resolved
44
+ },
45
+ async writeBundle() {
46
+ if (config.build.ssr) return
47
+ const outDir = resolve(config.root, config.build.outDir)
48
+ const ssrOutDir = resolve(config.root, 'node_modules', '.emberbox-prerender')
49
+ await build({
50
+ configFile: config.configFile,
51
+ root: config.root,
52
+ mode: config.mode,
53
+ logLevel: 'warn',
54
+ build: {ssr: options.entry, outDir: ssrOutDir, emptyOutDir: true, copyPublicDir: false},
55
+ })
56
+ const name = basename(options.entry, extname(options.entry))
57
+ const bundle = readdirSync(ssrOutDir).find(candidate => /^(.+)\.m?js$/.exec(candidate)?.[1] === name)
58
+ if (!bundle) throw new Error(`The SSR bundle of ${options.entry} is missing in ${ssrOutDir}.`)
59
+ const entry = await import(pathToFileURL(join(ssrOutDir, bundle)).href) as PrerenderEntry
60
+ const template = readFileSync(join(outDir, 'index.html'), 'utf8')
61
+ for (const path of options.paths) {
62
+ const target = pageFile(outDir, path)
63
+ mkdirSync(join(target, '..'), {recursive: true})
64
+ writeFileSync(target, await entry.render(path, template))
65
+ }
66
+ writeFileSync(join(outDir, 'sitemap.xml'), sitemap(url, options.paths))
67
+ writeFileSync(join(outDir, 'robots.txt'), `User-agent: *\nAllow: /\n\nSitemap: ${url}/sitemap.xml\n`)
68
+ rmSync(ssrOutDir, {recursive: true, force: true})
69
+ config.logger.info(`emberbox: prerendered ${options.paths.length} pages`)
70
+ },
71
+ }
72
+ }
package/src/vite.ts CHANGED
@@ -4,34 +4,34 @@ import {defu} from 'defu'
4
4
  import {execSync} from 'node:child_process'
5
5
  import type {PluginOption} from 'vite'
6
6
  import {type Logo, logoPlugin} from './vite/logo.js'
7
- import {vorrenderPlugin, type VorrendernOptionen} from './vite/vorrendern.js'
7
+ import {prerenderPlugin, type PrerenderOptions} from './vite/prerender.js'
8
8
 
9
- export {SEITEN_VERZEICHNIS, type VorrendernOptionen} from './vite/vorrendern.js'
9
+ export {PAGES_DIR, type PrerenderOptions} from './vite/prerender.js'
10
10
  export type {Logo} from './vite/logo.js'
11
11
 
12
- /** Einstellungen, mit denen ein Werkzeug `emberbox()` an seine Lage anpasst. */
13
- export interface EmberboxOptionen {
14
- /** `false` für Werkzeuge ohne vue-router; Links werden dann als einfache Anker gerendert. */
12
+ /** Settings a tool passes to `emberbox()`. */
13
+ export interface EmberboxOptions {
14
+ /** `false` for tools without vue-router; links are then rendered as plain anchors. */
15
15
  router?: boolean
16
- /** Zusätzliche Nuxt-UI-Einstellungen des Werkzeugs, die über die Emberbox-Vorgaben gelegt werden. */
16
+ /** Additional Nuxt UI settings of the tool, applied on top of the Emberbox defaults. */
17
17
  ui?: NuxtUIOptions['ui']
18
- /** Die öffentliche Adresse, etwa `https://calltaker.emberbox.app`; ein `/` am Ende fällt weg. */
19
- adresse?: string
20
- /** Welches Emberbox-Logo als Favicon, Touch-Icon und Vorschaubild ausgeliefert wird. */
18
+ /** The public address, such as `https://calltaker.emberbox.app`; a trailing `/` is dropped. */
19
+ url?: string
20
+ /** Which Emberbox logo is served as favicon, touch icon and preview image. */
21
21
  logo?: Logo
22
- /** Welche öffentlichen Seiten beim Bauen vorgerendert werden; braucht `adresse`. */
23
- vorrendern?: VorrendernOptionen
22
+ /** Which public pages are prerendered at build time; needs `url`. */
23
+ prerender?: PrerenderOptions
24
24
  }
25
25
 
26
- const FARBEN = ['primary', 'signal', 'success', 'info', 'warning', 'error']
26
+ const COLORS = ['primary', 'signal', 'success', 'info', 'warning', 'error']
27
27
 
28
28
  /**
29
- * Die Vorgaben, mit denen jede Nuxt-UI-Komponente im Emberbox-Stil erscheint. Die Farbnamen zeigen
30
- * auf die Paletten aus `stil.css`; `primary` ist dort die Tinte, Rot bleibt Signalen und Fehlern.
29
+ * The defaults that make every Nuxt UI component appear in the Emberbox style. The colour names
30
+ * point to the palettes in `style.css`; `primary` is ink there, red is kept for signals and errors.
31
31
  */
32
- const VORGABEN: NuxtUIOptions['ui'] = {
32
+ const DEFAULTS: NuxtUIOptions['ui'] = {
33
33
  colors: {
34
- primary: 'stahl',
34
+ primary: 'steel',
35
35
  signal: 'signal',
36
36
  success: 'green',
37
37
  info: 'blue',
@@ -41,25 +41,25 @@ const VORGABEN: NuxtUIOptions['ui'] = {
41
41
  },
42
42
  formField: {
43
43
  slots: {
44
- label: 'feld-label',
44
+ label: 'field-label',
45
45
  },
46
46
  },
47
47
  }
48
48
 
49
49
  /**
50
- * Wo nach benutzten Icons gesucht wird. Anders als die Vorgabe von `@nuxt/icon` auch in `.ts`- und
51
- * `.js`-Dateien, weil Werkzeuge Icons in Menü- und Routentabellen eintragen.
50
+ * Where to look for used icons. Unlike the `@nuxt/icon` default this includes `.ts` and `.js`
51
+ * files, because tools list icons in menu and route tables.
52
52
  */
53
- const ICON_SUCHE = {
53
+ const ICON_SCAN = {
54
54
  globInclude: ['**/*.{vue,ts,tsx,js,jsx}'],
55
55
  globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*', '**/*.d.ts'],
56
56
  }
57
57
 
58
58
  /**
59
- * Die Icons der Komponenten aus `@emberbox/ui`. Die Suche durchläuft `node_modules` nicht, also
60
- * stehen sie hier fest; wer einer Komponente ein Icon gibt, trägt es hier ein.
59
+ * The icons of the `@emberbox/ui` components. The scan does not walk `node_modules`, so they are
60
+ * listed here; whoever gives a component an icon adds it here.
61
61
  */
62
- export const EIGENE_ICONS = [
62
+ export const OWN_ICONS = [
63
63
  'i-lucide-check',
64
64
  'i-lucide-copy',
65
65
  'i-lucide-github',
@@ -71,14 +71,14 @@ export const EIGENE_ICONS = [
71
71
  ]
72
72
 
73
73
  /**
74
- * Setzt vor dem ersten Zeichnen die Klasse `dark`, damit die Seite nicht hell aufblitzt. Liest
75
- * denselben Schlüssel wie Nuxt UIs Farbmodus (`useDark` aus VueUse) und folgt ohne Wahl dem System.
74
+ * Sets the class `dark` before the first paint, so the page does not flash light. Reads the same
75
+ * key as Nuxt UI's colour mode (`useDark` from VueUse) and follows the system without a choice.
76
76
  */
77
- 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){}})()`
77
+ export const COLOR_MODE_SCRIPT = `(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){}})()`
78
78
 
79
79
  /**
80
- * Der kurze Commit, aus dem gebaut wird. Ein Image-Build ohne `.git` reicht ihn als Umgebungsvariable
81
- * `COMMIT` herein; ohne beides heißt er `dev`.
80
+ * The short commit being built. An image build without `.git` passes it in as the environment
81
+ * variable `COMMIT`; without either it is `dev`.
82
82
  */
83
83
  function commit(): string {
84
84
  if (process.env.COMMIT) return process.env.COMMIT
@@ -90,56 +90,56 @@ function commit(): string {
90
90
  }
91
91
 
92
92
  /**
93
- * Commit und Bauzeit dieses Bauvorgangs. Einmal je Prozess bestimmt, damit Client- und SSR-Build
94
- * eines Werkzeugs dieselbe Fassung tragen.
93
+ * Commit and build time of this build. Determined once per process, so the client and SSR build of
94
+ * a tool carry the same build info.
95
95
  */
96
- const FASSUNG = {commit: commit(), gebaut: process.env.GEBAUT || new Date().toISOString()}
96
+ const BUILD_INFO = {commit: commit(), builtAt: process.env.BUILD_TIME || new Date().toISOString()}
97
97
 
98
98
  /**
99
- * Richtet Nuxt UI mit dem Emberbox-Stil ein und setzt das Farbmodus-Skript in jede HTML-Seite.
100
- * Ersetzt in einem Werkzeug `@tailwindcss/vite`, das Nuxt UI selbst mitbringt. Icons werden aus den
101
- * installierten Iconify-Sammlungen gebündelt, damit der Browser nichts bei der Iconify-API nachlädt.
99
+ * Sets up Nuxt UI in the Emberbox style and puts the colour mode script into every HTML page.
100
+ * Replaces `@tailwindcss/vite` in a tool, since Nuxt UI brings it along. Icons are bundled from the
101
+ * installed Iconify collections, so the browser fetches nothing from the Iconify API.
102
102
  *
103
- * Außerdem stehen Commit und Bauzeit (`GEBAUT` aus der Umgebung oder jetzt) als `fassung` aus
104
- * `@emberbox/ui` bereit, und neben jedem Build liegt `fassung.json`, an der offene Seiten einen
105
- * neueren Build erkennen.
103
+ * Commit and build time (`BUILD_TIME` from the environment, or now) are available as `buildInfo`
104
+ * from `@emberbox/ui`, and every build gets a `build.json` by which open pages notice a newer
105
+ * build.
106
106
  */
107
- export function emberbox(optionen: EmberboxOptionen = {}): PluginOption[] {
108
- const adresse = optionen.adresse?.replace(/\/+$/, '') ?? ''
109
- if (optionen.vorrendern && !adresse) {
110
- throw new Error('emberbox(): Zum Vorrendern fehlt die adresse.')
107
+ export function emberbox(options: EmberboxOptions = {}): PluginOption[] {
108
+ const url = options.url?.replace(/\/+$/, '') ?? ''
109
+ if (options.prerender && !url) {
110
+ throw new Error('emberbox(): prerendering needs a url.')
111
111
  }
112
112
  return [
113
113
  ui({
114
- router: optionen.router ?? true,
115
- theme: {colors: FARBEN},
116
- ui: defu(optionen.ui, VORGABEN),
117
- icon: {clientBundle: {scan: ICON_SUCHE, icons: EIGENE_ICONS}},
114
+ router: options.router ?? true,
115
+ theme: {colors: COLORS},
116
+ ui: defu(options.ui, DEFAULTS),
117
+ icon: {clientBundle: {scan: ICON_SCAN, icons: OWN_ICONS}},
118
118
  scanPackages: ['@emberbox/ui'],
119
119
  }),
120
120
  {
121
121
  name: 'emberbox',
122
122
  config: () => ({
123
123
  define: {
124
- __EMBERBOX_COMMIT__: JSON.stringify(FASSUNG.commit),
125
- __EMBERBOX_GEBAUT__: JSON.stringify(FASSUNG.gebaut),
126
- __EMBERBOX_ADRESSE__: JSON.stringify(adresse),
127
- __EMBERBOX_BILD__: JSON.stringify(optionen.logo ? '/logo-512.png' : ''),
124
+ __EMBERBOX_COMMIT__: JSON.stringify(BUILD_INFO.commit),
125
+ __EMBERBOX_BUILT_AT__: JSON.stringify(BUILD_INFO.builtAt),
126
+ __EMBERBOX_URL__: JSON.stringify(url),
127
+ __EMBERBOX_IMAGE__: JSON.stringify(options.logo ? '/logo-512.png' : ''),
128
128
  },
129
129
  optimizeDeps: {exclude: ['@emberbox/ui', '@iconify/vue']},
130
130
  resolve: {dedupe: ['vue', 'vue-router', '@nuxt/ui']},
131
131
  ssr: {noExternal: ['@emberbox/ui', '@nuxt/ui']},
132
132
  }),
133
133
  transformIndexHtml: () => [
134
- {tag: 'script', children: FARBMODUS_SKRIPT, injectTo: 'head'},
134
+ {tag: 'script', children: COLOR_MODE_SCRIPT, injectTo: 'head'},
135
135
  ],
136
- generateBundle(this, ausgabe) {
137
- if (ausgabe.format === 'es' && !this.environment?.config.build.ssr) {
138
- this.emitFile({type: 'asset', fileName: 'fassung.json', source: JSON.stringify(FASSUNG)})
136
+ generateBundle(this, output) {
137
+ if (output.format === 'es' && !this.environment?.config.build.ssr) {
138
+ this.emitFile({type: 'asset', fileName: 'build.json', source: JSON.stringify(BUILD_INFO)})
139
139
  }
140
140
  },
141
141
  },
142
- optionen.logo ? logoPlugin(optionen.logo) : false,
143
- optionen.vorrendern && adresse ? vorrenderPlugin(optionen.vorrendern, adresse) : false,
142
+ options.logo ? logoPlugin(options.logo) : false,
143
+ options.prerender && url ? prerenderPlugin(options.prerender, url) : false,
144
144
  ]
145
145
  }
@@ -1,17 +0,0 @@
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;
@@ -1,57 +0,0 @@
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/src/adressen.ts DELETED
@@ -1,8 +0,0 @@
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 DELETED
@@ -1,11 +0,0 @@
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
- }