@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,409 @@
|
|
|
1
|
+
import { focusView } from "../iso-objects/focus.js";
|
|
2
|
+
const NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
const TRAVEL = 1150;
|
|
4
|
+
const EASE_IN = "cubic-bezier(.16,.84,.3,1)";
|
|
5
|
+
function svgEl(tag, attrs, parent) {
|
|
6
|
+
const e = document.createElementNS(NS, tag);
|
|
7
|
+
for (const k in attrs) e.setAttribute(k, String(attrs[k]));
|
|
8
|
+
parent.appendChild(e);
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
const ease = (f) => f < 0.5 ? 2 * f * f : 1 - Math.pow(-2 * f + 2, 2) / 2;
|
|
12
|
+
function init() {
|
|
13
|
+
const dataEl = document.getElementById("diagram-steps");
|
|
14
|
+
if (!dataEl) return;
|
|
15
|
+
const data = JSON.parse(dataEl.textContent || "{}");
|
|
16
|
+
const hash = location.hash;
|
|
17
|
+
const still = /still/.test(hash);
|
|
18
|
+
const reduceMedia = matchMedia("(prefers-reduced-motion: reduce)").matches && !/motion/.test(hash);
|
|
19
|
+
const reduce = still || reduceMedia;
|
|
20
|
+
const frozenT = Math.max(0, Math.min(1, Number((/[#&]t=([\d.]+)/.exec(hash) || [])[1] ?? 0.6)));
|
|
21
|
+
const wantScene = (/[#&]scene=([\w-]+)/.exec(hash) || [])[1];
|
|
22
|
+
const wantStep = Number((/[#&]step=?(\d+)/.exec(hash) || [])[1] || 0);
|
|
23
|
+
const wantGrid = /[#&]grid\b/.test(hash);
|
|
24
|
+
const wantAssemble = /[#&]assemble\b/.test(hash);
|
|
25
|
+
const assembleAt = (/[#&]at=(\d+)/.exec(hash) || [])[1];
|
|
26
|
+
if (still) document.documentElement.classList.add("still");
|
|
27
|
+
if (wantScene && !still) document.getElementById("scene-" + wantScene)?.scrollIntoView({ block: "start" });
|
|
28
|
+
const runners = [];
|
|
29
|
+
for (const sd of data.scenes) {
|
|
30
|
+
const sec = document.getElementById("scene-" + sd.id);
|
|
31
|
+
if (sec) runners.push(makeRunner(sec, sd));
|
|
32
|
+
}
|
|
33
|
+
function makeRunner(sec, sd) {
|
|
34
|
+
const STEPS = sd.steps, N = STEPS.length;
|
|
35
|
+
const svg = sec.querySelector("svg"), fig = sec.querySelector(".figure");
|
|
36
|
+
const anim = svg.querySelector(".g-anim");
|
|
37
|
+
const q = (s) => sec.querySelector(s);
|
|
38
|
+
const num = q(".cap-h .num"), hEl = q(".cap-h .h"), cnt = q(".cap-h .cnt");
|
|
39
|
+
const capT = q(".cap-t"), capC = q(".cap-c"), prog = q(".prog i"), dots = q(".dots");
|
|
40
|
+
const capBox = q(".cap"), playBtn = q("[data-a=play]");
|
|
41
|
+
const gridBtn = q("[data-a=grid]"), asmBtn = q("[data-a=assemble]");
|
|
42
|
+
const hlEls = [...svg.querySelectorAll("[data-hl]")];
|
|
43
|
+
const stepEls = [...svg.querySelectorAll("[data-step]")];
|
|
44
|
+
const idEls = [...svg.querySelectorAll("[data-id]")];
|
|
45
|
+
const visEls = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const e of idEls) if (sd.vis[e.dataset.id]) {
|
|
47
|
+
const l = visEls.get(e.dataset.id) ?? [];
|
|
48
|
+
l.push(e);
|
|
49
|
+
visEls.set(e.dataset.id, l);
|
|
50
|
+
}
|
|
51
|
+
for (const e of hlEls) {
|
|
52
|
+
const id = e.dataset.hl;
|
|
53
|
+
if (sd.vis[id] && !e.dataset.id) {
|
|
54
|
+
const l = visEls.get(id) ?? [];
|
|
55
|
+
l.push(e);
|
|
56
|
+
visEls.set(id, l);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const flowPath = (id) => svg.querySelector(`[data-hl="${CSS.escape(id)}"] path.flow`);
|
|
60
|
+
if (sd.dim === "all") svg.classList.add("dim-all");
|
|
61
|
+
let cur = 0, playing = false, userPaused = false, active = false, timer = 0, raf = 0, groups = 0, t0 = 0;
|
|
62
|
+
let assembling = false, assembled = false, animations = [];
|
|
63
|
+
let tokens = [];
|
|
64
|
+
const setGrid = (on) => {
|
|
65
|
+
svg.classList.toggle("show-grid", on);
|
|
66
|
+
gridBtn?.setAttribute("aria-pressed", String(on));
|
|
67
|
+
};
|
|
68
|
+
setGrid(sd.grid || wantGrid);
|
|
69
|
+
gridBtn?.addEventListener("click", () => setGrid(!svg.classList.contains("show-grid")));
|
|
70
|
+
STEPS.forEach((s, i) => {
|
|
71
|
+
const b = document.createElement("button");
|
|
72
|
+
b.className = "dot";
|
|
73
|
+
b.type = "button";
|
|
74
|
+
b.setAttribute("aria-label", `Step ${s.num}: ${s.heading}`);
|
|
75
|
+
b.addEventListener("click", () => {
|
|
76
|
+
userPause();
|
|
77
|
+
finishAssemble();
|
|
78
|
+
show(i);
|
|
79
|
+
});
|
|
80
|
+
dots?.appendChild(b);
|
|
81
|
+
});
|
|
82
|
+
function clearAnim() {
|
|
83
|
+
anim.textContent = "";
|
|
84
|
+
tokens = [];
|
|
85
|
+
if (raf) cancelAnimationFrame(raf);
|
|
86
|
+
raf = 0;
|
|
87
|
+
}
|
|
88
|
+
function tick(now) {
|
|
89
|
+
const per = TRAVEL * groups + 700, tt = (now - t0) % per;
|
|
90
|
+
for (const tk of tokens) {
|
|
91
|
+
const f = reduce ? frozenT : Math.max(0, Math.min(1, (tt - tk.gi * TRAVEL) / TRAVEL));
|
|
92
|
+
let e = ease(f);
|
|
93
|
+
if (tk.stop) e = f < 0.7 ? f / 0.7 : 1 - (f - 0.7) / 0.3 * 0.25;
|
|
94
|
+
const p = tk.path.getPointAtLength(Math.max(0, Math.min(1, e)) * tk.len);
|
|
95
|
+
tk.c.setAttribute("cx", String(p.x));
|
|
96
|
+
tk.c.setAttribute("cy", String(p.y));
|
|
97
|
+
tk.c.style.opacity = reduce ? "1" : f <= 0 || f >= 1 ? "0" : "1";
|
|
98
|
+
}
|
|
99
|
+
if (!reduce && active) raf = requestAnimationFrame(tick);
|
|
100
|
+
}
|
|
101
|
+
const FULL = svg.getAttribute("viewBox").split(/\s+/).map(Number);
|
|
102
|
+
let view = FULL.slice(), zoomTimer = 0;
|
|
103
|
+
const viewFor = (s) => focusView(FULL, s.focus);
|
|
104
|
+
function zoomTo(target) {
|
|
105
|
+
clearTimeout(zoomTimer);
|
|
106
|
+
if (target.every((v, k) => Math.abs(v - view[k]) < 0.5)) return;
|
|
107
|
+
const from = view.slice(), t0z = performance.now(), D = reduce ? 0 : 900;
|
|
108
|
+
const step = () => {
|
|
109
|
+
const f = D ? Math.min(1, (performance.now() - t0z) / D) : 1, e = ease(f);
|
|
110
|
+
view = from.map((v, k) => v + (target[k] - v) * e);
|
|
111
|
+
svg.setAttribute("viewBox", view.map((v) => v.toFixed(1)).join(" "));
|
|
112
|
+
if (f < 1) zoomTimer = window.setTimeout(step, 16);
|
|
113
|
+
};
|
|
114
|
+
step();
|
|
115
|
+
}
|
|
116
|
+
function show(i) {
|
|
117
|
+
if (!N) return;
|
|
118
|
+
clearAnim();
|
|
119
|
+
cur = i;
|
|
120
|
+
const s = STEPS[i], n = s.n;
|
|
121
|
+
zoomTo(svg.classList.contains("all") ? FULL : viewFor(s));
|
|
122
|
+
const lit = new Set(s.lit);
|
|
123
|
+
svg.classList.add("focus");
|
|
124
|
+
for (const e of hlEls) e.classList.toggle("hl", e.dataset.hl.split(" ").some((x) => lit.has(x)));
|
|
125
|
+
if (sd.dim === "all") {
|
|
126
|
+
for (const e of idEls) if (e.hasAttribute("data-dim")) e.classList.toggle("hl", lit.has(e.dataset.id));
|
|
127
|
+
}
|
|
128
|
+
for (const e of stepEls) e.classList.toggle("on", e.dataset.step === String(n));
|
|
129
|
+
svg.querySelectorAll("[data-badge]").forEach((b) => b.classList.toggle("on", b.dataset.badge === String(n)));
|
|
130
|
+
for (const [id, els] of visEls) {
|
|
131
|
+
const v = sd.vis[id][i];
|
|
132
|
+
for (const e of els) e.classList.toggle("pre", !v);
|
|
133
|
+
}
|
|
134
|
+
for (const [x, y, rx, ry] of s.pulses) svgEl("ellipse", { cx: x, cy: y, rx, ry, class: "pulse", style: `stroke:${s.color}` }, anim);
|
|
135
|
+
groups = s.phases.length;
|
|
136
|
+
s.phases.forEach((ph, gi) => ph.forEach((tk) => {
|
|
137
|
+
const path = flowPath(tk.route);
|
|
138
|
+
if (!path) return;
|
|
139
|
+
tokens.push({ path, len: path.getTotalLength(), gi, stop: tk.kind === "blocked", c: svgEl("circle", { r: 7, class: "tok", style: `fill:${tk.color}` }, anim) });
|
|
140
|
+
}));
|
|
141
|
+
t0 = performance.now();
|
|
142
|
+
tick(t0);
|
|
143
|
+
if (!reduce && active && !raf) raf = requestAnimationFrame(tick);
|
|
144
|
+
num.textContent = String(s.num);
|
|
145
|
+
num.style.background = s.color;
|
|
146
|
+
hEl.textContent = s.heading;
|
|
147
|
+
cnt.textContent = `${i + 1} / ${N}`;
|
|
148
|
+
capT.innerHTML = s.caption;
|
|
149
|
+
capC.textContent = s.command;
|
|
150
|
+
prog.style.setProperty("--c", s.color);
|
|
151
|
+
[...dots.children].forEach((d, j) => {
|
|
152
|
+
d.classList.toggle("on", j === i);
|
|
153
|
+
d.classList.toggle("done", j < i);
|
|
154
|
+
});
|
|
155
|
+
restartProg();
|
|
156
|
+
}
|
|
157
|
+
function restartProg() {
|
|
158
|
+
if (!prog) return;
|
|
159
|
+
prog.style.transition = "none";
|
|
160
|
+
prog.style.width = playing ? "0%" : (cur + 1) / N * 100 + "%";
|
|
161
|
+
if (playing) {
|
|
162
|
+
void prog.offsetWidth;
|
|
163
|
+
prog.style.transition = `width ${STEPS[cur].duration}ms linear`;
|
|
164
|
+
prog.style.width = "100%";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function schedule() {
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
if (!playing) return;
|
|
170
|
+
timer = window.setTimeout(() => {
|
|
171
|
+
if (cur === N - 1 && !sd.loop) {
|
|
172
|
+
stop();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
show((cur + 1) % N);
|
|
176
|
+
schedule();
|
|
177
|
+
}, STEPS[cur].duration);
|
|
178
|
+
}
|
|
179
|
+
function setBtn() {
|
|
180
|
+
if (!playBtn) return;
|
|
181
|
+
playBtn.textContent = playing ? "\u275A\u275A Pause" : "\u25B6 Play";
|
|
182
|
+
playBtn.setAttribute("aria-label", playing ? "Pause" : "Play");
|
|
183
|
+
capBox?.setAttribute("aria-live", playing ? "off" : "polite");
|
|
184
|
+
}
|
|
185
|
+
function play() {
|
|
186
|
+
if (reduce || !N || assembling) return;
|
|
187
|
+
playing = true;
|
|
188
|
+
setBtn();
|
|
189
|
+
restartProg();
|
|
190
|
+
schedule();
|
|
191
|
+
}
|
|
192
|
+
function stop() {
|
|
193
|
+
playing = false;
|
|
194
|
+
clearTimeout(timer);
|
|
195
|
+
setBtn();
|
|
196
|
+
restartProg();
|
|
197
|
+
}
|
|
198
|
+
function userPause() {
|
|
199
|
+
userPaused = true;
|
|
200
|
+
stop();
|
|
201
|
+
}
|
|
202
|
+
const A = sd.assembly;
|
|
203
|
+
const layer = (name) => svg.querySelector(`.g-${name}`);
|
|
204
|
+
function finishAssemble() {
|
|
205
|
+
if (!assembling) return;
|
|
206
|
+
for (const a of animations) a.finish();
|
|
207
|
+
}
|
|
208
|
+
function assemble(freezeAt) {
|
|
209
|
+
for (const a of animations) a.cancel();
|
|
210
|
+
animations = [];
|
|
211
|
+
stop();
|
|
212
|
+
if (N) show(cur);
|
|
213
|
+
clearAnim();
|
|
214
|
+
svg.classList.remove("focus", "pre-assemble", "all");
|
|
215
|
+
assembling = true;
|
|
216
|
+
const run = (el, frames, delay, dur, easing = EASE_IN) => animations.push(el.animate(frames, { delay, duration: dur, easing, fill: "backwards" }));
|
|
217
|
+
const solid = ["base", "blocks", "air"].map(layer).filter(Boolean);
|
|
218
|
+
for (const p of A.pieces) {
|
|
219
|
+
const from = `translate(${p.dx}px, ${p.dy}px)`;
|
|
220
|
+
for (const L of solid) L.querySelectorAll(`[data-id="${CSS.escape(p.id)}"]`).forEach((el) => run(el, [{ transform: from }, { transform: "translate(0px, 0px)" }], p.delay, p.dur));
|
|
221
|
+
}
|
|
222
|
+
for (const r of A.routes) {
|
|
223
|
+
const g = layer("flows")?.querySelector(`[data-hl="${CSS.escape(r.id)}"]`);
|
|
224
|
+
const path = g?.querySelector("path.flow");
|
|
225
|
+
if (!g || !path) continue;
|
|
226
|
+
const len = path.getTotalLength();
|
|
227
|
+
run(g, [{ opacity: 0 }, { opacity: 1 }], r.delay, 80, "linear");
|
|
228
|
+
run(path, [{ strokeDasharray: `${len} ${len}`, strokeDashoffset: len }, { strokeDasharray: `${len} ${len}`, strokeDashoffset: 0 }], r.delay, r.dur, "ease-out");
|
|
229
|
+
}
|
|
230
|
+
for (const name of ["floor", "labels", "badges"]) {
|
|
231
|
+
const L = layer(name);
|
|
232
|
+
if (L) run(L, [{ opacity: 0 }, { opacity: 1 }], A.labels.delay, A.labels.dur, "ease-out");
|
|
233
|
+
}
|
|
234
|
+
if (freezeAt !== void 0) {
|
|
235
|
+
for (const a of animations) {
|
|
236
|
+
a.pause();
|
|
237
|
+
a.currentTime = freezeAt;
|
|
238
|
+
}
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
Promise.all(animations.map((a) => a.finished)).then(() => {
|
|
242
|
+
assembling = false;
|
|
243
|
+
assembled = true;
|
|
244
|
+
animations = [];
|
|
245
|
+
if (N) show(cur);
|
|
246
|
+
if (active && !userPaused) play();
|
|
247
|
+
}, () => {
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
asmBtn?.addEventListener("click", () => {
|
|
251
|
+
userPaused = false;
|
|
252
|
+
assemble();
|
|
253
|
+
});
|
|
254
|
+
function setActive(on) {
|
|
255
|
+
if (on === active) return;
|
|
256
|
+
active = on;
|
|
257
|
+
if (on) {
|
|
258
|
+
if (!reduce) {
|
|
259
|
+
t0 = performance.now();
|
|
260
|
+
raf = requestAnimationFrame(tick);
|
|
261
|
+
}
|
|
262
|
+
if (!userPaused) play();
|
|
263
|
+
} else {
|
|
264
|
+
stop();
|
|
265
|
+
if (raf) cancelAnimationFrame(raf);
|
|
266
|
+
raf = 0;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
playBtn?.addEventListener("click", () => {
|
|
270
|
+
if (playing) userPause();
|
|
271
|
+
else {
|
|
272
|
+
userPaused = false;
|
|
273
|
+
finishAssemble();
|
|
274
|
+
if (cur === N - 1) show(0);
|
|
275
|
+
play();
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
q("[data-a=next]")?.addEventListener("click", () => {
|
|
279
|
+
userPause();
|
|
280
|
+
finishAssemble();
|
|
281
|
+
show(Math.min(N - 1, cur + 1));
|
|
282
|
+
});
|
|
283
|
+
q("[data-a=prev]")?.addEventListener("click", () => {
|
|
284
|
+
userPause();
|
|
285
|
+
finishAssemble();
|
|
286
|
+
show(Math.max(0, cur - 1));
|
|
287
|
+
});
|
|
288
|
+
fig.addEventListener("keydown", (e) => {
|
|
289
|
+
const k = e.key;
|
|
290
|
+
if (!N) return;
|
|
291
|
+
if (k === "ArrowRight") {
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
userPause();
|
|
294
|
+
finishAssemble();
|
|
295
|
+
show(Math.min(N - 1, cur + 1));
|
|
296
|
+
}
|
|
297
|
+
if (k === "ArrowLeft") {
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
userPause();
|
|
300
|
+
finishAssemble();
|
|
301
|
+
show(Math.max(0, cur - 1));
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
svg.querySelectorAll(".badge").forEach((b) => {
|
|
305
|
+
const go = () => {
|
|
306
|
+
userPause();
|
|
307
|
+
finishAssemble();
|
|
308
|
+
show(Number(b.dataset.go) - 1);
|
|
309
|
+
};
|
|
310
|
+
b.addEventListener("click", go);
|
|
311
|
+
b.addEventListener("keydown", (e) => {
|
|
312
|
+
const k = e.key;
|
|
313
|
+
if (k === "Enter" || k === " ") {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
go();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
const forced = wantStep && (!wantScene || wantScene === sd.id) ? Math.min(N, wantStep) - 1 : -1;
|
|
320
|
+
const frozenAssemble = wantAssemble && assembleAt !== void 0 && (!wantScene || wantScene === sd.id);
|
|
321
|
+
if (reduce && forced < 0 && !still && !frozenAssemble) {
|
|
322
|
+
if (N) {
|
|
323
|
+
svg.classList.add("all");
|
|
324
|
+
show(N - 1);
|
|
325
|
+
}
|
|
326
|
+
if (playBtn) {
|
|
327
|
+
playBtn.disabled = true;
|
|
328
|
+
playBtn.textContent = "Motion off";
|
|
329
|
+
}
|
|
330
|
+
if (asmBtn) asmBtn.disabled = true;
|
|
331
|
+
sec.querySelector("details.steps")?.setAttribute("open", "");
|
|
332
|
+
} else {
|
|
333
|
+
if (N) show(forced >= 0 ? forced : 0);
|
|
334
|
+
if (reduce && playBtn) {
|
|
335
|
+
playBtn.disabled = true;
|
|
336
|
+
playBtn.textContent = "Motion off";
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (frozenAssemble) assemble(Number(assembleAt));
|
|
340
|
+
else if ((sd.assemble || wantAssemble) && !reduce && !window.__diagramNoIntro) {
|
|
341
|
+
let check = function() {
|
|
342
|
+
if (enough(fig.getBoundingClientRect())) start();
|
|
343
|
+
};
|
|
344
|
+
svg.classList.add("pre-assemble");
|
|
345
|
+
let io;
|
|
346
|
+
const start = () => {
|
|
347
|
+
io?.disconnect();
|
|
348
|
+
removeEventListener("scroll", check);
|
|
349
|
+
if (!assembled && !assembling) assemble();
|
|
350
|
+
};
|
|
351
|
+
const enough = (r) => {
|
|
352
|
+
const seen = Math.max(0, Math.min(r.bottom, innerHeight) - Math.max(r.top, 0)) / Math.max(1, r.height);
|
|
353
|
+
return seen > 0 && seen >= Math.min(0.3, innerHeight / Math.max(1, r.height) * 0.8);
|
|
354
|
+
};
|
|
355
|
+
if ("IntersectionObserver" in window) {
|
|
356
|
+
io = new IntersectionObserver(
|
|
357
|
+
(es) => {
|
|
358
|
+
for (const e of es) if (e.isIntersecting && enough(e.boundingClientRect)) start();
|
|
359
|
+
},
|
|
360
|
+
{ threshold: [0, 0.05, 0.1, 0.2, 0.3, 0.5] }
|
|
361
|
+
);
|
|
362
|
+
io.observe(fig);
|
|
363
|
+
}
|
|
364
|
+
addEventListener("scroll", check, { passive: true });
|
|
365
|
+
setTimeout(check, 60);
|
|
366
|
+
}
|
|
367
|
+
return { fig, setActive };
|
|
368
|
+
}
|
|
369
|
+
if (!reduce) {
|
|
370
|
+
const ratio = /* @__PURE__ */ new Map();
|
|
371
|
+
const pick = () => {
|
|
372
|
+
let best, br = 0;
|
|
373
|
+
for (const r of runners) {
|
|
374
|
+
const v = ratio.get(r.fig) || 0;
|
|
375
|
+
if (v > br) {
|
|
376
|
+
br = v;
|
|
377
|
+
best = r;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
for (const r of runners) r.setActive(r === best && br >= 0.35);
|
|
381
|
+
};
|
|
382
|
+
const measure = () => {
|
|
383
|
+
for (const r of runners) {
|
|
384
|
+
const b = r.fig.getBoundingClientRect();
|
|
385
|
+
ratio.set(r.fig, Math.max(0, Math.min(b.bottom, innerHeight) - Math.max(b.top, 0)) / Math.max(1, b.height));
|
|
386
|
+
}
|
|
387
|
+
pick();
|
|
388
|
+
};
|
|
389
|
+
if ("IntersectionObserver" in window) {
|
|
390
|
+
const io = new IntersectionObserver((entries) => {
|
|
391
|
+
for (const e of entries) ratio.set(e.target, e.isIntersecting ? e.intersectionRatio : 0);
|
|
392
|
+
pick();
|
|
393
|
+
}, { threshold: [0, 0.2, 0.35, 0.5, 0.7, 0.9, 1] });
|
|
394
|
+
for (const r of runners) io.observe(r.fig);
|
|
395
|
+
}
|
|
396
|
+
let pending = 0;
|
|
397
|
+
addEventListener("scroll", () => {
|
|
398
|
+
if (!pending) pending = window.setTimeout(() => {
|
|
399
|
+
pending = 0;
|
|
400
|
+
measure();
|
|
401
|
+
}, 120);
|
|
402
|
+
}, { passive: true });
|
|
403
|
+
setTimeout(measure, 80);
|
|
404
|
+
} else {
|
|
405
|
+
for (const r of runners) r.setActive(true);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
|
|
409
|
+
else init();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const n = (v) => String(Math.round(v * 100) / 100);
|
|
2
|
+
const node = (name, attrs = {}, ...children) => ({ name, attrs: Object.entries(attrs).map(([k, v]) => [k, typeof v === "number" ? n(v) : v]), children });
|
|
3
|
+
function rewrite(t, pfx) {
|
|
4
|
+
if (typeof t === "string") return t;
|
|
5
|
+
const attrs = t.attrs.map(([k, v]) => {
|
|
6
|
+
if (k === "id") return [k, pfx + v];
|
|
7
|
+
let w = v.replace(/var\(--([a-zA-Z][\w-]*)/g, "var(--iso-$1").replace(/url\(\s*(['"]?)#/g, (_m, q) => `url(${q}#${pfx}`);
|
|
8
|
+
if ((k === "href" || k === "xlink:href") && w.startsWith("#") && !w.startsWith(`#${pfx}`)) w = `#${pfx}${w.slice(1)}`;
|
|
9
|
+
return [k, w];
|
|
10
|
+
});
|
|
11
|
+
return { name: t.name, attrs, children: t.children.map((c) => rewrite(c, pfx)) };
|
|
12
|
+
}
|
|
13
|
+
function prune(t, drop) {
|
|
14
|
+
if (typeof t === "string") return t;
|
|
15
|
+
if (drop(t)) return void 0;
|
|
16
|
+
return { ...t, children: t.children.map((c) => prune(c, drop)).filter((c) => c !== void 0) };
|
|
17
|
+
}
|
|
18
|
+
const cls = (t) => (t.attrs.find((a) => a[0] === "class")?.[1] ?? "").split(/\s+/);
|
|
19
|
+
const attr = (t, k) => t.attrs.find((a) => a[0] === k)?.[1];
|
|
20
|
+
function extent(ts) {
|
|
21
|
+
const xs = [], ys = [];
|
|
22
|
+
const walk = (t) => {
|
|
23
|
+
if (typeof t === "string") return;
|
|
24
|
+
const tr = attr(t, "transform");
|
|
25
|
+
if (tr && /matrix/.test(tr)) return;
|
|
26
|
+
const pts = attr(t, "points");
|
|
27
|
+
if (pts) for (const p of pts.trim().split(/\s+/)) {
|
|
28
|
+
const [x, y] = p.split(",").map(Number);
|
|
29
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
30
|
+
xs.push(x);
|
|
31
|
+
ys.push(y);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (t.name === "rect") {
|
|
35
|
+
const x = Number(attr(t, "x")), y = Number(attr(t, "y")), w = Number(attr(t, "width")), h = Number(attr(t, "height"));
|
|
36
|
+
if ([x, y, w, h].every(Number.isFinite)) {
|
|
37
|
+
xs.push(x, x + w);
|
|
38
|
+
ys.push(y, y + h);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (t.name === "circle") {
|
|
42
|
+
const x = Number(attr(t, "cx")), y = Number(attr(t, "cy")), r = Number(attr(t, "r"));
|
|
43
|
+
if ([x, y, r].every(Number.isFinite)) {
|
|
44
|
+
xs.push(x - r, x + r);
|
|
45
|
+
ys.push(y - r, y + r);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
t.children.forEach(walk);
|
|
49
|
+
};
|
|
50
|
+
ts.forEach(walk);
|
|
51
|
+
if (!xs.length) return void 0;
|
|
52
|
+
const x0 = Math.min(...xs), y0 = Math.min(...ys);
|
|
53
|
+
return { x: x0, y: y0, w: Math.max(...xs) - x0, h: Math.max(...ys) - y0 };
|
|
54
|
+
}
|
|
55
|
+
const unite = (a, b) => {
|
|
56
|
+
if (!b) return a;
|
|
57
|
+
const x0 = Math.min(a.x, b.x), y0 = Math.min(a.y, b.y);
|
|
58
|
+
return { x: x0, y: y0, w: Math.max(a.x + a.w, b.x + b.w) - x0, h: Math.max(a.y + a.h, b.y + b.h) - y0 };
|
|
59
|
+
};
|
|
60
|
+
function fitWithOverlay(drawn, size, paint) {
|
|
61
|
+
const fitK = (b) => Math.min((size.width - size.pad * 2) / b.w, (size.height - size.pad * 2) / b.h);
|
|
62
|
+
let k = fitK(drawn);
|
|
63
|
+
let live = paint(k);
|
|
64
|
+
let box = unite(drawn, extent(live));
|
|
65
|
+
k = fitK(box);
|
|
66
|
+
live = paint(k);
|
|
67
|
+
box = unite(drawn, extent(live));
|
|
68
|
+
k = fitK(box);
|
|
69
|
+
return { k, box, live };
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
attr,
|
|
73
|
+
cls,
|
|
74
|
+
extent,
|
|
75
|
+
fitWithOverlay,
|
|
76
|
+
n,
|
|
77
|
+
node,
|
|
78
|
+
prune,
|
|
79
|
+
rewrite,
|
|
80
|
+
unite
|
|
81
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const TIMELINE_VERSION = 1;
|
|
2
|
+
const SEGMENT_NAME = "(?:[^/:%\\s]|%[0-9A-F]{2})+";
|
|
3
|
+
const SEVERITIES = ["debug", "info", "notice", "warning", "error"];
|
|
4
|
+
const BINS = ["1m", "1h", "1d"];
|
|
5
|
+
const BIN_MS = { "1m": 6e4, "1h": 36e5, "1d": 864e5 };
|
|
6
|
+
const scopePattern = (cat) => `^(?:(?:${cat.kinds.join("|")}):(?:${SEGMENT_NAME})(?:/(?:${cat.kinds.join("|")}):(?:${SEGMENT_NAME}))*)?$`;
|
|
7
|
+
export {
|
|
8
|
+
BINS,
|
|
9
|
+
BIN_MS,
|
|
10
|
+
SEGMENT_NAME,
|
|
11
|
+
SEVERITIES,
|
|
12
|
+
TIMELINE_VERSION,
|
|
13
|
+
scopePattern
|
|
14
|
+
};
|