@entro314labs/iso-engine 0.0.0-stage → 0.5.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -2
  3. package/THIRD_PARTY_NOTICES.md +39 -0
  4. package/dist/engine/anim.js +225 -0
  5. package/dist/engine/behaviors.js +105 -0
  6. package/dist/engine/diagram.js +80 -0
  7. package/dist/engine/draw.js +117 -0
  8. package/dist/engine/export.js +81 -0
  9. package/dist/engine/figure.js +35 -0
  10. package/dist/engine/global.js +4 -0
  11. package/dist/engine/index.d.ts +278 -0
  12. package/dist/engine/index.js +164 -0
  13. package/dist/engine/math.js +190 -0
  14. package/dist/engine/node.js +290 -0
  15. package/dist/engine/paths.js +76 -0
  16. package/dist/engine/prefabs/architecture.js +136 -0
  17. package/dist/engine/prefabs/basics.js +131 -0
  18. package/dist/engine/prefabs/devices.js +295 -0
  19. package/dist/engine/prefabs/icons.js +49 -0
  20. package/dist/engine/prefabs/index.js +12 -0
  21. package/dist/engine/prefabs/logistics.js +156 -0
  22. package/dist/engine/scene.js +466 -0
  23. package/dist/engine/shapes.js +781 -0
  24. package/dist/engine/sort.js +153 -0
  25. package/dist/engine/spec.js +81 -0
  26. package/dist/engine/style.js +87 -0
  27. package/dist/engine.css +1 -0
  28. package/dist/figure.css +93 -0
  29. package/dist/figure.d.ts +22 -0
  30. package/dist/figure.js +73 -0
  31. package/dist/filters.d.ts +9 -0
  32. package/dist/filters.js +22 -0
  33. package/dist/index.d.ts +9 -0
  34. package/dist/index.js +8 -0
  35. package/dist/iso.global.js +7990 -0
  36. package/dist/kernel.d.ts +102 -0
  37. package/dist/kernel.js +172 -0
  38. package/dist/loops.d.ts +49 -0
  39. package/dist/loops.js +64 -0
  40. package/dist/patterns.d.ts +44 -0
  41. package/dist/patterns.js +97 -0
  42. package/dist/theme.css +19 -0
  43. package/dist/types.d.ts +86 -0
  44. package/dist/types.js +1 -0
  45. package/package.json +50 -4
  46. package/skills/iso-engine/SKILL.md +143 -0
  47. package/skills/iso-engine/examples/engine.html +42 -0
  48. package/skills/iso-engine/examples/figure.html +51 -0
  49. package/skills/iso-engine/examples/loop.html +68 -0
  50. package/skills/iso-engine/examples/loop.js +36 -0
  51. package/skills/iso-engine/examples/matcher.js +134 -0
  52. package/skills/iso-engine/examples/spec.html +42 -0
  53. package/skills/iso-engine/references/animation.md +116 -0
  54. package/skills/iso-engine/references/api.md +207 -0
  55. package/skills/iso-engine/references/composition.md +66 -0
  56. package/skills/iso-engine/references/diagrams.md +68 -0
  57. package/skills/iso-engine/references/figures.md +359 -0
  58. package/skills/iso-engine/references/loops.md +126 -0
  59. package/skills/iso-engine/references/prefabs.md +103 -0
  60. package/skills/iso-engine/references/spec.md +66 -0
  61. package/skills/iso-engine/references/style.md +76 -0
  62. package/skills/iso-engine/references/troubleshooting.md +49 -0
  63. package/skills/iso-engine/scripts/build.mjs +35 -0
@@ -0,0 +1,153 @@
1
+ /* Depth sorting for isometric scenes.
2
+ Every item has a world AABB. Two items only need an order when their screen silhouettes
3
+ (hexagons) overlap; then a separating axis tells which one is behind: if A ends where B begins
4
+ on x, y or z, A is behind B (the viewer sits at +x +y +z). Items with no separating axis
5
+ intersect; they fall back to a depth key. A topological sort turns the pairwise constraints
6
+ into a drawing order. Lower `layer` always draws first. */
7
+
8
+ const E = 1e-3;
9
+
10
+ /* Hexagon intervals of an AABB in a projection with z-scale zs:
11
+ h = x − y, u = x − z·zs, v = y − z·zs. */
12
+ export function hexOf(b, zs) {
13
+ return [b[0] - b[4], b[3] - b[1], b[0] - b[5] * zs, b[3] - b[2] * zs, b[1] - b[5] * zs, b[4] - b[2] * zs];
14
+ }
15
+
16
+ export function hexOverlap(h1, h2) {
17
+ return h1[0] < h2[1] - E && h2[0] < h1[1] - E &&
18
+ h1[2] < h2[3] - E && h2[2] < h1[3] - E &&
19
+ h1[4] < h2[5] - E && h2[4] < h1[5] - E;
20
+ }
21
+
22
+ function behind(a, b) {
23
+ return a[3] <= b[0] + E || a[4] <= b[1] + E || a[5] <= b[2] + E;
24
+ }
25
+
26
+ /* −1: a draws before b, 1: after, 0: free. Items: {box, hex, layer, order, key} */
27
+ export function compareItems(a, b) {
28
+ if (a.layer !== b.layer) return a.layer < b.layer ? -1 : 1;
29
+ const ab = behind(a.box, b.box), ba = behind(b.box, a.box);
30
+ if (ab && !ba) return -1;
31
+ if (ba && !ab) return 1;
32
+ if (ab && ba) {
33
+ /* touching on several axes (coplanar decals, flush neighbours): authoring order */
34
+ return a.order <= b.order ? -1 : 1;
35
+ }
36
+ /* intersecting volumes (an object sunk into its support, overlapping props): resolve along
37
+ the axis of least penetration, the way a collision would be separated */
38
+ const A = a.box, B = b.box;
39
+ let best = Infinity, res = 0;
40
+ for (let k = 0; k < 3; k++) {
41
+ const p1 = A[k + 3] - B[k], p2 = B[k + 3] - A[k]; // a behind by p1, or b behind by p2
42
+ const p = Math.min(p1, p2);
43
+ if (p < best - E) { best = p; res = p1 < p2 ? -1 : p2 < p1 ? 1 : 0; }
44
+ }
45
+ if (res) return res;
46
+ if (Math.abs(a.key - b.key) > E) return a.key < b.key ? -1 : 1;
47
+ return a.order <= b.order ? -1 : 1;
48
+ }
49
+
50
+ export function makeItem(node, box, zs, order) {
51
+ const key = box ? (box[0] + box[3]) / 2 + (box[1] + box[4]) / 2 + ((box[2] + box[5]) / 2) * zs : 0;
52
+ return { node, box, hex: box ? hexOf(box, zs) : null, layer: node.layer || 0, order, key };
53
+ }
54
+
55
+ /* Topological depth sort. Returns a new array of items in drawing order. */
56
+ export function depthSort(items) {
57
+ const n = items.length;
58
+ if (n < 2) return items.slice();
59
+ const succ = Array.from({ length: n }, () => []);
60
+ const indeg = new Int32Array(n);
61
+ /* sweep along h to prune pairs */
62
+ const idx = [];
63
+ for (let i = 0; i < n; i++) if (items[i].hex) idx.push(i);
64
+ idx.sort((p, q) => items[p].hex[0] - items[q].hex[0]);
65
+ for (let a = 0; a < idx.length; a++) {
66
+ const i = idx[a], hi = items[i].hex;
67
+ for (let b = a + 1; b < idx.length; b++) {
68
+ const j = idx[b], hj = items[j].hex;
69
+ if (hj[0] >= hi[1] - E) break;
70
+ if (!hexOverlap(hi, hj)) continue;
71
+ const c = compareItems(items[i], items[j]);
72
+ if (c < 0) { succ[i].push(j); indeg[j]++; } else if (c > 0) { succ[j].push(i); indeg[i]++; }
73
+ }
74
+ }
75
+ /* Kahn with a priority (layer, key, order) */
76
+ const pri = (i) => items[i];
77
+ const less = (p, q) => {
78
+ const A = pri(p), B = pri(q);
79
+ if (A.layer !== B.layer) return A.layer < B.layer;
80
+ if (Math.abs(A.key - B.key) > E) return A.key < B.key;
81
+ return A.order < B.order;
82
+ };
83
+ const heap = [];
84
+ const push = (i) => { heap.push(i); let k = heap.length - 1; while (k) { const p = (k - 1) >> 1; if (less(heap[k], heap[p])) { [heap[k], heap[p]] = [heap[p], heap[k]]; k = p; } else break; } };
85
+ const pop = () => {
86
+ const top = heap[0], last = heap.pop();
87
+ if (heap.length) {
88
+ heap[0] = last; let k = 0;
89
+ for (;;) {
90
+ const l = 2 * k + 1, r = l + 1; let m = k;
91
+ if (l < heap.length && less(heap[l], heap[m])) m = l;
92
+ if (r < heap.length && less(heap[r], heap[m])) m = r;
93
+ if (m === k) break;
94
+ [heap[k], heap[m]] = [heap[m], heap[k]]; k = m;
95
+ }
96
+ }
97
+ return top;
98
+ };
99
+ for (let i = 0; i < n; i++) if (!indeg[i]) push(i);
100
+ const out = [], done = new Uint8Array(n);
101
+ while (out.length < n) {
102
+ if (!heap.length) {
103
+ /* cycle: release the remaining item with the lowest priority */
104
+ let best = -1;
105
+ for (let i = 0; i < n; i++) if (!done[i] && (best < 0 || less(i, best))) best = i;
106
+ indeg[best] = 0; push(best);
107
+ }
108
+ const i = pop();
109
+ if (done[i]) continue;
110
+ done[i] = 1; out.push(items[i]);
111
+ for (const j of succ[i]) if (!done[j] && --indeg[j] === 0) push(j);
112
+ }
113
+ return out;
114
+ }
115
+
116
+ /* Place moving items among a fixed sorted list of static items.
117
+ Returns, for each dynamic item, the index of the static item it must follow (−1 = first). */
118
+ export class Placer {
119
+ constructor(statics, cell = 96) {
120
+ this.statics = statics;
121
+ this.cell = cell;
122
+ this.grid = new Map();
123
+ statics.forEach((it, i) => {
124
+ it.index = i;
125
+ if (!it.hex) return;
126
+ this._cells(it.hex, (k) => { let a = this.grid.get(k); if (!a) this.grid.set(k, (a = [])); a.push(it); });
127
+ });
128
+ }
129
+ _cells(h, fn) {
130
+ /* bin on (h, u) intervals: enough to prune */
131
+ const c = this.cell;
132
+ const h0 = Math.floor(h[0] / c), h1 = Math.floor(h[1] / c), u0 = Math.floor(h[2] / c), u1 = Math.floor(h[3] / c);
133
+ for (let i = h0; i <= h1; i++) for (let j = u0; j <= u1; j++) fn(i + ',' + j);
134
+ }
135
+ slot(d) {
136
+ let lo = -1, hi = this.statics.length;
137
+ if (!d.hex) return lo;
138
+ const seen = new Set();
139
+ this._cells(d.hex, (k) => {
140
+ const a = this.grid.get(k);
141
+ if (!a) return;
142
+ for (const s of a) {
143
+ if (seen.has(s)) continue;
144
+ seen.add(s);
145
+ if (!hexOverlap(s.hex, d.hex)) continue;
146
+ const c = compareItems(s, d);
147
+ if (c < 0) { if (s.index > lo) lo = s.index; } else if (c > 0) { if (s.index < hi) hi = s.index; }
148
+ }
149
+ });
150
+ /* after everything behind it; on a conflict (lo ≥ hi) the "behind" constraints win */
151
+ return lo;
152
+ }
153
+ }
@@ -0,0 +1,81 @@
1
+ /* Declarative scenes: Iso.render(spec) builds a scene from plain JSON.
2
+ {
3
+ host: '#app', theme: 'dark', figure: {index, title, hint, status}, padding, angle,
4
+ objects: [ {type: 'box'|'platform'|..., id, ...opts, children: [...] (for type 'group')} ],
5
+ animations: [ {type: 'assemble'|'float'|'travel'|'orbit'|'pulse'|'blink'|'spin'|'drawOn'|'typewriter'|'timeline', target, ...} ],
6
+ interactions: [ {target, hover: 'lift', click: 'power'|'toggle'|{to:{...}}, status: 'text'} ]
7
+ } */
8
+ import { path as P } from './paths.js';
9
+
10
+ export function pathFrom(p) {
11
+ if (!p) return null;
12
+ if (p.points && p.length !== undefined) return p; // already a Path
13
+ if (Array.isArray(p)) return P.polyline(p);
14
+ switch (p.type) {
15
+ case 'circle': return P.circle(p);
16
+ case 'arc': return P.arc(p);
17
+ case 'line': return P.line(p.from, p.to);
18
+ case 'rect': return P.rect(p);
19
+ case 'hop': return P.hop(p.from, p.to, p.height);
20
+ case 'bezier': return P.bezier(...p.points);
21
+ default: return P.polyline(p.points || [], { radius: p.radius, closed: p.closed });
22
+ }
23
+ }
24
+
25
+ function addObjects(parent, list) {
26
+ for (const raw of list || []) {
27
+ const { type, children, ...o } = raw;
28
+ if (type === 'group') { const g = parent.group(o); addObjects(g, children); continue; }
29
+ if (typeof parent[type] !== 'function') { console.warn('Iso.render: unknown object type "' + type + '"'); continue; }
30
+ const n = parent[type](o);
31
+ if (children && n && n.isGroup) addObjects(n, children);
32
+ }
33
+ }
34
+
35
+ export function renderSpec(Iso, spec, hostOverride) {
36
+ const { objects, animations, interactions, host, ...opts } = spec;
37
+ const s = Iso.scene(hostOverride || host, opts);
38
+ addObjects(s.root, objects);
39
+ for (const a of animations || []) {
40
+ const { type, target, ...o } = a;
41
+ if (o.path) o.path = pathFrom(o.path);
42
+ switch (type) {
43
+ case 'assemble': s.assemble(target, o); break;
44
+ case 'float': s.float(target, o); break;
45
+ case 'pulse': s.pulse(target, o); break;
46
+ case 'blink': s.blink(target, o); break;
47
+ case 'spin': s.spin(target, o); break;
48
+ case 'travel': s.travel(target, o.path, o); break;
49
+ case 'orbit': s.orbit(target, o); break;
50
+ case 'drawOn': s.drawOn(target, o); break;
51
+ case 'typewriter': s.typewriter(target, o); break;
52
+ case 'timeline': {
53
+ const tl = s.timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, repeatDelay: o.repeatDelay });
54
+ for (const st of o.steps || []) {
55
+ const m = st.from && st.to ? 'fromTo' : st.from ? 'from' : st.set ? 'set' : 'to';
56
+ const tg = st.target || target;
57
+ if (m === 'fromTo') tl.fromTo(tg, st.from, st.to, st, st.at);
58
+ else if (m === 'set') tl.set(tg, st.set, st.at);
59
+ else tl[m](tg, st.props || st.to || st.from, st, st.at);
60
+ if (st.wait) tl.wait(st.wait);
61
+ }
62
+ break;
63
+ }
64
+ default: console.warn('Iso.render: unknown animation "' + type + '"');
65
+ }
66
+ }
67
+ for (const it of interactions || []) {
68
+ const nodes = s.resolve(it.target);
69
+ if (it.hover === 'lift') s.hoverLift(nodes, { z: it.z ?? 4 });
70
+ for (const n of nodes) {
71
+ if (it.label) n.set('label', it.label);
72
+ if (!it.click) continue;
73
+ n.on('click', () => {
74
+ if (it.click === 'power' && typeof n.power === 'function') n.power();
75
+ else if (it.click === 'toggle') { const on = !n.opts.pressed; n.set('pressed', on); n.set('material', on ? it.onMaterial || 'lit' : it.offMaterial); if (it.status) s.status(on ? it.status.on : it.status.off); }
76
+ else if (typeof it.click === 'object' && it.click.to) s.to(n, it.click.to, it.click);
77
+ });
78
+ }
79
+ }
80
+ return s;
81
+ }
@@ -0,0 +1,87 @@
1
+ /* Theme and materials. Everything a scene paints reads a custom property, so a theme or a
2
+ material is only a set of property values. Derived tones are declared together with the
3
+ base colours (custom properties resolve where they are declared). */
4
+
5
+ /* A theme: base colours + how much of `fg` goes into each tone.
6
+ Dark themes light the top; light themes keep the top closest to paper. */
7
+ export const THEMES = {
8
+ dark: { bg: '#111214', fg: '#ecebe6', top: 6.5, left: 3.2, right: 1.2, bevel: 10, line: 30, soft: 15, faint: 7, strong: 60, text: 50, dark: '#060607', road: 3.2 },
9
+ light: { bg: '#f7f6f2', fg: '#121211', top: 0, left: 4.5, right: 8, bevel: 2.5, line: 42, soft: 20, faint: 9, strong: 72, text: 55, dark: '#d9d7d0', road: 3 },
10
+ paper: { bg: '#efe9dd', fg: '#2a241b', top: 1, left: 6, right: 11, bevel: 3, line: 48, soft: 24, faint: 10, strong: 75, text: 60, dark: '#d6ccb9', road: 4 },
11
+ blueprint: { bg: '#0d2a4a', fg: '#d8ecff', top: 9, left: 5, right: 2.5, bevel: 13, line: 55, soft: 26, faint: 10, strong: 80, text: 70, dark: '#081d35', road: 5 },
12
+ terminal: { bg: '#07110b', fg: '#9dffbf', top: 7, left: 3.5, right: 1.5, bevel: 11, line: 42, soft: 20, faint: 8, strong: 70, text: 60, dark: '#030805', road: 3 },
13
+ };
14
+
15
+ function themeVars(t) {
16
+ const mix = (p, base = 'var(--iso-bg)') => `color-mix(in oklab, var(--iso-fg) ${p}%, ${base})`;
17
+ const a = (p) => `color-mix(in oklab, var(--iso-fg) ${p}%, transparent)`;
18
+ return `--iso-bg:${t.bg};--iso-fg:${t.fg};` + derived(t, mix, a);
19
+ }
20
+ function derived(t, mix, a) {
21
+ return `--iso-top:${mix(t.top)};--iso-left:${mix(t.left)};--iso-right:${mix(t.right)};--iso-bevel:${mix(t.bevel)};` +
22
+ `--iso-line:${a(t.line)};--iso-line-soft:${a(t.soft)};--iso-line-faint:${a(t.faint)};--iso-line-strong:${a(t.strong)};` +
23
+ `--iso-text:${a(t.text)};--iso-ink:${mix(t.strong)};--iso-road:${mix(t.road)};` +
24
+ `--iso-dark:${t.dark};--iso-screen:color-mix(in oklab, ${t.dark} 70%, var(--iso-bg));--iso-screen-on:${mix(t.top + 3)};--iso-key:${mix(t.top + 1)};` +
25
+ `--iso-lit:var(--iso-fg);--iso-glow:${a(55)};--iso-glow-soft:${a(22)};--iso-glass:${a(7)};--iso-glass-edge:${a(t.line)};` +
26
+ `--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);`;
27
+ }
28
+
29
+ /* Materials: overrides of the tone properties, scoped to a node. */
30
+ const M = (top, left, right, bevel, line, soft) =>
31
+ `--iso-top:${top};--iso-left:${left};--iso-right:${right};--iso-bevel:${bevel};` + (line ? `--iso-line:${line};` : '') + (soft ? `--iso-line-soft:${soft};` : '');
32
+ const mixF = (c, p, base = 'var(--iso-bg)') => `color-mix(in oklab, ${c} ${p}%, ${base})`;
33
+
34
+ export const MATERIALS = {
35
+ /* matte: the default (theme tones) */
36
+ lit: M('var(--iso-lit)', mixF('var(--iso-lit)', 82), mixF('var(--iso-lit)', 68), mixF('var(--iso-lit)', 92), mixF('var(--iso-lit)', 70, 'transparent'), mixF('var(--iso-bg)', 30, 'transparent')),
37
+ screen: M('var(--iso-screen)', 'var(--iso-screen)', 'var(--iso-screen)', 'var(--iso-screen)'),
38
+ dark: M(mixF('var(--iso-dark)', 55), mixF('var(--iso-dark)', 70), mixF('var(--iso-dark)', 80), mixF('var(--iso-dark)', 45)),
39
+ glass: M(mixF('var(--iso-fg)', 9, 'transparent'), mixF('var(--iso-fg)', 6, 'transparent'), mixF('var(--iso-fg)', 4, 'transparent'), mixF('var(--iso-fg)', 10, 'transparent'), 'var(--iso-glass-edge)'),
40
+ wire: M('transparent', 'transparent', 'transparent', 'transparent'),
41
+ ghost: M('transparent', 'transparent', 'transparent', 'transparent', mixF('var(--iso-fg)', 12, 'transparent'), mixF('var(--iso-fg)', 7, 'transparent')),
42
+ solid: M('var(--iso-ink)', mixF('var(--iso-ink)', 85), mixF('var(--iso-ink)', 72), 'var(--iso-ink)', mixF('var(--iso-fg)', 75, 'transparent')),
43
+ paper: M(mixF('var(--iso-fg)', 14), mixF('var(--iso-fg)', 9), mixF('var(--iso-fg)', 6), mixF('var(--iso-fg)', 18)),
44
+ accent: M('var(--iso-accent)', mixF('var(--iso-accent)', 78), mixF('var(--iso-accent)', 62), mixF('var(--iso-accent)', 90), mixF('var(--iso-accent)', 70, 'transparent')),
45
+ tint: M(mixF('var(--iso-tint)', 26), mixF('var(--iso-tint)', 17), mixF('var(--iso-tint)', 11), mixF('var(--iso-tint)', 34), mixF('var(--iso-tint)', 60, 'transparent'), mixF('var(--iso-tint)', 32, 'transparent')),
46
+ };
47
+
48
+ export function css() {
49
+ let s = '';
50
+ s += `.iso{${themeVars(THEMES.dark)}--iso-font:ui-monospace,"Geist Mono","SF Mono","JetBrains Mono",Menlo,Consolas,monospace;display:block;width:100%;height:auto;overflow:visible;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}`;
51
+ for (const k in THEMES) s += `.iso.iso-${k}{${themeVars(THEMES[k])}}`;
52
+ /* host tokens (e.g. a design system's --fg/--bg) */
53
+ s += `.iso.iso-inherit{--iso-bg:var(--bg,#111214);--iso-fg:var(--fg,#ecebe6);${derived(THEMES.dark, (p) => `color-mix(in oklab, var(--iso-fg) ${p}%, var(--iso-bg))`, (p) => `color-mix(in oklab, var(--iso-fg) ${p}%, transparent)`)}}`;
54
+ for (const k in MATERIALS) s += `.iso .m-${k}{${MATERIALS[k]}}`;
55
+ s += `.iso path,.iso rect,.iso circle,.iso ellipse,.iso line,.iso polyline{fill:none;stroke:none;stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke}`;
56
+ const fills = { top: 'top', left: 'left', right: 'right', bevel: 'bevel', dark: 'dark', screen: 'screen', 'screen-on': 'screen-on', key: 'key', lit: 'lit', glass: 'glass', ink: 'ink', road: 'road', bg: 'bg', accent: 'accent', soft: 'line-faint' };
57
+ for (const k in fills) s += `.iso .f-${k}{fill:var(--iso-${fills[k]});stroke:var(--iso-${fills[k]});stroke-width:.6}`;
58
+ s += `.iso .f-glass,.iso .m-glass [class^="f-"],.iso .m-wire [class^="f-"],.iso .m-ghost [class^="f-"]{stroke:none}`;
59
+ s += `.iso .f-ink{stroke:none}`;
60
+ s += `.iso .ln{stroke:var(--iso-line);stroke-width:1}.iso .ln-soft{stroke:var(--iso-line-soft);stroke-width:1}.iso .ln-faint{stroke:var(--iso-line-faint);stroke-width:1}.iso .ln-strong{stroke:var(--iso-line-strong);stroke-width:1}`;
61
+ s += `.iso .ln-lit{stroke:var(--iso-lit);stroke-width:1.25}.iso .ln-accent{stroke:var(--iso-accent);stroke-width:1.25}.iso .ln-bold{stroke:var(--iso-line-strong);stroke-width:1.6}`;
62
+ s += `.iso .tx{fill:var(--iso-text);stroke:none;font-family:var(--iso-font);font-weight:400}.iso .tx-label{letter-spacing:.08em;text-transform:uppercase}.iso .tx-lit{fill:var(--iso-lit);stroke:none;font-family:var(--iso-font)}.iso .tx-strong{fill:var(--iso-line-strong);stroke:none;font-family:var(--iso-font)}.iso .tx-on-lit{fill:color-mix(in oklab, var(--iso-bg) 72%, transparent)}`;
63
+ s += `.iso .glow{filter:drop-shadow(0 0 2px var(--iso-glow)) drop-shadow(0 0 9px var(--iso-glow-soft))}`;
64
+ s += `.iso .hit{cursor:pointer;outline:none}.iso .focus-ring{fill:none;stroke:none;pointer-events:none}.iso .hit:focus-visible>.focus-ring{stroke:var(--iso-focus);stroke-width:1.25;stroke-dasharray:3 3}`;
65
+ s += `.iso [data-flow]{stroke-dasharray:3 5}`;
66
+ /* figure frame (caption grammar: index, name, hint, state) */
67
+ s += `.iso-fig{--iso-fig-bg:#151618;--iso-fig-border:rgba(255,255,255,.06);--iso-fig-cap:rgba(236,235,230,.38);--iso-fig-cap-strong:rgba(236,235,230,.62);position:relative;margin:0;border:1px solid var(--iso-fig-border);border-radius:14px;background:var(--iso-fig-bg);padding:64px 32px;overflow:hidden;box-sizing:border-box;font-family:ui-monospace,"Geist Mono","SF Mono",Menlo,monospace}`;
68
+ s += `.iso-fig.iso-light{--iso-fig-bg:#fbfaf7;--iso-fig-border:rgba(0,0,0,.08);--iso-fig-cap:rgba(18,18,17,.45);--iso-fig-cap-strong:rgba(18,18,17,.7)}`;
69
+ s += `.iso-fig.iso-paper{--iso-fig-bg:#f3eee4;--iso-fig-border:rgba(42,36,27,.12);--iso-fig-cap:rgba(42,36,27,.5);--iso-fig-cap-strong:rgba(42,36,27,.75)}`;
70
+ s += `.iso-fig.iso-blueprint{--iso-fig-bg:#0f2f52;--iso-fig-border:rgba(216,236,255,.12);--iso-fig-cap:rgba(216,236,255,.5);--iso-fig-cap-strong:rgba(216,236,255,.8)}`;
71
+ s += `.iso-fig.iso-terminal{--iso-fig-bg:#08140d;--iso-fig-border:rgba(157,255,191,.1);--iso-fig-cap:rgba(157,255,191,.45);--iso-fig-cap-strong:rgba(157,255,191,.75)}`;
72
+ s += `.iso-fig .iso-cap{position:absolute;margin:0;font-size:11px;line-height:1;letter-spacing:.08em;color:var(--iso-fig-cap);pointer-events:none;white-space:nowrap}`;
73
+ s += `.iso-fig .iso-cap-tl{top:22px;left:24px}.iso-fig .iso-cap-tr{top:22px;right:24px;text-transform:uppercase}.iso-fig .iso-cap-bl{bottom:22px;left:24px;text-transform:uppercase}.iso-fig .iso-cap-br{bottom:22px;right:24px;color:var(--iso-fig-cap-strong)}`;
74
+ s += `@media (max-width:520px){.iso-fig{padding:52px 12px}.iso-fig .iso-cap-bl{display:none}}`;
75
+ s += `.iso-stage{position:relative}`;
76
+ return s;
77
+ }
78
+
79
+ let injected = false;
80
+ export function injectCSS(doc = typeof document !== 'undefined' ? document : null) {
81
+ if (!doc || injected || doc.getElementById('iso-engine-css')) { injected = true; return; }
82
+ const el = doc.createElement('style');
83
+ el.id = 'iso-engine-css';
84
+ el.textContent = css();
85
+ doc.head.appendChild(el);
86
+ injected = true;
87
+ }
@@ -0,0 +1 @@
1
+ .iso{--iso-bg:#111214;--iso-fg:#ecebe6;--iso-top:color-mix(in oklab, var(--iso-fg) 6.5%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 1.2%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 10%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 15%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 60%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 50%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 60%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-dark:#060607;--iso-screen:color-mix(in oklab, #060607 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 9.5%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 7.5%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);--iso-font:ui-monospace,"Geist Mono","SF Mono","JetBrains Mono",Menlo,Consolas,monospace;display:block;width:100%;height:auto;overflow:visible;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.iso.iso-dark{--iso-bg:#111214;--iso-fg:#ecebe6;--iso-top:color-mix(in oklab, var(--iso-fg) 6.5%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 1.2%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 10%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 15%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 60%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 50%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 60%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-dark:#060607;--iso-screen:color-mix(in oklab, #060607 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 9.5%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 7.5%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso.iso-light{--iso-bg:#f7f6f2;--iso-fg:#121211;--iso-top:color-mix(in oklab, var(--iso-fg) 0%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 4.5%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 8%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 2.5%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 42%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 20%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 9%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 72%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 72%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 3%, var(--iso-bg));--iso-dark:#d9d7d0;--iso-screen:color-mix(in oklab, #d9d7d0 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 3%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 1%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 42%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso.iso-paper{--iso-bg:#efe9dd;--iso-fg:#2a241b;--iso-top:color-mix(in oklab, var(--iso-fg) 1%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 6%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 11%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 3%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 48%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 24%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 10%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 75%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 60%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 75%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 4%, var(--iso-bg));--iso-dark:#d6ccb9;--iso-screen:color-mix(in oklab, #d6ccb9 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 4%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 2%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 48%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso.iso-blueprint{--iso-bg:#0d2a4a;--iso-fg:#d8ecff;--iso-top:color-mix(in oklab, var(--iso-fg) 9%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 5%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 2.5%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 13%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 26%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 10%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 80%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 70%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 80%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 5%, var(--iso-bg));--iso-dark:#081d35;--iso-screen:color-mix(in oklab, #081d35 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 12%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 10%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso.iso-terminal{--iso-bg:#07110b;--iso-fg:#9dffbf;--iso-top:color-mix(in oklab, var(--iso-fg) 7%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 3.5%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 1.5%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 11%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 42%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 20%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 8%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 70%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 60%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 70%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 3%, var(--iso-bg));--iso-dark:#030805;--iso-screen:color-mix(in oklab, #030805 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 10%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 8%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 42%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso.iso-inherit{--iso-bg:var(--bg,#111214);--iso-fg:var(--fg,#ecebe6);--iso-top:color-mix(in oklab, var(--iso-fg) 6.5%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 1.2%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 10%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 15%, transparent);--iso-line-faint:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-line-strong:color-mix(in oklab, var(--iso-fg) 60%, transparent);--iso-text:color-mix(in oklab, var(--iso-fg) 50%, transparent);--iso-ink:color-mix(in oklab, var(--iso-fg) 60%, var(--iso-bg));--iso-road:color-mix(in oklab, var(--iso-fg) 3.2%, var(--iso-bg));--iso-dark:#060607;--iso-screen:color-mix(in oklab, #060607 70%, var(--iso-bg));--iso-screen-on:color-mix(in oklab, var(--iso-fg) 9.5%, var(--iso-bg));--iso-key:color-mix(in oklab, var(--iso-fg) 7.5%, var(--iso-bg));--iso-lit:var(--iso-fg);--iso-glow:color-mix(in oklab, var(--iso-fg) 55%, transparent);--iso-glow-soft:color-mix(in oklab, var(--iso-fg) 22%, transparent);--iso-glass:color-mix(in oklab, var(--iso-fg) 7%, transparent);--iso-glass-edge:color-mix(in oklab, var(--iso-fg) 30%, transparent);--iso-accent:var(--iso-fg);--iso-focus:var(--iso-fg);}.iso .m-lit{--iso-top:var(--iso-lit);--iso-left:color-mix(in oklab, var(--iso-lit) 82%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-lit) 68%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-lit) 92%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-lit) 70%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-bg) 30%, transparent);}.iso .m-screen{--iso-top:var(--iso-screen);--iso-left:var(--iso-screen);--iso-right:var(--iso-screen);--iso-bevel:var(--iso-screen);}.iso .m-dark{--iso-top:color-mix(in oklab, var(--iso-dark) 55%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-dark) 70%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-dark) 80%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-dark) 45%, var(--iso-bg));}.iso .m-glass{--iso-top:color-mix(in oklab, var(--iso-fg) 9%, transparent);--iso-left:color-mix(in oklab, var(--iso-fg) 6%, transparent);--iso-right:color-mix(in oklab, var(--iso-fg) 4%, transparent);--iso-bevel:color-mix(in oklab, var(--iso-fg) 10%, transparent);--iso-line:var(--iso-glass-edge);}.iso .m-wire{--iso-top:transparent;--iso-left:transparent;--iso-right:transparent;--iso-bevel:transparent;}.iso .m-ghost{--iso-top:transparent;--iso-left:transparent;--iso-right:transparent;--iso-bevel:transparent;--iso-line:color-mix(in oklab, var(--iso-fg) 12%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-fg) 7%, transparent);}.iso .m-solid{--iso-top:var(--iso-ink);--iso-left:color-mix(in oklab, var(--iso-ink) 85%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-ink) 72%, var(--iso-bg));--iso-bevel:var(--iso-ink);--iso-line:color-mix(in oklab, var(--iso-fg) 75%, transparent);}.iso .m-paper{--iso-top:color-mix(in oklab, var(--iso-fg) 14%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-fg) 9%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-fg) 6%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-fg) 18%, var(--iso-bg));}.iso .m-accent{--iso-top:var(--iso-accent);--iso-left:color-mix(in oklab, var(--iso-accent) 78%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-accent) 62%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-accent) 90%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-accent) 70%, transparent);}.iso .m-tint{--iso-top:color-mix(in oklab, var(--iso-tint) 26%, var(--iso-bg));--iso-left:color-mix(in oklab, var(--iso-tint) 17%, var(--iso-bg));--iso-right:color-mix(in oklab, var(--iso-tint) 11%, var(--iso-bg));--iso-bevel:color-mix(in oklab, var(--iso-tint) 34%, var(--iso-bg));--iso-line:color-mix(in oklab, var(--iso-tint) 60%, transparent);--iso-line-soft:color-mix(in oklab, var(--iso-tint) 32%, transparent);}.iso path,.iso rect,.iso circle,.iso ellipse,.iso line,.iso polyline{fill:none;stroke:none;stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke}.iso .f-top{fill:var(--iso-top);stroke:var(--iso-top);stroke-width:.6}.iso .f-left{fill:var(--iso-left);stroke:var(--iso-left);stroke-width:.6}.iso .f-right{fill:var(--iso-right);stroke:var(--iso-right);stroke-width:.6}.iso .f-bevel{fill:var(--iso-bevel);stroke:var(--iso-bevel);stroke-width:.6}.iso .f-dark{fill:var(--iso-dark);stroke:var(--iso-dark);stroke-width:.6}.iso .f-screen{fill:var(--iso-screen);stroke:var(--iso-screen);stroke-width:.6}.iso .f-screen-on{fill:var(--iso-screen-on);stroke:var(--iso-screen-on);stroke-width:.6}.iso .f-key{fill:var(--iso-key);stroke:var(--iso-key);stroke-width:.6}.iso .f-lit{fill:var(--iso-lit);stroke:var(--iso-lit);stroke-width:.6}.iso .f-glass{fill:var(--iso-glass);stroke:var(--iso-glass);stroke-width:.6}.iso .f-ink{fill:var(--iso-ink);stroke:var(--iso-ink);stroke-width:.6}.iso .f-road{fill:var(--iso-road);stroke:var(--iso-road);stroke-width:.6}.iso .f-bg{fill:var(--iso-bg);stroke:var(--iso-bg);stroke-width:.6}.iso .f-accent{fill:var(--iso-accent);stroke:var(--iso-accent);stroke-width:.6}.iso .f-soft{fill:var(--iso-line-faint);stroke:var(--iso-line-faint);stroke-width:.6}.iso .f-glass,.iso .m-glass [class^="f-"],.iso .m-wire [class^="f-"],.iso .m-ghost [class^="f-"]{stroke:none}.iso .f-ink{stroke:none}.iso .ln{stroke:var(--iso-line);stroke-width:1}.iso .ln-soft{stroke:var(--iso-line-soft);stroke-width:1}.iso .ln-faint{stroke:var(--iso-line-faint);stroke-width:1}.iso .ln-strong{stroke:var(--iso-line-strong);stroke-width:1}.iso .ln-lit{stroke:var(--iso-lit);stroke-width:1.25}.iso .ln-accent{stroke:var(--iso-accent);stroke-width:1.25}.iso .ln-bold{stroke:var(--iso-line-strong);stroke-width:1.6}.iso .tx{fill:var(--iso-text);stroke:none;font-family:var(--iso-font);font-weight:400}.iso .tx-label{letter-spacing:.08em;text-transform:uppercase}.iso .tx-lit{fill:var(--iso-lit);stroke:none;font-family:var(--iso-font)}.iso .tx-strong{fill:var(--iso-line-strong);stroke:none;font-family:var(--iso-font)}.iso .tx-on-lit{fill:color-mix(in oklab, var(--iso-bg) 72%, transparent)}.iso .glow{filter:drop-shadow(0 0 2px var(--iso-glow)) drop-shadow(0 0 9px var(--iso-glow-soft))}.iso .hit{cursor:pointer;outline:none}.iso .focus-ring{fill:none;stroke:none;pointer-events:none}.iso .hit:focus-visible>.focus-ring{stroke:var(--iso-focus);stroke-width:1.25;stroke-dasharray:3 3}.iso [data-flow]{stroke-dasharray:3 5}.iso-fig{--iso-fig-bg:#151618;--iso-fig-border:rgba(255,255,255,.06);--iso-fig-cap:rgba(236,235,230,.38);--iso-fig-cap-strong:rgba(236,235,230,.62);position:relative;margin:0;border:1px solid var(--iso-fig-border);border-radius:14px;background:var(--iso-fig-bg);padding:64px 32px;overflow:hidden;box-sizing:border-box;font-family:ui-monospace,"Geist Mono","SF Mono",Menlo,monospace}.iso-fig.iso-light{--iso-fig-bg:#fbfaf7;--iso-fig-border:rgba(0,0,0,.08);--iso-fig-cap:rgba(18,18,17,.45);--iso-fig-cap-strong:rgba(18,18,17,.7)}.iso-fig.iso-paper{--iso-fig-bg:#f3eee4;--iso-fig-border:rgba(42,36,27,.12);--iso-fig-cap:rgba(42,36,27,.5);--iso-fig-cap-strong:rgba(42,36,27,.75)}.iso-fig.iso-blueprint{--iso-fig-bg:#0f2f52;--iso-fig-border:rgba(216,236,255,.12);--iso-fig-cap:rgba(216,236,255,.5);--iso-fig-cap-strong:rgba(216,236,255,.8)}.iso-fig.iso-terminal{--iso-fig-bg:#08140d;--iso-fig-border:rgba(157,255,191,.1);--iso-fig-cap:rgba(157,255,191,.45);--iso-fig-cap-strong:rgba(157,255,191,.75)}.iso-fig .iso-cap{position:absolute;margin:0;font-size:11px;line-height:1;letter-spacing:.08em;color:var(--iso-fig-cap);pointer-events:none;white-space:nowrap}.iso-fig .iso-cap-tl{top:22px;left:24px}.iso-fig .iso-cap-tr{top:22px;right:24px;text-transform:uppercase}.iso-fig .iso-cap-bl{bottom:22px;left:24px;text-transform:uppercase}.iso-fig .iso-cap-br{bottom:22px;right:24px;color:var(--iso-fig-cap-strong)}@media (max-width:520px){.iso-fig{padding:52px 12px}.iso-fig .iso-cap-bl{display:none}}.iso-stage{position:relative}
@@ -0,0 +1,93 @@
1
+ /* Shared figure classes (skills/iso-engine/references/figures.md: classes, glow kit, layers & links). Figure-specific rules live in
2
+ each figure's `css`, scoped under [data-fig="<id>"]. Reads the tokens in theme.css. */
3
+
4
+ /* host and stage: mountFigure marks the host [data-fig] and fills it with the stage. Lit tones derive from the
5
+ accent where the figure sits, so an accent set on any ancestor carries into lit glass and the power haze. */
6
+ [data-fig] { --glass-on:color-mix(in oklab, var(--accent) 16%, var(--glass)); --accent-dim:color-mix(in oklab, var(--accent) 11%, transparent);
7
+ transition:background .5s; }
8
+ [data-fig].powered { background:radial-gradient(ellipse 50% 45% at 50% 52%, var(--accent-dim), transparent 72%); } /* ctx.power(true): warm haze while the figure is on */
9
+ [data-fig] > .stage { display:block; width:100%; height:100%; outline:none; touch-action:manipulation; }
10
+ [data-fig] > .stage:focus-visible { outline:1px dashed var(--edge); outline-offset:4px; border-radius:10px; }
11
+
12
+ .face { fill:var(--body); stroke:var(--line); stroke-width:1; vector-effect:non-scaling-stroke; stroke-linejoin:round; }
13
+ .face.top { fill:var(--deck); }
14
+ .face.glass { fill:var(--glass); }
15
+ .band { stroke:none; } /* cylinder side: fill only, its edges are drawn as lines */
16
+ .edge { stroke:var(--line); stroke-width:1; vector-effect:non-scaling-stroke; }
17
+ .detail { fill:none; stroke:var(--detail); stroke-width:1; vector-effect:non-scaling-stroke; }
18
+ .press { cursor:pointer; transition:transform 60ms ease-out; }
19
+ .press.down { transform:translateY(4px); }
20
+ .press.down .face { stroke:var(--live); }
21
+ .stage text { fill:var(--line); font-family:var(--mono); letter-spacing:.08em; }
22
+ .stage .lcd { fill:var(--live); }
23
+ .stage .lcd.dim { fill:var(--detail); }
24
+
25
+ .deco { pointer-events:none; } /* decoration never steals clicks from parts */
26
+
27
+ /* selection model */
28
+ .part.sel .face, .part.linked .face, .part.hover .face { stroke:var(--live); }
29
+ .part.sel .face.top { fill:var(--live); }
30
+ .stage .part.sel text { fill:var(--body); }
31
+ .part.sel .detail { stroke:var(--body); }
32
+ .part.dim .face { stroke:var(--detail); }
33
+ .stage .part.dim text { fill:var(--detail); }
34
+
35
+ /* connections */
36
+ .trace { fill:none; stroke:var(--detail); stroke-width:1; vector-effect:non-scaling-stroke; }
37
+ .flow { fill:none; stroke:var(--live); stroke-width:1.5; vector-effect:non-scaling-stroke;
38
+ stroke-dasharray:3 9; opacity:0; transition:opacity 150ms; pointer-events:none; }
39
+ .flow.on { opacity:1; animation:iso-flow 900ms linear infinite; }
40
+ .flow.rev { animation-direction:reverse; }
41
+ @keyframes iso-flow { to { stroke-dashoffset:-12; } }
42
+
43
+ /* exploded layers + cutaway */
44
+ .layer { transition:transform 380ms cubic-bezier(.2,.7,.2,1); }
45
+ .cut .face { fill-opacity:0; stroke:var(--detail); }
46
+ .stage .cut text { fill:var(--detail); }
47
+
48
+ /* callouts */
49
+ :is(.hud, #hud) { pointer-events:none; }
50
+ :is(.hud, #hud) .leader { fill:none; stroke:var(--live); stroke-width:1; vector-effect:non-scaling-stroke; }
51
+ :is(.hud, #hud) .dot { fill:var(--live); }
52
+ .stage :is(.hud, #hud) text { fill:var(--live); paint-order:stroke; stroke:var(--panel); stroke-linejoin:round; } /* halo width set per zoom by placeCallouts */
53
+
54
+ @media (prefers-reduced-motion: reduce) {
55
+ .press, .layer { transition:none; }
56
+ .flow.on { animation:none; stroke-dasharray:none; }
57
+ }
58
+
59
+ /* ---- glow kit (adapted from iso-glow; see THIRD_PARTY_NOTICES.md). Only what is live gets the accent, and it
60
+ glows. Kernel figures only (.stage); engine loops have their own glow. Filters: #fx-glow, #fx-soft, #fx-bloom
61
+ (installFilters(), which mountFigure and loopScene call). ---- */
62
+ .stage .glass { fill:var(--glass); transition:fill .3s, stroke .3s; }
63
+ .stage .glass.hot { fill:var(--glass-on); stroke:var(--accent); }
64
+ .stage .glow-halo { fill:var(--accent); opacity:0; transition:opacity .4s; pointer-events:none; }
65
+ .stage .glow-halo.hot { opacity:.24; }
66
+ .stage .led { fill:var(--detail); transition:fill .2s; }
67
+ .stage .led.hot { fill:var(--accent); }
68
+ .stage .wire { fill:none; stroke:var(--line); stroke-width:1; vector-effect:non-scaling-stroke; stroke-linecap:round; stroke-linejoin:round; transition:stroke .4s; }
69
+ .stage .wire.hot { stroke:var(--accent); }
70
+ .stage .wire-under { fill:none; stroke:var(--panel); stroke-width:3.5; stroke-linecap:round; stroke-linejoin:round; }
71
+ .stage .pulse { fill:none; stroke:var(--accent-hi); stroke-width:2.2; stroke-linecap:round; vector-effect:non-scaling-stroke;
72
+ stroke-dasharray:70 1200; stroke-dashoffset:70; opacity:0; pointer-events:none; }
73
+ .stage .pulse.go { animation:iso-pulse .55s linear; }
74
+ @keyframes iso-pulse { 0% { stroke-dashoffset:70; opacity:1; } 90% { opacity:1; } 100% { stroke-dashoffset:-1000; opacity:0; } }
75
+ .stage .press .face { transition:fill .6s ease-out, stroke .6s ease-out; }
76
+ .stage .press.flash .face, .stage .press.latched .face { fill:var(--accent); stroke:var(--accent-hi); transition:none; }
77
+ .stage .press.flash .face.top, .stage .press.latched .face.top { fill:var(--accent-hi); }
78
+ .stage .press.flash { filter:url(#fx-glow); }
79
+ .stage .press.latched { filter:url(#fx-soft); }
80
+ @media (prefers-reduced-motion: reduce) {
81
+ .stage .glass, .stage .glow-halo, .stage .press .face, .stage .wire { transition:none; }
82
+ .stage .pulse.go { animation:none; }
83
+ }
84
+
85
+ /* Engine scenes inside a figure or loop take the page's accent; loops draw on the panel in the live ink. */
86
+ :is([data-fig], [data-loop]) svg.iso { --iso-accent:var(--accent); --iso-lit:var(--accent);
87
+ --iso-glow:color-mix(in oklab, var(--accent) 55%, transparent); --iso-glow-soft:color-mix(in oklab, var(--accent) 22%, transparent); }
88
+ [data-loop] { --bg:var(--panel); --fg:var(--live); }
89
+
90
+ /* Engine scenes (loops): a soft bloom of light behind a lit object. Add a flat shape with class 'glow-halo'
91
+ (e.g. s.add('rect', { class: 'glow-halo', at, size }) or a 'circle') just before the thing it lights. */
92
+ .iso .glow-halo, .iso .glow-halo [class] { fill:var(--iso-accent); stroke:none; } /* [class] outranks the engine's .iso .f-* fills */
93
+ .iso .glow-halo { opacity:.26; filter:url(#fx-bloom); pointer-events:none; }
@@ -0,0 +1,22 @@
1
+ import type { Figure, FigureHandle } from './types.js';
2
+ export interface MountFigureOptions {
3
+ /** Receives the figure's live readout on every interaction. */
4
+ readout?(text: string): void;
5
+ /** Run the figure's `demo()` shortly after mounting, so it opens already alive. */
6
+ demo?: boolean;
7
+ }
8
+ export interface MountedFigure {
9
+ /** The figure's `<svg class="stage">`, a child of the host. */
10
+ readonly stage: SVGSVGElement;
11
+ /** What the figure returned: route page-level keys to `handle.key`. */
12
+ readonly handle: FigureHandle;
13
+ /** Stop the figure: its own `destroy()`, then every timer, frame and haze its context created. Empties the host. */
14
+ destroy(): void;
15
+ }
16
+ /**
17
+ * Mount `f` into `host`: install the glow filters and the figure's scoped css (once per document), mark the host
18
+ * `data-fig="<id>"` so that css applies, put an empty, focusable `<svg class="stage">` in it and call `f.mount` with a
19
+ * context whose timers, frames and power haze are all cleared by `destroy()`. The host should be sized (the stage
20
+ * fills it) and the page should load `@entro314-labs/iso-engine/theme.css` (or define its tokens) and `@entro314-labs/iso-engine/figure.css`.
21
+ */
22
+ export declare function mountFigure(host: HTMLElement, f: Figure, opts?: MountFigureOptions): MountedFigure;
package/dist/figure.js ADDED
@@ -0,0 +1,73 @@
1
+ import { installFilters } from './filters.js';
2
+ const SVGNS = 'http://www.w3.org/2000/svg';
3
+ /**
4
+ * Mount `f` into `host`: install the glow filters and the figure's scoped css (once per document), mark the host
5
+ * `data-fig="<id>"` so that css applies, put an empty, focusable `<svg class="stage">` in it and call `f.mount` with a
6
+ * context whose timers, frames and power haze are all cleared by `destroy()`. The host should be sized (the stage
7
+ * fills it) and the page should load `@entro314-labs/iso-engine/theme.css` (or define its tokens) and `@entro314-labs/iso-engine/figure.css`.
8
+ */
9
+ export function mountFigure(host, f, opts = {}) {
10
+ const doc = host.ownerDocument;
11
+ installFilters(doc);
12
+ if (f.css && !doc.querySelector(`style[data-iso-fig="${CSS.escape(f.id)}"]`)) {
13
+ const style = doc.createElement('style');
14
+ style.dataset.isoFig = f.id;
15
+ style.textContent = f.css;
16
+ doc.head.append(style);
17
+ }
18
+ host.dataset.fig = f.id;
19
+ const stage = doc.createElementNS(SVGNS, 'svg');
20
+ stage.classList.add('stage');
21
+ stage.setAttribute('role', 'img');
22
+ stage.setAttribute('tabindex', '0');
23
+ stage.setAttribute('aria-label', f.aria);
24
+ host.replaceChildren(stage);
25
+ const timers = new Set(), intervals = new Set(), frames = new Set();
26
+ const after = (ms, fn) => {
27
+ const t = window.setTimeout(() => { timers.delete(t); fn(); }, ms);
28
+ timers.add(t);
29
+ };
30
+ const handle = f.mount({
31
+ stage, host,
32
+ readout: t => opts.readout?.(t),
33
+ after,
34
+ every: (ms, fn) => { intervals.add(window.setInterval(fn, ms)); },
35
+ loop: fn => {
36
+ let id = 0, live = true;
37
+ const tick = (now) => { frames.delete(id); if (!live)
38
+ return; fn(now); id = requestAnimationFrame(tick); frames.add(id); };
39
+ id = requestAnimationFrame(tick);
40
+ frames.add(id);
41
+ return () => { live = false; cancelAnimationFrame(id); frames.delete(id); };
42
+ },
43
+ flash: (el, ms = 160) => {
44
+ if (!el)
45
+ return;
46
+ el.classList.add('down', 'flash');
47
+ after(110, () => el.classList.remove('down'));
48
+ after(ms, () => el.classList.remove('flash'));
49
+ },
50
+ replay: (el, cls = 'go') => { if (!el)
51
+ return; el.classList.remove(cls); void el.getBoundingClientRect(); el.classList.add(cls); },
52
+ power: on => { host.classList.toggle('powered', on); },
53
+ });
54
+ if (opts.demo && handle.demo)
55
+ after(150, () => handle.demo());
56
+ return {
57
+ stage, handle,
58
+ destroy() {
59
+ handle.destroy?.();
60
+ for (const t of timers)
61
+ clearTimeout(t);
62
+ for (const t of intervals)
63
+ clearInterval(t);
64
+ for (const r of frames)
65
+ cancelAnimationFrame(r);
66
+ timers.clear();
67
+ intervals.clear();
68
+ frames.clear();
69
+ host.classList.remove('powered');
70
+ host.replaceChildren();
71
+ },
72
+ };
73
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The glow kit's SVG filters, referenced from `figure.css` as `url(#fx-glow)` (flash), `url(#fx-soft)` (latched) and
3
+ * `url(#fx-bloom)` (halos). A CSS `filter: url(#id)` that points at a missing filter hides the element in Chromium,
4
+ * so these must be in the document before a figure or loop lights anything; `mountFigure` and `loopScene` install
5
+ * them. userSpaceOnUse regions: under a box-relative region a perfectly straight line has no height and would vanish.
6
+ */
7
+ export declare const FILTERS: string;
8
+ /** Add the glow filters to `doc` once (a hidden zero-size `<svg>` at the end of `<body>`). Safe to call repeatedly. */
9
+ export declare function installFilters(doc?: Document): void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The glow kit's SVG filters, referenced from `figure.css` as `url(#fx-glow)` (flash), `url(#fx-soft)` (latched) and
3
+ * `url(#fx-bloom)` (halos). A CSS `filter: url(#id)` that points at a missing filter hides the element in Chromium,
4
+ * so these must be in the document before a figure or loop lights anything; `mountFigure` and `loopScene` install
5
+ * them. userSpaceOnUse regions: under a box-relative region a perfectly straight line has no height and would vanish.
6
+ */
7
+ export const FILTERS = '<filter id="fx-glow" filterUnits="userSpaceOnUse" x="-4000" y="-4000" width="12000" height="12000"><feGaussianBlur stdDeviation="4" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge></filter>' +
8
+ '<filter id="fx-soft" filterUnits="userSpaceOnUse" x="-4000" y="-4000" width="12000" height="12000"><feGaussianBlur stdDeviation="2.2" result="b"/><feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge></filter>' +
9
+ '<filter id="fx-bloom" filterUnits="userSpaceOnUse" x="-4000" y="-4000" width="12000" height="12000"><feGaussianBlur stdDeviation="9"/></filter>';
10
+ /** Add the glow filters to `doc` once (a hidden zero-size `<svg>` at the end of `<body>`). Safe to call repeatedly. */
11
+ export function installFilters(doc = document) {
12
+ if (doc.getElementById('fx-glow'))
13
+ return;
14
+ const svg = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
15
+ svg.setAttribute('class', 'iso-fx');
16
+ svg.setAttribute('width', '0');
17
+ svg.setAttribute('height', '0');
18
+ svg.setAttribute('aria-hidden', 'true');
19
+ svg.style.position = 'absolute'; // CSSOM, not a style attribute: allowed under a strict CSP
20
+ svg.innerHTML = `<defs>${FILTERS}</defs>`;
21
+ doc.body.append(svg);
22
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @entro314-labs/iso-engine: interactive isometric figures. The projection kernel, the interaction patterns, the figure contract
3
+ * and `mountFigure`. The animation engine is `@entro314-labs/iso-engine/engine`; loop helpers are `@entro314-labs/iso-engine/loops`.
4
+ */
5
+ export * from './kernel.js';
6
+ export * from './patterns.js';
7
+ export { mountFigure, type MountFigureOptions, type MountedFigure } from './figure.js';
8
+ export { FILTERS, installFilters } from './filters.js';
9
+ export type { Figure, FigureContext, FigureHandle } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @entro314-labs/iso-engine: interactive isometric figures. The projection kernel, the interaction patterns, the figure contract
3
+ * and `mountFigure`. The animation engine is `@entro314-labs/iso-engine/engine`; loop helpers are `@entro314-labs/iso-engine/loops`.
4
+ */
5
+ export * from './kernel.js';
6
+ export * from './patterns.js';
7
+ export { mountFigure } from './figure.js';
8
+ export { FILTERS, installFilters } from './filters.js';