@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
package/package.json CHANGED
@@ -1,6 +1,504 @@
1
1
  {
2
2
  "name": "@johnoscott/isometric-engine",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.9.0",
4
+ "description": "A generic isometric diagram engine: render (L0–L2) and editor (L0–L3), with a 2D view and a YAML diagram format.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "./src/**",
9
+ "./js/**"
10
+ ],
11
+ "publishConfig": {
12
+ "registry": "https://registry.npmjs.org/",
13
+ "access": "public"
14
+ },
15
+ "files": [
16
+ "LICENSE",
17
+ "iso-render.js",
18
+ "iso-render.d.ts",
19
+ "iso-editor.js",
20
+ "iso-editor.d.ts",
21
+ "iso-systems.js",
22
+ "iso-systems.d.ts",
23
+ "types/",
24
+ "assets/",
25
+ "LICENSES/",
26
+ "README.md",
27
+ "EDITOR-GUIDE.md",
28
+ "src/",
29
+ "js/"
30
+ ],
31
+ "exports": {
32
+ "./render": {
33
+ "types": "./iso-render.d.ts",
34
+ "default": "./iso-render.js"
35
+ },
36
+ "./editor": {
37
+ "types": "./iso-editor.d.ts",
38
+ "default": "./iso-editor.js"
39
+ },
40
+ "./systems": {
41
+ "types": "./iso-systems.d.ts",
42
+ "default": "./iso-systems.js"
43
+ },
44
+ "./modules/iso-core/compile-schema": {
45
+ "types": "./src/iso-core/compile-schema.ts",
46
+ "source": "./src/iso-core/compile-schema.ts",
47
+ "default": "./js/iso-core/compile-schema.js"
48
+ },
49
+ "./modules/iso-core/depth": {
50
+ "types": "./src/iso-core/depth.ts",
51
+ "source": "./src/iso-core/depth.ts",
52
+ "default": "./js/iso-core/depth.js"
53
+ },
54
+ "./modules/iso-core/errors": {
55
+ "types": "./src/iso-core/errors.ts",
56
+ "source": "./src/iso-core/errors.ts",
57
+ "default": "./js/iso-core/errors.js"
58
+ },
59
+ "./modules/iso-core/glyphs": {
60
+ "types": "./src/iso-core/glyphs.ts",
61
+ "source": "./src/iso-core/glyphs.ts",
62
+ "default": "./js/iso-core/glyphs.js"
63
+ },
64
+ "./modules/iso-core/index": {
65
+ "types": "./src/iso-core/index.ts",
66
+ "source": "./src/iso-core/index.ts",
67
+ "default": "./js/iso-core/index.js"
68
+ },
69
+ "./modules/iso-core/kernel": {
70
+ "types": "./src/iso-core/kernel.ts",
71
+ "source": "./src/iso-core/kernel.ts",
72
+ "default": "./js/iso-core/kernel.js"
73
+ },
74
+ "./modules/iso-core/parse": {
75
+ "types": "./src/iso-core/parse.ts",
76
+ "source": "./src/iso-core/parse.ts",
77
+ "default": "./js/iso-core/parse.js"
78
+ },
79
+ "./modules/iso-core/schema-errors": {
80
+ "types": "./src/iso-core/schema-errors.ts",
81
+ "source": "./src/iso-core/schema-errors.ts",
82
+ "default": "./js/iso-core/schema-errors.js"
83
+ },
84
+ "./modules/iso-core/shims/crypto": {
85
+ "types": "./src/iso-core/shims/crypto.ts",
86
+ "source": "./src/iso-core/shims/crypto.ts",
87
+ "default": "./js/iso-core/shims/crypto.js"
88
+ },
89
+ "./modules/iso-core/svg-dom": {
90
+ "types": "./src/iso-core/svg-dom.ts",
91
+ "source": "./src/iso-core/svg-dom.ts",
92
+ "default": "./js/iso-core/svg-dom.js"
93
+ },
94
+ "./modules/iso-core/theme": {
95
+ "types": "./src/iso-core/theme.ts",
96
+ "source": "./src/iso-core/theme.ts",
97
+ "default": "./js/iso-core/theme.js"
98
+ },
99
+ "./modules/iso-core/vdom": {
100
+ "types": "./src/iso-core/vdom.ts",
101
+ "source": "./src/iso-core/vdom.ts",
102
+ "default": "./js/iso-core/vdom.js"
103
+ },
104
+ "./modules/iso-objects/assemble": {
105
+ "types": "./src/iso-objects/assemble.ts",
106
+ "source": "./src/iso-objects/assemble.ts",
107
+ "default": "./js/iso-objects/assemble.js"
108
+ },
109
+ "./modules/iso-objects/assets": {
110
+ "types": "./src/iso-objects/assets.ts",
111
+ "source": "./src/iso-objects/assets.ts",
112
+ "default": "./js/iso-objects/assets.js"
113
+ },
114
+ "./modules/iso-objects/board": {
115
+ "types": "./src/iso-objects/board.ts",
116
+ "source": "./src/iso-objects/board.ts",
117
+ "default": "./js/iso-objects/board.js"
118
+ },
119
+ "./modules/iso-objects/compile": {
120
+ "types": "./src/iso-objects/compile.ts",
121
+ "source": "./src/iso-objects/compile.ts",
122
+ "default": "./js/iso-objects/compile.js"
123
+ },
124
+ "./modules/iso-objects/css": {
125
+ "types": "./src/iso-objects/css.ts",
126
+ "source": "./src/iso-objects/css.ts",
127
+ "default": "./js/iso-objects/css.js"
128
+ },
129
+ "./modules/iso-objects/flat": {
130
+ "types": "./src/iso-objects/flat.ts",
131
+ "source": "./src/iso-objects/flat.ts",
132
+ "default": "./js/iso-objects/flat.js"
133
+ },
134
+ "./modules/iso-objects/focus": {
135
+ "types": "./src/iso-objects/focus.ts",
136
+ "source": "./src/iso-objects/focus.ts",
137
+ "default": "./js/iso-objects/focus.js"
138
+ },
139
+ "./modules/iso-objects/geometry": {
140
+ "types": "./src/iso-objects/geometry.ts",
141
+ "source": "./src/iso-objects/geometry.ts",
142
+ "default": "./js/iso-objects/geometry.js"
143
+ },
144
+ "./modules/iso-objects/index": {
145
+ "types": "./src/iso-objects/index.ts",
146
+ "source": "./src/iso-objects/index.ts",
147
+ "default": "./js/iso-objects/index.js"
148
+ },
149
+ "./modules/iso-objects/kinds": {
150
+ "types": "./src/iso-objects/kinds.ts",
151
+ "source": "./src/iso-objects/kinds.ts",
152
+ "default": "./js/iso-objects/kinds.js"
153
+ },
154
+ "./modules/iso-objects/labels": {
155
+ "types": "./src/iso-objects/labels.ts",
156
+ "source": "./src/iso-objects/labels.ts",
157
+ "default": "./js/iso-objects/labels.js"
158
+ },
159
+ "./modules/iso-objects/place": {
160
+ "types": "./src/iso-objects/place.ts",
161
+ "source": "./src/iso-objects/place.ts",
162
+ "default": "./js/iso-objects/place.js"
163
+ },
164
+ "./modules/iso-objects/route": {
165
+ "types": "./src/iso-objects/route.ts",
166
+ "source": "./src/iso-objects/route.ts",
167
+ "default": "./js/iso-objects/route.js"
168
+ },
169
+ "./modules/iso-objects/scene": {
170
+ "types": "./src/iso-objects/scene.ts",
171
+ "source": "./src/iso-objects/scene.ts",
172
+ "default": "./js/iso-objects/scene.js"
173
+ },
174
+ "./modules/iso-objects/steps": {
175
+ "types": "./src/iso-objects/steps.ts",
176
+ "source": "./src/iso-objects/steps.ts",
177
+ "default": "./js/iso-objects/steps.js"
178
+ },
179
+ "./modules/iso-objects/types": {
180
+ "types": "./src/iso-objects/types.ts",
181
+ "source": "./src/iso-objects/types.ts",
182
+ "default": "./js/iso-objects/types.js"
183
+ },
184
+ "./modules/iso-viewer/bundle": {
185
+ "types": "./src/iso-viewer/bundle.ts",
186
+ "source": "./src/iso-viewer/bundle.ts",
187
+ "default": "./js/iso-viewer/bundle.js"
188
+ },
189
+ "./modules/iso-viewer/card-motion": {
190
+ "types": "./src/iso-viewer/card-motion.ts",
191
+ "source": "./src/iso-viewer/card-motion.ts",
192
+ "default": "./js/iso-viewer/card-motion.js"
193
+ },
194
+ "./modules/iso-viewer/dom": {
195
+ "types": "./src/iso-viewer/dom.ts",
196
+ "source": "./src/iso-viewer/dom.ts",
197
+ "default": "./js/iso-viewer/dom.js"
198
+ },
199
+ "./modules/iso-viewer/dual-view": {
200
+ "types": "./src/iso-viewer/dual-view.ts",
201
+ "source": "./src/iso-viewer/dual-view.ts",
202
+ "default": "./js/iso-viewer/dual-view.js"
203
+ },
204
+ "./modules/iso-viewer/flat-view": {
205
+ "types": "./src/iso-viewer/flat-view.ts",
206
+ "source": "./src/iso-viewer/flat-view.ts",
207
+ "default": "./js/iso-viewer/flat-view.js"
208
+ },
209
+ "./modules/iso-viewer/history": {
210
+ "types": "./src/iso-viewer/history.ts",
211
+ "source": "./src/iso-viewer/history.ts",
212
+ "default": "./js/iso-viewer/history.js"
213
+ },
214
+ "./modules/iso-viewer/index": {
215
+ "types": "./src/iso-viewer/index.ts",
216
+ "source": "./src/iso-viewer/index.ts",
217
+ "default": "./js/iso-viewer/index.js"
218
+ },
219
+ "./modules/iso-viewer/morph": {
220
+ "types": "./src/iso-viewer/morph.ts",
221
+ "source": "./src/iso-viewer/morph.ts",
222
+ "default": "./js/iso-viewer/morph.js"
223
+ },
224
+ "./modules/iso-viewer/overlay": {
225
+ "types": "./src/iso-viewer/overlay.ts",
226
+ "source": "./src/iso-viewer/overlay.ts",
227
+ "default": "./js/iso-viewer/overlay.js"
228
+ },
229
+ "./modules/iso-viewer/page": {
230
+ "types": "./src/iso-viewer/page.ts",
231
+ "source": "./src/iso-viewer/page.ts",
232
+ "default": "./js/iso-viewer/page.js"
233
+ },
234
+ "./modules/iso-viewer/still": {
235
+ "types": "./src/iso-viewer/still.ts",
236
+ "source": "./src/iso-viewer/still.ts",
237
+ "default": "./js/iso-viewer/still.js"
238
+ },
239
+ "./modules/iso-viewer/timeline-contract": {
240
+ "types": "./src/iso-viewer/timeline-contract.ts",
241
+ "source": "./src/iso-viewer/timeline-contract.ts",
242
+ "default": "./js/iso-viewer/timeline-contract.js"
243
+ },
244
+ "./modules/iso-viewer/timeline-engine": {
245
+ "types": "./src/iso-viewer/timeline-engine.ts",
246
+ "source": "./src/iso-viewer/timeline-engine.ts",
247
+ "default": "./js/iso-viewer/timeline-engine.js"
248
+ },
249
+ "./modules/iso-viewer/timeline-export": {
250
+ "types": "./src/iso-viewer/timeline-export.ts",
251
+ "source": "./src/iso-viewer/timeline-export.ts",
252
+ "default": "./js/iso-viewer/timeline-export.js"
253
+ },
254
+ "./modules/iso-viewer/timeline-scale": {
255
+ "types": "./src/iso-viewer/timeline-scale.ts",
256
+ "source": "./src/iso-viewer/timeline-scale.ts",
257
+ "default": "./js/iso-viewer/timeline-scale.js"
258
+ },
259
+ "./modules/iso-viewer/timeline-scope": {
260
+ "types": "./src/iso-viewer/timeline-scope.ts",
261
+ "source": "./src/iso-viewer/timeline-scope.ts",
262
+ "default": "./js/iso-viewer/timeline-scope.js"
263
+ },
264
+ "./modules/iso-viewer/timeline-search": {
265
+ "types": "./src/iso-viewer/timeline-search.ts",
266
+ "source": "./src/iso-viewer/timeline-search.ts",
267
+ "default": "./js/iso-viewer/timeline-search.js"
268
+ },
269
+ "./modules/iso-viewer/timeline-time": {
270
+ "types": "./src/iso-viewer/timeline-time.ts",
271
+ "source": "./src/iso-viewer/timeline-time.ts",
272
+ "default": "./js/iso-viewer/timeline-time.js"
273
+ },
274
+ "./modules/iso-viewer/view-css": {
275
+ "types": "./src/iso-viewer/view-css.ts",
276
+ "source": "./src/iso-viewer/view-css.ts",
277
+ "default": "./js/iso-viewer/view-css.js"
278
+ },
279
+ "./modules/iso-viewer/viewport": {
280
+ "types": "./src/iso-viewer/viewport.ts",
281
+ "source": "./src/iso-viewer/viewport.ts",
282
+ "default": "./js/iso-viewer/viewport.js"
283
+ },
284
+ "./modules/iso-editor/adapter": {
285
+ "types": "./src/iso-editor/adapter.ts",
286
+ "source": "./src/iso-editor/adapter.ts",
287
+ "default": "./js/iso-editor/adapter.js"
288
+ },
289
+ "./modules/iso-editor/clipboard": {
290
+ "types": "./src/iso-editor/clipboard.ts",
291
+ "source": "./src/iso-editor/clipboard.ts",
292
+ "default": "./js/iso-editor/clipboard.js"
293
+ },
294
+ "./modules/iso-editor/commands": {
295
+ "types": "./src/iso-editor/commands.ts",
296
+ "source": "./src/iso-editor/commands.ts",
297
+ "default": "./js/iso-editor/commands.js"
298
+ },
299
+ "./modules/iso-editor/complete": {
300
+ "types": "./src/iso-editor/complete.ts",
301
+ "source": "./src/iso-editor/complete.ts",
302
+ "default": "./js/iso-editor/complete.js"
303
+ },
304
+ "./modules/iso-editor/doc": {
305
+ "types": "./src/iso-editor/doc.ts",
306
+ "source": "./src/iso-editor/doc.ts",
307
+ "default": "./js/iso-editor/doc.js"
308
+ },
309
+ "./modules/iso-editor/index": {
310
+ "types": "./src/iso-editor/index.ts",
311
+ "source": "./src/iso-editor/index.ts",
312
+ "default": "./js/iso-editor/index.js"
313
+ },
314
+ "./modules/iso-editor/model": {
315
+ "types": "./src/iso-editor/model.ts",
316
+ "source": "./src/iso-editor/model.ts",
317
+ "default": "./js/iso-editor/model.js"
318
+ },
319
+ "./modules/iso-editor/outline": {
320
+ "types": "./src/iso-editor/outline.ts",
321
+ "source": "./src/iso-editor/outline.ts",
322
+ "default": "./js/iso-editor/outline.js"
323
+ },
324
+ "./modules/iso-editor/path": {
325
+ "types": "./src/iso-editor/path.ts",
326
+ "source": "./src/iso-editor/path.ts",
327
+ "default": "./js/iso-editor/path.js"
328
+ },
329
+ "./modules/iso-editor/providers": {
330
+ "types": "./src/iso-editor/providers.ts",
331
+ "source": "./src/iso-editor/providers.ts",
332
+ "default": "./js/iso-editor/providers.js"
333
+ },
334
+ "./modules/iso-editor/schema-nav": {
335
+ "types": "./src/iso-editor/schema-nav.ts",
336
+ "source": "./src/iso-editor/schema-nav.ts",
337
+ "default": "./js/iso-editor/schema-nav.js"
338
+ },
339
+ "./modules/iso-editor/splice": {
340
+ "types": "./src/iso-editor/splice.ts",
341
+ "source": "./src/iso-editor/splice.ts",
342
+ "default": "./js/iso-editor/splice.js"
343
+ },
344
+ "./modules/iso-editor/storage-keys": {
345
+ "types": "./src/iso-editor/storage-keys.ts",
346
+ "source": "./src/iso-editor/storage-keys.ts",
347
+ "default": "./js/iso-editor/storage-keys.js"
348
+ },
349
+ "./modules/iso-editor/ui/actions": {
350
+ "types": "./src/iso-editor/ui/actions.ts",
351
+ "source": "./src/iso-editor/ui/actions.ts",
352
+ "default": "./js/iso-editor/ui/actions.js"
353
+ },
354
+ "./modules/iso-editor/ui/app.css": "./src/iso-editor/ui/app.css",
355
+ "./modules/iso-editor/ui/canvas-layer": {
356
+ "types": "./src/iso-editor/ui/canvas-layer.ts",
357
+ "source": "./src/iso-editor/ui/canvas-layer.ts",
358
+ "default": "./js/iso-editor/ui/canvas-layer.js"
359
+ },
360
+ "./modules/iso-editor/ui/canvas": {
361
+ "types": "./src/iso-editor/ui/canvas.ts",
362
+ "source": "./src/iso-editor/ui/canvas.ts",
363
+ "default": "./js/iso-editor/ui/canvas.js"
364
+ },
365
+ "./modules/iso-editor/ui/clip": {
366
+ "types": "./src/iso-editor/ui/clip.ts",
367
+ "source": "./src/iso-editor/ui/clip.ts",
368
+ "default": "./js/iso-editor/ui/clip.js"
369
+ },
370
+ "./modules/iso-editor/ui/dialog": {
371
+ "types": "./src/iso-editor/ui/dialog.ts",
372
+ "source": "./src/iso-editor/ui/dialog.ts",
373
+ "default": "./js/iso-editor/ui/dialog.js"
374
+ },
375
+ "./modules/iso-editor/ui/flat-canvas": {
376
+ "types": "./src/iso-editor/ui/flat-canvas.ts",
377
+ "source": "./src/iso-editor/ui/flat-canvas.ts",
378
+ "default": "./js/iso-editor/ui/flat-canvas.js"
379
+ },
380
+ "./modules/iso-editor/ui/icons": {
381
+ "types": "./src/iso-editor/ui/icons.ts",
382
+ "source": "./src/iso-editor/ui/icons.ts",
383
+ "default": "./js/iso-editor/ui/icons.js"
384
+ },
385
+ "./modules/iso-editor/ui/keys": {
386
+ "types": "./src/iso-editor/ui/keys.ts",
387
+ "source": "./src/iso-editor/ui/keys.ts",
388
+ "default": "./js/iso-editor/ui/keys.js"
389
+ },
390
+ "./modules/iso-editor/ui/later": {
391
+ "types": "./src/iso-editor/ui/later.ts",
392
+ "source": "./src/iso-editor/ui/later.ts",
393
+ "default": "./js/iso-editor/ui/later.js"
394
+ },
395
+ "./modules/iso-editor/ui/layer": {
396
+ "types": "./src/iso-editor/ui/layer.ts",
397
+ "source": "./src/iso-editor/ui/layer.ts",
398
+ "default": "./js/iso-editor/ui/layer.js"
399
+ },
400
+ "./modules/iso-editor/ui/menu": {
401
+ "types": "./src/iso-editor/ui/menu.ts",
402
+ "source": "./src/iso-editor/ui/menu.ts",
403
+ "default": "./js/iso-editor/ui/menu.js"
404
+ },
405
+ "./modules/iso-editor/ui/monaco-entry": {
406
+ "types": "./src/iso-editor/ui/monaco-entry.ts",
407
+ "source": "./src/iso-editor/ui/monaco-entry.ts",
408
+ "default": "./js/iso-editor/ui/monaco-entry.js"
409
+ },
410
+ "./modules/iso-editor/ui/mount-kit": {
411
+ "types": "./src/iso-editor/ui/mount-kit.ts",
412
+ "source": "./src/iso-editor/ui/mount-kit.ts",
413
+ "default": "./js/iso-editor/ui/mount-kit.js"
414
+ },
415
+ "./modules/iso-editor/ui/mount": {
416
+ "types": "./src/iso-editor/ui/mount.ts",
417
+ "source": "./src/iso-editor/ui/mount.ts",
418
+ "default": "./js/iso-editor/ui/mount.js"
419
+ },
420
+ "./modules/iso-editor/ui/pane": {
421
+ "types": "./src/iso-editor/ui/pane.ts",
422
+ "source": "./src/iso-editor/ui/pane.ts",
423
+ "default": "./js/iso-editor/ui/pane.js"
424
+ },
425
+ "./modules/iso-editor/ui/part": {
426
+ "types": "./src/iso-editor/ui/part.ts",
427
+ "source": "./src/iso-editor/ui/part.ts",
428
+ "default": "./js/iso-editor/ui/part.js"
429
+ },
430
+ "./modules/iso-editor/ui/plain-icons": {
431
+ "types": "./src/iso-editor/ui/plain-icons.ts",
432
+ "source": "./src/iso-editor/ui/plain-icons.ts",
433
+ "default": "./js/iso-editor/ui/plain-icons.js"
434
+ },
435
+ "./modules/iso-editor/ui/props": {
436
+ "types": "./src/iso-editor/ui/props.ts",
437
+ "source": "./src/iso-editor/ui/props.ts",
438
+ "default": "./js/iso-editor/ui/props.js"
439
+ },
440
+ "./modules/iso-editor/ui/scope-css": {
441
+ "types": "./src/iso-editor/ui/scope-css.ts",
442
+ "source": "./src/iso-editor/ui/scope-css.ts",
443
+ "default": "./js/iso-editor/ui/scope-css.js"
444
+ },
445
+ "./modules/iso-editor/ui/setup": {
446
+ "types": "./src/iso-editor/ui/setup.ts",
447
+ "source": "./src/iso-editor/ui/setup.ts",
448
+ "default": "./js/iso-editor/ui/setup.js"
449
+ },
450
+ "./modules/iso-editor/ui/skin.css": "./src/iso-editor/ui/skin.css",
451
+ "./modules/iso-editor/ui/text": {
452
+ "types": "./src/iso-editor/ui/text.ts",
453
+ "source": "./src/iso-editor/ui/text.ts",
454
+ "default": "./js/iso-editor/ui/text.js"
455
+ },
456
+ "./modules/iso-editor/ui/tree": {
457
+ "types": "./src/iso-editor/ui/tree.ts",
458
+ "source": "./src/iso-editor/ui/tree.ts",
459
+ "default": "./js/iso-editor/ui/tree.js"
460
+ },
461
+ "./modules/iso-editor/validate": {
462
+ "types": "./src/iso-editor/validate.ts",
463
+ "source": "./src/iso-editor/validate.ts",
464
+ "default": "./js/iso-editor/validate.js"
465
+ },
466
+ "./modules/iso-editor/window/protocol": {
467
+ "types": "./src/iso-editor/window/protocol.ts",
468
+ "source": "./src/iso-editor/window/protocol.ts",
469
+ "default": "./js/iso-editor/window/protocol.js"
470
+ },
471
+ "./modules/iso-systems/catalog": {
472
+ "types": "./src/iso-systems/catalog.ts",
473
+ "source": "./src/iso-systems/catalog.ts",
474
+ "default": "./js/iso-systems/catalog.js"
475
+ },
476
+ "./modules/iso-systems/compile": {
477
+ "types": "./src/iso-systems/compile.ts",
478
+ "source": "./src/iso-systems/compile.ts",
479
+ "default": "./js/iso-systems/compile.js"
480
+ },
481
+ "./modules/iso-systems/css": {
482
+ "types": "./src/iso-systems/css.ts",
483
+ "source": "./src/iso-systems/css.ts",
484
+ "default": "./js/iso-systems/css.js"
485
+ },
486
+ "./modules/iso-systems/index": {
487
+ "types": "./src/iso-systems/index.ts",
488
+ "source": "./src/iso-systems/index.ts",
489
+ "default": "./js/iso-systems/index.js"
490
+ },
491
+ "./modules/iso-systems/nodes": {
492
+ "types": "./src/iso-systems/nodes.ts",
493
+ "source": "./src/iso-systems/nodes.ts",
494
+ "default": "./js/iso-systems/nodes.js"
495
+ },
496
+ "./modules/iso-systems/validate": {
497
+ "types": "./src/iso-systems/validate.ts",
498
+ "source": "./src/iso-systems/validate.ts",
499
+ "default": "./js/iso-systems/validate.js"
500
+ },
501
+ "./assets/*": "./assets/*",
502
+ "./package.json": "./package.json"
503
+ }
504
+ }
@@ -0,0 +1,23 @@
1
+ // Compiles a JSON Schema into a validator with ajv. In Node this is ajv.compile. In the browser (the editor's page),
2
+ // whose CSP forbids evaluating strings, the browser build swaps this module for validators that ajv wrote out as
3
+ // code at build time (ajv standalone), keyed by the schema's fingerprint. Both use these options.
4
+
5
+ import Ajv2020Mod from 'ajv/dist/2020.js';
6
+ import type { ValidateFunction } from 'ajv';
7
+
8
+ // ajv is CommonJS; under Node's ESM loader the class may sit on `.default`.
9
+ export const Ajv2020 = ((Ajv2020Mod as unknown as { default?: unknown }).default ?? Ajv2020Mod) as typeof Ajv2020Mod.default;
10
+ export const AJV_OPTIONS = { allErrors: true, verbose: true, strict: false } as const;
11
+ const ajv = new Ajv2020(AJV_OPTIONS);
12
+
13
+ export function compileSchema(schema: object): ValidateFunction {
14
+ return ajv.compile(schema);
15
+ }
16
+
17
+ /** A stable fingerprint of a schema (FNV-1a over its JSON): the browser build looks validators up by it. */
18
+ export function fingerprint(schema: object): string {
19
+ const t = JSON.stringify(schema);
20
+ let h = 0x811c9dc5;
21
+ for (let i = 0; i < t.length; i++) { h ^= t.charCodeAt(i); h = Math.imul(h, 0x01000193) >>> 0; }
22
+ return h.toString(16) + ':' + t.length;
23
+ }
@@ -0,0 +1,56 @@
1
+ // Painter's order for boxes seen from the isometric viewpoint (looking from +x, +y, +z toward the origin).
2
+ // A box is drawn before another when it is separated from it on the far side of some axis and their
3
+ // pictures overlap; everything else keeps the references' rule, the sum x0 + y0, then z0.
4
+
5
+ import { type Box, iso } from './kernel.ts';
6
+
7
+ export interface Drawable { box: Box; key?: number }
8
+
9
+ function screenRect(b: Box): [number, number, number, number] {
10
+ const pts = [iso(b.x0, b.y0, b.z1), iso(b.x1, b.y0, b.z0), iso(b.x0, b.y1, b.z0), iso(b.x1, b.y1, b.z0), iso(b.x1, b.y1, b.z1), iso(b.x0, b.y0, b.z0)];
11
+ const xs = pts.map(p => p[0]), ys = pts.map(p => p[1]);
12
+ return [Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)];
13
+ }
14
+
15
+ /** -1: a before b; 1: b before a; 0: no constraint */
16
+ function behind(a: Box, b: Box): number {
17
+ const e = 1e-6;
18
+ const ax = a.x1 <= b.x0 + e, bx = b.x1 <= a.x0 + e;
19
+ const ay = a.y1 <= b.y0 + e, by = b.y1 <= a.y0 + e;
20
+ const az = a.z1 <= b.z0 + e, bz = b.z1 <= a.z0 + e;
21
+ const aFirst = ax || ay || az, bFirst = bx || by || bz;
22
+ if (aFirst && !bFirst) return -1;
23
+ if (bFirst && !aFirst) return 1;
24
+ return 0;
25
+ }
26
+
27
+ export function depthSort<T extends Drawable>(list: T[]): T[] {
28
+ const n = list.length;
29
+ const rects = list.map(d => screenRect(d.box));
30
+ const prio = (d: T) => d.box.x0 + d.box.y0 + d.box.z0 * 0.01;
31
+ const after: number[][] = list.map(() => []);
32
+ const indeg = new Array(n).fill(0);
33
+ for (let i = 0; i < n; i++) for (let j = i + 1; j < n; j++) {
34
+ const ri = rects[i], rj = rects[j];
35
+ if (ri[2] <= rj[0] || rj[2] <= ri[0] || ri[3] <= rj[1] || rj[3] <= ri[1]) continue;
36
+ const c = behind(list[i].box, list[j].box);
37
+ if (c < 0) { after[i].push(j); indeg[j]++; } else if (c > 0) { after[j].push(i); indeg[i]++; }
38
+ }
39
+ const out: T[] = [];
40
+ const ready = list.map((_, i) => i).filter(i => !indeg[i]);
41
+ const used = new Array(n).fill(false);
42
+ while (out.length < n) {
43
+ if (!ready.length) {
44
+ // a cycle (boxes that interpenetrate): take the furthest-back remaining box
45
+ const rest = list.map((_, i) => i).filter(i => !used[i]).sort((x, y) => prio(list[x]) - prio(list[y]));
46
+ ready.push(rest[0]);
47
+ indeg[rest[0]] = 0;
48
+ }
49
+ ready.sort((x, y) => prio(list[x]) - prio(list[y]) || x - y);
50
+ const i = ready.shift()!;
51
+ if (used[i]) continue;
52
+ used[i] = true; out.push(list[i]);
53
+ for (const j of after[i]) if (!used[j] && --indeg[j] === 0) ready.push(j);
54
+ }
55
+ return out;
56
+ }
@@ -0,0 +1,73 @@
1
+ // Diagnostics: a message tied to a place in the YAML source, printed with a caret excerpt.
2
+
3
+ export type Severity = 'error' | 'warning';
4
+
5
+ export interface Diag {
6
+ severity: Severity;
7
+ message: string;
8
+ /** 1-based; 0 when the place is unknown */
9
+ line: number;
10
+ col: number;
11
+ /** the JSON path in the document, for tools and tests, e.g. /scenes/0/nodes/2/asset */
12
+ path: string;
13
+ hint?: string;
14
+ /** another file the place is in (a defaults or override file), with its text for the excerpt */
15
+ file?: string;
16
+ source?: string;
17
+ }
18
+
19
+ export class DiagError extends Error {
20
+ diags: Diag[];
21
+ constructor(diags: Diag[]) {
22
+ super(diags.map(d => `${d.line}:${d.col} ${d.message}`).join('\n'));
23
+ this.diags = diags;
24
+ }
25
+ }
26
+
27
+ /** Edit distance where swapping two neighbouring letters counts as one edit (optimal string alignment). */
28
+ export function distance(a: string, b: string): number {
29
+ const m = a.length, n = b.length;
30
+ if (!m) return n;
31
+ if (!n) return m;
32
+ const d: number[][] = Array.from({ length: m + 1 }, (_, i) => [i, ...Array(n).fill(0)]);
33
+ for (let j = 0; j <= n; j++) d[0][j] = j;
34
+ for (let i = 1; i <= m; i++) {
35
+ for (let j = 1; j <= n; j++) {
36
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
37
+ d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
38
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
39
+ }
40
+ }
41
+ return d[m][n];
42
+ }
43
+
44
+ /** The closest candidate, if it is close enough to be a likely typo. */
45
+ export function didYouMean(word: string, candidates: Iterable<string>): string | undefined {
46
+ let best: string | undefined, bd = Infinity;
47
+ const w = word.toLowerCase();
48
+ for (const c of candidates) {
49
+ const d = distance(w, c.toLowerCase());
50
+ if (d < bd) { bd = d; best = c; }
51
+ }
52
+ if (best === undefined) return undefined;
53
+ const limit = Math.max(1, Math.min(3, Math.floor(Math.max(word.length, best.length) / 3)));
54
+ return bd <= limit ? best : undefined;
55
+ }
56
+
57
+ export function formatDiag(d: Diag, file: string, source?: string): string {
58
+ if (d.file) { file = d.file; source = d.source; }
59
+ const where = d.line ? `${file}:${d.line}:${d.col}` : file;
60
+ let out = `${where} ${d.severity}: ${d.message}`;
61
+ if (d.hint) out += `\n ${d.hint}`;
62
+ if (source && d.line) {
63
+ const lines = source.split(/\r?\n/);
64
+ const text = lines[d.line - 1] ?? '';
65
+ const gutter = String(d.line).padStart(4);
66
+ out += `\n${gutter} | ${text}\n${' '.repeat(gutter.length)} | ${' '.repeat(Math.max(0, d.col - 1))}^`;
67
+ }
68
+ return out;
69
+ }
70
+
71
+ export function formatDiags(diags: Diag[], file: string, source?: string): string {
72
+ return diags.map(d => formatDiag(d, file, source)).join('\n\n');
73
+ }