topotopo 0.4.0 → 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.
- package/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +323 -146
- 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 +196 -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 +44 -5
- package/dist/render/preview.d.ts +15 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +66 -5
- package/dist/render/raster.js +506 -138
- 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 +17 -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,5 +1,7 @@
|
|
|
1
|
-
// Baking a
|
|
2
|
-
//
|
|
1
|
+
// Baking a package's previews: .web/thumb.png (512 px matcap, or the graph's meta.thumbnail_render: a "pbr" one
|
|
2
|
+
// renders through the asynchronous entry, which loads MikkTSpace and the textures itself) and .web/preview.glb
|
|
3
|
+
// (meshopt), plus
|
|
4
|
+
// .web/bake.json recording the bake key they were made from. The web app never cooks in its own process (cooks
|
|
3
5
|
// block the event loop and cannot be cancelled): BakeQueue runs `topotopo library bake <dir>` children one at a time,
|
|
4
6
|
// with a shorter simulation limit, a hard time limit and a low priority. A failed bake keeps the previous files.
|
|
5
7
|
import fs from 'node:fs';
|
|
@@ -11,9 +13,12 @@ import { fileURLToPath } from 'node:url';
|
|
|
11
13
|
import '../nodes/index.js';
|
|
12
14
|
import { Engine } from '../graph/engine.js';
|
|
13
15
|
import { createNodeHost } from '../host/node.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { previewGLB, thumbOptions } from '../render/preview.js';
|
|
17
|
+
import { renderGeometryAsync } from '../render/raster.js';
|
|
18
|
+
import { encodePNG } from '../render/png.js';
|
|
19
|
+
import { bakeKey, webDir, readBakeState } from './library.js';
|
|
20
|
+
import { readManifest, writeAtomic } from '../package.js';
|
|
21
|
+
import { openPackage } from '../open.js';
|
|
17
22
|
export const THUMB_SIZE = 512;
|
|
18
23
|
/** a preview.glb above this is not written (the page shows the thumbnail instead) */
|
|
19
24
|
export const MAX_PREVIEW_GLB = 50 * 1024 * 1024;
|
|
@@ -21,11 +26,11 @@ export const MAX_PREVIEW_GLB = 50 * 1024 * 1024;
|
|
|
21
26
|
export const BAKE_TIMEOUT_MS = 300_000;
|
|
22
27
|
/** the simulation limit inside a bake child (the engine's default is 600 s per node) */
|
|
23
28
|
export const BAKE_SIM_TIMEOUT_MS = 120_000;
|
|
24
|
-
/** Bake one
|
|
25
|
-
export async function
|
|
29
|
+
/** Bake one package in this process. Never throws for a graph problem: the result (also in bake.json) says. */
|
|
30
|
+
export async function bakePackage(dir) {
|
|
26
31
|
const m = readManifest(dir);
|
|
27
32
|
const key = bakeKey(dir, m);
|
|
28
|
-
const out =
|
|
33
|
+
const out = webDir(dir);
|
|
29
34
|
fs.mkdirSync(out, { recursive: true });
|
|
30
35
|
const t0 = performance.now();
|
|
31
36
|
const finish = (s) => {
|
|
@@ -40,16 +45,20 @@ export async function bakeProject(dir) {
|
|
|
40
45
|
if (process.env.TOPOTOPO_SCRIPT_TIMEOUT_MS)
|
|
41
46
|
engine.scriptTimeoutMs = Number(process.env.TOPOTOPO_SCRIPT_TIMEOUT_MS);
|
|
42
47
|
await engine.init();
|
|
43
|
-
|
|
44
|
-
ws
|
|
48
|
+
// the packages it uses, from its copies (a bake adds none), its graphs and its assets
|
|
49
|
+
const ws = openPackage(engine, dir).session;
|
|
45
50
|
const name = m.bake.graph ?? m.graph;
|
|
46
51
|
const g = ws.graphs.get(name);
|
|
47
52
|
if (!g)
|
|
48
|
-
return finish({ ok: false, error: `no graph "${name}"
|
|
53
|
+
return finish({ ok: false, error: `no default graph yet: the package has no graph "${name}" (its manifest's "graph")` });
|
|
49
54
|
const r = await engine.cook(g, { target: m.bake.node, frame: m.bake.frame });
|
|
50
55
|
if (!r.ok || !r.geo)
|
|
51
56
|
return finish({ ok: false, error: r.errors.map((e) => `[${e.node}] ${e.message}`).join('\n') || 'the cook gave no geometry' });
|
|
52
|
-
|
|
57
|
+
// the asynchronous render: shading "pbr" needs MikkTSpace and the material's textures, which it loads (a package
|
|
58
|
+
// needs no preload script of its own)
|
|
59
|
+
const img = await renderGeometryAsync(r.geo, thumbOptions(g, THUMB_SIZE), (p) => engine.host.readFile(p));
|
|
60
|
+
const side = img.width; // a single square view tile sits above the footer
|
|
61
|
+
writeAtomic(path.join(out, 'thumb.png'), encodePNG(img.rgba.subarray(0, side * side * 4), side, side, (d) => zlib.deflateSync(d, { level: 9 })));
|
|
53
62
|
const glb = await previewGLB(r.geo, { compress: 'meshopt' });
|
|
54
63
|
const small = glb.length <= MAX_PREVIEW_GLB;
|
|
55
64
|
if (small)
|
|
@@ -67,7 +76,7 @@ export async function bakeProject(dir) {
|
|
|
67
76
|
}
|
|
68
77
|
// ------------------------------------------------------------------------------------------------------ BakeQueue
|
|
69
78
|
const cli = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', import.meta.url.endsWith('.ts') ? 'cli.ts' : 'cli.js');
|
|
70
|
-
/** Bakes in child processes, one at a time, each
|
|
79
|
+
/** Bakes in child processes, one at a time, each package once however often it is asked for meanwhile. */
|
|
71
80
|
export class BakeQueue {
|
|
72
81
|
queue = [];
|
|
73
82
|
running = null;
|
|
@@ -129,8 +138,8 @@ export class BakeQueue {
|
|
|
129
138
|
const why = signal ? `stopped after ${((Date.now() - t0) / 1000).toFixed(0)} s (the bake time limit is ${(this.opts.timeoutMs ?? BAKE_TIMEOUT_MS) / 1000} s)` : `the bake process failed (exit ${code}): ${stderr.trim().split('\n').slice(-3).join(' ')}`;
|
|
130
139
|
try {
|
|
131
140
|
state = { key: bakeKey(dir, readManifest(dir)), at: Date.now(), ok: false, error: why };
|
|
132
|
-
fs.mkdirSync(
|
|
133
|
-
writeAtomic(path.join(
|
|
141
|
+
fs.mkdirSync(webDir(dir), { recursive: true });
|
|
142
|
+
writeAtomic(path.join(webDir(dir), 'bake.json'), JSON.stringify(state, null, 1) + '\n');
|
|
134
143
|
}
|
|
135
144
|
catch {
|
|
136
145
|
state = null;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { PackageData, Urls } from './pages.ts';
|
|
2
|
+
import type { FileKind, Flag } from './folders.ts';
|
|
3
|
+
/** A subfolder as a card. */
|
|
4
|
+
export interface FolderCard {
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
/** a plain folder, a package (it holds a .topo), an engine project (opens on demand, never audited), another workspace */
|
|
8
|
+
kind: 'folder' | 'package' | 'engine' | 'workspace';
|
|
9
|
+
/** the package's title, the engine project's name, else the folder's name */
|
|
10
|
+
title: string;
|
|
11
|
+
/** what is in it: "12 files · 3 folders", "Godot project" */
|
|
12
|
+
sub: string;
|
|
13
|
+
thumb?: string;
|
|
14
|
+
/** the flags in it and below it */
|
|
15
|
+
flags: number;
|
|
16
|
+
/** the packages in it and below it (a plain folder) */
|
|
17
|
+
packages: number;
|
|
18
|
+
/** a package's full name and newest version */
|
|
19
|
+
pkg?: {
|
|
20
|
+
name: string;
|
|
21
|
+
version: string | null;
|
|
22
|
+
};
|
|
23
|
+
/** a package's preview status ('failed' …) */
|
|
24
|
+
status?: string;
|
|
25
|
+
/** a plain folder with nothing in it: listed in one line, not as a card */
|
|
26
|
+
empty?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface FileItem {
|
|
29
|
+
name: string;
|
|
30
|
+
url: string;
|
|
31
|
+
size: number;
|
|
32
|
+
mtime: number;
|
|
33
|
+
kind: FileKind;
|
|
34
|
+
/** a model's 3D view */
|
|
35
|
+
model?: string;
|
|
36
|
+
/** an export TopoTopo made: its graph and output, and whether the graph changed since */
|
|
37
|
+
made?: {
|
|
38
|
+
graph: string;
|
|
39
|
+
output: string | null;
|
|
40
|
+
stale: boolean | null;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface NoteBox {
|
|
44
|
+
name: string;
|
|
45
|
+
id: string;
|
|
46
|
+
url: string;
|
|
47
|
+
html: string;
|
|
48
|
+
/** too large to show: linked only */
|
|
49
|
+
long: boolean;
|
|
50
|
+
/** the note a link asked for (?note=): shown whole */
|
|
51
|
+
asked?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface FolderPageData {
|
|
54
|
+
root: {
|
|
55
|
+
kind: string;
|
|
56
|
+
name: string;
|
|
57
|
+
label: string;
|
|
58
|
+
};
|
|
59
|
+
/** posix path from the root ('' for the root) */
|
|
60
|
+
rel: string;
|
|
61
|
+
crumbs: {
|
|
62
|
+
name: string;
|
|
63
|
+
url: string;
|
|
64
|
+
}[];
|
|
65
|
+
/** what the folder is, above its name: "Workspace · Godot · My Game", "Package", "Folder" */
|
|
66
|
+
kicker: string;
|
|
67
|
+
title: string;
|
|
68
|
+
/** the folder's own files and folders, in a line */
|
|
69
|
+
stats: string;
|
|
70
|
+
dir: string;
|
|
71
|
+
/** its own flags */
|
|
72
|
+
flags: Flag[];
|
|
73
|
+
/** the flags of its subfolders, by folder */
|
|
74
|
+
below: {
|
|
75
|
+
at: string;
|
|
76
|
+
url: string;
|
|
77
|
+
flags: Flag[];
|
|
78
|
+
}[];
|
|
79
|
+
/** a word on the folder: an engine project is browsable and not audited, a package outside the scan … */
|
|
80
|
+
notice?: string;
|
|
81
|
+
notes: NoteBox[];
|
|
82
|
+
/** the notes not shown as boxes (listed with the other files) */
|
|
83
|
+
moreNotes: number;
|
|
84
|
+
folders: FolderCard[];
|
|
85
|
+
files: FileItem[];
|
|
86
|
+
/** Unreal's .uasset and .umap files here */
|
|
87
|
+
engineAssets: number;
|
|
88
|
+
package: PackageData | null;
|
|
89
|
+
/** a workspace's root: the one version of each package its packages use */
|
|
90
|
+
uses?: PackageData['uses'];
|
|
91
|
+
/** a root whose audit stopped short: where, in words */
|
|
92
|
+
cut?: string[];
|
|
93
|
+
/** what the page script needs: the root and folder (live updates), the package shown */
|
|
94
|
+
live: {
|
|
95
|
+
root: string;
|
|
96
|
+
rel: string;
|
|
97
|
+
package?: string;
|
|
98
|
+
reveal: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export declare function folderPage(d: FolderPageData, u: Urls): string;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// A folder page of the web app (/w/<workspace>/<path…>/, /l/<library>/<path…>/): the folder's flags, its package when
|
|
2
|
+
// it is one (src/web/pages.ts packageBlock, packageCols, packageEnd: the package in one piece), its notes as boxes (kept
|
|
3
|
+
// short when pictures, folders or a package come after them; one note with pictures beside it on a wide screen), a card
|
|
4
|
+
// per subfolder (the empty ones as one line of links) and its files by type: images to view large, audio and video in
|
|
5
|
+
// players, models in 3D on a click, the rest to open or download. A pure function of its data (src/web/server.ts
|
|
6
|
+
// gathers it, src/web/folders.ts reads the folder) and a URL builder.
|
|
7
|
+
import { count, esc, flagBadge, mosaic, packageBlock, packageCols, packageEnd, shell, size, usesSection, when } from './pages.js';
|
|
8
|
+
/** Each flag's chip: what is wrong, in two words. */
|
|
9
|
+
const FLAG_WORD = { link: 'broken link', bake: 'bake failed', publish: 'unpublished', export: 'stale export', unused: 'unused outputs', workspace: 'workspace' };
|
|
10
|
+
function flagList(flags) {
|
|
11
|
+
return `<ul class="flaglist">${flags.map((f) => `<li class="flag f-${esc(f.kind)}"><span class="fkind">${esc(FLAG_WORD[f.kind] ?? f.kind)}</span><span class="fwhat">${esc(f.what)}</span><span class="ftodo">${esc(f.todo)}</span></li>`).join('')}</ul>`;
|
|
12
|
+
}
|
|
13
|
+
/** Flags by kind in words: "4 broken links, 2 exports". */
|
|
14
|
+
function kinds(flags) {
|
|
15
|
+
const n = new Map();
|
|
16
|
+
for (const f of flags)
|
|
17
|
+
n.set(f.kind, (n.get(f.kind) ?? 0) + 1);
|
|
18
|
+
const word = { link: ['broken link', 'broken links'], bake: ['preview that did not cook', 'previews that did not cook'], publish: ['package to publish', 'packages to publish'], export: ['export older than its graph', 'exports older than their graph'], unused: ['package with unused outputs', 'packages with unused outputs'], workspace: ['workspace problem', 'workspace problems'] };
|
|
19
|
+
return [...n].map(([k, c]) => `${c} ${(word[k] ?? [k, k])[c === 1 ? 0 : 1]}`).join(', ');
|
|
20
|
+
}
|
|
21
|
+
function flagsSection(d) {
|
|
22
|
+
const below = d.below.reduce((n, b) => n + b.flags.length, 0);
|
|
23
|
+
if (!d.flags.length && !below)
|
|
24
|
+
return '';
|
|
25
|
+
const all = d.below.flatMap((b) => b.flags);
|
|
26
|
+
return `<section class="flags" aria-label="Flags">
|
|
27
|
+
<h2>${esc(count(d.flags.length + below, 'flag'))}${below && d.flags.length ? ` <span class="count">${esc(`${d.flags.length} here, ${below} in its folders`)}</span>` : below ? ' <span class="count">in its folders</span>' : ''}</h2>
|
|
28
|
+
${d.flags.length ? flagList(d.flags) : ''}
|
|
29
|
+
${below ? `<details class="below"${d.flags.length || below > 6 ? '' : ' open'}><summary>${esc(count(below, 'flag'))} in ${esc(count(d.below.length, 'folder'))} below: ${esc(kinds(all))}</summary>
|
|
30
|
+
${d.below.map((b) => `<div class="fgroup"><a class="fat" href="${esc(b.url)}">${esc(b.at)}</a>${flagList(b.flags.slice(0, 20))}${b.flags.length > 20 ? `<p class="dim small">and ${b.flags.length - 20} more: <a href="${esc(b.url)}">open the folder</a></p>` : ''}</div>`).join('')}
|
|
31
|
+
</details>` : ''}
|
|
32
|
+
</section>`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The notes as boxes. Three or more fold shorter, and so do notes with pictures, folders or a package after them
|
|
36
|
+
* (`short`): the page stays an overview, each note a click from whole.
|
|
37
|
+
*/
|
|
38
|
+
function notesSection(d, short) {
|
|
39
|
+
if (!d.notes.length)
|
|
40
|
+
return '';
|
|
41
|
+
return `<section class="notes${d.notes.length >= 3 ? ' many' : d.notes.length === 1 ? ' one' : ''}${short ? ' short' : ''}" aria-label="Notes">
|
|
42
|
+
${d.notes.map((n) => `<article class="note${n.asked ? ' open' : ''}" id="${esc(n.id)}">
|
|
43
|
+
<header><a href="${esc(n.url)}" target="_blank" rel="noopener">${esc(n.name)}</a></header>
|
|
44
|
+
${n.long ? `<p class="dim">Too long to show here: <a href="${esc(n.url)}" target="_blank" rel="noopener">open ${esc(n.name)}</a>.</p>` : `<div class="md${/\.txt$/i.test(n.name) ? ' txt' : ''}">${n.html}</div>`}
|
|
45
|
+
<button class="more" type="button" hidden>${n.asked ? 'Show less' : 'Show all'}</button>
|
|
46
|
+
</article>`).join('\n')}
|
|
47
|
+
${d.moreNotes ? `<p class="dim small morenotes">${esc(count(d.moreNotes, 'more note'))} of this folder ${d.moreNotes === 1 ? 'is' : 'are'} listed with its other files.</p>` : ''}
|
|
48
|
+
</section>`;
|
|
49
|
+
}
|
|
50
|
+
function folderCard(c) {
|
|
51
|
+
// a folder without a picture: a folder, a package's cube, the engine's name
|
|
52
|
+
const pic = c.thumb ? mosaic([c.thumb], '') : c.kind === 'engine' ? `<span class="mosaic m0 engine"><span class="mono">${c.sub.startsWith('Unreal') ? 'Unreal' : 'Godot'}</span></span>` : `<span class="mosaic m0 icon ${c.kind === 'package' ? 'cube' : 'dir'}"></span>`;
|
|
53
|
+
return `<a class="fcard k-${esc(c.kind)}" href="${esc(c.url)}">
|
|
54
|
+
${pic}
|
|
55
|
+
<span class="fbody">
|
|
56
|
+
<span class="ftitle">${esc(c.title)}</span>
|
|
57
|
+
${c.title !== c.name ? `<span class="fname">${esc(c.name)}/</span>` : ''}
|
|
58
|
+
<span class="fsub">${esc(c.sub)}</span>
|
|
59
|
+
${c.pkg ? `<span class="pkg">${esc(c.pkg.name)}${c.pkg.version ? ` ${esc(c.pkg.version)}` : ''}</span>` : ''}
|
|
60
|
+
<span class="fmarks">${c.kind === 'package' ? '<span class="kindmark">package</span>' : c.packages ? `<span class="kindmark">${esc(count(c.packages, 'package'))}</span>` : ''}${c.status === 'failed' ? '<span class="status s-failed">bake failed</span>' : ''}${flagBadge(c.flags)}</span>
|
|
61
|
+
</span>
|
|
62
|
+
</a>`;
|
|
63
|
+
}
|
|
64
|
+
/** The folder's images as tiles. */
|
|
65
|
+
function imagesPart(images) {
|
|
66
|
+
return images.length ? `<h2>Images <span class="count">${images.length}</span></h2>
|
|
67
|
+
<div class="igrid${images.length <= 4 ? ' few' : ''}">${images.map((f) => `<a class="tile" href="${esc(f.url)}" data-view="image" data-name="${esc(f.name)}" title="${esc(`${f.name} · ${size(f.size)}`)}"><img src="${esc(f.url)}" alt="" loading="lazy" decoding="async"><span>${esc(f.name)}</span></a>`).join('')}</div>` : '';
|
|
68
|
+
}
|
|
69
|
+
/** The folder's files by type (`withImages`: its images too, unless they stand beside its note). */
|
|
70
|
+
function filesSection(d, u, withImages) {
|
|
71
|
+
const by = (k) => d.files.filter((f) => f.kind === k);
|
|
72
|
+
const images = by('image'), audio = by('audio'), video = by('video'), models = by('model'), other = by('other');
|
|
73
|
+
const made = (f) => (f.made ? `<span class="made" title="${esc(`exported from graph "${f.made.graph}"${f.made.output ? `, output "${f.made.output}"` : ''}`)}">from ${esc(f.made.graph)}${f.made.output ? ` · ${esc(f.made.output)}` : ''}</span>${f.made.stale ? '<span class="stale" title="its graph changed since it was exported">older than its graph</span>' : ''}` : '');
|
|
74
|
+
const parts = [];
|
|
75
|
+
if (withImages && images.length)
|
|
76
|
+
parts.push(imagesPart(images));
|
|
77
|
+
if (audio.length) {
|
|
78
|
+
// a few sounds load their length at once (shown beside their size); a folder of hundreds loads each when it is played
|
|
79
|
+
const preload = audio.length > 40 ? 'none' : 'metadata';
|
|
80
|
+
parts.push(`<h2>Sounds <span class="count">${audio.length}</span></h2>
|
|
81
|
+
<div class="alist">${audio.map((f) => `<div class="arow"><span class="aname" title="${esc(f.name)}"><span class="ax">${esc(ext(f.name))}</span>${esc(f.name.replace(/\.[^.]+$/, ''))}</span><audio controls preload="${preload}" src="${esc(f.url)}"></audio><span class="adur" title="length"></span><span class="asize">${esc(size(f.size))}</span><a class="dl" href="${esc(f.url)}?download" title="download ${esc(f.name)}" aria-label="download ${esc(f.name)}">download</a></div>`).join('')}</div>`);
|
|
82
|
+
}
|
|
83
|
+
if (video.length) {
|
|
84
|
+
const preload = video.length > 12 ? 'none' : 'metadata';
|
|
85
|
+
parts.push(`<h2>Videos <span class="count">${video.length}</span></h2>
|
|
86
|
+
<div class="vgrid">${video.map((f) => `<figure class="vtile"><video controls preload="${preload}" src="${esc(f.url)}"></video><figcaption><span title="${esc(f.name)}">${esc(f.name)}</span><span class="dim">${esc(size(f.size))}</span></figcaption></figure>`).join('')}</div>`);
|
|
87
|
+
}
|
|
88
|
+
if (models.length) {
|
|
89
|
+
parts.push(`<h2>Models <span class="count">${models.length}</span></h2>
|
|
90
|
+
<div class="mgrid">${models.map((f) => `<button type="button" class="mtile" data-view="model" data-src="${esc(f.model ?? '')}" data-name="${esc(f.name)}"><span class="cube"></span><span class="mname">${esc(f.name)}</span><span class="dim small">${esc(size(f.size))} · View in 3D</span>${made(f)}</button>`).join('')}</div>`);
|
|
91
|
+
}
|
|
92
|
+
if (other.length || d.engineAssets) {
|
|
93
|
+
parts.push(`<h2>Other files <span class="count">${other.length}</span></h2>
|
|
94
|
+
${other.length ? `<div class="table"><table class="ftable"><tbody>${other.map((f) => `<tr><td class="fn"><a href="${esc(f.url)}" target="_blank" rel="noopener">${esc(f.name)}</a>${made(f)}</td><td class="fx">${esc(ext(f.name))}</td><td class="fs">${esc(size(f.size))}</td><td class="fd">${esc(when(f.mtime))}</td><td class="fdl"><a class="dl" href="${esc(f.url)}?download" title="download" aria-label="download ${esc(f.name)}">download</a></td></tr>`).join('')}</tbody></table></div>` : ''}
|
|
95
|
+
${d.engineAssets ? `<p class="engassets">${esc(count(d.engineAssets, 'Unreal asset'))} (.uasset, .umap): the engine's own files, opened in Unreal</p>` : ''}`);
|
|
96
|
+
}
|
|
97
|
+
return parts.length ? `<section class="files" aria-label="Files">${parts.join('\n')}</section>` : '';
|
|
98
|
+
}
|
|
99
|
+
const ext = (n) => { const i = n.lastIndexOf('.'); return i > 0 ? n.slice(i + 1).toLowerCase() : ''; };
|
|
100
|
+
/** The subfolders as cards; the empty ones as one line of links after them. */
|
|
101
|
+
function foldersSection(d) {
|
|
102
|
+
if (!d.folders.length)
|
|
103
|
+
return '';
|
|
104
|
+
const empty = d.folders.filter((f) => f.empty && !f.flags && !f.packages), cards = d.folders.filter((f) => !empty.includes(f));
|
|
105
|
+
return `<section class="folders" aria-label="Folders"><h2>Folders <span class="count">${d.folders.length}${empty.length ? ` · ${empty.length} empty` : ''}</span></h2>
|
|
106
|
+
${cards.length ? `<div class="fgrid">${cards.map(folderCard).join('\n')}</div>` : ''}
|
|
107
|
+
${empty.length ? `<p class="empties"><span class="dim">Empty:</span> ${empty.map((f) => `<a href="${esc(f.url)}">${esc(f.name)}</a>`).join('<span class="dim">, </span>')}</p>` : ''}
|
|
108
|
+
</section>`;
|
|
109
|
+
}
|
|
110
|
+
export function folderPage(d, u) {
|
|
111
|
+
const crumbs = d.crumbs.map((c, i) => (i === d.crumbs.length - 1 ? `<span aria-current="page">${esc(c.name)}</span>` : `<a href="${esc(c.url)}">${esc(c.name)}</a>`)).join('<span class="sep">/</span>');
|
|
112
|
+
const empty = !d.notes.length && !d.folders.length && !d.files.length && !d.engineAssets && !d.package;
|
|
113
|
+
const images = d.files.filter((f) => f.kind === 'image');
|
|
114
|
+
// one note and pictures: the pictures beside the note on a wide screen; notes before pictures, folders or a
|
|
115
|
+
// package's attachments stay short
|
|
116
|
+
const split = d.notes.length === 1 && images.length > 0 && !d.package;
|
|
117
|
+
const short = images.length > 0 || d.folders.length > 0 || !!d.package;
|
|
118
|
+
const notes = split ? `<div class="split">${notesSection(d, short)}<section class="files side" aria-label="Images">${imagesPart(images)}</section></div>` : notesSection(d, short);
|
|
119
|
+
return shell(`${d.title} · TopoTopo`, u, `<header class="bar">
|
|
120
|
+
<a class="brand" href="${esc(u.home)}"><b>TopoTopo</b></a>
|
|
121
|
+
<nav class="crumbs" aria-label="Folders">${crumbs}</nav>
|
|
122
|
+
<button class="btn ghost" type="button" data-reveal title="open this folder in your file manager">Show folder</button>
|
|
123
|
+
</header>
|
|
124
|
+
<main class="wrap folder">
|
|
125
|
+
<div class="head">
|
|
126
|
+
<p class="kicker">${esc(d.kicker)}</p>
|
|
127
|
+
<h1>${esc(d.title)}</h1>
|
|
128
|
+
<p class="hstats">${esc(d.stats)}</p>
|
|
129
|
+
</div>
|
|
130
|
+
${d.notice ? `<p class="notice">${esc(d.notice)}</p>` : ''}
|
|
131
|
+
${d.cut?.length ? `<p class="notice cut">Audited in part, a very large tree: ${esc(d.cut.join('; '))}. Flags past that are not counted.</p>` : ''}
|
|
132
|
+
${flagsSection(d)}
|
|
133
|
+
${d.package ? packageBlock(d.package, u) + packageCols(d.package) : ''}
|
|
134
|
+
${notes}
|
|
135
|
+
${d.package ? packageEnd(d.package, u) : ''}
|
|
136
|
+
${foldersSection(d)}
|
|
137
|
+
${d.uses?.length ? `<section class="wsuses">${usesSection(d.uses)}</section>` : ''}
|
|
138
|
+
${filesSection(d, u, !split)}
|
|
139
|
+
${empty ? '<p class="empty">This folder is empty.</p>' : ''}
|
|
140
|
+
<p class="foot"><code>${esc(d.dir)}</code></p>
|
|
141
|
+
</main>
|
|
142
|
+
<dialog id="viewer" aria-label="View">
|
|
143
|
+
<div class="vbar"><span class="vname"></span><a class="vopen" target="_blank" rel="noopener">Open</a><button type="button" class="vprev" aria-label="previous">‹</button><button type="button" class="vnext" aria-label="next">›</button><button type="button" class="vclose" aria-label="close">✕</button></div>
|
|
144
|
+
<div class="vbody"></div>
|
|
145
|
+
</dialog>`, { page: 'folder', data: d.live });
|
|
146
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import type { EngineType } from '../engines.ts';
|
|
3
|
+
import type { LinkOut, MdLink } from './markdown.ts';
|
|
4
|
+
export type RootKind = 'w' | 'l';
|
|
5
|
+
/** A registered workspace ("w") or library ("l") as a tree of pages. */
|
|
6
|
+
export interface Root {
|
|
7
|
+
kind: RootKind;
|
|
8
|
+
/** its name in URLs: /w/<name>/, /l/<name>/ */
|
|
9
|
+
name: string;
|
|
10
|
+
/** absolute */
|
|
11
|
+
dir: string;
|
|
12
|
+
/** TopoTopo's built-in library */
|
|
13
|
+
builtin?: boolean;
|
|
14
|
+
/** the engine project its workspace file names (the project file, absolute) */
|
|
15
|
+
engine: {
|
|
16
|
+
type: EngineType;
|
|
17
|
+
file: string;
|
|
18
|
+
} | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const rootKey: (r: Pick<Root, 'kind' | 'name'>) => string;
|
|
21
|
+
export type FileKind = 'image' | 'audio' | 'video' | 'model' | 'note' | 'other';
|
|
22
|
+
export declare const kindOf: (name: string) => FileKind;
|
|
23
|
+
/** The media types files are served with; anything else is application/octet-stream. */
|
|
24
|
+
export declare const MIME_TYPES: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Why a folder named `name` is plumbing no page shows, or null: what the scan never enters (src/scan.ts: dot folders,
|
|
27
|
+
* node_modules, topotopo-packages, the engines' caches and build folders), and a package's versions/ and packages/.
|
|
28
|
+
* `parentFiles`: the files of the folder it is in, or a function that lists them (called only when they matter).
|
|
29
|
+
*/
|
|
30
|
+
export declare function plumbing(name: string, parentFiles: string[] | (() => string[])): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Where an existing `abs` really is below `top`, links and short names resolved (fs.realpathSync.native: a junction,
|
|
33
|
+
* a symlink, a Windows 8.3 name like GIT~1, the letter case on disk): its posix path from `top`, or why it is not shown
|
|
34
|
+
* (it leads out of `top`, or through a dot folder or plumbing by another name; `dotsOnly`: a dot name only).
|
|
35
|
+
*/
|
|
36
|
+
export declare function realBelow(top: string, abs: string, dotsOnly?: boolean): {
|
|
37
|
+
rel: string;
|
|
38
|
+
} | {
|
|
39
|
+
why: string;
|
|
40
|
+
out: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** File name order, numbers as numbers ("2-x" before "10-x"), case aside. */
|
|
43
|
+
export declare const byName: (a: string, b: string) => number;
|
|
44
|
+
export declare class PathError extends Error {
|
|
45
|
+
status: number;
|
|
46
|
+
constructor(status: number, msg: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The file or folder that URL path segments name below a root, or a PathError: each segment is percent-decoded and
|
|
50
|
+
* must be a plain name (no "", ".", "..", dot names, separators, NUL, and on Windows no ":" or reserved characters);
|
|
51
|
+
* no folder on the way may be plumbing; and with links and short names resolved the path must stay inside the root and
|
|
52
|
+
* clear of plumbing too. `rel` is in the letter case on disk when only the case differs from the request.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveIn(rootDir: string, segs: string[]): {
|
|
55
|
+
abs: string;
|
|
56
|
+
rel: string;
|
|
57
|
+
parts: string[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Send a file: its media type (SVG, HTML and unknown types as downloads, `download` for any), a sandbox policy, an
|
|
61
|
+
* ETag, and byte ranges (one range: 206 with Content-Range; past the end: 416).
|
|
62
|
+
*/
|
|
63
|
+
export declare function sendFile(req: http.IncomingMessage, res: http.ServerResponse, abs: string, o?: {
|
|
64
|
+
download?: boolean;
|
|
65
|
+
}): void;
|
|
66
|
+
export interface FileEntry {
|
|
67
|
+
name: string;
|
|
68
|
+
/** posix path from the root */
|
|
69
|
+
rel: string;
|
|
70
|
+
size: number;
|
|
71
|
+
mtime: number;
|
|
72
|
+
kind: FileKind;
|
|
73
|
+
/** an export TopoTopo made: what its sidecar records */
|
|
74
|
+
made?: ExportMade;
|
|
75
|
+
}
|
|
76
|
+
/** What an export's recorded source says (src/io/source.ts). */
|
|
77
|
+
export interface ExportMade {
|
|
78
|
+
graph: string;
|
|
79
|
+
output: string | null;
|
|
80
|
+
node: string;
|
|
81
|
+
graph_sha256: string;
|
|
82
|
+
vars: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
export interface FolderEntry {
|
|
85
|
+
name: string;
|
|
86
|
+
rel: string;
|
|
87
|
+
/** an engine project (project.godot, *.uproject): one card that opens on demand, never audited */
|
|
88
|
+
engine?: {
|
|
89
|
+
type: EngineType;
|
|
90
|
+
title: string;
|
|
91
|
+
};
|
|
92
|
+
/** another workspace (it holds topotopo-workspace.json) */
|
|
93
|
+
workspace?: boolean;
|
|
94
|
+
/** it holds a .topo file */
|
|
95
|
+
package?: boolean;
|
|
96
|
+
/** its own files (shown ones, as its page counts them) and subfolders */
|
|
97
|
+
files: number;
|
|
98
|
+
folders: number;
|
|
99
|
+
/** its Unreal assets (*.uasset, *.umap), which its page shows as one line */
|
|
100
|
+
unreal: number;
|
|
101
|
+
/** its first image (posix path from the root) */
|
|
102
|
+
image?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface Listing {
|
|
105
|
+
folders: FolderEntry[];
|
|
106
|
+
/** every shown file but the notes, in file name order */
|
|
107
|
+
files: FileEntry[];
|
|
108
|
+
/** the .md and .txt files, in file name order */
|
|
109
|
+
notes: FileEntry[];
|
|
110
|
+
/** Unreal's *.uasset and *.umap files: one line */
|
|
111
|
+
engineAssets: number;
|
|
112
|
+
/** the .topo files: one makes the folder a package */
|
|
113
|
+
topo: string[];
|
|
114
|
+
/** the export source recorded for the folder itself (a textures folder's source.json) */
|
|
115
|
+
made?: ExportMade;
|
|
116
|
+
}
|
|
117
|
+
/** An engine project's own name: project.godot's config/name, a .uproject's file name. */
|
|
118
|
+
export declare function engineTitle(file: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* A folder below a root (`rel` posix, '' for the root): its subfolders, files by type and notes; plumbing left out, and
|
|
121
|
+
* links that lead out of `root` (when given).
|
|
122
|
+
*/
|
|
123
|
+
export declare function listFolder(abs: string, rel: string, root?: string): Listing;
|
|
124
|
+
/** The export source a sidecar records (its "format" names a TopoTopo sidecar), or null. */
|
|
125
|
+
export declare function readSource(file: string): ExportMade | null;
|
|
126
|
+
/** The source a GLB or glTF export carries in asset.extras.source, or null (its JSON is read, never its buffers). */
|
|
127
|
+
export declare function modelSource(file: string): ExportMade | null;
|
|
128
|
+
/**
|
|
129
|
+
* Whether the graph an export was made from changed since (the hash it recorded is not the graph file's, with the
|
|
130
|
+
* vars it was made with); null when the graph cannot be read.
|
|
131
|
+
*/
|
|
132
|
+
export declare function exportStale(graphFile: string, m: ExportMade): boolean | null;
|
|
133
|
+
/** Where a link in a note leads. */
|
|
134
|
+
export type LinkTarget =
|
|
135
|
+
/** a web address; `player`: the privacy player of a YouTube or Vimeo video */
|
|
136
|
+
{
|
|
137
|
+
t: 'web';
|
|
138
|
+
url: string;
|
|
139
|
+
player?: string;
|
|
140
|
+
}
|
|
141
|
+
/** a heading of the note itself ("#usage") */
|
|
142
|
+
| {
|
|
143
|
+
t: 'anchor';
|
|
144
|
+
id: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* a file or folder: `rel` from the root (null: in the engine project, outside the root), whether it is there; `hash`
|
|
148
|
+
* names a heading in a note
|
|
149
|
+
*/
|
|
150
|
+
| {
|
|
151
|
+
t: 'path';
|
|
152
|
+
abs: string;
|
|
153
|
+
rel: string | null;
|
|
154
|
+
exists: boolean;
|
|
155
|
+
dir: boolean;
|
|
156
|
+
hash: string;
|
|
157
|
+
}
|
|
158
|
+
/** not a link here: it stays text (`why` says) */
|
|
159
|
+
| {
|
|
160
|
+
t: 'text';
|
|
161
|
+
why: string;
|
|
162
|
+
};
|
|
163
|
+
/** A YouTube or Vimeo address as its privacy player's address (youtube-nocookie.com, player.vimeo.com), or null. */
|
|
164
|
+
export declare function videoPlayer(url: string): string | null;
|
|
165
|
+
/**
|
|
166
|
+
* Where a link written in a note in `folder` leads, below `root`: a web address; a heading of the note ("#usage"); a
|
|
167
|
+
* path relative to the folder, from the root when it starts with "/", res:// from the Godot project (the workspace's
|
|
168
|
+
* engine, else the one the folder is in), /Game/ from Unreal's Content/ (with .uasset or .umap added when that is the
|
|
169
|
+
* file); anything else stays text. A path is judged by its letters before the file system is asked anything: one that
|
|
170
|
+
* is absolute (a drive, a network share \\host\share), leaves the root (or the engine project), or passes a dot folder
|
|
171
|
+
* or plumbing stays text and is never looked up; only what is left is, and then by where it really is (links and short
|
|
172
|
+
* names resolved). A lookup that fails says "not there"; this never throws.
|
|
173
|
+
*/
|
|
174
|
+
export declare function resolveLink(root: Root, folder: string, href: string): LinkTarget;
|
|
175
|
+
/** What a note's page needs to show its links: the URLs of the root's pages and files, and a folder's card. */
|
|
176
|
+
export interface NoteEnv {
|
|
177
|
+
root: Root;
|
|
178
|
+
folderUrl(rel: string): string;
|
|
179
|
+
fileUrl(rel: string): string;
|
|
180
|
+
modelUrl(rel: string): string;
|
|
181
|
+
/** the address of a note's box (`rel` the note's path from the root), at one of its headings when `anchor` names one */
|
|
182
|
+
noteUrl(rel: string, anchor: string): string;
|
|
183
|
+
/** a folder as a card: a package's title and preview, else the folder's name and first image */
|
|
184
|
+
card(rel: string, abs: string): {
|
|
185
|
+
title: string;
|
|
186
|
+
sub: string;
|
|
187
|
+
thumb?: string;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** The anchor of a note on its folder's page. */
|
|
191
|
+
export declare const noteId: (name: string) => string;
|
|
192
|
+
/** What a note's heading ids start with on its folder's page: the note's anchor, so a link can name a heading of another note. */
|
|
193
|
+
export declare const headingPrefix: (name: string) => string;
|
|
194
|
+
/** A heading's anchor in the note `name`, from what a link writes after "#" ("Usage", "usage"). */
|
|
195
|
+
export declare const headingId: (name: string, hash: string) => string;
|
|
196
|
+
export declare function imageSize(file: string): {
|
|
197
|
+
w: number;
|
|
198
|
+
h: number;
|
|
199
|
+
} | null;
|
|
200
|
+
/**
|
|
201
|
+
* A link of a note as HTML, by what it leads to: an image, audio and video in a player, a model as a 3D view on
|
|
202
|
+
* click, a folder or package as a card, a note as a link to its box (or one of its headings), a heading of the note
|
|
203
|
+
* itself, YouTube and Vimeo in their privacy players, a missing file struck through (`broken` gets it), anything else
|
|
204
|
+
* a plain link. The author's words stay: a card is titled with the link's text (the folder's name and counts below
|
|
205
|
+
* it), a linked image carries it as a caption. A card, picture or player is shown in place when the link stands alone
|
|
206
|
+
* in its paragraph or list item (`at.alone`); in running text the link stays a link, marked with an icon, and the
|
|
207
|
+
* card, picture or player follows the paragraph (`block`).
|
|
208
|
+
*/
|
|
209
|
+
export declare function linkHtml(env: NoteEnv, folder: string, l: MdLink, inner: string, broken: string[], at?: {
|
|
210
|
+
alone: boolean;
|
|
211
|
+
idPrefix: string;
|
|
212
|
+
}): LinkOut;
|
|
213
|
+
/** Notes longer than this are linked, not shown. */
|
|
214
|
+
export declare const MAX_NOTE_BYTES: number;
|
|
215
|
+
/** Web addresses in plain text, linked: found in the raw text, then each piece escaped (a "&" or "'" stays in its address). */
|
|
216
|
+
export declare function linkText(text: string): string;
|
|
217
|
+
/** A note (.md rendered, .txt as text with its web addresses linked) as HTML, and the links in it to missing files. */
|
|
218
|
+
export declare function noteHtml(env: NoteEnv, folder: string, file: string, idPrefix: string): {
|
|
219
|
+
html: string;
|
|
220
|
+
broken: string[];
|
|
221
|
+
long: boolean;
|
|
222
|
+
};
|
|
223
|
+
export type FlagKind = 'link' | 'bake' | 'publish' | 'export' | 'unused' | 'workspace';
|
|
224
|
+
/** Something TopoTopo can tell is wrong in a folder, and the one thing to do about it. */
|
|
225
|
+
export interface Flag {
|
|
226
|
+
kind: FlagKind;
|
|
227
|
+
/** the folder it is in: posix path from the root ('' for the root) */
|
|
228
|
+
at: string;
|
|
229
|
+
what: string;
|
|
230
|
+
todo: string;
|
|
231
|
+
/** a broken link's note (its file name) */
|
|
232
|
+
note?: string;
|
|
233
|
+
}
|
|
234
|
+
/** A tree's walk: its folders and files (plumbing and engine projects left out), a few images, its notes' broken links. */
|
|
235
|
+
export interface Walk {
|
|
236
|
+
folders: number;
|
|
237
|
+
files: number;
|
|
238
|
+
notes: number;
|
|
239
|
+
/** the first images, nearest the root first (posix paths from the root) */
|
|
240
|
+
images: string[];
|
|
241
|
+
/** folders holding an engine project below the root: browsable, not audited */
|
|
242
|
+
engines: string[];
|
|
243
|
+
flags: Flag[];
|
|
244
|
+
/** where the walk stopped short, in words ("the first 10,000 notes were checked for links"): flags past it are not counted */
|
|
245
|
+
cut: string[];
|
|
246
|
+
ms: number;
|
|
247
|
+
}
|
|
248
|
+
/** How far a walk goes: folders deep, folders in all, notes whose links it checks. */
|
|
249
|
+
export interface WalkLimits {
|
|
250
|
+
depth: number;
|
|
251
|
+
folders: number;
|
|
252
|
+
notes: number;
|
|
253
|
+
}
|
|
254
|
+
export declare const WALK_LIMITS: WalkLimits;
|
|
255
|
+
/** The links of the notes a walk read, kept while each note is unchanged (its size and time): a walk again reads only what changed. */
|
|
256
|
+
export type NoteLinks = Map<string, {
|
|
257
|
+
key: string;
|
|
258
|
+
hrefs: string[];
|
|
259
|
+
}>;
|
|
260
|
+
export interface WalkOptions {
|
|
261
|
+
limits?: Partial<WalkLimits>;
|
|
262
|
+
/** the notes' links from earlier walks (the walk adds to it) */
|
|
263
|
+
links?: NoteLinks;
|
|
264
|
+
/** give the event loop a turn after this many milliseconds of work (a server's pages and files keep answering) */
|
|
265
|
+
slice?: number;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Walk a root: count its folders and files (as its pages count them), keep its first images, and check every link of
|
|
269
|
+
* its notes (.md files), a flag for each that leads to a missing file. Engine projects below the root, other
|
|
270
|
+
* workspaces and TopoTopo checkouts are not entered (as the scan); plumbing is not either. A walk that stops short
|
|
271
|
+
* says where (`cut`).
|
|
272
|
+
*/
|
|
273
|
+
export declare function walkTree(root: Root, o?: WalkOptions): Promise<Walk>;
|
|
274
|
+
/** The node types a graph file's nodes have, nested graphs included ("owner/name/output" when it uses a package). */
|
|
275
|
+
export declare function graphTypes(file: string): string[];
|
|
276
|
+
/** Exports below a package's exports/ with the source each records: sidecars, and GLB / glTF files that carry one. */
|
|
277
|
+
export declare function exportSources(dir: string): {
|
|
278
|
+
rel: string;
|
|
279
|
+
made: ExportMade;
|
|
280
|
+
}[];
|