@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,57 @@
1
+ export type { FileRole, ObjectKindInfo, RefSlot, Ref, ObjectRef, ReadOutcome, DomainAdapter, ConnectPlan, GroupPlan } from './adapter.js';
2
+ export { toPointer, fromPointer, parentOf, isPrefix, samePath } from './path.js';
3
+ export type { Seg, Path } from './path.js';
4
+ export { EditorDoc, completionContext } from './doc.js';
5
+ export type { Where, At, CompletionContext } from './doc.js';
6
+ export { HISTORY_DEPTH, EditorModel } from './model.js';
7
+ export type { Origin, Command, Change, SelectionChange } from './model.js';
8
+ export { SpliceError, applyStep, invertStep, scalarText, flowText, setValue, insertKey, deleteAt, insertItem, renameKey, moveKey, insertRawPair, pairText } from './splice.js';
9
+ export type { TextEdit, Step, Splice } from './splice.js';
10
+ export { SchemaNav } from './schema-nav.js';
11
+ export type { KeyInfo } from './schema-nav.js';
12
+ export { PREF, VIEWS } from './storage-keys.js';
13
+ export { chain, seqCmd, commandsFor } from './commands.js';
14
+ export type { Commands } from './commands.js';
15
+ export { clipboardFor } from './clipboard.js';
16
+ export type { PastePlan, Clipboard } from './clipboard.js';
17
+ export { namesIn, complete } from './complete.js';
18
+ export type { Item, Completion } from './complete.js';
19
+ export { outline, flatten } from './outline.js';
20
+ export type { NodeKind, OutlineNode } from './outline.js';
21
+ export { analyse, place } from './validate.js';
22
+ export type { Problem, ValidateOpts } from './validate.js';
23
+ export { docFor, providersFor, rangeOfPath, problemRange, cmSnippet, mdRuns } from './providers.js';
24
+ export type { Providers } from './providers.js';
25
+ export { setLayer, layer } from './ui/layer.js';
26
+ export { icon } from './ui/icons.js';
27
+ export type { IconName } from './ui/icons.js';
28
+ export { ask } from './ui/dialog.js';
29
+ export type { DialogButton } from './ui/dialog.js';
30
+ export { menuOpen, openMenu, closeMenu } from './ui/menu.js';
31
+ export type { MenuItem } from './ui/menu.js';
32
+ export { TYPING_PAUSE_MS, isTyping, later } from './ui/later.js';
33
+ export { keymapWith, keySheet } from './ui/keys.js';
34
+ export type { KeyGroup } from './ui/keys.js';
35
+ export type { TextSel, TextPane, TextServices, PaneOpts } from './ui/pane.js';
36
+ export { clipboard } from './ui/clip.js';
37
+ export type { Clip } from './ui/clip.js';
38
+ export { treeView } from './ui/tree.js';
39
+ export type { NewItem, EntryItem, TreeUi, TreeKit, TreeOpts } from './ui/tree.js';
40
+ export { run, composite, actionsFor } from './ui/actions.js';
41
+ export type { ActionsKit, Actions } from './ui/actions.js';
42
+ export { propsPanel } from './ui/props.js';
43
+ export type { PropsUi, PropsKit, PropsOpts } from './ui/props.js';
44
+ export type { Box as CanvasBox, Outline, CanvasCtx, CanvasLayer } from './ui/canvas-layer.js';
45
+ export { canvasView } from './ui/canvas.js';
46
+ export type { CanvasDrawing, DropInto, CanvasUi, CanvasKit, CanvasOpts, FlatCanvas, FlatDrawn, PaletteItem } from './ui/canvas.js';
47
+ export { flatCanvas } from './ui/flat-canvas.js';
48
+ export type { PartCtx, Attention, EditorPart } from './ui/part.js';
49
+ export type { Checked, MountKit } from './ui/mount-kit.js';
50
+ export { mountEditor } from './ui/mount.js';
51
+ export type { Theme, SaveResult, HostHooks, EditorOptions, ShellWords, ShellFeatures, ShellCanvas, EditorSetup, EditorState, Editor } from './ui/mount.js';
52
+ export { PROTOCOL, isMessage } from './window/protocol.js';
53
+ export type { Refused, Capabilities, BaseToHost, BaseToWindow } from './window/protocol.js';
54
+ export { setupFor, PLAIN_WORDS, PLAIN_KEYMAP } from './ui/setup.js';
55
+ export type { DomainView } from './ui/setup.js';
56
+ export { scopeCss, scopeOne } from './ui/scope-css.js';
57
+ export { PLAIN_ICON_SVG, PLAIN_ICONS, PLAIN_SPRITE, iconSymbols, spriteOf } from './ui/plain-icons.js';
@@ -0,0 +1,96 @@
1
+ import { EditorDoc } from './doc.js';
2
+ import { type Splice, type Step } from './splice.js';
3
+ import type { Path } from './path.js';
4
+ export type Origin = 'text' | 'tree' | 'canvas' | 'props' | 'menu' | 'api' | 'history' | 'file';
5
+ export interface Command {
6
+ /** for the menu and the undo button's tooltip: "Delete node web" */
7
+ label: string;
8
+ /** the change, worked out against the text it will apply to */
9
+ build(text: string): Splice;
10
+ /** the paths it touched (for the views to refresh and reveal) */
11
+ touched?: Path[];
12
+ /** where a path is after the change (a rename moves paths); null when it no longer exists */
13
+ remap?(p: Path): Path | null;
14
+ /** the selection afterwards (default: the old one, remapped) */
15
+ select?: Path[];
16
+ }
17
+ /** What a view needs to know about a change. */
18
+ export interface Change {
19
+ kind: 'do' | 'undo' | 'redo' | 'load';
20
+ origin: Origin;
21
+ label: string;
22
+ /** the steps, in order, each against the text the one before produced */
23
+ steps: Step[];
24
+ version: number;
25
+ /** the text selection to put back (undo/redo of typing), opaque to the model */
26
+ textSel?: unknown;
27
+ /** typing: which text pane typed it (each pane skips only its own; another pane takes it like any change) */
28
+ source?: string;
29
+ /** where paths moved (a rename), so views can carry their own state (expanded rows) along */
30
+ remap?(p: Path): Path | null;
31
+ }
32
+ /** The selection changed, and which view changed it (a view doesn't react to its own). */
33
+ export interface SelectionChange {
34
+ paths: Path[];
35
+ origin: Origin;
36
+ }
37
+ export declare const HISTORY_DEPTH = 500;
38
+ export declare class EditorModel {
39
+ private _text;
40
+ private _doc;
41
+ private _version;
42
+ private undoStack;
43
+ private redoStack;
44
+ private nextId;
45
+ private cleanId;
46
+ private listeners;
47
+ private selListeners;
48
+ private _good;
49
+ /** the selected paths (tree, canvas, properties) */
50
+ selection: Path[];
51
+ /** the text pane's selection, as it last reported it (opaque) */
52
+ textSel: unknown;
53
+ /** how many commands needed a fallback (re-serialising a collection): for the tests */
54
+ fallbacks: number;
55
+ depth: number;
56
+ now: () => number;
57
+ constructor(text?: string);
58
+ get text(): string;
59
+ get version(): number;
60
+ get doc(): EditorDoc;
61
+ /** the document as last parsed without a YAML error: what the tree and canvas show while the text is broken */
62
+ get goodDoc(): EditorDoc;
63
+ /** Select paths (from a view). Every other view shows it. */
64
+ select(paths: Path[], origin: Origin): void;
65
+ onSelect(fn: (c: SelectionChange) => void): () => void;
66
+ on(fn: (c: Change) => void): () => void;
67
+ private emit;
68
+ /** A new file: the text, an empty history, clean. */
69
+ load(text: string, origin?: Origin): void;
70
+ private set;
71
+ /** Run a command: build it against the text, apply its steps, push it. Returns false if it changed nothing. */
72
+ apply(cmd: Command, origin?: Origin): boolean;
73
+ /**
74
+ * Text the user typed (one change from the text pane: edits against the text before it). The view has already
75
+ * made the change; the model takes it, and coalesces typing into one command per word or pause.
76
+ */
77
+ typed(step: Step, sel?: {
78
+ before?: unknown;
79
+ after?: unknown;
80
+ }, source?: string): void;
81
+ /** End the typing group being added to (a caret jump, a pause, leaving the text pane, a save). */
82
+ seal(): void;
83
+ private run;
84
+ private push;
85
+ get canUndo(): boolean;
86
+ get canRedo(): boolean;
87
+ get undoLabel(): string;
88
+ get redoLabel(): string;
89
+ undo(): boolean;
90
+ redo(): boolean;
91
+ /** The text was saved: this is the clean point. */
92
+ markClean(): void;
93
+ get dirty(): boolean;
94
+ /** the labels on the stack, oldest first (for tests and a history list) */
95
+ get history(): string[];
96
+ }
@@ -0,0 +1,28 @@
1
+ import type { EditorDoc } from './doc.js';
2
+ import { type Path } from './path.js';
3
+ import type { OutlineAdapter, FileRole } from './adapter.js';
4
+ export type NodeKind = 'root' | 'group' | 'resource' | 'key' | 'item';
5
+ export interface OutlineNode {
6
+ /** the JSON Pointer of the node's path (unique) */
7
+ id: string;
8
+ path: Path;
9
+ kind: NodeKind;
10
+ label: string;
11
+ /** a scalar's text, as written */
12
+ value?: string;
13
+ shape: 'map' | 'list' | 'scalar' | 'missing';
14
+ /** for an object and its group: its kind */
15
+ section?: string;
16
+ /** for an object: its tag (the reader's, else the adapter's from this file) */
17
+ lifetime?: string;
18
+ /** the key is an x-* extension */
19
+ ext?: boolean;
20
+ children: OutlineNode[];
21
+ }
22
+ /**
23
+ * @param tags the reader's tags by object name (with the base files merged), when known; without them an object's
24
+ * tag is the adapter's, from this file alone
25
+ */
26
+ export declare function outline(d: EditorDoc, a: OutlineAdapter, role?: FileRole, tags?: Map<string, string>): OutlineNode;
27
+ /** Every node, depth first (for search and keyboard). */
28
+ export declare function flatten(n: OutlineNode, out?: OutlineNode[]): OutlineNode[];
@@ -0,0 +1,7 @@
1
+ export type Seg = string | number;
2
+ export type Path = Seg[];
3
+ export declare const toPointer: (p: Path) => string;
4
+ export declare function fromPointer(ptr: string): Path;
5
+ export declare const parentOf: (p: Path) => Path | undefined;
6
+ export declare const isPrefix: (a: Path, b: Path) => boolean;
7
+ export declare const samePath: (a: Path, b: Path) => boolean;
@@ -0,0 +1,43 @@
1
+ import { EditorDoc } from './doc.js';
2
+ import { SchemaNav } from './schema-nav.js';
3
+ import { type Item } from './complete.js';
4
+ import type { Problem } from './validate.js';
5
+ import { type Path } from './path.js';
6
+ import type { ProvidersAdapter } from './adapter.js';
7
+ export declare function docFor(text: string): EditorDoc;
8
+ /** What the text panes ask, for one domain: completion, hover and go to definition, and the schema navigator for a
9
+ * text (the main one, or a base file's). */
10
+ export declare function providersFor(a: ProvidersAdapter): {
11
+ navFor: (text: string) => SchemaNav;
12
+ completionAt: (d: EditorDoc, offset: number) => {
13
+ from: number;
14
+ items: Item[];
15
+ };
16
+ hoverAt: (d: EditorDoc, offset: number) => {
17
+ from: number;
18
+ to: number;
19
+ parts: string[];
20
+ } | null;
21
+ definitionAt: (d: EditorDoc, offset: number) => {
22
+ from: number;
23
+ to: number;
24
+ } | {
25
+ open: string;
26
+ } | null;
27
+ };
28
+ export type Providers = ReturnType<typeof providersFor>;
29
+ /** Where a path is drawn in the text, to mark it: its whole pair, else its value. */
30
+ export declare function rangeOfPath(d: EditorDoc, p: Path): [number, number] | undefined;
31
+ /** A problem's range as offsets into the text (its lines and columns are 1-based), clamped to the text. */
32
+ export declare function problemRange(text: string, p: Pick<Problem, 'startLine' | 'startCol' | 'endLine' | 'endCol'>): [number, number];
33
+ /**
34
+ * Completion's snippets are written in Monaco's syntax (${1:name}, ${2|a,b|}, ${0}). CodeMirror's has fields (${1:name},
35
+ * ${}) but no choices: a choice becomes a field holding its first option (the others are offered as values once the
36
+ * caret is there), and the final ${0} an empty field.
37
+ */
38
+ export declare function cmSnippet(monaco: string): string;
39
+ /** The Markdown a hover or completion carries, as runs of text: plain, bold or code, in paragraphs (never markup). */
40
+ export declare function mdRuns(md: string): {
41
+ kind: 'text' | 'bold' | 'code';
42
+ text: string;
43
+ }[][];
@@ -0,0 +1,34 @@
1
+ import type { Path } from './path.js';
2
+ type J = Record<string, unknown>;
3
+ export interface KeyInfo {
4
+ name: string;
5
+ /** Markdown */
6
+ doc?: string;
7
+ /** the value's shape, for the text inserted after "key:" */
8
+ shape: 'map' | 'list' | 'scalar';
9
+ enumValues: string[];
10
+ examples: unknown[];
11
+ }
12
+ export declare class SchemaNav {
13
+ private root;
14
+ private defs;
15
+ constructor(schema: object);
16
+ /** a schema with its $ref and anyOf/allOf branches spread out (each branch is a candidate) */
17
+ private spread;
18
+ /** The candidate schemas at a path. A name in a section map matches additionalProperties; x-* keys match nothing useful. */
19
+ at(path: Path): J[];
20
+ /** The keys a map at this path may have (not counting x-*), given what the map holds now. */
21
+ keys(path: Path, present?: J): KeyInfo[];
22
+ private info;
23
+ /** The words a value at this path may be: enum values, consts, true/false. */
24
+ values(path: Path, cands?: J[]): string[];
25
+ /** Markdown for a path: the description of the key, plus allowed values. */
26
+ hover(path: Path): string | undefined;
27
+ /** A value to start a new key with: the first allowed value, else an empty one of the right shape. */
28
+ defaultFor(path: Path): unknown;
29
+ /** The value types a path takes (for parsing what is typed into the tree). */
30
+ types(path: Path): Set<string>;
31
+ /** Is the path a map of names (a section of named things)? */
32
+ isNameMap(path: Path): boolean;
33
+ }
34
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { Path, Seg } from './path.js';
2
+ export interface TextEdit {
3
+ start: number;
4
+ end: number;
5
+ text: string;
6
+ }
7
+ /** one step: non-overlapping edits against the same text */
8
+ export type Step = TextEdit[];
9
+ export interface Splice {
10
+ steps: Step[];
11
+ fallback?: boolean;
12
+ }
13
+ export declare class SpliceError extends Error {
14
+ }
15
+ /** Apply one step's edits (non-overlapping) to a text. */
16
+ export declare function applyStep(text: string, step: Step): string;
17
+ /** The step that undoes `step` on the text it produced. */
18
+ export declare function invertStep(text: string, step: Step): Step;
19
+ type Style = string | undefined;
20
+ /** A scalar as YAML text. Keeps a quoting style when one is given; multi-line text becomes a block literal. */
21
+ export declare function scalarText(v: unknown, opts: {
22
+ flow: boolean;
23
+ indent: number;
24
+ style?: Style;
25
+ }): string;
26
+ /** A value inline, in flow style: { a: 1, b: [x, y] } */
27
+ export declare function flowText(v: unknown): string;
28
+ /** Set the value at a path (which must exist: use insertKey for a new key). */
29
+ export declare function setValue(text: string, path: Path, value: unknown): Splice;
30
+ /** Add `key: value` to the map at a path (creating the map, and its parents, when missing). order: the format's
31
+ * top-level key order, for where a new top-level key goes (the adapter's topOrder). */
32
+ export declare function insertKey(text: string, mapPath: Path, key: string, value: unknown, opts?: {
33
+ after?: string;
34
+ before?: string;
35
+ order?: readonly string[];
36
+ }): Splice;
37
+ /** Remove the entry at a path: a key and its value (with its own comment lines), or a list item. */
38
+ export declare function deleteAt(text: string, path: Path): Splice;
39
+ /** Add an item to the list at a path, at an index (default: the end). */
40
+ export declare function insertItem(text: string, listPath: Path, value: unknown, index?: number, order?: readonly string[]): Splice;
41
+ /** Rename a key in place. */
42
+ export declare function renameKey(text: string, path: Path, to: string): Splice;
43
+ /** Move a block map's entry (with its comment lines) to before another key, or to the end. */
44
+ export declare function moveKey(text: string, path: Path, before?: string, order?: readonly string[]): Splice;
45
+ export type { Seg };
46
+ /**
47
+ * Add a pair given as source text ("key: value", with its own comments, at indent 0) to the map at a path, re-indented
48
+ * to the map's; the text, comments and all, is kept. A flow map (or one the splices can't place a line in) takes the
49
+ * value's data instead. The map must exist (insertKey makes a missing one).
50
+ */
51
+ export declare function insertRawPair(text: string, mapPath: Path, key: string, pairText: string, order?: readonly string[]): Splice;
52
+ /** A pair's source text (its own comment lines, the key and its value, a comment after it), at indent 0. */
53
+ export declare function pairText(text: string, path: Path): string | undefined;
@@ -0,0 +1,5 @@
1
+ export declare const PREF: {
2
+ readonly view: 'view';
3
+ readonly live: 'live';
4
+ };
5
+ export declare const VIEWS: readonly ['text', 'both', 'canvas'];
@@ -0,0 +1,23 @@
1
+ import type { EditorModel, Command } from '../model.js';
2
+ import type { Commands } from '../commands.js';
3
+ import type { ObjectKindInfo, ObjectRef } from '../adapter.js';
4
+ import { type Path } from '../path.js';
5
+ /** what the shared actions are given of the domain */
6
+ export interface ActionsKit {
7
+ commands: Pick<Commands, 'deleteCmd' | 'renameCmd' | 'renameKeyCmd' | 'referencesTo' | 'describe' | 'duplicateCmd'>;
8
+ objectOf(ptr: string): ObjectRef | undefined;
9
+ kinds: ObjectKindInfo[];
10
+ nameRule: RegExp;
11
+ nameHint: string;
12
+ }
13
+ export declare function run(doc: EditorModel, c: Command, origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void): boolean;
14
+ /** Several commands as one undo step. */
15
+ export declare function composite(label: string, cmds: Command[]): Command;
16
+ /** The shared actions, for one domain. */
17
+ export declare function actionsFor(kit: ActionsKit): {
18
+ deletePaths: (doc: EditorModel, paths: Path[], origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void) => Promise<boolean>;
19
+ renameDialog: (doc: EditorModel, path: Path, origin: 'canvas' | 'props' | 'menu', note?: (t: string, tone?: 'bad') => void) => Promise<boolean>;
20
+ duplicate: (doc: EditorModel, path: Path, origin: 'canvas' | 'menu', note?: (t: string, tone?: 'bad') => void) => void;
21
+ connected: (doc: EditorModel, paths: Path[]) => Path[];
22
+ };
23
+ export type Actions = ReturnType<typeof actionsFor>;
@@ -0,0 +1,65 @@
1
+ import type { EditorModel } from '../model.js';
2
+ import type { Path } from '../path.js';
3
+ export interface Box {
4
+ x: number;
5
+ y: number;
6
+ w: number;
7
+ h: number;
8
+ }
9
+ export type Outline = {
10
+ kind: 'poly';
11
+ id: string;
12
+ points: [number, number][];
13
+ } | {
14
+ kind: 'route';
15
+ d: string;
16
+ };
17
+ /** what the canvas gives a layer (D: the domain's drawn document) */
18
+ export interface CanvasCtx<D> {
19
+ host: HTMLElement;
20
+ doc: EditorModel;
21
+ cd(): D | undefined;
22
+ svg(): SVGSVGElement | undefined;
23
+ elementsFor(ptr: string): SVGGraphicsElement[];
24
+ boxOf(e: SVGGraphicsElement): Box;
25
+ union(bs: Box[]): Box | undefined;
26
+ outlinesFor(ptr: string): Outline[];
27
+ scale(): number;
28
+ /** the whole drawing's box */
29
+ full(): Box | undefined;
30
+ toSvg(x: number, y: number): {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ autoFit(): void;
35
+ /** paint the overlay again (the layer's paint() runs in it) */
36
+ paint(): void;
37
+ /** pan to it, if it is outside the view */
38
+ reveal(p: Path): void;
39
+ note(t: string, tone?: 'info' | 'warn' | 'bad'): void;
40
+ }
41
+ /** what a layer gives the canvas; A: its calls, added to what the canvas returns */
42
+ export interface CanvasLayer<A extends object> {
43
+ tools?: HTMLElement[];
44
+ marks?: HTMLElement[];
45
+ /** each new drawing: the layer's groups, put after the overlay's */
46
+ groups?(): SVGGElement[];
47
+ /** a new drawing is on the stage */
48
+ drawn?(): void;
49
+ /** what a fit takes in besides the drawing */
50
+ extent?(): Box[];
51
+ /** the layer shows marks (the view keeps them in a fit) */
52
+ showing?(): boolean;
53
+ /** after the overlay's own marks */
54
+ paint?(d: Document): void;
55
+ /** a press the layer takes (true: the canvas does nothing more) */
56
+ down?(e: PointerEvent): boolean;
57
+ /** a menu the layer opens (true: the canvas's own isn't) */
58
+ context?(e: MouseEvent, at: {
59
+ x: number;
60
+ y: number;
61
+ }): boolean;
62
+ /** a key: handled (the canvas stops it), ignore (the canvas leaves it be), or not the layer's */
63
+ key?(e: KeyboardEvent): 'handled' | 'ignore' | undefined;
64
+ api: A;
65
+ }