@miragon/modeler-shell 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 (97) hide show
  1. package/API.md +1051 -84
  2. package/README.md +162 -31
  3. package/dist/appearance-BBaM_4bD.d.ts +323 -0
  4. package/dist/appearance-XX3JC3pI.d.cts +323 -0
  5. package/dist/{chunk-6LQOFACK.js → chunk-66HCSJNY.js} +1247 -31
  6. package/dist/chunk-66HCSJNY.js.map +1 -0
  7. package/dist/{chunk-RJRFR6N3.js → chunk-KYDG5DMX.js} +2 -2
  8. package/dist/{chunk-5JSZ4VGA.js → chunk-OADW3GPA.js} +240 -6
  9. package/dist/chunk-OADW3GPA.js.map +1 -0
  10. package/dist/core.cjs +260 -6
  11. package/dist/core.cjs.map +1 -1
  12. package/dist/core.d.cts +81 -6
  13. package/dist/core.d.ts +81 -6
  14. package/dist/core.js +43 -3
  15. package/dist/diagram-js.cjs +34 -2
  16. package/dist/diagram-js.cjs.map +1 -1
  17. package/dist/diagram-js.d.cts +10 -3
  18. package/dist/diagram-js.d.ts +10 -3
  19. package/dist/diagram-js.js +14 -2
  20. package/dist/diagram-js.js.map +1 -1
  21. package/dist/index.cjs +1654 -197
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +18 -9
  24. package/dist/index.d.ts +18 -9
  25. package/dist/index.js +44 -4
  26. package/dist/shell.css +692 -3
  27. package/dist/testing-vscode-stub.js +2 -2
  28. package/dist/testing.cjs +2849 -550
  29. package/dist/testing.cjs.map +1 -1
  30. package/dist/testing.d.cts +75 -9
  31. package/dist/testing.d.ts +75 -9
  32. package/dist/testing.js +2744 -558
  33. package/dist/testing.js.map +1 -1
  34. package/dist/toasts-Bp0REqdq.d.cts +142 -0
  35. package/dist/toasts-Bp0REqdq.d.ts +142 -0
  36. package/dist/{types-OuFlqZp0.d.cts → types-CnRrINRs.d.cts} +170 -9
  37. package/dist/{types-DnZn9CPw.d.ts → types-PuDZczzy.d.ts} +170 -9
  38. package/dist/vscode-extension.js +2 -2
  39. package/dist/vscode-webview.cjs +1541 -178
  40. package/dist/vscode-webview.cjs.map +1 -1
  41. package/dist/vscode-webview.d.cts +6 -4
  42. package/dist/vscode-webview.d.ts +6 -4
  43. package/dist/vscode-webview.js +11 -2
  44. package/dist/vscode-webview.js.map +1 -1
  45. package/package.json +2 -2
  46. package/src/core/feedback/appearance.ts +141 -0
  47. package/src/core/feedback/problems.ts +23 -0
  48. package/src/core/feedback/toasts.ts +118 -0
  49. package/src/core/fit.ts +18 -3
  50. package/src/core/index.ts +43 -0
  51. package/src/core/keymap.ts +20 -0
  52. package/src/core/messages.ts +71 -0
  53. package/src/core/types.ts +24 -2
  54. package/src/core/web-chrome/bottom-row.ts +37 -0
  55. package/src/core/web-chrome/drop.ts +78 -0
  56. package/src/core/web-chrome/top-row.ts +66 -0
  57. package/src/diagram-js/service.ts +4 -1
  58. package/src/diagram-js/viewport.ts +19 -0
  59. package/src/dom/buttons.css +124 -0
  60. package/src/dom/feedback/appearance.ts +184 -0
  61. package/src/dom/feedback/feedback.css +435 -0
  62. package/src/dom/feedback/problems-popover.ts +287 -0
  63. package/src/dom/feedback/toasts.ts +431 -0
  64. package/src/dom/index.ts +13 -0
  65. package/src/dom/keys.ts +8 -0
  66. package/src/dom/menu.ts +28 -17
  67. package/src/dom/mount.ts +290 -20
  68. package/src/dom/problems.ts +5 -4
  69. package/src/dom/shell-dom.css +7 -4
  70. package/src/dom/types.ts +188 -6
  71. package/src/dom/web/drop-zone.ts +181 -0
  72. package/src/dom/web/empty-state.ts +144 -0
  73. package/src/dom/web/legal.ts +75 -0
  74. package/src/dom/web/menu-groups.ts +69 -0
  75. package/src/dom/web/primary.ts +124 -0
  76. package/src/dom/web/web.css +386 -0
  77. package/src/shell.css +3 -0
  78. package/src/testing/case-tools.ts +164 -0
  79. package/src/testing/cases.ts +209 -144
  80. package/src/testing/checks.ts +51 -15
  81. package/src/testing/facts.ts +56 -2
  82. package/src/testing/geometry.ts +206 -26
  83. package/src/testing/harness.ts +56 -7
  84. package/src/testing/index.ts +4 -0
  85. package/src/testing/page-tools.ts +24 -1
  86. package/src/testing/page.ts +10 -0
  87. package/src/testing/web-cases.ts +913 -0
  88. package/src/testing/web-checks.ts +1049 -0
  89. package/src/testing/web-facts.ts +713 -0
  90. package/src/vscode/webview/mount.ts +13 -1
  91. package/dist/chunk-5JSZ4VGA.js.map +0 -1
  92. package/dist/chunk-6LQOFACK.js.map +0 -1
  93. package/dist/keymap-CObQE6q6.d.cts +0 -151
  94. package/dist/keymap-DORzHnK-.d.ts +0 -151
  95. package/dist/types-B6NfkiUG.d.cts +0 -66
  96. package/dist/types-B6NfkiUG.d.ts +0 -66
  97. /package/dist/{chunk-RJRFR6N3.js.map → chunk-KYDG5DMX.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { c as ShellHost, Z as ZoomTarget, I as Insets } from './types-B6NfkiUG.js';
2
- import { P as Platform, d as ShellMessages, S as ShellMessageOverrides } from './keymap-DORzHnK-.js';
1
+ import { d as ShellHost, Z as ZoomTarget, I as Insets, h as ToastRequest } from './toasts-Bp0REqdq.js';
2
+ import { P as Platform, k as ShellMessages, a as AppearanceChoice, i as ProblemItem, S as ShellMessageOverrides, l as ThemeColors } from './appearance-BBaM_4bD.js';
3
3
  import { T as Theme } from './appearance-D3FUcbu6.js';
4
4
 
5
5
  /*! @miragon/modeler-shell icon geometry
@@ -54,10 +54,11 @@ interface ShellOptions {
54
54
  keyScope?: "document" | "root" | undefined;
55
55
  /**
56
56
  * The modes the modeler can show (a static value of the modeler package), default `["light"]`.
57
- * Read in the `embedded` host only: there the root carries `data-cd-theme="<themes[0]>"` itself
58
- * (until the contract's `appearance` surface an embedded modeler stays in its first mode,
59
- * whatever the page shows) and mirrors the host's `data-cd-kontrast` (guide §13.3). In an own
60
- * document the host writes the mode on `<html>`.
57
+ * Read in the `embedded` and `web` hosts. Embedded: the root carries `data-cd-theme="<themes[0]>"`
58
+ * itself (until the contract's `appearance` surface an embedded modeler stays in its first mode,
59
+ * whatever the page shows) and mirrors the host's `data-cd-kontrast` (guide §13.3). Web: with
60
+ * `"dark"` the shell renders the Appearance group and applies the choice on `<html>` (needs
61
+ * `appearance`); light-only it renders no group. In the `ide` host the host writes the mode.
61
62
  */
62
63
  themes?: readonly Theme[] | undefined;
63
64
  /** The fixed menu groups this modeler fills (guide §5.4); omitted groups and empty ones collapse. */
@@ -70,6 +71,21 @@ interface ShellOptions {
70
71
  inspector?: InspectorOptions | undefined;
71
72
  /** The empty-file hint of IDE and embedded hosts (guide §13.5); omitted = no hint. */
72
73
  emptyHint?: EmptyHintOptions | undefined;
74
+ /** The primary action at the top right (guide §5.7); omitted = the top right stays empty. */
75
+ primary?: PrimaryActionOptions | undefined;
76
+ /**
77
+ * The legal line at the bottom left (guide §5.10), always rendered in the web host: copyright,
78
+ * Impressum and Datenschutz (`lang="de"`), then `links`.
79
+ */
80
+ legal?: LegalLineOptions | undefined;
81
+ /** The File group, first in the menu (guide §5.4); omitted = no File group. */
82
+ file?: FileMenuOptions | undefined;
83
+ /** The mode choice of a dark-capable modeler (guide §13.3); required when `themes` includes `"dark"`. */
84
+ appearance?: WebAppearanceOptions | undefined;
85
+ /** The start screen (guide §8 Empty State); omitted = none. Shown by `setEmptyState(true)`. */
86
+ emptyState?: EmptyStateOptions | undefined;
87
+ /** Files dropped anywhere on the page (guide §9 Drag-over, Drop forbidden); omitted = none. */
88
+ dropZone?: DropZoneOptions | undefined;
73
89
  }
74
90
  /** Rendered in this order, separated by separators: Model, Export, Help (guide §5.4). */
75
91
  interface MenuGroups {
@@ -113,6 +129,10 @@ interface MenuActionEntry extends MenuItemBase {
113
129
  */
114
130
  interface MenuDialogEntry extends MenuItemBase {
115
131
  kind: "dialog";
132
+ /** Shortcut chip text shown on the right, verbatim ("?" for "Keyboard shortcuts…"). */
133
+ shortcut?: string | undefined;
134
+ /** As for `MenuActionEntry`: default `ariaKeyShortcutsFromLabel(shortcut)`, `""` sets none. */
135
+ ariaKeyShortcuts?: string | undefined;
116
136
  onSelect(): void;
117
137
  }
118
138
  /** `menuitemcheckbox`: toggles and keeps the menu open; the check mark carries the state. */
@@ -139,8 +159,17 @@ interface MenuRadioOption {
139
159
  label: string;
140
160
  }
141
161
  interface ProblemsOptions {
142
- /** A click on the pill: the IDE host opens its Problems view. */
143
- onActivate(): void;
162
+ /**
163
+ * A click on the pill where the host has a problems view of its own: the IDE host opens its
164
+ * Problems view (give it there), an embedding host its own list. Ignored in the web host, where
165
+ * the pill opens the problems popover; an embedded shell without it opens the popover as well.
166
+ */
167
+ onActivate?: (() => void) | undefined;
168
+ /**
169
+ * A click on a row of the problems popover, after the popover closed (guide §5.10): select the
170
+ * element the item names, where there is one.
171
+ */
172
+ onSelectItem?: ((item: ProblemItem) => void) | undefined;
144
173
  }
145
174
  interface LegendOptions {
146
175
  /** Renders the legend rows into `body` once (classes `cd-shell-legend-*`, see API.md). */
@@ -177,6 +206,10 @@ interface ShellHandle {
177
206
  readonly tooltip: TooltipHandle;
178
207
  readonly legend: LegendHandle | undefined;
179
208
  readonly inspector: InspectorHandle | undefined;
209
+ /** The web app's primary action; `undefined` without `primary` and outside the web host. */
210
+ readonly primary: PrimaryActionHandle | undefined;
211
+ /** The web app's mode choice; `undefined` outside the web host and for a light-only modeler. */
212
+ readonly appearance: AppearanceHandle | undefined;
180
213
  /** Binds zoom panel, readout and chrome keys; `null` unbinds (buttons disabled). */
181
214
  setZoomTarget(target: ZoomTarget | null): void;
182
215
  /** The fit insets for what is open right now (palette row, legend, inspector, pill). */
@@ -207,6 +240,21 @@ interface ShellHandle {
207
240
  }): void;
208
241
  /** The lock, true from the first `setReadOnly(true)` on, also while its marks are still delayed. */
209
242
  isReadOnly(): boolean;
243
+ /**
244
+ * Shows or hides the web app's start screen (guide §8): while it shows, menu trigger, primary
245
+ * action, palette, zoom panel, pill, legend, status box, hint and inspector are hidden, the canvas
246
+ * slot is `inert` and the chrome keys do nothing; the legal line, toasts and the drop zone stay.
247
+ * A no-op without `emptyState`. Hiding it while it holds the focus moves the focus to the canvas.
248
+ */
249
+ setEmptyState(shown: boolean): void;
250
+ isEmptyStateShown(): boolean;
251
+ /**
252
+ * Shows a toast (guide §8, §9) in the web and embedded hosts: bottom centre, at most three, the
253
+ * newest at the bottom, closing by itself after `toastLifetime` unless hovered or focused. In the
254
+ * `ide` host it shows nothing and returns an inert handle: there the extension shows the host's
255
+ * notification (§13.5).
256
+ */
257
+ toast(request: ToastRequest): ToastHandle;
210
258
  /** Removes every element, attribute, listener, observer and timer the shell added. Idempotent. */
211
259
  destroy(): void;
212
260
  }
@@ -274,11 +322,124 @@ interface ProblemSummary {
274
322
  count: number;
275
323
  /** How many of them are errors; decides icon and wording. */
276
324
  errors: number;
325
+ /**
326
+ * The rows of the problems popover (web, embedded without `onActivate`), in this order; the IDE
327
+ * host ignores them. `problemSummary(items)` builds the whole summary from them.
328
+ */
329
+ items?: readonly ProblemItem[] | undefined;
277
330
  }
278
331
  type StatusSeverity = "danger" | "warning";
279
332
  interface StatusMessage {
280
333
  severity: StatusSeverity;
281
334
  text: string;
282
335
  }
336
+ /** The web app's primary action (guide §5.7): a blue primary button, icon and label, at the top right. */
337
+ interface PrimaryActionOptions {
338
+ /** Label and `aria-label`; default `messages.share` ("Share"). */
339
+ label?: string | undefined;
340
+ /** Default `"share-2"`. */
341
+ icon?: ShellIconName | undefined;
342
+ onSelect(): void;
343
+ /** Read on mount and on `primary.refresh()`; disabled stays focusable (`aria-disabled`). */
344
+ disabled?: (() => boolean) | undefined;
345
+ }
346
+ interface PrimaryActionHandle {
347
+ /** The `<button data-chrome="primary">`. */
348
+ readonly element: HTMLButtonElement;
349
+ /** True while the label is collapsed to the icon (guide §5.15); the root then carries `data-primary="collapsed"`. */
350
+ isCollapsed(): boolean;
351
+ /** Re-reads `disabled()`. */
352
+ refresh(): void;
353
+ }
354
+ /** A link of the legal line after Impressum and Datenschutz. */
355
+ interface LegalLink {
356
+ label: string;
357
+ href: string;
358
+ /** For a label in another language than the tool's. */
359
+ lang?: string | undefined;
360
+ }
361
+ interface LegalLineOptions {
362
+ /** After Impressum and Datenschutz: `{ label: "GitHub", href: "https://github.com/Miragon/…" }`. */
363
+ links?: readonly LegalLink[] | undefined;
364
+ /** The copyright year; default the current year at mount. */
365
+ year?: number | undefined;
366
+ }
367
+ /** One entry of the File group; label and icon come from the shell (guide §2, §5.4). */
368
+ interface FileMenuAction {
369
+ onSelect(): void;
370
+ /** Shortcut chip, e.g. "⌘O"; the web app binds the key itself. */
371
+ shortcut?: string | undefined;
372
+ /** `kind: "dialog"` (`aria-haspopup="dialog"`) when it opens an in-page dialog, not the browser's file picker. */
373
+ dialog?: boolean | undefined;
374
+ disabled?: (() => boolean) | undefined;
375
+ }
376
+ /**
377
+ * The File group of the web app (guide §5.4), in this order, as far as the modeler has them:
378
+ * "New diagram" (`file-plus`), "Open…" (`folder-open`), "Show example", "Import…" (`import`).
379
+ * Menu ids `new-diagram`, `open`, `show-example`, `import`, `data-menu-group="file"`.
380
+ */
381
+ interface FileMenuOptions {
382
+ newDiagram?: FileMenuAction | undefined;
383
+ open?: FileMenuAction | undefined;
384
+ showExample?: FileMenuAction | undefined;
385
+ import?: FileMenuAction | undefined;
386
+ }
387
+ /** What `localStorage` offers; a blocked storage throws, the shell catches it. */
388
+ interface StorageLike {
389
+ getItem(key: string): string | null;
390
+ setItem(key: string, value: string): void;
391
+ removeItem(key: string): void;
392
+ }
393
+ interface WebAppearanceOptions {
394
+ /** The two `theme-color` values from the vendored token JSON (see `ThemeColors`). */
395
+ themeColors: ThemeColors;
396
+ /** Default `globalThis.localStorage`. */
397
+ storage?: StorageLike | undefined;
398
+ }
399
+ /** The mode choice of a dark-capable web app (guide §13.3), as the Appearance group drives it. */
400
+ interface AppearanceHandle {
401
+ /** The stored choice, `"system"` without one. */
402
+ choice(): AppearanceChoice;
403
+ /**
404
+ * Stores the choice (`"system"` removes `APPEARANCE_STORAGE_KEY`) and applies `documentMode` on
405
+ * `<html>` and the metas in one step, with `cd-shell-no-transition` for one frame (guide §7).
406
+ */
407
+ setChoice(choice: AppearanceChoice): void;
408
+ }
409
+ /** The web app's start screen (guide §8): a centred glass card with the Komet and two actions. */
410
+ interface EmptyStateOptions {
411
+ /** The card's title (h1, 21px/600), the modeler's name: "Event Storming Modeler". */
412
+ title: string;
413
+ /** One line of help (16px/1.6, `--cd-ui-text-leise`): "Start a new diagram, or explore the example." */
414
+ text: string;
415
+ /**
416
+ * URL of the official Miragon icon `miragon-komet-blau.svg`, vendored unchanged from
417
+ * `Miragon/corporate-identity` (guide §2, §11), shown at 64px with `alt=""`.
418
+ */
419
+ komet: string;
420
+ /** "New diagram", the blue primary button. The shell hides the card first. */
421
+ onNewDiagram(): void;
422
+ /** "Show example", the ghost button; omitted = no example button. The shell hides the card first. */
423
+ onShowExample?: (() => void) | undefined;
424
+ /** The drag-and-drop hint (13px, `--cd-ui-text-leise`), shown with a `dropZone` only; default `messages.dropHint`. */
425
+ dropHint?: string | undefined;
426
+ }
427
+ interface DropZoneOptions {
428
+ /**
429
+ * Like `<input accept>`: extensions (".storm") and MIME types ("application/json", "text/*").
430
+ * List the MIME types too, so a drag can already show a foreign type as forbidden. Empty = any file.
431
+ */
432
+ accept: readonly string[];
433
+ /** Default `false`: a drag with more than one file is forbidden. */
434
+ multiple?: boolean | undefined;
435
+ /** The dropped files that match `accept` (one unless `multiple`). */
436
+ onDrop(files: readonly File[]): void;
437
+ /** The dropped files outside `accept`; default a danger toast `messages.cannotOpenFile`. */
438
+ onReject?: ((files: readonly File[]) => void) | undefined;
439
+ }
440
+ interface ToastHandle {
441
+ /** Closes the toast (slide and fade out); a second call does nothing. */
442
+ dismiss(): void;
443
+ }
283
444
 
284
- export { type EmptyHintOptions as E, ICONS as I, type LegendHandle as L, type MenuActionEntry as M, PALETTE_TOOL_ICON as P, type ShellOptions as S, type TooltipContent as T, type ShellHandle as a, type IconNode as b, type IconOptions as c, type InspectorHandle as d, type InspectorOptions as e, type LegendOptions as f, type MenuCheckboxEntry as g, type MenuDialogEntry as h, type MenuEntry as i, type MenuGroups as j, type MenuHandle as k, type MenuRadioGroup as l, type MenuRadioOption as m, type PaletteReadOnlyState as n, type PaletteRegistration as o, type ProblemSummary as p, type ProblemsOptions as q, type ShellIconName as r, type StatusMessage as s, type StatusSeverity as t, type TooltipHandle as u, iconElement as v, iconMarkup as w };
445
+ export { type AppearanceHandle as A, type StorageLike as B, type TooltipContent as C, type DropZoneOptions as D, type EmptyHintOptions as E, type FileMenuAction as F, type TooltipHandle as G, iconElement as H, ICONS as I, iconMarkup as J, type LegalLineOptions as L, type MenuActionEntry as M, PALETTE_TOOL_ICON as P, type ShellOptions as S, type ToastHandle as T, type WebAppearanceOptions as W, type ShellHandle as a, type EmptyStateOptions as b, type FileMenuOptions as c, type IconNode as d, type IconOptions as e, type InspectorHandle as f, type InspectorOptions as g, type LegalLink as h, type LegendHandle as i, type LegendOptions as j, type MenuCheckboxEntry as k, type MenuDialogEntry as l, type MenuEntry as m, type MenuGroups as n, type MenuHandle as o, type MenuRadioGroup as p, type MenuRadioOption as q, type PaletteReadOnlyState as r, type PaletteRegistration as s, type PrimaryActionHandle as t, type PrimaryActionOptions as u, type ProblemSummary as v, type ProblemsOptions as w, type ShellIconName as x, type StatusMessage as y, type StatusSeverity as z };
@@ -4,13 +4,13 @@ import {
4
4
  currentAppearance,
5
5
  renderWebviewHtml,
6
6
  revealFileLabel
7
- } from "./chunk-RJRFR6N3.js";
7
+ } from "./chunk-KYDG5DMX.js";
8
8
  import {
9
9
  APPEARANCE_MESSAGE_TYPE,
10
10
  appearanceMessage,
11
11
  isAppearanceMessage
12
12
  } from "./chunk-N4QXFF3A.js";
13
- import "./chunk-5JSZ4VGA.js";
13
+ import "./chunk-OADW3GPA.js";
14
14
  export {
15
15
  APPEARANCE_MESSAGE_TYPE,
16
16
  appearanceMessage,