@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,35 @@
1
+ import type { Routed } from './route.js';
2
+ import type { Layout } from './place.js';
3
+ import { type Rect } from './labels.js';
4
+ export type Edge = 'left' | 'right' | 'top' | 'bottom';
5
+ export interface Piece {
6
+ id: string;
7
+ kind: 'region' | 'node';
8
+ edge: Edge;
9
+ dx: number;
10
+ dy: number;
11
+ delay: number;
12
+ dur: number;
13
+ bbox: Rect;
14
+ }
15
+ export interface Assembly {
16
+ pieces: Piece[];
17
+ routes: {
18
+ id: string;
19
+ delay: number;
20
+ dur: number;
21
+ }[];
22
+ labels: {
23
+ delay: number;
24
+ dur: number;
25
+ };
26
+ /** ms until everything is in place */
27
+ total: number;
28
+ }
29
+ /** The edge of the canvas nearest a box, and the offset that puts the box fully outside the canvas beyond it. */
30
+ export declare function offscreen(b: Rect, vb: [number, number, number, number]): {
31
+ edge: Edge;
32
+ dx: number;
33
+ dy: number;
34
+ };
35
+ export declare function assembly(layout: Layout, routes: Routed[], vb: [number, number, number, number]): Assembly;
@@ -0,0 +1,49 @@
1
+ import { type Box, type Kernel } from '../iso-core/kernel.js';
2
+ import * as D from '../iso-core/glyphs.js';
3
+ import type { RawDeco, RawNode } from './types.js';
4
+ export interface LabelSpot {
5
+ /** screen pixels: where the label's first line's baseline sits */
6
+ x: number;
7
+ y: number;
8
+ anchor: 'start' | 'middle' | 'end';
9
+ }
10
+ export interface NodeAsset {
11
+ name: string;
12
+ description: string;
13
+ /** default w (x), d (y), h (z) in grid units */
14
+ size: [number, number, number];
15
+ role: string;
16
+ deco?: RawDeco[];
17
+ /** SVG for the inside of the node's <g class="blk k-ROLE">; b is the node's box */
18
+ draw(k: Kernel, b: Box, n: RawNode): string;
19
+ /** where the label goes; default: centred above the top */
20
+ label?(b: Box, n: RawNode, hasSub: boolean): LabelSpot;
21
+ /** [x, y, z, r]: centre and radius (px) of the step pulse ring; default from the footprint */
22
+ pulse?(b: Box): [number, number, number, number];
23
+ /** extra classes for the node group */
24
+ cls?: string;
25
+ }
26
+ /** an icon a node can wear (deco: icon: NAME), painted on its box */
27
+ export type IconPainter = (k: Kernel, b: Box) => string;
28
+ /** `css`: the marks' styles; drawingCss() includes them from then on */
29
+ export declare function registerMarks(marks: {
30
+ icons?: Record<string, IconPainter>;
31
+ faces?: Record<string, D.FacePainter>;
32
+ css?: string;
33
+ }): void;
34
+ /** the registered marks' styles */
35
+ export declare const markCss: () => string;
36
+ export declare const iconPainter: (name: string) => IconPainter | undefined;
37
+ export declare const facePainter: (name: string) => D.FacePainter | undefined;
38
+ /** an icon the drawing names but nothing has registered: a dashed square with a question mark on the top face */
39
+ export declare function placeholderIcon(k: Kernel, b: Box): string;
40
+ export declare function drawDecos(k: Kernel, b: Box, decos: RawDeco[] | undefined): string;
41
+ /** A plain box, with decorations: the workhorse. */
42
+ export declare function boxAsset(name: string, description: string, size: [number, number, number], role: string, deco?: RawDeco[], extra?: (k: Kernel, b: Box) => string): NodeAsset;
43
+ /** The plate figures stand on: 1.5 × 1.5, 0.18 high, centred in the box. */
44
+ export declare function plate(b: Box): Box;
45
+ /** A puffy cloud outline in a face's 2D plane (w × h px), drawn clockwise with outward bumps. */
46
+ export declare function cloudPath(w: number, h: number): string;
47
+ /** A cloud lying on the floor with a little thickness: the side is the outline dropped by the height. */
48
+ export declare function drawCloud(k: Kernel, b: Box): string;
49
+ export declare function defaultLabel(b: Box, hasSub: boolean): LabelSpot;
@@ -0,0 +1,36 @@
1
+ import type { NodeAsset } from './assets.js';
2
+ import type { KindCatalog } from './kinds.js';
3
+ import type { CompiledScene } from './compile.js';
4
+ import type { RawDiagram, RawKind, RawRole } from './types.js';
5
+ import { type Board } from './flat.js';
6
+ /** the board of a laid-out scene; `visible`: only what it says is shown (e.g. a step's visible set) */
7
+ export declare function boardOf(scene: CompiledScene, visible?: (id: string) => boolean): Required<Board>;
8
+ /** the 3D board's sizes, in grid units: a card's footprint and height, the gaps, a panel's margin, the channel */
9
+ export declare const BOARD_3D: {
10
+ W: number;
11
+ D: number;
12
+ H: number;
13
+ GX: number;
14
+ GY: number;
15
+ PAD: number;
16
+ CH: number;
17
+ PANEL_H: number;
18
+ };
19
+ /** the text on a 3D card's front face */
20
+ export declare const BOARD_CSS = "\n.blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}\n.blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}\n.blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}\n";
21
+ /** a card: a slab with its name (and sub) on its front face. The text is the board's (`text`), not the node's label:
22
+ * a node with a label gets the scene's upright label above it as well */
23
+ export declare function cardAsset(text: (id: string) => {
24
+ label: string;
25
+ sub?: string;
26
+ } | undefined): NodeAsset;
27
+ /** the catalogue a board is drawn with in 3D: a panel (a thin slab, its name on its floor) and a card showing the
28
+ * board's text */
29
+ export declare function boardCatalog(board: Board): KindCatalog;
30
+ /** a board as an engine drawing (one scene): panels as regions, nested as they hold each other, cards as nodes, links
31
+ * as routes (kinds and roles: the drawing's own, as a document's `kinds:` and `roles:`) */
32
+ export declare function boardDiagram(board: Board, opts?: {
33
+ title?: string;
34
+ kinds?: Record<string, RawKind>;
35
+ roles?: Record<string, RawRole>;
36
+ }): RawDiagram;
@@ -0,0 +1,35 @@
1
+ import type { Parsed } from '../iso-core/parse.js';
2
+ import type { Diag } from '../iso-core/errors.js';
3
+ import { type Layout } from './place.js';
4
+ import { type RenderedScene } from './scene.js';
5
+ import { type Routed } from './route.js';
6
+ import { type Steps } from './steps.js';
7
+ import { type KindCatalog } from './kinds.js';
8
+ import type { GridDef, RawDiagram, Theme } from './types.js';
9
+ export interface CompiledScene {
10
+ id: string;
11
+ raw: RawDiagram['scenes'][number];
12
+ layout: Layout;
13
+ routes: Routed[];
14
+ steps: Steps;
15
+ rendered: RenderedScene;
16
+ grid: GridDef;
17
+ assemble: boolean;
18
+ }
19
+ export interface Compiled {
20
+ ok: boolean;
21
+ /** the parsed source: positions and spans of every value, for the proof sheet */
22
+ parsed?: Parsed;
23
+ source?: string;
24
+ diags: Diag[];
25
+ doc?: RawDiagram;
26
+ theme?: Theme;
27
+ /** the kinds it was drawn with (a page's legend and stylesheet ask them) */
28
+ catalog: KindCatalog;
29
+ scenes: CompiledScene[];
30
+ }
31
+ /** Places for a document that has no source text: every place is unknown (line 0). */
32
+ export declare const noSource: (data: unknown) => Parsed;
33
+ export declare function compileRaw(doc: RawDiagram, themeText: string, catalog: KindCatalog, parsed?: Parsed, source?: string, opts?: {
34
+ snap?: number;
35
+ }, diags?: Diag[]): Compiled;
@@ -0,0 +1,16 @@
1
+ import { type KindCatalog } from './kinds.js';
2
+ /** The page around a figure (the standalone page only). */
3
+ export declare const PAGE_CSS = "\n*{box-sizing:border-box}\nhtml,body{margin:0}\nbody{background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,-apple-system,\"Segoe UI\",Roboto,sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden}\ncode,pre,.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}\ncode{font-size:.92em;background:var(--code-bg);padding:1px 5px;border-radius:5px;overflow-wrap:anywhere}\n.wrap{max-width:1180px;margin:0 auto;padding:32px 16px 64px}\nheader.page{display:flex;flex-wrap:wrap;gap:12px 24px;align-items:flex-end;justify-content:space-between;margin-bottom:8px}\nh1{font-size:clamp(24px,4vw,34px);line-height:1.15;margin:0;letter-spacing:-.01em}\n.lede{color:var(--muted);max-width:76ch;margin:8px 0 0}\n.pills{display:flex;gap:8px;align-items:center;flex-wrap:wrap}\n.pill{display:inline-block;font-size:12px;font-weight:600;padding:3px 10px;border-radius:99px;border:1px solid var(--line);color:var(--muted);background:var(--surface)}\n.theme{font:inherit;font-size:12px;border:1px solid var(--line);background:var(--surface);color:var(--muted);border-radius:99px;padding:3px 10px;cursor:pointer}\nh2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}\n.sec-sub{color:var(--muted);margin:0 0 14px;font-size:14px;max-width:84ch}\n.figure{background:var(--surface);border:1px solid var(--line);border-radius:16px;margin:12px 0 10px;overflow:hidden}\n.scroller{overflow-x:auto;-webkit-overflow-scrolling:touch}\n.scroller svg{display:block;width:100%;min-width:720px;height:auto}\n.legend{display:flex;flex-wrap:wrap;gap:6px 18px;padding:10px 18px;border-top:1px solid var(--line);font-size:12.5px;color:var(--muted)}\n.legend:empty{display:none}\n.legend span{display:inline-flex;align-items:center;gap:8px}\n.legend i{display:inline-block;width:26px;height:0;border-top:3px solid}\n.legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}\nfooter{margin-top:40px;font-size:12.5px;color:var(--muted)}\n";
4
+ /** The drawing itself (a page's, and an interactive view's, scoped: src/iso-viewer/view-css.ts). */
5
+ /** the drawing's stylesheet; the catalogue's kinds add their own rules (kindsCss) in the middle, as they always sat */
6
+ /** the drawing's styles for a catalogue, with the marks a host has registered so far (registerMarks) */
7
+ export declare const drawingCss: (cat: KindCatalog) => string;
8
+ /** a page's stylesheet: the page's own rules and the drawing's */
9
+ export declare const baseCss: (cat: KindCatalog) => string;
10
+ /** Step marks and step focus, drawn in the SVG (the page, and the editor's canvas). */
11
+ export declare const MARKS_CSS = "\n/* step marks */\n.xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}\n.xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}\n.say rect{fill:var(--surface);stroke-width:1.5}\n.say text{font-size:12px;font-weight:600}\n.badge{cursor:pointer}\n.badge circle{fill:var(--c);stroke:var(--surface);stroke-width:2.5}\n.badge text{font-size:11.5px;font-weight:800;fill:var(--on);text-anchor:middle;dominant-baseline:central;pointer-events:none}\n.tok{stroke:var(--surface);stroke-width:2.5}\n.pulse{fill:none;stroke-width:2.5;transform-box:fill-box;transform-origin:center;animation:pulse 1.5s ease-out infinite}\n@keyframes pulse{from{transform:scale(.35);opacity:.95}to{transform:scale(1.5);opacity:0}}\n.sub{stroke-width:5px}\n\n/* step focus: what a step does not touch dims; things that appear later are hidden */\n[data-hl],[data-id],[data-step]{transition:opacity .25s}\nsvg.focus [data-hl]:not(.hl){opacity:.12}\nsvg.focus.dim-all [data-dim]:not(.hl){opacity:.14}\nsvg.focus .badge:not(.on){opacity:.14}\nsvg.all .badge{opacity:1}\nsvg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}\nsvg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}\n.pre{opacity:0!important;pointer-events:none}\n";
12
+ /** The player's controls (the page only). */
13
+ export declare const PLAYER_UI_CSS = "\n/* player */\n.player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}\n.ctrls{display:flex;gap:6px;flex:none}\n.pbtn{font:inherit;font-size:13px;font-weight:700;display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:99px;padding:6px 14px;cursor:pointer}\n.pbtn.icon{padding:6px 11px}\n.pbtn:hover{border-color:var(--muted)}\n.pbtn:disabled{opacity:.6;cursor:default}\n.pbtn.primary{background:var(--ink);color:var(--surface);border-color:var(--ink);min-width:92px;justify-content:center}\n.pbtn:focus-visible,.dot:focus-visible,.badge:focus-visible{outline:2px solid var(--send);outline-offset:2px}\n.cap{flex:1 1 360px;min-width:0}\n.cap-h{font-size:14.5px;font-weight:700;display:flex;align-items:center;gap:8px}\n.cap-h .cnt{margin-left:auto;font-weight:500;color:var(--muted);font-size:12px;white-space:nowrap}\n.num{flex:none;display:inline-grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--c,var(--control));color:var(--on);font-size:11px;font-weight:800}\n.cap-t{font-size:13.5px;color:var(--ink);margin:4px 0 0;max-width:92ch;min-height:3.1em}\n.cap-c{margin:8px 0 0;background:var(--code-bg);border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;max-height:9.5em;overflow-y:auto;color:var(--ink)}\n.cap-c:empty{display:none}\n.prog{height:3px;background:var(--line);border-radius:3px;overflow:hidden;margin-top:9px}\n.prog i{display:block;height:100%;width:0;background:var(--c,var(--ink))}\n.dots{display:flex;gap:5px;flex-wrap:wrap;flex-basis:100%;padding-left:2px;order:4}\n.dot{width:10px;height:10px;border-radius:50%;background:var(--line);border:0;padding:0;cursor:pointer}\n.dot.on{background:var(--ink)} .dot.done{background:var(--muted)}\ndetails.steps{margin:0 0 8px;font-size:13.5px}\ndetails.steps summary{cursor:pointer;color:var(--muted);font-size:13px}\ndetails.steps ol{margin:8px 0 0;padding-left:22px;max-width:92ch}\ndetails.steps li{margin:6px 0}\ndetails.steps li code{font-size:11.5px}\n@media (prefers-reduced-motion:reduce){.pulse{animation:none;opacity:.8}}\n@media (max-width:560px){.cap{flex-basis:100%}}\n.still .pulse{animation:none;opacity:.85}\n.still *,.still *::before{transition:none!important}\n.still .prog{display:none}\n.still .ctrls,.still .tools{display:none}\n.tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}\n.pbtn.small{font-size:12px;padding:4px 11px;font-weight:600;color:var(--muted)}\n.pbtn.small[aria-pressed=\"true\"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}";
14
+ /** The floor grid and the assemble intro, in the SVG. */
15
+ export declare const GRID_CSS = "\n.grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}\nsvg.show-grid .grid{display:inline}\nsvg.pre-assemble > g:not(.g-anim){opacity:0}\n";
16
+ export declare const PLAYER_CSS: string;
@@ -0,0 +1,130 @@
1
+ import { type Font } from '../iso-core/kernel.js';
2
+ /** a card: one thing, at a cell of the grid ([column, row]) */
3
+ export interface BoardCard {
4
+ id: string;
5
+ label: string;
6
+ sub?: string;
7
+ role?: string;
8
+ ghost?: boolean;
9
+ cell: [number, number];
10
+ }
11
+ /** a panel: a container over a range of cells, [c0, r0, c1, r1] inclusive; panels nest by containment */
12
+ export interface BoardPanel {
13
+ id: string;
14
+ label?: string;
15
+ sub?: string;
16
+ role?: string;
17
+ cells: [number, number, number, number];
18
+ }
19
+ /** a link between two cards or panels; aOn / bOn: draw that end to a panel (one holding it, or any) instead */
20
+ export interface BoardLink {
21
+ id?: string;
22
+ a: string;
23
+ b: string;
24
+ kind?: string;
25
+ label?: string;
26
+ aOn?: string;
27
+ bOn?: string;
28
+ }
29
+ /** the scene description both views are drawn from */
30
+ export interface Board {
31
+ cards: BoardCard[];
32
+ panels?: BoardPanel[];
33
+ links?: BoardLink[];
34
+ }
35
+ export interface FlatRect {
36
+ l: number;
37
+ t: number;
38
+ r: number;
39
+ b: number;
40
+ }
41
+ export type FlatPoint = [number, number];
42
+ /** the fonts a 2D layout measures: a card's name and sub, a panel's title and its subtitle, a link's label */
43
+ export type FlatFont = 'name' | 'sub' | 'title' | 'titleSub' | 'label';
44
+ export type Measure = (text: string, font: FlatFont) => number;
45
+ export interface FlatOptions {
46
+ W: number;
47
+ H: number;
48
+ GX: number;
49
+ GY: number;
50
+ PAD: number;
51
+ TITLE: number;
52
+ CH: number;
53
+ /** card and panel corner radii */
54
+ cardRx: number;
55
+ panelRx: number;
56
+ /** the cost model */
57
+ bend: number;
58
+ overlap: number;
59
+ crossPanel: number;
60
+ border: number;
61
+ nearEdge: number;
62
+ /** the margin round the drawing */
63
+ margin: number;
64
+ /** wrap a drawing wider than this (width / height) onto further shelves (wrapBoard); off by default */
65
+ wrap?: {
66
+ aspect: number;
67
+ };
68
+ }
69
+ export declare const FLAT_DEFAULTS: Readonly<FlatOptions>;
70
+ export interface FlatCard extends BoardCard {
71
+ rect: FlatRect;
72
+ }
73
+ export interface FlatPanel extends BoardPanel {
74
+ rect: FlatRect;
75
+ /** the title strip's box (what a link may not cross) */
76
+ title: FlatRect;
77
+ /** the title's baseline */
78
+ titleAt: FlatPoint;
79
+ /** the panel it sits in, if any */
80
+ parent?: string;
81
+ depth: number;
82
+ }
83
+ export interface FlatLabel {
84
+ x: number;
85
+ y: number;
86
+ anchor: 'start' | 'middle' | 'end';
87
+ box: FlatRect;
88
+ text: string;
89
+ }
90
+ export interface FlatLink extends BoardLink {
91
+ id: string;
92
+ points: FlatPoint[];
93
+ at?: FlatLabel;
94
+ routed: boolean;
95
+ }
96
+ export interface FlatLayout {
97
+ cards: FlatCard[];
98
+ panels: FlatPanel[];
99
+ links: FlatLink[];
100
+ /** everything drawn, with the margin */
101
+ bounds: FlatRect;
102
+ options: FlatOptions;
103
+ /** warnings: a link with no clear route (drawn the least bad way) */
104
+ warnings: string[];
105
+ }
106
+ /** the 2D view's fonts (its stylesheet's: src/iso-viewer/flat-view.ts), as L0's measured metrics have them */
107
+ export declare const FLAT_FONTS: Record<FlatFont, Font>;
108
+ /** text measured with L0's font metrics: the same in Node and every browser (stills and tests); a page measures its
109
+ * rendered text instead (flat-view.ts: measureIn) */
110
+ export declare const metricsMeasure: Measure;
111
+ /** what is wrong with a board, as messages; layoutFlat refuses a board with any */
112
+ export declare function boardErrors(board: Board): string[];
113
+ /** where a board's cards and panels go on a grid with the given sizes and gaps (the 2D layout's, in px; the 3D
114
+ * drawing's, in grid units): each card's top-left corner, each panel's rect, and how the panels nest */
115
+ export declare function placeBoard(board: Board, o: Pick<FlatOptions, 'W' | 'H' | 'GX' | 'GY' | 'PAD' | 'TITLE' | 'CH'>): {
116
+ prect: FlatRect[];
117
+ parentIx: number[];
118
+ depthOf: (i: number) => number;
119
+ pos: (i: number, j: number) => FlatPoint;
120
+ cardAt: (i: number) => FlatPoint;
121
+ };
122
+ /** the 2D layout of a board. Throws on a board with errors (boardErrors). */
123
+ export declare function layoutFlat(board: Board, measure: Measure, opts?: Partial<FlatOptions>): FlatLayout;
124
+ /** which card or panel a point is on (topmost: a card, then the innermost panel) */
125
+ export declare function flatHit(L: FlatLayout, x: number, y: number): string | undefined;
126
+ /** A wide drawing wrapped for a frame of an aspect (width / height): in a container (the drawing, or a panel) whose
127
+ * children stand side by side, the last of them go onto a shelf of their own below the others, in their order. Each
128
+ * step takes the wrap that lets the drawing be drawn largest in such a frame, while one does. Cards inside a panel of cards only
129
+ * stay as they are: what moves is a container's children as wholes (inner panels, and cards beside them). */
130
+ export declare function wrapBoard(board: Board, measure: Measure, aspect: number, opts?: Partial<FlatOptions>): Board;
@@ -0,0 +1 @@
1
+ export declare function focusView(full: number[], box: [number, number, number, number] | undefined): number[];
@@ -0,0 +1,59 @@
1
+ import type { CompiledScene } from './compile.js';
2
+ import { type KindCatalog } from './kinds.js';
3
+ /** A move on screen (SVG units) as a move on the floor (grid units): the inverse of the iso projection at one height. */
4
+ export declare function screenToGrid(dx: number, dy: number): [number, number];
5
+ /** Where an element sits in its parent's frame (what at: means), in grid units. */
6
+ export declare function localAt(sc: CompiledScene, id: string): [number, number] | undefined;
7
+ type Box3 = {
8
+ x0: number;
9
+ y0: number;
10
+ z0: number;
11
+ x1: number;
12
+ y1: number;
13
+ z1: number;
14
+ };
15
+ /** The outline a box makes on screen: the convex hull of its eight projected corners (a hexagon, seen from above). */
16
+ export declare function boxSilhouette(b: Box3): [number, number][];
17
+ /** A region's floor: its footprint at the height it stands on, projected (a parallelogram). */
18
+ export declare function floorOf(b: Box3): [number, number][];
19
+ /** a region's inner margin: its own, else its kind's (as place.ts pads it); 0 for a kind the catalogue doesn't have */
20
+ export declare const paddingOf: (cat: KindCatalog, region: {
21
+ kind?: string;
22
+ padding?: number;
23
+ } | undefined) => number;
24
+ export interface Move {
25
+ /** the new at: in the parent's frame */
26
+ at: [number, number];
27
+ /** the grid move actually made (after snapping and clamping) */
28
+ delta: [number, number];
29
+ /** which edges of the parent stopped it */
30
+ clamped: {
31
+ left: boolean;
32
+ right: boolean;
33
+ top: boolean;
34
+ bottom: boolean;
35
+ };
36
+ }
37
+ /**
38
+ * A drag of (dx, dy) grid units, from `start` (at: in the parent's frame), to a position snapped to `step` (1: whole
39
+ * cells; 0.5: half cells), then clamped so the item's footprint `size` stays inside its parent's inner area (`parent`: its size, `pad`:
40
+ * its margin). With no parent (the scene), nothing clamps.
41
+ */
42
+ export declare function snapMove(start: [number, number], d: [number, number], step: number, size: [number, number], parent?: {
43
+ w: number;
44
+ d: number;
45
+ pad: number;
46
+ }): Move;
47
+ /** Does a footprint overlap any of these (sharing an edge isn't overlapping)? */
48
+ export declare function overlaps(a: {
49
+ x0: number;
50
+ y0: number;
51
+ x1: number;
52
+ y1: number;
53
+ }, others: {
54
+ x0: number;
55
+ y0: number;
56
+ x1: number;
57
+ y1: number;
58
+ }[]): boolean;
59
+ export {};
@@ -0,0 +1,26 @@
1
+ export type { Side, StepRef, RawPlacement, RawDeco, RawNode, RawGate, RawRegion, RawNote, RawScene, GridDef, RawDiagram, RegionKindName, Placed, RawRole, RawKind, Theme } from './types.js';
2
+ export { regionKind, nodeKind, nodeKindOr, wallHeight, kindsCss } from './kinds.js';
3
+ export type { RegionShape, RegionKind, KindCatalog } from './kinds.js';
4
+ export { drawDecos, boxAsset, plate, cloudPath, drawCloud, defaultLabel, registerMarks, markCss, iconPainter, facePainter, placeholderIcon } from './assets.js';
5
+ export type { LabelSpot, NodeAsset, IconPainter } from './assets.js';
6
+ export { WALL_T, place, gateBox, overlap2 } from './place.js';
7
+ export type { Located, Layout } from './place.js';
8
+ export { parseEnd, floorAt, ROUTE_BUDGET, routeAll, openList, simplify } from './route.js';
9
+ export type { Side as RouteSide, RawRoute, Routed, RouteResult } from './route.js';
10
+ export { silhouette, polyBounds, polyRectArea, rectArea, lineRectArea, Obstacles, labelRect, placeNodeLabel, calloutRect, placeCallout, inConvex, convexOverlap } from './labels.js';
11
+ export type { Rect, Poly, LabelText, PlacedLabel, CalloutSpot } from './labels.js';
12
+ export { offscreen, assembly } from './assemble.js';
13
+ export type { Edge, Piece, Assembly } from './assemble.js';
14
+ export { durationFor, resolveSteps, midpoint } from './steps.js';
15
+ export type { RawStep, Token, StepData, Say, Mark, Badge, Steps } from './steps.js';
16
+ export { focusView } from './focus.js';
17
+ export { regionRole, renderScene, wallsOf, LABEL_BUDGET } from './scene.js';
18
+ export type { RenderedScene, RenderWarning, SceneInput } from './scene.js';
19
+ export { PAGE_CSS, drawingCss, baseCss, MARKS_CSS, PLAYER_UI_CSS, GRID_CSS, PLAYER_CSS } from './css.js';
20
+ export { noSource, compileRaw } from './compile.js';
21
+ export { screenToGrid, localAt, boxSilhouette, floorOf, paddingOf, snapMove, overlaps } from './geometry.js';
22
+ export type { Move } from './geometry.js';
23
+ export type { CompiledScene, Compiled } from './compile.js';
24
+ export { FLAT_DEFAULTS, FLAT_FONTS, metricsMeasure, boardErrors, placeBoard, layoutFlat, flatHit } from './flat.js';
25
+ export type { Board, BoardCard, BoardPanel, BoardLink, FlatRect, FlatPoint, FlatFont, Measure, FlatOptions, FlatCard, FlatPanel, FlatLabel, FlatLink, FlatLayout } from './flat.js';
26
+ export { boardOf, BOARD_3D, BOARD_CSS, cardAsset, boardCatalog, boardDiagram } from './board.js';
@@ -0,0 +1,53 @@
1
+ import type { NodeAsset } from './assets.js';
2
+ /** How a region is drawn, and how it takes part in layout and routing. */
3
+ export type RegionShape =
4
+ /** a thick base slab: a skirt below its floor (none on another slab), its name large on its front face */
5
+ 'slab'
6
+ /** a plain block children stand on */
7
+ | 'block'
8
+ /** a cloud lying on the floor, its name in the middle */
9
+ | 'cloud'
10
+ /** a flat tint on the floor: overlays other things on purpose */
11
+ | 'zone'
12
+ /** a cage of thin walls with a gate in one: routes go round its walls (or through its gate) */
13
+ | 'walled'
14
+ /** a translucent tube over other things: overlays them on purpose */
15
+ | 'tunnel';
16
+ export interface RegionKind {
17
+ shape: RegionShape;
18
+ /** inner margin, grid units */
19
+ pad: number;
20
+ /** [z0 offset below the floor it stands on, default height above it] */
21
+ z: [number, number];
22
+ /** children stand on its top, and routes find a floor on it */
23
+ floor: boolean;
24
+ /** the colour role it is drawn in, unless the region says its own */
25
+ role: string;
26
+ /** where its name goes, unless the region says */
27
+ labelStyle: 'face' | 'face-right' | 'floor' | 'none';
28
+ /** its row in a page's legend: a swatch (a box, or a line) and its words; auto: shown whenever the kind is drawn */
29
+ legend?: {
30
+ label: string;
31
+ swatch: string;
32
+ box: boolean;
33
+ auto: boolean;
34
+ };
35
+ /** the kind's own drawing CSS, in the drawing's stylesheet */
36
+ css?: string;
37
+ }
38
+ export interface KindCatalog {
39
+ regions: Record<string, RegionKind>;
40
+ nodes: Record<string, NodeAsset>;
41
+ /** the node kind a node without one (or with an unknown one) is drawn as */
42
+ defaultNode: string;
43
+ }
44
+ /** a region kind's data; undefined for a name the catalogue doesn't have */
45
+ export declare const regionKind: (cat: KindCatalog, name: string | undefined) => RegionKind | undefined;
46
+ /** a node kind by name (none: the default); undefined for a name the catalogue doesn't have */
47
+ export declare const nodeKind: (cat: KindCatalog, name: string | undefined) => NodeAsset | undefined;
48
+ /** a node kind by name, or the default one */
49
+ export declare const nodeKindOr: (cat: KindCatalog, name: string | undefined) => NodeAsset;
50
+ /** a walled kind's default height: a gate's height follows it */
51
+ export declare const wallHeight: (cat: KindCatalog) => number;
52
+ /** the kinds' CSS, in the catalogue's order */
53
+ export declare const kindsCss: (cat: KindCatalog) => string;
@@ -0,0 +1,92 @@
1
+ import { type Box, type P2 } from '../iso-core/kernel.js';
2
+ export interface Rect {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }
8
+ export type Poly = P2[];
9
+ /** The outline of a box as seen: six corners, clockwise from the back-top corner. */
10
+ export declare function silhouette(b: Box): Poly;
11
+ export declare function polyBounds(p: Poly): Rect;
12
+ /** Area of a convex polygon clipped to a rectangle (Sutherland–Hodgman). */
13
+ export declare function polyRectArea(poly: Poly, r: Rect): number;
14
+ export declare function rectArea(a: Rect, b: Rect): number;
15
+ /** How much of a polyline (as 4px-wide strokes) falls inside a rectangle, in px². */
16
+ export declare function lineRectArea(pts: P2[], r: Rect): number;
17
+ export declare class Obstacles {
18
+ polys: {
19
+ poly: Poly;
20
+ owner: string;
21
+ }[];
22
+ rects: {
23
+ r: Rect;
24
+ owner: string;
25
+ }[];
26
+ lines: {
27
+ pts: P2[];
28
+ owner: string;
29
+ }[];
30
+ /** everything drawn over the floor (nodes, walls, gates): floor text under them is hidden */
31
+ solids: Poly[];
32
+ /** text lying in a plane (floor and face labels), as parallelograms */
33
+ slants: Poly[];
34
+ /** label spots the scene may still weigh (see LABEL_BUDGET in src/iso-objects/scene.ts); shared with forks */
35
+ budget: {
36
+ spots: number;
37
+ over: boolean;
38
+ told: boolean;
39
+ };
40
+ /** px² of a rectangle hidden under solids */
41
+ hidden(r: Rect): number;
42
+ /** px² of a convex polygon (slanted floor text) hidden under solids */
43
+ hiddenPoly(q: Poly): number;
44
+ /** like cost(), for a convex polygon */
45
+ costPoly(q: Poly, limit?: number): number;
46
+ /** px² a rectangle shares with nodes, labels and (weighted by lineW) route lines */
47
+ cost(r: Rect, owner?: string, lineW?: number): number;
48
+ /** a copy whose added rectangles do not reach this one (callouts of one step) */
49
+ fork(): Obstacles;
50
+ }
51
+ export interface LabelText {
52
+ name?: string;
53
+ sub?: string;
54
+ }
55
+ export interface PlacedLabel {
56
+ x: number;
57
+ y: number;
58
+ anchor: 'start' | 'middle' | 'end';
59
+ rect: Rect;
60
+ }
61
+ /** The rectangle a label block covers when its first baseline is at (x, y). */
62
+ export declare function labelRect(t: LabelText, x: number, y: number, anchor: 'start' | 'middle' | 'end'): Rect;
63
+ /**
64
+ * Place a node's label. Spots, each with a penalty that says how natural it is: above the node clear of its top (the
65
+ * references' place), a little higher, beside it, then below. Each spot costs its penalty plus what it covers;
66
+ * route lines count little, since labels have a halo. The cheapest wins.
67
+ */
68
+ export declare function placeNodeLabel(t: LabelText, box: Box, own: Poly, obs: Obstacles, owner: string, preferred?: {
69
+ x: number;
70
+ y: number;
71
+ anchor: 'start' | 'middle' | 'end';
72
+ }): PlacedLabel;
73
+ export interface CalloutSpot {
74
+ x: number;
75
+ y: number;
76
+ anchor: 'start' | 'middle' | 'end';
77
+ rect: Rect;
78
+ }
79
+ /** The rectangle of a callout pill whose text centre line is at y. */
80
+ export declare function calloutRect(w: number, x: number, y: number, anchor: 'start' | 'middle' | 'end'): Rect;
81
+ /**
82
+ * Place a step's callout pill: where the author put it if that is clear, else around its anchor (above first),
83
+ * whichever covers least of the nodes, the labels and the step's other callouts. Callouts move; labels stay.
84
+ */
85
+ export declare function placeCallout(w: number, ax: number, ay: number, preferred: {
86
+ x: number;
87
+ y: number;
88
+ anchor: 'start' | 'middle' | 'end';
89
+ }, obs: Obstacles): CalloutSpot;
90
+ export declare function inConvex(poly: Poly, q: P2): boolean;
91
+ /** Area of the intersection of two convex polygons (Sutherland–Hodgman, clipping a by each edge of b). */
92
+ export declare function convexOverlap(a: Poly, b: Poly): number;
@@ -0,0 +1,25 @@
1
+ import type { Box } from '../iso-core/kernel.js';
2
+ import { type KindCatalog } from './kinds.js';
3
+ import { type Diag } from '../iso-core/errors.js';
4
+ import type { Placed, RawScene, Theme } from './types.js';
5
+ export interface Located {
6
+ locate(path: string, opts?: {
7
+ key?: boolean;
8
+ }): {
9
+ line: number;
10
+ col: number;
11
+ };
12
+ }
13
+ /** a walled region's wall thickness */
14
+ export declare const WALL_T = 0.16;
15
+ export interface Layout {
16
+ items: Placed[];
17
+ byId: Map<string, Placed>;
18
+ roots: Placed[];
19
+ diags: Diag[];
20
+ /** the kinds it was laid out with: drawing and routing ask them too */
21
+ catalog: KindCatalog;
22
+ }
23
+ export declare function place(scene: RawScene, scenePath: string, src: Located, theme: Theme, catalog: KindCatalog, fileRoles?: Record<string, unknown>, snap?: number): Layout;
24
+ export declare function gateBox(f: Placed, h: number, w: number, d: number): Box;
25
+ export declare function overlap2(a: Box, b: Box, e?: number): boolean;
@@ -0,0 +1,67 @@
1
+ import type { P3 } from '../iso-core/kernel.js';
2
+ import { type Diag } from '../iso-core/errors.js';
3
+ import type { Placed, RawScene } from './types.js';
4
+ import { type Layout, type Located } from './place.js';
5
+ export type Side = 'n' | 'e' | 's' | 'w' | 'top';
6
+ export interface RawRoute {
7
+ id: string;
8
+ from: string;
9
+ to: string;
10
+ kind?: string;
11
+ via?: (number[] | string)[];
12
+ points?: number[][];
13
+ lane?: number;
14
+ arrow?: boolean;
15
+ cross?: boolean;
16
+ label?: string | {
17
+ text: string;
18
+ along?: number;
19
+ side?: 'left' | 'right';
20
+ at?: number[];
21
+ dir?: 'x' | 'y';
22
+ anchor?: 'start' | 'middle' | 'end';
23
+ };
24
+ appears?: string | number;
25
+ disappears?: string | number;
26
+ }
27
+ export interface Routed {
28
+ id: string;
29
+ raw: RawRoute;
30
+ path: string;
31
+ kind: string;
32
+ points: P3[];
33
+ from?: Placed;
34
+ to?: Placed;
35
+ }
36
+ export declare function parseEnd(s: string): {
37
+ id: string;
38
+ side?: Side;
39
+ };
40
+ export declare function floorAt(layout: Layout, x: number, y: number): number;
41
+ export interface RouteResult {
42
+ routes: Routed[];
43
+ diags: Diag[];
44
+ }
45
+ /**
46
+ * The search steps routing may take in one scene. The heaviest diagram in this repo takes about 57,000
47
+ * (the session-messaging reproduction in repro/); a drawing with 40 more nodes took 11 million, and minutes. Past the budget,
48
+ * the routes left are drawn as plain elbows and the scene says so, so a large diagram draws in about a second.
49
+ */
50
+ export declare const ROUTE_BUDGET = 500000;
51
+ export declare function routeAll(scene: RawScene, scenePath: string, layout: Layout, src: Located, kinds: Set<string>, snap?: number): RouteResult;
52
+ /**
53
+ * A* open list, taking the state with the lowest f, ties to the one earliest in the list, where taking one moves the
54
+ * last into its place (so the order is exactly that of the array scan this replaces, and every route is the same).
55
+ * A binary heap ordered by (f, position): O(log n) a step instead of a scan of the whole list, which on a large drawing
56
+ * (tens of thousands of open states, hundreds of thousands of steps) took minutes.
57
+ */
58
+ export declare function openList<T extends {
59
+ f: number;
60
+ idx: number;
61
+ hp: number;
62
+ }>(): {
63
+ length: () => number;
64
+ push(s: T): void;
65
+ take(): T;
66
+ };
67
+ export declare function simplify(p: [number, number][]): [number, number][];