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/render/texview.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ export declare function drawTextureView(g: Geometry, col: Float32Array, W: numbe
|
|
|
12
12
|
* texture view does. Anything else (points, prims, other volumes) is returned as it is.
|
|
13
13
|
*/
|
|
14
14
|
export declare function withImagePreview(g: Geometry, max?: number): Geometry;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* A material output (materials and their maps, no geometry) as something to look at: one sphere per material, side by
|
|
17
|
+
* side in table order, each wearing its material with the maps it carries (tangents for normal maps come from the
|
|
18
|
+
* exporters and the renderer as for any mesh). Anything else comes back as it is.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withMaterialPreview(g: Geometry, max?: number): Geometry;
|
|
21
|
+
/** Base colour maps per prim for persp/ortho views: sample fills out with RGBA (grey has alpha 1). */
|
|
16
22
|
export interface TextureSampler {
|
|
17
23
|
/** true when prim p shows a base colour map */
|
|
18
24
|
has(p: number): boolean;
|
package/dist/render/texview.js
CHANGED
|
@@ -7,6 +7,8 @@ import { Geometry } from '../core/geometry.js';
|
|
|
7
7
|
import { Image, channelsOf, imageRef, isImage, referenceableImages, resizeLayer } from '../core/image.js';
|
|
8
8
|
import { MATERIAL_ATTRIB, normalizeMaterial, primMaterials, readMaterials, writeMaterials } from '../core/materials.js';
|
|
9
9
|
import { drawText, textWidth } from './font.js';
|
|
10
|
+
import { uvSphere } from '../core/shapes.js';
|
|
11
|
+
import { imageRowOfV } from '../core/texcoord.js';
|
|
10
12
|
const SLOT_LABEL = { baseColor: 'BASE COLOR', normal: 'NORMAL', roughness: 'ROUGHNESS', orm: 'ORM' };
|
|
11
13
|
/**
|
|
12
14
|
* What the texture view shows for a spec: "" = every image (at most 16); an image name = that image (all its layers
|
|
@@ -180,6 +182,32 @@ export function withImagePreview(g, max = 16) {
|
|
|
180
182
|
out.volumes = imgs;
|
|
181
183
|
return out;
|
|
182
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* A material output (materials and their maps, no geometry) as something to look at: one sphere per material, side by
|
|
187
|
+
* side in table order, each wearing its material with the maps it carries (tangents for normal maps come from the
|
|
188
|
+
* exporters and the renderer as for any mesh). Anything else comes back as it is.
|
|
189
|
+
*/
|
|
190
|
+
export function withMaterialPreview(g, max = 8) {
|
|
191
|
+
if (g.numPoints)
|
|
192
|
+
return g;
|
|
193
|
+
const table = readMaterials(g), names = Object.keys(table).slice(0, max);
|
|
194
|
+
if (!names.length || g.volumes.some((v) => !isImage(v)))
|
|
195
|
+
return g;
|
|
196
|
+
const parts = names.map((name, k) => {
|
|
197
|
+
const s = uvSphere(0.5, 24, 48);
|
|
198
|
+
const P = s.P;
|
|
199
|
+
for (let i = 0; i < P.length; i += 3)
|
|
200
|
+
P[i] += k * 1.25 - ((names.length - 1) * 1.25) / 2;
|
|
201
|
+
const a = s.prims.add(MATERIAL_ATTRIB, 'string', 1);
|
|
202
|
+
for (let p = 0; p < s.numPrims; p++)
|
|
203
|
+
a.set(p, name);
|
|
204
|
+
return s;
|
|
205
|
+
});
|
|
206
|
+
const out = parts.length === 1 ? parts[0] : Geometry.merge(parts);
|
|
207
|
+
writeMaterials(out, table);
|
|
208
|
+
out.volumes = g.volumes.slice();
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
183
211
|
/** A mip chain of a layer (area-averaged halves, wrapping) down to 1 × 1. */
|
|
184
212
|
function mipChain(img, layer) {
|
|
185
213
|
const a = img.layer(layer), ch = channelsOf(a, img.count) || 1;
|
|
@@ -221,11 +249,15 @@ export function textureSampler(g, notes) {
|
|
|
221
249
|
sample(p, u, v, lod, out) {
|
|
222
250
|
const chain = perPrim[p];
|
|
223
251
|
const m = chain[Math.max(0, Math.min(chain.length - 1, Math.round(lod)))];
|
|
224
|
-
const x = u * m.w - 0.5, y = (
|
|
252
|
+
const x = u * m.w - 0.5, y = imageRowOfV(v, m.h) - 0.5;
|
|
225
253
|
const x0 = Math.floor(x), y0 = Math.floor(y), tx = x - x0, ty = y - y0;
|
|
226
254
|
const i0 = wrap(x0, m.w), i1 = wrap(x0 + 1, m.w), j0 = wrap(y0, m.h), j1 = wrap(y0 + 1, m.h);
|
|
227
255
|
const d = m.data, ch = m.ch;
|
|
228
|
-
for (let c = 0; c <
|
|
256
|
+
for (let c = 0; c < 4; c++) {
|
|
257
|
+
if (ch === 1 && c === 3) {
|
|
258
|
+
out[c] = 1;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
229
261
|
const cc = ch === 4 ? c : 0;
|
|
230
262
|
const a = d[(j0 * m.w + i0) * ch + cc], b = d[(j0 * m.w + i1) * ch + cc], e = d[(j1 * m.w + i0) * ch + cc], f = d[(j1 * m.w + i1) * ch + cc];
|
|
231
263
|
const t = a + (b - a) * tx, s = e + (f - e) * tx;
|
package/dist/scan.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PackageManifest } from './package.ts';
|
|
2
|
+
/** How deep below its root a scan looks. */
|
|
3
|
+
export declare const SCAN_DEPTH = 16;
|
|
4
|
+
/** Folders a scan never enters, anywhere (lower case). The web app hides the same folders (src/web/folders.ts). */
|
|
5
|
+
export declare const SKIP: Set<string>;
|
|
6
|
+
export declare const WORKSPACE_FILE = "topotopo-workspace.json";
|
|
7
|
+
export interface Package {
|
|
8
|
+
/** the name of the workspace or library it was found in */
|
|
9
|
+
lib: string;
|
|
10
|
+
id: string;
|
|
11
|
+
/** absolute folder */
|
|
12
|
+
dir: string;
|
|
13
|
+
/** posix path of the folder relative to the root of its workspace or library */
|
|
14
|
+
rel: string;
|
|
15
|
+
/** the parent folders' path ("" at the top), how the web app groups packages */
|
|
16
|
+
collection: string;
|
|
17
|
+
manifest: PackageManifest;
|
|
18
|
+
/** newest change to its manifest, graphs/ or assets/ (ms), read when asked */
|
|
19
|
+
readonly updated: number;
|
|
20
|
+
}
|
|
21
|
+
export interface Scan {
|
|
22
|
+
/** the workspace's or library's name */
|
|
23
|
+
name: string;
|
|
24
|
+
root: string;
|
|
25
|
+
/** every package below the root, sorted by path */
|
|
26
|
+
packages: Package[];
|
|
27
|
+
/** what is wrong: a manifest that cannot be read, two .topo files, an id used twice, a folder too deep */
|
|
28
|
+
problems: string[];
|
|
29
|
+
/** other workspaces below the root (a folder holding topotopo-workspace.json): listed, not scanned */
|
|
30
|
+
workspaces: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface ScanOptions {
|
|
33
|
+
/** the engine project file of the workspace being scanned (absolute): the folder holding it is scanned */
|
|
34
|
+
engine?: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** A folder as a key: its absolute path, without case on Windows and macOS. */
|
|
37
|
+
export declare const folderKey: (p: string) => string;
|
|
38
|
+
/** A folder holding a package.json named "topotopo": a TopoTopo checkout. */
|
|
39
|
+
export declare function isCheckout(dir: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Why the scan never enters a folder named `name` whose parent holds the files `parentFiles` (or a function that lists
|
|
42
|
+
* them, called only when they matter); null when it may. The web app hides the same folders.
|
|
43
|
+
*/
|
|
44
|
+
export declare function skippedName(name: string, parentFiles: string[] | (() => string[])): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Why a scan of `root` never reaches `dir`, a folder below it, by the scan's own rules: the first folder on the way it
|
|
47
|
+
* does not enter, said ("tool/bin: C#'s bin folder beside a .csproj or .sln, which the scan never enters"); null when
|
|
48
|
+
* the scan reaches it, or `dir` is `root` or not below it. Folders that are not there yet are judged by their names and
|
|
49
|
+
* the files of those that are (a new package's path is asked before it is made). `dir` itself may hold a .topo file (a
|
|
50
|
+
* package the scan finds); a folder above it that holds one, the root included, is a package the scan never enters.
|
|
51
|
+
*/
|
|
52
|
+
export declare function unscanned(root: string, dir: string, o?: ScanOptions): string | null;
|
|
53
|
+
/** Forget the scans kept: the next one reads the folders again. */
|
|
54
|
+
export declare function forgetScans(): void;
|
|
55
|
+
/** Forget the scans kept of one root (a workspace's or library's folder): the others stay. */
|
|
56
|
+
export declare function forgetScansOf(root: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* The packages below a workspace's or library's root (see the top of this file), kept until forgetScans(). `name`:
|
|
59
|
+
* the workspace's or library's name, which each package carries (Package.lib).
|
|
60
|
+
*/
|
|
61
|
+
export declare function scanTree(name: string, root: string, o?: ScanOptions): Scan;
|
package/dist/scan.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// The one scan: the packages of a workspace or a library, which the lookup, gathering copies, update, check, the
|
|
2
|
+
// workspace text, the MCP server and the web app all read. A package is a folder holding exactly one <id>.topo file;
|
|
3
|
+
// the scan never enters one (a package holds no other), and the root of a workspace or library is no package. It
|
|
4
|
+
// lists each folder once (spotting .topo files, project.json, engine projects and subfolders in that one listing),
|
|
5
|
+
// reads a manifest only for a package, and stats nothing. What it skips, anywhere (names compared without case):
|
|
6
|
+
// dot folders, node_modules, topotopo-packages (a workspace's copies);
|
|
7
|
+
// Unreal's Binaries, Intermediate, Saved, DerivedDataCache, __ExternalActors__, __ExternalObjects__;
|
|
8
|
+
// C#'s bin and obj beside a *.csproj or *.sln;
|
|
9
|
+
// a folder holding an engine project (project.godot, *.uproject) other than the workspace's own;
|
|
10
|
+
// a folder holding another topotopo-workspace.json: another workspace, listed as such and not scanned;
|
|
11
|
+
// a TopoTopo checkout (a package.json named "topotopo").
|
|
12
|
+
// Plain folders named assets, graphs, inputs, exports, attachments, versions or packages are scanned like any other
|
|
13
|
+
// outside a package (a Godot project keeps its content in assets/). It goes 16 folders deep; a folder cut off there is
|
|
14
|
+
// said, once. A root that holds a .topo file is a package: said, and not entered either. unscanned() says why a scan
|
|
15
|
+
// never reaches a folder, by the same rules: the workspace a package belongs to (package.ts locate) and where a new
|
|
16
|
+
// package may go (web/library.ts createPackage) follow it. Scans are kept per process by root until forgetScans(): a command forgets them when it starts,
|
|
17
|
+
// TopoTopo forgets them when it writes a manifest or a workspace file, and a long-running process (the MCP server, the
|
|
18
|
+
// viewer, the web app) when it refreshes or when a lookup does not find a name.
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { ID_RE } from './graph/scope.js';
|
|
22
|
+
import { MANIFEST_EXT } from './session.js';
|
|
23
|
+
import { engineTypeOf } from './engines.js';
|
|
24
|
+
import { oldManifest, readManifestFile, slugify } from './package.js';
|
|
25
|
+
/** How deep below its root a scan looks. */
|
|
26
|
+
export const SCAN_DEPTH = 16;
|
|
27
|
+
/** Folders a scan never enters, anywhere (lower case). The web app hides the same folders (src/web/folders.ts). */
|
|
28
|
+
export const SKIP = new Set(['node_modules', 'topotopo-packages', 'binaries', 'intermediate', 'saved', 'deriveddatacache', '__externalactors__', '__externalobjects__']);
|
|
29
|
+
/** C#'s build folders: skipped beside a *.csproj or *.sln. */
|
|
30
|
+
const DOTNET = new Set(['bin', 'obj']);
|
|
31
|
+
export const WORKSPACE_FILE = 'topotopo-workspace.json';
|
|
32
|
+
const mtime = (p) => fs.statSync(p, { throwIfNoEntry: false })?.mtimeMs ?? 0;
|
|
33
|
+
const jsonFiles = (dir) => { try {
|
|
34
|
+
return fs.readdirSync(dir).filter((f) => f.endsWith('.json')).sort();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return [];
|
|
38
|
+
} };
|
|
39
|
+
const byName = (a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
40
|
+
/** A folder as a key: its absolute path, without case on Windows and macOS. */
|
|
41
|
+
export const folderKey = (p) => (process.platform === 'linux' ? path.resolve(p) : path.resolve(p).toLowerCase());
|
|
42
|
+
/** A folder holding a package.json named "topotopo": a TopoTopo checkout. */
|
|
43
|
+
export function isCheckout(dir) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))?.name === 'topotopo';
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false; /* not JSON: a folder like any other */
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Why the scan never enters a folder named `name` whose parent holds the files `parentFiles` (or a function that lists
|
|
53
|
+
* them, called only when they matter); null when it may. The web app hides the same folders.
|
|
54
|
+
*/
|
|
55
|
+
export function skippedName(name, parentFiles) {
|
|
56
|
+
const lower = name.toLowerCase();
|
|
57
|
+
if (name.startsWith('.'))
|
|
58
|
+
return 'a dot folder';
|
|
59
|
+
if (SKIP.has(lower))
|
|
60
|
+
return `a ${name} folder`;
|
|
61
|
+
if (DOTNET.has(lower) && (typeof parentFiles === 'function' ? parentFiles() : parentFiles).some((f) => /\.(csproj|sln)$/i.test(f)))
|
|
62
|
+
return `C#'s ${name} folder beside a .csproj or .sln`;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Why the scan does not look into a folder below its root that holds `files` (`engine`: the folderKey of the
|
|
67
|
+
* workspace's own engine project file); null when it does.
|
|
68
|
+
*/
|
|
69
|
+
function skippedFolder(dir, files, engine) {
|
|
70
|
+
if (files.includes(WORKSPACE_FILE))
|
|
71
|
+
return `another workspace (it holds ${WORKSPACE_FILE})`;
|
|
72
|
+
const projects = files.filter((f) => engineTypeOf(f));
|
|
73
|
+
if (projects.length && !projects.some((f) => folderKey(path.join(dir, f)) === engine))
|
|
74
|
+
return `another engine project (it holds ${projects[0]})`;
|
|
75
|
+
if (files.includes('package.json') && isCheckout(dir))
|
|
76
|
+
return 'a TopoTopo checkout';
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const filesIn = (dir) => { try {
|
|
80
|
+
return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return [];
|
|
84
|
+
} };
|
|
85
|
+
const isTopo = (f) => f.endsWith(MANIFEST_EXT) && f.length > MANIFEST_EXT.length;
|
|
86
|
+
/**
|
|
87
|
+
* Why a scan of `root` never reaches `dir`, a folder below it, by the scan's own rules: the first folder on the way it
|
|
88
|
+
* does not enter, said ("tool/bin: C#'s bin folder beside a .csproj or .sln, which the scan never enters"); null when
|
|
89
|
+
* the scan reaches it, or `dir` is `root` or not below it. Folders that are not there yet are judged by their names and
|
|
90
|
+
* the files of those that are (a new package's path is asked before it is made). `dir` itself may hold a .topo file (a
|
|
91
|
+
* package the scan finds); a folder above it that holds one, the root included, is a package the scan never enters.
|
|
92
|
+
*/
|
|
93
|
+
export function unscanned(root, dir, o = {}) {
|
|
94
|
+
const top = path.resolve(root), r = path.relative(top, path.resolve(dir));
|
|
95
|
+
if (!r || r.startsWith('..') || path.isAbsolute(r))
|
|
96
|
+
return null;
|
|
97
|
+
const parts = r.split(path.sep), engine = o.engine ? folderKey(o.engine) : null;
|
|
98
|
+
let files = filesIn(top);
|
|
99
|
+
if (files.some(isTopo))
|
|
100
|
+
return `${top} is a package itself (${files.find(isTopo)}), and the scan enters no package`;
|
|
101
|
+
for (let i = 0, d = top; i < parts.length; i++) {
|
|
102
|
+
const rel = parts.slice(0, i + 1).join('/'), name = skippedName(parts[i], files);
|
|
103
|
+
if (name)
|
|
104
|
+
return `${rel}: ${name}, which the scan never enters`;
|
|
105
|
+
if (i + 1 > SCAN_DEPTH)
|
|
106
|
+
return `${rel}: more than ${SCAN_DEPTH} folders below ${top}, deeper than the scan looks`;
|
|
107
|
+
d = path.join(d, parts[i]);
|
|
108
|
+
files = filesIn(d);
|
|
109
|
+
const folder = skippedFolder(d, files, engine);
|
|
110
|
+
if (folder)
|
|
111
|
+
return `${rel}: ${folder}, which the scan does not enter`;
|
|
112
|
+
if (i < parts.length - 1 && files.some(isTopo))
|
|
113
|
+
return `${rel}: a package (${files.find(isTopo)}), which the scan never enters`;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const scans = new Map();
|
|
118
|
+
/** Forget the scans kept: the next one reads the folders again. */
|
|
119
|
+
export function forgetScans() { scans.clear(); }
|
|
120
|
+
/** Forget the scans kept of one root (a workspace's or library's folder): the others stay. */
|
|
121
|
+
export function forgetScansOf(root) {
|
|
122
|
+
const k = `|${folderKey(root)}|`;
|
|
123
|
+
for (const key of [...scans.keys()])
|
|
124
|
+
if (key.includes(k))
|
|
125
|
+
scans.delete(key);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The packages below a workspace's or library's root (see the top of this file), kept until forgetScans(). `name`:
|
|
129
|
+
* the workspace's or library's name, which each package carries (Package.lib).
|
|
130
|
+
*/
|
|
131
|
+
export function scanTree(name, root, o = {}) {
|
|
132
|
+
const key = `${name}|${folderKey(root)}|${o.engine ? folderKey(o.engine) : ''}`;
|
|
133
|
+
const have = scans.get(key);
|
|
134
|
+
if (have)
|
|
135
|
+
return have;
|
|
136
|
+
const s = scanNow(name, root, o);
|
|
137
|
+
scans.set(key, s);
|
|
138
|
+
return s;
|
|
139
|
+
}
|
|
140
|
+
function scanNow(name, rootDir, o) {
|
|
141
|
+
const root = path.resolve(rootDir);
|
|
142
|
+
const out = { name, root, packages: [], problems: [], workspaces: [] };
|
|
143
|
+
if (!fs.statSync(root, { throwIfNoEntry: false })?.isDirectory()) {
|
|
144
|
+
out.problems.push(`no folder ${root}`);
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
const engine = o.engine ? folderKey(o.engine) : null;
|
|
148
|
+
const ids = new Map();
|
|
149
|
+
const walk = (dir, rel, depth) => {
|
|
150
|
+
let entries;
|
|
151
|
+
try {
|
|
152
|
+
entries = fs.readdirSync(dir, { withFileTypes: true }).sort(byName);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const files = entries.filter((e) => e.isFile()).map((e) => e.name);
|
|
158
|
+
const tops = files.filter(isTopo);
|
|
159
|
+
if (rel) {
|
|
160
|
+
// another workspace (listed, not scanned), another engine project than the workspace's own, a TopoTopo checkout
|
|
161
|
+
// (its test fixtures and built-in packages are not the workspace's)
|
|
162
|
+
if (skippedFolder(dir, files, engine)) {
|
|
163
|
+
if (files.includes(WORKSPACE_FILE))
|
|
164
|
+
out.workspaces.push(dir);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (tops.length > 1) {
|
|
168
|
+
out.problems.push(`${rel}: holds ${tops.slice(0, -1).join(', ')} and ${tops.at(-1)}: a package has one ${MANIFEST_EXT} file, whose name is its id`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (tops.length === 1) {
|
|
172
|
+
addPackage(dir, rel, tops[0]);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// a folder that holds project.json instead: said, and not entered
|
|
176
|
+
if (files.includes('project.json')) {
|
|
177
|
+
const old = oldManifest(dir);
|
|
178
|
+
if (old) {
|
|
179
|
+
out.problems.push(old);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (tops.length) {
|
|
185
|
+
// a package is never entered: its versions/ and packages/ hold copies of packages, not packages of the root's
|
|
186
|
+
out.problems.push(`${path.join(dir, tops[0])}: the ${name ? `folder of "${name}"` : 'root folder'} is a package itself, and a package holds no other: nothing below it is looked in for packages; keep the packages in folders below a root that is no package`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const below = entries.filter((e) => e.isDirectory() && !skippedName(e.name, files));
|
|
190
|
+
if (!below.length)
|
|
191
|
+
return;
|
|
192
|
+
if (depth >= SCAN_DEPTH) {
|
|
193
|
+
out.problems.push(`${rel || '.'}: its folders are more than ${SCAN_DEPTH} below ${root} and were not looked in for packages`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
for (const e of below)
|
|
197
|
+
walk(path.join(dir, e.name), rel ? `${rel}/${e.name}` : e.name, depth + 1);
|
|
198
|
+
};
|
|
199
|
+
const addPackage = (dir, rel, file) => {
|
|
200
|
+
const id = file.slice(0, -MANIFEST_EXT.length), abs = path.join(dir, file);
|
|
201
|
+
if (!ID_RE.test(id)) {
|
|
202
|
+
out.problems.push(`${abs}: the file's name is the package id: lower-case letters, digits, - and _, starting with a letter or digit ("${slugify(id) || 'package'}${MANIFEST_EXT}")`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
let manifest;
|
|
206
|
+
try {
|
|
207
|
+
manifest = readManifestFile(abs, id);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
out.problems.push(e.message);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const prev = ids.get(id);
|
|
214
|
+
if (prev !== undefined)
|
|
215
|
+
out.problems.push(`${rel}: id "${id}" is also used by ${prev} (rename its ${file}): the web app shows ${prev}`);
|
|
216
|
+
else
|
|
217
|
+
ids.set(id, rel);
|
|
218
|
+
let updated;
|
|
219
|
+
out.packages.push({
|
|
220
|
+
lib: name, id, dir, rel, collection: rel.includes('/') ? rel.slice(0, rel.lastIndexOf('/')) : '', manifest,
|
|
221
|
+
get updated() {
|
|
222
|
+
return updated ??= Math.round(Math.max(mtime(abs), ...['graphs', 'assets'].flatMap((d) => jsonFiles(path.join(dir, d)).map((f) => mtime(path.join(dir, d, f))))));
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
walk(root, '', 0);
|
|
227
|
+
return out;
|
|
228
|
+
}
|