topotopo 0.4.0 → 0.5.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/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +327 -147
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +198 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +57 -5
- package/dist/render/preview.d.ts +17 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +74 -5
- package/dist/render/raster.js +527 -143
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +13 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// The gallery pages' script (src/gallery/pages.ts): search and tag filters on the grid, copy buttons and actions on a
|
|
2
|
-
// project page, and live updates from the server's event stream (a bake finished, projects added or removed).
|
|
3
|
-
const page = document.body.dataset.page;
|
|
4
|
-
const data = document.body.dataset.json ? JSON.parse(document.body.dataset.json) : {};
|
|
5
|
-
const $$ = (s) => [...document.querySelectorAll(s)];
|
|
6
|
-
|
|
7
|
-
if (page === 'gallery') {
|
|
8
|
-
const search = document.getElementById('search');
|
|
9
|
-
const chips = $$('.chip');
|
|
10
|
-
const filter = () => {
|
|
11
|
-
const words = search.value.toLowerCase().split(/\s+/).filter(Boolean);
|
|
12
|
-
const tags = chips.filter((c) => c.getAttribute('aria-pressed') === 'true').map((c) => c.dataset.tag);
|
|
13
|
-
let shown = 0;
|
|
14
|
-
for (const card of $$('.card')) {
|
|
15
|
-
const own = card.dataset.tags.split('\n');
|
|
16
|
-
const ok = words.every((w) => card.dataset.hay.includes(w)) && tags.every((t) => own.includes(t));
|
|
17
|
-
card.hidden = !ok;
|
|
18
|
-
if (ok) shown++;
|
|
19
|
-
}
|
|
20
|
-
for (const sec of $$('.collection')) sec.hidden = !sec.querySelector('.card:not([hidden])');
|
|
21
|
-
document.getElementById('nomatch').hidden = shown > 0 || !$$('.card').length;
|
|
22
|
-
try { sessionStorage.setItem('gallery.filter', JSON.stringify({ q: search.value, tags })); } catch { /* storage blocked */ }
|
|
23
|
-
};
|
|
24
|
-
try {
|
|
25
|
-
const saved = JSON.parse(sessionStorage.getItem('gallery.filter') ?? 'null');
|
|
26
|
-
if (saved) { search.value = saved.q ?? ''; for (const c of chips) c.setAttribute('aria-pressed', String(saved.tags?.includes(c.dataset.tag) ?? false)); }
|
|
27
|
-
} catch { /* storage blocked */ }
|
|
28
|
-
search.addEventListener('input', filter);
|
|
29
|
-
for (const c of chips) c.addEventListener('click', () => { c.setAttribute('aria-pressed', String(c.getAttribute('aria-pressed') !== 'true')); filter(); });
|
|
30
|
-
document.addEventListener('keydown', (e) => { if (e.key === '/' && document.activeElement !== search) { e.preventDefault(); search.focus(); } });
|
|
31
|
-
filter();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (page === 'project') {
|
|
35
|
-
for (const b of $$('[data-copy]')) {
|
|
36
|
-
b.addEventListener('click', async () => {
|
|
37
|
-
const input = b.previousElementSibling;
|
|
38
|
-
input.select();
|
|
39
|
-
try { await navigator.clipboard.writeText(input.value); } catch { document.execCommand('copy'); }
|
|
40
|
-
b.textContent = 'Copied';
|
|
41
|
-
b.classList.add('done');
|
|
42
|
-
setTimeout(() => { b.textContent = 'Copy'; b.classList.remove('done'); }, 1500);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
for (const b of $$('[data-post]')) {
|
|
46
|
-
b.addEventListener('click', async () => {
|
|
47
|
-
b.disabled = true;
|
|
48
|
-
try {
|
|
49
|
-
const res = await fetch(`${location.pathname.replace(/\/$/, '')}/${b.dataset.post}`, { method: 'POST' });
|
|
50
|
-
const j = await res.json().catch(() => ({}));
|
|
51
|
-
if (b.dataset.post === 'bake') document.getElementById('bake').textContent = j.ok ? 'Baking…' : `Could not bake: ${j.error ?? res.status}`;
|
|
52
|
-
} finally { setTimeout(() => { b.disabled = false; }, 800); }
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// live updates: a finished bake reloads that project's thumbnail (grid) or the page (project); a changed list reloads
|
|
58
|
-
// the grid
|
|
59
|
-
const es = new EventSource('/api/events');
|
|
60
|
-
es.onmessage = (m) => {
|
|
61
|
-
let ev;
|
|
62
|
-
try { ev = JSON.parse(m.data); } catch { return; }
|
|
63
|
-
const key = `${data.lib}/${data.id}`;
|
|
64
|
-
if (page === 'gallery') {
|
|
65
|
-
if (ev.list) { location.reload(); return; }
|
|
66
|
-
if (ev.project) {
|
|
67
|
-
const card = document.querySelector(`.card[data-key="${CSS.escape(ev.project)}"]`);
|
|
68
|
-
if (!card) return;
|
|
69
|
-
const st = card.querySelector('.status');
|
|
70
|
-
if (ev.baking) { st.className = 'status s-baking'; st.textContent = 'baking…'; return; }
|
|
71
|
-
st.className = `status s-${ev.ok ? 'ok' : 'failed'}`;
|
|
72
|
-
st.textContent = ev.ok ? '' : 'bake failed';
|
|
73
|
-
const img = card.querySelector('img');
|
|
74
|
-
img.src = img.src.replace(/(\?v=[^&]*)?$/, `?v=${ev.version}`);
|
|
75
|
-
}
|
|
76
|
-
} else if (page === 'project') {
|
|
77
|
-
if (ev.project === key && ev.baking) document.getElementById('bake').textContent = 'Baking…';
|
|
78
|
-
else if ((ev.project === key && !ev.baking) || ev.changed?.includes(key)) location.reload();
|
|
79
|
-
}
|
|
80
|
-
};
|
package/dist/gallery/cli.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function galleryCommand(argv: string[], prog: string): Promise<undefined>;
|
|
2
|
-
export declare function libraryCommand(argv: string[], prog: string): Promise<undefined>;
|
|
3
|
-
/** `edit <project>`: the live viewer on a project's workspace, following changes other processes make to it. */
|
|
4
|
-
export declare function editCommand(argv: string[], prog: string): Promise<void>;
|
package/dist/gallery/cli.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// The gallery's commands (src/cli.ts dispatches here):
|
|
2
|
-
// topotopo gallery [--port 7340] [--library <folder>] [--no-bake] the gallery website on 127.0.0.1
|
|
3
|
-
// topotopo library add <name> <folder> list a folder as a library (~/.topotopo/config.json)
|
|
4
|
-
// topotopo library list libraries, projects and problems
|
|
5
|
-
// topotopo library new <library> <folder/name> [--title t] [--tags a,b] [--description d]
|
|
6
|
-
// topotopo library bake <project folder> | --stale | --all bake previews in this process
|
|
7
|
-
// topotopo edit <project folder> [--port 7341] [--json] the live viewer on a project (the gallery's editor)
|
|
8
|
-
import fs from 'node:fs';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import { addLibrary, createProject, isStale, loadConfig, projectDirOf, readBakeState, scanAll, slugify } from './library.js';
|
|
11
|
-
const fail = (msg) => { console.error(msg); process.exit(1); };
|
|
12
|
-
export async function galleryCommand(argv, prog) {
|
|
13
|
-
const opt = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
|
|
14
|
-
let cfg;
|
|
15
|
-
try {
|
|
16
|
-
cfg = loadConfig();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
return fail(e.message);
|
|
20
|
-
}
|
|
21
|
-
const extra = opt('--library');
|
|
22
|
-
if (extra) {
|
|
23
|
-
const name = slugify(path.basename(path.resolve(extra))) || 'library';
|
|
24
|
-
cfg = { ...cfg, libraries: [...cfg.libraries.filter((l) => l.name !== name), { name, path: path.resolve(extra) }] };
|
|
25
|
-
}
|
|
26
|
-
if (!cfg.libraries.length)
|
|
27
|
-
console.log(`no libraries yet: add a folder with \`${prog} library add <name> <folder>\` (or pass --library <folder>)`);
|
|
28
|
-
const port = opt('--port') !== undefined ? Number(opt('--port')) : cfg.gallery.port;
|
|
29
|
-
const { startGallery, runningGallery } = await import('./server.js');
|
|
30
|
-
try {
|
|
31
|
-
const g = await startGallery({ config: cfg, port, bake: !argv.includes('--no-bake'), log: (m) => console.log(m) });
|
|
32
|
-
const n = cfg.libraries.length;
|
|
33
|
-
console.log(`gallery: ${g.url} (${n} librar${n === 1 ? 'y' : 'ies'}: ${cfg.libraries.map((l) => `${l.name} → ${l.path}`).join(', ') || 'none'}; Ctrl+C to stop)`);
|
|
34
|
-
if (g.queue.size)
|
|
35
|
-
console.log(`baking ${g.queue.size} project(s) in the background`);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
if (e?.code !== 'EADDRINUSE')
|
|
39
|
-
throw e;
|
|
40
|
-
const url = await runningGallery(port);
|
|
41
|
-
if (url) {
|
|
42
|
-
console.log(`gallery: ${url} (already running)`);
|
|
43
|
-
process.exit(0);
|
|
44
|
-
}
|
|
45
|
-
fail(`port ${port} is taken by another program: pass --port, or set "gallery": {"port": N} in ${cfg.file}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export async function libraryCommand(argv, prog) {
|
|
49
|
-
const opt = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
|
|
50
|
-
const [sub, a, b] = argv;
|
|
51
|
-
const usage = `usage: ${prog} library add <name> <folder> | list | new <library> <folder/name> [--title t] [--tags a,b] [--description d] | bake <project folder> | bake --stale | bake --all`;
|
|
52
|
-
let cfg;
|
|
53
|
-
try {
|
|
54
|
-
cfg = loadConfig();
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
return fail(e.message);
|
|
58
|
-
}
|
|
59
|
-
if (sub === 'add') {
|
|
60
|
-
if (!a || !b)
|
|
61
|
-
fail(usage);
|
|
62
|
-
try {
|
|
63
|
-
cfg = addLibrary(a, b);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
fail(e.message);
|
|
67
|
-
}
|
|
68
|
-
console.log(`library ${a} → ${path.resolve(b)} (in ${cfg.file})`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (sub === 'list') {
|
|
72
|
-
if (!cfg.libraries.length)
|
|
73
|
-
console.log(`no libraries (config ${cfg.file}): ${prog} library add <name> <folder>`);
|
|
74
|
-
for (const s of scanAll(cfg)) {
|
|
75
|
-
console.log(`${s.name} ${s.root} (${s.projects.length} projects)`);
|
|
76
|
-
for (const p of s.projects) {
|
|
77
|
-
const st = readBakeState(p.dir);
|
|
78
|
-
const status = !st ? 'not baked' : !st.ok ? 'bake failed' : isStale(p) ? 'stale' : 'baked';
|
|
79
|
-
console.log(` ${p.id.padEnd(24)} ${p.rel.padEnd(32)} ${status}${p.manifest.tags.length ? ' [' + p.manifest.tags.join(', ') + ']' : ''}`);
|
|
80
|
-
}
|
|
81
|
-
for (const pr of s.problems)
|
|
82
|
-
console.log(` ! ${pr}`);
|
|
83
|
-
}
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (sub === 'new') {
|
|
87
|
-
if (!a || !b)
|
|
88
|
-
fail(usage);
|
|
89
|
-
const lib = cfg.libraries.find((l) => l.name === a) ?? fail(`no library "${a}" (${cfg.libraries.map((l) => l.name).join(', ') || `none: ${prog} library add <name> <folder>`})`);
|
|
90
|
-
try {
|
|
91
|
-
const p = createProject(lib, b, { title: opt('--title'), description: opt('--description'), tags: opt('--tags')?.split(',').map((t) => t.trim()).filter(Boolean) });
|
|
92
|
-
console.log(`project ${p.lib}/${p.id} → ${p.dir}`);
|
|
93
|
-
console.log(` gallery: http://127.0.0.1:${cfg.gallery.port}/p/${p.lib}/${p.id}`);
|
|
94
|
-
}
|
|
95
|
-
catch (e) {
|
|
96
|
-
fail(e.message);
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (sub === 'bake') {
|
|
101
|
-
if (!a)
|
|
102
|
-
fail(usage);
|
|
103
|
-
const { bakeProject } = await import('./bake.js');
|
|
104
|
-
let dirs;
|
|
105
|
-
if (a === '--all' || a === '--stale')
|
|
106
|
-
dirs = scanAll(cfg).flatMap((s) => s.projects).filter((p) => a === '--all' || isStale(p)).map((p) => p.dir);
|
|
107
|
-
else {
|
|
108
|
-
const d = projectDirOf(a);
|
|
109
|
-
if (!d)
|
|
110
|
-
fail(`${a}: no project.json here or in a parent folder`);
|
|
111
|
-
dirs = [d];
|
|
112
|
-
}
|
|
113
|
-
let failed = 0;
|
|
114
|
-
for (const d of dirs) {
|
|
115
|
-
const s = await bakeProject(d);
|
|
116
|
-
if (!s.ok)
|
|
117
|
-
failed++;
|
|
118
|
-
console.log(`${s.ok ? 'ok ' : 'FAIL'} ${d} ${s.ok ? `${s.ms} ms, ${s.points} points, ${s.prims} prims${s.glb ? '' : ', no preview.glb'}` : s.error}`);
|
|
119
|
-
}
|
|
120
|
-
if (!dirs.length)
|
|
121
|
-
console.log('nothing to bake');
|
|
122
|
-
process.exit(failed ? 1 : 0);
|
|
123
|
-
}
|
|
124
|
-
fail(usage);
|
|
125
|
-
}
|
|
126
|
-
/** `edit <project>`: the live viewer on a project's workspace, following changes other processes make to it. */
|
|
127
|
-
export async function editCommand(argv, prog) {
|
|
128
|
-
const opt = (f) => { const i = argv.indexOf(f); return i >= 0 ? argv[i + 1] : undefined; };
|
|
129
|
-
const dir = argv[0] && !argv[0].startsWith('-') ? projectDirOf(argv[0]) ?? path.resolve(argv[0]) : fail(`usage: ${prog} edit <project folder> [--port 7341] [--json]`);
|
|
130
|
-
if (!fs.existsSync(dir))
|
|
131
|
-
fail(`no folder ${dir}`);
|
|
132
|
-
const { Engine } = await import('../graph/engine.js');
|
|
133
|
-
const { createNodeHost } = await import('../host/node.js');
|
|
134
|
-
const { Workspace } = await import('../workspace.js');
|
|
135
|
-
const { startViewer } = await import('../viewer/server.js');
|
|
136
|
-
const engine = new Engine(createNodeHost({ baseDir: dir }));
|
|
137
|
-
await engine.init();
|
|
138
|
-
const ws = new Workspace(dir, engine);
|
|
139
|
-
ws.load();
|
|
140
|
-
ws.watch();
|
|
141
|
-
const v = await startViewer(ws, opt('--port') !== undefined ? Number(opt('--port')) : undefined);
|
|
142
|
-
if (argv.includes('--json')) {
|
|
143
|
-
// started by the gallery: report the URL, and stop once no page has been open for a while
|
|
144
|
-
console.log(JSON.stringify({ url: v.url }));
|
|
145
|
-
let idleSince = Date.now();
|
|
146
|
-
setInterval(() => {
|
|
147
|
-
if (v.clients() > 0)
|
|
148
|
-
idleSince = Date.now();
|
|
149
|
-
else if (Date.now() - idleSince > 10 * 60_000) {
|
|
150
|
-
v.close();
|
|
151
|
-
process.exit(0);
|
|
152
|
-
}
|
|
153
|
-
}, 30_000);
|
|
154
|
-
}
|
|
155
|
-
else
|
|
156
|
-
console.log(`edit: ${v.url} (${dir}; Ctrl+C to stop)`);
|
|
157
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/** Bumped when the baked files change shape (render options, GLB options), so every project bakes again. */
|
|
2
|
-
export declare const BAKE_VERSION = 1;
|
|
3
|
-
export declare const DEFAULT_PORT = 7340;
|
|
4
|
-
/** a library name or project id: lower-case letters, digits, "-" and "_", starting with a letter or digit */
|
|
5
|
-
export declare const ID_RE: RegExp;
|
|
6
|
-
export interface LibraryRef {
|
|
7
|
-
name: string;
|
|
8
|
-
path: string;
|
|
9
|
-
}
|
|
10
|
-
export interface GalleryConfig {
|
|
11
|
-
/** the config file read (or the one `library add` writes) */
|
|
12
|
-
file: string;
|
|
13
|
-
libraries: LibraryRef[];
|
|
14
|
-
gallery: {
|
|
15
|
-
port: number;
|
|
16
|
-
cors: string[];
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export interface ProjectLink {
|
|
20
|
-
label: string;
|
|
21
|
-
url: string;
|
|
22
|
-
}
|
|
23
|
-
export interface ProjectManifest {
|
|
24
|
-
id: string;
|
|
25
|
-
title: string;
|
|
26
|
-
description: string;
|
|
27
|
-
tags: string[];
|
|
28
|
-
/** the graph the gallery shows and bakes */
|
|
29
|
-
graph: string;
|
|
30
|
-
/** what to bake instead of the graph's output: another graph, a node, a frame (simulations settle after frame 1) */
|
|
31
|
-
bake: {
|
|
32
|
-
graph?: string;
|
|
33
|
-
node?: string;
|
|
34
|
-
frame?: number;
|
|
35
|
-
};
|
|
36
|
-
/** links back to the board, concept pages, tickets */
|
|
37
|
-
links: ProjectLink[];
|
|
38
|
-
/** ISO date */
|
|
39
|
-
created: string;
|
|
40
|
-
}
|
|
41
|
-
export interface BakeState {
|
|
42
|
-
key: string;
|
|
43
|
-
/** ms since the epoch */
|
|
44
|
-
at: number;
|
|
45
|
-
ok: boolean;
|
|
46
|
-
error?: string;
|
|
47
|
-
ms?: number;
|
|
48
|
-
/** preview.glb was written (false: too large, or the bake failed before it) */
|
|
49
|
-
glb?: boolean;
|
|
50
|
-
points?: number;
|
|
51
|
-
prims?: number;
|
|
52
|
-
warnings?: string[];
|
|
53
|
-
}
|
|
54
|
-
export interface Project {
|
|
55
|
-
lib: string;
|
|
56
|
-
id: string;
|
|
57
|
-
/** absolute folder */
|
|
58
|
-
dir: string;
|
|
59
|
-
/** posix path of the folder relative to the library root */
|
|
60
|
-
rel: string;
|
|
61
|
-
/** the parent folders' path ("" at the top), how the gallery groups projects */
|
|
62
|
-
collection: string;
|
|
63
|
-
manifest: ProjectManifest;
|
|
64
|
-
/** newest change to project.json, graphs/ or assets/ (ms) */
|
|
65
|
-
updated: number;
|
|
66
|
-
}
|
|
67
|
-
export interface LibraryScan {
|
|
68
|
-
name: string;
|
|
69
|
-
root: string;
|
|
70
|
-
projects: Project[];
|
|
71
|
-
problems: string[];
|
|
72
|
-
}
|
|
73
|
-
export declare const slugify: (s: string) => string;
|
|
74
|
-
export declare function configFile(): string;
|
|
75
|
-
/** The user's config with defaults filled in; libraries from $TOPOTOPO_LIBRARIES come after the file's. */
|
|
76
|
-
export declare function loadConfig(): GalleryConfig;
|
|
77
|
-
/** Add (or re-point) a library in the config file, keeping its other keys. */
|
|
78
|
-
export declare function addLibrary(name: string, dir: string): GalleryConfig;
|
|
79
|
-
/** project.json checked and normalised; throws naming the problem. `fallbackId` is used when it has no id. */
|
|
80
|
-
export declare function parseManifest(raw: any, fallbackId: string): ProjectManifest;
|
|
81
|
-
export declare const manifestFile: (dir: string) => string;
|
|
82
|
-
export declare function readManifest(dir: string): ProjectManifest;
|
|
83
|
-
/** Write a manifest (atomically), keeping keys of the file this version does not know. */
|
|
84
|
-
export declare function writeManifest(dir: string, m: ProjectManifest): void;
|
|
85
|
-
/** Written as a dot-file next to the target and renamed, so readers never see half a file. */
|
|
86
|
-
export declare function writeAtomic(file: string, data: string | Uint8Array): void;
|
|
87
|
-
/** Every project below a library root, sorted by path. Ids used twice: the first path keeps it, the others are problems. */
|
|
88
|
-
export declare function scanLibrary(lib: LibraryRef): LibraryScan;
|
|
89
|
-
export declare function scanAll(cfg?: GalleryConfig): LibraryScan[];
|
|
90
|
-
/** The project a folder belongs to (the folder itself, or the nearest parent with a project.json), or null. */
|
|
91
|
-
export declare function projectDirOf(start: string): string | null;
|
|
92
|
-
export interface CreateOptions {
|
|
93
|
-
title?: string;
|
|
94
|
-
description?: string;
|
|
95
|
-
tags?: string[];
|
|
96
|
-
links?: ProjectLink[];
|
|
97
|
-
graph?: object;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* A new project at `<library root>/<rel>` ("props/lantern"): project.json, the workspace folders, attachments/, and a
|
|
101
|
-
* .gitignore for the derived files. `graph` (a graph spec) becomes graphs/main.json. Fails when the folder holds a
|
|
102
|
-
* project already or the id is taken in the library.
|
|
103
|
-
*/
|
|
104
|
-
export declare function createProject(lib: LibraryRef, rel: string, o?: CreateOptions): Project;
|
|
105
|
-
export interface ProjectFile {
|
|
106
|
-
path: string;
|
|
107
|
-
size: number;
|
|
108
|
-
mtime: number;
|
|
109
|
-
image: boolean;
|
|
110
|
-
}
|
|
111
|
-
/** Files under a project subfolder (attachments/, exports/), recursively: posix paths, dot-files skipped. */
|
|
112
|
-
export declare function listFiles(dir: string): ProjectFile[];
|
|
113
|
-
export declare const graphNames: (dir: string) => string[];
|
|
114
|
-
/** A project's graph file, parsed (null when missing or unreadable). */
|
|
115
|
-
export declare function readGraph(dir: string, name: string): any;
|
|
116
|
-
export declare const galleryDir: (dir: string) => string;
|
|
117
|
-
/**
|
|
118
|
-
* What a bake depends on: the bake version, the package version, the manifest's graph and bake choice, every graph
|
|
119
|
-
* and asset file's content, and each input file's path, size and time.
|
|
120
|
-
*/
|
|
121
|
-
export declare function bakeKey(dir: string, m: ProjectManifest): string;
|
|
122
|
-
export declare function readBakeState(dir: string): BakeState | null;
|
|
123
|
-
/** The project needs a bake: never baked, or something it depends on changed since. */
|
|
124
|
-
export declare function isStale(p: Project): boolean;
|