@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,216 @@
1
+ import { SEVERITIES } from "./timeline-contract.js";
2
+ import { within } from "./timeline-scope.js";
3
+ const BASE_FIELDS = ["kind", "source", "severity", "scope", "since", "before"];
4
+ function tokens(q) {
5
+ const out = [];
6
+ let i = 0;
7
+ while (i < q.length) {
8
+ while (i < q.length && /\s/.test(q[i])) i++;
9
+ if (i >= q.length) break;
10
+ let neg = false;
11
+ if (q[i] === "-" && i + 1 < q.length && !/\s/.test(q[i + 1])) {
12
+ neg = true;
13
+ i++;
14
+ }
15
+ const m = /^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(q.slice(i));
16
+ let field;
17
+ if (m) {
18
+ field = m[1];
19
+ i += m[0].length;
20
+ }
21
+ let raw = "", quoted = false;
22
+ if (q[i] === '"') {
23
+ const j = q.indexOf('"', i + 1);
24
+ raw = q.slice(i + 1, j < 0 ? q.length : j);
25
+ quoted = true;
26
+ i = j < 0 ? q.length : j + 1;
27
+ } else {
28
+ const s = i;
29
+ while (i < q.length && !/\s/.test(q[i])) i++;
30
+ raw = q.slice(s, i);
31
+ }
32
+ out.push({ neg, raw, quoted, field });
33
+ }
34
+ return out;
35
+ }
36
+ const REL = /^(\d+)(s|m|h|d|w)$/;
37
+ const UNIT = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 7 * 864e5 };
38
+ function readTime(v, now) {
39
+ const r = REL.exec(v);
40
+ if (r) return now - Number(r[1]) * UNIT[r[2]];
41
+ const d = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(v);
42
+ if (!d) return void 0;
43
+ const [, y, mo, da, hh = "0", mi = "0", ss = "0", ms = "0", zone] = d;
44
+ if (zone) {
45
+ const t2 = Date.parse(v.replace(" ", "T"));
46
+ return Number.isNaN(t2) ? void 0 : t2;
47
+ }
48
+ const t = new Date(+y, +mo - 1, +da, +hh, +mi, +ss, +ms.padEnd(3, "0")).getTime();
49
+ return Number.isNaN(t) ? void 0 : t;
50
+ }
51
+ function parseWith(fields, q, now = Date.now()) {
52
+ const terms = [], warnings = [];
53
+ for (const t of tokens(q ?? "")) {
54
+ const asText = (why) => {
55
+ const value = t.field ? `${t.field}:${t.raw}` : t.raw;
56
+ if (why) warnings.push(`${JSON.stringify(value)}: ${why}; searched as text`);
57
+ if (value) terms.push({ neg: t.neg, value });
58
+ };
59
+ if (!t.field) {
60
+ asText();
61
+ continue;
62
+ }
63
+ const known = fields.includes(t.field) || t.field.startsWith("attr.");
64
+ if (!known) {
65
+ asText(`no field ${t.field}`);
66
+ continue;
67
+ }
68
+ if (!t.raw) {
69
+ asText(`${t.field}: needs a value`);
70
+ continue;
71
+ }
72
+ const field = t.field;
73
+ if (field === "severity") {
74
+ const m = /^(>=|<=|>|<|=)?(.*)$/.exec(t.raw);
75
+ if (!SEVERITIES.includes(m[2])) {
76
+ asText(`no severity ${m[2]} (${SEVERITIES.join(", ")})`);
77
+ continue;
78
+ }
79
+ terms.push({ neg: t.neg, field, op: m[1] ?? "=", value: m[2] });
80
+ } else if (field === "since" || field === "before") {
81
+ const time = readTime(t.raw, now);
82
+ if (time === void 0) {
83
+ asText(`can't read the time ${t.raw} (15m, 2h, 3d, 1w, or a date like 2026-11-20 or 2026-11-20T09:30)`);
84
+ continue;
85
+ }
86
+ if (t.neg) {
87
+ asText(`-${field} isn't allowed (use ${field === "since" ? "before" : "since"})`);
88
+ continue;
89
+ }
90
+ terms.push({ neg: false, field, value: t.raw, time });
91
+ } else terms.push({ neg: t.neg, field, value: t.raw });
92
+ }
93
+ return { terms, warnings };
94
+ }
95
+ const sevRank = (s) => SEVERITIES.indexOf(s);
96
+ const OPS = { "=": "eq", ">=": "ge", ">": "gt", "<=": "le", "<": "lt" };
97
+ function matchOf(t, d) {
98
+ switch (t.field) {
99
+ case void 0:
100
+ return { field: "text", value: t.value };
101
+ case "kind":
102
+ case "source":
103
+ return t.value.endsWith("*") ? { field: t.field, value: t.value.slice(0, -1), prefix: true } : { field: t.field, value: t.value };
104
+ case "severity":
105
+ return { field: "severity", op: OPS[t.op ?? "="], value: t.value };
106
+ case "scope":
107
+ return { field: "scope", value: t.value, from: d.topKinds.some((k) => t.value.startsWith(`${k}:`)) ? "top" : "segments" };
108
+ case "since":
109
+ case "before":
110
+ return void 0;
111
+ default:
112
+ if (d.links.includes(t.field)) return { field: "link", link: t.field, value: t.value };
113
+ return { field: "attr", key: t.field.slice(5), value: t.value };
114
+ }
115
+ }
116
+ function toAstWith(d, p) {
117
+ const all = [], groups = /* @__PURE__ */ new Map();
118
+ for (const t of p.terms) {
119
+ const m = matchOf(t, d);
120
+ if (!m) continue;
121
+ if (t.neg) {
122
+ all.push({ not: true, any: [m] });
123
+ continue;
124
+ }
125
+ if (m.field === "text" || m.field === "severity") {
126
+ all.push({ any: [m] });
127
+ continue;
128
+ }
129
+ const key = m.field === "link" ? `link.${m.link}` : m.field === "attr" ? `attr.${m.key}` : m.field;
130
+ const g = groups.get(key);
131
+ if (g) g.any.push(m);
132
+ else {
133
+ const n = { any: [m] };
134
+ groups.set(key, n);
135
+ all.push(n);
136
+ }
137
+ }
138
+ return { all };
139
+ }
140
+ function test1(d, m, e, sensitive) {
141
+ switch (m.field) {
142
+ case "text": {
143
+ const v = m.value.toLowerCase();
144
+ if (e.summary.toLowerCase().includes(v) || e.kind.toLowerCase().includes(v) || e.source.toLowerCase().includes(v) || e.scope.toLowerCase().includes(v)) return true;
145
+ for (const [k, a] of Object.entries(e.attrs)) if (typeof a === "string" && !sensitive.has(`${e.source}.${k}`) && a.toLowerCase().includes(v)) return true;
146
+ return false;
147
+ }
148
+ case "kind":
149
+ case "source": {
150
+ const v = e[m.field];
151
+ return m.prefix ? v.startsWith(m.value) : v === m.value;
152
+ }
153
+ case "severity": {
154
+ const a = sevRank(e.severity), b = sevRank(m.value);
155
+ return m.op === "ge" ? a >= b : m.op === "gt" ? a > b : m.op === "le" ? a <= b : m.op === "lt" ? a < b : a === b;
156
+ }
157
+ case "scope":
158
+ return m.from === "top" ? within(e.scope, m.value) : `/${e.scope}/`.includes(`/${m.value}/`);
159
+ case "link": {
160
+ const own = d.linkMatch?.(String(m.link), m.value, e);
161
+ return own ?? e.links[m.link] === m.value;
162
+ }
163
+ case "attr": {
164
+ const a = e.attrs[m.key];
165
+ return a !== void 0 && a !== null && String(a).toLowerCase() === m.value.toLowerCase();
166
+ }
167
+ }
168
+ }
169
+ function searchFor(d) {
170
+ const FIELDS = [...BASE_FIELDS, ...d.links];
171
+ const parseSearch = (q, now = Date.now()) => parseWith(FIELDS, q, now);
172
+ const toAst = (p) => toAstWith(d, p);
173
+ function compileSearch(q, now, from, to) {
174
+ const p = parseSearch(q, now);
175
+ return { where: toAst(p), ...rangeOf(p, from, to), warnings: p.warnings };
176
+ }
177
+ function matchAst(ast, sensitive = []) {
178
+ const sens = new Set(sensitive), all = ast?.all ?? [];
179
+ if (!all.length) return () => true;
180
+ return (e) => all.every((t) => t.any.some((m) => test1(d, m, e, sens)) !== !!t.not);
181
+ }
182
+ const matcher = (p, sensitive = []) => matchAst(toAst(p), sensitive);
183
+ return { FIELDS, parseSearch, toAst, compileSearch, matchAst, matcher };
184
+ }
185
+ function rangeOf(p, from, to) {
186
+ for (const t of p.terms) {
187
+ if (t.field === "since") from = Math.max(from, t.time);
188
+ if (t.field === "before") to = Math.min(to, t.time);
189
+ }
190
+ return { from, to: Math.max(from, to) };
191
+ }
192
+ function highlights(p, line) {
193
+ const low = line.toLowerCase(), out = [];
194
+ for (const t of p.terms) {
195
+ if (t.neg || t.field || !t.value) continue;
196
+ const v = t.value.toLowerCase();
197
+ for (let i = low.indexOf(v); i >= 0; i = low.indexOf(v, i + v.length)) out.push([i, i + v.length]);
198
+ }
199
+ out.sort((a, b) => a[0] - b[0]);
200
+ const merged = [];
201
+ for (const r of out) {
202
+ const l = merged[merged.length - 1];
203
+ if (l && r[0] <= l[1]) l[1] = Math.max(l[1], r[1]);
204
+ else merged.push([...r]);
205
+ }
206
+ return merged;
207
+ }
208
+ const severities = (min) => SEVERITIES.filter((s) => sevRank(s) >= sevRank(min));
209
+ export {
210
+ BASE_FIELDS,
211
+ highlights,
212
+ rangeOf,
213
+ readTime,
214
+ searchFor,
215
+ severities
216
+ };
@@ -0,0 +1,55 @@
1
+ const MIN = 6e4, HOUR = 36e5, DAY = 864e5;
2
+ const formats = /* @__PURE__ */ new Map();
3
+ const offsets = /* @__PURE__ */ new Map();
4
+ function offsetAt(tz, t) {
5
+ if (!tz || tz === "UTC") return 0;
6
+ const key = `${tz}|${Math.floor(t / (15 * MIN))}`;
7
+ const hit = offsets.get(key);
8
+ if (hit !== void 0) return hit;
9
+ let f = formats.get(tz);
10
+ if (!f) {
11
+ try {
12
+ f = new Intl.DateTimeFormat("en-US", { timeZone: tz, hourCycle: "h23", year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric" });
13
+ } catch {
14
+ return 0;
15
+ }
16
+ formats.set(tz, f);
17
+ }
18
+ const p = {};
19
+ for (const x of f.formatToParts(new Date(t))) if (x.type !== "literal") p[x.type] = Number(x.value);
20
+ const local = Date.UTC(p.year, p.month - 1, p.day, p.hour % 24, p.minute, p.second);
21
+ const off = Math.round((local - Math.floor(t / 1e3) * 1e3) / MIN) * MIN;
22
+ if (offsets.size > 5e4) offsets.clear();
23
+ offsets.set(key, off);
24
+ return off;
25
+ }
26
+ const isZone = (tz) => {
27
+ try {
28
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
29
+ return true;
30
+ } catch {
31
+ return false;
32
+ }
33
+ };
34
+ function binStart(t, bin, tz) {
35
+ if (bin === "1m") return Math.floor(t / MIN) * MIN;
36
+ const off = offsetAt(tz, t);
37
+ if (bin === "1h") return off % HOUR === 0 ? Math.floor(t / HOUR) * HOUR : Math.floor((t + off) / HOUR) * HOUR - off;
38
+ const day = Math.floor((t + off) / DAY) * DAY;
39
+ let s = day - offsetAt(tz, day - off);
40
+ if (s > t) s = day - DAY - offsetAt(tz, day - DAY - off);
41
+ else if (binNext(s, tz) <= t) s = binNext(s, tz);
42
+ return s;
43
+ }
44
+ function binNext(s, tz, bin = "1d") {
45
+ if (bin === "1m") return s + MIN;
46
+ if (bin === "1h") return s + HOUR;
47
+ const off = offsetAt(tz, s), day = Math.floor((s + off) / DAY) * DAY + DAY;
48
+ return day - offsetAt(tz, day - off);
49
+ }
50
+ export {
51
+ binNext,
52
+ binStart,
53
+ isZone,
54
+ offsetAt
55
+ };
@@ -0,0 +1,68 @@
1
+ const isoVars = (css) => css.replace(/--([a-zA-Z][\w-]*)/g, "--iso-$1");
2
+ function blocks(css) {
3
+ const out = [];
4
+ let i = 0;
5
+ const text = css.replace(/\/\*[\s\S]*?\*\//g, "");
6
+ while (i < text.length) {
7
+ const open = text.indexOf("{", i);
8
+ if (open < 0) break;
9
+ let depth = 1, j = open + 1;
10
+ while (j < text.length && depth) {
11
+ if (text[j] === "{") depth++;
12
+ else if (text[j] === "}") depth--;
13
+ j++;
14
+ }
15
+ out.push([text.slice(i, open).trim(), text.slice(open + 1, j - 1)]);
16
+ i = j;
17
+ }
18
+ return out;
19
+ }
20
+ function selectors(list) {
21
+ const out = [];
22
+ let depth = 0, cut = 0;
23
+ for (let i = 0; i < list.length; i++) {
24
+ const c = list[i];
25
+ if (c === "(" || c === "[") depth++;
26
+ else if (c === ")" || c === "]") depth--;
27
+ else if (c === "," && !depth) {
28
+ out.push(list.slice(cut, i).trim());
29
+ cut = i + 1;
30
+ }
31
+ }
32
+ out.push(list.slice(cut).trim());
33
+ return out.filter(Boolean);
34
+ }
35
+ function scopeSelector(sel, root, stateRoot) {
36
+ const m = /^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(sel);
37
+ const st = stateRoot.replace(/^\./, "");
38
+ if (m) {
39
+ const state = m[1], rest = m[2].trim();
40
+ return `${state ? `.${st}${state} ` : ""}${root}${rest ? " " + rest : ""}`;
41
+ }
42
+ if (/^(html|body|\*)\b/.test(sel) || /^[a-z]+$/.test(sel) && !/^(svg|g|text|path|polygon|rect|circle|line)$/.test(sel)) throw new Error(`the canvas's CSS can't style the page: "${sel}"`);
43
+ return `${root} ${sel}`;
44
+ }
45
+ function scope(css, root, stateRoot) {
46
+ let out = "";
47
+ for (const [pre, body] of blocks(css)) {
48
+ if (pre.startsWith("@keyframes")) {
49
+ out += `@keyframes iso-${pre.slice("@keyframes".length).trim()}{${body}}
50
+ `;
51
+ continue;
52
+ }
53
+ if (pre.startsWith("@media") || pre.startsWith("@supports")) {
54
+ out += `${pre}{${scope(body, root, stateRoot)}}
55
+ `;
56
+ continue;
57
+ }
58
+ if (pre.startsWith("@")) throw new Error(`the canvas's CSS has an at-rule it can't scope: ${pre}`);
59
+ out += `${selectors(pre).map((x) => scopeSelector(x, root, stateRoot)).join(",")}{${body.replace(/\banimation:\s*([a-z][\w-]*)/g, "animation:iso-$1")}}
60
+ `;
61
+ }
62
+ return out;
63
+ }
64
+ export {
65
+ isoVars,
66
+ scope,
67
+ scopeSelector
68
+ };
@@ -0,0 +1,177 @@
1
+ const MIN_ZOOM = 0.1, MAX_ZOOM = 8;
2
+ function viewport(host, o) {
3
+ let view, full;
4
+ let moved = false, quiet = 0, keptK = 0;
5
+ let paintedK = 0, rezoom = 0, resizeFrame = 0, disposed = false;
6
+ const size = () => {
7
+ const r = host.getBoundingClientRect();
8
+ return { w: Math.max(1, r.width), h: Math.max(1, r.height) };
9
+ };
10
+ const scale = (v = view) => {
11
+ const s = size();
12
+ return Math.min(s.w / v.w, s.h / v.h);
13
+ };
14
+ const quietly = (f) => {
15
+ quiet++;
16
+ try {
17
+ f();
18
+ } finally {
19
+ quiet--;
20
+ }
21
+ };
22
+ function applyView() {
23
+ const svg = o.svg();
24
+ if (!svg || !view) return;
25
+ if (!quiet) moved = true;
26
+ const s = size(), k = scale();
27
+ const vw = s.w / k, vh = s.h / k;
28
+ view = { x: view.x + (view.w - vw) / 2, y: view.y + (view.h - vh) / 2, w: vw, h: vh };
29
+ svg.setAttribute("viewBox", `${view.x.toFixed(2)} ${view.y.toFixed(2)} ${view.w.toFixed(2)} ${view.h.toFixed(2)}`);
30
+ keptK = k;
31
+ o.onApply(k);
32
+ if (paintedK && Math.abs(k / paintedK - 1) > 0.02) {
33
+ cancelAnimationFrame(rezoom);
34
+ rezoom = requestAnimationFrame(() => {
35
+ rezoom = 0;
36
+ o.onRezoom();
37
+ });
38
+ }
39
+ }
40
+ const toSvg = (cx, cy) => {
41
+ const r = host.getBoundingClientRect(), k = scale();
42
+ return { x: view.x + (cx - r.left) / k, y: view.y + (cy - r.top) / k };
43
+ };
44
+ function zoomAt(f, cx, cy) {
45
+ if (!view) return;
46
+ const k = scale(), nk = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, k * f));
47
+ const r = host.getBoundingClientRect();
48
+ const px = cx ?? r.left + r.width / 2, py = cy ?? r.top + r.height / 2;
49
+ const p = toSvg(px, py);
50
+ const s = size();
51
+ view = { x: p.x - (px - r.left) / nk, y: p.y - (py - r.top) / nk, w: s.w / nk, h: s.h / nk };
52
+ applyView();
53
+ }
54
+ function fit(box = full) {
55
+ if (!box) return;
56
+ const s = size(), pad = 24;
57
+ const k = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Math.min((s.w - pad * 2) / box.w, (s.h - pad * 2) / box.h)));
58
+ const cx = box.x + box.w / 2, cy = box.y + box.h / 2;
59
+ const next = { x: cx - s.w / k / 2, y: cy - s.h / k / 2, w: s.w / k, h: s.h / k };
60
+ if (view && Math.abs(next.w / view.w - 1) < 1e-3 && Math.abs(next.h / view.h - 1) < 1e-3 && Math.abs(next.x - view.x) < next.w * 1e-3 && Math.abs(next.y - view.y) < next.h * 1e-3) {
61
+ applyView();
62
+ return;
63
+ }
64
+ view = next;
65
+ applyView();
66
+ }
67
+ function fitItems() {
68
+ for (let round = 0, last = ""; round < 4; round++) {
69
+ const b = o.itemsBox() ?? full;
70
+ if (!b) return;
71
+ const key = [b.x, b.y, b.w, b.h].map((n) => Math.round(n)).join();
72
+ if (key === last) break;
73
+ last = key;
74
+ const m = Math.max(24, Math.min(b.w, b.h) * 0.06);
75
+ quietly(() => fit({ x: b.x - m, y: b.y - m, w: b.w + m * 2, h: b.h + m * 2 }));
76
+ if (!o.marksShowing() || !paintedK || Math.abs(scale() / paintedK - 1) <= 0.02) break;
77
+ cancelAnimationFrame(rezoom);
78
+ rezoom = 0;
79
+ o.onRezoom();
80
+ }
81
+ moved = false;
82
+ }
83
+ function autoFit() {
84
+ if (moved || !o.svg() || !view) return;
85
+ const r = host.getBoundingClientRect();
86
+ if (r.width < 2 || r.height < 2) return;
87
+ fitItems();
88
+ }
89
+ function actual() {
90
+ if (!view) return;
91
+ const k = scale();
92
+ zoomAt(1 / k);
93
+ }
94
+ function settled() {
95
+ return new Promise((res) => {
96
+ let calm = 0, k0 = keptK;
97
+ const tick = () => {
98
+ if (disposed) {
99
+ res();
100
+ return;
101
+ }
102
+ const busy = !!(rezoom || resizeFrame) || keptK !== k0;
103
+ k0 = keptK;
104
+ calm = busy ? 0 : calm + 1;
105
+ if (calm >= 2) res();
106
+ else requestAnimationFrame(tick);
107
+ };
108
+ requestAnimationFrame(tick);
109
+ });
110
+ }
111
+ const resizes = new ResizeObserver(() => {
112
+ if (!view || disposed) return;
113
+ if (moved && keptK) {
114
+ const sz = size(), cx = view.x + view.w / 2, cy = view.y + view.h / 2;
115
+ view = { x: cx - sz.w / keptK / 2, y: cy - sz.h / keptK / 2, w: sz.w / keptK, h: sz.h / keptK };
116
+ }
117
+ if (!moved) {
118
+ cancelAnimationFrame(resizeFrame);
119
+ resizeFrame = requestAnimationFrame(() => {
120
+ resizeFrame = 0;
121
+ if (!disposed) autoFit();
122
+ });
123
+ }
124
+ quietly(applyView);
125
+ });
126
+ resizes.observe(host);
127
+ return {
128
+ /** the view (the drawing's units): set by a pan or a reveal, then applyView() */
129
+ get view() {
130
+ return view;
131
+ },
132
+ set view(v) {
133
+ view = v;
134
+ },
135
+ /** the scene's whole frame */
136
+ get full() {
137
+ return full;
138
+ },
139
+ set full(v) {
140
+ full = v;
141
+ },
142
+ /** the person has moved the view since the last fit */
143
+ get moved() {
144
+ return moved;
145
+ },
146
+ /** the zoom the view was last applied at */
147
+ get zoom() {
148
+ return keptK;
149
+ },
150
+ /** the marks were drawn at this zoom (0: none drawn) */
151
+ painted(k) {
152
+ paintedK = k;
153
+ },
154
+ size,
155
+ scale,
156
+ quietly,
157
+ applyView,
158
+ toSvg,
159
+ zoomAt,
160
+ fit,
161
+ fitItems,
162
+ autoFit,
163
+ actual,
164
+ settled,
165
+ dispose() {
166
+ cancelAnimationFrame(resizeFrame);
167
+ cancelAnimationFrame(rezoom);
168
+ resizes.disconnect();
169
+ disposed = true;
170
+ }
171
+ };
172
+ }
173
+ export {
174
+ MAX_ZOOM,
175
+ MIN_ZOOM,
176
+ viewport
177
+ };