@johnoscott/isometric-engine 0.9.0 → 0.12.3

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 (43) hide show
  1. package/EDITOR-GUIDE.md +54 -6
  2. package/README.md +1 -1
  3. package/assets/app.css +38 -3
  4. package/assets/icons.svg +1 -1
  5. package/assets/marks.css +5 -1
  6. package/iso-editor.js +173 -173
  7. package/iso-render.js +97 -97
  8. package/iso-systems.js +104 -104
  9. package/js/iso-editor/doc.js +4 -0
  10. package/js/iso-editor/splice.js +3 -1
  11. package/js/iso-editor/ui/canvas.js +393 -18
  12. package/js/iso-editor/ui/plain-icons.js +2 -0
  13. package/js/iso-editor/ui/setup.js +7 -2
  14. package/js/iso-objects/board.js +6 -1
  15. package/js/iso-objects/scene.js +3 -2
  16. package/js/iso-viewer/index.js +4 -1
  17. package/package.json +101 -92
  18. package/src/iso-core/compile-schema.ts +3 -1
  19. package/src/iso-editor/adapter.ts +19 -0
  20. package/src/iso-editor/doc.ts +6 -0
  21. package/src/iso-editor/index.ts +2 -2
  22. package/src/iso-editor/splice.ts +8 -3
  23. package/src/iso-editor/ui/app.css +33 -2
  24. package/src/iso-editor/ui/canvas.ts +299 -23
  25. package/src/iso-editor/ui/marks.css +5 -1
  26. package/src/iso-editor/ui/plain-icons.ts +2 -0
  27. package/src/iso-editor/ui/setup.ts +16 -3
  28. package/src/iso-objects/board.ts +6 -2
  29. package/src/iso-objects/route.ts +1 -1
  30. package/src/iso-objects/scene.ts +4 -2
  31. package/src/iso-viewer/index.ts +2 -2
  32. package/src/iso-viewer/morph.ts +5 -2
  33. package/types/iso-core/compile-schema.d.ts +2 -2
  34. package/types/iso-editor/adapter.d.ts +33 -0
  35. package/types/iso-editor/index.d.ts +2 -2
  36. package/types/iso-editor/ui/canvas.d.ts +44 -8
  37. package/types/iso-editor/ui/monaco-entry.d.ts +2 -0
  38. package/types/iso-editor/ui/setup.d.ts +13 -0
  39. package/types/iso-objects/route.d.ts +1 -1
  40. package/types/iso-systems/validate.d.ts +4 -0
  41. package/types/iso-viewer/bundle.d.ts +1 -0
  42. package/types/iso-viewer/index.d.ts +2 -2
  43. package/types/iso-viewer/morph.d.ts +6 -3
@@ -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
- const big = shape === 'slab';
187
- const z = big ? b.z0 + 0.28 : b.z0 + Math.min(0.1, (b.z1 - b.z0) * 0.25);
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'));
@@ -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';
@@ -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
- /** the layer a morph draws on: `at(t)` paints it t of the way from one view to the other */
95
- export function buildLayer(root: HTMLElement, fromSvg: SVGSVGElement, toSvg: SVGSVGElement, from: ViewMode): { svg: SVGSVGElement; at(t: number): void } {
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');
@@ -1,6 +1,6 @@
1
- import Ajv2020Mod from 'ajv/dist/2020.js';
1
+ import type { Ajv2020 as Ajv2020Class } from 'ajv/dist/2020.js';
2
2
  import type { ValidateFunction } from 'ajv';
3
- export declare const Ajv2020: typeof Ajv2020Mod.default;
3
+ export declare const Ajv2020: typeof Ajv2020Class;
4
4
  export declare const AJV_OPTIONS: {
5
5
  readonly allErrors: true;
6
6
  readonly verbose: true;
@@ -48,6 +48,26 @@ export interface ObjectRef {
48
48
  name: string;
49
49
  path: string;
50
50
  }
51
+ /** (0.10.0) what a connection drawn on the canvas writes: a value added to a list (`at`), or, with `name` (a base for a
52
+ * fresh one), to a map */
53
+ export interface ConnectPlan {
54
+ at: Path;
55
+ value: unknown;
56
+ name?: string;
57
+ label?: string;
58
+ }
59
+ /** (0.10.0) the selection made into a new container: where it goes (`at`, a map), the base of its fresh name, its
60
+ * value, and, given the name it got, what changes in each member (each a set) */
61
+ export interface GroupPlan {
62
+ at: Path;
63
+ name: string;
64
+ value: unknown;
65
+ members(name: string): {
66
+ path: Path;
67
+ value: unknown;
68
+ }[];
69
+ label?: string;
70
+ }
51
71
  /** what the domain's reader says of a text */
52
72
  export interface ReadOutcome {
53
73
  diags: Diag[];
@@ -113,6 +133,19 @@ export interface DomainAdapter {
113
133
  } | undefined;
114
134
  /** what a completion list says of an extra word in a slot */
115
135
  extraDetail?(word: string, data: unknown): string | undefined;
136
+ /** (0.10.0) a connection drawn from one object to another: what to add, or undefined (these two don't connect). None:
137
+ * the canvas offers no connect gesture */
138
+ connect?(from: ObjectRef, to: ObjectRef, data: unknown): ConnectPlan | undefined;
139
+ /** (0.10.0) the selected objects grouped into a new container, as one step; undefined: these can't be. None: the
140
+ * canvas offers no Group */
141
+ group?(members: ObjectRef[], data: unknown): GroupPlan | undefined;
142
+ /** (0.10.1) a new object of `kind` (its value as the palette made it) dropped onto `target`: its value put inside the
143
+ * target, and the words for it ("in subnet app"), or undefined (the target doesn't hold it). The canvas asks what is
144
+ * under the drop, innermost first; none: a drop is pinned where it lands */
145
+ dropInto?(target: ObjectRef, value: unknown, kind: string, data: unknown): {
146
+ value: unknown;
147
+ label?: string;
148
+ } | undefined;
116
149
  /** the top-level key order: where a new section goes */
117
150
  topOrder: readonly string[];
118
151
  /** the layout pins: the key they live under, a legacy key read too, and whether a file has only the legacy one */
@@ -1,4 +1,4 @@
1
- export type { FileRole, ObjectKindInfo, RefSlot, Ref, ObjectRef, ReadOutcome, DomainAdapter } from './adapter.js';
1
+ export type { FileRole, ObjectKindInfo, RefSlot, Ref, ObjectRef, ReadOutcome, DomainAdapter, ConnectPlan, GroupPlan } from './adapter.js';
2
2
  export { toPointer, fromPointer, parentOf, isPrefix, samePath } from './path.js';
3
3
  export type { Seg, Path } from './path.js';
4
4
  export { EditorDoc, completionContext } from './doc.js';
@@ -43,7 +43,7 @@ export { propsPanel } from './ui/props.js';
43
43
  export type { PropsUi, PropsKit, PropsOpts } from './ui/props.js';
44
44
  export type { Box as CanvasBox, Outline, CanvasCtx, CanvasLayer } from './ui/canvas-layer.js';
45
45
  export { canvasView } from './ui/canvas.js';
46
- export type { CanvasDrawing, DropInto, CanvasUi, CanvasKit, CanvasOpts, FlatCanvas, FlatDrawn } from './ui/canvas.js';
46
+ export type { CanvasDrawing, DropInto, CanvasUi, CanvasKit, CanvasOpts, FlatCanvas, FlatDrawn, PaletteItem } from './ui/canvas.js';
47
47
  export { flatCanvas } from './ui/flat-canvas.js';
48
48
  export type { PartCtx, Attention, EditorPart } from './ui/part.js';
49
49
  export type { Checked, MountKit } from './ui/mount-kit.js';
@@ -7,7 +7,7 @@ import type { CompiledScene } from '../../iso-objects/compile.js';
7
7
  import type { EditorModel } from '../model.js';
8
8
  import type { Problem } from '../validate.js';
9
9
  import { type Commands } from '../commands.js';
10
- import type { ObjectKindInfo, ObjectRef } from '../adapter.js';
10
+ import type { ObjectKindInfo, ObjectRef, ConnectPlan, GroupPlan } from '../adapter.js';
11
11
  import { type Path } from '../path.js';
12
12
  import { type View } from '../../iso-viewer/viewport.js';
13
13
  import type { CanvasCtx, CanvasLayer } from './canvas-layer.js';
@@ -83,11 +83,13 @@ export interface CanvasUi {
83
83
  panKeyClass: string;
84
84
  /** the kinds the canvas's menu offers, in order */
85
85
  newOrder: string[];
86
- palette: {
87
- kind: string;
88
- icon: IconName;
89
- label: string;
90
- }[];
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
+ * the base of its fresh name (default: the kind's singular) */
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';
91
93
  text: {
92
94
  stage: string;
93
95
  dragGroup: string;
@@ -100,6 +102,17 @@ export interface CanvasUi {
100
102
  duplicateWhy: string;
101
103
  };
102
104
  }
105
+ export interface PaletteItem {
106
+ kind: string;
107
+ icon: IconName;
108
+ label: string;
109
+ value?(): unknown;
110
+ name?: string;
111
+ /** (0.11.0) the header it is listed under: entries with one are grouped by it, in order of first use, each group under
112
+ * a header that collapses (all collapsed but the one last added from, remembered in the host's store as
113
+ * `canvas-palette`); entries without one are listed as before, where they are */
114
+ section?: string;
115
+ }
103
116
  /** what the canvas is given of the domain (M: the domain's reading of the file; D: its drawing) */
104
117
  export interface CanvasKit<M, D extends CanvasDrawing> {
105
118
  draw(model: M, data: unknown, theme: string): D;
@@ -108,7 +121,17 @@ export interface CanvasKit<M, D extends CanvasDrawing> {
108
121
  catalog: KindCatalog;
109
122
  objectOf(ptr: string): ObjectRef | undefined;
110
123
  kinds: ObjectKindInfo[];
111
- commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertCmd' | 'pinsCmd' | 'withPinsMoved' | 'describe' | 'freshName'>;
124
+ commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertCmd' | 'insertItemCmd' | 'pinsCmd' | 'withPinsMoved' | 'describe' | 'freshName'>;
125
+ /** (0.10.0) a connection drawn from one object to another (the adapter's connect): the canvas offers the gesture (a
126
+ * handle on a selected object, and "Connect to…") only when it is given */
127
+ connect?(from: ObjectRef, to: ObjectRef, data: unknown): ConnectPlan | undefined;
128
+ /** (0.10.1) a palette drop onto an object (the adapter's dropInto): the new thing inside it, asked innermost first */
129
+ dropOnto?(target: ObjectRef, value: unknown, kind: string, data: unknown): {
130
+ value: unknown;
131
+ label?: string;
132
+ } | undefined;
133
+ /** (0.10.0) the selection made into a new container (the adapter's group): Group, ⌘G, one undo step */
134
+ group?(members: ObjectRef[], data: unknown): GroupPlan | undefined;
112
135
  actions: Actions;
113
136
  /** what an object's own menu offers, beyond rename, duplicate and delete */
114
137
  objectItems(doc: EditorModel, path: Path, origin: 'canvas' | 'menu', note?: (t: string, tone?: 'bad') => void): MenuItem[];
@@ -161,8 +184,21 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
161
184
  addFromPalette: (sec: string, at?: {
162
185
  x: number;
163
186
  y: number;
164
- }) => Path | undefined;
187
+ }, item?: PaletteItem) => Path | undefined;
165
188
  palette: HTMLDivElement;
189
+ groupSelection: () => void;
190
+ startPick: () => void;
191
+ objectsUnder: (at: {
192
+ x: number;
193
+ y: number;
194
+ }) => ObjectRef[];
195
+ readonly linking: {
196
+ from: ObjectRef;
197
+ x?: number;
198
+ y?: number;
199
+ over?: string;
200
+ pick?: boolean;
201
+ } | undefined;
166
202
  render: (s3: M | undefined, data: unknown) => Promise<void>;
167
203
  setTheme: (_t: 'light' | 'dark') => void;
168
204
  paintOverlay: () => void;
@@ -0,0 +1,2 @@
1
+ export * from 'monaco-editor/editor/editor.api.js';
2
+ import 'monaco-editor/languages/definitions/yaml/register.js';
@@ -26,6 +26,19 @@ export interface DomainView<R, D extends CanvasDrawing> {
26
26
  icons?: Record<string, string>;
27
27
  words?: Partial<ShellWords>;
28
28
  keymap?: KeyGroup[];
29
+ /** (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
30
+ * `value`; default: the kind's template) and the base of its fresh name. None: one entry per kind, as before */
31
+ palette?: {
32
+ kind: string;
33
+ label: string;
34
+ icon?: string;
35
+ value?: unknown;
36
+ name?: string;
37
+ section?: string;
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';
29
42
  /** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
30
43
  flat?: CanvasKit<R, D>['flat'];
31
44
  /** a layer over the canvas, and a part beside the views (A: their calls) */
@@ -44,7 +44,7 @@ export interface RouteResult {
44
44
  }
45
45
  /**
46
46
  * The search steps routing may take in one scene. The heaviest diagram in this repo takes about 57,000
47
- * (the session-messaging reproduction in repro/); a drawing with 40 more nodes took 11 million, and minutes. Past the budget,
47
+ * (the large drawing in corpus/messaging.yaml); a drawing with 40 more nodes took 11 million, and minutes. Past the budget,
48
48
  * the routes left are drawn as plain elbows and the scene says so, so a large diagram draws in about a second.
49
49
  */
50
50
  export declare const ROUTE_BUDGET = 500000;
@@ -0,0 +1,4 @@
1
+ import type { Diag } from '../iso-core/errors.js';
2
+ import type { Parsed } from '../iso-core/parse.js';
3
+ export { schemaValidator } from '../iso-core/schema-errors.js';
4
+ export declare function validateSchema(parsed: Parsed): Diag[];
@@ -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
- /** the layer a morph draws on: `at(t)` paints it t of the way from one view to the other */
25
- export declare function buildLayer(root: HTMLElement, fromSvg: SVGSVGElement, toSvg: SVGSVGElement, from: ViewMode): {
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;