@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,170 @@
1
+ import { compileSchema } from "./compile-schema.js";
2
+ import { didYouMean } from "./errors.js";
3
+ const nouns = [];
4
+ function registerNoun(noun) {
5
+ if (!nouns.includes(noun)) nouns.push(noun);
6
+ }
7
+ function thing(path) {
8
+ for (const n of nouns) {
9
+ const w = n(path);
10
+ if (w !== void 0) return w;
11
+ }
12
+ return path ? "this item" : "the file";
13
+ }
14
+ function typeName(v) {
15
+ if (v === null) return "nothing";
16
+ if (Array.isArray(v)) return "a list";
17
+ if (typeof v === "object") return "a map";
18
+ if (typeof v === "string") return `the text "${v}"`;
19
+ return `${typeof v} ${String(v)}`;
20
+ }
21
+ const typeWord = {
22
+ string: "text",
23
+ number: "a number",
24
+ integer: "a whole number",
25
+ boolean: "true or false",
26
+ array: "a list",
27
+ object: "a map"
28
+ };
29
+ const refKeys = /* @__PURE__ */ new Map();
30
+ function registerRefKeys(ref, keys) {
31
+ refKeys.set(ref, keys);
32
+ }
33
+ const constWords = /* @__PURE__ */ new Map();
34
+ function registerConst(path, words) {
35
+ constWords.set(path, (d, a) => words(typeName(d), a));
36
+ }
37
+ const patternWords = [];
38
+ function registerPattern(prefix, words) {
39
+ if (!patternWords.some(([p]) => p === prefix)) patternWords.push([prefix, words]);
40
+ }
41
+ function knownKeys(e) {
42
+ const ps = e.parentSchema;
43
+ const keys = Object.keys(ps?.properties ?? {});
44
+ if (ps?.$ref && refKeys.has(ps.$ref)) keys.push(...refKeys.get(ps.$ref).filter((k) => !keys.includes(k)));
45
+ for (const a of ps?.allOf ?? []) if (a.$ref && refKeys.has(a.$ref)) keys.push(...refKeys.get(a.$ref));
46
+ return keys;
47
+ }
48
+ function one(e, parsed) {
49
+ const pn = e.propertyName ?? (e.keyword === "propertyNames" ? e.params.propertyName : void 0);
50
+ if (pn !== void 0) {
51
+ const kp = `${e.instancePath}/${pn.replace(/~/g, "~0").replace(/\//g, "~1")}`;
52
+ const at2 = parsed.locate(kp, { key: true });
53
+ return { severity: "error", message: `"${pn}" can't be a name`, line: at2.line, col: at2.col, path: kp, hint: "names are a lower-case letter, then lower-case letters, digits and -" };
54
+ }
55
+ const path = e.instancePath;
56
+ let message = e.message ?? "is not valid";
57
+ let hint;
58
+ let at = parsed.locate(path);
59
+ const p = e.params;
60
+ switch (e.keyword) {
61
+ case "required":
62
+ message = `${thing(path)} is missing "${p.missingProperty}"`;
63
+ break;
64
+ case "additionalProperties":
65
+ case "unevaluatedProperties": {
66
+ const key = String(p.additionalProperty ?? p.unevaluatedProperty);
67
+ const keys = knownKeys(e);
68
+ const dym = didYouMean(key, keys);
69
+ message = `unknown key "${key}" in ${thing(path)}` + (dym ? ` (did you mean "${dym}"?)` : "");
70
+ if (!dym && keys.length) hint = `known keys: ${keys.join(", ")}`;
71
+ if (/\s/.test(key)) hint = 'inside { \u2026 } a comma starts a new key: put text with commas in quotes, e.g. label: "read once, at launch"';
72
+ at = parsed.locate(`${path}/${key}`, { key: true });
73
+ return { severity: "error", message, line: at.line, col: at.col, path: `${path}/${key}`, hint };
74
+ }
75
+ case "enum": {
76
+ const allowed = p.allowedValues.map(String);
77
+ const dym = typeof e.data === "string" ? didYouMean(e.data, allowed) : void 0;
78
+ const key = path.split("/").pop();
79
+ message = `${typeName(e.data)} is not a valid ${key && !/^\d+$/.test(key) ? `"${key}"` : "value"}` + (dym ? ` (did you mean "${dym}"?)` : "");
80
+ hint = `expected one of: ${allowed.join(", ")}`;
81
+ break;
82
+ }
83
+ case "const":
84
+ message = constWords.has(path) ? constWords.get(path)(e.data, p.allowedValue) : `must be ${JSON.stringify(p.allowedValue)}`;
85
+ break;
86
+ case "type":
87
+ message = `expected ${typeWord[String(p.type)] ?? p.type}, got ${typeName(e.data)}`;
88
+ break;
89
+ case "pattern":
90
+ const pw = patternWords.find(([prefix]) => String(p.pattern).startsWith(prefix));
91
+ if (pw) ({ message, hint } = pw[1](e.data));
92
+ else {
93
+ message = `"${e.data}" is not a valid id`;
94
+ hint = "ids start with a letter and use only letters, digits, - and _";
95
+ }
96
+ break;
97
+ case "minItems":
98
+ case "maxItems":
99
+ if (e.schema === 2 || e.parentSchema?.minItems === 2) {
100
+ message = `expected a list of ${e.parentSchema.minItems === e.parentSchema.maxItems ? e.parentSchema.minItems : `${e.parentSchema.minItems} to ${e.parentSchema.maxItems}`} numbers, got ${e.data.length}`;
101
+ } else message = `list ${e.message}`;
102
+ break;
103
+ case "false schema": {
104
+ const key = path.split("/").pop() ?? "";
105
+ const owner = path.split("/").slice(0, -1).join("/");
106
+ message = `"${key.replace(/~1/g, "/").replace(/~0/g, "~")}" can't be set on ${thing(owner)}`;
107
+ at = parsed.locate(path, { key: true });
108
+ break;
109
+ }
110
+ case "minimum":
111
+ case "maximum":
112
+ case "exclusiveMinimum":
113
+ case "exclusiveMaximum":
114
+ message = `${e.data} is out of range: ${e.message}`;
115
+ break;
116
+ }
117
+ return { severity: "error", message, line: at.line, col: at.col, path, hint };
118
+ }
119
+ function prune(errors, parsed) {
120
+ const anyOfs = errors.filter((e) => e.keyword === "anyOf");
121
+ const consumed = /* @__PURE__ */ new Set();
122
+ const out = [];
123
+ for (const a of anyOfs) {
124
+ const base = a.schemaPath.replace(/\/anyOf$/, "/anyOf/");
125
+ const subs = errors.filter((e) => e !== a && e.schemaPath.startsWith(base) && e.instancePath.startsWith(a.instancePath));
126
+ subs.forEach((s) => consumed.add(s));
127
+ consumed.add(a);
128
+ if (anyOfs.some((o) => o !== a && a.schemaPath.startsWith(o.schemaPath.replace(/\/anyOf$/, "/anyOf/")) && o.instancePath === a.instancePath)) continue;
129
+ const deeper = subs.filter((s) => s.instancePath.length > a.instancePath.length && s.keyword !== "anyOf");
130
+ const enumHit = subs.find((s) => s.keyword === "enum" && s.instancePath === a.instancePath && typeof a.data === "string");
131
+ if (enumHit) out.push(one(enumHit, parsed));
132
+ else if (deeper.length) out.push(...deeper.map((s) => one(s, parsed)));
133
+ else {
134
+ const sameLevel = subs.filter((s) => s.instancePath === a.instancePath && s.keyword !== "type" && s.keyword !== "anyOf");
135
+ if (sameLevel.length && typeof a.data === "object" && a.data !== null) out.push(...sameLevel.map((s) => one(s, parsed)));
136
+ else {
137
+ const types = [...new Set(subs.filter((s) => s.keyword === "type").map((s) => typeWord[String(s.params.type)] ?? ""))].filter(Boolean);
138
+ const at = parsed.locate(a.instancePath);
139
+ out.push({ severity: "error", message: `${typeName(a.data)} is not allowed here` + (types.length ? `; expected ${types.join(" or ")}` : ""), line: at.line, col: at.col, path: a.instancePath });
140
+ }
141
+ }
142
+ }
143
+ for (const e of errors) if (!consumed.has(e)) out.push(one(e, parsed));
144
+ const seen = /* @__PURE__ */ new Set();
145
+ return out.filter((d) => {
146
+ const k = `${d.path}|${d.message}`;
147
+ if (seen.has(k)) return false;
148
+ seen.add(k);
149
+ return true;
150
+ }).sort((x, y) => x.line - y.line || x.col - y.col);
151
+ }
152
+ function schemaValidator(other, what, keysOf = {}) {
153
+ for (const [ref, keys] of Object.entries(keysOf)) registerRefKeys(ref, keys);
154
+ const fn = compileSchema(other);
155
+ return (parsed) => {
156
+ if (parsed.data == null || typeof parsed.data !== "object" || Array.isArray(parsed.data)) {
157
+ return [{ severity: "error", message: `the file must be a YAML map: ${what}`, line: 1, col: 1, path: "" }];
158
+ }
159
+ if (fn(parsed.data)) return [];
160
+ return prune(fn.errors ?? [], parsed);
161
+ };
162
+ }
163
+ export {
164
+ prune,
165
+ registerConst,
166
+ registerNoun,
167
+ registerPattern,
168
+ registerRefKeys,
169
+ schemaValidator
170
+ };
@@ -0,0 +1,125 @@
1
+ const K = new Uint32Array([
2
+ 1116352408,
3
+ 1899447441,
4
+ 3049323471,
5
+ 3921009573,
6
+ 961987163,
7
+ 1508970993,
8
+ 2453635748,
9
+ 2870763221,
10
+ 3624381080,
11
+ 310598401,
12
+ 607225278,
13
+ 1426881987,
14
+ 1925078388,
15
+ 2162078206,
16
+ 2614888103,
17
+ 3248222580,
18
+ 3835390401,
19
+ 4022224774,
20
+ 264347078,
21
+ 604807628,
22
+ 770255983,
23
+ 1249150122,
24
+ 1555081692,
25
+ 1996064986,
26
+ 2554220882,
27
+ 2821834349,
28
+ 2952996808,
29
+ 3210313671,
30
+ 3336571891,
31
+ 3584528711,
32
+ 113926993,
33
+ 338241895,
34
+ 666307205,
35
+ 773529912,
36
+ 1294757372,
37
+ 1396182291,
38
+ 1695183700,
39
+ 1986661051,
40
+ 2177026350,
41
+ 2456956037,
42
+ 2730485921,
43
+ 2820302411,
44
+ 3259730800,
45
+ 3345764771,
46
+ 3516065817,
47
+ 3600352804,
48
+ 4094571909,
49
+ 275423344,
50
+ 430227734,
51
+ 506948616,
52
+ 659060556,
53
+ 883997877,
54
+ 958139571,
55
+ 1322822218,
56
+ 1537002063,
57
+ 1747873779,
58
+ 1955562222,
59
+ 2024104815,
60
+ 2227730452,
61
+ 2361852424,
62
+ 2428436474,
63
+ 2756734187,
64
+ 3204031479,
65
+ 3329325298
66
+ ]);
67
+ function sha256Hex(text) {
68
+ const msg = new TextEncoder().encode(text);
69
+ const len = msg.length, blocks = Math.ceil((len + 9) / 64);
70
+ const buf = new Uint8Array(blocks * 64);
71
+ buf.set(msg);
72
+ buf[len] = 128;
73
+ const dv = new DataView(buf.buffer);
74
+ dv.setUint32(buf.length - 4, len * 8 >>> 0);
75
+ dv.setUint32(buf.length - 8, Math.floor(len / 536870912));
76
+ const H = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
77
+ const W = new Uint32Array(64);
78
+ const r = (x, n) => x >>> n | x << 32 - n;
79
+ for (let b = 0; b < blocks; b++) {
80
+ for (let i = 0; i < 16; i++) W[i] = dv.getUint32(b * 64 + i * 4);
81
+ for (let i = 16; i < 64; i++) {
82
+ const s0 = r(W[i - 15], 7) ^ r(W[i - 15], 18) ^ W[i - 15] >>> 3, s1 = r(W[i - 2], 17) ^ r(W[i - 2], 19) ^ W[i - 2] >>> 10;
83
+ W[i] = W[i - 16] + s0 + W[i - 7] + s1 >>> 0;
84
+ }
85
+ let [a, bb, c, d, e, f, g, h] = H;
86
+ for (let i = 0; i < 64; i++) {
87
+ const t1 = h + (r(e, 6) ^ r(e, 11) ^ r(e, 25)) + (e & f ^ ~e & g) + K[i] + W[i] >>> 0;
88
+ const t2 = (r(a, 2) ^ r(a, 13) ^ r(a, 22)) + (a & bb ^ a & c ^ bb & c) >>> 0;
89
+ h = g;
90
+ g = f;
91
+ f = e;
92
+ e = d + t1 >>> 0;
93
+ d = c;
94
+ c = bb;
95
+ bb = a;
96
+ a = t1 + t2 >>> 0;
97
+ }
98
+ H[0] += a;
99
+ H[1] += bb;
100
+ H[2] += c;
101
+ H[3] += d;
102
+ H[4] += e;
103
+ H[5] += f;
104
+ H[6] += g;
105
+ H[7] += h;
106
+ }
107
+ return [...H].map((x) => x.toString(16).padStart(8, "0")).join("");
108
+ }
109
+ function createHash(alg) {
110
+ if (alg !== "sha256") throw new Error(`only sha256 here, not ${alg}`);
111
+ let t = "";
112
+ const h = { update(s) {
113
+ t += s;
114
+ return h;
115
+ }, digest(_enc) {
116
+ return sha256Hex(t);
117
+ } };
118
+ return h;
119
+ }
120
+ var crypto_default = { createHash };
121
+ export {
122
+ createHash,
123
+ crypto_default as default,
124
+ sha256Hex
125
+ };
@@ -0,0 +1,49 @@
1
+ const sep = "/";
2
+ function isAbsolute(p) {
3
+ return p.startsWith("/");
4
+ }
5
+ function normalize(p) {
6
+ const abs = p.startsWith("/");
7
+ const out = [];
8
+ for (const s of p.split("/")) {
9
+ if (!s || s === ".") continue;
10
+ if (s === "..") {
11
+ if (out.length && out[out.length - 1] !== "..") out.pop();
12
+ else if (!abs) out.push("..");
13
+ } else out.push(s);
14
+ }
15
+ return (abs ? "/" : "") + out.join("/") || (abs ? "/" : ".");
16
+ }
17
+ function resolve(...parts) {
18
+ let p = "";
19
+ for (const x of parts) p = x.startsWith("/") ? x : p ? `${p}/${x}` : x;
20
+ return normalize(p.startsWith("/") ? p : "/" + p);
21
+ }
22
+ function dirname(p) {
23
+ const i = p.replace(/\/+$/, "").lastIndexOf("/");
24
+ return i <= 0 ? p.startsWith("/") ? "/" : "." : p.slice(0, i);
25
+ }
26
+ function basename(p) {
27
+ return p.replace(/\/+$/, "").split("/").pop() ?? "";
28
+ }
29
+ function join(...parts) {
30
+ return normalize(parts.join("/"));
31
+ }
32
+ function relative(from, to) {
33
+ const a = normalize(from).split("/").filter(Boolean), b = normalize(to).split("/").filter(Boolean);
34
+ let i = 0;
35
+ while (i < a.length && a[i] === b[i]) i++;
36
+ return [...a.slice(i).map(() => ".."), ...b.slice(i)].join("/");
37
+ }
38
+ var path_default = { sep, isAbsolute, normalize, resolve, dirname, basename, join, relative };
39
+ export {
40
+ basename,
41
+ path_default as default,
42
+ dirname,
43
+ isAbsolute,
44
+ join,
45
+ normalize,
46
+ relative,
47
+ resolve,
48
+ sep
49
+ };
@@ -0,0 +1,144 @@
1
+ const ELEMENTS = /* @__PURE__ */ new Set([
2
+ "svg",
3
+ "g",
4
+ "defs",
5
+ "marker",
6
+ "symbol",
7
+ "title",
8
+ "desc",
9
+ "path",
10
+ "polygon",
11
+ "polyline",
12
+ "line",
13
+ "rect",
14
+ "circle",
15
+ "ellipse",
16
+ "text",
17
+ "tspan",
18
+ "linearGradient",
19
+ "radialGradient",
20
+ "stop",
21
+ "clipPath"
22
+ ]);
23
+ const ATTRIBUTES = /* @__PURE__ */ new Set([
24
+ "id",
25
+ "class",
26
+ "role",
27
+ "transform",
28
+ "viewBox",
29
+ "width",
30
+ "height",
31
+ "x",
32
+ "y",
33
+ "x1",
34
+ "y1",
35
+ "x2",
36
+ "y2",
37
+ "cx",
38
+ "cy",
39
+ "r",
40
+ "rx",
41
+ "ry",
42
+ "fx",
43
+ "fy",
44
+ "d",
45
+ "points",
46
+ "offset",
47
+ "gradientUnits",
48
+ "gradientTransform",
49
+ "markerWidth",
50
+ "markerHeight",
51
+ "refX",
52
+ "refY",
53
+ "orient",
54
+ "markerUnits",
55
+ "text-anchor",
56
+ "dominant-baseline",
57
+ "font-size",
58
+ "font-weight",
59
+ "letter-spacing",
60
+ "fill",
61
+ "stroke",
62
+ "stroke-width",
63
+ "stroke-dasharray",
64
+ "stroke-linecap",
65
+ "stroke-linejoin",
66
+ "opacity",
67
+ "fill-opacity",
68
+ "stroke-opacity",
69
+ "stop-color",
70
+ "stop-opacity",
71
+ "marker-start",
72
+ "marker-mid",
73
+ "marker-end",
74
+ "clip-path",
75
+ "preserveAspectRatio",
76
+ "vector-effect",
77
+ "paint-order",
78
+ "style"
79
+ ]);
80
+ const REFERENCES = /* @__PURE__ */ new Set(["fill", "stroke", "marker-start", "marker-mid", "marker-end", "clip-path", "style"]);
81
+ const ENTITY = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", "#39": "'" };
82
+ const unescape = (s) => s.replace(/&(amp|lt|gt|quot|apos|#39);/g, (_m, e) => ENTITY[e]);
83
+ function allowed(name, value) {
84
+ if (name.startsWith("data-") || name.startsWith("aria-")) return /^[a-z][\w-]*$/.test(name);
85
+ if (!ATTRIBUTES.has(name)) return false;
86
+ if (REFERENCES.has(name) && /url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(value)) return false;
87
+ return true;
88
+ }
89
+ function parseSvg(markup) {
90
+ const root = { name: "#root", attrs: [], children: [] };
91
+ const stack = [{ node: root, dropped: false }];
92
+ const re = /<(?:!--)[\s\S]*?-->|<\/([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g;
93
+ let m, at = 0;
94
+ while (m = re.exec(markup)) {
95
+ if (m.index !== at) throw new Error(`not the renderer's SVG at ${at}: ${JSON.stringify(markup.slice(at, at + 40))}`);
96
+ at = re.lastIndex;
97
+ const top = stack[stack.length - 1];
98
+ if (m[0].charAt(1) === "!") continue;
99
+ if (m[1]) {
100
+ if (stack.length < 2 || top.node.name !== m[1]) throw new Error(`a stray </${m[1]}>`);
101
+ stack.pop();
102
+ continue;
103
+ }
104
+ if (m[2]) {
105
+ const name = m[2];
106
+ const attrs = [];
107
+ for (const a of m[3].matchAll(/([\w:-]+)="([^"]*)"/g)) {
108
+ const k = a[1], v = unescape(a[2]);
109
+ if (k === "xmlns" || k.startsWith("xmlns:")) continue;
110
+ if (allowed(k, v)) attrs.push([k, v]);
111
+ }
112
+ const node = { name, attrs, children: [] };
113
+ const dropped = top.dropped || !ELEMENTS.has(name);
114
+ if (!dropped) top.node.children.push(node);
115
+ if (!m[4]) stack.push({ node, dropped });
116
+ continue;
117
+ }
118
+ if (!top.dropped && m[5].trim()) top.node.children.push(unescape(m[5]));
119
+ }
120
+ if (at !== markup.length) throw new Error(`not the renderer's SVG at ${at}`);
121
+ if (stack.length !== 1) throw new Error(`<${stack[stack.length - 1].node.name}> is never closed`);
122
+ return root;
123
+ }
124
+ const SVGNS = "http://www.w3.org/2000/svg";
125
+ const isoVars = (v) => v.replace(/var\(--([a-zA-Z][\w-]*)/g, "var(--iso-$1");
126
+ function buildSvg(markup, d = document) {
127
+ const make = (n) => {
128
+ const el = d.createElementNS(SVGNS, n.name);
129
+ for (const [k, v] of n.attrs) {
130
+ if (k === "style") el.style.cssText = isoVars(v);
131
+ else el.setAttribute(k, /var\(--/.test(v) ? isoVars(v) : v);
132
+ }
133
+ for (const c of n.children) el.append(typeof c === "string" ? d.createTextNode(c) : make(c));
134
+ return el;
135
+ };
136
+ const top = parseSvg(markup).children.find((c) => typeof c !== "string" && c.name === "svg");
137
+ if (!top) throw new Error("the drawing has no <svg>");
138
+ return make(top);
139
+ }
140
+ export {
141
+ allowed,
142
+ buildSvg,
143
+ parseSvg
144
+ };
@@ -0,0 +1,48 @@
1
+ import { parse as parseYaml } from "yaml";
2
+ function loadTheme(text) {
3
+ const t = parseYaml(text);
4
+ for (const k of ["light", "dark", "kinds", "roles"]) if (!t || typeof t[k] !== "object") throw new Error(`theme: missing "${k}"`);
5
+ return t;
6
+ }
7
+ function extendTheme(t, roles = {}, kinds = {}) {
8
+ const k = { ...t.kinds };
9
+ for (const [name, def] of Object.entries(kinds)) {
10
+ const base = k[def.like ?? name] ?? k.control;
11
+ k[name] = { color: def.color ?? base.color, dash: def.dash ?? base.dash, legend: def.legend ?? base.legend };
12
+ }
13
+ return { ...t, roles: { ...t.roles, ...roles }, kinds: k };
14
+ }
15
+ const vars = (o) => Object.entries(o).map(([k, v]) => `--${k}:${v}`).join(";");
16
+ function colorRef(t, c) {
17
+ return c in t.light ? `var(--${c})` : c;
18
+ }
19
+ function themeCss(t) {
20
+ const { light: L, dark: Dk, rest } = themeParts(t);
21
+ return `:root{${L}}
22
+ @media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${Dk}}}
23
+ :root[data-theme="dark"]{${Dk}}
24
+ ${rest}`;
25
+ }
26
+ function themeParts(t) {
27
+ let css = "";
28
+ for (const [name, r] of Object.entries(t.roles)) {
29
+ css += `.k-${name}{--h:${r.h};--s:${r.s}%}`;
30
+ if (r.top) css += `.k-${name} .top{fill:${r.top}}`;
31
+ else if (r.tint) css += `.k-${name} .top{fill:color-mix(in srgb,hsl(${r.h} ${Math.min(100, r.s + 15)}% 50%) ${r.tint}%,var(--pad-top))}`;
32
+ css += "\n";
33
+ }
34
+ for (const [name, k] of Object.entries(t.kinds)) {
35
+ const c = colorRef(t, k.color);
36
+ const dash = k.dash === "dashed" ? ";stroke-dasharray:7 6;stroke-width:2.4" : k.dash === "dotted" ? ";stroke-dasharray:3 6;stroke-width:2.4" : "";
37
+ css += `.f-${name}{stroke:${c}${dash}} .t-${name}{fill:${c}} .c-${name}{--c:${c}}
38
+ `;
39
+ }
40
+ return { light: vars(t.light), dark: vars(t.dark), rest: css };
41
+ }
42
+ export {
43
+ colorRef,
44
+ extendTheme,
45
+ loadTheme,
46
+ themeCss,
47
+ themeParts
48
+ };
@@ -0,0 +1,48 @@
1
+ const kebab = (k) => k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
2
+ class VEl {
3
+ name;
4
+ attrs = [];
5
+ children = [];
6
+ /** style properties as set (fontSize, transformOrigin…), written out as one style attribute */
7
+ style = {};
8
+ constructor(name) {
9
+ this.name = name;
10
+ }
11
+ setAttribute(k, v) {
12
+ const i = this.attrs.findIndex((a) => a[0] === k);
13
+ if (i >= 0) this.attrs[i][1] = String(v);
14
+ else this.attrs.push([k, String(v)]);
15
+ }
16
+ getAttribute(k) {
17
+ return this.attrs.find((a) => a[0] === k)?.[1] ?? null;
18
+ }
19
+ append(...ns) {
20
+ for (const n of ns) if (n !== null && n !== void 0) this.children.push(n);
21
+ }
22
+ set textContent(t) {
23
+ this.children = [String(t)];
24
+ }
25
+ get textContent() {
26
+ return this.children.map((c) => typeof c === "string" ? c : c.textContent).join("");
27
+ }
28
+ /** as a plain node, its style folded into a style attribute */
29
+ toNode() {
30
+ const st = Object.entries(this.style).filter(([, v]) => v !== "" && v !== void 0).map(([k, v]) => `${kebab(k)}:${v}`).join(";");
31
+ return { name: this.name, attrs: st ? [...this.attrs, ["style", st]] : [...this.attrs], children: this.children.map((c) => c instanceof VEl ? c.toNode() : c) };
32
+ }
33
+ }
34
+ const vdoc = { createElementNS: (_ns, name) => new VEl(name) };
35
+ const escText = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
36
+ const escAttr = (s) => escText(s).replace(/"/g, "&quot;");
37
+ function serialize(n, raw = /* @__PURE__ */ new Set(["style"])) {
38
+ if (typeof n === "string") return escText(n);
39
+ const a = n.attrs.map(([k, v]) => ` ${k}="${escAttr(v)}"`).join("");
40
+ if (!n.children.length) return `<${n.name}${a}/>`;
41
+ const inner = raw.has(n.name) ? n.children.map((c) => typeof c === "string" ? c.replace(/<\//g, "<\\/") : serialize(c, raw)).join("") : n.children.map((c) => serialize(c, raw)).join("");
42
+ return `<${n.name}${a}>${inner}</${n.name}>`;
43
+ }
44
+ export {
45
+ VEl,
46
+ serialize,
47
+ vdoc
48
+ };
File without changes