@johnoscott/isometric-engine 0.0.0-stage → 0.10.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.
Files changed (310) hide show
  1. package/EDITOR-GUIDE.md +355 -0
  2. package/LICENSE +21 -0
  3. package/LICENSES/ajv.txt +22 -0
  4. package/LICENSES/lucide-static.txt +43 -0
  5. package/LICENSES/yaml.txt +13 -0
  6. package/README.md +62 -2
  7. package/assets/app.css +269 -0
  8. package/assets/default-theme.yaml +99 -0
  9. package/assets/icons.svg +1 -0
  10. package/assets/marks.css +39 -0
  11. package/assets/skin.css +181 -0
  12. package/iso-editor.d.ts +4 -0
  13. package/iso-editor.js +550 -0
  14. package/iso-render.d.ts +3 -0
  15. package/iso-render.js +388 -0
  16. package/iso-systems.d.ts +4 -0
  17. package/iso-systems.js +389 -0
  18. package/js/iso-core/compile-schema.js +22 -0
  19. package/js/iso-core/depth.js +55 -0
  20. package/js/iso-core/errors.js +65 -0
  21. package/js/iso-core/glyphs.js +100 -0
  22. package/js/iso-core/index.js +55 -0
  23. package/js/iso-core/kernel.js +158 -0
  24. package/js/iso-core/metrics.json +1 -0
  25. package/js/iso-core/package.json +6 -0
  26. package/js/iso-core/parse.js +79 -0
  27. package/js/iso-core/schema-errors.js +170 -0
  28. package/js/iso-core/shims/crypto.js +125 -0
  29. package/js/iso-core/shims/path.js +49 -0
  30. package/js/iso-core/svg-dom.js +144 -0
  31. package/js/iso-core/theme.js +48 -0
  32. package/js/iso-core/vdom.js +48 -0
  33. package/js/iso-editor/adapter.js +0 -0
  34. package/js/iso-editor/clipboard.js +152 -0
  35. package/js/iso-editor/commands.js +173 -0
  36. package/js/iso-editor/complete.js +55 -0
  37. package/js/iso-editor/doc.js +182 -0
  38. package/js/iso-editor/index.js +105 -0
  39. package/js/iso-editor/model.js +210 -0
  40. package/js/iso-editor/outline.js +111 -0
  41. package/js/iso-editor/package.json +6 -0
  42. package/js/iso-editor/path.js +19 -0
  43. package/js/iso-editor/providers.js +96 -0
  44. package/js/iso-editor/schema-nav.js +117 -0
  45. package/js/iso-editor/splice.js +443 -0
  46. package/js/iso-editor/storage-keys.js +6 -0
  47. package/js/iso-editor/ui/actions.js +116 -0
  48. package/js/iso-editor/ui/canvas-layer.js +0 -0
  49. package/js/iso-editor/ui/canvas.js +1403 -0
  50. package/js/iso-editor/ui/clip.js +133 -0
  51. package/js/iso-editor/ui/dialog.js +26 -0
  52. package/js/iso-editor/ui/flat-canvas.js +54 -0
  53. package/js/iso-editor/ui/icons.js +15 -0
  54. package/js/iso-editor/ui/keys.js +26 -0
  55. package/js/iso-editor/ui/later.js +28 -0
  56. package/js/iso-editor/ui/layer.js +11 -0
  57. package/js/iso-editor/ui/menu.js +105 -0
  58. package/js/iso-editor/ui/monaco-entry.js +2 -0
  59. package/js/iso-editor/ui/mount-kit.js +0 -0
  60. package/js/iso-editor/ui/mount.js +767 -0
  61. package/js/iso-editor/ui/pane.js +0 -0
  62. package/js/iso-editor/ui/part.js +0 -0
  63. package/js/iso-editor/ui/plain-icons.js +34 -0
  64. package/js/iso-editor/ui/props.js +314 -0
  65. package/js/iso-editor/ui/scope-css.js +81 -0
  66. package/js/iso-editor/ui/setup.js +149 -0
  67. package/js/iso-editor/ui/text.js +323 -0
  68. package/js/iso-editor/ui/tree.js +728 -0
  69. package/js/iso-editor/validate.js +33 -0
  70. package/js/iso-editor/window/protocol.js +8 -0
  71. package/js/iso-objects/assemble.js +43 -0
  72. package/js/iso-objects/assets.js +88 -0
  73. package/js/iso-objects/board.js +162 -0
  74. package/js/iso-objects/compile.js +60 -0
  75. package/js/iso-objects/css.js +154 -0
  76. package/js/iso-objects/flat.js +696 -0
  77. package/js/iso-objects/focus.js +16 -0
  78. package/js/iso-objects/geometry.js +76 -0
  79. package/js/iso-objects/index.js +93 -0
  80. package/js/iso-objects/kinds.js +12 -0
  81. package/js/iso-objects/labels.js +325 -0
  82. package/js/iso-objects/package.json +6 -0
  83. package/js/iso-objects/place.js +347 -0
  84. package/js/iso-objects/route.js +461 -0
  85. package/js/iso-objects/scene.js +350 -0
  86. package/js/iso-objects/steps.js +246 -0
  87. package/js/iso-objects/types.js +0 -0
  88. package/js/iso-systems/catalog.js +42 -0
  89. package/js/iso-systems/compile.js +34 -0
  90. package/js/iso-systems/css.js +8 -0
  91. package/js/iso-systems/index.js +16 -0
  92. package/js/iso-systems/nodes.js +124 -0
  93. package/js/iso-systems/package.json +6 -0
  94. package/js/iso-systems/schema.json +311 -0
  95. package/js/iso-systems/validate.js +35 -0
  96. package/js/iso-viewer/bundle.js +20 -0
  97. package/js/iso-viewer/card-motion.js +228 -0
  98. package/js/iso-viewer/dom.js +14 -0
  99. package/js/iso-viewer/dual-view.js +212 -0
  100. package/js/iso-viewer/flat-view.js +124 -0
  101. package/js/iso-viewer/history.js +990 -0
  102. package/js/iso-viewer/index.js +98 -0
  103. package/js/iso-viewer/morph.js +192 -0
  104. package/js/iso-viewer/overlay.js +199 -0
  105. package/js/iso-viewer/package.json +6 -0
  106. package/js/iso-viewer/page.js +138 -0
  107. package/js/iso-viewer/player.js +409 -0
  108. package/js/iso-viewer/still.js +81 -0
  109. package/js/iso-viewer/timeline-contract.js +14 -0
  110. package/js/iso-viewer/timeline-engine.js +475 -0
  111. package/js/iso-viewer/timeline-export.js +36 -0
  112. package/js/iso-viewer/timeline-scale.js +116 -0
  113. package/js/iso-viewer/timeline-scope.js +58 -0
  114. package/js/iso-viewer/timeline-search.js +216 -0
  115. package/js/iso-viewer/timeline-time.js +55 -0
  116. package/js/iso-viewer/view-css.js +68 -0
  117. package/js/iso-viewer/viewport.js +177 -0
  118. package/package.json +511 -4
  119. package/src/iso-core/compile-schema.ts +23 -0
  120. package/src/iso-core/depth.ts +56 -0
  121. package/src/iso-core/errors.ts +73 -0
  122. package/src/iso-core/glyphs.ts +108 -0
  123. package/src/iso-core/index.ts +27 -0
  124. package/src/iso-core/kernel.ts +163 -0
  125. package/src/iso-core/metrics.json +1 -0
  126. package/src/iso-core/package.json +6 -0
  127. package/src/iso-core/parse.ts +91 -0
  128. package/src/iso-core/schema-errors.ts +163 -0
  129. package/src/iso-core/shims/crypto.ts +37 -0
  130. package/src/iso-core/shims/path.ts +24 -0
  131. package/src/iso-core/svg-dom.ts +103 -0
  132. package/src/iso-core/theme.ts +64 -0
  133. package/src/iso-core/vdom.ts +41 -0
  134. package/src/iso-editor/adapter.ts +147 -0
  135. package/src/iso-editor/clipboard.ts +163 -0
  136. package/src/iso-editor/commands.ts +191 -0
  137. package/src/iso-editor/complete.ts +73 -0
  138. package/src/iso-editor/doc.ts +207 -0
  139. package/src/iso-editor/index.ts +67 -0
  140. package/src/iso-editor/model.ts +234 -0
  141. package/src/iso-editor/outline.ts +126 -0
  142. package/src/iso-editor/package.json +6 -0
  143. package/src/iso-editor/path.ts +18 -0
  144. package/src/iso-editor/providers.ts +113 -0
  145. package/src/iso-editor/schema-nav.ts +129 -0
  146. package/src/iso-editor/splice.ts +477 -0
  147. package/src/iso-editor/storage-keys.ts +6 -0
  148. package/src/iso-editor/ui/actions.ts +119 -0
  149. package/src/iso-editor/ui/app.css +230 -0
  150. package/src/iso-editor/ui/canvas-layer.ts +56 -0
  151. package/src/iso-editor/ui/canvas.ts +1227 -0
  152. package/src/iso-editor/ui/clip.ts +97 -0
  153. package/src/iso-editor/ui/dialog.ts +25 -0
  154. package/src/iso-editor/ui/flat-canvas.ts +51 -0
  155. package/src/iso-editor/ui/icons.ts +21 -0
  156. package/src/iso-editor/ui/keys.ts +30 -0
  157. package/src/iso-editor/ui/later.ts +22 -0
  158. package/src/iso-editor/ui/layer.ts +7 -0
  159. package/src/iso-editor/ui/marks.css +39 -0
  160. package/src/iso-editor/ui/menu.ts +67 -0
  161. package/src/iso-editor/ui/monaco-entry.ts +6 -0
  162. package/src/iso-editor/ui/mount-kit.ts +35 -0
  163. package/src/iso-editor/ui/mount.ts +684 -0
  164. package/src/iso-editor/ui/pane.ts +45 -0
  165. package/src/iso-editor/ui/part.ts +45 -0
  166. package/src/iso-editor/ui/plain-icons.ts +83 -0
  167. package/src/iso-editor/ui/props.ts +347 -0
  168. package/src/iso-editor/ui/scope-css.ts +65 -0
  169. package/src/iso-editor/ui/setup.ts +153 -0
  170. package/src/iso-editor/ui/skin.css +181 -0
  171. package/src/iso-editor/ui/text.ts +262 -0
  172. package/src/iso-editor/ui/tree.ts +657 -0
  173. package/src/iso-editor/validate.ts +62 -0
  174. package/src/iso-editor/window/protocol.ts +33 -0
  175. package/src/iso-objects/assemble.ts +57 -0
  176. package/src/iso-objects/assets.ts +122 -0
  177. package/src/iso-objects/board.ts +169 -0
  178. package/src/iso-objects/compile.ts +76 -0
  179. package/src/iso-objects/css.ts +163 -0
  180. package/src/iso-objects/flat.ts +653 -0
  181. package/src/iso-objects/focus.ts +14 -0
  182. package/src/iso-objects/geometry.ts +86 -0
  183. package/src/iso-objects/index.ts +33 -0
  184. package/src/iso-objects/kinds.ts +56 -0
  185. package/src/iso-objects/labels.ts +310 -0
  186. package/src/iso-objects/package.json +6 -0
  187. package/src/iso-objects/place.ts +318 -0
  188. package/src/iso-objects/route.ts +444 -0
  189. package/src/iso-objects/scene.ts +376 -0
  190. package/src/iso-objects/steps.ts +234 -0
  191. package/src/iso-objects/types.ts +68 -0
  192. package/src/iso-systems/catalog.ts +31 -0
  193. package/src/iso-systems/compile.ts +39 -0
  194. package/src/iso-systems/css.ts +9 -0
  195. package/src/iso-systems/index.ts +12 -0
  196. package/src/iso-systems/nodes.ts +126 -0
  197. package/src/iso-systems/package.json +6 -0
  198. package/src/iso-systems/schema.json +311 -0
  199. package/src/iso-systems/validate.ts +34 -0
  200. package/src/iso-viewer/bundle.ts +15 -0
  201. package/src/iso-viewer/card-motion.ts +237 -0
  202. package/src/iso-viewer/dom.ts +13 -0
  203. package/src/iso-viewer/dual-view.ts +212 -0
  204. package/src/iso-viewer/flat-view.ts +127 -0
  205. package/src/iso-viewer/history.ts +781 -0
  206. package/src/iso-viewer/index.ts +40 -0
  207. package/src/iso-viewer/morph.ts +191 -0
  208. package/src/iso-viewer/overlay.ts +212 -0
  209. package/src/iso-viewer/package.json +6 -0
  210. package/src/iso-viewer/page.ts +150 -0
  211. package/src/iso-viewer/player.ts +321 -0
  212. package/src/iso-viewer/still.ts +74 -0
  213. package/src/iso-viewer/timeline-contract.ts +342 -0
  214. package/src/iso-viewer/timeline-engine.ts +420 -0
  215. package/src/iso-viewer/timeline-export.ts +31 -0
  216. package/src/iso-viewer/timeline-scale.ts +129 -0
  217. package/src/iso-viewer/timeline-scope.ts +56 -0
  218. package/src/iso-viewer/timeline-search.ts +198 -0
  219. package/src/iso-viewer/timeline-time.ts +54 -0
  220. package/src/iso-viewer/view-css.ts +59 -0
  221. package/src/iso-viewer/viewport.ts +142 -0
  222. package/types/iso-core/compile-schema.d.ts +11 -0
  223. package/types/iso-core/depth.d.ts +6 -0
  224. package/types/iso-core/errors.d.ts +24 -0
  225. package/types/iso-core/glyphs.d.ts +19 -0
  226. package/types/iso-core/index.d.ts +17 -0
  227. package/types/iso-core/kernel.d.ts +130 -0
  228. package/types/iso-core/metrics.json +1 -0
  229. package/types/iso-core/parse.d.ts +18 -0
  230. package/types/iso-core/schema-errors.d.ts +14 -0
  231. package/types/iso-core/shims/crypto.d.ts +9 -0
  232. package/types/iso-core/svg-dom.d.ts +15 -0
  233. package/types/iso-core/theme.d.ts +38 -0
  234. package/types/iso-core/vdom.d.ts +26 -0
  235. package/types/iso-editor/adapter.d.ts +178 -0
  236. package/types/iso-editor/clipboard.d.ts +23 -0
  237. package/types/iso-editor/commands.d.ts +32 -0
  238. package/types/iso-editor/complete.d.ts +25 -0
  239. package/types/iso-editor/doc.d.ts +50 -0
  240. package/types/iso-editor/index.d.ts +57 -0
  241. package/types/iso-editor/model.d.ts +96 -0
  242. package/types/iso-editor/outline.d.ts +28 -0
  243. package/types/iso-editor/path.d.ts +7 -0
  244. package/types/iso-editor/providers.d.ts +43 -0
  245. package/types/iso-editor/schema-nav.d.ts +34 -0
  246. package/types/iso-editor/splice.d.ts +53 -0
  247. package/types/iso-editor/storage-keys.d.ts +5 -0
  248. package/types/iso-editor/ui/actions.d.ts +23 -0
  249. package/types/iso-editor/ui/canvas-layer.d.ts +65 -0
  250. package/types/iso-editor/ui/canvas.d.ts +307 -0
  251. package/types/iso-editor/ui/clip.d.ts +14 -0
  252. package/types/iso-editor/ui/dialog.d.ts +7 -0
  253. package/types/iso-editor/ui/flat-canvas.d.ts +2 -0
  254. package/types/iso-editor/ui/icons.d.ts +5 -0
  255. package/types/iso-editor/ui/keys.d.ts +7 -0
  256. package/types/iso-editor/ui/later.d.ts +12 -0
  257. package/types/iso-editor/ui/layer.d.ts +2 -0
  258. package/types/iso-editor/ui/menu.d.ts +21 -0
  259. package/types/iso-editor/ui/mount-kit.d.ts +31 -0
  260. package/types/iso-editor/ui/mount.d.ts +146 -0
  261. package/types/iso-editor/ui/pane.d.ts +60 -0
  262. package/types/iso-editor/ui/part.d.ts +40 -0
  263. package/types/iso-editor/ui/plain-icons.d.ts +10 -0
  264. package/types/iso-editor/ui/props.d.ts +57 -0
  265. package/types/iso-editor/ui/scope-css.d.ts +5 -0
  266. package/types/iso-editor/ui/setup.d.ts +49 -0
  267. package/types/iso-editor/ui/text.d.ts +19 -0
  268. package/types/iso-editor/ui/tree.d.ts +100 -0
  269. package/types/iso-editor/validate.d.ts +36 -0
  270. package/types/iso-editor/window/protocol.d.ts +60 -0
  271. package/types/iso-objects/assemble.d.ts +35 -0
  272. package/types/iso-objects/assets.d.ts +49 -0
  273. package/types/iso-objects/board.d.ts +36 -0
  274. package/types/iso-objects/compile.d.ts +35 -0
  275. package/types/iso-objects/css.d.ts +16 -0
  276. package/types/iso-objects/flat.d.ts +130 -0
  277. package/types/iso-objects/focus.d.ts +1 -0
  278. package/types/iso-objects/geometry.d.ts +59 -0
  279. package/types/iso-objects/index.d.ts +26 -0
  280. package/types/iso-objects/kinds.d.ts +53 -0
  281. package/types/iso-objects/labels.d.ts +92 -0
  282. package/types/iso-objects/place.d.ts +25 -0
  283. package/types/iso-objects/route.d.ts +67 -0
  284. package/types/iso-objects/scene.d.ts +63 -0
  285. package/types/iso-objects/steps.d.ts +90 -0
  286. package/types/iso-objects/types.d.ts +140 -0
  287. package/types/iso-systems/catalog.d.ts +4 -0
  288. package/types/iso-systems/compile.d.ts +6 -0
  289. package/types/iso-systems/css.d.ts +3 -0
  290. package/types/iso-systems/index.d.ts +5 -0
  291. package/types/iso-systems/nodes.d.ts +3 -0
  292. package/types/iso-viewer/card-motion.d.ts +56 -0
  293. package/types/iso-viewer/dom.d.ts +1 -0
  294. package/types/iso-viewer/dual-view.d.ts +44 -0
  295. package/types/iso-viewer/flat-view.d.ts +25 -0
  296. package/types/iso-viewer/history.d.ts +91 -0
  297. package/types/iso-viewer/index.d.ts +31 -0
  298. package/types/iso-viewer/morph.d.ts +28 -0
  299. package/types/iso-viewer/overlay.d.ts +135 -0
  300. package/types/iso-viewer/page.d.ts +13 -0
  301. package/types/iso-viewer/still.d.ts +26 -0
  302. package/types/iso-viewer/timeline-contract.d.ts +345 -0
  303. package/types/iso-viewer/timeline-engine.d.ts +20 -0
  304. package/types/iso-viewer/timeline-export.d.ts +5 -0
  305. package/types/iso-viewer/timeline-scale.d.ts +44 -0
  306. package/types/iso-viewer/timeline-scope.d.ts +33 -0
  307. package/types/iso-viewer/timeline-search.d.ts +52 -0
  308. package/types/iso-viewer/timeline-time.d.ts +8 -0
  309. package/types/iso-viewer/view-css.d.ts +7 -0
  310. package/types/iso-viewer/viewport.d.ts +50 -0
@@ -0,0 +1,307 @@
1
+ import { type IconName } from './icons.js';
2
+ import { type MenuItem } from './menu.js';
3
+ import { type Actions } from './actions.js';
4
+ import { type Move } from '../../iso-objects/geometry.js';
5
+ import { type KindCatalog } from '../../iso-objects/kinds.js';
6
+ import type { CompiledScene } from '../../iso-objects/compile.js';
7
+ import type { EditorModel } from '../model.js';
8
+ import type { Problem } from '../validate.js';
9
+ import { type Commands } from '../commands.js';
10
+ import type { ObjectKindInfo, ObjectRef, ConnectPlan, GroupPlan } from '../adapter.js';
11
+ import { type Path } from '../path.js';
12
+ import { type View } from '../../iso-viewer/viewport.js';
13
+ import type { CanvasCtx, CanvasLayer } from './canvas-layer.js';
14
+ import type { FlatStyle } from '../../iso-viewer/flat-view.js';
15
+ import type { FlatOptions } from '../../iso-objects/flat.js';
16
+ import type { SvgMorph } from '../../iso-viewer/morph.js';
17
+ /** what the canvas draws: the domain's drawn document */
18
+ export interface CanvasDrawing {
19
+ scene: CompiledScene;
20
+ /** the frame: the scene's SVG */
21
+ svg: string;
22
+ /** data-id → the JSON pointer in the file it shows */
23
+ pathOf: Map<string, string>;
24
+ /** object name → the id of the element a pin moves */
25
+ pinId: Map<string, string>;
26
+ /** pins that couldn't apply, with why */
27
+ pinNotes: string[];
28
+ diags: string[];
29
+ }
30
+ /** a scene drawn in 2D, as the canvas uses it (flat-canvas.ts makes it) */
31
+ export interface FlatDrawn {
32
+ svg: string;
33
+ /** its viewBox */
34
+ full: [number, number, number, number];
35
+ /** the layout (for tests) */
36
+ layout: unknown;
37
+ /** the outlines of these drawn ids: a card's or a panel's rect, a link's path */
38
+ outlines(ids: Set<string>, svg: SVGSVGElement): ({
39
+ kind: 'poly';
40
+ id: string;
41
+ points: [number, number][];
42
+ } | {
43
+ kind: 'route';
44
+ d: string;
45
+ })[];
46
+ /** the ids of the cards and panels in a rectangle (or touching it) */
47
+ hits(r: {
48
+ l: number;
49
+ t: number;
50
+ r: number;
51
+ b: number;
52
+ }, touch: boolean): string[];
53
+ /** the panels under a point, innermost first */
54
+ panelsAt(x: number, y: number): string[];
55
+ }
56
+ /** the 2D view's implementation, handed to the canvas by its host */
57
+ export interface FlatCanvas {
58
+ draw(scene: CompiledScene, stage: Element, o: {
59
+ styles?: Record<string, FlatStyle>;
60
+ title?: string;
61
+ options?: Partial<FlatOptions>;
62
+ }): FlatDrawn;
63
+ /** (0.7.5) the switch's morph, from the view on the stage to the other, both laid out in `root`: undefined when it
64
+ * shouldn't animate (the motion option, reduced motion); the canvas shows and hides the two drawings itself */
65
+ morph?(root: HTMLElement, scene: CompiledScene, from: {
66
+ svg: SVGSVGElement;
67
+ mode: '3d' | '2d';
68
+ }, to: SVGSVGElement, o: {
69
+ duration?: number;
70
+ motion?: 'auto' | 'always' | 'never';
71
+ }): SvgMorph | undefined;
72
+ }
73
+ /** a drop into a container: what the new object is made as, and the words for it */
74
+ export interface DropInto {
75
+ container: string;
76
+ value(container: string): unknown;
77
+ label(container: string): string;
78
+ }
79
+ /** the canvas's words and names */
80
+ export interface CanvasUi {
81
+ /** the stage's class (the host's canvas CSS is scoped under it), and the drawing's class while the space key is down */
82
+ rootClass: string;
83
+ panKeyClass: string;
84
+ /** the kinds the canvas's menu offers, in order */
85
+ newOrder: string[];
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
+ text: {
90
+ stage: string;
91
+ dragGroup: string;
92
+ dragSelectTip: string;
93
+ unreadable: string;
94
+ palette: string;
95
+ /** the end of a pin drag's hint */
96
+ pinHint: string;
97
+ renameWhy: string;
98
+ duplicateWhy: string;
99
+ };
100
+ }
101
+ export interface PaletteItem {
102
+ kind: string;
103
+ icon: IconName;
104
+ label: string;
105
+ value?(): unknown;
106
+ name?: string;
107
+ }
108
+ /** what the canvas is given of the domain (M: the domain's reading of the file; D: its drawing) */
109
+ export interface CanvasKit<M, D extends CanvasDrawing> {
110
+ draw(model: M, data: unknown, theme: string): D;
111
+ /** the drawing a text would be (a trial: where a drop lands), or undefined */
112
+ trial(text: string, theme: string): D | undefined;
113
+ catalog: KindCatalog;
114
+ objectOf(ptr: string): ObjectRef | undefined;
115
+ kinds: ObjectKindInfo[];
116
+ commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertCmd' | 'insertItemCmd' | 'pinsCmd' | 'withPinsMoved' | 'describe' | 'freshName'>;
117
+ /** (0.10.0) a connection drawn from one object to another (the adapter's connect): the canvas offers the gesture (a
118
+ * handle on a selected object, and "Connect to…") only when it is given */
119
+ connect?(from: ObjectRef, to: ObjectRef, data: unknown): ConnectPlan | undefined;
120
+ /** (0.10.1) a palette drop onto an object (the adapter's dropInto): the new thing inside it, asked innermost first */
121
+ dropOnto?(target: ObjectRef, value: unknown, kind: string, data: unknown): {
122
+ value: unknown;
123
+ label?: string;
124
+ } | undefined;
125
+ /** (0.10.0) the selection made into a new container (the adapter's group): Group, ⌘G, one undo step */
126
+ group?(members: ObjectRef[], data: unknown): GroupPlan | undefined;
127
+ actions: Actions;
128
+ /** what an object's own menu offers, beyond rename, duplicate and delete */
129
+ objectItems(doc: EditorModel, path: Path, origin: 'canvas' | 'menu', note?: (t: string, tone?: 'bad') => void): MenuItem[];
130
+ pins: {
131
+ key: string;
132
+ legacyKey?: string;
133
+ of(data: unknown): Record<string, unknown> | undefined;
134
+ keyOf(data: unknown): string;
135
+ legacyOnly(data: unknown): boolean;
136
+ };
137
+ /** the 2D view (0.6.4): offered as a 3D | 2D switch when given. `load` hands over its implementation (flat-canvas.ts;
138
+ * the canvas never names it, so a host without a 2D view bundles none of it). In 2D, selecting, the menu, renaming,
139
+ * deleting, adding from the palette (into a panel, or placed by the layout) and undo work as in 3D; pins (moving)
140
+ * are 3D only. The host's canvas CSS has the 2D view's (flatCss), scoped as the drawing's is. */
141
+ flat?: {
142
+ load(): Promise<FlatCanvas>;
143
+ styles?: Record<string, FlatStyle>;
144
+ title?: string;
145
+ options?: Partial<FlatOptions>;
146
+ /** (0.7.5) the switch morphs, as dualView does: 'auto' (the default) honours prefers-reduced-motion, 'always' morphs
147
+ * regardless, 'never' swaps at once; `duration` in ms (600) */
148
+ motion?: 'auto' | 'always' | 'never';
149
+ duration?: number;
150
+ };
151
+ /** a drop of this kind onto a container's floor (none: it is pinned where it drops) */
152
+ dropInto?(kind: string): DropInto | undefined;
153
+ ui: CanvasUi;
154
+ }
155
+ export interface CanvasOpts<M, D extends CanvasDrawing, A extends object = object> {
156
+ kit: CanvasKit<M, D>;
157
+ theme: string;
158
+ problems(): Problem[];
159
+ note(t: string, tone?: 'info' | 'warn' | 'bad'): void;
160
+ showInText(p: Path): void;
161
+ showInTree(p: Path): void;
162
+ onZoom(pct: number): void;
163
+ /** the navigation modes, for the status bar */
164
+ onHint?(text: string): void;
165
+ /** Copy, Cut and Paste for the menu */
166
+ clipItems?(): MenuItem[];
167
+ /** where the navigation modes are kept between visits (the host's storage); none: for this mount only */
168
+ store?: {
169
+ get(k: string): string | null;
170
+ set(k: string, v: string | null): void;
171
+ };
172
+ /** a layer over the drawing (none: the drawing and its marks only) */
173
+ layer?: (ctx: CanvasCtx<D>) => CanvasLayer<A>;
174
+ }
175
+ export declare function canvasView<M, D extends CanvasDrawing, A extends object = object>(host: HTMLElement, doc: EditorModel, opts: CanvasOpts<M, D, A>): {
176
+ addFromPalette: (sec: string, at?: {
177
+ x: number;
178
+ y: number;
179
+ }, item?: PaletteItem) => Path | undefined;
180
+ palette: HTMLDivElement;
181
+ groupSelection: () => void;
182
+ startPick: () => void;
183
+ objectsUnder: (at: {
184
+ x: number;
185
+ y: number;
186
+ }) => ObjectRef[];
187
+ readonly linking: {
188
+ from: ObjectRef;
189
+ x?: number;
190
+ y?: number;
191
+ over?: string;
192
+ pick?: boolean;
193
+ } | undefined;
194
+ render: (s3: M | undefined, data: unknown) => Promise<void>;
195
+ setTheme: (_t: 'light' | 'dark') => void;
196
+ paintOverlay: () => void;
197
+ fit: () => void;
198
+ fitAll: (box?: View | undefined) => void;
199
+ actual: () => void;
200
+ zoomAt: (f: number, cx?: number, cy?: number) => void;
201
+ itemsBox: () => {
202
+ x: number;
203
+ y: number;
204
+ w: number;
205
+ h: number;
206
+ } | undefined;
207
+ readonly moved: boolean;
208
+ settled: () => Promise<void>;
209
+ readonly zoom: number;
210
+ dispose(): void;
211
+ focus: () => void;
212
+ /** for the tests */
213
+ readonly view: View | undefined;
214
+ readonly doc: D | undefined;
215
+ /** the view (3D or 2D), and the 2D layout while it shows */
216
+ readonly mode: "2d" | "3d";
217
+ setMode: (m: '3d' | '2d') => void;
218
+ readonly flat: unknown;
219
+ stage: HTMLDivElement;
220
+ key: (e: KeyboardEvent) => void;
221
+ scale: () => number;
222
+ nav: {
223
+ wheel: 'zoom' | 'scroll';
224
+ drag: 'pan' | 'select';
225
+ };
226
+ paintNav: () => void;
227
+ outlinesFor: (ptr: string) => ({
228
+ kind: 'poly';
229
+ id: string;
230
+ points: [number, number][];
231
+ } | {
232
+ kind: 'route';
233
+ d: string;
234
+ })[];
235
+ footprints: () => Map<string, {
236
+ x0: number;
237
+ y0: number;
238
+ x1: number;
239
+ y1: number;
240
+ }>;
241
+ readonly drag: {
242
+ kind: 'pan' | 'marquee' | 'pin' | 'click';
243
+ x0: number;
244
+ y0: number;
245
+ v0?: View;
246
+ emptyClick?: boolean;
247
+ start?: [number, number];
248
+ shown?: [number, number];
249
+ z0?: number;
250
+ size?: [number, number];
251
+ parent?: {
252
+ w: number;
253
+ d: number;
254
+ pad: number;
255
+ box: {
256
+ x0: number;
257
+ y0: number;
258
+ x1: number;
259
+ y1: number;
260
+ };
261
+ label: string;
262
+ };
263
+ siblings?: {
264
+ x0: number;
265
+ y0: number;
266
+ x1: number;
267
+ y1: number;
268
+ }[];
269
+ move?: Move;
270
+ invalid?: boolean;
271
+ step?: number;
272
+ origCd?: D;
273
+ gridShown?: boolean;
274
+ /** siblings that flow after the dragged item, pinned where they stand so the drag doesn't push them */
275
+ keep?: [string, [number, number]][];
276
+ sel0?: Path[];
277
+ add?: boolean;
278
+ touch?: boolean;
279
+ name?: string;
280
+ id?: string;
281
+ box?: {
282
+ x: number;
283
+ y: number;
284
+ w: number;
285
+ h: number;
286
+ };
287
+ moved?: boolean;
288
+ ptr?: string;
289
+ narrow?: string;
290
+ } | undefined;
291
+ readonly lastMarquee: {
292
+ x0: number;
293
+ y0: number;
294
+ x1: number;
295
+ y1: number;
296
+ } | undefined;
297
+ boxFor: (p: Path) => {
298
+ x: number;
299
+ y: number;
300
+ w: number;
301
+ h: number;
302
+ } | undefined;
303
+ pageXYOf: (p: Path) => {
304
+ x: number;
305
+ y: number;
306
+ } | undefined;
307
+ } & A;
@@ -0,0 +1,14 @@
1
+ import type { Clipboard } from '../clipboard.js';
2
+ import type { EditorModel } from '../model.js';
3
+ import type { MenuItem } from './menu.js';
4
+ export interface Clip {
5
+ /** the menu items for what is selected */
6
+ items(): MenuItem[];
7
+ /** handle the clipboard events of a document (the page, or the canvas's frame) */
8
+ attach(d: EventTarget, owns: (target: EventTarget | null) => boolean): () => void;
9
+ copy(): Promise<boolean>;
10
+ cut(): Promise<boolean>;
11
+ paste(text?: string): Promise<boolean>;
12
+ }
13
+ /** the page's clipboard over the domain's (its copyText, cutCmd and pasteCmd: src/iso-editor/clipboard.ts) */
14
+ export declare function clipboard(doc: EditorModel, note: (t: string, tone?: 'info' | 'warn' | 'bad') => void, services: Clipboard): Clip;
@@ -0,0 +1,7 @@
1
+ export interface DialogButton {
2
+ label: string;
3
+ value: string;
4
+ primary?: boolean;
5
+ danger?: boolean;
6
+ }
7
+ export declare function ask(title: string, body: (Node | string)[], buttons: DialogButton[]): Promise<string | null>;
@@ -0,0 +1,2 @@
1
+ import type { FlatCanvas } from './canvas.js';
2
+ export declare const flatCanvas: FlatCanvas;
@@ -0,0 +1,5 @@
1
+ /** an icon's name in the sprite */
2
+ export type IconName = string;
3
+ export declare function icon(name: IconName, cls?: string): SVGSVGElement;
4
+ /** h(): the DOM, built as text only (never HTML), from the viewer (src/iso-viewer/dom.ts) */
5
+ export { h } from '../../iso-viewer/dom.js';
@@ -0,0 +1,7 @@
1
+ export type KeyGroup = {
2
+ where: string;
3
+ keys: [string, string][];
4
+ };
5
+ /** The map with a host's own keys added to the first group (the standalone page: ⇧⌘S Save as, ⌘O Open). */
6
+ export declare function keymapWith(map: KeyGroup[], extra: [string, string][]): KeyGroup[];
7
+ export declare function keySheet(map: KeyGroup[]): HTMLDialogElement;
@@ -0,0 +1,12 @@
1
+ import type { Change } from '../model.js';
2
+ export declare const TYPING_PAUSE_MS = 150;
3
+ /** Is this change typing (from a text pane)? Then the structural views can wait. */
4
+ export declare const isTyping: (c: Change) => boolean;
5
+ /** A function that runs `fn` once, `ms` after the last call; `now()` runs it at once (and cancels the wait); `cancel()`
6
+ * drops a pending run (when the editor is disposed). */
7
+ export declare function later(fn: () => void, ms?: number): {
8
+ (): void;
9
+ now(): void;
10
+ pending(): boolean;
11
+ cancel(): void;
12
+ };
@@ -0,0 +1,2 @@
1
+ export declare function setLayer(el: HTMLElement | null): void;
2
+ export declare function layer(): HTMLElement;
@@ -0,0 +1,21 @@
1
+ import { type IconName } from './icons.js';
2
+ export type MenuItem = {
3
+ label: string;
4
+ icon?: IconName;
5
+ desc?: string;
6
+ keys?: string;
7
+ danger?: boolean;
8
+ disabled?: boolean;
9
+ why?: string;
10
+ onSelect(): void;
11
+ } | {
12
+ sep: true;
13
+ } | {
14
+ heading: string;
15
+ };
16
+ export declare const menuOpen: () => boolean;
17
+ export declare function openMenu(items: MenuItem[], at: {
18
+ x: number;
19
+ y: number;
20
+ } | HTMLElement, label?: string): HTMLElement;
21
+ export declare function closeMenu(): void;
@@ -0,0 +1,31 @@
1
+ import type { Problem } from '../validate.js';
2
+ import type { SchemaNav } from '../schema-nav.js';
3
+ import type { FileRole } from '../adapter.js';
4
+ import type { KeyGroup } from './keys.js';
5
+ /** a text, checked (R: the domain's reading; X: a host's deeper check, shown beside Problems) */
6
+ export interface Checked<R, X> {
7
+ problems: Problem[];
8
+ read: R | undefined;
9
+ /** each object's tag (the tree's pills) */
10
+ tags: Map<string, string>;
11
+ /** what the canvas draws (undefined: nothing), and the data it is drawn from */
12
+ model: unknown;
13
+ data: unknown;
14
+ extra: X | undefined;
15
+ }
16
+ export interface MountKit<R, X> {
17
+ /** check a text (prev: the last check's extra); a failure of the host's check is a note, not a throw */
18
+ check(text: string, prev: X | undefined, note: (t: string, tone?: 'info' | 'warn' | 'bad') => void): Promise<Checked<R, X>>;
19
+ role(text: string): FileRole;
20
+ /** the status bar's word for the file's kind */
21
+ kindLabel(text: string): string;
22
+ nav(text: string): SchemaNav;
23
+ /** an object's pointer, by its name, in the reading */
24
+ objectPath(name: string, read: R | undefined): string | undefined;
25
+ /** the host's check beside Problems, in a word (none: '' and '') */
26
+ extraLabel(extra: X | undefined): {
27
+ text: string;
28
+ cls: string;
29
+ };
30
+ keymap: KeyGroup[];
31
+ }
@@ -0,0 +1,146 @@
1
+ import type { MonacoPane } from './text.js';
2
+ import type { PaneOpts } from './pane.js';
3
+ import type { Clip } from './clip.js';
4
+ import { type TreeKit } from './tree.js';
5
+ import { EditorModel } from '../model.js';
6
+ import type { Problem } from '../validate.js';
7
+ import type { MountKit } from './mount-kit.js';
8
+ import type { PartCtx, EditorPart } from './part.js';
9
+ export type Theme = 'light' | 'dark' | 'system';
10
+ export type SaveResult = {
11
+ ok: true;
12
+ } | {
13
+ conflict: true;
14
+ };
15
+ /** what a host adds to the shell */
16
+ export interface HostHooks {
17
+ titleStart?: HTMLElement[];
18
+ sideTabs?: {
19
+ id: string;
20
+ label: string;
21
+ icon: string;
22
+ panel: HTMLElement;
23
+ }[];
24
+ keys?(e: KeyboardEvent): boolean;
25
+ keymap?: [string, string][];
26
+ themeControls?: boolean;
27
+ onOpen?(rel: string): void;
28
+ onSaveAs?(): void;
29
+ onConflict?(): void;
30
+ /** the setup's brand mark in the title bar */
31
+ brand?: boolean;
32
+ }
33
+ export interface EditorOptions {
34
+ text?: string;
35
+ readOnly?: boolean;
36
+ theme?: Theme;
37
+ storage?: {
38
+ get(k: string): string | null;
39
+ set(k: string, v: string | null): void;
40
+ };
41
+ watch?: boolean;
42
+ onSave?(text: string): Promise<SaveResult>;
43
+ onDirtyChange?(dirty: boolean): void;
44
+ host?: HostHooks;
45
+ }
46
+ /** the shell's words (markup is the setup's constant, never the file's) */
47
+ export interface ShellWords {
48
+ rootClass: string;
49
+ /** the brand mark's markup */
50
+ brand: string;
51
+ sideLabel: string;
52
+ canvasLabel: string;
53
+ problemsLabel: string;
54
+ bottomTabsLabel: string;
55
+ extraTab: string;
56
+ /** more panels' slots under the work area (markup) */
57
+ slots: string;
58
+ }
59
+ /** the views' features, as the shell uses them (a feature not given is never loaded) */
60
+ export interface ShellFeatures {
61
+ text?: {
62
+ textPane(el: HTMLElement, doc: EditorModel, o: Omit<PaneOpts, 'services'>): MonacoPane;
63
+ };
64
+ canvas?: {
65
+ canvasView(host: HTMLElement, doc: EditorModel, o: never): ShellCanvas;
66
+ };
67
+ edit?: {
68
+ propsPanel(body: HTMLElement, doc: EditorModel, o: never): {
69
+ paint(): void;
70
+ dispose(): void;
71
+ };
72
+ clipboard(doc: EditorModel, note: (t: string, tone?: 'info' | 'warn' | 'bad') => void): Clip;
73
+ };
74
+ /** the host's deeper check, as a panel beside Problems */
75
+ plan?: {
76
+ planPanel(el: HTMLElement, o: {
77
+ has(name: string): boolean;
78
+ select(name: string): boolean;
79
+ }): {
80
+ paint(extra: unknown, has: boolean): void;
81
+ };
82
+ };
83
+ }
84
+ /** what the shell calls on a canvas */
85
+ export interface ShellCanvas {
86
+ render(model: unknown, data: unknown): Promise<void>;
87
+ setTheme(t: 'light' | 'dark'): void;
88
+ fit(): void;
89
+ focus(): void;
90
+ dispose(): void;
91
+ }
92
+ /** what the domain gives the mounted editor */
93
+ export interface EditorSetup<R, X, A extends object> {
94
+ kit: MountKit<R, X>;
95
+ tree: TreeKit;
96
+ words: ShellWords;
97
+ features: ShellFeatures & Record<string, unknown>;
98
+ /** every feature's name, and those that can be added to a mounted editor */
99
+ names: readonly string[];
100
+ late: readonly string[];
101
+ load?: (names: readonly string[]) => Promise<{
102
+ name: string;
103
+ }[]>;
104
+ /** the host's deeper check is given (its panel paints "none" otherwise) */
105
+ hasExtra: boolean;
106
+ /** the domain's own canvas options (its layer's), given its part's calls */
107
+ canvasOpts?(part: () => A): Record<string, unknown>;
108
+ part?(ctx: PartCtx, deps: {
109
+ canvas: () => ShellCanvas;
110
+ objectPath(name: string): string | undefined;
111
+ }): EditorPart<A>;
112
+ /** what an absent canvas answers, beyond nothing */
113
+ noCanvas?: Record<string, unknown>;
114
+ /** more of the internal handle */
115
+ internal?: Record<string, unknown>;
116
+ /** the icons the views use (<svg> markup of <symbol id="se-i-NAME">s; the build makes it from the domain's icon names) */
117
+ sprite?: string;
118
+ }
119
+ /** The editor's state, for the standalone page and the tests (not part of the component's API). */
120
+ export interface EditorState<R = unknown, X = unknown> {
121
+ problems: Problem[];
122
+ lifetimes: Map<string, string>;
123
+ read: R | undefined;
124
+ plan: X | undefined;
125
+ view: 'canvas' | 'both' | 'text';
126
+ theme: Theme;
127
+ density: 'comfortable' | 'compact';
128
+ readOnly: boolean;
129
+ problemsOpen: boolean;
130
+ problemsSeen: number;
131
+ checks: number;
132
+ }
133
+ export interface Editor {
134
+ getText(): string;
135
+ setText(text: string): void;
136
+ setReadOnly(ro: boolean): void;
137
+ setTheme(t: Theme): void;
138
+ addFeatures(names: readonly string[]): Promise<void>;
139
+ fit(): void;
140
+ dispose(): void;
141
+ }
142
+ /** P3: the editor with the features given (the core alone: the shell, the model, the reader and the tree; read-only
143
+ * unless edit is given). */
144
+ export declare function mountEditor<R, X, A extends object = object>(el: HTMLElement, opts: EditorOptions, S: EditorSetup<R, X, A>): Editor & {
145
+ internal: Record<string, unknown>;
146
+ };
@@ -0,0 +1,60 @@
1
+ import type { Problem } from '../validate.js';
2
+ import type { Path } from '../path.js';
3
+ import type { EditorDoc } from '../doc.js';
4
+ import type { Item } from '../complete.js';
5
+ /** A text selection as offsets into the text, the form the model keeps for undo (any pane can put it back). */
6
+ export type TextSel = {
7
+ anchor: number;
8
+ head: number;
9
+ }[];
10
+ export interface TextPane {
11
+ id: 'monaco';
12
+ el: HTMLElement;
13
+ setProblems(ps: Problem[]): void;
14
+ /** the path at the caret, for the status bar */
15
+ pathAtCaret(): Path;
16
+ /** mark paths in the text (and move the caret to the first, unless this pane has the focus) */
17
+ showSelection(paths: Path[], move: boolean): void;
18
+ /** put the caret at a path, scroll to it, and focus the pane */
19
+ goTo(path: Path): void;
20
+ /** put the caret at an offset, scroll to it, and focus the pane */
21
+ goToOffset(offset: number): void;
22
+ /** the caret, 1-based, for the status bar */
23
+ caret(): {
24
+ line: number;
25
+ col: number;
26
+ } | undefined;
27
+ /** the caret moved (in this pane) */
28
+ onCaret(fn: () => void): void;
29
+ hasFocus(): boolean;
30
+ focus(): void;
31
+ setTheme(dark: boolean): void;
32
+ /** times the pane and the model disagreed and the pane was put right (should stay 0: the tests check) */
33
+ resyncs(): number;
34
+ }
35
+ /** what a pane asks of the domain, by offset into the text (the editor core's providers, given an adapter) */
36
+ export interface TextServices {
37
+ docFor(text: string): EditorDoc;
38
+ completionAt(d: EditorDoc, offset: number): {
39
+ from: number;
40
+ items: Item[];
41
+ };
42
+ hoverAt(d: EditorDoc, offset: number): {
43
+ from: number;
44
+ to: number;
45
+ parts: string[];
46
+ } | null;
47
+ definitionAt(d: EditorDoc, offset: number): {
48
+ from: number;
49
+ to: number;
50
+ } | {
51
+ open: string;
52
+ } | null;
53
+ rangeOfPath(d: EditorDoc, p: Path): [number, number] | undefined;
54
+ }
55
+ export interface PaneOpts {
56
+ services: TextServices;
57
+ onOpen?(file: string): void;
58
+ onSave?(): void;
59
+ onSaveAs?(): void;
60
+ }
@@ -0,0 +1,40 @@
1
+ import type { EditorModel } from '../model.js';
2
+ /** what the editor gives a part */
3
+ export interface PartCtx {
4
+ root: HTMLElement;
5
+ /** one of the shell's elements, by its id (without the prefix) */
6
+ byId<T extends HTMLElement = HTMLElement>(id: string): T;
7
+ doc: EditorModel;
8
+ store: {
9
+ get(k: string): string | null;
10
+ set(k: string, v: string | null): void;
11
+ };
12
+ note(t: string, tone?: 'info' | 'warn' | 'bad'): void;
13
+ /** the editor shows the file for this mount only (nothing it shows is kept) */
14
+ watch: boolean;
15
+ /** a listener, removed when the editor is disposed */
16
+ on(t: EventTarget, ev: string, fn: (e: never) => void): void;
17
+ disposed(): boolean;
18
+ paintProblems(): void;
19
+ paintProps(): void;
20
+ }
21
+ /** what waits for a person: rows put before the file's problems */
22
+ export interface Attention {
23
+ /** how many (they count as problems seen) */
24
+ count: number;
25
+ /** how many open the list when they appear */
26
+ opens: number;
27
+ /** the list keeps still (neither opens nor closes for these) */
28
+ still: boolean;
29
+ rows: Node[];
30
+ /** their words in the list's label */
31
+ label: string;
32
+ }
33
+ /** what a part gives the editor; A: its calls */
34
+ export interface EditorPart<A extends object> {
35
+ now?(ptr: string): unknown;
36
+ attention?(): Attention | undefined;
37
+ start?(): void;
38
+ dispose?(): void;
39
+ api: A;
40
+ }
@@ -0,0 +1,10 @@
1
+ /** each icon's SVG body, by name (Lucide, ISC) */
2
+ export declare const PLAIN_ICON_SVG: Record<string, string>;
3
+ /** the names L3 uses */
4
+ export declare const PLAIN_ICONS: readonly string[];
5
+ /** symbols of a sprite: one per icon, with the id icon() and the shell's markup use */
6
+ export declare const iconSymbols: (svgs: Record<string, string>) => string;
7
+ /** a sprite of symbols, as the setup's sprite (mountEditor puts it in the editor's root) */
8
+ export declare const spriteOf: (symbols: string) => string;
9
+ /** L3's sprite: every icon it uses */
10
+ export declare const PLAIN_SPRITE: string;