@miragon/modeler-shell 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.
Files changed (126) hide show
  1. package/API.md +1902 -0
  2. package/LICENSE +21 -0
  3. package/README.md +435 -2
  4. package/THIRD_PARTY_NOTICES.md +52 -0
  5. package/dist/appearance-D3FUcbu6.d.cts +53 -0
  6. package/dist/appearance-D3FUcbu6.d.ts +53 -0
  7. package/dist/chunk-5JSZ4VGA.js +551 -0
  8. package/dist/chunk-5JSZ4VGA.js.map +1 -0
  9. package/dist/chunk-6LQOFACK.js +1576 -0
  10. package/dist/chunk-6LQOFACK.js.map +1 -0
  11. package/dist/chunk-N4QXFF3A.js +23 -0
  12. package/dist/chunk-N4QXFF3A.js.map +1 -0
  13. package/dist/chunk-RJRFR6N3.js +136 -0
  14. package/dist/chunk-RJRFR6N3.js.map +1 -0
  15. package/dist/core.cjs +619 -0
  16. package/dist/core.cjs.map +1 -0
  17. package/dist/core.d.cts +171 -0
  18. package/dist/core.d.ts +171 -0
  19. package/dist/core.js +91 -0
  20. package/dist/core.js.map +1 -0
  21. package/dist/diagram-js.cjs +1115 -0
  22. package/dist/diagram-js.cjs.map +1 -0
  23. package/dist/diagram-js.d.cts +163 -0
  24. package/dist/diagram-js.d.ts +163 -0
  25. package/dist/diagram-js.js +867 -0
  26. package/dist/diagram-js.js.map +1 -0
  27. package/dist/index.cjs +2175 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +20 -0
  30. package/dist/index.d.ts +20 -0
  31. package/dist/index.js +103 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/keymap-CObQE6q6.d.cts +151 -0
  34. package/dist/keymap-DORzHnK-.d.ts +151 -0
  35. package/dist/protocol-DhYBakWL.d.cts +15 -0
  36. package/dist/protocol-IeW8bf4f.d.ts +15 -0
  37. package/dist/shell.css +914 -0
  38. package/dist/testing-vscode-stub.cjs +332 -0
  39. package/dist/testing-vscode-stub.cjs.map +1 -0
  40. package/dist/testing-vscode-stub.d.cts +65 -0
  41. package/dist/testing-vscode-stub.d.ts +65 -0
  42. package/dist/testing-vscode-stub.js +154 -0
  43. package/dist/testing-vscode-stub.js.map +1 -0
  44. package/dist/testing.cjs +2364 -0
  45. package/dist/testing.cjs.map +1 -0
  46. package/dist/testing.d.cts +165 -0
  47. package/dist/testing.d.ts +165 -0
  48. package/dist/testing.js +2297 -0
  49. package/dist/testing.js.map +1 -0
  50. package/dist/types-B6NfkiUG.d.cts +66 -0
  51. package/dist/types-B6NfkiUG.d.ts +66 -0
  52. package/dist/types-DnZn9CPw.d.ts +284 -0
  53. package/dist/types-OuFlqZp0.d.cts +284 -0
  54. package/dist/vscode-extension.cjs +215 -0
  55. package/dist/vscode-extension.cjs.map +1 -0
  56. package/dist/vscode-extension.d.cts +103 -0
  57. package/dist/vscode-extension.d.ts +103 -0
  58. package/dist/vscode-extension.js +24 -0
  59. package/dist/vscode-extension.js.map +1 -0
  60. package/dist/vscode-webview.cjs +2198 -0
  61. package/dist/vscode-webview.cjs.map +1 -0
  62. package/dist/vscode-webview.d.cts +82 -0
  63. package/dist/vscode-webview.d.ts +82 -0
  64. package/dist/vscode-webview.js +250 -0
  65. package/dist/vscode-webview.js.map +1 -0
  66. package/package.json +145 -4
  67. package/src/core/appearance.ts +104 -0
  68. package/src/core/fit.ts +205 -0
  69. package/src/core/index.ts +84 -0
  70. package/src/core/keymap.ts +275 -0
  71. package/src/core/layout.ts +69 -0
  72. package/src/core/messages.ts +88 -0
  73. package/src/core/sizes.ts +85 -0
  74. package/src/core/types.ts +84 -0
  75. package/src/core/zoom.ts +74 -0
  76. package/src/core.ts +2 -0
  77. package/src/diagram-js/connect.ts +75 -0
  78. package/src/diagram-js/index.ts +16 -0
  79. package/src/diagram-js/module.ts +20 -0
  80. package/src/diagram-js/palette-skin.ts +267 -0
  81. package/src/diagram-js/palette.css +269 -0
  82. package/src/diagram-js/service.ts +240 -0
  83. package/src/diagram-js/types.ts +67 -0
  84. package/src/diagram-js/viewport.ts +564 -0
  85. package/src/diagram-js.ts +2 -0
  86. package/src/dom/element.ts +51 -0
  87. package/src/dom/hint.ts +51 -0
  88. package/src/dom/icons.ts +309 -0
  89. package/src/dom/index.ts +29 -0
  90. package/src/dom/inspector.ts +35 -0
  91. package/src/dom/keys.ts +59 -0
  92. package/src/dom/ledger.ts +87 -0
  93. package/src/dom/legend.ts +85 -0
  94. package/src/dom/menu.ts +393 -0
  95. package/src/dom/mount.ts +461 -0
  96. package/src/dom/problems.ts +72 -0
  97. package/src/dom/shell-dom.css +966 -0
  98. package/src/dom/status.ts +72 -0
  99. package/src/dom/tooltip.ts +237 -0
  100. package/src/dom/types.ts +277 -0
  101. package/src/dom/zoom-panel.ts +154 -0
  102. package/src/index.ts +3 -0
  103. package/src/shell.css +6 -0
  104. package/src/testing/cases.ts +1012 -0
  105. package/src/testing/checks.ts +832 -0
  106. package/src/testing/facts.ts +587 -0
  107. package/src/testing/geometry.ts +472 -0
  108. package/src/testing/harness.ts +138 -0
  109. package/src/testing/index.ts +15 -0
  110. package/src/testing/page-tools.ts +434 -0
  111. package/src/testing/page.ts +17 -0
  112. package/src/testing/vscode-stub.ts +237 -0
  113. package/src/testing-vscode-stub.ts +2 -0
  114. package/src/testing.ts +2 -0
  115. package/src/vscode/extension/html.ts +107 -0
  116. package/src/vscode/extension/index.ts +8 -0
  117. package/src/vscode/extension/reveal.ts +9 -0
  118. package/src/vscode/extension/theme-bridge.ts +85 -0
  119. package/src/vscode/extension/types.ts +36 -0
  120. package/src/vscode/protocol.ts +31 -0
  121. package/src/vscode/webview/appearance.ts +141 -0
  122. package/src/vscode/webview/index.ts +8 -0
  123. package/src/vscode/webview/mount.ts +76 -0
  124. package/src/vscode/webview/state.ts +116 -0
  125. package/src/vscode-extension.ts +2 -0
  126. package/src/vscode-webview.ts +2 -0
@@ -0,0 +1,66 @@
1
+ /** A point in pixels or diagram coordinates, as the context says. */
2
+ interface Point {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ interface Size {
7
+ width: number;
8
+ height: number;
9
+ }
10
+ /** A rectangle; content bounds and viewboxes are in diagram coordinates. */
11
+ interface Bounds {
12
+ x: number;
13
+ y: number;
14
+ width: number;
15
+ height: number;
16
+ }
17
+ /** A viewbox together with the scale diagram-js shows it at (`canvas.viewbox().scale`). */
18
+ interface ScaledViewbox extends Bounds {
19
+ scale: number;
20
+ }
21
+ /** Distances in pixels from the edges of the modeler's container. */
22
+ interface Insets {
23
+ top: number;
24
+ right: number;
25
+ bottom: number;
26
+ left: number;
27
+ }
28
+ /**
29
+ * The host column of guide §5.2: `ide` is a VS Code webview (later IntelliJ), `web` a Miragon web
30
+ * app that owns its page, `embedded` a modeler inside a foreign page (designIQ, modeler-api hosts).
31
+ */
32
+ type ShellHost = "ide" | "web" | "embedded";
33
+ /** The `data-chrome` names of the islands (guide §5.2, §13.4). `primary` is reserved for the web app. */
34
+ type ChromeIsland = "menu" | "palette" | "primary" | "zoom" | "problems" | "legend" | "inspector" | "status";
35
+ declare const CHROME_ISLANDS: readonly ChromeIsland[];
36
+ /** Where the palette sits: in the top row, or in the second row below it (guide §5.15). */
37
+ type PaletteRow = "top" | "second-row";
38
+ /**
39
+ * What the zoom panel and the chrome keys act on. The diagram-js viewport implements it; the DOM
40
+ * shell only talks to this interface.
41
+ */
42
+ interface ZoomTarget {
43
+ /** The current zoom, 1 = 100 % (diagram-js `canvas.zoom()`, rounded to three decimals). */
44
+ zoom(): number;
45
+ /** One step on the zoom raster around the container centre (diagram-js `zoomScroll.stepZoom`). */
46
+ stepZoom(direction: 1 | -1): void;
47
+ /** 100 % around the container centre. Counts as a user move. */
48
+ zoomToActual(): void;
49
+ /** Explicit fit (button, Shift+1, command): animated unless reduced motion, makes the view automatic. */
50
+ fit(): void;
51
+ /** False while there is nothing to fit (the content bounds are empty). */
52
+ canFit(): boolean;
53
+ /**
54
+ * Calls `listener` after every viewbox change and whenever `canFit()` may have changed, possibly
55
+ * several times per frame. Returns the unsubscribe function.
56
+ */
57
+ onChange(listener: () => void): () => void;
58
+ }
59
+ /** The persisted view (VS Code `setState`): JSON-serializable. */
60
+ interface ViewportState {
61
+ viewbox: Bounds;
62
+ /** The user zoomed or panned since the last fit; a resize no longer refits. */
63
+ userMoved: boolean;
64
+ }
65
+
66
+ export { type Bounds as B, CHROME_ISLANDS as C, type Insets as I, type PaletteRow as P, type ScaledViewbox as S, type ViewportState as V, type ZoomTarget as Z, type ChromeIsland as a, type Point as b, type ShellHost as c, type Size as d };
@@ -0,0 +1,284 @@
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';
3
+ import { T as Theme } from './appearance-D3FUcbu6.js';
4
+
5
+ /*! @miragon/modeler-shell icon geometry
6
+ * Lucide (lucide-static 1.59.0) @license ISC
7
+ * Copyright (c) 2026 Lucide Icons and Contributors
8
+ * Derived from Feather, as Lucide's LICENSE lists them: check, circle-x (x-circle), maximize,
9
+ * minus, plus, triangle-alert (alert-triangle) and x. Feather @license MIT
10
+ * Copyright (c) 2013-present Cole Bemis
11
+ * Full notices: THIRD_PARTY_NOTICES.md of @miragon/modeler-shell */
12
+ /** One Lucide icon: its SVG child elements on the 24 × 24 grid. */
13
+ type IconNode = ReadonlyArray<readonly [tag: string, attributes: Readonly<Record<string, string>>]>;
14
+ type ShellIconName = "menu" | "minus" | "plus" | "maximize" | "check" | "x" | "file-plus" | "folder-open" | "import" | "file-image" | "file-code-corner" | "keyboard" | "share-2" | "circle-x" | "triangle-alert" | "square-dashed-mouse-pointer" | "hand" | "line-segment" | "unfold-horizontal" | "workflow";
15
+ declare const ICONS: Readonly<Record<ShellIconName, IconNode>>;
16
+ interface IconOptions {
17
+ /** Rendered width and height in px; default 16 (chrome). */
18
+ size?: number;
19
+ /** Stroke width on the 24 grid; default 2.5. */
20
+ strokeWidth?: number;
21
+ className?: string;
22
+ }
23
+ /** Palette tool icons: 20px with stroke 2 (guide §5.5), as heavy as the 16px chrome icons. */
24
+ declare const PALETTE_TOOL_ICON: Readonly<IconOptions>;
25
+ /**
26
+ * Decorative inline SVG markup (`aria-hidden="true"`, `focusable="false"`, `fill="none"`,
27
+ * `stroke="currentColor"`, round caps and joins). Only Lucide's elements and geometry attributes
28
+ * pass, so the result is safe for `innerHTML` (palette entry `html`).
29
+ */
30
+ declare function iconMarkup(icon: ShellIconName | IconNode, options?: IconOptions): string;
31
+ /** The same icon as an `SVGSVGElement`. */
32
+ declare function iconElement(icon: ShellIconName | IconNode, options?: IconOptions): SVGSVGElement;
33
+
34
+ interface ShellOptions {
35
+ /** The host column of guide §5.2. */
36
+ host: ShellHost;
37
+ /**
38
+ * The element diagram-js renders into (for example a renderer's `modeler.container`). The shell
39
+ * moves it into its canvas slot and adds `cd-shell-canvas`. Omitted: the shell creates the slot,
40
+ * and the modeler is constructed with `container: handle.canvas`.
41
+ */
42
+ canvas?: HTMLElement | undefined;
43
+ /**
44
+ * The tool's UI language (BCP 47) for `Intl` and `<html lang>` (guide §2: one language per tool).
45
+ * Default in an own document (`ide`, `web`): the closest `[lang]` of the root, else `"en"`. In the
46
+ * `embedded` host the page's language is not the tool's, so the default is the root's own `lang`
47
+ * attribute, else `"en"`, and the root carries `lang` itself.
48
+ */
49
+ lang?: string | undefined;
50
+ messages?: ShellMessageOverrides | undefined;
51
+ /** Platform of the shortcut labels; default `detectPlatform(navigator)`. */
52
+ platform?: Platform | undefined;
53
+ /** Where the one `keydown` listener sits; default `document`, `root` in the `embedded` host. */
54
+ keyScope?: "document" | "root" | undefined;
55
+ /**
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>`.
61
+ */
62
+ themes?: readonly Theme[] | undefined;
63
+ /** The fixed menu groups this modeler fills (guide §5.4); omitted groups and empty ones collapse. */
64
+ menu?: MenuGroups | undefined;
65
+ /** The problems pill; omitted = the modeler has no diagnostics. */
66
+ problems?: ProblemsOptions | undefined;
67
+ /** The legend card; omitted = the notation has no legend. */
68
+ legend?: LegendOptions | undefined;
69
+ /** The inspector slot; omitted = the modeler has no inspector. */
70
+ inspector?: InspectorOptions | undefined;
71
+ /** The empty-file hint of IDE and embedded hosts (guide §13.5); omitted = no hint. */
72
+ emptyHint?: EmptyHintOptions | undefined;
73
+ }
74
+ /** Rendered in this order, separated by separators: Model, Export, Help (guide §5.4). */
75
+ interface MenuGroups {
76
+ model?: readonly MenuEntry[] | undefined;
77
+ export?: readonly MenuEntry[] | undefined;
78
+ help?: readonly MenuEntry[] | undefined;
79
+ }
80
+ type MenuEntry = MenuActionEntry | MenuDialogEntry | MenuCheckboxEntry | MenuRadioGroup;
81
+ interface MenuItemBase {
82
+ /** Stable id, rendered as `data-menu-id`. */
83
+ id: string;
84
+ label: string;
85
+ /** Only the entries the guide gives an icon (the common set, guide §5.14). */
86
+ icon?: ShellIconName | undefined;
87
+ /** Read whenever the menu opens or `refresh()` runs; disabled entries stay focusable. */
88
+ disabled?: (() => boolean) | undefined;
89
+ /**
90
+ * A Model entry that stays enabled on a read-only canvas: a view-only toggle that never touches
91
+ * the document (Legend, Type captions). Default `false`: the entry is aria-disabled while the
92
+ * canvas is read-only (guide §13.5). The shell's own Legend checkbox sets it.
93
+ */
94
+ keepEnabledWhenReadOnly?: boolean | undefined;
95
+ }
96
+ /** `menuitem`: closes the menu, returns focus to the trigger, then runs `onSelect`. */
97
+ interface MenuActionEntry extends MenuItemBase {
98
+ kind: "action";
99
+ /** Shortcut chip text shown on the right, verbatim. */
100
+ shortcut?: string | undefined;
101
+ /**
102
+ * `aria-keyshortcuts` (WAI-ARIA names, guide §5.6); default `ariaKeyShortcutsFromLabel(shortcut)`.
103
+ * An empty string sets none.
104
+ */
105
+ ariaKeyShortcuts?: string | undefined;
106
+ /** Destructive: icon in `--cd-ui-danger` (confirm per guide §9 in `onSelect`). */
107
+ danger?: boolean | undefined;
108
+ onSelect(): void;
109
+ }
110
+ /**
111
+ * `menuitem` with `aria-haspopup="dialog"`; its label ends with "…" (U+2026). Behaves like an
112
+ * action: the menu closes and focus returns to the trigger before `onSelect` opens the dialog.
113
+ */
114
+ interface MenuDialogEntry extends MenuItemBase {
115
+ kind: "dialog";
116
+ onSelect(): void;
117
+ }
118
+ /** `menuitemcheckbox`: toggles and keeps the menu open; the check mark carries the state. */
119
+ interface MenuCheckboxEntry extends MenuItemBase {
120
+ kind: "checkbox";
121
+ checked(): boolean;
122
+ onToggle(checked: boolean): void;
123
+ }
124
+ /** A `role="group"` with a heading and `menuitemradio` entries; keeps the menu open. */
125
+ interface MenuRadioGroup {
126
+ kind: "radio";
127
+ id: string;
128
+ /** Heading and group `aria-label`. */
129
+ label: string;
130
+ options: readonly MenuRadioOption[];
131
+ value(): string | undefined;
132
+ onSelect(value: string): void;
133
+ disabled?: (() => boolean) | undefined;
134
+ /** As `MenuItemBase.keepEnabledWhenReadOnly`. */
135
+ keepEnabledWhenReadOnly?: boolean | undefined;
136
+ }
137
+ interface MenuRadioOption {
138
+ value: string;
139
+ label: string;
140
+ }
141
+ interface ProblemsOptions {
142
+ /** A click on the pill: the IDE host opens its Problems view. */
143
+ onActivate(): void;
144
+ }
145
+ interface LegendOptions {
146
+ /** Renders the legend rows into `body` once (classes `cd-shell-legend-*`, see API.md). */
147
+ render(body: HTMLElement): void;
148
+ /** Start state the host remembered; default (also `undefined`) `legendStartsOpen(container height)`. */
149
+ open?: boolean | undefined;
150
+ /**
151
+ * Every change of the open state (close button, menu checkbox, `setOpen`, `toggle`), so the host
152
+ * can persist it; not the automatic start decision.
153
+ */
154
+ onToggle?: ((open: boolean) => void) | undefined;
155
+ /** Append the "Legend" checkbox to the Model group; default `true`. */
156
+ menuEntry?: boolean | undefined;
157
+ }
158
+ interface InspectorOptions {
159
+ /** `aria-label` of the inspector `<aside>`. */
160
+ label: string;
161
+ }
162
+ interface EmptyHintOptions {
163
+ /** Shows the "Insert example" button; the modeler writes the example as one document change. */
164
+ onInsertExample?: (() => void) | undefined;
165
+ }
166
+ interface ShellHandle {
167
+ /** The element passed to `mountShell`, now `.cd-shell`. */
168
+ readonly root: HTMLElement;
169
+ /** The canvas slot (`.cd-shell-canvas`), diagram-js's container. */
170
+ readonly canvas: HTMLElement;
171
+ readonly host: ShellHost;
172
+ readonly lang: string;
173
+ readonly platform: Platform;
174
+ /** The resolved messages table. */
175
+ readonly messages: ShellMessages;
176
+ readonly menu: MenuHandle;
177
+ readonly tooltip: TooltipHandle;
178
+ readonly legend: LegendHandle | undefined;
179
+ readonly inspector: InspectorHandle | undefined;
180
+ /** Binds zoom panel, readout and chrome keys; `null` unbinds (buttons disabled). */
181
+ setZoomTarget(target: ZoomTarget | null): void;
182
+ /** The fit insets for what is open right now (palette row, legend, inspector, pill). */
183
+ fitInsets(): Insets;
184
+ /** Adapter API: the diagram-js palette island; returns the unregister function. */
185
+ registerPalette(palette: PaletteRegistration): () => void;
186
+ /** Shows the pill for `count > 0`, hides it at 0. */
187
+ setProblems(summary: ProblemSummary): void;
188
+ /** Shows (after `delayMs`, default 0) or hides (at once) the status box under the palette. */
189
+ setStatus(status: StatusMessage | null, options?: {
190
+ delayMs?: number | undefined;
191
+ }): void;
192
+ /**
193
+ * Shows or hides the empty-file hint. `connectDiagramJs` keeps it in sync with the diagram
194
+ * (`ConnectOptions.isEmpty`). Hiding it while it holds the focus moves the focus to the canvas.
195
+ */
196
+ setEmptyHint(visible: boolean): void;
197
+ /**
198
+ * Read-only canvas (invalid file, guide §13.5). `true` locks at once: `isReadOnly()`, the palette
199
+ * veto (every entry but Lasso and Hand) and the Model entries of the menu without
200
+ * `keepEnabledWhenReadOnly`; the legend and its Legend checkbox stay usable. `data-readonly` and the
201
+ * `aria-disabled` palette entries show after `delayMs` (default 0; an invalid file passes
202
+ * `INVALID_STATUS_DELAY_MS`, as for `setStatus`), so typing in the text editor does not flicker.
203
+ * Repeated calls while the delay runs keep the first timer; `false` unlocks and hides at once.
204
+ */
205
+ setReadOnly(readOnly: boolean, options?: {
206
+ delayMs?: number | undefined;
207
+ }): void;
208
+ /** The lock, true from the first `setReadOnly(true)` on, also while its marks are still delayed. */
209
+ isReadOnly(): boolean;
210
+ /** Removes every element, attribute, listener, observer and timer the shell added. Idempotent. */
211
+ destroy(): void;
212
+ }
213
+ interface MenuHandle {
214
+ readonly trigger: HTMLButtonElement;
215
+ readonly dropdown: HTMLElement;
216
+ isOpen(): boolean;
217
+ /** Opens on the first (default) or last entry. */
218
+ open(focus?: "first" | "last"): void;
219
+ /** Closes; `restoreFocus` moves focus back to the trigger (default `false`). */
220
+ close(options?: {
221
+ restoreFocus?: boolean | undefined;
222
+ }): void;
223
+ /** Re-reads `checked`, `value` and `disabled` (call after an external state change). */
224
+ refresh(): void;
225
+ setGroups(groups: MenuGroups): void;
226
+ }
227
+ interface TooltipContent {
228
+ label: string;
229
+ /** Shortcut chip text, verbatim (`⌘+`). */
230
+ shortcut?: string | undefined;
231
+ }
232
+ interface TooltipHandle {
233
+ /**
234
+ * The chrome tooltip for `control`: after `TOOLTIP_DELAY_MS` hover, at once on keyboard focus,
235
+ * hidden on click, Escape, leave and menu open. Returns the detach function.
236
+ */
237
+ attach(control: HTMLElement, content: TooltipContent | (() => TooltipContent | null)): () => void;
238
+ hide(): void;
239
+ }
240
+ interface LegendHandle {
241
+ /** The legend card (`[data-chrome="legend"]`). */
242
+ readonly element: HTMLElement;
243
+ /** Where `render` put the rows. */
244
+ readonly body: HTMLElement;
245
+ isOpen(): boolean;
246
+ setOpen(open: boolean): void;
247
+ toggle(): void;
248
+ }
249
+ interface InspectorHandle {
250
+ /** The `<aside data-chrome="inspector">`; the modeler renders its fields into it. */
251
+ readonly element: HTMLElement;
252
+ isOpen(): boolean;
253
+ open(): void;
254
+ /** Closes; a focus inside it moves to the canvas. */
255
+ close(): void;
256
+ }
257
+ /** What the diagram-js adapter hands the shell about the palette. */
258
+ interface PaletteRegistration {
259
+ /** The `.djs-palette` element (already carrying `data-chrome="palette"`). */
260
+ element: HTMLElement;
261
+ /** Tooltip of an entry element (`.entry`), from `palette.getEntries()` title and shortcut. */
262
+ entryTooltip(entry: HTMLElement): TooltipContent | null;
263
+ /** The read-only state, on registration and on every `setReadOnly` and its delayed marks. */
264
+ setReadOnly(state: PaletteReadOnlyState): void;
265
+ }
266
+ /** The read-only canvas as the palette sees it (guide §13.5). */
267
+ interface PaletteReadOnlyState {
268
+ /** Veto every entry but Lasso and Hand on `palette.trigger`, from the invalid import on. */
269
+ locked: boolean;
270
+ /** Mark those entries `aria-disabled` and muted, once the shell's delay has passed. */
271
+ shown: boolean;
272
+ }
273
+ interface ProblemSummary {
274
+ count: number;
275
+ /** How many of them are errors; decides icon and wording. */
276
+ errors: number;
277
+ }
278
+ type StatusSeverity = "danger" | "warning";
279
+ interface StatusMessage {
280
+ severity: StatusSeverity;
281
+ text: string;
282
+ }
283
+
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 };
@@ -0,0 +1,284 @@
1
+ import { c as ShellHost, Z as ZoomTarget, I as Insets } from './types-B6NfkiUG.cjs';
2
+ import { P as Platform, d as ShellMessages, S as ShellMessageOverrides } from './keymap-CObQE6q6.cjs';
3
+ import { T as Theme } from './appearance-D3FUcbu6.cjs';
4
+
5
+ /*! @miragon/modeler-shell icon geometry
6
+ * Lucide (lucide-static 1.59.0) @license ISC
7
+ * Copyright (c) 2026 Lucide Icons and Contributors
8
+ * Derived from Feather, as Lucide's LICENSE lists them: check, circle-x (x-circle), maximize,
9
+ * minus, plus, triangle-alert (alert-triangle) and x. Feather @license MIT
10
+ * Copyright (c) 2013-present Cole Bemis
11
+ * Full notices: THIRD_PARTY_NOTICES.md of @miragon/modeler-shell */
12
+ /** One Lucide icon: its SVG child elements on the 24 × 24 grid. */
13
+ type IconNode = ReadonlyArray<readonly [tag: string, attributes: Readonly<Record<string, string>>]>;
14
+ type ShellIconName = "menu" | "minus" | "plus" | "maximize" | "check" | "x" | "file-plus" | "folder-open" | "import" | "file-image" | "file-code-corner" | "keyboard" | "share-2" | "circle-x" | "triangle-alert" | "square-dashed-mouse-pointer" | "hand" | "line-segment" | "unfold-horizontal" | "workflow";
15
+ declare const ICONS: Readonly<Record<ShellIconName, IconNode>>;
16
+ interface IconOptions {
17
+ /** Rendered width and height in px; default 16 (chrome). */
18
+ size?: number;
19
+ /** Stroke width on the 24 grid; default 2.5. */
20
+ strokeWidth?: number;
21
+ className?: string;
22
+ }
23
+ /** Palette tool icons: 20px with stroke 2 (guide §5.5), as heavy as the 16px chrome icons. */
24
+ declare const PALETTE_TOOL_ICON: Readonly<IconOptions>;
25
+ /**
26
+ * Decorative inline SVG markup (`aria-hidden="true"`, `focusable="false"`, `fill="none"`,
27
+ * `stroke="currentColor"`, round caps and joins). Only Lucide's elements and geometry attributes
28
+ * pass, so the result is safe for `innerHTML` (palette entry `html`).
29
+ */
30
+ declare function iconMarkup(icon: ShellIconName | IconNode, options?: IconOptions): string;
31
+ /** The same icon as an `SVGSVGElement`. */
32
+ declare function iconElement(icon: ShellIconName | IconNode, options?: IconOptions): SVGSVGElement;
33
+
34
+ interface ShellOptions {
35
+ /** The host column of guide §5.2. */
36
+ host: ShellHost;
37
+ /**
38
+ * The element diagram-js renders into (for example a renderer's `modeler.container`). The shell
39
+ * moves it into its canvas slot and adds `cd-shell-canvas`. Omitted: the shell creates the slot,
40
+ * and the modeler is constructed with `container: handle.canvas`.
41
+ */
42
+ canvas?: HTMLElement | undefined;
43
+ /**
44
+ * The tool's UI language (BCP 47) for `Intl` and `<html lang>` (guide §2: one language per tool).
45
+ * Default in an own document (`ide`, `web`): the closest `[lang]` of the root, else `"en"`. In the
46
+ * `embedded` host the page's language is not the tool's, so the default is the root's own `lang`
47
+ * attribute, else `"en"`, and the root carries `lang` itself.
48
+ */
49
+ lang?: string | undefined;
50
+ messages?: ShellMessageOverrides | undefined;
51
+ /** Platform of the shortcut labels; default `detectPlatform(navigator)`. */
52
+ platform?: Platform | undefined;
53
+ /** Where the one `keydown` listener sits; default `document`, `root` in the `embedded` host. */
54
+ keyScope?: "document" | "root" | undefined;
55
+ /**
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>`.
61
+ */
62
+ themes?: readonly Theme[] | undefined;
63
+ /** The fixed menu groups this modeler fills (guide §5.4); omitted groups and empty ones collapse. */
64
+ menu?: MenuGroups | undefined;
65
+ /** The problems pill; omitted = the modeler has no diagnostics. */
66
+ problems?: ProblemsOptions | undefined;
67
+ /** The legend card; omitted = the notation has no legend. */
68
+ legend?: LegendOptions | undefined;
69
+ /** The inspector slot; omitted = the modeler has no inspector. */
70
+ inspector?: InspectorOptions | undefined;
71
+ /** The empty-file hint of IDE and embedded hosts (guide §13.5); omitted = no hint. */
72
+ emptyHint?: EmptyHintOptions | undefined;
73
+ }
74
+ /** Rendered in this order, separated by separators: Model, Export, Help (guide §5.4). */
75
+ interface MenuGroups {
76
+ model?: readonly MenuEntry[] | undefined;
77
+ export?: readonly MenuEntry[] | undefined;
78
+ help?: readonly MenuEntry[] | undefined;
79
+ }
80
+ type MenuEntry = MenuActionEntry | MenuDialogEntry | MenuCheckboxEntry | MenuRadioGroup;
81
+ interface MenuItemBase {
82
+ /** Stable id, rendered as `data-menu-id`. */
83
+ id: string;
84
+ label: string;
85
+ /** Only the entries the guide gives an icon (the common set, guide §5.14). */
86
+ icon?: ShellIconName | undefined;
87
+ /** Read whenever the menu opens or `refresh()` runs; disabled entries stay focusable. */
88
+ disabled?: (() => boolean) | undefined;
89
+ /**
90
+ * A Model entry that stays enabled on a read-only canvas: a view-only toggle that never touches
91
+ * the document (Legend, Type captions). Default `false`: the entry is aria-disabled while the
92
+ * canvas is read-only (guide §13.5). The shell's own Legend checkbox sets it.
93
+ */
94
+ keepEnabledWhenReadOnly?: boolean | undefined;
95
+ }
96
+ /** `menuitem`: closes the menu, returns focus to the trigger, then runs `onSelect`. */
97
+ interface MenuActionEntry extends MenuItemBase {
98
+ kind: "action";
99
+ /** Shortcut chip text shown on the right, verbatim. */
100
+ shortcut?: string | undefined;
101
+ /**
102
+ * `aria-keyshortcuts` (WAI-ARIA names, guide §5.6); default `ariaKeyShortcutsFromLabel(shortcut)`.
103
+ * An empty string sets none.
104
+ */
105
+ ariaKeyShortcuts?: string | undefined;
106
+ /** Destructive: icon in `--cd-ui-danger` (confirm per guide §9 in `onSelect`). */
107
+ danger?: boolean | undefined;
108
+ onSelect(): void;
109
+ }
110
+ /**
111
+ * `menuitem` with `aria-haspopup="dialog"`; its label ends with "…" (U+2026). Behaves like an
112
+ * action: the menu closes and focus returns to the trigger before `onSelect` opens the dialog.
113
+ */
114
+ interface MenuDialogEntry extends MenuItemBase {
115
+ kind: "dialog";
116
+ onSelect(): void;
117
+ }
118
+ /** `menuitemcheckbox`: toggles and keeps the menu open; the check mark carries the state. */
119
+ interface MenuCheckboxEntry extends MenuItemBase {
120
+ kind: "checkbox";
121
+ checked(): boolean;
122
+ onToggle(checked: boolean): void;
123
+ }
124
+ /** A `role="group"` with a heading and `menuitemradio` entries; keeps the menu open. */
125
+ interface MenuRadioGroup {
126
+ kind: "radio";
127
+ id: string;
128
+ /** Heading and group `aria-label`. */
129
+ label: string;
130
+ options: readonly MenuRadioOption[];
131
+ value(): string | undefined;
132
+ onSelect(value: string): void;
133
+ disabled?: (() => boolean) | undefined;
134
+ /** As `MenuItemBase.keepEnabledWhenReadOnly`. */
135
+ keepEnabledWhenReadOnly?: boolean | undefined;
136
+ }
137
+ interface MenuRadioOption {
138
+ value: string;
139
+ label: string;
140
+ }
141
+ interface ProblemsOptions {
142
+ /** A click on the pill: the IDE host opens its Problems view. */
143
+ onActivate(): void;
144
+ }
145
+ interface LegendOptions {
146
+ /** Renders the legend rows into `body` once (classes `cd-shell-legend-*`, see API.md). */
147
+ render(body: HTMLElement): void;
148
+ /** Start state the host remembered; default (also `undefined`) `legendStartsOpen(container height)`. */
149
+ open?: boolean | undefined;
150
+ /**
151
+ * Every change of the open state (close button, menu checkbox, `setOpen`, `toggle`), so the host
152
+ * can persist it; not the automatic start decision.
153
+ */
154
+ onToggle?: ((open: boolean) => void) | undefined;
155
+ /** Append the "Legend" checkbox to the Model group; default `true`. */
156
+ menuEntry?: boolean | undefined;
157
+ }
158
+ interface InspectorOptions {
159
+ /** `aria-label` of the inspector `<aside>`. */
160
+ label: string;
161
+ }
162
+ interface EmptyHintOptions {
163
+ /** Shows the "Insert example" button; the modeler writes the example as one document change. */
164
+ onInsertExample?: (() => void) | undefined;
165
+ }
166
+ interface ShellHandle {
167
+ /** The element passed to `mountShell`, now `.cd-shell`. */
168
+ readonly root: HTMLElement;
169
+ /** The canvas slot (`.cd-shell-canvas`), diagram-js's container. */
170
+ readonly canvas: HTMLElement;
171
+ readonly host: ShellHost;
172
+ readonly lang: string;
173
+ readonly platform: Platform;
174
+ /** The resolved messages table. */
175
+ readonly messages: ShellMessages;
176
+ readonly menu: MenuHandle;
177
+ readonly tooltip: TooltipHandle;
178
+ readonly legend: LegendHandle | undefined;
179
+ readonly inspector: InspectorHandle | undefined;
180
+ /** Binds zoom panel, readout and chrome keys; `null` unbinds (buttons disabled). */
181
+ setZoomTarget(target: ZoomTarget | null): void;
182
+ /** The fit insets for what is open right now (palette row, legend, inspector, pill). */
183
+ fitInsets(): Insets;
184
+ /** Adapter API: the diagram-js palette island; returns the unregister function. */
185
+ registerPalette(palette: PaletteRegistration): () => void;
186
+ /** Shows the pill for `count > 0`, hides it at 0. */
187
+ setProblems(summary: ProblemSummary): void;
188
+ /** Shows (after `delayMs`, default 0) or hides (at once) the status box under the palette. */
189
+ setStatus(status: StatusMessage | null, options?: {
190
+ delayMs?: number | undefined;
191
+ }): void;
192
+ /**
193
+ * Shows or hides the empty-file hint. `connectDiagramJs` keeps it in sync with the diagram
194
+ * (`ConnectOptions.isEmpty`). Hiding it while it holds the focus moves the focus to the canvas.
195
+ */
196
+ setEmptyHint(visible: boolean): void;
197
+ /**
198
+ * Read-only canvas (invalid file, guide §13.5). `true` locks at once: `isReadOnly()`, the palette
199
+ * veto (every entry but Lasso and Hand) and the Model entries of the menu without
200
+ * `keepEnabledWhenReadOnly`; the legend and its Legend checkbox stay usable. `data-readonly` and the
201
+ * `aria-disabled` palette entries show after `delayMs` (default 0; an invalid file passes
202
+ * `INVALID_STATUS_DELAY_MS`, as for `setStatus`), so typing in the text editor does not flicker.
203
+ * Repeated calls while the delay runs keep the first timer; `false` unlocks and hides at once.
204
+ */
205
+ setReadOnly(readOnly: boolean, options?: {
206
+ delayMs?: number | undefined;
207
+ }): void;
208
+ /** The lock, true from the first `setReadOnly(true)` on, also while its marks are still delayed. */
209
+ isReadOnly(): boolean;
210
+ /** Removes every element, attribute, listener, observer and timer the shell added. Idempotent. */
211
+ destroy(): void;
212
+ }
213
+ interface MenuHandle {
214
+ readonly trigger: HTMLButtonElement;
215
+ readonly dropdown: HTMLElement;
216
+ isOpen(): boolean;
217
+ /** Opens on the first (default) or last entry. */
218
+ open(focus?: "first" | "last"): void;
219
+ /** Closes; `restoreFocus` moves focus back to the trigger (default `false`). */
220
+ close(options?: {
221
+ restoreFocus?: boolean | undefined;
222
+ }): void;
223
+ /** Re-reads `checked`, `value` and `disabled` (call after an external state change). */
224
+ refresh(): void;
225
+ setGroups(groups: MenuGroups): void;
226
+ }
227
+ interface TooltipContent {
228
+ label: string;
229
+ /** Shortcut chip text, verbatim (`⌘+`). */
230
+ shortcut?: string | undefined;
231
+ }
232
+ interface TooltipHandle {
233
+ /**
234
+ * The chrome tooltip for `control`: after `TOOLTIP_DELAY_MS` hover, at once on keyboard focus,
235
+ * hidden on click, Escape, leave and menu open. Returns the detach function.
236
+ */
237
+ attach(control: HTMLElement, content: TooltipContent | (() => TooltipContent | null)): () => void;
238
+ hide(): void;
239
+ }
240
+ interface LegendHandle {
241
+ /** The legend card (`[data-chrome="legend"]`). */
242
+ readonly element: HTMLElement;
243
+ /** Where `render` put the rows. */
244
+ readonly body: HTMLElement;
245
+ isOpen(): boolean;
246
+ setOpen(open: boolean): void;
247
+ toggle(): void;
248
+ }
249
+ interface InspectorHandle {
250
+ /** The `<aside data-chrome="inspector">`; the modeler renders its fields into it. */
251
+ readonly element: HTMLElement;
252
+ isOpen(): boolean;
253
+ open(): void;
254
+ /** Closes; a focus inside it moves to the canvas. */
255
+ close(): void;
256
+ }
257
+ /** What the diagram-js adapter hands the shell about the palette. */
258
+ interface PaletteRegistration {
259
+ /** The `.djs-palette` element (already carrying `data-chrome="palette"`). */
260
+ element: HTMLElement;
261
+ /** Tooltip of an entry element (`.entry`), from `palette.getEntries()` title and shortcut. */
262
+ entryTooltip(entry: HTMLElement): TooltipContent | null;
263
+ /** The read-only state, on registration and on every `setReadOnly` and its delayed marks. */
264
+ setReadOnly(state: PaletteReadOnlyState): void;
265
+ }
266
+ /** The read-only canvas as the palette sees it (guide §13.5). */
267
+ interface PaletteReadOnlyState {
268
+ /** Veto every entry but Lasso and Hand on `palette.trigger`, from the invalid import on. */
269
+ locked: boolean;
270
+ /** Mark those entries `aria-disabled` and muted, once the shell's delay has passed. */
271
+ shown: boolean;
272
+ }
273
+ interface ProblemSummary {
274
+ count: number;
275
+ /** How many of them are errors; decides icon and wording. */
276
+ errors: number;
277
+ }
278
+ type StatusSeverity = "danger" | "warning";
279
+ interface StatusMessage {
280
+ severity: StatusSeverity;
281
+ text: string;
282
+ }
283
+
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 };