@johnoscott/isometric-engine 0.12.3 → 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.
Files changed (37) hide show
  1. package/EDITOR-GUIDE.md +1 -0
  2. package/README.md +1 -1
  3. package/assets/app.css +6 -0
  4. package/iso-editor.js +165 -165
  5. package/iso-render.js +82 -82
  6. package/iso-systems.js +79 -79
  7. package/js/iso-editor/commands.js +7 -0
  8. package/js/iso-editor/connections.js +24 -0
  9. package/js/iso-editor/model.js +17 -3
  10. package/js/iso-editor/ui/actions.js +22 -24
  11. package/js/iso-editor/ui/canvas.js +92 -12
  12. package/js/iso-editor/ui/mount.js +2 -1
  13. package/js/iso-editor/ui/props.js +2 -2
  14. package/js/iso-editor/ui/rename.js +114 -0
  15. package/js/iso-editor/ui/setup.js +1 -0
  16. package/js/iso-viewer/viewport.js +17 -5
  17. package/package.json +1 -1
  18. package/src/iso-editor/commands.ts +9 -0
  19. package/src/iso-editor/connections.ts +28 -0
  20. package/src/iso-editor/model.ts +17 -3
  21. package/src/iso-editor/ui/actions.ts +20 -23
  22. package/src/iso-editor/ui/app.css +6 -0
  23. package/src/iso-editor/ui/canvas.ts +84 -15
  24. package/src/iso-editor/ui/mount.ts +4 -3
  25. package/src/iso-editor/ui/props.ts +3 -3
  26. package/src/iso-editor/ui/rename.ts +105 -0
  27. package/src/iso-editor/ui/setup.ts +3 -0
  28. package/src/iso-viewer/viewport.ts +25 -5
  29. package/types/iso-editor/connections.d.ts +8 -0
  30. package/types/iso-editor/model.d.ts +8 -2
  31. package/types/iso-editor/ui/actions.d.ts +5 -2
  32. package/types/iso-editor/ui/canvas.d.ts +10 -1
  33. package/types/iso-editor/ui/mount.d.ts +6 -2
  34. package/types/iso-editor/ui/props.d.ts +1 -1
  35. package/types/iso-editor/ui/rename.d.ts +43 -0
  36. package/types/iso-editor/ui/setup.d.ts +2 -0
  37. package/types/iso-viewer/viewport.d.ts +13 -1
@@ -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
- apply(cmd: Command, origin?: Origin): boolean;
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
- renameDialog: (doc: EditorModel, path: Path, origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void) => Promise<boolean>;
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
  };
@@ -90,6 +90,8 @@ export interface CanvasUi {
90
90
  * its own at the canvas's left, with a search box filtering by label and section, resizable and collapsible; its
91
91
  * width and whether it is collapsed are kept in the host's store as `canvas-palette-dock`) */
92
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';
93
95
  text: {
94
96
  stage: string;
95
97
  dragGroup: string;
@@ -203,7 +205,8 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
203
205
  setTheme: (_t: 'light' | 'dark') => void;
204
206
  paintOverlay: () => void;
205
207
  fit: () => void;
206
- fitAll: (box?: View | undefined) => void;
208
+ fitNext(): void;
209
+ fitAll: (box?: View | undefined, also?: View) => void;
207
210
  actual: () => void;
208
211
  zoomAt: (f: number, cx?: number, cy?: number) => void;
209
212
  itemsBox: () => {
@@ -212,6 +215,12 @@ export declare function canvasView<M, D extends CanvasDrawing, A extends object
212
215
  w: number;
213
216
  h: number;
214
217
  } | undefined;
218
+ routesBox: () => {
219
+ x: number;
220
+ y: number;
221
+ w: number;
222
+ h: number;
223
+ } | undefined;
215
224
  readonly moved: boolean;
216
225
  settled: () => Promise<void>;
217
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): void;
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' | 'renameDialog'>;
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>;
@@ -39,6 +39,8 @@ export interface DomainView<R, D extends CanvasDrawing> {
39
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
40
  * searchable by label and section, resizable and collapsible */
41
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';
42
44
  /** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
43
45
  flat?: CanvasKit<R, D>['flat'];
44
46
  /** a layer over the canvas, and a part beside the views (A: their calls) */
@@ -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;