@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
@@ -53,6 +53,13 @@ export interface Ref {
53
53
  /** a thing at a pointer: its kind, its name and its own pointer */
54
54
  export interface ObjectRef { kind: string; name: string; path: string }
55
55
 
56
+ /** (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
57
+ * fresh one), to a map */
58
+ export interface ConnectPlan { at: Path; value: unknown; name?: string; label?: string }
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 { at: Path; name: string; value: unknown; members(name: string): { path: Path; value: unknown }[]; label?: string }
62
+
56
63
  /** what the domain's reader says of a text */
57
64
  export interface ReadOutcome {
58
65
  diags: Diag[];
@@ -108,6 +115,18 @@ export interface DomainAdapter {
108
115
  /** what a completion list says of an extra word in a slot */
109
116
  extraDetail?(word: string, data: unknown): string | undefined;
110
117
 
118
+ /** (0.10.0) a connection drawn from one object to another: what to add, or undefined (these two don't connect). None:
119
+ * the canvas offers no connect gesture */
120
+ connect?(from: ObjectRef, to: ObjectRef, data: unknown): ConnectPlan | undefined;
121
+ /** (0.10.0) the selected objects grouped into a new container, as one step; undefined: these can't be. None: the
122
+ * canvas offers no Group */
123
+ group?(members: ObjectRef[], data: unknown): GroupPlan | undefined;
124
+
125
+ /** (0.10.1) a new object of `kind` (its value as the palette made it) dropped onto `target`: its value put inside the
126
+ * target, and the words for it ("in subnet app"), or undefined (the target doesn't hold it). The canvas asks what is
127
+ * under the drop, innermost first; none: a drop is pinned where it lands */
128
+ dropInto?(target: ObjectRef, value: unknown, kind: string, data: unknown): { value: unknown; label?: string } | undefined;
129
+
111
130
  /** the top-level key order: where a new section goes */
112
131
  topOrder: readonly string[];
113
132
  /** the layout pins: the key they live under, a legacy key read too, and whether a file has only the legacy one */
@@ -172,6 +172,12 @@ function parentByIndent(d: EditorDoc, lineStart: number, indent: number, forList
172
172
  if (a.where === 'key') return a.path.slice(0, -1);
173
173
  if (line.slice(ind).startsWith('- ')) return a.path.slice(0, -1);
174
174
  }
175
+ // (0.12.2) "- key: …" holds its item's first key two columns in: a key typed below it at that column is its
176
+ // sibling, in the same item (a list of maps, written in block style)
177
+ if (!forList && /^- /.test(line.slice(ind)) && ind + 2 === indent) {
178
+ const a = d.at(s + ind + 2);
179
+ if (a.where === 'key') return a.path.slice(0, -1);
180
+ }
175
181
  if (ind < indent || (forList && ind <= indent && /:\s*$/.test(line))) {
176
182
  const m = /^(\s*)(- )?([^\s:#][^:#]*?)\s*:/.exec(line);
177
183
  if (m) {
@@ -7,7 +7,7 @@
7
7
  // The layer's public API. Importers name the module a name comes from (with code splitting, a barrel puts every file
8
8
  // it reaches into each bundle that imports it); the Node tests may import this index.
9
9
 
10
- export type { FileRole, ObjectKindInfo, RefSlot, Ref, ObjectRef, ReadOutcome, DomainAdapter } from './adapter.ts';
10
+ export type { FileRole, ObjectKindInfo, RefSlot, Ref, ObjectRef, ReadOutcome, DomainAdapter, ConnectPlan, GroupPlan } from './adapter.ts';
11
11
  export { toPointer, fromPointer, parentOf, isPrefix, samePath } from './path.ts';
12
12
  export type { Seg, Path } from './path.ts';
13
13
  export { EditorDoc, completionContext } from './doc.ts';
@@ -52,7 +52,7 @@ export { propsPanel } from './ui/props.ts';
52
52
  export type { PropsUi, PropsKit, PropsOpts } from './ui/props.ts';
53
53
  export type { Box as CanvasBox, Outline, CanvasCtx, CanvasLayer } from './ui/canvas-layer.ts';
54
54
  export { canvasView } from './ui/canvas.ts';
55
- export type { CanvasDrawing, DropInto, CanvasUi, CanvasKit, CanvasOpts, FlatCanvas, FlatDrawn } from './ui/canvas.ts';
55
+ export type { CanvasDrawing, DropInto, CanvasUi, CanvasKit, CanvasOpts, FlatCanvas, FlatDrawn, PaletteItem } from './ui/canvas.ts';
56
56
  // the canvas's 2D view (0.6.4): a host hands it to the canvas (DomainView.flat.load); the canvas never imports it
57
57
  export { flatCanvas } from './ui/flat-canvas.ts';
58
58
  export type { PartCtx, Attention, EditorPart } from './ui/part.ts';
@@ -364,9 +364,14 @@ export function insertItem(text: string, listPath: Path, value: unknown, index?:
364
364
  const prefix = text.slice(dash, first.range![0]);
365
365
  if (!/^\s*- $/.test(prefix)) return fallback(text, listPath, d => { const s = d.getIn(listPath) as YAMLSeq; s.items.splice(at, 0, d.createNode(value) as never); }, true);
366
366
  const indent = prefix.indexOf('-');
367
- const body = ' '.repeat(indent) + '- ' + (isObj(value) && Object.keys(value as object).length
368
- ? reindent(yamlText(value), indent + 2).slice(indent + 2)
369
- : scalarText(value, { flow: false, indent: indent + 2 })) + '\n';
367
+ // (0.10.0) a map among maps written inline ({ … }) is written inline too
368
+ const near = items[Math.min(at, items.length - 1)];
369
+ const inline = isObj(value) && isMap(near) && (near as { flow?: boolean }).flow;
370
+ const body = ' '.repeat(indent) + '- ' + (inline
371
+ ? flowText(value)
372
+ : isObj(value) && Object.keys(value as object).length
373
+ ? reindent(yamlText(value), indent + 2).slice(indent + 2)
374
+ : scalarText(value, { flow: false, indent: indent + 2 })) + '\n';
370
375
  if (at < items.length) { const s = lineStart(text, items[at].range![0]); return { steps: [[{ start: s, end: s, text: body }]] }; }
371
376
  const e = items[items.length - 1].range![1];
372
377
  const end = nextLine(text, text[e - 1] === '\n' ? e - 1 : e);
@@ -54,6 +54,8 @@ body[data-view="text"] #se-canvas, body[data-view="text"] #se-work-grip { displa
54
54
  /* the stage (canvas.css styles the drawing in it); focused by a click, a quieter ring than the keyboard's */
55
55
  .canvas.has-focus .canvas-stage:not(:focus-visible) { outline: 2px solid color-mix(in srgb, var(--focus) 50%, transparent); outline-offset: -2px; }
56
56
  .canvas-tools { position: absolute; right: var(--sp-3); bottom: var(--sp-3); display: flex; gap: var(--sp-0); padding: var(--sp-0); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1, none); }
57
+ /* a canvas too narrow for it: the toolbar wraps onto rows inside it, right-aligned (one row, as ever, when it fits) */
58
+ .canvas-tools { max-width: calc(100% - 2 * var(--sp-3)); flex-wrap: wrap; justify-content: flex-end; }
57
59
  .canvas-tools .segmented { margin-right: var(--sp-1); }
58
60
  .status .hint-mode { color: var(--ink-3); }
59
61
  body[data-view="text"] .status .hint-mode { display: none; }
@@ -217,12 +219,41 @@ body { position: relative; height: 100%; min-height: 0; font: var(--fw-regular)
217
219
  }
218
220
  /* E11: the palette, on the canvas: click to add, or drag onto the canvas */
219
221
  @layer views {
220
- .palette { position: absolute; left: var(--sp-3); top: var(--sp-3); display: flex; flex-direction: column; gap: 2px; padding: var(--sp-0); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1, none); z-index: 2; }
221
- .pal-item { display: flex; align-items: center; gap: var(--sp-2); height: var(--ctl-sm); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font: inherit; font-size: var(--fs-sm); cursor: grab; text-align: left; touch-action: none; user-select: none; }
222
+ .palette { position: absolute; left: var(--sp-3); top: var(--sp-3); display: flex; flex-direction: column; gap: 2px; padding: var(--sp-0); max-height: calc(100% - 2 * var(--sp-3) - 56px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1, none); z-index: 2; }
223
+ .pal-item { display: flex; flex-shrink: 0; align-items: center; gap: var(--sp-2); height: var(--ctl-sm); padding: 0 var(--sp-2); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font: inherit; font-size: var(--fs-sm); cursor: grab; text-align: left; touch-action: none; user-select: none; }
222
224
  .pal-item:hover { background: var(--state-hover); color: var(--ink); }
223
225
  .pal-item:active { cursor: grabbing; }
224
226
  .pal-item .icon { width: 14px; height: 14px; }
227
+ .pal-section { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
228
+ .pal-head { display: flex; flex-shrink: 0; align-items: center; gap: var(--sp-1); height: var(--ctl-sm); padding: 0 var(--sp-2) 0 var(--sp-1); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-3); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-strong); letter-spacing: .02em; cursor: pointer; text-align: left; }
229
+ .pal-head:hover { background: var(--state-hover); color: var(--ink); }
230
+ .pal-head .pal-chev { width: 12px; height: 12px; transition: transform var(--dur-1, 0ms); }
231
+ .pal-head[aria-expanded="true"] .pal-chev { transform: rotate(90deg); }
232
+ .pal-body { display: flex; flex-direction: column; gap: 2px; }
233
+ .pal-body[hidden] { display: none; }
225
234
  body.read-only .palette { display: none; }
235
+ /* 0.12.0: the palette docked, a pane of its own at the canvas's left (search, sections, a grip, collapsible) */
236
+ .canvas.pal-docked { display: flex; --pal-cur: var(--pal-w, 220px); }
237
+ .canvas.pal-docked.pal-collapsed { --pal-cur: 36px; }
238
+ .canvas.pal-docked > .canvas-stage { flex: 1 1 auto; min-width: 0; position: relative; }
239
+ .canvas.pal-docked > .canvas-empty { left: var(--pal-cur, 220px); }
240
+ /* the toolbar stays on the stage, beside the pane */
241
+ .canvas.pal-docked > .canvas-tools { max-width: calc(100% - var(--pal-cur, 220px) - 2 * var(--sp-3)); }
242
+ .pal-dock { flex: 0 0 var(--pal-cur, 220px); width: var(--pal-cur, 220px); min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-right: var(--bw) solid var(--line); overflow: hidden; z-index: 2; }
243
+ .pal-dock-head { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1); border-bottom: var(--bw) solid var(--line); }
244
+ .pal-search-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-1); height: var(--ctl-sm); padding: 0 var(--sp-2); border: var(--bw) solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink-3); }
245
+ .pal-search-wrap:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
246
+ .pal-search-wrap .icon { width: 14px; height: 14px; flex: none; }
247
+ .pal-search { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: var(--fs-sm); }
248
+ .pal-dock .palette.pal-list { position: static; flex: 1 1 auto; max-height: none; min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: none; padding: var(--sp-1); }
249
+ .pal-dock .pal-item[hidden], .pal-dock .pal-section[hidden] { display: none; }
250
+ .pal-none { margin: 0; padding: var(--sp-2) var(--sp-3); color: var(--ink-3); font-size: var(--fs-sm); }
251
+ .pal-none[hidden] { display: none; }
252
+ .canvas.pal-collapsed .pal-search-wrap, .canvas.pal-collapsed .palette.pal-list, .canvas.pal-collapsed .pal-none, .canvas.pal-collapsed .pal-grip { display: none; }
253
+ .canvas.pal-collapsed .pal-dock-head { border-bottom: 0; justify-content: center; }
254
+ .pal-grip { flex: none; width: 6px; margin: 0 -3px; cursor: col-resize; z-index: 3; position: relative; }
255
+ .pal-grip:hover, .pal-grip:focus-visible { background: color-mix(in srgb, var(--accent) 30%, transparent); outline: 0; }
256
+ body.read-only .pal-dock, body.read-only .pal-grip { display: none; }
226
257
  .pal-ghost { position: absolute; z-index: 5; pointer-events: none; display: flex; align-items: center; gap: var(--sp-1); padding: 2px var(--sp-2); border: var(--bw) solid var(--accent); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: var(--fs-sm); box-shadow: var(--shadow-2, none); }
227
258
  .pal-ghost .icon { width: 14px; height: 14px; }
228
259
  .pal-ghost.bad { border-color: var(--bad); color: var(--bad); }