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
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import type { Geometry } from '../core/geometry.ts';
|
|
2
2
|
import type { ExportFormat } from '../io/export.ts';
|
|
3
3
|
import type { ExportFile } from '../io/files.ts';
|
|
4
|
+
import type { ExportSource } from '../io/source.ts';
|
|
4
5
|
import type { PublishedOutput, ResolvedTarget } from '../io/targets.ts';
|
|
5
6
|
import type { Host } from './types.ts';
|
|
6
|
-
/** The
|
|
7
|
-
export declare function
|
|
7
|
+
/** The package a path lies in: the nearest folder holding a .topo file, the path's own or one above it; null for none. */
|
|
8
|
+
export declare function packageFolderOf(p: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Where a graph file's exports go: its package's exports/ folder (the nearest .topo file above it), else exports/
|
|
11
|
+
* beside the graph. One rule for the CLI (--export-all, its receipts), `topotopo view` and the MCP server (whose
|
|
12
|
+
* folder is the package folder).
|
|
13
|
+
*/
|
|
14
|
+
export declare function exportsFolderFor(graphFile: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* The files an export writes, nothing written yet; `a` holds the export tool's snake_case options. Every option the
|
|
17
|
+
* format reads is passed explicitly, the given ones over the format's defaults (io/targets.ts exportDefaults), and the
|
|
18
|
+
* source block records exactly those, so the record replays to the same bytes.
|
|
19
|
+
*/
|
|
20
|
+
export declare function serializeExport(geo: Geometry, format: ExportFormat, p: string, given: Record<string, any>, host: Host, source?: ExportSource): Promise<{
|
|
8
21
|
files: ExportFile[];
|
|
9
22
|
summary: string;
|
|
10
23
|
warnings: string[];
|
|
11
24
|
outDir: string;
|
|
25
|
+
sourceFile: string | undefined;
|
|
26
|
+
sourceManifest: string | undefined;
|
|
12
27
|
}>;
|
|
13
28
|
/** `p` resolved inside `root`, crossing no symbolic link or junction on the way; throws otherwise. */
|
|
14
29
|
export declare function insideRoot(root: string, p: string): string;
|
|
@@ -21,13 +36,35 @@ export interface PreparedTarget {
|
|
|
21
36
|
label: string;
|
|
22
37
|
node: string;
|
|
23
38
|
target: ResolvedTarget;
|
|
39
|
+
/** the folder its files are written inside: the package's exports/ */
|
|
40
|
+
root: string;
|
|
24
41
|
files: ExportFile[];
|
|
25
42
|
summary: string;
|
|
26
43
|
warnings: string[];
|
|
44
|
+
/** the file that records the export's source (a sidecar, the bundle manifest or <file>.source.json) */
|
|
45
|
+
sourceFile?: string;
|
|
46
|
+
/** the standalone <file>.source.json among files, when the format has no sidecar of its own */
|
|
47
|
+
sourceManifest?: string;
|
|
27
48
|
}
|
|
28
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* When a target's output was cooked: the engine's defaults (frame 1, 24 fps) unless the cook used others, and the
|
|
51
|
+
* package versions the graph uses (src/graph/packages.ts packagesUsed).
|
|
52
|
+
*/
|
|
53
|
+
export interface TargetCook {
|
|
54
|
+
frame?: number;
|
|
55
|
+
fps?: number;
|
|
56
|
+
packages?: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Serialize one published output to its target inside `exportsDir` (nothing is written yet); a target still written
|
|
60
|
+
* with the export prefix that is gone is refused, saying what to write. The export records its source: the graph it is
|
|
61
|
+
* published from (p.spec), its vars and seeds, the node, `cook`'s frame and fps, its packages.
|
|
62
|
+
*/
|
|
29
63
|
export declare function prepareTarget(geo: Geometry, graph: string, p: PublishedOutput & {
|
|
30
64
|
target: ResolvedTarget;
|
|
31
|
-
}, exportsDir: string, host: Host): Promise<PreparedTarget>;
|
|
32
|
-
/**
|
|
65
|
+
}, exportsDir: string, host: Host, cook?: TargetCook): Promise<PreparedTarget>;
|
|
66
|
+
/**
|
|
67
|
+
* Write prepared targets and record the receipts of those inside `exportsDir` (the viewer lists that folder); two
|
|
68
|
+
* targets writing one file are refused before any write.
|
|
69
|
+
*/
|
|
33
70
|
export declare function writeTargets(prepared: PreparedTarget[], exportsDir: string): number;
|
|
@@ -1,18 +1,57 @@
|
|
|
1
1
|
// Writing exports for the CLI, the MCP server and the viewer: serialize with the export tool's options, then write
|
|
2
2
|
// each file through a .part beside it, renamed into place. Published targets (io/targets.ts) write inside exports/
|
|
3
3
|
// only, and every target is serialized before any file is written, so a failed cook or format changes nothing.
|
|
4
|
+
// exports/ is the package's (exportsFolderFor): the folder of the nearest .topo file above the graph, so a graph in
|
|
5
|
+
// <package>/graphs/ exports into <package>/exports/, from the CLI, the MCP server and the viewer alike; a graph file in
|
|
6
|
+
// no package exports beside itself.
|
|
7
|
+
// Every export records how it was made (io/source.ts): the caller passes the source block, and a target builds its own
|
|
8
|
+
// from the graph it is published from.
|
|
4
9
|
import fs from 'node:fs';
|
|
5
10
|
import path from 'node:path';
|
|
6
11
|
import zlib from 'node:zlib';
|
|
7
12
|
import { exportFilesAsync } from '../io/files.js';
|
|
13
|
+
import { exportSource, withExportOptions } from '../io/source.js';
|
|
14
|
+
import { prefixGone, resolvedExportOptions } from '../io/targets.js';
|
|
15
|
+
import { topoFiles } from '../session.js';
|
|
8
16
|
import { ArtifactStore } from './artifacts.js';
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
import { TOPOTOPO_VERSION } from './version.js';
|
|
18
|
+
/** The package a path lies in: the nearest folder holding a .topo file, the path's own or one above it; null for none. */
|
|
19
|
+
export function packageFolderOf(p) {
|
|
20
|
+
let d = path.resolve(p);
|
|
21
|
+
if (fs.statSync(d, { throwIfNoEntry: false })?.isFile())
|
|
22
|
+
d = path.dirname(d);
|
|
23
|
+
for (;;) {
|
|
24
|
+
if (topoFiles(d).length)
|
|
25
|
+
return d;
|
|
26
|
+
const up = path.dirname(d);
|
|
27
|
+
if (up === d)
|
|
28
|
+
return null;
|
|
29
|
+
d = up;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Where a graph file's exports go: its package's exports/ folder (the nearest .topo file above it), else exports/
|
|
34
|
+
* beside the graph. One rule for the CLI (--export-all, its receipts), `topotopo view` and the MCP server (whose
|
|
35
|
+
* folder is the package folder).
|
|
36
|
+
*/
|
|
37
|
+
export function exportsFolderFor(graphFile) {
|
|
38
|
+
const file = path.resolve(graphFile);
|
|
39
|
+
return path.join(packageFolderOf(path.dirname(file)) ?? path.dirname(file), 'exports');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The files an export writes, nothing written yet; `a` holds the export tool's snake_case options. Every option the
|
|
43
|
+
* format reads is passed explicitly, the given ones over the format's defaults (io/targets.ts exportDefaults), and the
|
|
44
|
+
* source block records exactly those, so the record replays to the same bytes.
|
|
45
|
+
*/
|
|
46
|
+
export async function serializeExport(geo, format, p, given, host, source) {
|
|
47
|
+
const a = resolvedExportOptions(format, given);
|
|
48
|
+
if (source)
|
|
49
|
+
source = withExportOptions(source, a);
|
|
11
50
|
const warnings = [];
|
|
12
51
|
const outDir = format === 'unreal_landscape' && !/\.json$/i.test(p) ? p : path.dirname(p);
|
|
13
52
|
const res = await exportFilesAsync(geo, format, p, {
|
|
14
53
|
upAxis: a.up_axis, scale: a.scale, splitByName: a.split_by_name ?? true, custom: a.custom_attribs,
|
|
15
|
-
materials: a.materials, compress: a.compress, quantize: a.quantize, attributes: a.attributes, pcg: a.pcg || a.pcg_struct, pcgStruct: a.pcg_struct,
|
|
54
|
+
materials: a.materials, vertexColors: a.vertex_colors, compress: a.compress, quantize: a.quantize, tangents: a.tangents, attributes: a.attributes, pcg: a.pcg || a.pcg_struct, pcgStruct: a.pcg_struct,
|
|
16
55
|
precision: a.precision, instancing: a.instancing, instances: a.instances, meshes: a.meshes,
|
|
17
56
|
layer: a.layer, layers: a.layers, heightMin: a.height_min, heightMax: a.height_max, heightfield: a.heightfield, tile_size: a.tile_size,
|
|
18
57
|
deflate: (d) => zlib.deflateSync(d, { level: 6 }),
|
|
@@ -22,8 +61,9 @@ export async function serializeExport(geo, format, p, a, host) {
|
|
|
22
61
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(abs) ? abs : path.relative(outDir, abs).split(path.sep).join('/');
|
|
23
62
|
},
|
|
24
63
|
warn: (m) => warnings.push(m),
|
|
64
|
+
source,
|
|
25
65
|
});
|
|
26
|
-
return { files: res.files, summary: res.summary, warnings: [...new Set(warnings)], outDir };
|
|
66
|
+
return { files: res.files, summary: res.summary, warnings: [...new Set(warnings)], outDir, sourceFile: res.sourceFile, sourceManifest: res.sourceManifest };
|
|
27
67
|
}
|
|
28
68
|
/** `p` resolved inside `root`, crossing no symbolic link or junction on the way; throws otherwise. */
|
|
29
69
|
export function insideRoot(root, p) {
|
|
@@ -55,15 +95,32 @@ export function writeExportFiles(files, root) {
|
|
|
55
95
|
}
|
|
56
96
|
return written;
|
|
57
97
|
}
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Serialize one published output to its target inside `exportsDir` (nothing is written yet); a target still written
|
|
100
|
+
* with the export prefix that is gone is refused, saying what to write. The export records its source: the graph it is
|
|
101
|
+
* published from (p.spec), its vars and seeds, the node, `cook`'s frame and fps, its packages.
|
|
102
|
+
*/
|
|
103
|
+
export async function prepareTarget(geo, graph, p, exportsDir, host, cook = {}) {
|
|
104
|
+
if (p.target.refused)
|
|
105
|
+
throw Object.assign(new Error(`"${p.label}" (${graph}): ${prefixGone(p.target.refused)}`), { status: 400 });
|
|
106
|
+
const root = exportsDir;
|
|
107
|
+
const dest = insideRoot(root, path.join(root, ...p.target.path.split('/')));
|
|
108
|
+
const source = exportSource({
|
|
109
|
+
graph, spec: p.spec, node: p.node, output: p.output, frame: cook.frame, fps: cook.fps,
|
|
110
|
+
format: p.target.format, options: p.target.options, packages: cook.packages, version: TOPOTOPO_VERSION,
|
|
111
|
+
});
|
|
112
|
+
const r = await serializeExport(geo, p.target.format, dest, p.target.options, host, source);
|
|
62
113
|
for (const f of r.files)
|
|
63
|
-
insideRoot(
|
|
64
|
-
return {
|
|
114
|
+
insideRoot(root, f.path);
|
|
115
|
+
return {
|
|
116
|
+
graph, output: p.output, label: p.label, node: p.node, target: p.target, root, files: r.files, summary: r.summary, warnings: r.warnings,
|
|
117
|
+
sourceFile: r.sourceFile, sourceManifest: r.sourceManifest,
|
|
118
|
+
};
|
|
65
119
|
}
|
|
66
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Write prepared targets and record the receipts of those inside `exportsDir` (the viewer lists that folder); two
|
|
122
|
+
* targets writing one file are refused before any write.
|
|
123
|
+
*/
|
|
67
124
|
export function writeTargets(prepared, exportsDir) {
|
|
68
125
|
const owner = new Map();
|
|
69
126
|
for (const p of prepared)
|
|
@@ -71,13 +128,15 @@ export function writeTargets(prepared, exportsDir) {
|
|
|
71
128
|
const key = path.resolve(f.path).toLowerCase(), other = owner.get(key);
|
|
72
129
|
// status: the viewer answers 409 (the request conflicts with itself); the CLI and MCP print the message
|
|
73
130
|
if (other && other !== p)
|
|
74
|
-
throw Object.assign(new Error(`"${other.label}" (${other.graph}) and "${p.label}" (${p.graph}) both write ${path.relative(
|
|
131
|
+
throw Object.assign(new Error(`"${other.label}" (${other.graph}) and "${p.label}" (${p.graph}) both write ${path.relative(p.root, f.path)}: give one a different export path`), { status: 409 });
|
|
75
132
|
owner.set(key, p);
|
|
76
133
|
}
|
|
77
134
|
const store = new ArtifactStore(exportsDir);
|
|
78
135
|
let written = 0;
|
|
79
136
|
for (const p of prepared) {
|
|
80
|
-
written += writeExportFiles(p.files,
|
|
137
|
+
written += writeExportFiles(p.files, p.root);
|
|
138
|
+
if (path.resolve(p.root) !== path.resolve(exportsDir))
|
|
139
|
+
continue;
|
|
81
140
|
store.record(p.files.map((f) => f.path), { label: p.target.path, graph: p.graph, node: p.node, format: p.target.format, output: p.output ?? '' });
|
|
82
141
|
}
|
|
83
142
|
return written;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The commands of the cook for an engine and of the Godot plugin's setup, as every list of them says them: src/cli.ts
|
|
2
|
+
// (its header and --help), the help topic "godot" (src/mcp/docs.ts), README.md and integrations/godot/PROTOCOL.md, each
|
|
3
|
+
// of which holds every usage as it is here (test/cook.ts checks). The commands themselves are src/host/godot.ts.
|
|
4
|
+
export const GODOT_COMMANDS = [
|
|
5
|
+
{
|
|
6
|
+
usage: 'cook <.topo | package folder | folder>... --for godot [--into <folder>] [--flat] [--skip a,b] [--instancing packed|expand] [--adopt] [--force] [--no-cache] [--timeout <s>] [--report <file>] [--progress json] [--quiet]',
|
|
7
|
+
what: 'cook the published outputs of packages inside a Godot project into it, one GLB (or PNG set) per output, only what changed, with the record <package>/.topotopo/godot.json; a folder means every package below it; options come from <id>.topo.import and flags override them',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
usage: 'cook --jobs <jobs.json> [--force] [--no-cache] [--progress json]',
|
|
11
|
+
what: 'the Godot plugin\'s form: many packages in one process, each with its options and report (integrations/godot/PROTOCOL.md)',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
usage: 'godot setup <godot project folder> [--no-enable]',
|
|
15
|
+
what: 'install the Godot plugin into a project: the addon, where TopoTopo is (~/.topotopo/config.json "install"), .gdignore in the TopoTopo folders of its packages, the plugin enabled, .gitignore lines, the addon kept out of every export preset, LFS warnings',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
usage: 'godot status <godot project folder> [--strict] [--json]',
|
|
19
|
+
what: 'every package Godot sees: ok, failed, stale (and why) or never cooked, each output, exposed TopoTopo folders, output folders LFS does not cover; --strict exits 1 on any of them (for CI)',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { Kind } from '../graph/outputs.ts';
|
|
2
|
+
import type { CookJob, EngineOptions, Flavour, Freshness } from './cook.ts';
|
|
3
|
+
import { GODOT_COMMANDS } from './godot-commands.ts';
|
|
4
|
+
import type { Io } from '../packages/commands.ts';
|
|
5
|
+
export { GODOT_COMMANDS };
|
|
6
|
+
/**
|
|
7
|
+
* The glTF extensions Godot 4.7's importer reads (GLTFDocument.get_supported_gltf_extensions() of the 4.7.2 editor,
|
|
8
|
+
* its built-in document extensions included). A GLB the cook writes requires none but these, and
|
|
9
|
+
* EXT_mesh_gpu_instancing when instances stay packed (the plugin's glTF extension reads it).
|
|
10
|
+
*/
|
|
11
|
+
export declare const GODOT_GLTF_EXTENSIONS: string[];
|
|
12
|
+
/** A package's TopoTopo folders, which Godot should not import (each with an empty .gdignore). */
|
|
13
|
+
export declare const GODOT_HIDDEN: string[];
|
|
14
|
+
/** The addon's folder in a project, and its plugin.cfg as project.godot names it. */
|
|
15
|
+
export declare const ADDON_DIR = "addons/topotopo";
|
|
16
|
+
export declare const PLUGIN_CFG = "res://addons/topotopo/plugin.cfg";
|
|
17
|
+
/** What a project's .gitignore gets: a cook's files being written, and its lock. */
|
|
18
|
+
export declare const GITIGNORE_LINES: string[];
|
|
19
|
+
/** What every export preset's exclude_filter gets: Godot's GDScript exporter ships the addon's scripts otherwise. */
|
|
20
|
+
export declare const PRESET_EXCLUDE = "addons/topotopo/*";
|
|
21
|
+
/** The import options' defaults (the plugin's package_importer.gd). */
|
|
22
|
+
export declare const IMPORT_DEFAULTS: {
|
|
23
|
+
folder: string;
|
|
24
|
+
per_output_folders: boolean;
|
|
25
|
+
skip: string;
|
|
26
|
+
mode: number;
|
|
27
|
+
};
|
|
28
|
+
/** The CLI the plugin runs: src/cli.ts in a checkout, dist/cli.js installed. */
|
|
29
|
+
export declare const CLI_PATH: string;
|
|
30
|
+
/** The addon this TopoTopo carries (integrations/godot/addons/topotopo, shipped in the npm package). */
|
|
31
|
+
export declare const ADDON_SOURCE: string;
|
|
32
|
+
/** A usage, setup or protocol error: exit code 2, nothing written. */
|
|
33
|
+
export declare class SetupError extends Error {
|
|
34
|
+
}
|
|
35
|
+
/** A path in a Godot project as res://… ("res://" for the project folder); throws for a path outside it. */
|
|
36
|
+
export declare function resPath(project: string, abs: string): string;
|
|
37
|
+
/** A res:// path in a project as a path. */
|
|
38
|
+
export declare function fromRes(project: string, res: string): string;
|
|
39
|
+
/** A res:// path normalised ("." and ".." resolved, no doubled or trailing slash); throws when it leaves the project. */
|
|
40
|
+
export declare function normalRes(res: string): string;
|
|
41
|
+
/** The [params] of a .topo's import file (<id>.topo.import), the plugin's import options; {} when there is none. */
|
|
42
|
+
export declare function readImportParams(topo: string): Record<string, string | number | boolean>;
|
|
43
|
+
/** Options given on the command line or in a job: each overrides the import options. */
|
|
44
|
+
export interface GivenOptions {
|
|
45
|
+
/** absolute, or res:// */
|
|
46
|
+
into?: string;
|
|
47
|
+
per_output_folders?: boolean;
|
|
48
|
+
skip?: string[];
|
|
49
|
+
instancing?: 'packed' | 'expand';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A package's cook options: the import options of its .topo (<id>.topo.import [params]: outputs/folder, relative to
|
|
53
|
+
* the package or res://; outputs/per_output_folders; outputs/skip, comma-separated; instances/mode, 0 MultiMesh or
|
|
54
|
+
* 1 Expand), the defaults where it has none, and `given` over both; the folder as a normalised res:// path.
|
|
55
|
+
*/
|
|
56
|
+
export declare function godotOptions(topo: string, project: string, given?: GivenOptions): EngineOptions;
|
|
57
|
+
/** The JSON chunk of a GLB, or null for bytes that are none. */
|
|
58
|
+
export declare function glbJson(bytes: Uint8Array): any;
|
|
59
|
+
/** The package a GLB's source block names (asset.extras.source.package), or null. */
|
|
60
|
+
export declare function glbPackage(file: string): string | null;
|
|
61
|
+
/** The keyword of the tEXt chunk that names the package a cooked PNG was made for (PNG has no source block). */
|
|
62
|
+
export declare const PNG_PACKAGE_KEY = "TopoTopo package";
|
|
63
|
+
/** A PNG with a tEXt chunk after its IHDR naming the package it was cooked for (decoders ignore it). */
|
|
64
|
+
export declare function markPng(bytes: Uint8Array, pkg: string): Uint8Array;
|
|
65
|
+
/** The package a PNG's tEXt chunk names (markPng), or null. */
|
|
66
|
+
export declare function pngPackage(bytes: Uint8Array): string | null;
|
|
67
|
+
/** The package a cooked file says it was made for: a GLB's source block, a PNG's tEXt chunk; null for other files. */
|
|
68
|
+
export declare function cookedFor(file: string): string | null;
|
|
69
|
+
/** Why outputs of a kind are not imported (v1), or null. */
|
|
70
|
+
export declare function godotSkipKind(kind: Kind): string | null;
|
|
71
|
+
/** The Godot flavour of the cook for one project. */
|
|
72
|
+
export declare function godotFlavour(project: string): Flavour;
|
|
73
|
+
/**
|
|
74
|
+
* Walk a Godot project as Godot's scan sees it: names starting with "." are not seen, a folder holding .gdignore and a
|
|
75
|
+
* folder below the root holding project.godot are not entered. `visit` gets each folder and its file names; it
|
|
76
|
+
* returns false to leave the folder's subfolders out.
|
|
77
|
+
*/
|
|
78
|
+
export declare function godotWalk(root: string, visit: (dir: string, files: string[]) => boolean | void): void;
|
|
79
|
+
/**
|
|
80
|
+
* A .topo that is a published copy, not a package: one beside a version.json, in a topotopo-packages/ folder, or in
|
|
81
|
+
* the versions/ or packages/ folder of a package (a folder holding a .topo).
|
|
82
|
+
*/
|
|
83
|
+
export declare function isPublishedCopy(topo: string): boolean;
|
|
84
|
+
/** Every .topo Godot's scan of a project sees, with whether it is a published copy. */
|
|
85
|
+
export declare function godotTopos(project: string): {
|
|
86
|
+
topo: string;
|
|
87
|
+
copy: boolean;
|
|
88
|
+
}[];
|
|
89
|
+
/**
|
|
90
|
+
* The packages a cook target names: a .topo file, a package folder, or every package below a folder (dot folders,
|
|
91
|
+
* .gdignore folders, folders below it holding project.godot, versions/, packages/ and topotopo-packages/ skipped; a
|
|
92
|
+
* package is not entered). Throws a SetupError for a target that is none of these.
|
|
93
|
+
*/
|
|
94
|
+
export declare function cookTargets(target: string): string[];
|
|
95
|
+
/**
|
|
96
|
+
* A package to cook: its manifest (checked: one .topo, an id), not a published copy, inside a Godot project; the
|
|
97
|
+
* options from its import file with `given` over them. Throws a SetupError otherwise.
|
|
98
|
+
*/
|
|
99
|
+
export declare function godotJob(topo: string, given?: GivenOptions & {
|
|
100
|
+
adopt?: boolean;
|
|
101
|
+
report?: string;
|
|
102
|
+
timeout?: number;
|
|
103
|
+
}): CookJob & {
|
|
104
|
+
project: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* topotopo cook … --for godot, and cook --jobs <file>: every package checked first (a usage, setup or protocol error
|
|
108
|
+
* exits 2 and writes nothing), then cooked one after the other in this process; exit 1 when an output or a package
|
|
109
|
+
* failed (records and reports are still written), else 0.
|
|
110
|
+
*/
|
|
111
|
+
export declare function cookCommand(argv: string[], io: Io): Promise<number>;
|
|
112
|
+
/** A jobs file read and checked (protocol, flavour, each job's package and options); throws a SetupError. */
|
|
113
|
+
export declare function readJobs(file: string): (CookJob & {
|
|
114
|
+
project: string;
|
|
115
|
+
})[];
|
|
116
|
+
/** A package as godot status sees it. */
|
|
117
|
+
export interface PackageStatus {
|
|
118
|
+
/** the .topo as res:// */
|
|
119
|
+
topo: string;
|
|
120
|
+
id: string;
|
|
121
|
+
state: Freshness['state'];
|
|
122
|
+
why: string;
|
|
123
|
+
path: string;
|
|
124
|
+
note: string;
|
|
125
|
+
text: string;
|
|
126
|
+
outputs: {
|
|
127
|
+
id: string;
|
|
128
|
+
state: string;
|
|
129
|
+
kind: string;
|
|
130
|
+
files: string[];
|
|
131
|
+
errors: {
|
|
132
|
+
node: string;
|
|
133
|
+
message: string;
|
|
134
|
+
hint: string;
|
|
135
|
+
}[];
|
|
136
|
+
}[];
|
|
137
|
+
skipped: {
|
|
138
|
+
id: string;
|
|
139
|
+
why: string;
|
|
140
|
+
}[];
|
|
141
|
+
exposed: string[];
|
|
142
|
+
/** output folders an LFS pattern does not cover, in a repository that uses LFS */
|
|
143
|
+
lfs: string[];
|
|
144
|
+
}
|
|
145
|
+
export interface StatusResult {
|
|
146
|
+
project: string;
|
|
147
|
+
packages: PackageStatus[];
|
|
148
|
+
/** published copies Godot sees (res:// of their .topo) */
|
|
149
|
+
copies: string[];
|
|
150
|
+
/** export presets that would ship the addon */
|
|
151
|
+
presets: string[];
|
|
152
|
+
/** a package at the project's root (not supported) */
|
|
153
|
+
root: string[];
|
|
154
|
+
ok: boolean;
|
|
155
|
+
}
|
|
156
|
+
/** The export presets (export_presets.cfg) whose exclude_filter does not keep the addon out. */
|
|
157
|
+
export declare function presetsShippingAddon(project: string): string[];
|
|
158
|
+
/** What `topotopo godot status` finds: every .topo Godot sees, checked with the one freshness rule (this TopoTopo installed). */
|
|
159
|
+
export declare function godotStatus(project: string): StatusResult;
|
|
160
|
+
/** A status as people read it. */
|
|
161
|
+
export declare function statusText(r: StatusResult): string;
|
|
162
|
+
/** project.godot with the plugin enabled ([editor_plugins] enabled=PackedStringArray(…)); null when it is enabled already. */
|
|
163
|
+
export declare function enablePlugin(text: string): string | null;
|
|
164
|
+
/** export_presets.cfg with addons/topotopo/* in every preset's exclude_filter; null when nothing changes. */
|
|
165
|
+
export declare function excludeAddon(text: string): string | null;
|
|
166
|
+
export interface SetupOptions {
|
|
167
|
+
/** enable the plugin in project.godot (default true) */
|
|
168
|
+
enable?: boolean;
|
|
169
|
+
/** the addon to copy (default: the one this TopoTopo carries) */
|
|
170
|
+
addon?: string;
|
|
171
|
+
/** what the install record names (default: this node and this CLI) */
|
|
172
|
+
node?: string;
|
|
173
|
+
cli?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* topotopo godot setup: install the plugin into a Godot project, saying each step. Throws a SetupError for a folder
|
|
177
|
+
* that is no Godot project or a TopoTopo without the addon.
|
|
178
|
+
*/
|
|
179
|
+
export declare function godotSetup(project: string, o?: SetupOptions): string[];
|
|
180
|
+
/** topotopo godot setup | status. */
|
|
181
|
+
export declare function godotCommand(argv: string[], io: Io): Promise<number>;
|
|
182
|
+
/** A package id from a folder name, for messages about folders without a manifest. */
|
|
183
|
+
export declare const idOf: (dir: string) => string;
|