@johnoscott/isometric-engine 0.10.1 → 0.12.6
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/EDITOR-GUIDE.md +12 -1
- package/README.md +1 -1
- package/assets/app.css +37 -0
- package/assets/icons.svg +1 -1
- package/iso-editor.js +182 -182
- package/iso-render.js +105 -105
- package/iso-systems.js +108 -108
- package/js/iso-editor/commands.js +7 -0
- package/js/iso-editor/connections.js +24 -0
- package/js/iso-editor/doc.js +4 -0
- package/js/iso-editor/model.js +17 -3
- package/js/iso-editor/ui/actions.js +22 -24
- package/js/iso-editor/ui/canvas.js +277 -20
- package/js/iso-editor/ui/mount.js +2 -1
- package/js/iso-editor/ui/plain-icons.js +2 -0
- package/js/iso-editor/ui/props.js +2 -2
- package/js/iso-editor/ui/rename.js +114 -0
- package/js/iso-editor/ui/setup.js +3 -1
- package/js/iso-objects/board.js +6 -1
- package/js/iso-objects/scene.js +3 -2
- package/js/iso-viewer/index.js +4 -1
- package/js/iso-viewer/viewport.js +17 -5
- package/package.json +92 -92
- package/src/iso-core/compile-schema.ts +3 -1
- package/src/iso-editor/commands.ts +9 -0
- package/src/iso-editor/connections.ts +28 -0
- package/src/iso-editor/doc.ts +6 -0
- package/src/iso-editor/model.ts +17 -3
- package/src/iso-editor/ui/actions.ts +20 -23
- package/src/iso-editor/ui/app.css +37 -0
- package/src/iso-editor/ui/canvas.ts +214 -25
- package/src/iso-editor/ui/mount.ts +4 -3
- package/src/iso-editor/ui/plain-icons.ts +2 -0
- package/src/iso-editor/ui/props.ts +3 -3
- package/src/iso-editor/ui/rename.ts +105 -0
- package/src/iso-editor/ui/setup.ts +9 -2
- package/src/iso-objects/board.ts +6 -2
- package/src/iso-objects/scene.ts +4 -2
- package/src/iso-viewer/index.ts +2 -2
- package/src/iso-viewer/morph.ts +5 -2
- package/src/iso-viewer/viewport.ts +25 -5
- package/types/iso-core/compile-schema.d.ts +2 -2
- package/types/iso-editor/connections.d.ts +8 -0
- package/types/iso-editor/model.d.ts +8 -2
- package/types/iso-editor/ui/actions.d.ts +5 -2
- package/types/iso-editor/ui/canvas.d.ts +18 -1
- package/types/iso-editor/ui/monaco-entry.d.ts +2 -0
- package/types/iso-editor/ui/mount.d.ts +6 -2
- package/types/iso-editor/ui/props.d.ts +1 -1
- package/types/iso-editor/ui/rename.d.ts +43 -0
- package/types/iso-editor/ui/setup.d.ts +6 -0
- package/types/iso-systems/validate.d.ts +4 -0
- package/types/iso-viewer/bundle.d.ts +1 -0
- package/types/iso-viewer/index.d.ts +2 -2
- package/types/iso-viewer/morph.d.ts +6 -3
- package/types/iso-viewer/viewport.d.ts +13 -1
|
@@ -69,7 +69,7 @@ export interface ShellFeatures {
|
|
|
69
69
|
plan?: { planPanel(el: HTMLElement, o: { has(name: string): boolean; select(name: string): boolean }): { paint(extra: unknown, has: boolean): void } };
|
|
70
70
|
}
|
|
71
71
|
/** what the shell calls on a canvas */
|
|
72
|
-
export interface ShellCanvas { render(model: unknown, data: unknown): Promise<void>; setTheme(t: 'light' | 'dark'): void; fit(): void; focus(): void; dispose(): void }
|
|
72
|
+
export interface ShellCanvas { render(model: unknown, data: unknown): Promise<void>; setTheme(t: 'light' | 'dark'): void; fit(): void; /** (0.12.5) the next drawing is fitted, whatever the person did with the view before */ fitNext?(): void; focus(): void; dispose(): void }
|
|
73
73
|
/** what the domain gives the mounted editor */
|
|
74
74
|
export interface EditorSetup<R, X, A extends object> {
|
|
75
75
|
kit: MountKit<R, X>;
|
|
@@ -184,7 +184,8 @@ export interface EditorState<R = unknown, X = unknown> {
|
|
|
184
184
|
checks: number;
|
|
185
185
|
}
|
|
186
186
|
export interface Editor {
|
|
187
|
-
|
|
187
|
+
/** `fit` (0.12.5): it is another document, so its drawing is fitted once drawn (default: the view stays where it is) */
|
|
188
|
+
getText(): string; setText(text: string, o?: { fit?: boolean }): void; setReadOnly(ro: boolean): void; setTheme(t: Theme): void;
|
|
188
189
|
addFeatures(names: readonly string[]): Promise<void>; fit(): void; dispose(): void;
|
|
189
190
|
}
|
|
190
191
|
|
|
@@ -651,7 +652,7 @@ export function mountEditor<R, X, A extends object = object>(el: HTMLElement, op
|
|
|
651
652
|
return {
|
|
652
653
|
internal,
|
|
653
654
|
getText: () => doc.text,
|
|
654
|
-
setText(text: string) { hideBanner(); doc.load(text); doc.markClean(); paintTitle(); paintHistory(); },
|
|
655
|
+
setText(text: string, o: { fit?: boolean } = {}) { hideBanner(); if (o.fit && !disposed) canvas.fitNext?.(); doc.load(text); doc.markClean(); paintTitle(); paintHistory(); },
|
|
655
656
|
setReadOnly,
|
|
656
657
|
setTheme,
|
|
657
658
|
addFeatures,
|
|
@@ -52,6 +52,7 @@ export const PLAIN_ICON_SVG: Record<string, string> = {
|
|
|
52
52
|
'arrow-up-right': '<path d="M7 7h10v10" /> <path d="M7 17 17 7" />',
|
|
53
53
|
'box': '<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" /> <path d="m3.3 7 8.7 5 8.7-5" /> <path d="M12 22V12" />',
|
|
54
54
|
'chevron-down': '<path d="m6 9 6 6 6-6" />',
|
|
55
|
+
'chevron-left': '<path d="m15 18-6-6 6-6" />',
|
|
55
56
|
'chevron-right': '<path d="m9 18 6-6-6-6" />',
|
|
56
57
|
'circle-dot': '<circle cx="12" cy="12" r="1" /> <circle cx="12" cy="12" r="10" />',
|
|
57
58
|
'circle-x': '<circle cx="12" cy="12" r="10" /> <path d="m15 9-6 6" /> <path d="m9 9 6 6" />',
|
|
@@ -67,6 +68,7 @@ export const PLAIN_ICON_SVG: Record<string, string> = {
|
|
|
67
68
|
'pencil': '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /> <path d="m15 5 4 4" />',
|
|
68
69
|
'plus': '<path d="M5 12h14" /> <path d="M12 5v14" />',
|
|
69
70
|
'rotate-ccw': '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> <path d="M3 3v5h5" />',
|
|
71
|
+
'search': '<path d="m21 21-4.34-4.34" /> <circle cx="11" cy="11" r="8" />',
|
|
70
72
|
'trash-2': '<path d="M10 11v6" /> <path d="M14 11v6" /> <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /> <path d="M3 6h18" /> <path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',
|
|
71
73
|
'triangle-alert': '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" /> <path d="M12 9v4" /> <path d="M12 17h.01" />',
|
|
72
74
|
'x': '<path d="M18 6 6 18" /> <path d="m6 6 12 12" />',
|
|
@@ -38,7 +38,7 @@ export interface PropsUi {
|
|
|
38
38
|
/** what the panel is given of the domain */
|
|
39
39
|
export interface PropsKit {
|
|
40
40
|
commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertItemCmd' | 'referencesTo' | 'describe'>;
|
|
41
|
-
actions: Pick<Actions, 'deletePaths' | '
|
|
41
|
+
actions: Pick<Actions, 'deletePaths' | 'rename'>;
|
|
42
42
|
slotAt(ptr: string): RefSlot | undefined;
|
|
43
43
|
objectOf(ptr: string): ObjectRef | undefined;
|
|
44
44
|
kinds: ObjectKindInfo[];
|
|
@@ -67,7 +67,7 @@ export function propsPanel(body: HTMLElement, doc: EditorModel, opts: PropsOpts)
|
|
|
67
67
|
let focusInput = false;
|
|
68
68
|
const K = opts.kit, ui = K.ui;
|
|
69
69
|
const { setCmd, deleteCmd, insertItemCmd, referencesTo, describe } = K.commands;
|
|
70
|
-
const { deletePaths,
|
|
70
|
+
const { deletePaths, rename } = K.actions;
|
|
71
71
|
const kindOf = (k: string) => K.kinds.find(x => x.kind === k);
|
|
72
72
|
const singular = (k: string) => kindOf(k)?.singular ?? 'item';
|
|
73
73
|
|
|
@@ -101,7 +101,7 @@ export function propsPanel(body: HTMLElement, doc: EditorModel, opts: PropsOpts)
|
|
|
101
101
|
if (!r) { settings(p); return; }
|
|
102
102
|
const head = h('div', { class: 'sel-headrow' }, h('div', { class: 'sel-title' }, describe(target)));
|
|
103
103
|
const rn = h('button', { type: 'button', class: 'btn sm quiet icon-only', 'aria-label': `Rename ${describe(target)}`, title: 'Rename (F2)' }, icon('pencil'));
|
|
104
|
-
rn.addEventListener('click', () =>
|
|
104
|
+
rn.addEventListener('click', () => void rename(doc, target, 'props', opts.note, { over: true, place: () => (head.isConnected ? head.firstElementChild!.getBoundingClientRect() : undefined) }));
|
|
105
105
|
head.append(rn);
|
|
106
106
|
body.append(head);
|
|
107
107
|
if (toPointer(p) !== r.path) pendingFocus = toPointer(p);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The inline name field (0.12.5): a small text field just above a thing (on the canvas it follows the thing through pan and
|
|
2
|
+
// zoom), the name selected, so typing replaces it. Nothing modal: no backdrop, and what is under it stays live. Enter commits, and so
|
|
3
|
+
// does a press anywhere else or the focus going elsewhere, when the name is a good one (a bad one is dropped, the name as
|
|
4
|
+
// it was); Esc dismisses. What is wrong with a name shows under the field, and Enter then does nothing.
|
|
5
|
+
|
|
6
|
+
import { h } from './icons.ts';
|
|
7
|
+
import { layer } from './layer.ts';
|
|
8
|
+
|
|
9
|
+
export interface RenameAt {
|
|
10
|
+
/** where the thing is on the page now (asked each frame while the field is open); undefined: not drawn */
|
|
11
|
+
place(): { left: number; top: number; width: number; height: number } | undefined;
|
|
12
|
+
/** over the thing's own words, from their left edge (a heading), not above it */
|
|
13
|
+
over?: boolean;
|
|
14
|
+
/** what the field stays inside, on the page (default: the window) */
|
|
15
|
+
bounds?(): { left: number; top: number; right: number; bottom: number };
|
|
16
|
+
/** where it is until the thing is drawn */
|
|
17
|
+
at?: { x: number; y: number };
|
|
18
|
+
/** a press in here saves the name once it is released (the press may be on the thing itself, or drag it: it goes by the
|
|
19
|
+
* name it has); anywhere else at once, before what was pressed acts (Save, Undo) */
|
|
20
|
+
late?: HTMLElement;
|
|
21
|
+
/** what such a press started (a drag of the thing) isn't over yet: the name waits for it */
|
|
22
|
+
busy?(): boolean;
|
|
23
|
+
/** what has the focus after Enter or Esc (default: what had it) */
|
|
24
|
+
back?: HTMLElement;
|
|
25
|
+
}
|
|
26
|
+
export interface RenameField {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
/** what is wrong with a name ('' : nothing) */
|
|
30
|
+
wrong(v: string): string;
|
|
31
|
+
/** Enter on a good name that isn't the one there */
|
|
32
|
+
commit(v: string): void;
|
|
33
|
+
/** false: the thing is gone, and the field with it */
|
|
34
|
+
alive?(): boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let open: { close(): void } | undefined;
|
|
38
|
+
export const renameOpen = () => !!open;
|
|
39
|
+
|
|
40
|
+
/** Open the field; resolves with the name committed, or undefined when dismissed. */
|
|
41
|
+
export function renameField(f: RenameField, at: RenameAt): Promise<string | undefined> {
|
|
42
|
+
open?.close();
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
const back = at.back ?? (document.activeElement as HTMLElement | null);
|
|
45
|
+
const id = `rename-${Math.random().toString(36).slice(2, 8)}`;
|
|
46
|
+
const input = h('input', { type: 'text', class: 'rename-input', 'aria-label': f.label, 'aria-describedby': id, spellcheck: 'false', autocomplete: 'off', autocapitalize: 'off' });
|
|
47
|
+
const why = h('p', { class: 'rename-error', role: 'alert', id });
|
|
48
|
+
const box = h('div', { class: `rename-field${at.over ? ' over' : ''}` }, input, why);
|
|
49
|
+
input.value = f.value;
|
|
50
|
+
const fitWidth = () => { input.size = Math.max(8, Math.min(40, input.value.length + 1)); };
|
|
51
|
+
fitWidth();
|
|
52
|
+
layer().append(box);
|
|
53
|
+
let done = false, frame = 0, seen = at.at ? { left: at.at.x, top: at.at.y, width: 0, height: 0 } : undefined;
|
|
54
|
+
const put = () => {
|
|
55
|
+
const p = at.place();
|
|
56
|
+
if (p) seen = p;
|
|
57
|
+
const b = at.bounds?.() ?? { left: 0, top: 0, right: innerWidth, bottom: innerHeight }, r = input.getBoundingClientRect();
|
|
58
|
+
const t = seen ?? { left: (b.left + b.right) / 2, top: b.top + 48, width: 0, height: 0 };
|
|
59
|
+
const within = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(v, Math.max(lo, hi)));
|
|
60
|
+
box.style.left = `${within(at.over ? t.left - 8 : t.left + t.width / 2 - r.width / 2, b.left + 4, b.right - r.width - 4)}px`;
|
|
61
|
+
box.style.top = `${within(at.over ? t.top + t.height / 2 - r.height / 2 : t.top - r.height - 8, b.top + 4, b.bottom - r.height - 4)}px`;
|
|
62
|
+
};
|
|
63
|
+
const follow = () => { if (done) return; if (f.alive && !f.alive()) { end(undefined, false); return; } put(); frame = requestAnimationFrame(follow); };
|
|
64
|
+
const check = () => {
|
|
65
|
+
const bad = f.wrong(input.value.trim());
|
|
66
|
+
why.textContent = bad;
|
|
67
|
+
input.setAttribute('aria-invalid', String(!!bad));
|
|
68
|
+
return bad;
|
|
69
|
+
};
|
|
70
|
+
/** the name to save: a good one that isn't the one there */
|
|
71
|
+
const good = () => { const v = input.value.trim(); return v !== f.value && !f.wrong(v) ? v : undefined; };
|
|
72
|
+
function end(v: string | undefined, focusBack: boolean, late = false) {
|
|
73
|
+
if (done) return;
|
|
74
|
+
done = true;
|
|
75
|
+
cancelAnimationFrame(frame);
|
|
76
|
+
removeEventListener('pointerdown', outside, true);
|
|
77
|
+
box.remove();
|
|
78
|
+
open = undefined;
|
|
79
|
+
if (focusBack && back?.isConnected) back.focus({ preventScroll: true });
|
|
80
|
+
const save = () => { if (v !== undefined && (!f.alive || f.alive())) f.commit(v); resolve(v); };
|
|
81
|
+
if (!late || v === undefined) { save(); return; }
|
|
82
|
+
const up = () => { removeEventListener('pointerup', up, true); removeEventListener('pointercancel', up, true); setTimeout(wait, 0); };
|
|
83
|
+
const wait = () => { if (at.busy?.()) setTimeout(wait, 20); else save(); };
|
|
84
|
+
addEventListener('pointerup', up, true); addEventListener('pointercancel', up, true);
|
|
85
|
+
}
|
|
86
|
+
const outside = (e: Event) => { if (!box.contains(e.target as Node)) end(good(), false, !!at.late?.contains(e.target as Node)); };
|
|
87
|
+
addEventListener('pointerdown', outside, true);
|
|
88
|
+
input.addEventListener('input', () => { fitWidth(); check(); });
|
|
89
|
+
input.addEventListener('keydown', e => {
|
|
90
|
+
// ⌘S saves the file, with the name
|
|
91
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 's') { end(good(), true); return; }
|
|
92
|
+
e.stopPropagation(); // the keys are the field's: ⌘Z, Delete and the arrows never reach the canvas
|
|
93
|
+
if (e.isComposing) return;
|
|
94
|
+
if (e.key === 'Escape') { e.preventDefault(); end(undefined, true); }
|
|
95
|
+
if (e.key === 'Enter') { e.preventDefault(); const v = input.value.trim(); if (!check()) end(v === f.value ? undefined : v, true); }
|
|
96
|
+
});
|
|
97
|
+
input.addEventListener('keyup', e => e.stopPropagation());
|
|
98
|
+
// the focus gone elsewhere in the page (not with the window: coming back, the field is as it was)
|
|
99
|
+
input.addEventListener('blur', () => setTimeout(() => { if (!done && document.hasFocus() && document.activeElement !== input && document.activeElement !== document.body) end(good(), false); }, 0));
|
|
100
|
+
open = { close: () => end(undefined, false) };
|
|
101
|
+
follow();
|
|
102
|
+
input.focus({ preventScroll: true });
|
|
103
|
+
input.select();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -52,7 +52,12 @@ export interface DomainView<R, D extends CanvasDrawing> {
|
|
|
52
52
|
keymap?: KeyGroup[];
|
|
53
53
|
/** (0.10.0) the palette's entries: presets of a kind, each with its label, icon, what a new one starts as (a copy of
|
|
54
54
|
* `value`; default: the kind's template) and the base of its fresh name. None: one entry per kind, as before */
|
|
55
|
-
palette?: { kind: string; label: string; icon?: string; value?: unknown; name?: string }[];
|
|
55
|
+
palette?: { kind: string; label: string; icon?: string; value?: unknown; name?: string; section?: string }[];
|
|
56
|
+
/** (0.12.0) the palette 'floating' over the canvas (the default) or 'docked': a pane of its own at the canvas's left,
|
|
57
|
+
* searchable by label and section, resizable and collapsible */
|
|
58
|
+
paletteLayout?: 'floating' | 'docked';
|
|
59
|
+
/** (0.12.5) what a double click on an object of the canvas does: shows it in the text (the default), or renames it */
|
|
60
|
+
doubleClick?: 'text' | 'rename';
|
|
56
61
|
/** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
|
|
57
62
|
flat?: CanvasKit<R, D>['flat'];
|
|
58
63
|
/** a layer over the canvas, and a part beside the views (A: their calls) */
|
|
@@ -106,8 +111,10 @@ export function setupFor<R, D extends CanvasDrawing>(a: DomainAdapter, v: Domain
|
|
|
106
111
|
const canvasUi: CanvasUi = {
|
|
107
112
|
rootClass: 'iso-canvas', panKeyClass: 'pan-key', newOrder: a.kinds.map(k => k.kind),
|
|
108
113
|
palette: v.palette
|
|
109
|
-
? v.palette.map(e => ({ kind: e.kind, label: e.label, icon: (e.icon ?? icon(e.kind)) as IconName, name: e.name, ...(e.value === undefined ? {} : { value: () => structuredClone(e.value) }) }))
|
|
114
|
+
? v.palette.map(e => ({ kind: e.kind, label: e.label, icon: (e.icon ?? icon(e.kind)) as IconName, name: e.name, ...(e.section === undefined ? {} : { section: e.section }), ...(e.value === undefined ? {} : { value: () => structuredClone(e.value) }) }))
|
|
110
115
|
: a.kinds.map(k => ({ kind: k.kind, icon: icon(k.kind), label: k.singular[0].toUpperCase() + k.singular.slice(1) })),
|
|
116
|
+
...(v.paletteLayout === undefined ? {} : { paletteLayout: v.paletteLayout }),
|
|
117
|
+
...(v.doubleClick === undefined ? {} : { doubleClick: v.doubleClick }),
|
|
111
118
|
text: {
|
|
112
119
|
stage: 'The file, drawn: arrow keys and Tab move through what is drawn; + and − zoom, 0 fits', dragGroup: 'A drag on nothing',
|
|
113
120
|
dragSelectTip: 'Drag draws a selection; hold the space key to pan', unreadable: 'The canvas draws a file that reads cleanly; fix the problems listed to see it.',
|
package/src/iso-objects/board.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// card above it, and its column one right of every card left of it, asked of the two things that part them (so each
|
|
6
6
|
// container's rows and columns are its own, and near-aligned boxes share them); a card in no region keeps its place
|
|
7
7
|
// across. Two cards in one cell get a column each. A region (or a node
|
|
8
|
-
// holding nodes) is a panel over the cells of what it holds; one holding nothing has no cell and isn't shown
|
|
8
|
+
// holding nodes) is a panel over the cells of what it holds; one holding nothing has no cell and isn't shown (in a
|
|
9
|
+
// drawing with no nodes at all, the innermost regions are the cards). Routes
|
|
9
10
|
// are links, their ends' sides dropped. What 2D leaves out: sizes (every card is the same size), heights, a route's
|
|
10
11
|
// sides and via points, a region's label style.
|
|
11
12
|
|
|
@@ -22,7 +23,9 @@ import { placeBoard, type Board, type BoardCard, type BoardLink, type BoardPanel
|
|
|
22
23
|
export function boardOf(scene: CompiledScene, visible: (id: string) => boolean = () => true): Required<Board> {
|
|
23
24
|
const items = scene.layout.items.filter(p => visible(p.id));
|
|
24
25
|
const cat = scene.layout.catalog;
|
|
25
|
-
|
|
26
|
+
// (0.12.2) a drawing of regions alone has no nodes to be cards: its innermost regions are (else 2D would be empty)
|
|
27
|
+
const bare = !scene.layout.items.some(p => p.type === 'node');
|
|
28
|
+
const isCard = (p: Placed) => (bare ? !p.children.some(c => visible(c.id)) : p.type === 'node' && !p.children.some(c => c.type === 'node' && visible(c.id)));
|
|
26
29
|
const cardsP = items.filter(isCard);
|
|
27
30
|
// rows and columns: a card is a row below every card above it, and a column right of every card left of it, asked of
|
|
28
31
|
// the two things that part them (the children of their nearest common container holding each: their regions, or the
|
|
@@ -68,6 +71,7 @@ export function boardOf(scene: CompiledScene, visible: (id: string) => boolean =
|
|
|
68
71
|
} else taken.set(String(c), p.id);
|
|
69
72
|
}
|
|
70
73
|
const cards: BoardCard[] = cardsP.map(p => {
|
|
74
|
+
if (p.region) { const r = p.region; return { id: p.id, label: r.label ?? p.id, sub: undefined, role: r.role ?? regionKind(cat, r.kind)?.role ?? 'grey', ghost: r.ghost || undefined, cell: cell.get(p.id)! }; }
|
|
71
75
|
const n = p.node!, a = nodeKindOr(cat, n.asset);
|
|
72
76
|
return { id: p.id, label: n.label ?? p.id, sub: n.sub, role: n.role ?? a.role, ghost: n.ghost || undefined, cell: cell.get(p.id)! };
|
|
73
77
|
});
|
package/src/iso-objects/scene.ts
CHANGED
|
@@ -183,8 +183,10 @@ function drawFlatRegion(k: Kernel, cat: KindCatalog, r: Placed, vis: Attrs, grid
|
|
|
183
183
|
const style = R['label-style'] ?? rk?.labelStyle;
|
|
184
184
|
if (R.label && style !== 'none') {
|
|
185
185
|
if (style === 'face') {
|
|
186
|
-
|
|
187
|
-
const
|
|
186
|
+
// (0.12.2) a thin slab's face can't hold the large name: it has the small one, in the middle of the face
|
|
187
|
+
const h = b.z1 - b.z0, cap = (f: { size: number }) => (f.size * 0.73) / S, thin = shape === 'slab' && 0.28 + cap(FONTS.slabname) + 0.08 > h;
|
|
188
|
+
const big = shape === 'slab' && !thin;
|
|
189
|
+
const z = big ? b.z0 + 0.28 : thin ? b.z0 + Math.max(0.02, (h - cap(FONTS.sm)) / 2) : b.z0 + Math.min(0.1, h * 0.25);
|
|
188
190
|
s += tag('g', attrs, k.faceText(b.x0 + (big ? 0.6 : 0.3), b.y1, z, R.label, big ? 'slabname' : 'slabname sm', big ? FONTS.slabname : FONTS.sm, 'left', 'start'));
|
|
189
191
|
} else if (style === 'face-right') {
|
|
190
192
|
s += tag('g', attrs, k.faceText(b.x1, b.y0 + 0.6, b.z0 + Math.max(0.14, (b.z1 - b.z0) * 0.2), R.label, 'slabname', FONTS.slabname, 'right', 'end'));
|
package/src/iso-viewer/index.ts
CHANGED
|
@@ -36,5 +36,5 @@ export { flatSvg, flatCss, measureIn, rectOf } from './flat-view.ts';
|
|
|
36
36
|
export type { FlatStyle } from './flat-view.ts';
|
|
37
37
|
export { dualView, storedMode, viewToggle, DUAL_VIEW_CSS } from './dual-view.ts';
|
|
38
38
|
export type { ViewMode, DualViewOptions, DualView } from './dual-view.ts';
|
|
39
|
-
export { morphSvgs, markConnectors } from './morph.ts';
|
|
40
|
-
export type { SvgMorph } from './morph.ts';
|
|
39
|
+
export { morphSvgs, markConnectors, buildLayer, ease, clamp } from './morph.ts';
|
|
40
|
+
export type { SvgMorph, MorphLayer } from './morph.ts';
|
package/src/iso-viewer/morph.ts
CHANGED
|
@@ -91,8 +91,11 @@ function topFace(g: Element, origin: DOMRect): { pts: [number, number][]; fill:
|
|
|
91
91
|
return pts.length === 4 ? { pts, fill: getComputedStyle(poly).fill } : undefined;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
/**
|
|
95
|
-
export
|
|
94
|
+
/** a morph's layer: append `svg` to the root; `at(t)` paints it t (0 to 1) of the way, in any order (no clock) */
|
|
95
|
+
export interface MorphLayer { svg: SVGSVGElement; at(t: number): void }
|
|
96
|
+
/** the layer a morph draws on: `at(t)` paints it t of the way from one view to the other. Both views are in the root and
|
|
97
|
+
* laid out (hidden is fine, display: none is not): a host seeks it frame by frame (0.12.2: exported). */
|
|
98
|
+
export function buildLayer(root: HTMLElement, fromSvg: SVGSVGElement, toSvg: SVGSVGElement, from: ViewMode): MorphLayer {
|
|
96
99
|
const origin = root.getBoundingClientRect();
|
|
97
100
|
const layer = document.createElementNS(NS, 'svg') as SVGSVGElement;
|
|
98
101
|
layer.setAttribute('class', 'dual-morph');
|
|
@@ -6,6 +6,24 @@
|
|
|
6
6
|
// Moved here from the editor canvas (R1 S4); the canvas owns the drawing, the overlay and the pointer.
|
|
7
7
|
|
|
8
8
|
export type View = { x: number; y: number; w: number; h: number };
|
|
9
|
+
/** (0.12.6) how far inside the stage what must be on it is, px */
|
|
10
|
+
const INSET = 6;
|
|
11
|
+
/** What a fit makes of a stage (px) and what it frames, `box` PAD px inside it, and what must be on it too, `also` INSET px inside:
|
|
12
|
+
* the zoom and the middle. Pure. */
|
|
13
|
+
export function fitted(s: { w: number; h: number }, box: View, also?: View): { k: number; cx: number; cy: number } {
|
|
14
|
+
const pad = 24;
|
|
15
|
+
// along one axis: the most zoom that `box`, and `also`, and the one's end and the other's together, allow
|
|
16
|
+
const most = (len: number, a0: number, a1: number, b0?: number, b1?: number) => Math.min((len - pad * 2) / (a1 - a0), ...(b0 === undefined || b1 === undefined ? [] : [[b1 - b0, INSET * 2], [b1 - a0, pad + INSET], [a1 - b0, pad + INSET]].map(([d, edges]) => (d > 0 ? (len - edges) / d : Infinity))));
|
|
17
|
+
const k = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Math.min(most(s.w, box.x, box.x + box.w, also?.x, also && also.x + also.w), most(s.h, box.y, box.y + box.h, also?.y, also && also.y + also.h))));
|
|
18
|
+
// the middle of `box`, moved only as far as `also` needs
|
|
19
|
+
const middle = (len: number, a0: number, a1: number, b0?: number, b1?: number) => {
|
|
20
|
+
const c = (a0 + a1) / 2;
|
|
21
|
+
if (b0 === undefined || b1 === undefined) return c;
|
|
22
|
+
const lo = b1 - (len / 2 - INSET) / k, hi = b0 + (len / 2 - INSET) / k;
|
|
23
|
+
return lo > hi ? (lo + hi) / 2 : Math.max(lo, Math.min(hi, c));
|
|
24
|
+
};
|
|
25
|
+
return { k, cx: middle(s.w, box.x, box.x + box.w, also?.x, also && also.x + also.w), cy: middle(s.h, box.y, box.y + box.h, also?.y, also && also.y + also.h) };
|
|
26
|
+
}
|
|
9
27
|
export const MIN_ZOOM = 0.1, MAX_ZOOM = 8;
|
|
10
28
|
|
|
11
29
|
export interface ViewportOpts {
|
|
@@ -17,6 +35,8 @@ export interface ViewportOpts {
|
|
|
17
35
|
onRezoom(): void;
|
|
18
36
|
/** what a fit frames (the drawing's own things, the overlay's shown marks), if not the whole scene */
|
|
19
37
|
itemsBox(): View | undefined;
|
|
38
|
+
/** (0.12.6) what must be on the stage too when the things are fitted (the connectors), a few px from its edges */
|
|
39
|
+
alsoBox?(): View | undefined;
|
|
20
40
|
/** the overlay has marks that keep their size on screen (a fit repeats while they are showing) */
|
|
21
41
|
marksShowing(): boolean;
|
|
22
42
|
}
|
|
@@ -59,11 +79,11 @@ export function viewport(host: HTMLElement, o: ViewportOpts) {
|
|
|
59
79
|
view = { x: p.x - (px - r.left) / nk, y: p.y - (py - r.top) / nk, w: s.w / nk, h: s.h / nk };
|
|
60
80
|
applyView();
|
|
61
81
|
}
|
|
62
|
-
|
|
82
|
+
/** `also` (0.12.6): what must be on the stage too, INSET px from its edges, and nothing more: the zoom and the middle change only as
|
|
83
|
+
* much as that takes (not at all where it is inside already) */
|
|
84
|
+
function fit(box = full, also?: View) {
|
|
63
85
|
if (!box) return;
|
|
64
|
-
const s = size(),
|
|
65
|
-
const k = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Math.min((s.w - pad * 2) / box.w, (s.h - pad * 2) / box.h)));
|
|
66
|
-
const cx = box.x + box.w / 2, cy = box.y + box.h / 2;
|
|
86
|
+
const s = size(), { k, cx, cy } = fitted(s, box, also);
|
|
67
87
|
const next = { x: cx - s.w / k / 2, y: cy - s.h / k / 2, w: s.w / k, h: s.h / k };
|
|
68
88
|
// v0.4.2: a fit that lands where the view already is (a refit after a resize that changed nothing it fits) leaves
|
|
69
89
|
// it alone: no new zoom by a rounding error, so nothing on the overlay is redrawn
|
|
@@ -82,7 +102,7 @@ export function viewport(host: HTMLElement, o: ViewportOpts) {
|
|
|
82
102
|
if (key === last) break;
|
|
83
103
|
last = key;
|
|
84
104
|
const m = Math.max(24, Math.min(b.w, b.h) * 0.06);
|
|
85
|
-
quietly(() => fit({ x: b.x - m, y: b.y - m, w: b.w + m * 2, h: b.h + m * 2 }));
|
|
105
|
+
quietly(() => fit({ x: b.x - m, y: b.y - m, w: b.w + m * 2, h: b.h + m * 2 }, o.alsoBox?.()));
|
|
86
106
|
// the marks are redrawn for a new zoom only past the same 2% the zoom itself uses (applyView's rezoom)
|
|
87
107
|
if (!o.marksShowing() || !paintedK || Math.abs(scale() / paintedK - 1) <= 0.02) break;
|
|
88
108
|
cancelAnimationFrame(rezoom); rezoom = 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Ajv2020 as Ajv2020Class } from 'ajv/dist/2020.js';
|
|
2
2
|
import type { ValidateFunction } from 'ajv';
|
|
3
|
-
export declare const Ajv2020: typeof
|
|
3
|
+
export declare const Ajv2020: typeof Ajv2020Class;
|
|
4
4
|
export declare const AJV_OPTIONS: {
|
|
5
5
|
readonly allErrors: true;
|
|
6
6
|
readonly verbose: true;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** path → route id, in the file's order as the drawing maps it */
|
|
2
|
+
export declare function connectionsOf(pathOf: ReadonlyMap<string, string>, isRoute: (id: string) => boolean, objectOf: (ptr: string) => unknown): Map<string, string>;
|
|
3
|
+
/** the nearest point of a polyline path ("M x,y L x,y …", the numbers taken in pairs) to a point */
|
|
4
|
+
export declare function nearestOn(d: string, x: number, y: number): {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
dist: number;
|
|
8
|
+
} | undefined;
|
|
@@ -9,6 +9,8 @@ export interface Command {
|
|
|
9
9
|
build(text: string): Splice;
|
|
10
10
|
/** the paths it touched (for the views to refresh and reveal) */
|
|
11
11
|
touched?: Path[];
|
|
12
|
+
/** (0.12.5) the label of the step it joined (apply's `joins`), given the step's own */
|
|
13
|
+
joined?(label: string): string;
|
|
12
14
|
/** where a path is after the change (a rename moves paths); null when it no longer exists */
|
|
13
15
|
remap?(p: Path): Path | null;
|
|
14
16
|
/** the selection afterwards (default: the old one, remapped) */
|
|
@@ -68,8 +70,10 @@ export declare class EditorModel {
|
|
|
68
70
|
/** A new file: the text, an empty history, clean. */
|
|
69
71
|
load(text: string, origin?: Origin): void;
|
|
70
72
|
private set;
|
|
71
|
-
/** Run a command: build it against the text, apply its steps, push it. Returns false if it changed nothing.
|
|
72
|
-
|
|
73
|
+
/** Run a command: build it against the text, apply its steps, push it. Returns false if it changed nothing. `joins`
|
|
74
|
+
* (0.12.5): the id of an undo step it is part of, when that is the last one, nothing was undone since and the file
|
|
75
|
+
* wasn't saved at it (the saved text must stay a step of its own to come back to). */
|
|
76
|
+
apply(cmd: Command, origin?: Origin, joins?: number): boolean;
|
|
73
77
|
/**
|
|
74
78
|
* Text the user typed (one change from the text pane: edits against the text before it). The view has already
|
|
75
79
|
* made the change; the model takes it, and coalesces typing into one command per word or pause.
|
|
@@ -84,6 +88,8 @@ export declare class EditorModel {
|
|
|
84
88
|
private push;
|
|
85
89
|
get canUndo(): boolean;
|
|
86
90
|
get canRedo(): boolean;
|
|
91
|
+
/** the last undo step's id (what `apply` may join) */
|
|
92
|
+
get undoId(): number;
|
|
87
93
|
get undoLabel(): string;
|
|
88
94
|
get redoLabel(): string;
|
|
89
95
|
undo(): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RenameAt } from './rename.js';
|
|
1
2
|
import type { EditorModel, Command } from '../model.js';
|
|
2
3
|
import type { Commands } from '../commands.js';
|
|
3
4
|
import type { ObjectKindInfo, ObjectRef } from '../adapter.js';
|
|
@@ -10,13 +11,15 @@ export interface ActionsKit {
|
|
|
10
11
|
nameRule: RegExp;
|
|
11
12
|
nameHint: string;
|
|
12
13
|
}
|
|
13
|
-
export declare function run(doc: EditorModel, c: Command, origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void): boolean;
|
|
14
|
+
export declare function run(doc: EditorModel, c: Command, origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void, joins?: number): boolean;
|
|
14
15
|
/** Several commands as one undo step. */
|
|
15
16
|
export declare function composite(label: string, cmds: Command[]): Command;
|
|
16
17
|
/** The shared actions, for one domain. */
|
|
17
18
|
export declare function actionsFor(kit: ActionsKit): {
|
|
18
19
|
deletePaths: (doc: EditorModel, paths: Path[], origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void) => Promise<boolean>;
|
|
19
|
-
|
|
20
|
+
rename: (doc: EditorModel, path: Path, origin: 'canvas' | 'props' | 'menu', note: ((t: string, tone?: 'bad') => void) | undefined, at: RenameAt & {
|
|
21
|
+
joins?: number;
|
|
22
|
+
}) => Promise<boolean>;
|
|
20
23
|
duplicate: (doc: EditorModel, path: Path, origin: 'canvas' | 'menu', note?: (t: string, tone?: 'bad') => void) => void;
|
|
21
24
|
connected: (doc: EditorModel, paths: Path[]) => Path[];
|
|
22
25
|
};
|
|
@@ -86,6 +86,12 @@ export interface CanvasUi {
|
|
|
86
86
|
/** the palette's entries: a kind, and (0.10.0) a preset: what a new one starts as (default: the kind's template) and
|
|
87
87
|
* the base of its fresh name (default: the kind's singular) */
|
|
88
88
|
palette: PaletteItem[];
|
|
89
|
+
/** (0.12.0) where the palette is: 'floating' (the default: over the canvas, at its top left) or 'docked' (a pane of
|
|
90
|
+
* its own at the canvas's left, with a search box filtering by label and section, resizable and collapsible; its
|
|
91
|
+
* width and whether it is collapsed are kept in the host's store as `canvas-palette-dock`) */
|
|
92
|
+
paletteLayout?: 'floating' | 'docked';
|
|
93
|
+
/** (0.12.5) what a double click on an object does: shows it in the text (the default), or renames it */
|
|
94
|
+
doubleClick?: 'text' | 'rename';
|
|
89
95
|
text: {
|
|
90
96
|
stage: string;
|
|
91
97
|
dragGroup: string;
|
|
@@ -104,6 +110,10 @@ export interface PaletteItem {
|
|
|
104
110
|
label: string;
|
|
105
111
|
value?(): unknown;
|
|
106
112
|
name?: string;
|
|
113
|
+
/** (0.11.0) the header it is listed under: entries with one are grouped by it, in order of first use, each group under
|
|
114
|
+
* a header that collapses (all collapsed but the one last added from, remembered in the host's store as
|
|
115
|
+
* `canvas-palette`); entries without one are listed as before, where they are */
|
|
116
|
+
section?: string;
|
|
107
117
|
}
|
|
108
118
|
/** what the canvas is given of the domain (M: the domain's reading of the file; D: its drawing) */
|
|
109
119
|
export interface CanvasKit<M, D extends CanvasDrawing> {
|
|
@@ -195,7 +205,8 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
|
|
|
195
205
|
setTheme: (_t: 'light' | 'dark') => void;
|
|
196
206
|
paintOverlay: () => void;
|
|
197
207
|
fit: () => void;
|
|
198
|
-
|
|
208
|
+
fitNext(): void;
|
|
209
|
+
fitAll: (box?: View | undefined, also?: View) => void;
|
|
199
210
|
actual: () => void;
|
|
200
211
|
zoomAt: (f: number, cx?: number, cy?: number) => void;
|
|
201
212
|
itemsBox: () => {
|
|
@@ -204,6 +215,12 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
|
|
|
204
215
|
w: number;
|
|
205
216
|
h: number;
|
|
206
217
|
} | undefined;
|
|
218
|
+
routesBox: () => {
|
|
219
|
+
x: number;
|
|
220
|
+
y: number;
|
|
221
|
+
w: number;
|
|
222
|
+
h: number;
|
|
223
|
+
} | undefined;
|
|
207
224
|
readonly moved: boolean;
|
|
208
225
|
settled: () => Promise<void>;
|
|
209
226
|
readonly zoom: number;
|
|
@@ -85,7 +85,8 @@ export interface ShellFeatures {
|
|
|
85
85
|
export interface ShellCanvas {
|
|
86
86
|
render(model: unknown, data: unknown): Promise<void>;
|
|
87
87
|
setTheme(t: 'light' | 'dark'): void;
|
|
88
|
-
fit(): void;
|
|
88
|
+
fit(): void; /** (0.12.5) the next drawing is fitted, whatever the person did with the view before */
|
|
89
|
+
fitNext?(): void;
|
|
89
90
|
focus(): void;
|
|
90
91
|
dispose(): void;
|
|
91
92
|
}
|
|
@@ -131,8 +132,11 @@ export interface EditorState<R = unknown, X = unknown> {
|
|
|
131
132
|
checks: number;
|
|
132
133
|
}
|
|
133
134
|
export interface Editor {
|
|
135
|
+
/** `fit` (0.12.5): it is another document, so its drawing is fitted once drawn (default: the view stays where it is) */
|
|
134
136
|
getText(): string;
|
|
135
|
-
setText(text: string
|
|
137
|
+
setText(text: string, o?: {
|
|
138
|
+
fit?: boolean;
|
|
139
|
+
}): void;
|
|
136
140
|
setReadOnly(ro: boolean): void;
|
|
137
141
|
setTheme(t: Theme): void;
|
|
138
142
|
addFeatures(names: readonly string[]): Promise<void>;
|
|
@@ -34,7 +34,7 @@ export interface PropsUi {
|
|
|
34
34
|
/** what the panel is given of the domain */
|
|
35
35
|
export interface PropsKit {
|
|
36
36
|
commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertItemCmd' | 'referencesTo' | 'describe'>;
|
|
37
|
-
actions: Pick<Actions, 'deletePaths' | '
|
|
37
|
+
actions: Pick<Actions, 'deletePaths' | 'rename'>;
|
|
38
38
|
slotAt(ptr: string): RefSlot | undefined;
|
|
39
39
|
objectOf(ptr: string): ObjectRef | undefined;
|
|
40
40
|
kinds: ObjectKindInfo[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface RenameAt {
|
|
2
|
+
/** where the thing is on the page now (asked each frame while the field is open); undefined: not drawn */
|
|
3
|
+
place(): {
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
} | undefined;
|
|
9
|
+
/** over the thing's own words, from their left edge (a heading), not above it */
|
|
10
|
+
over?: boolean;
|
|
11
|
+
/** what the field stays inside, on the page (default: the window) */
|
|
12
|
+
bounds?(): {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
};
|
|
18
|
+
/** where it is until the thing is drawn */
|
|
19
|
+
at?: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
/** a press in here saves the name once it is released (the press may be on the thing itself, or drag it: it goes by the
|
|
24
|
+
* name it has); anywhere else at once, before what was pressed acts (Save, Undo) */
|
|
25
|
+
late?: HTMLElement;
|
|
26
|
+
/** what such a press started (a drag of the thing) isn't over yet: the name waits for it */
|
|
27
|
+
busy?(): boolean;
|
|
28
|
+
/** what has the focus after Enter or Esc (default: what had it) */
|
|
29
|
+
back?: HTMLElement;
|
|
30
|
+
}
|
|
31
|
+
export interface RenameField {
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
/** what is wrong with a name ('' : nothing) */
|
|
35
|
+
wrong(v: string): string;
|
|
36
|
+
/** Enter on a good name that isn't the one there */
|
|
37
|
+
commit(v: string): void;
|
|
38
|
+
/** false: the thing is gone, and the field with it */
|
|
39
|
+
alive?(): boolean;
|
|
40
|
+
}
|
|
41
|
+
export declare const renameOpen: () => boolean;
|
|
42
|
+
/** Open the field; resolves with the name committed, or undefined when dismissed. */
|
|
43
|
+
export declare function renameField(f: RenameField, at: RenameAt): Promise<string | undefined>;
|
|
@@ -34,7 +34,13 @@ export interface DomainView<R, D extends CanvasDrawing> {
|
|
|
34
34
|
icon?: string;
|
|
35
35
|
value?: unknown;
|
|
36
36
|
name?: string;
|
|
37
|
+
section?: string;
|
|
37
38
|
}[];
|
|
39
|
+
/** (0.12.0) the palette 'floating' over the canvas (the default) or 'docked': a pane of its own at the canvas's left,
|
|
40
|
+
* searchable by label and section, resizable and collapsible */
|
|
41
|
+
paletteLayout?: 'floating' | 'docked';
|
|
42
|
+
/** (0.12.5) what a double click on an object of the canvas does: shows it in the text (the default), or renames it */
|
|
43
|
+
doubleClick?: 'text' | 'rename';
|
|
38
44
|
/** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
|
|
39
45
|
flat?: CanvasKit<R, D>['flat'];
|
|
40
46
|
/** a layer over the canvas, and a part beside the views (A: their calls) */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function playerScript(): string;
|
|
@@ -27,5 +27,5 @@ export { flatSvg, flatCss, measureIn, rectOf } from './flat-view.js';
|
|
|
27
27
|
export type { FlatStyle } from './flat-view.js';
|
|
28
28
|
export { dualView, storedMode, viewToggle, DUAL_VIEW_CSS } from './dual-view.js';
|
|
29
29
|
export type { ViewMode, DualViewOptions, DualView } from './dual-view.js';
|
|
30
|
-
export { morphSvgs, markConnectors } from './morph.js';
|
|
31
|
-
export type { SvgMorph } from './morph.js';
|
|
30
|
+
export { morphSvgs, markConnectors, buildLayer, ease, clamp } from './morph.js';
|
|
31
|
+
export type { SvgMorph, MorphLayer } from './morph.js';
|
|
@@ -21,8 +21,11 @@ export declare function morphSvgs(root: HTMLElement, fromSvg: SVGSVGElement, toS
|
|
|
21
21
|
}): SvgMorph | undefined;
|
|
22
22
|
export declare const clamp: (v: number) => number;
|
|
23
23
|
export declare const ease: (t: number) => number;
|
|
24
|
-
/**
|
|
25
|
-
export
|
|
24
|
+
/** a morph's layer: append `svg` to the root; `at(t)` paints it t (0 to 1) of the way, in any order (no clock) */
|
|
25
|
+
export interface MorphLayer {
|
|
26
26
|
svg: SVGSVGElement;
|
|
27
27
|
at(t: number): void;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
/** the layer a morph draws on: `at(t)` paints it t of the way from one view to the other. Both views are in the root and
|
|
30
|
+
* laid out (hidden is fine, display: none is not): a host seeks it frame by frame (0.12.2: exported). */
|
|
31
|
+
export declare function buildLayer(root: HTMLElement, fromSvg: SVGSVGElement, toSvg: SVGSVGElement, from: ViewMode): MorphLayer;
|
|
@@ -4,6 +4,16 @@ export type View = {
|
|
|
4
4
|
w: number;
|
|
5
5
|
h: number;
|
|
6
6
|
};
|
|
7
|
+
/** What a fit makes of a stage (px) and what it frames, `box` PAD px inside it, and what must be on it too, `also` INSET px inside:
|
|
8
|
+
* the zoom and the middle. Pure. */
|
|
9
|
+
export declare function fitted(s: {
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
}, box: View, also?: View): {
|
|
13
|
+
k: number;
|
|
14
|
+
cx: number;
|
|
15
|
+
cy: number;
|
|
16
|
+
};
|
|
7
17
|
export declare const MIN_ZOOM = 0.1, MAX_ZOOM = 8;
|
|
8
18
|
export interface ViewportOpts {
|
|
9
19
|
/** the drawing on the stage (its viewBox is the view), if any */
|
|
@@ -14,6 +24,8 @@ export interface ViewportOpts {
|
|
|
14
24
|
onRezoom(): void;
|
|
15
25
|
/** what a fit frames (the drawing's own things, the overlay's shown marks), if not the whole scene */
|
|
16
26
|
itemsBox(): View | undefined;
|
|
27
|
+
/** (0.12.6) what must be on the stage too when the things are fitted (the connectors), a few px from its edges */
|
|
28
|
+
alsoBox?(): View | undefined;
|
|
17
29
|
/** the overlay has marks that keep their size on screen (a fit repeats while they are showing) */
|
|
18
30
|
marksShowing(): boolean;
|
|
19
31
|
}
|
|
@@ -40,7 +52,7 @@ export declare function viewport(host: HTMLElement, o: ViewportOpts): {
|
|
|
40
52
|
y: number;
|
|
41
53
|
};
|
|
42
54
|
zoomAt: (f: number, cx?: number, cy?: number) => void;
|
|
43
|
-
fit: (box?: View | undefined) => void;
|
|
55
|
+
fit: (box?: View | undefined, also?: View) => void;
|
|
44
56
|
fitItems: () => void;
|
|
45
57
|
autoFit: () => void;
|
|
46
58
|
actual: () => void;
|