topotopo 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +10 -10
- package/README.md +460 -117
- package/dist/cli.js +327 -147
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/bake.d.ts +14 -3
- package/dist/core/bake.js +153 -4
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +76 -3
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +203 -3
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +7 -0
- package/dist/core/materials.js +45 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- package/dist/core/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- package/dist/core/scene.js +2 -1
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +14 -1
- package/dist/core/snippet-lib.js +39 -13
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +5 -1
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +10 -0
- package/dist/core/topology.js +168 -0
- package/dist/core/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +4 -18
- package/dist/core/uv.js +35 -188
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +61 -0
- package/dist/core/uvreport.js +207 -143
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +66 -62
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +80 -2
- package/dist/inspect.js +265 -30
- package/dist/io/common.d.ts +25 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +134 -47
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +148 -13
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +786 -143
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +56 -27
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +198 -103
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +151 -47
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +51 -3
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +21 -9
- package/dist/nodes/curves.js +433 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +12 -38
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.js +16 -19
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +1 -0
- package/dist/nodes/material.js +89 -24
- package/dist/nodes/measure.js +43 -17
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.js +4 -2
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +6 -2
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +5 -1
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +57 -5
- package/dist/render/preview.d.ts +17 -4
- package/dist/render/preview.js +6 -4
- package/dist/render/raster.d.ts +74 -5
- package/dist/render/raster.js +527 -143
- package/dist/render/texview.d.ts +6 -0
- package/dist/render/texview.js +27 -0
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +27 -7
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +5 -1
- package/dist/viewer/app/guides.js +122 -0
- package/dist/viewer/app/keymap.js +6 -3
- package/dist/viewer/app/layers.js +4 -4
- package/dist/viewer/app/main.js +185 -52
- package/dist/viewer/app/markers.js +60 -0
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +176 -52
- package/dist/viewer/app/scene.js +30 -5
- package/dist/viewer/app/select.js +4 -3
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +65 -7
- package/dist/viewer/app/vars.js +47 -0
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +23 -10
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +14 -9
- package/dist/viewer/server.js +266 -28
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/{gallery → web}/bake.d.ts +4 -4
- package/dist/{gallery → web}/bake.js +24 -15
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -118
- package/dist/workspace.js +358 -460
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +2 -1
- package/kernels/pkg-simd/README.md +2 -1
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +13 -8
- package/dist/gallery/app/gallery.css +0 -100
- package/dist/gallery/app/gallery.js +0 -80
- package/dist/gallery/cli.d.ts +0 -4
- package/dist/gallery/cli.js +0 -157
- package/dist/gallery/library.d.ts +0 -124
- package/dist/gallery/library.js +0 -366
- package/dist/gallery/pages.d.ts +0 -94
- package/dist/gallery/pages.js +0 -148
- package/dist/gallery/server.d.ts +0 -21
- package/dist/gallery/server.js +0 -391
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/dist/mcp/library.d.ts +0 -12
- package/dist/mcp/library.js +0 -159
- package/shelf/index.json +0 -190
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ID_RE } from '../graph/scope.ts';
|
|
2
|
+
import type { WebConfig, LibraryRef } from '../config.ts';
|
|
3
|
+
import type { PackageLink, PackageManifest } from '../package.ts';
|
|
4
|
+
import type { Package, Scan } from '../scan.ts';
|
|
5
|
+
export type { Package };
|
|
6
|
+
/** Bumped when the baked files change shape (render options, GLB options), so every package bakes again. */
|
|
7
|
+
export declare const BAKE_VERSION = 1;
|
|
8
|
+
/** a library name or package id: lower-case letters, digits, "-" and "_", starting with a letter or digit (the package name rule) */
|
|
9
|
+
export { ID_RE };
|
|
10
|
+
export interface BakeState {
|
|
11
|
+
key: string;
|
|
12
|
+
/** ms since the epoch */
|
|
13
|
+
at: number;
|
|
14
|
+
ok: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
ms?: number;
|
|
17
|
+
/** preview.glb was written (false: too large, or the bake failed before it) */
|
|
18
|
+
glb?: boolean;
|
|
19
|
+
points?: number;
|
|
20
|
+
prims?: number;
|
|
21
|
+
warnings?: string[];
|
|
22
|
+
}
|
|
23
|
+
/** A library's or workspace's packages (src/scan.ts); `workspace`: it is a registered workspace. */
|
|
24
|
+
export type LibraryScan = Scan & {
|
|
25
|
+
workspace?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A registered library or workspace: its name and folder (a workspace's packages are scanned as its file says). */
|
|
28
|
+
export type PlaceRef = LibraryRef & {
|
|
29
|
+
workspace?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Every package below a library's (or, `workspace`, a workspace's) root, sorted by path (src/scan.ts). A workspace goes
|
|
33
|
+
* by the name in its file, which its packages carry, whatever name it was registered under.
|
|
34
|
+
*/
|
|
35
|
+
export declare function scanLibrary(lib: PlaceRef): LibraryScan;
|
|
36
|
+
/**
|
|
37
|
+
* The registered libraries and workspaces, scanned: the libraries first, then the workspaces; a library inside a
|
|
38
|
+
* registered workspace is left out (its packages are the workspace's).
|
|
39
|
+
*/
|
|
40
|
+
export declare function scanAll(cfg?: WebConfig): LibraryScan[];
|
|
41
|
+
export interface CreateOptions {
|
|
42
|
+
title?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
tags?: string[];
|
|
45
|
+
links?: PackageLink[];
|
|
46
|
+
graph?: object;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A new package at `<root>/<rel>` ("props/lantern") of a library or a workspace: <id>.topo, the package folders,
|
|
50
|
+
* attachments/, a .gitignore for the derived files and a .gitattributes that keeps its versions and copies byte for
|
|
51
|
+
* byte (inside a Godot project, a .gdignore in inputs/). `graph` (a graph spec) becomes graphs/main.json. Fails when
|
|
52
|
+
* the folder holds a package already, lies inside one, the path holds a folder the scan never enters, or the id is
|
|
53
|
+
* taken in the library or workspace.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createPackage(lib: PlaceRef, rel: string, o?: CreateOptions): Package;
|
|
56
|
+
/**
|
|
57
|
+
* The place a registered library's or workspace's name stands for, as the web app serves it: a library, a workspace by
|
|
58
|
+
* the name in its file, or for a library inside a registered workspace that workspace (its packages are the
|
|
59
|
+
* workspace's, at /p/<workspace>/<id>), with the library's folder below it (`prefix`, posix; '' for a place that is
|
|
60
|
+
* itself). null for a name none has.
|
|
61
|
+
*/
|
|
62
|
+
export declare function placeNamed(cfg: WebConfig, name: string): {
|
|
63
|
+
place: PlaceRef;
|
|
64
|
+
prefix: string;
|
|
65
|
+
} | null;
|
|
66
|
+
/** A registered workspace's name as a place of the web app (and createPackage), or null when its file cannot be read. */
|
|
67
|
+
export declare function workspaceRef(w: LibraryRef): PlaceRef;
|
|
68
|
+
export interface PackageFile {
|
|
69
|
+
path: string;
|
|
70
|
+
size: number;
|
|
71
|
+
mtime: number;
|
|
72
|
+
image: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Files under a package subfolder (attachments/, exports/, inputs/), recursively: posix paths; dot-files and the files
|
|
76
|
+
* an engine writes beside ours (*.import, *.uid, *.uasset …) skipped.
|
|
77
|
+
*/
|
|
78
|
+
export declare function listFiles(dir: string): PackageFile[];
|
|
79
|
+
/** A package's graph names: graphs/ and the graph files beside its manifest (graphFiles). */
|
|
80
|
+
export declare const graphNames: (dir: string) => string[];
|
|
81
|
+
/** A package's graph file, parsed (null when missing or unreadable). */
|
|
82
|
+
export declare function readGraph(dir: string, name: string): any;
|
|
83
|
+
export declare const webDir: (dir: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* What a bake depends on: the bake version, the package version, the manifest's graph and bake choice, every graph
|
|
86
|
+
* and asset file's content, each input file's path, size and time, and the package lock (the versions it uses).
|
|
87
|
+
*/
|
|
88
|
+
export declare function bakeKey(dir: string, m: PackageManifest): string;
|
|
89
|
+
export declare function readBakeState(dir: string): BakeState | null;
|
|
90
|
+
/** The package needs a bake: never baked, or something it depends on changed since. */
|
|
91
|
+
export declare function isStale(p: Package): boolean;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Libraries and workspaces of packages, as the web app shows them: scanning one for its packages (the one scan,
|
|
2
|
+
// src/scan.ts: .topo files only; it never creates folders and never cooks), creating a package in one, a package's
|
|
3
|
+
// files, and baking its previews (.web/: thumb.png, preview.glb, bake.json, all derived). Packages themselves are
|
|
4
|
+
// src/package.ts.
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { ID_RE } from '../graph/scope.js';
|
|
9
|
+
import { graphFiles } from '../session.js';
|
|
10
|
+
import { loadConfig } from '../config.js';
|
|
11
|
+
import { manifestAt, parseManifest, packageRepoFiles, slugify, within, writeManifest } from '../package.js';
|
|
12
|
+
import { folderKey, forgetScans, scanTree, unscanned } from '../scan.js';
|
|
13
|
+
import { engineFile, readWorkspace, scanWorkspace } from '../workspace.js';
|
|
14
|
+
import { godotIgnore, isEngineFile } from '../engines.js';
|
|
15
|
+
/** Bumped when the baked files change shape (render options, GLB options), so every package bakes again. */
|
|
16
|
+
export const BAKE_VERSION = 1;
|
|
17
|
+
/** a library name or package id: lower-case letters, digits, "-" and "_", starting with a letter or digit (the package name rule) */
|
|
18
|
+
export { ID_RE };
|
|
19
|
+
/** Folder names a scan never enters (src/scan.ts), which no package path may hold. */
|
|
20
|
+
const SKIPPED = new Set(['node_modules', 'topotopo-packages', 'binaries', 'intermediate', 'saved', 'deriveddatacache', '__externalactors__', '__externalobjects__']);
|
|
21
|
+
const jsonFiles = (dir) => { try {
|
|
22
|
+
return fs.readdirSync(dir).filter((f) => f.endsWith('.json')).sort();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return [];
|
|
26
|
+
} };
|
|
27
|
+
const PKG_VERSION = (() => {
|
|
28
|
+
// package.json sits two levels above both src/web/library.ts and dist/web/library.js
|
|
29
|
+
try {
|
|
30
|
+
return String(JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return '0';
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
// ------------------------------------------------------------------------------------------------------------ scan
|
|
37
|
+
/**
|
|
38
|
+
* Every package below a library's (or, `workspace`, a workspace's) root, sorted by path (src/scan.ts). A workspace goes
|
|
39
|
+
* by the name in its file, which its packages carry, whatever name it was registered under.
|
|
40
|
+
*/
|
|
41
|
+
export function scanLibrary(lib) {
|
|
42
|
+
if (!lib.workspace)
|
|
43
|
+
return scanTree(lib.name, lib.path);
|
|
44
|
+
try {
|
|
45
|
+
return { ...scanWorkspace(path.resolve(lib.path)), workspace: true };
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
return { name: lib.name, root: path.resolve(lib.path), packages: [], problems: [e.message], workspaces: [], workspace: true };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The registered libraries and workspaces, scanned: the libraries first, then the workspaces; a library inside a
|
|
53
|
+
* registered workspace is left out (its packages are the workspace's).
|
|
54
|
+
*/
|
|
55
|
+
export function scanAll(cfg = loadConfig()) {
|
|
56
|
+
const libs = cfg.libraries.filter((l) => !cfg.workspaces.some((w) => within(l.path, w.path)));
|
|
57
|
+
return [...libs.map((l) => scanLibrary(l)), ...cfg.workspaces.map((w) => scanLibrary({ ...w, workspace: true }))];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A new package at `<root>/<rel>` ("props/lantern") of a library or a workspace: <id>.topo, the package folders,
|
|
61
|
+
* attachments/, a .gitignore for the derived files and a .gitattributes that keeps its versions and copies byte for
|
|
62
|
+
* byte (inside a Godot project, a .gdignore in inputs/). `graph` (a graph spec) becomes graphs/main.json. Fails when
|
|
63
|
+
* the folder holds a package already, lies inside one, the path holds a folder the scan never enters, or the id is
|
|
64
|
+
* taken in the library or workspace.
|
|
65
|
+
*/
|
|
66
|
+
export function createPackage(lib, rel, o = {}) {
|
|
67
|
+
const parts = rel.replace(/\\/g, '/').split('/').filter(Boolean);
|
|
68
|
+
if (!parts.length || parts.some((p) => p === '.' || p === '..' || p.startsWith('.') || SKIPPED.has(p.toLowerCase()) || /[<>:"|?*\u0000-\u001f]/.test(p)))
|
|
69
|
+
throw new Error(`bad package path "${rel}": give folders below the ${lib.workspace ? 'workspace' : 'library'}, e.g. "props/lantern" (no dot folders, node_modules, topotopo-packages or engine build folders)`);
|
|
70
|
+
const root = path.resolve(lib.path);
|
|
71
|
+
const dir = path.join(root, ...parts);
|
|
72
|
+
if (manifestAt(dir))
|
|
73
|
+
throw new Error(`${dir} is a package already`);
|
|
74
|
+
const id = slugify(parts[parts.length - 1]);
|
|
75
|
+
if (!ID_RE.test(id))
|
|
76
|
+
throw new Error(`"${parts[parts.length - 1]}" gives no usable id: use letters or digits`);
|
|
77
|
+
const scan = scanLibrary(lib);
|
|
78
|
+
const taken = scan.packages.find((p) => p.id === id);
|
|
79
|
+
if (taken)
|
|
80
|
+
throw new Error(`id "${id}" is used by ${taken.rel} in ${lib.workspace ? 'the workspace' : 'library'} "${lib.name}": pick another folder name`);
|
|
81
|
+
if (scan.packages.some((p) => dir.startsWith(p.dir + path.sep)))
|
|
82
|
+
throw new Error(`${rel} is inside another package`);
|
|
83
|
+
// a folder the scan never reaches holds no package it finds (src/scan.ts says why)
|
|
84
|
+
let engine = null;
|
|
85
|
+
if (lib.workspace) {
|
|
86
|
+
try {
|
|
87
|
+
engine = engineFile(root, readWorkspace(root));
|
|
88
|
+
}
|
|
89
|
+
catch { /* its file cannot be read: the scan finds nothing either */ }
|
|
90
|
+
}
|
|
91
|
+
const unreached = unscanned(root, dir, { engine });
|
|
92
|
+
if (unreached)
|
|
93
|
+
throw new Error(`bad package path "${rel}": ${unreached}: ${lib.workspace ? 'the workspace' : 'the library'} would not find a package there; pick another folder`);
|
|
94
|
+
for (const d of ['graphs', 'assets', 'inputs', 'exports', 'attachments'])
|
|
95
|
+
fs.mkdirSync(path.join(dir, d), { recursive: true });
|
|
96
|
+
packageRepoFiles(dir);
|
|
97
|
+
const manifest = parseManifest({
|
|
98
|
+
title: o.title ?? parts[parts.length - 1], description: o.description ?? '', tags: o.tags ?? [], links: o.links ?? [],
|
|
99
|
+
graph: 'main', created: new Date().toISOString().slice(0, 10),
|
|
100
|
+
}, id);
|
|
101
|
+
writeManifest(dir, manifest, id);
|
|
102
|
+
godotIgnore(dir);
|
|
103
|
+
if (o.graph)
|
|
104
|
+
fs.writeFileSync(path.join(dir, 'graphs', 'main.json'), JSON.stringify(o.graph, null, 2));
|
|
105
|
+
forgetScans();
|
|
106
|
+
const made = scanLibrary(lib).packages.find((p) => folderKey(p.dir) === folderKey(dir));
|
|
107
|
+
if (!made)
|
|
108
|
+
throw new Error(`made the package ${dir}, and the scan of ${lib.workspace ? 'the workspace' : 'library'} "${lib.name}" does not find it: ${scanLibrary(lib).problems.find((p) => p.includes(parts.join('/'))) ?? 'see topotopo library list'}`);
|
|
109
|
+
return made;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The place a registered library's or workspace's name stands for, as the web app serves it: a library, a workspace by
|
|
113
|
+
* the name in its file, or for a library inside a registered workspace that workspace (its packages are the
|
|
114
|
+
* workspace's, at /p/<workspace>/<id>), with the library's folder below it (`prefix`, posix; '' for a place that is
|
|
115
|
+
* itself). null for a name none has.
|
|
116
|
+
*/
|
|
117
|
+
export function placeNamed(cfg, name) {
|
|
118
|
+
const lib = cfg.libraries.find((l) => l.name === name);
|
|
119
|
+
if (lib) {
|
|
120
|
+
const w = cfg.workspaces.find((x) => within(lib.path, x.path));
|
|
121
|
+
if (!w)
|
|
122
|
+
return { place: lib, prefix: '' };
|
|
123
|
+
const prefix = path.relative(path.resolve(w.path), path.resolve(lib.path)).split(path.sep).join('/');
|
|
124
|
+
return { place: workspaceRef(w), prefix };
|
|
125
|
+
}
|
|
126
|
+
const ws = cfg.workspaces.map(workspaceRef).find((w) => w.name === name);
|
|
127
|
+
return ws ? { place: ws, prefix: '' } : null;
|
|
128
|
+
}
|
|
129
|
+
/** A registered workspace's name as a place of the web app (and createPackage), or null when its file cannot be read. */
|
|
130
|
+
export function workspaceRef(w) {
|
|
131
|
+
let name = w.name;
|
|
132
|
+
try {
|
|
133
|
+
name = readWorkspace(w.path).name;
|
|
134
|
+
}
|
|
135
|
+
catch { /* its registered name */ }
|
|
136
|
+
return { name, path: w.path, workspace: true };
|
|
137
|
+
}
|
|
138
|
+
const IMAGE_RE = /\.(png|jpe?g|webp|gif|avif)$/i;
|
|
139
|
+
/**
|
|
140
|
+
* Files under a package subfolder (attachments/, exports/, inputs/), recursively: posix paths; dot-files and the files
|
|
141
|
+
* an engine writes beside ours (*.import, *.uid, *.uasset …) skipped.
|
|
142
|
+
*/
|
|
143
|
+
export function listFiles(dir) {
|
|
144
|
+
const out = [];
|
|
145
|
+
const walk = (d, rel, depth) => {
|
|
146
|
+
let entries;
|
|
147
|
+
try {
|
|
148
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
for (const e of entries) {
|
|
154
|
+
if (e.name.startsWith('.'))
|
|
155
|
+
continue;
|
|
156
|
+
const abs = path.join(d, e.name), r = rel ? `${rel}/${e.name}` : e.name;
|
|
157
|
+
let st;
|
|
158
|
+
try {
|
|
159
|
+
st = fs.statSync(abs);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (st.isDirectory()) {
|
|
165
|
+
if (depth < 16)
|
|
166
|
+
walk(abs, r, depth + 1);
|
|
167
|
+
}
|
|
168
|
+
else if (st.isFile() && !isEngineFile(e.name))
|
|
169
|
+
out.push({ path: r, size: st.size, mtime: Math.round(st.mtimeMs), image: IMAGE_RE.test(e.name) });
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
walk(dir, '', 0);
|
|
173
|
+
return out.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
174
|
+
}
|
|
175
|
+
/** A package's graph names: graphs/ and the graph files beside its manifest (graphFiles). */
|
|
176
|
+
export const graphNames = (dir) => [...graphFiles(dir).keys()];
|
|
177
|
+
/** A package's graph file, parsed (null when missing or unreadable). */
|
|
178
|
+
export function readGraph(dir, name) {
|
|
179
|
+
try {
|
|
180
|
+
return JSON.parse(fs.readFileSync(path.join(dir, 'graphs', name + '.json'), 'utf8'));
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// ------------------------------------------------------------------------------------------------------------ bake
|
|
187
|
+
export const webDir = (dir) => path.join(dir, '.web');
|
|
188
|
+
/**
|
|
189
|
+
* What a bake depends on: the bake version, the package version, the manifest's graph and bake choice, every graph
|
|
190
|
+
* and asset file's content, each input file's path, size and time, and the package lock (the versions it uses).
|
|
191
|
+
*/
|
|
192
|
+
export function bakeKey(dir, m) {
|
|
193
|
+
const h = createHash('sha256');
|
|
194
|
+
h.update(`${BAKE_VERSION}|${PKG_VERSION}|${m.graph}|${JSON.stringify(m.bake)}\n`);
|
|
195
|
+
// the graphs (graphs/ and those beside the manifest) and the assets
|
|
196
|
+
const files = [...graphFiles(dir).values(), ...jsonFiles(path.join(dir, 'assets')).map((f) => path.join(dir, 'assets', f))];
|
|
197
|
+
for (const f of files) {
|
|
198
|
+
h.update(`${path.relative(dir, f).split(path.sep).join('/')}\n`);
|
|
199
|
+
try {
|
|
200
|
+
h.update(fs.readFileSync(f));
|
|
201
|
+
}
|
|
202
|
+
catch { /* removed meanwhile */ }
|
|
203
|
+
}
|
|
204
|
+
for (const f of listFiles(path.join(dir, 'inputs')))
|
|
205
|
+
h.update(`inputs/${f.path}|${f.size}|${f.mtime}\n`);
|
|
206
|
+
const lock = path.join(dir, 'packages', 'lock.json');
|
|
207
|
+
if (fs.existsSync(lock)) {
|
|
208
|
+
h.update('packages/lock.json\n');
|
|
209
|
+
try {
|
|
210
|
+
h.update(fs.readFileSync(lock));
|
|
211
|
+
}
|
|
212
|
+
catch { /* removed meanwhile */ }
|
|
213
|
+
}
|
|
214
|
+
return h.digest('hex').slice(0, 32);
|
|
215
|
+
}
|
|
216
|
+
export function readBakeState(dir) {
|
|
217
|
+
try {
|
|
218
|
+
return JSON.parse(fs.readFileSync(path.join(webDir(dir), 'bake.json'), 'utf8'));
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** The package needs a bake: never baked, or something it depends on changed since. */
|
|
225
|
+
export function isStale(p) {
|
|
226
|
+
const s = readBakeState(p.dir);
|
|
227
|
+
return !s || s.key !== bakeKey(p.dir, p.manifest);
|
|
228
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface MdLink {
|
|
2
|
+
/** the destination as written (angle brackets removed, backslash escapes resolved) */
|
|
3
|
+
href: string;
|
|
4
|
+
/** the link text, or an image's alt, as plain text */
|
|
5
|
+
text: string;
|
|
6
|
+
title: string;
|
|
7
|
+
image: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What a link shows as: HTML in the text (phrasing content), or that and a block to show below its paragraph (a card,
|
|
11
|
+
* a picture, a player). A link alone in its paragraph may show only the block, in its place.
|
|
12
|
+
*/
|
|
13
|
+
export type LinkOut = string | {
|
|
14
|
+
inline: string;
|
|
15
|
+
block?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The HTML for a link or image, or null for the default rendering. `at.alone`: the link is all its paragraph or list
|
|
19
|
+
* item holds.
|
|
20
|
+
*/
|
|
21
|
+
export type LinkRender = (l: MdLink, inner: string, at: {
|
|
22
|
+
alone: boolean;
|
|
23
|
+
}) => LinkOut | null;
|
|
24
|
+
export interface MdOptions {
|
|
25
|
+
link?: LinkRender;
|
|
26
|
+
/** put before every heading id and #fragment link, so that two notes on one page keep their anchors apart */
|
|
27
|
+
idPrefix?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const escHtml: (s: string) => string;
|
|
30
|
+
/** A heading's anchor: lower case, letters, digits and dashes. */
|
|
31
|
+
export declare const slug: (s: string) => string;
|
|
32
|
+
/** Only these destinations become links by default. */
|
|
33
|
+
export declare const safeHref: (href: string) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Front matter: a first line "---", key: value lines (lists below a key as "- item" lines), and a closing "---" or
|
|
36
|
+
* "..." (as GitHub and Obsidian read it); the properties in order and where the document starts after it, or null.
|
|
37
|
+
*/
|
|
38
|
+
export declare function frontMatter(lines: string[]): {
|
|
39
|
+
props: [string, string][];
|
|
40
|
+
next: number;
|
|
41
|
+
} | null;
|
|
42
|
+
/** The HTML of a markdown document: escaped throughout, links and images through `o.link`. */
|
|
43
|
+
export declare function renderMarkdown(src: string, o?: MdOptions): string;
|
|
44
|
+
/** Every link and image of a markdown document, in order (what renderMarkdown hands its callback). */
|
|
45
|
+
export declare function markdownLinks(src: string): MdLink[];
|