@johnoscott/isometric-engine 0.0.0-stage → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EDITOR-GUIDE.md +355 -0
- package/LICENSE +21 -0
- package/LICENSES/ajv.txt +22 -0
- package/LICENSES/lucide-static.txt +43 -0
- package/LICENSES/yaml.txt +13 -0
- package/README.md +62 -2
- package/assets/app.css +269 -0
- package/assets/default-theme.yaml +99 -0
- package/assets/icons.svg +1 -0
- package/assets/marks.css +39 -0
- package/assets/skin.css +181 -0
- package/iso-editor.d.ts +4 -0
- package/iso-editor.js +550 -0
- package/iso-render.d.ts +3 -0
- package/iso-render.js +388 -0
- package/iso-systems.d.ts +4 -0
- package/iso-systems.js +389 -0
- package/js/iso-core/compile-schema.js +22 -0
- package/js/iso-core/depth.js +55 -0
- package/js/iso-core/errors.js +65 -0
- package/js/iso-core/glyphs.js +100 -0
- package/js/iso-core/index.js +55 -0
- package/js/iso-core/kernel.js +158 -0
- package/js/iso-core/metrics.json +1 -0
- package/js/iso-core/package.json +6 -0
- package/js/iso-core/parse.js +79 -0
- package/js/iso-core/schema-errors.js +170 -0
- package/js/iso-core/shims/crypto.js +125 -0
- package/js/iso-core/shims/path.js +49 -0
- package/js/iso-core/svg-dom.js +144 -0
- package/js/iso-core/theme.js +48 -0
- package/js/iso-core/vdom.js +48 -0
- package/js/iso-editor/adapter.js +0 -0
- package/js/iso-editor/clipboard.js +152 -0
- package/js/iso-editor/commands.js +173 -0
- package/js/iso-editor/complete.js +55 -0
- package/js/iso-editor/doc.js +182 -0
- package/js/iso-editor/index.js +105 -0
- package/js/iso-editor/model.js +210 -0
- package/js/iso-editor/outline.js +111 -0
- package/js/iso-editor/package.json +6 -0
- package/js/iso-editor/path.js +19 -0
- package/js/iso-editor/providers.js +96 -0
- package/js/iso-editor/schema-nav.js +117 -0
- package/js/iso-editor/splice.js +443 -0
- package/js/iso-editor/storage-keys.js +6 -0
- package/js/iso-editor/ui/actions.js +116 -0
- package/js/iso-editor/ui/canvas-layer.js +0 -0
- package/js/iso-editor/ui/canvas.js +1403 -0
- package/js/iso-editor/ui/clip.js +133 -0
- package/js/iso-editor/ui/dialog.js +26 -0
- package/js/iso-editor/ui/flat-canvas.js +54 -0
- package/js/iso-editor/ui/icons.js +15 -0
- package/js/iso-editor/ui/keys.js +26 -0
- package/js/iso-editor/ui/later.js +28 -0
- package/js/iso-editor/ui/layer.js +11 -0
- package/js/iso-editor/ui/menu.js +105 -0
- package/js/iso-editor/ui/monaco-entry.js +2 -0
- package/js/iso-editor/ui/mount-kit.js +0 -0
- package/js/iso-editor/ui/mount.js +767 -0
- package/js/iso-editor/ui/pane.js +0 -0
- package/js/iso-editor/ui/part.js +0 -0
- package/js/iso-editor/ui/plain-icons.js +34 -0
- package/js/iso-editor/ui/props.js +314 -0
- package/js/iso-editor/ui/scope-css.js +81 -0
- package/js/iso-editor/ui/setup.js +149 -0
- package/js/iso-editor/ui/text.js +323 -0
- package/js/iso-editor/ui/tree.js +728 -0
- package/js/iso-editor/validate.js +33 -0
- package/js/iso-editor/window/protocol.js +8 -0
- package/js/iso-objects/assemble.js +43 -0
- package/js/iso-objects/assets.js +88 -0
- package/js/iso-objects/board.js +162 -0
- package/js/iso-objects/compile.js +60 -0
- package/js/iso-objects/css.js +154 -0
- package/js/iso-objects/flat.js +696 -0
- package/js/iso-objects/focus.js +16 -0
- package/js/iso-objects/geometry.js +76 -0
- package/js/iso-objects/index.js +93 -0
- package/js/iso-objects/kinds.js +12 -0
- package/js/iso-objects/labels.js +325 -0
- package/js/iso-objects/package.json +6 -0
- package/js/iso-objects/place.js +347 -0
- package/js/iso-objects/route.js +461 -0
- package/js/iso-objects/scene.js +350 -0
- package/js/iso-objects/steps.js +246 -0
- package/js/iso-objects/types.js +0 -0
- package/js/iso-systems/catalog.js +42 -0
- package/js/iso-systems/compile.js +34 -0
- package/js/iso-systems/css.js +8 -0
- package/js/iso-systems/index.js +16 -0
- package/js/iso-systems/nodes.js +124 -0
- package/js/iso-systems/package.json +6 -0
- package/js/iso-systems/schema.json +311 -0
- package/js/iso-systems/validate.js +35 -0
- package/js/iso-viewer/bundle.js +20 -0
- package/js/iso-viewer/card-motion.js +228 -0
- package/js/iso-viewer/dom.js +14 -0
- package/js/iso-viewer/dual-view.js +212 -0
- package/js/iso-viewer/flat-view.js +124 -0
- package/js/iso-viewer/history.js +990 -0
- package/js/iso-viewer/index.js +98 -0
- package/js/iso-viewer/morph.js +192 -0
- package/js/iso-viewer/overlay.js +199 -0
- package/js/iso-viewer/package.json +6 -0
- package/js/iso-viewer/page.js +138 -0
- package/js/iso-viewer/player.js +409 -0
- package/js/iso-viewer/still.js +81 -0
- package/js/iso-viewer/timeline-contract.js +14 -0
- package/js/iso-viewer/timeline-engine.js +475 -0
- package/js/iso-viewer/timeline-export.js +36 -0
- package/js/iso-viewer/timeline-scale.js +116 -0
- package/js/iso-viewer/timeline-scope.js +58 -0
- package/js/iso-viewer/timeline-search.js +216 -0
- package/js/iso-viewer/timeline-time.js +55 -0
- package/js/iso-viewer/view-css.js +68 -0
- package/js/iso-viewer/viewport.js +177 -0
- package/package.json +511 -4
- package/src/iso-core/compile-schema.ts +23 -0
- package/src/iso-core/depth.ts +56 -0
- package/src/iso-core/errors.ts +73 -0
- package/src/iso-core/glyphs.ts +108 -0
- package/src/iso-core/index.ts +27 -0
- package/src/iso-core/kernel.ts +163 -0
- package/src/iso-core/metrics.json +1 -0
- package/src/iso-core/package.json +6 -0
- package/src/iso-core/parse.ts +91 -0
- package/src/iso-core/schema-errors.ts +163 -0
- package/src/iso-core/shims/crypto.ts +37 -0
- package/src/iso-core/shims/path.ts +24 -0
- package/src/iso-core/svg-dom.ts +103 -0
- package/src/iso-core/theme.ts +64 -0
- package/src/iso-core/vdom.ts +41 -0
- package/src/iso-editor/adapter.ts +147 -0
- package/src/iso-editor/clipboard.ts +163 -0
- package/src/iso-editor/commands.ts +191 -0
- package/src/iso-editor/complete.ts +73 -0
- package/src/iso-editor/doc.ts +207 -0
- package/src/iso-editor/index.ts +67 -0
- package/src/iso-editor/model.ts +234 -0
- package/src/iso-editor/outline.ts +126 -0
- package/src/iso-editor/package.json +6 -0
- package/src/iso-editor/path.ts +18 -0
- package/src/iso-editor/providers.ts +113 -0
- package/src/iso-editor/schema-nav.ts +129 -0
- package/src/iso-editor/splice.ts +477 -0
- package/src/iso-editor/storage-keys.ts +6 -0
- package/src/iso-editor/ui/actions.ts +119 -0
- package/src/iso-editor/ui/app.css +230 -0
- package/src/iso-editor/ui/canvas-layer.ts +56 -0
- package/src/iso-editor/ui/canvas.ts +1227 -0
- package/src/iso-editor/ui/clip.ts +97 -0
- package/src/iso-editor/ui/dialog.ts +25 -0
- package/src/iso-editor/ui/flat-canvas.ts +51 -0
- package/src/iso-editor/ui/icons.ts +21 -0
- package/src/iso-editor/ui/keys.ts +30 -0
- package/src/iso-editor/ui/later.ts +22 -0
- package/src/iso-editor/ui/layer.ts +7 -0
- package/src/iso-editor/ui/marks.css +39 -0
- package/src/iso-editor/ui/menu.ts +67 -0
- package/src/iso-editor/ui/monaco-entry.ts +6 -0
- package/src/iso-editor/ui/mount-kit.ts +35 -0
- package/src/iso-editor/ui/mount.ts +684 -0
- package/src/iso-editor/ui/pane.ts +45 -0
- package/src/iso-editor/ui/part.ts +45 -0
- package/src/iso-editor/ui/plain-icons.ts +83 -0
- package/src/iso-editor/ui/props.ts +347 -0
- package/src/iso-editor/ui/scope-css.ts +65 -0
- package/src/iso-editor/ui/setup.ts +153 -0
- package/src/iso-editor/ui/skin.css +181 -0
- package/src/iso-editor/ui/text.ts +262 -0
- package/src/iso-editor/ui/tree.ts +657 -0
- package/src/iso-editor/validate.ts +62 -0
- package/src/iso-editor/window/protocol.ts +33 -0
- package/src/iso-objects/assemble.ts +57 -0
- package/src/iso-objects/assets.ts +122 -0
- package/src/iso-objects/board.ts +169 -0
- package/src/iso-objects/compile.ts +76 -0
- package/src/iso-objects/css.ts +163 -0
- package/src/iso-objects/flat.ts +653 -0
- package/src/iso-objects/focus.ts +14 -0
- package/src/iso-objects/geometry.ts +86 -0
- package/src/iso-objects/index.ts +33 -0
- package/src/iso-objects/kinds.ts +56 -0
- package/src/iso-objects/labels.ts +310 -0
- package/src/iso-objects/package.json +6 -0
- package/src/iso-objects/place.ts +318 -0
- package/src/iso-objects/route.ts +444 -0
- package/src/iso-objects/scene.ts +376 -0
- package/src/iso-objects/steps.ts +234 -0
- package/src/iso-objects/types.ts +68 -0
- package/src/iso-systems/catalog.ts +31 -0
- package/src/iso-systems/compile.ts +39 -0
- package/src/iso-systems/css.ts +9 -0
- package/src/iso-systems/index.ts +12 -0
- package/src/iso-systems/nodes.ts +126 -0
- package/src/iso-systems/package.json +6 -0
- package/src/iso-systems/schema.json +311 -0
- package/src/iso-systems/validate.ts +34 -0
- package/src/iso-viewer/bundle.ts +15 -0
- package/src/iso-viewer/card-motion.ts +237 -0
- package/src/iso-viewer/dom.ts +13 -0
- package/src/iso-viewer/dual-view.ts +212 -0
- package/src/iso-viewer/flat-view.ts +127 -0
- package/src/iso-viewer/history.ts +781 -0
- package/src/iso-viewer/index.ts +40 -0
- package/src/iso-viewer/morph.ts +191 -0
- package/src/iso-viewer/overlay.ts +212 -0
- package/src/iso-viewer/package.json +6 -0
- package/src/iso-viewer/page.ts +150 -0
- package/src/iso-viewer/player.ts +321 -0
- package/src/iso-viewer/still.ts +74 -0
- package/src/iso-viewer/timeline-contract.ts +342 -0
- package/src/iso-viewer/timeline-engine.ts +420 -0
- package/src/iso-viewer/timeline-export.ts +31 -0
- package/src/iso-viewer/timeline-scale.ts +129 -0
- package/src/iso-viewer/timeline-scope.ts +56 -0
- package/src/iso-viewer/timeline-search.ts +198 -0
- package/src/iso-viewer/timeline-time.ts +54 -0
- package/src/iso-viewer/view-css.ts +59 -0
- package/src/iso-viewer/viewport.ts +142 -0
- package/types/iso-core/compile-schema.d.ts +11 -0
- package/types/iso-core/depth.d.ts +6 -0
- package/types/iso-core/errors.d.ts +24 -0
- package/types/iso-core/glyphs.d.ts +19 -0
- package/types/iso-core/index.d.ts +17 -0
- package/types/iso-core/kernel.d.ts +130 -0
- package/types/iso-core/metrics.json +1 -0
- package/types/iso-core/parse.d.ts +18 -0
- package/types/iso-core/schema-errors.d.ts +14 -0
- package/types/iso-core/shims/crypto.d.ts +9 -0
- package/types/iso-core/svg-dom.d.ts +15 -0
- package/types/iso-core/theme.d.ts +38 -0
- package/types/iso-core/vdom.d.ts +26 -0
- package/types/iso-editor/adapter.d.ts +178 -0
- package/types/iso-editor/clipboard.d.ts +23 -0
- package/types/iso-editor/commands.d.ts +32 -0
- package/types/iso-editor/complete.d.ts +25 -0
- package/types/iso-editor/doc.d.ts +50 -0
- package/types/iso-editor/index.d.ts +57 -0
- package/types/iso-editor/model.d.ts +96 -0
- package/types/iso-editor/outline.d.ts +28 -0
- package/types/iso-editor/path.d.ts +7 -0
- package/types/iso-editor/providers.d.ts +43 -0
- package/types/iso-editor/schema-nav.d.ts +34 -0
- package/types/iso-editor/splice.d.ts +53 -0
- package/types/iso-editor/storage-keys.d.ts +5 -0
- package/types/iso-editor/ui/actions.d.ts +23 -0
- package/types/iso-editor/ui/canvas-layer.d.ts +65 -0
- package/types/iso-editor/ui/canvas.d.ts +307 -0
- package/types/iso-editor/ui/clip.d.ts +14 -0
- package/types/iso-editor/ui/dialog.d.ts +7 -0
- package/types/iso-editor/ui/flat-canvas.d.ts +2 -0
- package/types/iso-editor/ui/icons.d.ts +5 -0
- package/types/iso-editor/ui/keys.d.ts +7 -0
- package/types/iso-editor/ui/later.d.ts +12 -0
- package/types/iso-editor/ui/layer.d.ts +2 -0
- package/types/iso-editor/ui/menu.d.ts +21 -0
- package/types/iso-editor/ui/mount-kit.d.ts +31 -0
- package/types/iso-editor/ui/mount.d.ts +146 -0
- package/types/iso-editor/ui/pane.d.ts +60 -0
- package/types/iso-editor/ui/part.d.ts +40 -0
- package/types/iso-editor/ui/plain-icons.d.ts +10 -0
- package/types/iso-editor/ui/props.d.ts +57 -0
- package/types/iso-editor/ui/scope-css.d.ts +5 -0
- package/types/iso-editor/ui/setup.d.ts +49 -0
- package/types/iso-editor/ui/text.d.ts +19 -0
- package/types/iso-editor/ui/tree.d.ts +100 -0
- package/types/iso-editor/validate.d.ts +36 -0
- package/types/iso-editor/window/protocol.d.ts +60 -0
- package/types/iso-objects/assemble.d.ts +35 -0
- package/types/iso-objects/assets.d.ts +49 -0
- package/types/iso-objects/board.d.ts +36 -0
- package/types/iso-objects/compile.d.ts +35 -0
- package/types/iso-objects/css.d.ts +16 -0
- package/types/iso-objects/flat.d.ts +130 -0
- package/types/iso-objects/focus.d.ts +1 -0
- package/types/iso-objects/geometry.d.ts +59 -0
- package/types/iso-objects/index.d.ts +26 -0
- package/types/iso-objects/kinds.d.ts +53 -0
- package/types/iso-objects/labels.d.ts +92 -0
- package/types/iso-objects/place.d.ts +25 -0
- package/types/iso-objects/route.d.ts +67 -0
- package/types/iso-objects/scene.d.ts +63 -0
- package/types/iso-objects/steps.d.ts +90 -0
- package/types/iso-objects/types.d.ts +140 -0
- package/types/iso-systems/catalog.d.ts +4 -0
- package/types/iso-systems/compile.d.ts +6 -0
- package/types/iso-systems/css.d.ts +3 -0
- package/types/iso-systems/index.d.ts +5 -0
- package/types/iso-systems/nodes.d.ts +3 -0
- package/types/iso-viewer/card-motion.d.ts +56 -0
- package/types/iso-viewer/dom.d.ts +1 -0
- package/types/iso-viewer/dual-view.d.ts +44 -0
- package/types/iso-viewer/flat-view.d.ts +25 -0
- package/types/iso-viewer/history.d.ts +91 -0
- package/types/iso-viewer/index.d.ts +31 -0
- package/types/iso-viewer/morph.d.ts +28 -0
- package/types/iso-viewer/overlay.d.ts +135 -0
- package/types/iso-viewer/page.d.ts +13 -0
- package/types/iso-viewer/still.d.ts +26 -0
- package/types/iso-viewer/timeline-contract.d.ts +345 -0
- package/types/iso-viewer/timeline-engine.d.ts +20 -0
- package/types/iso-viewer/timeline-export.d.ts +5 -0
- package/types/iso-viewer/timeline-scale.d.ts +44 -0
- package/types/iso-viewer/timeline-scope.d.ts +33 -0
- package/types/iso-viewer/timeline-search.d.ts +52 -0
- package/types/iso-viewer/timeline-time.d.ts +8 -0
- package/types/iso-viewer/view-css.d.ts +7 -0
- 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
|
+
};
|