@miragon/modeler-shell 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +1051 -84
- package/README.md +162 -31
- package/dist/appearance-BBaM_4bD.d.ts +323 -0
- package/dist/appearance-XX3JC3pI.d.cts +323 -0
- package/dist/{chunk-6LQOFACK.js → chunk-A4YGKH4Y.js} +1252 -31
- package/dist/chunk-A4YGKH4Y.js.map +1 -0
- package/dist/{chunk-RJRFR6N3.js → chunk-KYDG5DMX.js} +2 -2
- package/dist/{chunk-5JSZ4VGA.js → chunk-OADW3GPA.js} +240 -6
- package/dist/chunk-OADW3GPA.js.map +1 -0
- package/dist/core.cjs +260 -6
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +81 -6
- package/dist/core.d.ts +81 -6
- package/dist/core.js +43 -3
- package/dist/diagram-js.cjs +34 -2
- package/dist/diagram-js.cjs.map +1 -1
- package/dist/diagram-js.d.cts +10 -3
- package/dist/diagram-js.d.ts +10 -3
- package/dist/diagram-js.js +14 -2
- package/dist/diagram-js.js.map +1 -1
- package/dist/index.cjs +1658 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +44 -4
- package/dist/shell.css +692 -3
- package/dist/testing-vscode-stub.js +2 -2
- package/dist/testing.cjs +2849 -550
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +75 -9
- package/dist/testing.d.ts +75 -9
- package/dist/testing.js +2744 -558
- package/dist/testing.js.map +1 -1
- package/dist/toasts-Bp0REqdq.d.cts +142 -0
- package/dist/toasts-Bp0REqdq.d.ts +142 -0
- package/dist/{types-OuFlqZp0.d.cts → types-CnRrINRs.d.cts} +170 -9
- package/dist/{types-DnZn9CPw.d.ts → types-PuDZczzy.d.ts} +170 -9
- package/dist/vscode-extension.js +2 -2
- package/dist/vscode-webview.cjs +1546 -178
- package/dist/vscode-webview.cjs.map +1 -1
- package/dist/vscode-webview.d.cts +6 -4
- package/dist/vscode-webview.d.ts +6 -4
- package/dist/vscode-webview.js +11 -2
- package/dist/vscode-webview.js.map +1 -1
- package/package.json +2 -2
- package/src/core/feedback/appearance.ts +141 -0
- package/src/core/feedback/problems.ts +23 -0
- package/src/core/feedback/toasts.ts +118 -0
- package/src/core/fit.ts +18 -3
- package/src/core/index.ts +43 -0
- package/src/core/keymap.ts +20 -0
- package/src/core/messages.ts +71 -0
- package/src/core/types.ts +24 -2
- package/src/core/web-chrome/bottom-row.ts +37 -0
- package/src/core/web-chrome/drop.ts +78 -0
- package/src/core/web-chrome/top-row.ts +66 -0
- package/src/diagram-js/service.ts +4 -1
- package/src/diagram-js/viewport.ts +19 -0
- package/src/dom/buttons.css +124 -0
- package/src/dom/feedback/appearance.ts +184 -0
- package/src/dom/feedback/feedback.css +435 -0
- package/src/dom/feedback/problems-popover.ts +287 -0
- package/src/dom/feedback/toasts.ts +431 -0
- package/src/dom/index.ts +13 -0
- package/src/dom/keys.ts +8 -0
- package/src/dom/menu.ts +28 -17
- package/src/dom/mount.ts +290 -20
- package/src/dom/problems.ts +5 -4
- package/src/dom/shell-dom.css +7 -4
- package/src/dom/tooltip.ts +10 -0
- package/src/dom/types.ts +188 -6
- package/src/dom/web/drop-zone.ts +181 -0
- package/src/dom/web/empty-state.ts +144 -0
- package/src/dom/web/legal.ts +75 -0
- package/src/dom/web/menu-groups.ts +69 -0
- package/src/dom/web/primary.ts +124 -0
- package/src/dom/web/web.css +386 -0
- package/src/shell.css +3 -0
- package/src/testing/case-tools.ts +164 -0
- package/src/testing/cases.ts +209 -144
- package/src/testing/checks.ts +51 -15
- package/src/testing/facts.ts +56 -2
- package/src/testing/geometry.ts +206 -26
- package/src/testing/harness.ts +56 -7
- package/src/testing/index.ts +4 -0
- package/src/testing/page-tools.ts +24 -1
- package/src/testing/page.ts +10 -0
- package/src/testing/web-cases.ts +913 -0
- package/src/testing/web-checks.ts +1049 -0
- package/src/testing/web-facts.ts +713 -0
- package/src/vscode/webview/mount.ts +13 -1
- package/dist/chunk-5JSZ4VGA.js.map +0 -1
- package/dist/chunk-6LQOFACK.js.map +0 -1
- package/dist/keymap-CObQE6q6.d.cts +0 -151
- package/dist/keymap-DORzHnK-.d.ts +0 -151
- package/dist/types-B6NfkiUG.d.cts +0 -66
- package/dist/types-B6NfkiUG.d.ts +0 -66
- /package/dist/{chunk-RJRFR6N3.js.map → chunk-KYDG5DMX.js.map} +0 -0
package/src/testing/harness.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Appearance, ColorThemeSetting, ShellHost, Size, Theme } from "../core/index.js";
|
|
1
|
+
import type { Appearance, ColorThemeSetting, ShellHost, Size, Theme, ToastStatus } from "../core/index.js";
|
|
2
2
|
import { createCases } from "./cases.js";
|
|
3
3
|
import type { PageLike } from "./page.js";
|
|
4
4
|
|
|
@@ -8,7 +8,10 @@ export interface OpenContext {
|
|
|
8
8
|
/**
|
|
9
9
|
* What the host requests before the modeler resolves it: in an IDE host the VS Code color theme
|
|
10
10
|
* (`vsCodeStubSearch` hands it to a page with the VS Code stub). For an embedded host the kit
|
|
11
|
-
* itself puts the foreign page's `<html>` in this mode once `open` resolved.
|
|
11
|
+
* itself puts the foreign page's `<html>` in this mode once `open` resolved. In the web host the
|
|
12
|
+
* system's preference without a stored choice: the kit emulates `prefers-color-scheme` and
|
|
13
|
+
* `prefers-contrast` (`PageLike.emulateMedia`) before `open`, and `open` loads the page with an
|
|
14
|
+
* empty `localStorage` entry `miragon.darstellung`.
|
|
12
15
|
*/
|
|
13
16
|
requested: Appearance;
|
|
14
17
|
}
|
|
@@ -27,11 +30,53 @@ export interface ShowHooks<P extends PageLike = PageLike> {
|
|
|
27
30
|
* read-only canvas and the status box. The kit waits `INVALID_STATUS_DELAY_MS` afterwards.
|
|
28
31
|
*/
|
|
29
32
|
invalid?: ((page: P) => Promise<void>) | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Web host: puts the page on its start screen, the way a fresh visit without a document shows
|
|
35
|
+
* it (`shell.setEmptyState(true)`); `open` itself loads a document.
|
|
36
|
+
*/
|
|
37
|
+
emptyState?: ((page: P) => Promise<void>) | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Web and embedded hosts: shows `toast` through the modeler's `shell.toast`, with
|
|
40
|
+
* `{ label: toast.actionLabel, onSelect() {} }` as its action when `actionLabel` is given.
|
|
41
|
+
*/
|
|
42
|
+
toast?: ((page: P, toast: ToastFixture) => Promise<void>) | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A toast the kit asks the `toast` hook to show (cases `toasts`, `geometry`). */
|
|
46
|
+
export interface ToastFixture {
|
|
47
|
+
status: ToastStatus;
|
|
48
|
+
text: string;
|
|
49
|
+
actionLabel?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A file the kit drops on the page (case `dropZone`), built in the page as `new File([text], name, { type })`. */
|
|
53
|
+
export interface DropFixture {
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
text: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface DropFixtures {
|
|
60
|
+
/** A file `DropZoneOptions.accept` takes; dropping it on the start screen opens it (the card goes). */
|
|
61
|
+
accepted: DropFixture;
|
|
62
|
+
/** A file outside `accept`; dropping it opens nothing and shows a danger toast (or the modeler's `onReject`). */
|
|
63
|
+
rejected?: DropFixture | undefined;
|
|
64
|
+
/** `DropZoneOptions.multiple` of the modeler; default `false`, so a drag of two files is forbidden. */
|
|
65
|
+
multiple?: boolean | undefined;
|
|
30
66
|
}
|
|
31
67
|
|
|
32
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* A show hook by name: the islands `legend`, `inspector`, `problems`, `status`, the state
|
|
70
|
+
* `invalid`, and in the web column `emptyState` and `toast`.
|
|
71
|
+
*/
|
|
33
72
|
export type ShowHook = keyof ShowHooks;
|
|
34
73
|
|
|
74
|
+
/**
|
|
75
|
+
* What a harness can lack: a show hook, the web app's drop zone (`drop`), or problems that point at
|
|
76
|
+
* an element (`problemSelection`: the modeler's diagnostics only name lines, so no row selects).
|
|
77
|
+
*/
|
|
78
|
+
export type AbsentFeature = ShowHook | "drop" | "problemSelection";
|
|
79
|
+
|
|
35
80
|
export interface ShellConformanceHarness<P extends PageLike = PageLike> {
|
|
36
81
|
host: ShellHost;
|
|
37
82
|
/** The modes the modeler declares (static); the appearance case requests dark from `["light"]`. */
|
|
@@ -44,12 +89,14 @@ export interface ShellConformanceHarness<P extends PageLike = PageLike> {
|
|
|
44
89
|
root?: string | undefined;
|
|
45
90
|
/** Hooks for the islands and states the modeler has; one that is neither given nor `absent` is reported as skipped. */
|
|
46
91
|
show?: ShowHooks<P> | undefined;
|
|
92
|
+
/** Web host: the files the `dropZone` case drops; without them (and not `absent`) it is skipped with `hook: "drop"`. */
|
|
93
|
+
drop?: DropFixtures | undefined;
|
|
47
94
|
/**
|
|
48
95
|
* The islands and states the modeler does not have. An absent hook is not reported as skipped,
|
|
49
96
|
* and `geometry` and `aria` assert that its island is never visible. Listing a hook that `show`
|
|
50
97
|
* also gives fails every case that uses it.
|
|
51
98
|
*/
|
|
52
|
-
absent?: readonly
|
|
99
|
+
absent?: readonly AbsentFeature[] | undefined;
|
|
53
100
|
/** Container sizes of the geometry case; default wide 1280 × 900, narrow 720 × 700, very narrow 420 × 700. */
|
|
54
101
|
sizes?: readonly Size[] | undefined;
|
|
55
102
|
}
|
|
@@ -60,7 +107,7 @@ export interface ShellSkip {
|
|
|
60
107
|
* The harness field that would feed it: a show hook, `destroy`, or `open` when the document it
|
|
61
108
|
* opens lacks what the case needs (a shape on the canvas).
|
|
62
109
|
*/
|
|
63
|
-
hook: ShowHook | "destroy" | "open";
|
|
110
|
+
hook: ShowHook | "drop" | "destroy" | "open";
|
|
64
111
|
reason: string;
|
|
65
112
|
}
|
|
66
113
|
|
|
@@ -82,8 +129,10 @@ export interface ShellConformanceCase {
|
|
|
82
129
|
* canvas only), `create` (Enter on the first creating palette entry places one selected element in
|
|
83
130
|
* the free rectangle and focuses the canvas), `readOnly` (the invalid-file lock of guide §13.5),
|
|
84
131
|
* `appearance` (dark requested from a light-only modeler: nothing turns dark, `color-scheme` light
|
|
85
|
-
* everywhere, the canvas surround and the palette's tool colours from the roles
|
|
86
|
-
* `destroy` no shell element, class, attribute or
|
|
132
|
+
* everywhere, the canvas surround and the palette's tool colours from the roles; the web app's mode
|
|
133
|
+
* and its Appearance group) and `cleanup` (after `destroy` no shell element, class, attribute or
|
|
134
|
+
* key handling remains); then the web column's `webChrome`, `emptyState`, `toasts`,
|
|
135
|
+
* `problemsList` and `dropZone`, which assert in the other hosts that nothing of them shows.
|
|
87
136
|
*/
|
|
88
137
|
export function shellConformanceCases(): ShellConformanceCase[] {
|
|
89
138
|
return createCases();
|
package/src/testing/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ export type { PageLike } from "./page.js";
|
|
|
2
2
|
export type { ChromeMeasurement, ExpectedBox, IslandBox } from "./geometry.js";
|
|
3
3
|
export { GEOMETRY_TOLERANCE_PX, expectedChromeBoxes, measureChrome } from "./geometry.js";
|
|
4
4
|
export type {
|
|
5
|
+
AbsentFeature,
|
|
6
|
+
DropFixture,
|
|
7
|
+
DropFixtures,
|
|
5
8
|
OpenContext,
|
|
6
9
|
RegisterShellConformanceOptions,
|
|
7
10
|
ShellCaseOutcome,
|
|
@@ -11,5 +14,6 @@ export type {
|
|
|
11
14
|
ShellSkip,
|
|
12
15
|
ShowHook,
|
|
13
16
|
ShowHooks,
|
|
17
|
+
ToastFixture,
|
|
14
18
|
} from "./harness.js";
|
|
15
19
|
export { registerShellConformance, shellConformanceCases, vsCodeStubSearch } from "./harness.js";
|
|
@@ -51,6 +51,12 @@ export interface PageTools {
|
|
|
51
51
|
injected: Element[];
|
|
52
52
|
cleanups: Array<() => void>;
|
|
53
53
|
armedRoot?: HTMLElement;
|
|
54
|
+
/** Clicks a kit listener counted on a control (the web app's primary action). */
|
|
55
|
+
clicks: number;
|
|
56
|
+
/** Changes of the document's mode the kit records while it switches the web app's appearance. */
|
|
57
|
+
modeWatch?: ModeWatch | undefined;
|
|
58
|
+
/** `newState` of every `beforetoggle` of the web app's toast stack since the kit started listening. */
|
|
59
|
+
toastToggles?: string[] | undefined;
|
|
54
60
|
frame(): Promise<void>;
|
|
55
61
|
settle(): Promise<void>;
|
|
56
62
|
visible(element: Element): boolean;
|
|
@@ -62,6 +68,18 @@ export interface PageTools {
|
|
|
62
68
|
|
|
63
69
|
export type ToolWindow = Window & { __modelerShellConformance?: PageTools };
|
|
64
70
|
|
|
71
|
+
/** One change of `<html>`'s mode or of its meta tags, with the animation frame it landed in. */
|
|
72
|
+
export interface ModeChange {
|
|
73
|
+
part: "theme" | "kontrast" | "color-scheme" | "theme-color" | "no-transition";
|
|
74
|
+
value: string | null;
|
|
75
|
+
frame: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ModeWatch {
|
|
79
|
+
changes: ModeChange[];
|
|
80
|
+
stop(): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
65
83
|
/** Installs the in-page helpers once per document (idempotent; a navigation drops them). */
|
|
66
84
|
export const installPageTools = (_: null): void => {
|
|
67
85
|
const scope = window as ToolWindow;
|
|
@@ -106,6 +124,7 @@ export const installPageTools = (_: null): void => {
|
|
|
106
124
|
errors: [],
|
|
107
125
|
injected: [],
|
|
108
126
|
cleanups: [],
|
|
127
|
+
clicks: 0,
|
|
109
128
|
frame,
|
|
110
129
|
async settle() {
|
|
111
130
|
await frame();
|
|
@@ -209,7 +228,9 @@ export type ChromeTarget =
|
|
|
209
228
|
| "zoom-actual"
|
|
210
229
|
| "zoom-in"
|
|
211
230
|
| "zoom-fit"
|
|
212
|
-
| "canvas"
|
|
231
|
+
| "canvas"
|
|
232
|
+
| "primary"
|
|
233
|
+
| "pill";
|
|
213
234
|
|
|
214
235
|
export const CHROME_TARGET_SELECTORS: Readonly<Record<ChromeTarget, string>> = {
|
|
215
236
|
menu: '[data-chrome="menu"]',
|
|
@@ -220,6 +241,8 @@ export const CHROME_TARGET_SELECTORS: Readonly<Record<ChromeTarget, string>> = {
|
|
|
220
241
|
"zoom-in": '[data-chrome="zoom"] [data-zoom="in"]',
|
|
221
242
|
"zoom-fit": '[data-chrome="zoom"] [data-zoom="fit"]',
|
|
222
243
|
canvas: ".djs-container > svg",
|
|
244
|
+
primary: '[data-chrome="primary"]',
|
|
245
|
+
pill: '[data-chrome="problems"]',
|
|
223
246
|
};
|
|
224
247
|
|
|
225
248
|
export interface TargetFacts {
|
package/src/testing/page.ts
CHANGED
|
@@ -14,4 +14,14 @@ export interface PageLike {
|
|
|
14
14
|
up(): Promise<void>;
|
|
15
15
|
};
|
|
16
16
|
waitForTimeout(timeout: number): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Playwright's `page.emulateMedia`; the web-host cases need it for the system's mode and contrast
|
|
19
|
+
* (`appearance`) and report a skip with `hook: "open"` without it.
|
|
20
|
+
*/
|
|
21
|
+
emulateMedia?(options: {
|
|
22
|
+
colorScheme?: "light" | "dark" | "no-preference" | null;
|
|
23
|
+
contrast?: "more" | "no-preference" | null;
|
|
24
|
+
reducedMotion?: "reduce" | "no-preference" | null;
|
|
25
|
+
forcedColors?: "active" | "none" | null;
|
|
26
|
+
}): Promise<void>;
|
|
17
27
|
}
|