topotopo 0.3.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 +40 -10
- package/README.md +475 -111
- package/dist/cli.js +328 -133
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +16 -8
- package/dist/core/bake.js +165 -29
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +238 -97
- 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 +204 -4
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- 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 +11 -0
- package/dist/core/materials.js +56 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/packed.js +11 -0
- package/dist/core/particles.d.ts +1 -1
- package/dist/core/particles.js +1 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/rbd.js +13 -1
- 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/scatter.d.ts +1 -1
- package/dist/core/scatter.js +1 -1
- package/dist/core/scene.d.ts +20 -0
- package/dist/core/scene.js +72 -0
- 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 +15 -2
- package/dist/core/snippet-lib.js +40 -14
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +54 -0
- package/dist/core/tangents.js +218 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- 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 +32 -0
- package/dist/core/topology.js +238 -7
- package/dist/core/traceimage.d.ts +7 -0
- package/dist/core/traceimage.js +221 -0
- package/dist/core/tritri.d.ts +5 -0
- package/dist/core/tritri.js +120 -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 +15 -16
- package/dist/core/uv.js +36 -189
- 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 +127 -0
- package/dist/core/uvreport.js +372 -0
- 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 +95 -61
- 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 +5 -3
- package/dist/index.js +3 -2
- package/dist/inspect.d.ts +84 -1
- package/dist/inspect.js +271 -24
- package/dist/io/common.d.ts +33 -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 +355 -51
- 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 +149 -14
- 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 +816 -119
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +70 -24
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +207 -108
- 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 +207 -83
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +54 -5
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +22 -10
- package/dist/nodes/curves.js +440 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +13 -39
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +203 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/material.js +91 -23
- package/dist/nodes/measure.js +45 -18
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +55 -0
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- 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 +11 -3
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +6 -2
- 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/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +69 -0
- package/dist/render/preview.js +26 -0
- package/dist/render/raster.d.ts +78 -7
- package/dist/render/raster.js +600 -145
- package/dist/render/texview.d.ts +7 -1
- package/dist/render/texview.js +34 -2
- 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/camera.js +1 -1
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +100 -0
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +6 -2
- package/dist/viewer/app/guides.js +123 -1
- package/dist/viewer/app/keymap.js +7 -4
- package/dist/viewer/app/layers.js +5 -5
- package/dist/viewer/app/main.js +186 -53
- package/dist/viewer/app/markers.js +61 -1
- 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 +177 -53
- package/dist/viewer/app/scene.js +35 -6
- package/dist/viewer/app/select.js +5 -4
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +66 -8
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +48 -1
- 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 +24 -11
- 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 +24 -7
- package/dist/viewer/server.js +289 -31
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/web/bake.d.ts +34 -0
- package/dist/web/bake.js +153 -0
- 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 -105
- package/dist/workspace.js +359 -375
- 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 +23 -29
- package/kernels/pkg-simd/README.md +23 -29
- 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 +23 -8
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/shelf/index.json +0 -190
package/dist/web/bake.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
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
|
|
5
|
+
// block the event loop and cannot be cancelled): BakeQueue runs `topotopo library bake <dir>` children one at a time,
|
|
6
|
+
// with a shorter simulation limit, a hard time limit and a low priority. A failed bake keeps the previous files.
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import zlib from 'node:zlib';
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import '../nodes/index.js';
|
|
14
|
+
import { Engine } from '../graph/engine.js';
|
|
15
|
+
import { createNodeHost } from '../host/node.js';
|
|
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';
|
|
22
|
+
export const THUMB_SIZE = 512;
|
|
23
|
+
/** a preview.glb above this is not written (the page shows the thumbnail instead) */
|
|
24
|
+
export const MAX_PREVIEW_GLB = 50 * 1024 * 1024;
|
|
25
|
+
/** a bake child is stopped after this */
|
|
26
|
+
export const BAKE_TIMEOUT_MS = 300_000;
|
|
27
|
+
/** the simulation limit inside a bake child (the engine's default is 600 s per node) */
|
|
28
|
+
export const BAKE_SIM_TIMEOUT_MS = 120_000;
|
|
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) {
|
|
31
|
+
const m = readManifest(dir);
|
|
32
|
+
const key = bakeKey(dir, m);
|
|
33
|
+
const out = webDir(dir);
|
|
34
|
+
fs.mkdirSync(out, { recursive: true });
|
|
35
|
+
const t0 = performance.now();
|
|
36
|
+
const finish = (s) => {
|
|
37
|
+
const state = { key, at: Date.now(), ms: Math.round(performance.now() - t0), ...s };
|
|
38
|
+
writeAtomic(path.join(out, 'bake.json'), JSON.stringify(state, null, 1) + '\n');
|
|
39
|
+
return state;
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const engine = new Engine(createNodeHost({ baseDir: dir }));
|
|
43
|
+
if (process.env.TOPOTOPO_SIM_TIMEOUT_MS)
|
|
44
|
+
engine.simTimeoutMs = Number(process.env.TOPOTOPO_SIM_TIMEOUT_MS);
|
|
45
|
+
if (process.env.TOPOTOPO_SCRIPT_TIMEOUT_MS)
|
|
46
|
+
engine.scriptTimeoutMs = Number(process.env.TOPOTOPO_SCRIPT_TIMEOUT_MS);
|
|
47
|
+
await engine.init();
|
|
48
|
+
// the packages it uses, from its copies (a bake adds none), its graphs and its assets
|
|
49
|
+
const ws = openPackage(engine, dir).session;
|
|
50
|
+
const name = m.bake.graph ?? m.graph;
|
|
51
|
+
const g = ws.graphs.get(name);
|
|
52
|
+
if (!g)
|
|
53
|
+
return finish({ ok: false, error: `no default graph yet: the package has no graph "${name}" (its manifest's "graph")` });
|
|
54
|
+
const r = await engine.cook(g, { target: m.bake.node, frame: m.bake.frame });
|
|
55
|
+
if (!r.ok || !r.geo)
|
|
56
|
+
return finish({ ok: false, error: r.errors.map((e) => `[${e.node}] ${e.message}`).join('\n') || 'the cook gave no geometry' });
|
|
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 })));
|
|
62
|
+
const glb = await previewGLB(r.geo, { compress: 'meshopt' });
|
|
63
|
+
const small = glb.length <= MAX_PREVIEW_GLB;
|
|
64
|
+
if (small)
|
|
65
|
+
writeAtomic(path.join(out, 'preview.glb'), glb);
|
|
66
|
+
else
|
|
67
|
+
fs.rmSync(path.join(out, 'preview.glb'), { force: true });
|
|
68
|
+
const warnings = r.warnings.map((w) => `[${w.node}] ${w.message}`);
|
|
69
|
+
if (!small)
|
|
70
|
+
warnings.push(`preview.glb would be ${(glb.length / 2 ** 20).toFixed(0)} MB (over ${MAX_PREVIEW_GLB / 2 ** 20} MB): not written`);
|
|
71
|
+
return finish({ ok: true, glb: small, points: r.geo.numPoints, prims: r.geo.numPrims, warnings });
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return finish({ ok: false, error: String(e?.message ?? e) });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// ------------------------------------------------------------------------------------------------------ BakeQueue
|
|
78
|
+
const cli = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', import.meta.url.endsWith('.ts') ? 'cli.ts' : 'cli.js');
|
|
79
|
+
/** Bakes in child processes, one at a time, each package once however often it is asked for meanwhile. */
|
|
80
|
+
export class BakeQueue {
|
|
81
|
+
queue = [];
|
|
82
|
+
running = null;
|
|
83
|
+
child = null;
|
|
84
|
+
closed = false;
|
|
85
|
+
opts;
|
|
86
|
+
constructor(opts = {}) { this.opts = opts; }
|
|
87
|
+
/** Ask for a bake; true when it was queued now (false: queued or running already). */
|
|
88
|
+
add(dir) {
|
|
89
|
+
if (this.closed || this.running === dir || this.queue.includes(dir))
|
|
90
|
+
return false;
|
|
91
|
+
this.queue.push(dir);
|
|
92
|
+
this.next();
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
pending(dir) { return this.running === dir || this.queue.includes(dir); }
|
|
96
|
+
get size() { return this.queue.length + (this.running ? 1 : 0); }
|
|
97
|
+
/** Resolves when nothing is queued or running. */
|
|
98
|
+
async idle() {
|
|
99
|
+
while (this.size)
|
|
100
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
101
|
+
}
|
|
102
|
+
close() {
|
|
103
|
+
this.closed = true;
|
|
104
|
+
this.queue = [];
|
|
105
|
+
this.child?.kill();
|
|
106
|
+
}
|
|
107
|
+
next() {
|
|
108
|
+
if (this.running || this.closed)
|
|
109
|
+
return;
|
|
110
|
+
const dir = this.queue.shift();
|
|
111
|
+
if (!dir)
|
|
112
|
+
return;
|
|
113
|
+
this.running = dir;
|
|
114
|
+
const t0 = Date.now();
|
|
115
|
+
const child = spawn(process.execPath, [cli, 'library', 'bake', dir], {
|
|
116
|
+
env: { ...process.env, TOPOTOPO_SIM_TIMEOUT_MS: process.env.TOPOTOPO_SIM_TIMEOUT_MS ?? String(BAKE_SIM_TIMEOUT_MS) },
|
|
117
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
118
|
+
windowsHide: true,
|
|
119
|
+
});
|
|
120
|
+
this.child = child;
|
|
121
|
+
try {
|
|
122
|
+
if (child.pid)
|
|
123
|
+
os.setPriority(child.pid, os.constants.priority.PRIORITY_BELOW_NORMAL);
|
|
124
|
+
}
|
|
125
|
+
catch { /* not allowed: normal priority */ }
|
|
126
|
+
let stderr = '';
|
|
127
|
+
child.stderr?.on('data', (d) => { if (stderr.length < 4000)
|
|
128
|
+
stderr += d; });
|
|
129
|
+
const timer = setTimeout(() => child.kill(), this.opts.timeoutMs ?? BAKE_TIMEOUT_MS);
|
|
130
|
+
timer.unref();
|
|
131
|
+
child.on('exit', (code, signal) => {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
this.child = null;
|
|
134
|
+
this.running = null;
|
|
135
|
+
let state = readBakeState(dir);
|
|
136
|
+
// killed (time limit) or crashed: record it, so the page says why and the same key is not retried in a loop
|
|
137
|
+
if (!state || state.at < t0) {
|
|
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(' ')}`;
|
|
139
|
+
try {
|
|
140
|
+
state = { key: bakeKey(dir, readManifest(dir)), at: Date.now(), ok: false, error: why };
|
|
141
|
+
fs.mkdirSync(webDir(dir), { recursive: true });
|
|
142
|
+
writeAtomic(path.join(webDir(dir), 'bake.json'), JSON.stringify(state, null, 1) + '\n');
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
state = null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.opts.log?.(`bake ${dir}: ${state?.ok ? `ok in ${state.ms} ms` : `failed: ${state?.error ?? 'no result'}`}`);
|
|
149
|
+
this.opts.onDone?.(dir, state);
|
|
150
|
+
this.next();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -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
|
+
}
|