@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,16 @@
|
|
|
1
|
+
import { NODE_ASSETS, getAsset } from "./nodes.js";
|
|
2
|
+
import { REGION_KINDS, systems } from "./catalog.js";
|
|
3
|
+
import { DRAWING_CSS, BASE_CSS } from "./css.js";
|
|
4
|
+
import { validateSchema, schemaValidator } from "./validate.js";
|
|
5
|
+
import { compile } from "./compile.js";
|
|
6
|
+
export {
|
|
7
|
+
BASE_CSS,
|
|
8
|
+
DRAWING_CSS,
|
|
9
|
+
NODE_ASSETS,
|
|
10
|
+
REGION_KINDS,
|
|
11
|
+
compile,
|
|
12
|
+
getAsset,
|
|
13
|
+
schemaValidator,
|
|
14
|
+
systems,
|
|
15
|
+
validateSchema
|
|
16
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { iso, tag, S, center } from "../iso-core/kernel.js";
|
|
2
|
+
import * as D from "../iso-core/glyphs.js";
|
|
3
|
+
import { boxAsset, plate, drawCloud, facePainter } from "../iso-objects/assets.js";
|
|
4
|
+
const volume = {
|
|
5
|
+
name: "volume",
|
|
6
|
+
description: "Stored data that is kept: a drum with two bands (a volume, a room's history, an archive).",
|
|
7
|
+
size: [1.8, 1.8, 1.3],
|
|
8
|
+
role: "folder",
|
|
9
|
+
draw(k, b) {
|
|
10
|
+
const [cx, cy] = center(b), r = Math.min(b.x1 - b.x0, b.y1 - b.y0) / 2;
|
|
11
|
+
const at = (deg, z) => [cx + r * Math.cos(deg * Math.PI / 180), cy + r * Math.sin(deg * Math.PI / 180), z];
|
|
12
|
+
const arc = (a0, a1, z) => Array.from({ length: 13 }, (_, i) => at(a0 + (a1 - a0) * i / 12, z));
|
|
13
|
+
const side = (a0, a1, cls) => k.poly([...arc(a0, a1, b.z0), ...arc(a0, a1, b.z1).reverse()], cls);
|
|
14
|
+
const h = b.z1 - b.z0;
|
|
15
|
+
const band = (z) => arc(-45, 135, z).slice(1).map((p, i, all) => k.line3(i ? all[i - 1] : at(-45, z), p, "det")).join("");
|
|
16
|
+
return side(45, 135, "lft") + side(-45, 45, "rgt") + band(b.z0 + h * 0.36) + band(b.z0 + h * 0.68) + k.poly(Array.from({ length: 32 }, (_, i) => at(i * 360 / 32, b.z1)), "top");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const orb = {
|
|
20
|
+
name: "orb",
|
|
21
|
+
description: "An agent: a white sphere with two eyes, on a small plate.",
|
|
22
|
+
size: [1.5, 1.5, 1.6],
|
|
23
|
+
role: "lead",
|
|
24
|
+
cls: "orb",
|
|
25
|
+
draw(k, b) {
|
|
26
|
+
k.def("orbG", tag(
|
|
27
|
+
"radialGradient",
|
|
28
|
+
{ id: "orbG", cx: "0.36", cy: "0.30", r: "0.80" },
|
|
29
|
+
tag("stop", { offset: "0", style: "stop-color:#ffffff" }) + tag("stop", { offset: "0.62", style: "stop-color:#f6f6f4" }) + tag("stop", { offset: "1", style: "stop-color:#cfd0d6" })
|
|
30
|
+
));
|
|
31
|
+
const p = plate(b);
|
|
32
|
+
const [px, py] = iso((b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, p.z1), R = 23, cy = py - R + 3;
|
|
33
|
+
k.bounds.add([px - R, cy - R]);
|
|
34
|
+
k.bounds.add([px + R, cy + R]);
|
|
35
|
+
const eye = (dx, dy, w, h) => tag("rect", { class: "eye", x: px + dx - w / 2, y: cy + dy - h / 2, width: w, height: h, rx: w / 2, transform: `rotate(-24 ${(px + dx).toFixed(1)} ${(cy + dy).toFixed(1)})` });
|
|
36
|
+
return k.blockFaces(p) + tag("ellipse", { class: "shade", cx: px, cy: py + 1, rx: R * 0.8, ry: R * 0.3 }) + tag("circle", { class: "ball", cx: px, cy, r: R }) + eye(3, -7, 6.4, 13.5) + eye(14, -12, 5.4, 10.5);
|
|
37
|
+
},
|
|
38
|
+
label(b, _n, hasSub) {
|
|
39
|
+
const [X, Y] = iso((b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, b.z0 + 1.95);
|
|
40
|
+
return { x: X, y: Y - 26 + (hasSub ? 0 : 14), anchor: "middle" };
|
|
41
|
+
},
|
|
42
|
+
pulse: (b) => [(b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, b.z0 + 0.8, 26]
|
|
43
|
+
};
|
|
44
|
+
const person = {
|
|
45
|
+
name: "person",
|
|
46
|
+
description: "A human: body and head on a small plate. The label sits to the right.",
|
|
47
|
+
size: [1.5, 1.5, 1.6],
|
|
48
|
+
role: "person",
|
|
49
|
+
cls: "person",
|
|
50
|
+
draw(k, b) {
|
|
51
|
+
const p = plate(b);
|
|
52
|
+
const [px, py] = iso((b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, p.z1);
|
|
53
|
+
k.bounds.add([px - 13, py - 50]);
|
|
54
|
+
const r = (v) => v.toFixed(1);
|
|
55
|
+
return k.blockFaces(p) + tag("path", { class: "body", d: `M${r(px - 13)},${r(py - 4)} C${r(px - 13)},${r(py - 34)} ${r(px + 13)},${r(py - 34)} ${r(px + 13)},${r(py - 4)} Q${r(px)},${r(py + 4)} ${r(px - 13)},${r(py - 4)}z` }) + tag("circle", { class: "head", cx: px, cy: py - 40, r: 10 });
|
|
56
|
+
},
|
|
57
|
+
label(b) {
|
|
58
|
+
const [X, Y] = iso((b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, b.z0);
|
|
59
|
+
return { x: X + 30, y: Y + 2, anchor: "start" };
|
|
60
|
+
},
|
|
61
|
+
pulse: (b) => [(b.x0 + b.x1) / 2, (b.y0 + b.y1) / 2, b.z0 + 0.9, 26]
|
|
62
|
+
};
|
|
63
|
+
const screen = {
|
|
64
|
+
name: "screen",
|
|
65
|
+
description: "An upright screen or terminal panel. `face`: terminal, chat, desktop, tiles, or one the host registers. `facing`: turn in degrees.",
|
|
66
|
+
size: [1.64, 0.3, 1.75],
|
|
67
|
+
role: "term",
|
|
68
|
+
draw(k, b, n) {
|
|
69
|
+
const [cx, cy] = center(b), HW = (b.x1 - b.x0) / 2, PH = b.z1 - b.z0, T = 0.14;
|
|
70
|
+
const t = (n.facing ?? 0) * Math.PI / 180, tx = Math.cos(t), ty = Math.sin(t), nx = Math.sin(t) * T, ny = -Math.cos(t) * T;
|
|
71
|
+
const a = [cx - tx * HW, cy - ty * HW], bb = [cx + tx * HW, cy + ty * HW];
|
|
72
|
+
const z0 = b.z0, z1 = b.z1;
|
|
73
|
+
let s = k.poly([[bb[0], bb[1], z0], [bb[0] + nx, bb[1] + ny, z0], [bb[0] + nx, bb[1] + ny, z1], [bb[0], bb[1], z1]], "rgt") + k.poly([[a[0], a[1], z1], [bb[0], bb[1], z1], [bb[0] + nx, bb[1] + ny, z1], [a[0] + nx, a[1] + ny, z1]], "top") + k.poly([[a[0], a[1], z0], [bb[0], bb[1], z0], [bb[0], bb[1], z1], [a[0], a[1], z1]], "lft");
|
|
74
|
+
const A = iso(a[0], a[1], z1), B = iso(bb[0], bb[1], z1), w = 2 * HW * S, h = PH * S;
|
|
75
|
+
const m = [(B[0] - A[0]) / w, (B[1] - A[1]) / w, 0, 1, A[0], A[1]];
|
|
76
|
+
const face = facePainter(n.face ?? "terminal") ?? D.placeholderFace;
|
|
77
|
+
s += k.onMatrix(m, w, h, (W, H) => D.screenGlass(W, H) + face(W, H), "scr");
|
|
78
|
+
return s;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const monitor = {
|
|
82
|
+
name: "monitor",
|
|
83
|
+
description: "A block with a screen painted on its front-left face. `face` as for screen.",
|
|
84
|
+
size: [2.4, 0.8, 1.8],
|
|
85
|
+
role: "term",
|
|
86
|
+
draw(k, b, n) {
|
|
87
|
+
const face = facePainter(n.face ?? "terminal") ?? D.placeholderFace;
|
|
88
|
+
return k.blockFaces(b) + k.onFace(b, "left", (w, h) => D.screenGlass(w, h) + face(w, h), "scr");
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const cloud = {
|
|
92
|
+
name: "cloud",
|
|
93
|
+
description: "A cloud lying on the floor: the internet, or a hosted service.",
|
|
94
|
+
size: [3, 2.4, 0.3],
|
|
95
|
+
role: "cloud",
|
|
96
|
+
draw: (k, b) => drawCloud(k, b)
|
|
97
|
+
};
|
|
98
|
+
const NODE_ASSETS = {
|
|
99
|
+
block: boxAsset("block", "A box. Size and colour role are free; add decorations with `deco`.", [2.4, 2.4, 1.6], "grey"),
|
|
100
|
+
session: boxAsset("session", "An agent session: a box with terminal lines (`deco: [terminal: 4]`; add an icon the host registers with `icon: NAME`).", [2.6, 2.6, 1.8], "work", [{ terminal: 4 }]),
|
|
101
|
+
terminal: boxAsset("terminal", "A box with terminal lines on its front.", [1.6, 1.2, 0.8], "term", [{ terminal: 2 }]),
|
|
102
|
+
server: boxAsset("server", "A service or daemon: a low box with two terminal lines.", [3, 2.2, 0.9], "doz", [{ terminal: 2 }]),
|
|
103
|
+
chat: boxAsset("chat", "A chat server or room: a box with a chat bubble on top.", [3.6, 4.4, 1.3], "chat", ["bubble"]),
|
|
104
|
+
mailbox: boxAsset("mailbox", "A room or inbox: terminal lines and an envelope on top.", [2.4, 2.4, 1.6], "mail", [{ terminal: 3 }, "envelope"]),
|
|
105
|
+
file: boxAsset("file", "A file or document: a low box with lines on top.", [1.6, 1.6, 0.6], "file", ["file-lines"]),
|
|
106
|
+
folder: boxAsset("folder", "A folder or directory: a flat box.", [1.6, 1.6, 0.5], "folder"),
|
|
107
|
+
key: boxAsset("key", "A secret: a low box with a key on top.", [1.6, 1.6, 0.6], "key", [], (k, b) => D.keyGlyph(k, b)),
|
|
108
|
+
socket: boxAsset("socket", "A socket: a small box with a round opening on top.", [1.2, 1.2, 0.5], "socket", [], (k, b) => D.socketGlyph(k, b)),
|
|
109
|
+
gate: boxAsset("gate", "A gate or proxy: a narrow upright slab, usually set in a fence wall.", [0.3, 2, 1.1], "gate"),
|
|
110
|
+
placeholder: boxAsset("placeholder", "A placeholder value: a small low box with lines.", [1.2, 1, 0.45], "placeholder", ["file-lines"]),
|
|
111
|
+
orb,
|
|
112
|
+
person,
|
|
113
|
+
screen,
|
|
114
|
+
monitor,
|
|
115
|
+
cloud,
|
|
116
|
+
volume
|
|
117
|
+
};
|
|
118
|
+
function getAsset(name) {
|
|
119
|
+
return NODE_ASSETS[name ?? "block"];
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
NODE_ASSETS,
|
|
123
|
+
getAsset
|
|
124
|
+
};
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://isodiag.local/schema/isodiag-1.json",
|
|
4
|
+
"title": "isodiag diagram",
|
|
5
|
+
"description": "A page of isometric, animated diagrams. See docs/FORMAT.md.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["isodiag", "scenes"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"isodiag": { "const": 1, "description": "Format version. Always 1." },
|
|
11
|
+
"title": { "type": "string" },
|
|
12
|
+
"lede": { "type": "string" },
|
|
13
|
+
"pills": { "type": "array", "items": { "type": "string" } },
|
|
14
|
+
"theme": { "type": "string", "description": "'default' or a path to a theme file" },
|
|
15
|
+
"roles": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"description": "Extra or changed colour roles for nodes and regions",
|
|
18
|
+
"additionalProperties": { "$ref": "#/$defs/role" }
|
|
19
|
+
},
|
|
20
|
+
"kinds": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"description": "Extra flow kinds, or new legend text for the standard ones",
|
|
23
|
+
"additionalProperties": { "$ref": "#/$defs/kindDef" }
|
|
24
|
+
},
|
|
25
|
+
"after": { "type": "string", "description": "Markdown shown after all scenes" },
|
|
26
|
+
"grid": { "$ref": "#/$defs/grid" },
|
|
27
|
+
"assemble": { "type": "boolean", "description": "draw each scene by flying its parts in from the nearest edge, then play" },
|
|
28
|
+
"footer": { "type": "string" },
|
|
29
|
+
"scenes": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/scene" } }
|
|
30
|
+
},
|
|
31
|
+
"$defs": {
|
|
32
|
+
"id": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_-]*$" },
|
|
33
|
+
"grid": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"snap": { "type": "number", "exclusiveMinimum": 0, "description": "round every placed edge and route waypoint to this step, in grid units" },
|
|
38
|
+
"show": { "type": "boolean", "description": "draw the floor grid when the page opens (the Grid button toggles it)" },
|
|
39
|
+
"step": { "type": "number", "exclusiveMinimum": 0, "description": "spacing of the drawn grid lines; default the snap step, or 1" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"num": { "type": "number" },
|
|
43
|
+
"point2": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 },
|
|
44
|
+
"size2or3": { "type": "array", "items": { "type": "number", "exclusiveMinimum": 0 }, "minItems": 2, "maxItems": 3 },
|
|
45
|
+
"stepRef": { "anyOf": [{ "type": "string" }, { "type": "integer", "minimum": 1 }] },
|
|
46
|
+
"side": { "enum": ["n", "e", "s", "w"] },
|
|
47
|
+
"align": { "enum": ["start", "center", "end"] },
|
|
48
|
+
"role": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"required": ["h", "s"],
|
|
52
|
+
"properties": {
|
|
53
|
+
"h": { "type": "number", "minimum": 0, "maximum": 360, "description": "hue" },
|
|
54
|
+
"s": { "type": "number", "minimum": 0, "maximum": 100, "description": "saturation, percent" },
|
|
55
|
+
"top": { "type": "string", "description": "CSS colour for the top face, overriding the computed one" },
|
|
56
|
+
"tint": { "type": "number", "minimum": 0, "maximum": 100, "description": "percent of the role colour mixed into the pad colour for the top face" }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"kindDef": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"additionalProperties": false,
|
|
62
|
+
"properties": {
|
|
63
|
+
"legend": { "type": "string" },
|
|
64
|
+
"like": { "type": "string", "description": "a standard kind whose colour and line style this one uses" },
|
|
65
|
+
"color": { "type": "string" },
|
|
66
|
+
"dash": { "enum": ["solid", "dashed", "dotted"] }
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"placement": {
|
|
70
|
+
"properties": {
|
|
71
|
+
"in": { "$ref": "#/$defs/id" },
|
|
72
|
+
"at": { "$ref": "#/$defs/point2" },
|
|
73
|
+
"right-of": { "$ref": "#/$defs/id" },
|
|
74
|
+
"left-of": { "$ref": "#/$defs/id" },
|
|
75
|
+
"below": { "$ref": "#/$defs/id" },
|
|
76
|
+
"behind": { "$ref": "#/$defs/id" },
|
|
77
|
+
"gap": { "type": "number" },
|
|
78
|
+
"align": { "$ref": "#/$defs/align" },
|
|
79
|
+
"shift": { "$ref": "#/$defs/point2", "description": "nudge after placement, grid units [dx, dy]" },
|
|
80
|
+
"appears": { "$ref": "#/$defs/stepRef" },
|
|
81
|
+
"disappears": { "$ref": "#/$defs/stepRef" }
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"scene": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"required": ["id", "title"],
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": {
|
|
89
|
+
"id": { "$ref": "#/$defs/id" },
|
|
90
|
+
"title": { "type": "string" },
|
|
91
|
+
"caption": { "type": "string" },
|
|
92
|
+
"aria": { "type": "string" },
|
|
93
|
+
"gap": { "type": "number", "exclusiveMinimum": 0 },
|
|
94
|
+
"flow": { "enum": ["row", "column"] },
|
|
95
|
+
"regions": { "type": "array", "items": { "$ref": "#/$defs/region" } },
|
|
96
|
+
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } },
|
|
97
|
+
"routes": { "type": "array", "items": { "$ref": "#/$defs/route" } },
|
|
98
|
+
"notes": { "type": "array", "items": { "$ref": "#/$defs/note" } },
|
|
99
|
+
"steps": { "type": "array", "items": { "$ref": "#/$defs/step" } },
|
|
100
|
+
"legend": {
|
|
101
|
+
"anyOf": [
|
|
102
|
+
{ "enum": ["auto"] },
|
|
103
|
+
{ "const": false },
|
|
104
|
+
{ "type": "array", "items": { "type": "string" } }
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"badges": { "type": "boolean" },
|
|
108
|
+
"grid": { "$ref": "#/$defs/grid" },
|
|
109
|
+
"assemble": { "type": "boolean", "description": "draw the scene by flying its parts in from the nearest edge, then play" },
|
|
110
|
+
"loop": { "type": "boolean", "description": "the player wraps from the last step to the first (default true)" },
|
|
111
|
+
"dim": { "enum": ["flows", "all"], "description": "what a step dims: only flows, their labels and marks (default), or nodes too" },
|
|
112
|
+
"after": { "type": "string" }
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"region": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"required": ["id", "kind"],
|
|
118
|
+
"unevaluatedProperties": false,
|
|
119
|
+
"allOf": [{ "$ref": "#/$defs/placement" }],
|
|
120
|
+
"properties": {
|
|
121
|
+
"id": { "$ref": "#/$defs/id" },
|
|
122
|
+
"kind": { "enum": ["slab", "pad", "fence", "vm", "cloud", "zone", "platform", "tunnel"] },
|
|
123
|
+
"label": { "type": "string" },
|
|
124
|
+
"label-style": { "enum": ["face", "face-right", "floor", "none"] },
|
|
125
|
+
"ghost": { "type": "boolean", "description": "drawn as a dashed outline: not there yet, out of reach, or stopped" },
|
|
126
|
+
"role": { "type": "string" },
|
|
127
|
+
"size": { "$ref": "#/$defs/size2or3" },
|
|
128
|
+
"padding": { "type": "number", "minimum": 0 },
|
|
129
|
+
"height": { "type": "number", "exclusiveMinimum": 0 },
|
|
130
|
+
"z": { "type": "number", "description": "lift above the floor it stands on (tunnels)" },
|
|
131
|
+
"flow": { "enum": ["row", "column"] },
|
|
132
|
+
"gate": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": false,
|
|
135
|
+
"required": ["side"],
|
|
136
|
+
"properties": {
|
|
137
|
+
"side": { "$ref": "#/$defs/side" },
|
|
138
|
+
"at": { "type": "number", "minimum": 0, "maximum": 1, "description": "centre of the gate along the wall, 0..1" },
|
|
139
|
+
"width": { "type": "number", "exclusiveMinimum": 0 },
|
|
140
|
+
"height": { "type": "number", "exclusiveMinimum": 0 },
|
|
141
|
+
"node": { "$ref": "#/$defs/id" }
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"around": { "type": "array", "items": { "$ref": "#/$defs/id" }, "description": "tunnel: routes it wraps" },
|
|
145
|
+
"regions": { "type": "array", "items": { "$ref": "#/$defs/region" } },
|
|
146
|
+
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } }
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"deco": {
|
|
150
|
+
"anyOf": [
|
|
151
|
+
{ "enum": ["envelope", "bubble", "file-lines", "ghost", "terminal"] },
|
|
152
|
+
{
|
|
153
|
+
"type": "object",
|
|
154
|
+
"additionalProperties": false,
|
|
155
|
+
"minProperties": 1,
|
|
156
|
+
"maxProperties": 1,
|
|
157
|
+
"properties": {
|
|
158
|
+
"terminal": { "type": "integer", "minimum": 1, "maximum": 8 },
|
|
159
|
+
"icon": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$", "description": "an icon the host registers (none by default); one nothing registers is drawn as a placeholder, with a warning" },
|
|
160
|
+
"screen": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$", "description": "terminal, chat, desktop, tiles, or a face the host registers" }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"node": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"required": ["id"],
|
|
168
|
+
"unevaluatedProperties": false,
|
|
169
|
+
"allOf": [{ "$ref": "#/$defs/placement" }],
|
|
170
|
+
"properties": {
|
|
171
|
+
"id": { "$ref": "#/$defs/id" },
|
|
172
|
+
"asset": { "type": "string", "description": "asset name from the library; default 'block'" },
|
|
173
|
+
"role": { "type": "string", "description": "colour role" },
|
|
174
|
+
"label": { "type": "string" },
|
|
175
|
+
"sub": { "type": "string" },
|
|
176
|
+
"size": { "$ref": "#/$defs/size2or3" },
|
|
177
|
+
"z": { "type": "number", "description": "lift above the floor it stands on" },
|
|
178
|
+
"deco": { "type": "array", "items": { "$ref": "#/$defs/deco" } },
|
|
179
|
+
"ghost": { "type": "boolean" },
|
|
180
|
+
"face": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$", "description": "screen asset: what the screen shows: terminal, chat, desktop, tiles, or a face the host registers" },
|
|
181
|
+
"facing": { "type": "number", "description": "screen asset: rotation in degrees" },
|
|
182
|
+
"label-at": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"additionalProperties": false,
|
|
185
|
+
"properties": {
|
|
186
|
+
"side": { "enum": ["above", "right", "left", "below"] },
|
|
187
|
+
"dx": { "type": "number" },
|
|
188
|
+
"dy": { "type": "number" }
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" }, "description": "nodes standing on top of this one" }
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"endpoint": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_-]*(\\.(n|e|s|w|top))?$" },
|
|
195
|
+
"route": {
|
|
196
|
+
"type": "object",
|
|
197
|
+
"required": ["id", "from", "to"],
|
|
198
|
+
"additionalProperties": false,
|
|
199
|
+
"properties": {
|
|
200
|
+
"id": { "$ref": "#/$defs/id" },
|
|
201
|
+
"from": { "$ref": "#/$defs/endpoint" },
|
|
202
|
+
"to": { "$ref": "#/$defs/endpoint" },
|
|
203
|
+
"kind": { "type": "string" },
|
|
204
|
+
"via": { "type": "array", "items": { "anyOf": [{ "$ref": "#/$defs/point2" }, { "$ref": "#/$defs/endpoint" }] } },
|
|
205
|
+
"points": { "type": "array", "items": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 3 }, "description": "exact polyline in grid units; skips the router" },
|
|
206
|
+
"lane": { "type": "number" },
|
|
207
|
+
"arrow": { "type": "boolean" },
|
|
208
|
+
"cross": { "type": "boolean", "description": "the route may pass through fence walls (it crosses a boundary)" },
|
|
209
|
+
"label": {
|
|
210
|
+
"anyOf": [
|
|
211
|
+
{ "type": "string" },
|
|
212
|
+
{
|
|
213
|
+
"type": "object",
|
|
214
|
+
"additionalProperties": false,
|
|
215
|
+
"required": ["text"],
|
|
216
|
+
"properties": {
|
|
217
|
+
"text": { "type": "string" },
|
|
218
|
+
"along": { "type": "integer", "minimum": 1 },
|
|
219
|
+
"side": { "enum": ["left", "right"] },
|
|
220
|
+
"at": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 3, "description": "exact place [x, y] or [x, y, z]; skips placement" },
|
|
221
|
+
"dir": { "enum": ["x", "y"] },
|
|
222
|
+
"anchor": { "enum": ["start", "middle", "end"] }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
"appears": { "$ref": "#/$defs/stepRef" },
|
|
228
|
+
"disappears": { "$ref": "#/$defs/stepRef" }
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"note": {
|
|
232
|
+
"type": "object",
|
|
233
|
+
"additionalProperties": false,
|
|
234
|
+
"properties": {
|
|
235
|
+
"floor": { "type": "string" },
|
|
236
|
+
"face": { "type": "string" },
|
|
237
|
+
"label": { "type": "string" },
|
|
238
|
+
"sub": { "type": "string" },
|
|
239
|
+
"at": { "anyOf": [{ "$ref": "#/$defs/point2" }, { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3 }] },
|
|
240
|
+
"on": { "$ref": "#/$defs/id", "description": "a node, region or route; a note on a route dims and lights with it" },
|
|
241
|
+
"kind": { "type": "string" },
|
|
242
|
+
"dir": { "enum": ["x", "y"] },
|
|
243
|
+
"anchor": { "enum": ["start", "middle", "end"] },
|
|
244
|
+
"dx": { "type": "number" },
|
|
245
|
+
"dy": { "type": "number" },
|
|
246
|
+
"appears": { "$ref": "#/$defs/stepRef" },
|
|
247
|
+
"disappears": { "$ref": "#/$defs/stepRef" }
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"routeRef": {
|
|
251
|
+
"anyOf": [
|
|
252
|
+
{ "type": "string" },
|
|
253
|
+
{ "type": "object", "minProperties": 1, "maxProperties": 1, "additionalProperties": { "type": "string" } }
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
"phase": {
|
|
257
|
+
"anyOf": [
|
|
258
|
+
{ "$ref": "#/$defs/routeRef" },
|
|
259
|
+
{ "type": "array", "items": { "$ref": "#/$defs/routeRef" } }
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
"step": {
|
|
263
|
+
"type": "object",
|
|
264
|
+
"required": ["heading"],
|
|
265
|
+
"additionalProperties": false,
|
|
266
|
+
"properties": {
|
|
267
|
+
"id": { "$ref": "#/$defs/id" },
|
|
268
|
+
"number": { "type": "integer", "minimum": 1, "description": "the number shown; defaults to the position" },
|
|
269
|
+
"kind": { "type": "string" },
|
|
270
|
+
"heading": { "type": "string" },
|
|
271
|
+
"caption": { "type": "string" },
|
|
272
|
+
"command": { "type": "string" },
|
|
273
|
+
"animate": { "type": "array", "items": { "$ref": "#/$defs/phase" } },
|
|
274
|
+
"pulse": { "type": "array", "items": { "$ref": "#/$defs/id" } },
|
|
275
|
+
"highlight": { "type": "array", "items": { "$ref": "#/$defs/id" } },
|
|
276
|
+
"focus": { "type": "array", "items": { "$ref": "#/$defs/id" }, "description": "nodes or regions to zoom to for this step; the view eases back on steps without focus" },
|
|
277
|
+
"show": { "type": "array", "items": { "$ref": "#/$defs/id" } },
|
|
278
|
+
"hide": { "type": "array", "items": { "$ref": "#/$defs/id" } },
|
|
279
|
+
"say": {
|
|
280
|
+
"type": "array",
|
|
281
|
+
"items": {
|
|
282
|
+
"type": "object",
|
|
283
|
+
"additionalProperties": false,
|
|
284
|
+
"required": ["at", "text"],
|
|
285
|
+
"properties": {
|
|
286
|
+
"at": { "anyOf": [{ "$ref": "#/$defs/id" }, { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 3 }], "description": "a node (the callout sits above it) or a grid point [x, y, z]" },
|
|
287
|
+
"text": { "type": "string" },
|
|
288
|
+
"kind": { "type": "string" },
|
|
289
|
+
"dx": { "type": "number" },
|
|
290
|
+
"dy": { "type": "number" },
|
|
291
|
+
"anchor": { "enum": ["start", "middle", "end"] }
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"mark": {
|
|
296
|
+
"type": "array",
|
|
297
|
+
"items": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"additionalProperties": false,
|
|
300
|
+
"properties": {
|
|
301
|
+
"on": { "$ref": "#/$defs/id" },
|
|
302
|
+
"at": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 3 }
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"badge": { "anyOf": [{ "type": "boolean" }, { "$ref": "#/$defs/id" }, { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 3 }], "description": "false, a route or node id, or a grid point [x, y, z]" },
|
|
307
|
+
"duration": { "anyOf": [{ "const": "auto" }, { "type": "integer", "minimum": 500 }] }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { compileSchema } from "../iso-core/compile-schema.js";
|
|
2
|
+
import schema from "./schema.json" with { type: "json" };
|
|
3
|
+
import { prune, registerConst, registerNoun, registerPattern, registerRefKeys } from "../iso-core/schema-errors.js";
|
|
4
|
+
import { schemaValidator } from "../iso-core/schema-errors.js";
|
|
5
|
+
const check = compileSchema(schema);
|
|
6
|
+
const placementKeys = Object.keys(schema.$defs.placement.properties);
|
|
7
|
+
registerRefKeys("#/$defs/placement", placementKeys);
|
|
8
|
+
registerConst("/isodiag", (got) => `"isodiag" must be 1 (the format version), got ${got}`);
|
|
9
|
+
const what = {
|
|
10
|
+
scene: "a scene",
|
|
11
|
+
region: "a region",
|
|
12
|
+
node: "a node",
|
|
13
|
+
route: "a route",
|
|
14
|
+
note: "a note",
|
|
15
|
+
step: "a step"
|
|
16
|
+
};
|
|
17
|
+
registerNoun((path) => {
|
|
18
|
+
const m = /\/(scenes|regions|nodes|routes|notes|steps)\/\d+$/.exec(path);
|
|
19
|
+
return m ? what[m[1].replace(/s$/, "")] ?? "this item" : void 0;
|
|
20
|
+
});
|
|
21
|
+
registerPattern("^[A-Za-z][A-Za-z0-9_-]*(", (data) => ({
|
|
22
|
+
message: `"${data}" is not a node reference`,
|
|
23
|
+
hint: "write an id, optionally with a side: worker, worker.e (sides: n, e, s, w, top)"
|
|
24
|
+
}));
|
|
25
|
+
function validateSchema(parsed) {
|
|
26
|
+
if (parsed.data == null || typeof parsed.data !== "object" || Array.isArray(parsed.data)) {
|
|
27
|
+
return [{ severity: "error", message: 'the file must be a YAML map with "isodiag: 1" and "scenes:"', line: 1, col: 1, path: "" }];
|
|
28
|
+
}
|
|
29
|
+
if (check(parsed.data)) return [];
|
|
30
|
+
return prune(check.errors ?? [], parsed);
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
schemaValidator,
|
|
34
|
+
validateSchema
|
|
35
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { buildSync } from "esbuild";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
let cached;
|
|
4
|
+
function playerScript() {
|
|
5
|
+
if (cached) return cached;
|
|
6
|
+
const r = buildSync({
|
|
7
|
+
entryPoints: [fileURLToPath(new URL("../../src/iso-viewer/player.ts", import.meta.url))],
|
|
8
|
+
bundle: true,
|
|
9
|
+
minify: true,
|
|
10
|
+
format: "iife",
|
|
11
|
+
target: "es2020",
|
|
12
|
+
write: false,
|
|
13
|
+
legalComments: "none"
|
|
14
|
+
});
|
|
15
|
+
cached = r.outputFiles[0].text;
|
|
16
|
+
return cached;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
playerScript
|
|
20
|
+
};
|