@johnoscott/isometric-engine 0.0.0-stage → 0.9.0

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 +317 -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 +265 -0
  8. package/assets/default-theme.yaml +99 -0
  9. package/assets/icons.svg +1 -0
  10. package/assets/marks.css +35 -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 +441 -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 +1205 -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 +145 -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 +502 -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 +128 -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 +472 -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 +1071 -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 +35 -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 +144 -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 +145 -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 +279 -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 +40 -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,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;
@@ -0,0 +1,57 @@
1
+ import type { EditorModel } from '../model.js';
2
+ import type { SchemaNav } from '../schema-nav.js';
3
+ import type { Problem } from '../validate.js';
4
+ import type { Commands } from '../commands.js';
5
+ import type { ObjectKindInfo, ObjectRef, RefSlot } from '../adapter.js';
6
+ import { type Actions } from './actions.js';
7
+ import { type Path } from '../path.js';
8
+ /** what the panel shows of the domain */
9
+ export interface PropsUi {
10
+ /** keys worth showing even when unset */
11
+ important(kind: string, value: Record<string, unknown>, external: boolean): string[];
12
+ /** an object that exists elsewhere (only its reference keys apply) */
13
+ isExternal(value: unknown): boolean;
14
+ /** a key one object inherits (its value, and where from), given the domain's reading; and every key it inherits */
15
+ inherited?(path: Path, key: string, read: unknown): {
16
+ value: unknown;
17
+ from?: string;
18
+ } | undefined;
19
+ inheritedKeys?(path: Path, read: unknown): string[];
20
+ /** where inherited values come from, when the reading doesn't say */
21
+ inheritedFrom: string;
22
+ /** what is true now about an object, as rows (undefined: not shown; empty: not known) */
23
+ facts?(now: unknown): {
24
+ term: string;
25
+ def: string;
26
+ cls?: string;
27
+ }[] | undefined;
28
+ /** an x- key's words */
29
+ extensionDoc: string;
30
+ /** the root's title, and its words in a list */
31
+ rootTitle: string;
32
+ rootItem: string;
33
+ }
34
+ /** what the panel is given of the domain */
35
+ export interface PropsKit {
36
+ commands: Pick<Commands, 'setCmd' | 'deleteCmd' | 'insertItemCmd' | 'referencesTo' | 'describe'>;
37
+ actions: Pick<Actions, 'deletePaths' | 'renameDialog'>;
38
+ slotAt(ptr: string): RefSlot | undefined;
39
+ objectOf(ptr: string): ObjectRef | undefined;
40
+ kinds: ObjectKindInfo[];
41
+ ui: PropsUi;
42
+ }
43
+ export interface PropsOpts {
44
+ kit: PropsKit;
45
+ nav(): SchemaNav;
46
+ problems(): Problem[];
47
+ /** the domain's reading of the file (the kit's inherited() reads it) */
48
+ read(): unknown;
49
+ note(t: string, tone?: 'info' | 'warn' | 'bad'): void;
50
+ showInText(p: Path): void;
51
+ /** while the host's state is shown, what is true now about an object (the kit's facts() reads it); undefined while not */
52
+ now?(ptr: string): unknown;
53
+ }
54
+ export declare function propsPanel(body: HTMLElement, doc: EditorModel, opts: PropsOpts): {
55
+ paint: () => void;
56
+ dispose: () => void;
57
+ };
@@ -0,0 +1,5 @@
1
+ /** One selector under the root: html, body and :root (with any state they name) become the root itself; * is the
2
+ * root and everything in it. */
3
+ export declare function scopeOne(sel: string, root: string): string;
4
+ /** Scope a stylesheet to the root class. */
5
+ export declare function scopeCss(css: string, root: string): string;
@@ -0,0 +1,40 @@
1
+ import type { DomainAdapter } from '../adapter.js';
2
+ import type { KindCatalog } from '../../iso-objects/kinds.js';
3
+ import { type CanvasKit, type CanvasDrawing } from './canvas.js';
4
+ import type { CanvasCtx, CanvasLayer } from './canvas-layer.js';
5
+ import type { EditorSetup, ShellWords } from './mount.js';
6
+ import type { PaneOpts } from './pane.js';
7
+ import type { MonacoPane } from './text.js';
8
+ import type { IconName } from './icons.js';
9
+ import type { KeyGroup } from './keys.js';
10
+ import type { EditorModel } from '../model.js';
11
+ import type { PartCtx, EditorPart } from './part.js';
12
+ /** what a domain gives besides its adapter */
13
+ export interface DomainView<R, D extends CanvasDrawing> {
14
+ /** a reading, drawn (the adapter's read() gives the reading) */
15
+ draw(read: R, data: unknown, theme: string): D;
16
+ catalog: KindCatalog;
17
+ theme: string;
18
+ /** the file's name when the host gives none */
19
+ fileName: string;
20
+ /** what a name must be, and the rule in words */
21
+ nameRule?: RegExp;
22
+ nameHint?: string;
23
+ /** a kind's icon (default: box) */
24
+ icon?(kind: string): IconName;
25
+ /** the domain's own icons, as 24 × 24 SVG bodies by name (stroke in currentColor, as Lucide's), added to L3's */
26
+ icons?: Record<string, string>;
27
+ words?: Partial<ShellWords>;
28
+ keymap?: KeyGroup[];
29
+ /** the canvas's 2D view (0.6.0): a 3D | 2D switch; its link kinds' styles (the host's canvas CSS adds flatCss) */
30
+ flat?: CanvasKit<R, D>['flat'];
31
+ /** a layer over the canvas, and a part beside the views (A: their calls) */
32
+ layer?(ctx: CanvasCtx<D>): CanvasLayer<object>;
33
+ part?(ctx: PartCtx): EditorPart<object>;
34
+ }
35
+ /** the plain shell's words */
36
+ export declare const PLAIN_WORDS: ShellWords;
37
+ /** the plain keymap: the shell's own keys */
38
+ export declare const PLAIN_KEYMAP: KeyGroup[];
39
+ /** The kits and features for an adapter (R: its reading; D: its drawing), with the text pane if the host has one. */
40
+ export declare function setupFor<R, D extends CanvasDrawing>(a: DomainAdapter, v: DomainView<R, D>, textPane?: (el: HTMLElement, doc: EditorModel, o: PaneOpts) => MonacoPane): EditorSetup<R, undefined, object>;
@@ -0,0 +1,19 @@
1
+ import 'monaco-editor/languages/definitions/yaml/register.js';
2
+ import type { EditorModel } from '../model.js';
3
+ import type { TextPane, PaneOpts } from './pane.js';
4
+ export type Monaco = typeof import('monaco-editor/editor/editor.api.js');
5
+ export declare const monaco: Monaco;
6
+ type IModel = import('monaco-editor/editor/editor.api.js').editor.ITextModel;
7
+ /** threads Monaco has made and not been given back (for the tests) */
8
+ export declare const liveThreads: () => number;
9
+ export type MonacoPane = TextPane & {
10
+ editor: import('monaco-editor/editor/editor.api.js').editor.IStandaloneCodeEditor;
11
+ model: IModel;
12
+ monaco: Monaco;
13
+ setReadOnly(ro: boolean): void;
14
+ dispose(): void;
15
+ };
16
+ export declare function textPane(el: HTMLElement, doc: EditorModel, opts: PaneOpts): MonacoPane;
17
+ /** Monaco themes made from the page's tokens (--surface, --ink…), as the page resolves them now (light or dark). */
18
+ export declare function paneTheme(dark: boolean, within?: HTMLElement): string;
19
+ export {};
@@ -0,0 +1,100 @@
1
+ import { type IconName } from './icons.js';
2
+ import { type OutlineNode } from '../outline.js';
3
+ import type { EditorModel } from '../model.js';
4
+ import type { EditorDoc } from '../doc.js';
5
+ import type { SchemaNav } from '../schema-nav.js';
6
+ import type { Problem } from '../validate.js';
7
+ import type { Commands } from '../commands.js';
8
+ import type { FileRole, ObjectKindInfo, RefSlot } from '../adapter.js';
9
+ import { type Path } from '../path.js';
10
+ /** a "New …" entry for a kind's group: its words, its icon, and what it starts as (default: the kind's) */
11
+ export interface NewItem {
12
+ label: string;
13
+ icon: IconName;
14
+ desc?: string;
15
+ template?: () => unknown;
16
+ stem?: string;
17
+ }
18
+ /** an entry an entry group offers: its words, its icon, its key (made unique) and its value */
19
+ export interface EntryItem {
20
+ label: string;
21
+ icon: IconName;
22
+ entry: string;
23
+ value: unknown;
24
+ cmdLabel?: string;
25
+ when?: (data: Record<string, unknown>) => boolean;
26
+ }
27
+ /** what the tree shows of the domain, in its words */
28
+ export interface TreeUi {
29
+ /** the tree's aria-label */
30
+ label: string;
31
+ rootIcon: IconName;
32
+ kindIcon(kind: string): IconName;
33
+ /** a top-level key's icon, if it has one */
34
+ keyIcon(key: string): IconName | undefined;
35
+ /** an entry group's entries' icon */
36
+ entryIcon(group: string): IconName;
37
+ /** a kind's group's "New …" entries, in order */
38
+ newItems(kind: string): NewItem[];
39
+ /** an entry group's own add items (its entries made from the file: owned, not yet entered) */
40
+ entryItems?(group: Path, data: Record<string, unknown>, owned: (kind: string) => string[]): EntryItem[];
41
+ /** a tag's pill (none: no pill) */
42
+ tagPill(tag: string): {
43
+ title: string;
44
+ } | undefined;
45
+ /** the name rule, in words */
46
+ nameHint: string;
47
+ text: {
48
+ root: string;
49
+ rootAdd: string;
50
+ renameWhy: string;
51
+ deleteWhy: string;
52
+ duplicateNote: string;
53
+ duplicateWhy: string;
54
+ };
55
+ }
56
+ /** what the tree is given of the domain */
57
+ export interface TreeKit {
58
+ outline(d: EditorDoc, role: FileRole, tags: Map<string, string>): OutlineNode;
59
+ commands: Pick<Commands, 'setCmd' | 'insertCmd' | 'insertItemCmd' | 'deleteCmd' | 'renameCmd' | 'renameKeyCmd' | 'duplicateCmd' | 'moveCmd' | 'moveItemCmd' | 'referencesTo' | 'describe' | 'freshName'>;
60
+ slotAt(ptr: string): RefSlot | undefined;
61
+ /** the kinds, in the outline's order */
62
+ kinds: ObjectKindInfo[];
63
+ /** named maps that aren't kinds (their names a pool of their own) */
64
+ entryGroups: Path[];
65
+ /** what a name must be */
66
+ nameRule: RegExp;
67
+ ui: TreeUi;
68
+ }
69
+ export interface TreeOpts {
70
+ kit: TreeKit;
71
+ nav(): SchemaNav;
72
+ problems(): Problem[];
73
+ role(): FileRole;
74
+ /** each object's tag as the reader resolved it, with the base files merged */
75
+ lifetimes(): Map<string, string>;
76
+ /** show a path in the text pane and give it the focus */
77
+ showInText(path: Path): void;
78
+ /** Copy, Cut and Paste for the menu */
79
+ clipItems?(): import('./menu.js').MenuItem[];
80
+ /** a message for the person (an edit that can't be made) */
81
+ note(text: string, tone?: 'info' | 'warn' | 'bad'): void;
82
+ }
83
+ export declare function treeView(el: HTMLElement, doc: EditorModel, opts: TreeOpts): {
84
+ paint: () => void;
85
+ dispose: () => void;
86
+ focus: () => void;
87
+ /** for the tests */
88
+ rows: () => {
89
+ id: string;
90
+ label: string;
91
+ depth: number;
92
+ kind: import("../outline.js").NodeKind;
93
+ value: string | undefined;
94
+ lifetime: string | undefined;
95
+ }[];
96
+ startEdit: (id: string, mode: 'rename' | 'value') => void;
97
+ remove: (ids: string[]) => Promise<void>;
98
+ duplicate: (id: string) => void;
99
+ expand: (id: string) => void;
100
+ };
@@ -0,0 +1,36 @@
1
+ import { EditorDoc } from './doc.js';
2
+ import type { Diag } from '../iso-core/errors.js';
3
+ import type { PlaceAdapter, ReadAdapter } from './adapter.js';
4
+ export interface Problem {
5
+ severity: 'error' | 'warning';
6
+ message: string;
7
+ hint?: string;
8
+ path: string;
9
+ /** 1-based, end exclusive */
10
+ startLine: number;
11
+ startCol: number;
12
+ endLine: number;
13
+ endCol: number;
14
+ /** the other file it is in, when it isn't this one */
15
+ file?: string;
16
+ }
17
+ export interface ValidateOpts {
18
+ fileName?: string;
19
+ defaults?: {
20
+ name: string;
21
+ text: string;
22
+ }[];
23
+ /** problems resolving extends: (loops, missing files), from the server */
24
+ extendsDiags?: Diag[];
25
+ profiles?: string[];
26
+ }
27
+ /** The problems, and what the reader resolved: each object's tag (with the base files merged), and its own reading. */
28
+ export declare function analyse(a: ReadAdapter, text: string, opts: ValidateOpts & {
29
+ fileName: string;
30
+ }): {
31
+ problems: Problem[];
32
+ tags: Map<string, string>;
33
+ read?: unknown;
34
+ };
35
+ /** A diagnostic as a range in the text (a host's plan problem too: its pointer and line, made a Diag). */
36
+ export declare function place(a: PlaceAdapter, d: EditorDoc, x: Diag, fileName: string): Problem;
@@ -0,0 +1,60 @@
1
+ import type { Theme, SaveResult } from '../ui/mount.js';
2
+ export declare const PROTOCOL = 1;
3
+ export type Refused = {
4
+ refused: string;
5
+ };
6
+ /** what a window can do: a newer window tells an older host what it lacks, and the reverse */
7
+ export interface Capabilities {
8
+ protocol: number;
9
+ features: string[];
10
+ messages: string[];
11
+ }
12
+ /** the window's messages every editor sends */
13
+ export type BaseToHost = {
14
+ v: 1;
15
+ type: 'hello';
16
+ capabilities: Capabilities;
17
+ } | {
18
+ v: 1;
19
+ type: 'save';
20
+ id: number;
21
+ text: string;
22
+ } | {
23
+ v: 1;
24
+ type: 'dirty';
25
+ dirty: boolean;
26
+ } | {
27
+ v: 1;
28
+ type: 'close';
29
+ };
30
+ /** the host's messages every editor takes (I: the domain's own fields in init) */
31
+ export type BaseToWindow<I extends object = object> = ({
32
+ v: 1;
33
+ type: 'init';
34
+ text: string;
35
+ fileName?: string;
36
+ readOnly?: boolean;
37
+ theme?: Theme;
38
+ features?: string[];
39
+ } & I) | {
40
+ v: 1;
41
+ type: 'text';
42
+ text: string;
43
+ } | {
44
+ v: 1;
45
+ type: 'read-only';
46
+ readOnly: boolean;
47
+ } | {
48
+ v: 1;
49
+ type: 'theme';
50
+ theme: Theme;
51
+ } | {
52
+ v: 1;
53
+ type: 'saved';
54
+ re: number;
55
+ result: SaveResult | Refused;
56
+ };
57
+ /** a message of this protocol, of a type the receiver knows (anything else is ignored, never an error) */
58
+ export declare function isMessage<T extends {
59
+ type: string;
60
+ }>(d: unknown, types: readonly string[]): d is T;