@miragon/modeler-shell 0.0.0-stage → 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 (147) hide show
  1. package/API.md +2869 -0
  2. package/LICENSE +21 -0
  3. package/README.md +566 -2
  4. package/THIRD_PARTY_NOTICES.md +52 -0
  5. package/dist/appearance-BBaM_4bD.d.ts +323 -0
  6. package/dist/appearance-D3FUcbu6.d.cts +53 -0
  7. package/dist/appearance-D3FUcbu6.d.ts +53 -0
  8. package/dist/appearance-XX3JC3pI.d.cts +323 -0
  9. package/dist/chunk-66HCSJNY.js +2792 -0
  10. package/dist/chunk-66HCSJNY.js.map +1 -0
  11. package/dist/chunk-KYDG5DMX.js +136 -0
  12. package/dist/chunk-KYDG5DMX.js.map +1 -0
  13. package/dist/chunk-N4QXFF3A.js +23 -0
  14. package/dist/chunk-N4QXFF3A.js.map +1 -0
  15. package/dist/chunk-OADW3GPA.js +785 -0
  16. package/dist/chunk-OADW3GPA.js.map +1 -0
  17. package/dist/core.cjs +873 -0
  18. package/dist/core.cjs.map +1 -0
  19. package/dist/core.d.cts +246 -0
  20. package/dist/core.d.ts +246 -0
  21. package/dist/core.js +131 -0
  22. package/dist/core.js.map +1 -0
  23. package/dist/diagram-js.cjs +1147 -0
  24. package/dist/diagram-js.cjs.map +1 -0
  25. package/dist/diagram-js.d.cts +170 -0
  26. package/dist/diagram-js.d.ts +170 -0
  27. package/dist/diagram-js.js +879 -0
  28. package/dist/diagram-js.js.map +1 -0
  29. package/dist/index.cjs +3632 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.d.cts +29 -0
  32. package/dist/index.d.ts +29 -0
  33. package/dist/index.js +143 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/protocol-DhYBakWL.d.cts +15 -0
  36. package/dist/protocol-IeW8bf4f.d.ts +15 -0
  37. package/dist/shell.css +1603 -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 +4663 -0
  45. package/dist/testing.cjs.map +1 -0
  46. package/dist/testing.d.cts +231 -0
  47. package/dist/testing.d.ts +231 -0
  48. package/dist/testing.js +4483 -0
  49. package/dist/testing.js.map +1 -0
  50. package/dist/toasts-Bp0REqdq.d.cts +142 -0
  51. package/dist/toasts-Bp0REqdq.d.ts +142 -0
  52. package/dist/types-CnRrINRs.d.cts +445 -0
  53. package/dist/types-PuDZczzy.d.ts +445 -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 +3561 -0
  61. package/dist/vscode-webview.cjs.map +1 -0
  62. package/dist/vscode-webview.d.cts +84 -0
  63. package/dist/vscode-webview.d.ts +84 -0
  64. package/dist/vscode-webview.js +259 -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/feedback/appearance.ts +141 -0
  69. package/src/core/feedback/problems.ts +23 -0
  70. package/src/core/feedback/toasts.ts +118 -0
  71. package/src/core/fit.ts +220 -0
  72. package/src/core/index.ts +127 -0
  73. package/src/core/keymap.ts +295 -0
  74. package/src/core/layout.ts +69 -0
  75. package/src/core/messages.ts +159 -0
  76. package/src/core/sizes.ts +85 -0
  77. package/src/core/types.ts +106 -0
  78. package/src/core/web-chrome/bottom-row.ts +37 -0
  79. package/src/core/web-chrome/drop.ts +78 -0
  80. package/src/core/web-chrome/top-row.ts +66 -0
  81. package/src/core/zoom.ts +74 -0
  82. package/src/core.ts +2 -0
  83. package/src/diagram-js/connect.ts +75 -0
  84. package/src/diagram-js/index.ts +16 -0
  85. package/src/diagram-js/module.ts +20 -0
  86. package/src/diagram-js/palette-skin.ts +267 -0
  87. package/src/diagram-js/palette.css +269 -0
  88. package/src/diagram-js/service.ts +243 -0
  89. package/src/diagram-js/types.ts +67 -0
  90. package/src/diagram-js/viewport.ts +583 -0
  91. package/src/diagram-js.ts +2 -0
  92. package/src/dom/buttons.css +124 -0
  93. package/src/dom/element.ts +51 -0
  94. package/src/dom/feedback/appearance.ts +184 -0
  95. package/src/dom/feedback/feedback.css +435 -0
  96. package/src/dom/feedback/problems-popover.ts +287 -0
  97. package/src/dom/feedback/toasts.ts +431 -0
  98. package/src/dom/hint.ts +51 -0
  99. package/src/dom/icons.ts +309 -0
  100. package/src/dom/index.ts +42 -0
  101. package/src/dom/inspector.ts +35 -0
  102. package/src/dom/keys.ts +67 -0
  103. package/src/dom/ledger.ts +87 -0
  104. package/src/dom/legend.ts +85 -0
  105. package/src/dom/menu.ts +404 -0
  106. package/src/dom/mount.ts +731 -0
  107. package/src/dom/problems.ts +73 -0
  108. package/src/dom/shell-dom.css +969 -0
  109. package/src/dom/status.ts +72 -0
  110. package/src/dom/tooltip.ts +237 -0
  111. package/src/dom/types.ts +459 -0
  112. package/src/dom/web/drop-zone.ts +181 -0
  113. package/src/dom/web/empty-state.ts +144 -0
  114. package/src/dom/web/legal.ts +75 -0
  115. package/src/dom/web/menu-groups.ts +69 -0
  116. package/src/dom/web/primary.ts +124 -0
  117. package/src/dom/web/web.css +386 -0
  118. package/src/dom/zoom-panel.ts +154 -0
  119. package/src/index.ts +3 -0
  120. package/src/shell.css +9 -0
  121. package/src/testing/case-tools.ts +164 -0
  122. package/src/testing/cases.ts +1077 -0
  123. package/src/testing/checks.ts +868 -0
  124. package/src/testing/facts.ts +641 -0
  125. package/src/testing/geometry.ts +652 -0
  126. package/src/testing/harness.ts +187 -0
  127. package/src/testing/index.ts +19 -0
  128. package/src/testing/page-tools.ts +457 -0
  129. package/src/testing/page.ts +27 -0
  130. package/src/testing/vscode-stub.ts +237 -0
  131. package/src/testing/web-cases.ts +913 -0
  132. package/src/testing/web-checks.ts +1049 -0
  133. package/src/testing/web-facts.ts +713 -0
  134. package/src/testing-vscode-stub.ts +2 -0
  135. package/src/testing.ts +2 -0
  136. package/src/vscode/extension/html.ts +107 -0
  137. package/src/vscode/extension/index.ts +8 -0
  138. package/src/vscode/extension/reveal.ts +9 -0
  139. package/src/vscode/extension/theme-bridge.ts +85 -0
  140. package/src/vscode/extension/types.ts +36 -0
  141. package/src/vscode/protocol.ts +31 -0
  142. package/src/vscode/webview/appearance.ts +141 -0
  143. package/src/vscode/webview/index.ts +8 -0
  144. package/src/vscode/webview/mount.ts +88 -0
  145. package/src/vscode/webview/state.ts +116 -0
  146. package/src/vscode-extension.ts +2 -0
  147. package/src/vscode-webview.ts +2 -0
@@ -0,0 +1,84 @@
1
+ import { T as Theme, A as Appearance } from './appearance-D3FUcbu6.cjs';
2
+ import { S as ShellOptions, a as ShellHandle } from './types-CnRrINRs.cjs';
3
+ import { V as ViewportState } from './toasts-Bp0REqdq.cjs';
4
+ export { A as APPEARANCE_MESSAGE_TYPE, a as AppearanceMessage, b as appearanceMessage, i as isAppearanceMessage } from './protocol-DhYBakWL.cjs';
5
+ import './appearance-XX3JC3pI.cjs';
6
+
7
+ /**
8
+ * Writes `data-cd-theme` and `data-cd-kontrast` on `element` (default `<html>`) in one task, with
9
+ * transitions suppressed for one frame: adds `cd-shell-no-transition` to `<html>`, sets both
10
+ * attributes and removes the class in a nested `requestAnimationFrame` (after the last of several
11
+ * quick switches).
12
+ */
13
+ declare function applyAppearance(appearance: Appearance, element?: HTMLElement): void;
14
+ interface AppearanceListenerOptions {
15
+ /** The modes the modeler can show; the body-class fallback resolves against them. */
16
+ themes: readonly Theme[];
17
+ }
18
+ /**
19
+ * Listens for `AppearanceMessage`s on `window` and applies them to `<html>`, resolved against
20
+ * `themes` once more so a webview never shows a mode its bundle cannot. A page whose `<html>` has
21
+ * no `data-cd-theme` at connect (no `renderWebviewHtml`) falls back to the VS Code body classes,
22
+ * through a `MutationObserver` on `<body>` until the first message (resolved against `themes`).
23
+ * With the attributes of `renderWebviewHtml` there is no fallback: the extension's bridge knows the
24
+ * `colorTheme` setting, the body classes do not, and VS Code changes them before the bridge's
25
+ * message arrives, which would flash the mode without the setting. Returns the disconnect
26
+ * function. Throws when `themes` is empty.
27
+ */
28
+ declare function connectAppearance(options: AppearanceListenerOptions): () => void;
29
+ /**
30
+ * Mirrors VS Code's `workbench.reduceMotion` (the body class `vscode-reduce-motion`, which VS Code
31
+ * keeps up to date) as `REDUCED_MOTION_CLASS` on `<html>` for the whole session: the shell's
32
+ * animations stop and an explicit fit jumps, as under `prefers-reduced-motion` (guide §5.14, §7).
33
+ * Returns the disconnect function, which removes the class again.
34
+ */
35
+ declare function connectReducedMotion(): () => void;
36
+
37
+ /** The web column's options (0.2): a VS Code webview has none of them (guide §5.2, §13.5). */
38
+ type WebHostOptionKey = "primary" | "legal" | "file" | "appearance" | "emptyState" | "dropZone";
39
+ interface VsCodeShellOptions extends Omit<ShellOptions, "host" | "keyScope" | "themes" | WebHostOptionKey>, AppearanceListenerOptions {
40
+ }
41
+ /**
42
+ * `mountShell` for a VS Code webview: `host: "ide"`, the key listener on `document` (VS Code's own
43
+ * listener sits on `window`, so handled keys are stopped before it), `cd-shell-document` on
44
+ * `<html>`, plus `connectAppearance` and `connectReducedMotion`. `destroy()` also disconnects both.
45
+ */
46
+ declare function mountVsCodeShell(root: HTMLElement, options: VsCodeShellOptions): ShellHandle;
47
+
48
+ /** `acquireVsCodeApi()` as far as the state helpers need it. */
49
+ interface WebviewStateApi {
50
+ getState(): unknown;
51
+ setState(state: unknown): void;
52
+ }
53
+ /** What the shell keeps across a webview rebuild (guide §13.5: legend state and view). */
54
+ interface ShellWebviewState {
55
+ legendOpen?: boolean | undefined;
56
+ view?: ViewportState | undefined;
57
+ }
58
+ /** The key under which the shell's part lives in the webview state; other keys stay untouched. */
59
+ declare const SHELL_STATE_KEY = "modelerShell";
60
+ /** The shell's part of `api.getState()`; `{}` when there is none or it is malformed. */
61
+ declare function readShellState(api: WebviewStateApi): ShellWebviewState;
62
+ /**
63
+ * Merges `patch` into the shell's part and writes the whole state back, keeping every other key.
64
+ * A value that is `undefined` (for example `viewport.getState()` before the first import) or
65
+ * malformed leaves the stored value alone; nothing is written when nothing changed.
66
+ */
67
+ declare function writeShellState(api: WebviewStateApi, patch: ShellWebviewState): void;
68
+ /** What `persistView` reads of a viewport (`connectDiagramJs(…).viewport`). */
69
+ interface PersistableView {
70
+ onChange(listener: () => void): () => void;
71
+ getState(): ViewportState | undefined;
72
+ }
73
+ interface PersistViewOptions {
74
+ /** Quiet time before the write, default 250ms. */
75
+ delayMs?: number | undefined;
76
+ }
77
+ /**
78
+ * Keeps the stored view (`writeShellState(api, { view })`) up to date once the view has rested for
79
+ * `delayMs`, instead of one `vscode.setState` IPC message per animation frame. Returns the stop
80
+ * function; it writes a pending change at once.
81
+ */
82
+ declare function persistView(api: WebviewStateApi, viewport: PersistableView, options?: PersistViewOptions): () => void;
83
+
84
+ export { type AppearanceListenerOptions, type PersistViewOptions, type PersistableView, SHELL_STATE_KEY, type ShellWebviewState, type VsCodeShellOptions, type WebviewStateApi, applyAppearance, connectAppearance, connectReducedMotion, mountVsCodeShell, persistView, readShellState, writeShellState };
@@ -0,0 +1,84 @@
1
+ import { T as Theme, A as Appearance } from './appearance-D3FUcbu6.js';
2
+ import { S as ShellOptions, a as ShellHandle } from './types-PuDZczzy.js';
3
+ import { V as ViewportState } from './toasts-Bp0REqdq.js';
4
+ export { A as APPEARANCE_MESSAGE_TYPE, a as AppearanceMessage, b as appearanceMessage, i as isAppearanceMessage } from './protocol-IeW8bf4f.js';
5
+ import './appearance-BBaM_4bD.js';
6
+
7
+ /**
8
+ * Writes `data-cd-theme` and `data-cd-kontrast` on `element` (default `<html>`) in one task, with
9
+ * transitions suppressed for one frame: adds `cd-shell-no-transition` to `<html>`, sets both
10
+ * attributes and removes the class in a nested `requestAnimationFrame` (after the last of several
11
+ * quick switches).
12
+ */
13
+ declare function applyAppearance(appearance: Appearance, element?: HTMLElement): void;
14
+ interface AppearanceListenerOptions {
15
+ /** The modes the modeler can show; the body-class fallback resolves against them. */
16
+ themes: readonly Theme[];
17
+ }
18
+ /**
19
+ * Listens for `AppearanceMessage`s on `window` and applies them to `<html>`, resolved against
20
+ * `themes` once more so a webview never shows a mode its bundle cannot. A page whose `<html>` has
21
+ * no `data-cd-theme` at connect (no `renderWebviewHtml`) falls back to the VS Code body classes,
22
+ * through a `MutationObserver` on `<body>` until the first message (resolved against `themes`).
23
+ * With the attributes of `renderWebviewHtml` there is no fallback: the extension's bridge knows the
24
+ * `colorTheme` setting, the body classes do not, and VS Code changes them before the bridge's
25
+ * message arrives, which would flash the mode without the setting. Returns the disconnect
26
+ * function. Throws when `themes` is empty.
27
+ */
28
+ declare function connectAppearance(options: AppearanceListenerOptions): () => void;
29
+ /**
30
+ * Mirrors VS Code's `workbench.reduceMotion` (the body class `vscode-reduce-motion`, which VS Code
31
+ * keeps up to date) as `REDUCED_MOTION_CLASS` on `<html>` for the whole session: the shell's
32
+ * animations stop and an explicit fit jumps, as under `prefers-reduced-motion` (guide §5.14, §7).
33
+ * Returns the disconnect function, which removes the class again.
34
+ */
35
+ declare function connectReducedMotion(): () => void;
36
+
37
+ /** The web column's options (0.2): a VS Code webview has none of them (guide §5.2, §13.5). */
38
+ type WebHostOptionKey = "primary" | "legal" | "file" | "appearance" | "emptyState" | "dropZone";
39
+ interface VsCodeShellOptions extends Omit<ShellOptions, "host" | "keyScope" | "themes" | WebHostOptionKey>, AppearanceListenerOptions {
40
+ }
41
+ /**
42
+ * `mountShell` for a VS Code webview: `host: "ide"`, the key listener on `document` (VS Code's own
43
+ * listener sits on `window`, so handled keys are stopped before it), `cd-shell-document` on
44
+ * `<html>`, plus `connectAppearance` and `connectReducedMotion`. `destroy()` also disconnects both.
45
+ */
46
+ declare function mountVsCodeShell(root: HTMLElement, options: VsCodeShellOptions): ShellHandle;
47
+
48
+ /** `acquireVsCodeApi()` as far as the state helpers need it. */
49
+ interface WebviewStateApi {
50
+ getState(): unknown;
51
+ setState(state: unknown): void;
52
+ }
53
+ /** What the shell keeps across a webview rebuild (guide §13.5: legend state and view). */
54
+ interface ShellWebviewState {
55
+ legendOpen?: boolean | undefined;
56
+ view?: ViewportState | undefined;
57
+ }
58
+ /** The key under which the shell's part lives in the webview state; other keys stay untouched. */
59
+ declare const SHELL_STATE_KEY = "modelerShell";
60
+ /** The shell's part of `api.getState()`; `{}` when there is none or it is malformed. */
61
+ declare function readShellState(api: WebviewStateApi): ShellWebviewState;
62
+ /**
63
+ * Merges `patch` into the shell's part and writes the whole state back, keeping every other key.
64
+ * A value that is `undefined` (for example `viewport.getState()` before the first import) or
65
+ * malformed leaves the stored value alone; nothing is written when nothing changed.
66
+ */
67
+ declare function writeShellState(api: WebviewStateApi, patch: ShellWebviewState): void;
68
+ /** What `persistView` reads of a viewport (`connectDiagramJs(…).viewport`). */
69
+ interface PersistableView {
70
+ onChange(listener: () => void): () => void;
71
+ getState(): ViewportState | undefined;
72
+ }
73
+ interface PersistViewOptions {
74
+ /** Quiet time before the write, default 250ms. */
75
+ delayMs?: number | undefined;
76
+ }
77
+ /**
78
+ * Keeps the stored view (`writeShellState(api, { view })`) up to date once the view has rested for
79
+ * `delayMs`, instead of one `vscode.setState` IPC message per animation frame. Returns the stop
80
+ * function; it writes a pending change at once.
81
+ */
82
+ declare function persistView(api: WebviewStateApi, viewport: PersistableView, options?: PersistViewOptions): () => void;
83
+
84
+ export { type AppearanceListenerOptions, type PersistViewOptions, type PersistableView, SHELL_STATE_KEY, type ShellWebviewState, type VsCodeShellOptions, type WebviewStateApi, applyAppearance, connectAppearance, connectReducedMotion, mountVsCodeShell, persistView, readShellState, writeShellState };
@@ -0,0 +1,259 @@
1
+ import {
2
+ mountShell
3
+ } from "./chunk-66HCSJNY.js";
4
+ import {
5
+ APPEARANCE_MESSAGE_TYPE,
6
+ appearanceMessage,
7
+ isAppearanceMessage
8
+ } from "./chunk-N4QXFF3A.js";
9
+ import {
10
+ REDUCED_MOTION_CLASS,
11
+ appearanceAttributes,
12
+ appearanceFromBodyClasses,
13
+ reducedMotionFromBodyClasses,
14
+ resolveAppearance
15
+ } from "./chunk-OADW3GPA.js";
16
+
17
+ // src/vscode/webview/appearance.ts
18
+ var NO_TRANSITION_CLASS = "cd-shell-no-transition";
19
+ var latestSwitch = /* @__PURE__ */ new WeakMap();
20
+ function showsAppearance(element, appearance) {
21
+ const attributes = appearanceAttributes(appearance);
22
+ return element.getAttribute("data-cd-theme") === attributes["data-cd-theme"] && element.getAttribute("data-cd-kontrast") === (attributes["data-cd-kontrast"] ?? null);
23
+ }
24
+ function applyAppearance(appearance, element) {
25
+ const target = element ?? document.documentElement;
26
+ const html = target.ownerDocument.documentElement;
27
+ const attributes = appearanceAttributes(appearance);
28
+ const kontrast = attributes["data-cd-kontrast"];
29
+ const switchId = (latestSwitch.get(html) ?? 0) + 1;
30
+ latestSwitch.set(html, switchId);
31
+ html.classList.add(NO_TRANSITION_CLASS);
32
+ target.setAttribute("data-cd-theme", attributes["data-cd-theme"]);
33
+ if (kontrast) target.setAttribute("data-cd-kontrast", kontrast);
34
+ else target.removeAttribute("data-cd-kontrast");
35
+ requestAnimationFrame(
36
+ () => requestAnimationFrame(() => {
37
+ if (latestSwitch.get(html) !== switchId) return;
38
+ latestSwitch.delete(html);
39
+ html.classList.remove(NO_TRANSITION_CLASS);
40
+ })
41
+ );
42
+ }
43
+ function connectAppearance(options) {
44
+ const { themes } = options;
45
+ if (themes.length === 0) {
46
+ throw new Error("@miragon/modeler-shell: connectAppearance needs at least one theme");
47
+ }
48
+ const html = document.documentElement;
49
+ const show = (requested) => {
50
+ const resolved = resolveAppearance(requested, themes);
51
+ if (!showsAppearance(html, resolved)) applyAppearance(resolved, html);
52
+ };
53
+ let fallbackActive = !html.hasAttribute("data-cd-theme");
54
+ const applyBodyClasses = () => {
55
+ if (!fallbackActive || !document.body) return;
56
+ const requested = appearanceFromBodyClasses(document.body.classList);
57
+ if (requested) show(requested);
58
+ };
59
+ const observer = new MutationObserver(applyBodyClasses);
60
+ const startFallback = () => {
61
+ if (!fallbackActive || !document.body) return;
62
+ observer.observe(document.body, { attributes: true, attributeFilter: ["class"] });
63
+ applyBodyClasses();
64
+ };
65
+ const stopFallback = () => {
66
+ if (!fallbackActive) return;
67
+ fallbackActive = false;
68
+ observer.disconnect();
69
+ document.removeEventListener("DOMContentLoaded", startFallback);
70
+ };
71
+ const onMessage = (event) => {
72
+ if (!isAppearanceMessage(event.data)) return;
73
+ stopFallback();
74
+ show(event.data.appearance);
75
+ };
76
+ window.addEventListener("message", onMessage);
77
+ if (document.body) startFallback();
78
+ else if (fallbackActive) document.addEventListener("DOMContentLoaded", startFallback, { once: true });
79
+ return () => {
80
+ window.removeEventListener("message", onMessage);
81
+ fallbackActive = false;
82
+ observer.disconnect();
83
+ document.removeEventListener("DOMContentLoaded", startFallback);
84
+ };
85
+ }
86
+ function connectReducedMotion() {
87
+ const html = document.documentElement;
88
+ const apply = () => {
89
+ if (document.body)
90
+ html.classList.toggle(REDUCED_MOTION_CLASS, reducedMotionFromBodyClasses(document.body.classList));
91
+ };
92
+ const observer = new MutationObserver(apply);
93
+ const start = () => {
94
+ if (!document.body) return;
95
+ observer.observe(document.body, { attributes: true, attributeFilter: ["class"] });
96
+ apply();
97
+ };
98
+ if (document.body) start();
99
+ else document.addEventListener("DOMContentLoaded", start, { once: true });
100
+ return () => {
101
+ observer.disconnect();
102
+ document.removeEventListener("DOMContentLoaded", start);
103
+ html.classList.remove(REDUCED_MOTION_CLASS);
104
+ };
105
+ }
106
+
107
+ // src/vscode/webview/mount.ts
108
+ function withDestroyHook(shell, beforeDestroy) {
109
+ return {
110
+ get root() {
111
+ return shell.root;
112
+ },
113
+ get canvas() {
114
+ return shell.canvas;
115
+ },
116
+ get host() {
117
+ return shell.host;
118
+ },
119
+ get lang() {
120
+ return shell.lang;
121
+ },
122
+ get platform() {
123
+ return shell.platform;
124
+ },
125
+ get messages() {
126
+ return shell.messages;
127
+ },
128
+ get menu() {
129
+ return shell.menu;
130
+ },
131
+ get tooltip() {
132
+ return shell.tooltip;
133
+ },
134
+ get legend() {
135
+ return shell.legend;
136
+ },
137
+ get inspector() {
138
+ return shell.inspector;
139
+ },
140
+ get primary() {
141
+ return shell.primary;
142
+ },
143
+ get appearance() {
144
+ return shell.appearance;
145
+ },
146
+ setZoomTarget: (target) => shell.setZoomTarget(target),
147
+ fitInsets: () => shell.fitInsets(),
148
+ registerPalette: (palette) => shell.registerPalette(palette),
149
+ setProblems: (summary) => shell.setProblems(summary),
150
+ setStatus: (status, options) => shell.setStatus(status, options),
151
+ setEmptyHint: (visible) => shell.setEmptyHint(visible),
152
+ setReadOnly: (readOnly, options) => shell.setReadOnly(readOnly, options),
153
+ isReadOnly: () => shell.isReadOnly(),
154
+ setEmptyState: (shown) => shell.setEmptyState(shown),
155
+ isEmptyStateShown: () => shell.isEmptyStateShown(),
156
+ toast: (request) => shell.toast(request),
157
+ destroy() {
158
+ beforeDestroy();
159
+ shell.destroy();
160
+ }
161
+ };
162
+ }
163
+ function mountVsCodeShell(root, options) {
164
+ const { themes } = options;
165
+ const disconnectAppearance = connectAppearance({ themes });
166
+ const disconnectReducedMotion = connectReducedMotion();
167
+ const disconnect = () => {
168
+ disconnectAppearance();
169
+ disconnectReducedMotion();
170
+ };
171
+ let shell;
172
+ try {
173
+ shell = mountShell(root, { ...options, host: "ide", keyScope: "document" });
174
+ } catch (error) {
175
+ disconnect();
176
+ throw error;
177
+ }
178
+ return withDestroyHook(shell, disconnect);
179
+ }
180
+
181
+ // src/vscode/webview/state.ts
182
+ var SHELL_STATE_KEY = "modelerShell";
183
+ function isRecord(value) {
184
+ return typeof value === "object" && value !== null && !Array.isArray(value);
185
+ }
186
+ function storedState(api) {
187
+ const state = api.getState();
188
+ return isRecord(state) ? state : {};
189
+ }
190
+ function viewboxFrom(value) {
191
+ if (!isRecord(value)) return void 0;
192
+ const { x, y, width, height } = value;
193
+ if (typeof x !== "number" || typeof y !== "number") return void 0;
194
+ if (typeof width !== "number" || typeof height !== "number") return void 0;
195
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || !Number.isFinite(height)) {
196
+ return void 0;
197
+ }
198
+ return width > 0 && height > 0 ? { x, y, width, height } : void 0;
199
+ }
200
+ function viewFrom(value) {
201
+ if (!isRecord(value) || typeof value.userMoved !== "boolean") return void 0;
202
+ const viewbox = viewboxFrom(value.viewbox);
203
+ return viewbox ? { viewbox, userMoved: value.userMoved } : void 0;
204
+ }
205
+ function readShellState(api) {
206
+ const part = storedState(api)[SHELL_STATE_KEY];
207
+ if (!isRecord(part)) return {};
208
+ const state = {};
209
+ if (typeof part.legendOpen === "boolean") state.legendOpen = part.legendOpen;
210
+ const view = viewFrom(part.view);
211
+ if (view) state.view = view;
212
+ return state;
213
+ }
214
+ function writeShellState(api, patch) {
215
+ const state = storedState(api);
216
+ const part = isRecord(state[SHELL_STATE_KEY]) ? state[SHELL_STATE_KEY] : {};
217
+ const next = { ...part };
218
+ if (typeof patch.legendOpen === "boolean") next.legendOpen = patch.legendOpen;
219
+ const view = viewFrom(patch.view);
220
+ if (view) next.view = view;
221
+ if (JSON.stringify(next) === JSON.stringify(state[SHELL_STATE_KEY])) return;
222
+ api.setState({ ...state, [SHELL_STATE_KEY]: next });
223
+ }
224
+ var PERSIST_VIEW_DELAY_MS = 250;
225
+ function persistView(api, viewport, options = {}) {
226
+ const delayMs = options.delayMs ?? PERSIST_VIEW_DELAY_MS;
227
+ let timer;
228
+ const write = () => {
229
+ timer = void 0;
230
+ writeShellState(api, { view: viewport.getState() });
231
+ };
232
+ const unsubscribe = viewport.onChange(() => {
233
+ clearTimeout(timer);
234
+ timer = setTimeout(write, delayMs);
235
+ });
236
+ let stopped = false;
237
+ return () => {
238
+ if (stopped) return;
239
+ stopped = true;
240
+ unsubscribe();
241
+ if (timer === void 0) return;
242
+ clearTimeout(timer);
243
+ write();
244
+ };
245
+ }
246
+ export {
247
+ APPEARANCE_MESSAGE_TYPE,
248
+ SHELL_STATE_KEY,
249
+ appearanceMessage,
250
+ applyAppearance,
251
+ connectAppearance,
252
+ connectReducedMotion,
253
+ isAppearanceMessage,
254
+ mountVsCodeShell,
255
+ persistView,
256
+ readShellState,
257
+ writeShellState
258
+ };
259
+ //# sourceMappingURL=vscode-webview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vscode/webview/appearance.ts","../src/vscode/webview/mount.ts","../src/vscode/webview/state.ts"],"sourcesContent":["import {\n REDUCED_MOTION_CLASS,\n appearanceAttributes,\n appearanceFromBodyClasses,\n reducedMotionFromBodyClasses,\n resolveAppearance,\n type Appearance,\n type Theme,\n} from \"../../core/index.js\";\nimport { isAppearanceMessage } from \"../protocol.js\";\n\nconst NO_TRANSITION_CLASS = \"cd-shell-no-transition\";\n\n/** The latest mode switch per `<html>`: only its second frame may lift the transition stop. */\nconst latestSwitch = new WeakMap<Element, number>();\n\nfunction showsAppearance(element: Element, appearance: Appearance): boolean {\n const attributes = appearanceAttributes(appearance);\n return (\n element.getAttribute(\"data-cd-theme\") === attributes[\"data-cd-theme\"] &&\n element.getAttribute(\"data-cd-kontrast\") === (attributes[\"data-cd-kontrast\"] ?? null)\n );\n}\n\n/**\n * Writes `data-cd-theme` and `data-cd-kontrast` on `element` (default `<html>`) in one task, with\n * transitions suppressed for one frame: adds `cd-shell-no-transition` to `<html>`, sets both\n * attributes and removes the class in a nested `requestAnimationFrame` (after the last of several\n * quick switches).\n */\nexport function applyAppearance(appearance: Appearance, element?: HTMLElement): void {\n const target = element ?? document.documentElement;\n const html = target.ownerDocument.documentElement;\n const attributes = appearanceAttributes(appearance);\n const kontrast = attributes[\"data-cd-kontrast\"];\n\n const switchId = (latestSwitch.get(html) ?? 0) + 1;\n latestSwitch.set(html, switchId);\n html.classList.add(NO_TRANSITION_CLASS);\n target.setAttribute(\"data-cd-theme\", attributes[\"data-cd-theme\"]);\n if (kontrast) target.setAttribute(\"data-cd-kontrast\", kontrast);\n else target.removeAttribute(\"data-cd-kontrast\");\n\n requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n if (latestSwitch.get(html) !== switchId) return;\n latestSwitch.delete(html);\n html.classList.remove(NO_TRANSITION_CLASS);\n }),\n );\n}\n\nexport interface AppearanceListenerOptions {\n /** The modes the modeler can show; the body-class fallback resolves against them. */\n themes: readonly Theme[];\n}\n\n/**\n * Listens for `AppearanceMessage`s on `window` and applies them to `<html>`, resolved against\n * `themes` once more so a webview never shows a mode its bundle cannot. A page whose `<html>` has\n * no `data-cd-theme` at connect (no `renderWebviewHtml`) falls back to the VS Code body classes,\n * through a `MutationObserver` on `<body>` until the first message (resolved against `themes`).\n * With the attributes of `renderWebviewHtml` there is no fallback: the extension's bridge knows the\n * `colorTheme` setting, the body classes do not, and VS Code changes them before the bridge's\n * message arrives, which would flash the mode without the setting. Returns the disconnect\n * function. Throws when `themes` is empty.\n */\nexport function connectAppearance(options: AppearanceListenerOptions): () => void {\n const { themes } = options;\n if (themes.length === 0) {\n throw new Error(\"@miragon/modeler-shell: connectAppearance needs at least one theme\");\n }\n const html = document.documentElement;\n const show = (requested: Appearance): void => {\n const resolved = resolveAppearance(requested, themes);\n if (!showsAppearance(html, resolved)) applyAppearance(resolved, html);\n };\n\n let fallbackActive = !html.hasAttribute(\"data-cd-theme\");\n const applyBodyClasses = (): void => {\n if (!fallbackActive || !document.body) return;\n const requested = appearanceFromBodyClasses(document.body.classList);\n if (requested) show(requested);\n };\n const observer = new MutationObserver(applyBodyClasses);\n const startFallback = (): void => {\n if (!fallbackActive || !document.body) return;\n observer.observe(document.body, { attributes: true, attributeFilter: [\"class\"] });\n applyBodyClasses();\n };\n const stopFallback = (): void => {\n if (!fallbackActive) return;\n fallbackActive = false;\n observer.disconnect();\n document.removeEventListener(\"DOMContentLoaded\", startFallback);\n };\n\n const onMessage = (event: MessageEvent): void => {\n if (!isAppearanceMessage(event.data)) return;\n stopFallback();\n show(event.data.appearance);\n };\n\n window.addEventListener(\"message\", onMessage);\n if (document.body) startFallback();\n else if (fallbackActive) document.addEventListener(\"DOMContentLoaded\", startFallback, { once: true });\n\n return () => {\n window.removeEventListener(\"message\", onMessage);\n fallbackActive = false;\n observer.disconnect();\n document.removeEventListener(\"DOMContentLoaded\", startFallback);\n };\n}\n\n/**\n * Mirrors VS Code's `workbench.reduceMotion` (the body class `vscode-reduce-motion`, which VS Code\n * keeps up to date) as `REDUCED_MOTION_CLASS` on `<html>` for the whole session: the shell's\n * animations stop and an explicit fit jumps, as under `prefers-reduced-motion` (guide §5.14, §7).\n * Returns the disconnect function, which removes the class again.\n */\nexport function connectReducedMotion(): () => void {\n const html = document.documentElement;\n const apply = (): void => {\n if (document.body)\n html.classList.toggle(REDUCED_MOTION_CLASS, reducedMotionFromBodyClasses(document.body.classList));\n };\n const observer = new MutationObserver(apply);\n const start = (): void => {\n if (!document.body) return;\n observer.observe(document.body, { attributes: true, attributeFilter: [\"class\"] });\n apply();\n };\n if (document.body) start();\n else document.addEventListener(\"DOMContentLoaded\", start, { once: true });\n return () => {\n observer.disconnect();\n document.removeEventListener(\"DOMContentLoaded\", start);\n html.classList.remove(REDUCED_MOTION_CLASS);\n };\n}\n","import { mountShell, type ShellHandle, type ShellOptions } from \"../../dom/index.js\";\nimport { connectAppearance, connectReducedMotion, type AppearanceListenerOptions } from \"./appearance.js\";\n\n/** The web column's options (0.2): a VS Code webview has none of them (guide §5.2, §13.5). */\ntype WebHostOptionKey = \"primary\" | \"legal\" | \"file\" | \"appearance\" | \"emptyState\" | \"dropZone\";\n\nexport interface VsCodeShellOptions\n extends Omit<ShellOptions, \"host\" | \"keyScope\" | \"themes\" | WebHostOptionKey>, AppearanceListenerOptions {}\n\n/** The shell's handle with a `destroy` that runs `beforeDestroy` first; every other member delegates. */\nfunction withDestroyHook(shell: ShellHandle, beforeDestroy: () => void): ShellHandle {\n return {\n get root() {\n return shell.root;\n },\n get canvas() {\n return shell.canvas;\n },\n get host() {\n return shell.host;\n },\n get lang() {\n return shell.lang;\n },\n get platform() {\n return shell.platform;\n },\n get messages() {\n return shell.messages;\n },\n get menu() {\n return shell.menu;\n },\n get tooltip() {\n return shell.tooltip;\n },\n get legend() {\n return shell.legend;\n },\n get inspector() {\n return shell.inspector;\n },\n get primary() {\n return shell.primary;\n },\n get appearance() {\n return shell.appearance;\n },\n setZoomTarget: (target) => shell.setZoomTarget(target),\n fitInsets: () => shell.fitInsets(),\n registerPalette: (palette) => shell.registerPalette(palette),\n setProblems: (summary) => shell.setProblems(summary),\n setStatus: (status, options) => shell.setStatus(status, options),\n setEmptyHint: (visible) => shell.setEmptyHint(visible),\n setReadOnly: (readOnly, options) => shell.setReadOnly(readOnly, options),\n isReadOnly: () => shell.isReadOnly(),\n setEmptyState: (shown) => shell.setEmptyState(shown),\n isEmptyStateShown: () => shell.isEmptyStateShown(),\n toast: (request) => shell.toast(request),\n destroy() {\n beforeDestroy();\n shell.destroy();\n },\n };\n}\n\n/**\n * `mountShell` for a VS Code webview: `host: \"ide\"`, the key listener on `document` (VS Code's own\n * listener sits on `window`, so handled keys are stopped before it), `cd-shell-document` on\n * `<html>`, plus `connectAppearance` and `connectReducedMotion`. `destroy()` also disconnects both.\n */\nexport function mountVsCodeShell(root: HTMLElement, options: VsCodeShellOptions): ShellHandle {\n const { themes } = options;\n const disconnectAppearance = connectAppearance({ themes });\n const disconnectReducedMotion = connectReducedMotion();\n const disconnect = (): void => {\n disconnectAppearance();\n disconnectReducedMotion();\n };\n let shell: ShellHandle;\n try {\n shell = mountShell(root, { ...options, host: \"ide\", keyScope: \"document\" });\n } catch (error) {\n disconnect();\n throw error;\n }\n return withDestroyHook(shell, disconnect);\n}\n","import type { Bounds, ViewportState } from \"../../core/index.js\";\n\n/** `acquireVsCodeApi()` as far as the state helpers need it. */\nexport interface WebviewStateApi {\n getState(): unknown;\n setState(state: unknown): void;\n}\n\n/** What the shell keeps across a webview rebuild (guide §13.5: legend state and view). */\nexport interface ShellWebviewState {\n legendOpen?: boolean | undefined;\n view?: ViewportState | undefined;\n}\n\n/** The key under which the shell's part lives in the webview state; other keys stay untouched. */\nexport const SHELL_STATE_KEY = \"modelerShell\";\n\ntype StateRecord = Record<string, unknown>;\n\nfunction isRecord(value: unknown): value is StateRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction storedState(api: WebviewStateApi): StateRecord {\n const state = api.getState();\n return isRecord(state) ? state : {};\n}\n\nfunction viewboxFrom(value: unknown): Bounds | undefined {\n if (!isRecord(value)) return undefined;\n const { x, y, width, height } = value;\n if (typeof x !== \"number\" || typeof y !== \"number\") return undefined;\n if (typeof width !== \"number\" || typeof height !== \"number\") return undefined;\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(width) || !Number.isFinite(height)) {\n return undefined;\n }\n return width > 0 && height > 0 ? { x, y, width, height } : undefined;\n}\n\nfunction viewFrom(value: unknown): ViewportState | undefined {\n if (!isRecord(value) || typeof value.userMoved !== \"boolean\") return undefined;\n const viewbox = viewboxFrom(value.viewbox);\n return viewbox ? { viewbox, userMoved: value.userMoved } : undefined;\n}\n\n/** The shell's part of `api.getState()`; `{}` when there is none or it is malformed. */\nexport function readShellState(api: WebviewStateApi): ShellWebviewState {\n const part = storedState(api)[SHELL_STATE_KEY];\n if (!isRecord(part)) return {};\n const state: ShellWebviewState = {};\n if (typeof part.legendOpen === \"boolean\") state.legendOpen = part.legendOpen;\n const view = viewFrom(part.view);\n if (view) state.view = view;\n return state;\n}\n\n/**\n * Merges `patch` into the shell's part and writes the whole state back, keeping every other key.\n * A value that is `undefined` (for example `viewport.getState()` before the first import) or\n * malformed leaves the stored value alone; nothing is written when nothing changed.\n */\nexport function writeShellState(api: WebviewStateApi, patch: ShellWebviewState): void {\n const state = storedState(api);\n const part = isRecord(state[SHELL_STATE_KEY]) ? (state[SHELL_STATE_KEY] as StateRecord) : {};\n const next: StateRecord = { ...part };\n if (typeof patch.legendOpen === \"boolean\") next.legendOpen = patch.legendOpen;\n const view = viewFrom(patch.view);\n if (view) next.view = view;\n if (JSON.stringify(next) === JSON.stringify(state[SHELL_STATE_KEY])) return;\n api.setState({ ...state, [SHELL_STATE_KEY]: next });\n}\n\n/** What `persistView` reads of a viewport (`connectDiagramJs(…).viewport`). */\nexport interface PersistableView {\n onChange(listener: () => void): () => void;\n getState(): ViewportState | undefined;\n}\n\nexport interface PersistViewOptions {\n /** Quiet time before the write, default 250ms. */\n delayMs?: number | undefined;\n}\n\n/** A pan, a wheel zoom or a fit animation changes the view on every frame. */\nconst PERSIST_VIEW_DELAY_MS = 250;\n\n/**\n * Keeps the stored view (`writeShellState(api, { view })`) up to date once the view has rested for\n * `delayMs`, instead of one `vscode.setState` IPC message per animation frame. Returns the stop\n * function; it writes a pending change at once.\n */\nexport function persistView(\n api: WebviewStateApi,\n viewport: PersistableView,\n options: PersistViewOptions = {},\n): () => void {\n const delayMs = options.delayMs ?? PERSIST_VIEW_DELAY_MS;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const write = (): void => {\n timer = undefined;\n writeShellState(api, { view: viewport.getState() });\n };\n const unsubscribe = viewport.onChange(() => {\n clearTimeout(timer);\n timer = setTimeout(write, delayMs);\n });\n let stopped = false;\n return () => {\n if (stopped) return;\n stopped = true;\n unsubscribe();\n if (timer === undefined) return;\n clearTimeout(timer);\n write();\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,IAAM,sBAAsB;AAG5B,IAAM,eAAe,oBAAI,QAAyB;AAElD,SAAS,gBAAgB,SAAkB,YAAiC;AAC1E,QAAM,aAAa,qBAAqB,UAAU;AAClD,SACE,QAAQ,aAAa,eAAe,MAAM,WAAW,eAAe,KACpE,QAAQ,aAAa,kBAAkB,OAAO,WAAW,kBAAkB,KAAK;AAEpF;AAQO,SAAS,gBAAgB,YAAwB,SAA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@@
1
1
  {
2
2
  "name": "@miragon/modeler-shell",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "The shared, framework-free chrome around Miragon diagram-js modelers: menu, palette skin, tooltip, zoom panel, keys, fit, problems pill, status box, legend and inspector slots, the VS Code host plumbing and the web-app chrome (primary action, legal line, toasts, empty state, drop zone).",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Miragon/modeler-api.git",
9
+ "directory": "packages/shell"
10
+ },
11
+ "homepage": "https://github.com/Miragon/modeler-api/tree/main/packages/shell#readme",
12
+ "bugs": "https://github.com/Miragon/modeler-api/issues",
13
+ "type": "module",
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.cts",
25
+ "default": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "./core": {
29
+ "import": {
30
+ "types": "./dist/core.d.ts",
31
+ "default": "./dist/core.js"
32
+ },
33
+ "require": {
34
+ "types": "./dist/core.d.cts",
35
+ "default": "./dist/core.cjs"
36
+ }
37
+ },
38
+ "./diagram-js": {
39
+ "import": {
40
+ "types": "./dist/diagram-js.d.ts",
41
+ "default": "./dist/diagram-js.js"
42
+ },
43
+ "require": {
44
+ "types": "./dist/diagram-js.d.cts",
45
+ "default": "./dist/diagram-js.cjs"
46
+ }
47
+ },
48
+ "./vscode/extension": {
49
+ "import": {
50
+ "types": "./dist/vscode-extension.d.ts",
51
+ "default": "./dist/vscode-extension.js"
52
+ },
53
+ "require": {
54
+ "types": "./dist/vscode-extension.d.cts",
55
+ "default": "./dist/vscode-extension.cjs"
56
+ }
57
+ },
58
+ "./vscode/webview": {
59
+ "import": {
60
+ "types": "./dist/vscode-webview.d.ts",
61
+ "default": "./dist/vscode-webview.js"
62
+ },
63
+ "require": {
64
+ "types": "./dist/vscode-webview.d.cts",
65
+ "default": "./dist/vscode-webview.cjs"
66
+ }
67
+ },
68
+ "./testing": {
69
+ "import": {
70
+ "types": "./dist/testing.d.ts",
71
+ "default": "./dist/testing.js"
72
+ },
73
+ "require": {
74
+ "types": "./dist/testing.d.cts",
75
+ "default": "./dist/testing.cjs"
76
+ }
77
+ },
78
+ "./testing/vscode-stub": {
79
+ "import": {
80
+ "types": "./dist/testing-vscode-stub.d.ts",
81
+ "default": "./dist/testing-vscode-stub.js"
82
+ },
83
+ "require": {
84
+ "types": "./dist/testing-vscode-stub.d.cts",
85
+ "default": "./dist/testing-vscode-stub.cjs"
86
+ }
87
+ },
88
+ "./shell.css": "./dist/shell.css",
89
+ "./package.json": "./package.json"
90
+ },
91
+ "main": "./dist/index.cjs",
92
+ "module": "./dist/index.js",
93
+ "types": "./dist/index.d.ts",
94
+ "typesVersions": {
95
+ "*": {
96
+ "core": [
97
+ "./dist/core.d.ts"
98
+ ],
99
+ "diagram-js": [
100
+ "./dist/diagram-js.d.ts"
101
+ ],
102
+ "vscode/extension": [
103
+ "./dist/vscode-extension.d.ts"
104
+ ],
105
+ "vscode/webview": [
106
+ "./dist/vscode-webview.d.ts"
107
+ ],
108
+ "testing": [
109
+ "./dist/testing.d.ts"
110
+ ],
111
+ "testing/vscode-stub": [
112
+ "./dist/testing-vscode-stub.d.ts"
113
+ ]
114
+ }
115
+ },
116
+ "files": [
117
+ "dist",
118
+ "src",
119
+ "!src/**/*.test.ts",
120
+ "API.md",
121
+ "THIRD_PARTY_NOTICES.md"
122
+ ],
123
+ "publishConfig": {
124
+ "access": "public"
125
+ },
126
+ "engines": {
127
+ "node": ">=20"
128
+ },
129
+ "scripts": {
130
+ "build": "tsup",
131
+ "publint": "publint",
132
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.core.json && tsc -p demo/tsconfig.json",
133
+ "test": "vitest run",
134
+ "test:e2e": "playwright test",
135
+ "demo": "vite --config demo/vite.config.ts"
136
+ },
137
+ "devDependencies": {
138
+ "@fontsource-variable/geist": "5.3.0",
139
+ "@fontsource-variable/geist-mono": "5.3.0",
140
+ "@playwright/test": "1.64.1",
141
+ "@types/node": "22.20.5",
142
+ "@types/vscode": "1.96.0",
143
+ "diagram-js": "15.28.1",
144
+ "happy-dom": "21.0.3",
145
+ "vite": "8.2.2"
146
+ }
147
+ }