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.
Files changed (336) hide show
  1. package/NOTICE +10 -10
  2. package/README.md +460 -117
  3. package/dist/cli.js +327 -147
  4. package/dist/config.d.ts +48 -0
  5. package/dist/config.js +170 -0
  6. package/dist/core/bake.d.ts +14 -3
  7. package/dist/core/bake.js +153 -4
  8. package/dist/core/bevel.d.ts +3 -1
  9. package/dist/core/bevel.js +76 -3
  10. package/dist/core/decimate.d.ts +65 -0
  11. package/dist/core/decimate.js +409 -3
  12. package/dist/core/erosion.d.ts +37 -0
  13. package/dist/core/erosion.js +41 -1
  14. package/dist/core/geometry.d.ts +5 -1
  15. package/dist/core/geometry.js +203 -3
  16. package/dist/core/heightfield.d.ts +27 -4
  17. package/dist/core/heightfield.js +54 -16
  18. package/dist/core/intrinsics.d.ts +7 -0
  19. package/dist/core/intrinsics.js +94 -0
  20. package/dist/core/manifold.d.ts +12 -1
  21. package/dist/core/manifold.js +78 -6
  22. package/dist/core/materials.d.ts +7 -0
  23. package/dist/core/materials.js +45 -0
  24. package/dist/core/noise.d.ts +9 -0
  25. package/dist/core/noise.js +10 -1
  26. package/dist/core/polymerge.d.ts +21 -0
  27. package/dist/core/polymerge.js +327 -0
  28. package/dist/core/repair.d.ts +2 -0
  29. package/dist/core/repair.js +2 -0
  30. package/dist/core/report.d.ts +70 -0
  31. package/dist/core/report.js +275 -0
  32. package/dist/core/scene.js +2 -1
  33. package/dist/core/sha256.d.ts +4 -0
  34. package/dist/core/sha256.js +69 -0
  35. package/dist/core/shapes.d.ts +3 -0
  36. package/dist/core/shapes.js +34 -0
  37. package/dist/core/snippet-lib.d.ts +14 -1
  38. package/dist/core/snippet-lib.js +39 -13
  39. package/dist/core/tangents.d.ts +2 -0
  40. package/dist/core/tangents.js +5 -1
  41. package/dist/core/texnoise.d.ts +6 -1
  42. package/dist/core/texnoise.js +6 -2
  43. package/dist/core/texsdf.d.ts +131 -0
  44. package/dist/core/texsdf.js +637 -0
  45. package/dist/core/texture.d.ts +163 -9
  46. package/dist/core/texture.js +844 -20
  47. package/dist/core/topology.d.ts +10 -0
  48. package/dist/core/topology.js +168 -0
  49. package/dist/core/unwrap.d.ts +72 -0
  50. package/dist/core/unwrap.js +800 -0
  51. package/dist/core/usercode.d.ts +27 -0
  52. package/dist/core/usercode.js +87 -0
  53. package/dist/core/uv.d.ts +4 -18
  54. package/dist/core/uv.js +35 -188
  55. package/dist/core/uvislands.d.ts +62 -0
  56. package/dist/core/uvislands.js +574 -0
  57. package/dist/core/uvoverlap.d.ts +58 -0
  58. package/dist/core/uvoverlap.js +220 -0
  59. package/dist/core/uvpack.d.ts +64 -0
  60. package/dist/core/uvpack.js +628 -0
  61. package/dist/core/uvreport.d.ts +61 -0
  62. package/dist/core/uvreport.js +207 -143
  63. package/dist/core/wrangle.d.ts +6 -1
  64. package/dist/core/wrangle.js +27 -16
  65. package/dist/core/xatlas.d.ts +16 -1
  66. package/dist/core/xatlas.js +66 -62
  67. package/dist/engines.d.ts +63 -0
  68. package/dist/engines.js +180 -0
  69. package/dist/explain.d.ts +4 -3
  70. package/dist/explain.js +129 -12
  71. package/dist/graph/engine.d.ts +92 -29
  72. package/dist/graph/engine.js +298 -148
  73. package/dist/graph/expr.d.ts +6 -3
  74. package/dist/graph/expr.js +18 -8
  75. package/dist/graph/outputs.d.ts +23 -0
  76. package/dist/graph/outputs.js +41 -0
  77. package/dist/graph/packages.d.ts +72 -0
  78. package/dist/graph/packages.js +261 -0
  79. package/dist/graph/parallel.d.ts +3 -1
  80. package/dist/graph/parallel.js +4 -1
  81. package/dist/graph/params.d.ts +6 -0
  82. package/dist/graph/params.js +34 -7
  83. package/dist/graph/scope.d.ts +55 -0
  84. package/dist/graph/scope.js +14 -0
  85. package/dist/graph/types.d.ts +75 -12
  86. package/dist/graph/types.js +4 -2
  87. package/dist/graph/vars.d.ts +16 -0
  88. package/dist/graph/vars.js +80 -0
  89. package/dist/host/artifacts.d.ts +10 -1
  90. package/dist/host/artifacts.js +37 -6
  91. package/dist/host/cook.d.ts +241 -0
  92. package/dist/host/cook.js +844 -0
  93. package/dist/host/export-targets.d.ts +42 -5
  94. package/dist/host/export-targets.js +72 -13
  95. package/dist/host/godot-commands.d.ts +4 -0
  96. package/dist/host/godot-commands.js +21 -0
  97. package/dist/host/godot.d.ts +183 -0
  98. package/dist/host/godot.js +916 -0
  99. package/dist/host/node.d.ts +12 -7
  100. package/dist/host/node.js +27 -9
  101. package/dist/host/pool.js +51 -2
  102. package/dist/host/sidecars.d.ts +8 -0
  103. package/dist/host/sidecars.js +50 -0
  104. package/dist/host/types.d.ts +19 -6
  105. package/dist/host/version.d.ts +1 -0
  106. package/dist/host/version.js +3 -0
  107. package/dist/host/worker.js +5 -2
  108. package/dist/index.d.ts +2 -2
  109. package/dist/index.js +1 -1
  110. package/dist/inspect.d.ts +80 -2
  111. package/dist/inspect.js +265 -30
  112. package/dist/io/common.d.ts +25 -5
  113. package/dist/io/export.js +2 -1
  114. package/dist/io/files.d.ts +23 -4
  115. package/dist/io/files.js +60 -8
  116. package/dist/io/gltf.js +134 -47
  117. package/dist/io/heightmap.d.ts +3 -0
  118. package/dist/io/heightmap.js +1 -0
  119. package/dist/io/import.js +10 -0
  120. package/dist/io/inspect-scene.d.ts +55 -0
  121. package/dist/io/inspect-scene.js +155 -0
  122. package/dist/io/kinds.d.ts +81 -0
  123. package/dist/io/kinds.js +163 -0
  124. package/dist/io/points.d.ts +2 -1
  125. package/dist/io/points.js +3 -1
  126. package/dist/io/sidecars.d.ts +24 -0
  127. package/dist/io/sidecars.js +57 -0
  128. package/dist/io/source.d.ts +65 -0
  129. package/dist/io/source.js +112 -0
  130. package/dist/io/targets.d.ts +47 -3
  131. package/dist/io/targets.js +148 -13
  132. package/dist/io/textures.js +21 -1
  133. package/dist/io/unreal.js +5 -1
  134. package/dist/mcp/docs.d.ts +10 -1
  135. package/dist/mcp/docs.js +786 -143
  136. package/dist/mcp/inputs.d.ts +12 -5
  137. package/dist/mcp/inputs.js +50 -13
  138. package/dist/mcp/server.js +56 -27
  139. package/dist/mcp/tools.d.ts +14 -7
  140. package/dist/mcp/tools.js +198 -103
  141. package/dist/mcp/verify.d.ts +2 -2
  142. package/dist/mcp/verify.js +1 -1
  143. package/dist/mcp/workspace.d.ts +15 -0
  144. package/dist/mcp/workspace.js +349 -0
  145. package/dist/nodes/attributes.js +198 -1
  146. package/dist/nodes/bake.js +151 -47
  147. package/dist/nodes/beam.d.ts +1 -0
  148. package/dist/nodes/beam.js +201 -0
  149. package/dist/nodes/bevel.js +51 -3
  150. package/dist/nodes/cloth.js +2 -0
  151. package/dist/nodes/code.js +21 -9
  152. package/dist/nodes/curves.js +433 -93
  153. package/dist/nodes/flow.js +53 -33
  154. package/dist/nodes/generate.js +12 -38
  155. package/dist/nodes/heightfield.js +248 -77
  156. package/dist/nodes/imageops.js +16 -19
  157. package/dist/nodes/index.d.ts +1 -0
  158. package/dist/nodes/index.js +1 -0
  159. package/dist/nodes/material.js +89 -24
  160. package/dist/nodes/measure.js +43 -17
  161. package/dist/nodes/particles.js +2 -0
  162. package/dist/nodes/pcg.js +6 -5
  163. package/dist/nodes/procedural.js +4 -3
  164. package/dist/nodes/remesh.js +71 -15
  165. package/dist/nodes/scene.js +4 -2
  166. package/dist/nodes/sdf.js +10 -5
  167. package/dist/nodes/solid.js +20 -5
  168. package/dist/nodes/splines.d.ts +15 -1
  169. package/dist/nodes/splines.js +112 -105
  170. package/dist/nodes/texture.d.ts +21 -6
  171. package/dist/nodes/texture.js +1318 -185
  172. package/dist/nodes/topology.d.ts +7 -0
  173. package/dist/nodes/topology.js +133 -6
  174. package/dist/nodes/transform.js +6 -2
  175. package/dist/nodes/uv.js +192 -174
  176. package/dist/nodes/wasmcall.js +5 -1
  177. package/dist/open.d.ts +19 -0
  178. package/dist/open.js +12 -0
  179. package/dist/package.d.ts +288 -0
  180. package/dist/package.js +772 -0
  181. package/dist/packages/check.d.ts +32 -0
  182. package/dist/packages/check.js +169 -0
  183. package/dist/packages/commands.d.ts +57 -0
  184. package/dist/packages/commands.js +537 -0
  185. package/dist/packages/registry.d.ts +796 -0
  186. package/dist/packages/registry.js +2998 -0
  187. package/dist/packages/update.d.ts +124 -0
  188. package/dist/packages/update.js +476 -0
  189. package/dist/render/options.d.ts +2 -0
  190. package/dist/render/options.js +57 -5
  191. package/dist/render/preview.d.ts +17 -4
  192. package/dist/render/preview.js +6 -4
  193. package/dist/render/raster.d.ts +74 -5
  194. package/dist/render/raster.js +527 -143
  195. package/dist/render/texview.d.ts +6 -0
  196. package/dist/render/texview.js +27 -0
  197. package/dist/scan.d.ts +61 -0
  198. package/dist/scan.js +228 -0
  199. package/dist/session.d.ts +311 -0
  200. package/dist/session.js +849 -0
  201. package/dist/viewer/app/api.js +48 -6
  202. package/dist/viewer/app/cooking.js +78 -0
  203. package/dist/viewer/app/embed.js +27 -7
  204. package/dist/viewer/app/export-popover.js +118 -16
  205. package/dist/viewer/app/grid.js +5 -1
  206. package/dist/viewer/app/guides.js +122 -0
  207. package/dist/viewer/app/keymap.js +6 -3
  208. package/dist/viewer/app/layers.js +4 -4
  209. package/dist/viewer/app/main.js +185 -52
  210. package/dist/viewer/app/markers.js +60 -0
  211. package/dist/viewer/app/outliner.js +72 -27
  212. package/dist/viewer/app/output-info.js +45 -0
  213. package/dist/viewer/app/outputs.css +147 -8
  214. package/dist/viewer/app/outputs.js +168 -54
  215. package/dist/viewer/app/packages.js +614 -0
  216. package/dist/viewer/app/props.js +176 -52
  217. package/dist/viewer/app/scene.js +30 -5
  218. package/dist/viewer/app/select.js +4 -3
  219. package/dist/viewer/app/status.js +12 -15
  220. package/dist/viewer/app/style.css +65 -7
  221. package/dist/viewer/app/vars.js +47 -0
  222. package/dist/viewer/app/welcome.js +72 -0
  223. package/dist/viewer/graph-file.d.ts +62 -0
  224. package/dist/viewer/graph-file.js +175 -0
  225. package/dist/viewer/index.html +23 -10
  226. package/dist/viewer/json-edit.d.ts +13 -0
  227. package/dist/viewer/json-edit.js +274 -0
  228. package/dist/viewer/outputs.d.ts +49 -5
  229. package/dist/viewer/outputs.js +264 -56
  230. package/dist/viewer/packages.d.ts +121 -0
  231. package/dist/viewer/packages.js +584 -0
  232. package/dist/viewer/server.d.ts +14 -9
  233. package/dist/viewer/server.js +266 -28
  234. package/dist/web/app/web.css +419 -0
  235. package/dist/web/app/web.js +188 -0
  236. package/dist/{gallery → web}/bake.d.ts +4 -4
  237. package/dist/{gallery → web}/bake.js +24 -15
  238. package/dist/web/folder-page.d.ts +101 -0
  239. package/dist/web/folder-page.js +146 -0
  240. package/dist/web/folders.d.ts +280 -0
  241. package/dist/web/folders.js +970 -0
  242. package/dist/web/library.d.ts +91 -0
  243. package/dist/web/library.js +228 -0
  244. package/dist/web/markdown.d.ts +45 -0
  245. package/dist/web/markdown.js +677 -0
  246. package/dist/web/pages.d.ts +258 -0
  247. package/dist/web/pages.js +301 -0
  248. package/dist/web/server.d.ts +24 -0
  249. package/dist/web/server.js +1068 -0
  250. package/dist/workspace.d.ts +88 -118
  251. package/dist/workspace.js +358 -460
  252. package/integrations/godot/addons/topotopo/LICENSE +202 -0
  253. package/integrations/godot/addons/topotopo/README.md +57 -0
  254. package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
  255. package/integrations/godot/addons/topotopo/dock.gd +266 -0
  256. package/integrations/godot/addons/topotopo/dock.tscn +72 -0
  257. package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
  258. package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
  259. package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
  260. package/integrations/godot/addons/topotopo/inspector.gd +38 -0
  261. package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
  262. package/integrations/godot/addons/topotopo/package.gd +23 -0
  263. package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
  264. package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
  265. package/integrations/godot/addons/topotopo/plugin.gd +970 -0
  266. package/integrations/godot/addons/topotopo/record.gd +435 -0
  267. package/integrations/godot/addons/topotopo/runner.gd +458 -0
  268. package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
  269. package/integrations/godot/addons/topotopo/watcher.gd +199 -0
  270. package/kernels/pkg/README.md +2 -1
  271. package/kernels/pkg-simd/README.md +2 -1
  272. package/library/architecture/versions/1.0/architecture.topo +12 -0
  273. package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
  274. package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
  275. package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
  276. package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
  277. package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
  278. package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
  279. package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
  280. package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
  281. package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
  282. package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
  283. package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
  284. package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
  285. package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
  286. package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
  287. package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
  288. package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
  289. package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
  290. package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
  291. package/library/architecture/versions/1.0/version.json +1119 -0
  292. package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
  293. package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
  294. package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
  295. package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
  296. package/library/nature/versions/1.0/graphs/lineup.json +24 -0
  297. package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
  298. package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
  299. package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
  300. package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
  301. package/library/nature/versions/1.0/nature.topo +12 -0
  302. package/library/nature/versions/1.0/version.json +534 -0
  303. package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
  304. package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
  305. package/library/props/versions/1.0/graphs/lineup.json +18 -0
  306. package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
  307. package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
  308. package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
  309. package/library/props/versions/1.0/props.topo +12 -0
  310. package/library/props/versions/1.0/version.json +336 -0
  311. package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
  312. package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
  313. package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
  314. package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
  315. package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
  316. package/library/street/versions/1.0/graphs/lineup.json +22 -0
  317. package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
  318. package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
  319. package/library/street/versions/1.0/street.topo +12 -0
  320. package/library/street/versions/1.0/version.json +421 -0
  321. package/package.json +13 -8
  322. package/dist/gallery/app/gallery.css +0 -100
  323. package/dist/gallery/app/gallery.js +0 -80
  324. package/dist/gallery/cli.d.ts +0 -4
  325. package/dist/gallery/cli.js +0 -157
  326. package/dist/gallery/library.d.ts +0 -124
  327. package/dist/gallery/library.js +0 -366
  328. package/dist/gallery/pages.d.ts +0 -94
  329. package/dist/gallery/pages.js +0 -148
  330. package/dist/gallery/server.d.ts +0 -21
  331. package/dist/gallery/server.js +0 -391
  332. package/dist/graph/migrate.d.ts +0 -23
  333. package/dist/graph/migrate.js +0 -58
  334. package/dist/mcp/library.d.ts +0 -12
  335. package/dist/mcp/library.js +0 -159
  336. package/shelf/index.json +0 -190
@@ -0,0 +1,258 @@
1
+ export interface Urls {
2
+ home: string;
3
+ /** a package's stable address (/p/<library or workspace>/<id>): it leads to its folder page */
4
+ package(lib: string, id: string): string;
5
+ thumb(lib: string, id: string, version?: string | number): string;
6
+ glb(lib: string, id: string, version?: string | number): string;
7
+ embed(lib: string, id: string): string;
8
+ file(lib: string, id: string, rel: string): string;
9
+ /** null where there is no editor (TopoTopo's built-in packages) */
10
+ edit(lib: string, id: string): string | null;
11
+ /** a folder page of a workspace ("w") or library ("l"), '' for its root */
12
+ folder(kind: string, name: string, rel: string): string;
13
+ /** a file of a workspace or library, as the browser shows it */
14
+ raw(kind: string, name: string, rel: string): string;
15
+ /** the 3D view of a model file (glb, gltf) */
16
+ model(kind: string, name: string, rel: string): string;
17
+ /** the web app's own files (web.css, web.js) */
18
+ asset(name: string): string;
19
+ /** the viewer's modules (embed.js, scene.js) */
20
+ app(name: string): string;
21
+ /** three.js: the import map's base for build/ and examples/jsm/ */
22
+ three: string;
23
+ }
24
+ export interface CardData {
25
+ lib: string;
26
+ id: string;
27
+ title: string;
28
+ collection: string;
29
+ tags: string[];
30
+ description: string;
31
+ updated: number;
32
+ /** 'ok' | 'failed' | 'baking' | 'new', or 'empty': the package has not the graph its manifest shows (nothing to bake yet) */
33
+ status: string;
34
+ version: string;
35
+ /** its folder page */
36
+ url?: string;
37
+ /** a package: its full name and newest version (null before the first is published) */
38
+ pkg?: {
39
+ name: string;
40
+ version: string | null;
41
+ };
42
+ /** a package's outputs in its newest version, which the search finds by name, label, kind and tag */
43
+ outputs?: {
44
+ type: string;
45
+ alias?: string;
46
+ label: string;
47
+ kind?: string;
48
+ tags: string[];
49
+ }[];
50
+ /** the packages it uses (the search finds a package by them), and those with a newer version than the one in use */
51
+ usesPackages?: string[];
52
+ updates?: {
53
+ name: string;
54
+ version: string;
55
+ newest: string;
56
+ }[];
57
+ }
58
+ /** A package that uses another, with the version it uses. */
59
+ export interface UserRow {
60
+ lib: string;
61
+ id: string;
62
+ title: string;
63
+ version: string;
64
+ url: string;
65
+ }
66
+ export interface VarRow {
67
+ name: string;
68
+ value: unknown;
69
+ desc?: string;
70
+ min?: number;
71
+ max?: number;
72
+ }
73
+ export interface FileRow {
74
+ path: string;
75
+ size: number;
76
+ image: boolean;
77
+ }
78
+ /**
79
+ * A published output: the node type a graph names it with ("owner/name/output"; `alias` "owner/name" for the default),
80
+ * its kind and tags (none in a version published before TopoTopo recorded kinds), and its thumbnail when the package
81
+ * keeps one (thumbs/<output>.png: TopoTopo's built-in packages do).
82
+ */
83
+ export interface OutputRow {
84
+ type: string;
85
+ alias?: string;
86
+ label: string;
87
+ kind?: string;
88
+ tags: string[];
89
+ graph: string;
90
+ node: string;
91
+ params: string[];
92
+ inputs: string[];
93
+ thumb?: string;
94
+ }
95
+ /** A published version: `big` when it starts a big version, `marked` when its author marked it big; its outputs. */
96
+ export interface VersionRow {
97
+ version: string;
98
+ note: string;
99
+ published: string;
100
+ big: boolean;
101
+ marked: boolean;
102
+ outputs?: OutputRow[];
103
+ }
104
+ export interface PackageData extends CardData {
105
+ /** one of TopoTopo's own packages (its built-in library): nothing to bake or edit here */
106
+ builtin: boolean;
107
+ rel: string;
108
+ /** where it is, for people: library "props", the workspace "my-game" */
109
+ place: string;
110
+ links: {
111
+ label: string;
112
+ url: string;
113
+ }[];
114
+ graph: string;
115
+ graphs: {
116
+ name: string;
117
+ nodes: number;
118
+ vars: VarRow[];
119
+ }[];
120
+ /** its attachments/ files: images and the rest, each with its URL (a model's 3D view as `model`) */
121
+ attachments: (FileRow & {
122
+ url: string;
123
+ model?: string;
124
+ })[];
125
+ /** its exports/ files, each with its URL (a model's 3D view as `model`) and, when its graph changed since, `stale` */
126
+ exports: (FileRow & {
127
+ url: string;
128
+ model?: string;
129
+ stale?: boolean;
130
+ })[];
131
+ glb: boolean;
132
+ /** it has a preview picture (a baked thumb.png, a built-in package's output's) */
133
+ thumb: boolean;
134
+ bake: {
135
+ at: number;
136
+ ok: boolean;
137
+ error?: string;
138
+ ms?: number;
139
+ glb?: boolean;
140
+ points?: number;
141
+ prims?: number;
142
+ warnings?: string[];
143
+ } | null;
144
+ created: string;
145
+ /** absolute URLs for the copy boxes (the board pastes them) */
146
+ share: {
147
+ link: string;
148
+ thumb: string;
149
+ embed: string;
150
+ };
151
+ /** a package: its versions, newest first, the outputs of the newest, and the packages that use it */
152
+ package: {
153
+ name: string;
154
+ versions: VersionRow[];
155
+ outputs: OutputRow[];
156
+ usedBy?: UserRow[];
157
+ } | null;
158
+ /** the packages it uses: the version in use and its note, the package's page and its newest version when newer */
159
+ uses: {
160
+ name: string;
161
+ version: string;
162
+ note?: string;
163
+ published?: string;
164
+ url?: string;
165
+ newest?: string;
166
+ }[];
167
+ }
168
+ /** A registered workspace or library on the front page: what it is, a few pictures from inside, its counts. */
169
+ export interface RootCardData {
170
+ kind: 'w' | 'l';
171
+ name: string;
172
+ dir: string;
173
+ url: string;
174
+ /** "Godot · My Game" for a workspace with an engine project */
175
+ engine?: string;
176
+ builtin?: boolean;
177
+ /** up to four thumbnails: packages' previews first, then images */
178
+ thumbs: string[];
179
+ packages: number;
180
+ folders: number;
181
+ files: number;
182
+ flags: number;
183
+ /** the folder or its file cannot be read: what is wrong */
184
+ problem?: string;
185
+ /** its audit stopped short (a very large tree): there may be more flags than counted */
186
+ cut?: boolean;
187
+ }
188
+ /** The front page's data: the workspaces, the libraries (TopoTopo's built-in one last), every package for the search. */
189
+ export interface WebData {
190
+ workspaces: RootCardData[];
191
+ libraries: RootCardData[];
192
+ packages: CardData[];
193
+ problems: string[];
194
+ }
195
+ export declare const esc: (s: unknown) => string;
196
+ export declare const size: (n: number) => string;
197
+ export declare const when: (ms: number) => string;
198
+ export declare const count: (n: number, one: string, many?: string) => string;
199
+ export declare function shell(title: string, u: Urls, body: string, opts: {
200
+ page: string;
201
+ data?: object;
202
+ }): string;
203
+ /** A package's full name and newest version, as a card and a package's folder page mark it. */
204
+ export declare const pkgMark: (p: {
205
+ name: string;
206
+ version: string | null;
207
+ }) => string;
208
+ /** A package's card in the search results. */
209
+ export declare function card(c: CardData, u: Urls): string;
210
+ /** Up to four pictures as one tile: one fills it, two side by side, three or four in a grid. */
211
+ export declare function mosaic(thumbs: string[], fallback: string): string;
212
+ /** A flag count as a badge (nothing for none). */
213
+ export declare const flagBadge: (n: number) => string;
214
+ /**
215
+ * The front page: the registered workspaces as large cards, then the libraries (TopoTopo's built-in one last), each a
216
+ * door to its folder pages; the search finds every package by name, tag and the packages it uses, and their outputs
217
+ * by name, kind and tag.
218
+ */
219
+ export declare function frontPage(d: WebData, u: Urls): string;
220
+ /**
221
+ * The packages a package (or a workspace) uses: the version in use, when a newer one is out, its date and its note
222
+ * (one line; the whole note on hover and on the package's page).
223
+ */
224
+ export declare function usesSection(uses: PackageData['uses']): string;
225
+ /**
226
+ * A package on its folder page, the top part: its 3D view (the baked preview) beside what it is, its links, its
227
+ * actions (Open in editor, Re-bake), how its preview cooked and the snippets for a board.
228
+ */
229
+ export declare function packageBlock(p: PackageData, u: Urls): string;
230
+ /**
231
+ * A package on its folder page, right below its preview: its published outputs and versions, the packages that use it
232
+ * and those it uses beside its graphs and their vars and its exports (those older than their graph marked). One column
233
+ * when it publishes no versions and uses no package.
234
+ */
235
+ export declare function packageCols(p: PackageData): string;
236
+ /** A package on its folder page, last: its attachments, where it is and its stable link. */
237
+ export declare function packageEnd(p: PackageData, u: Urls): string;
238
+ /**
239
+ * The page a board embeds in an iframe (and a package's folder page shows): the baked preview.glb under an orbit
240
+ * camera, or the thumbnail. It sits in a page that scrolls, so the wheel scrolls that page until the view is clicked
241
+ * (or with Ctrl held).
242
+ */
243
+ export declare function embedPage(e: {
244
+ lib: string;
245
+ id: string;
246
+ title: string;
247
+ glb: boolean;
248
+ version: string;
249
+ packageUrl: string;
250
+ }, u: Urls): string;
251
+ /** The 3D view of a model file (glb, gltf) of a folder: what a page opens when a model is clicked. */
252
+ export declare function modelPage(m: {
253
+ title: string;
254
+ src: string;
255
+ link: string;
256
+ }, u: Urls): string;
257
+ /** The import map the 3D views load three.js with (inline: its hash is in their content policy). */
258
+ export declare const importMap: (u: Urls) => string;
@@ -0,0 +1,301 @@
1
+ // The web app's pages as plain HTML strings: the front page (the registered workspaces and libraries as cards, a
2
+ // search over every package and output), the package block a package's folder page shows (src/web/folder-page.ts),
3
+ // the embed page a board frames and the 3D view of a model file. Pure functions of their data and a URL builder.
4
+ // Styles and the small page script are files: app/web.css and app/web.js here, app/embed.js in the viewer.
5
+ export const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
6
+ export const size = (n) => (n < 1024 ? `${n} B` : n < 1 << 20 ? `${(n / 1024).toFixed(0)} KB` : n < 1 << 30 ? `${(n / 2 ** 20).toFixed(1)} MB` : `${(n / 2 ** 30).toFixed(2)} GB`);
7
+ export const when = (ms) => (ms ? new Date(ms).toISOString().slice(0, 16).replace('T', ' ') : '');
8
+ export const count = (n, one, many = `${one}s`) => `${n.toLocaleString('en')} ${n === 1 ? one : many}`;
9
+ const STATUS = { ok: '', failed: 'bake failed', baking: 'baking…', new: 'not baked yet', empty: 'no default graph yet' };
10
+ export function shell(title, u, body, opts) {
11
+ return `<!doctype html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="utf-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1">
16
+ <title>${esc(title)}</title>
17
+ <link rel="icon" href="data:,">
18
+ <link rel="stylesheet" href="${esc(u.asset('web.css'))}">
19
+ <script type="module" src="${esc(u.asset('web.js'))}"></script>
20
+ </head>
21
+ <body data-page="${opts.page}"${opts.data ? ` data-json="${esc(JSON.stringify(opts.data))}"` : ''}>
22
+ ${body}
23
+ </body>
24
+ </html>
25
+ `;
26
+ }
27
+ /** A package's full name and newest version, as a card and a package's folder page mark it. */
28
+ export const pkgMark = (p) => `<span class="pkg" title="${esc(`package ${p.name}${p.version ? `, newest version ${p.version}` : ', no version published yet'}`)}">${esc(p.name)}${p.version ? ` ${esc(p.version)}` : ''}</span>`;
29
+ const day = (iso) => (iso ? iso.slice(0, 10) : '');
30
+ /** An output's kind and tags as marks: the kind outlined, each tag a tag. */
31
+ const kindTagMarks = (o) => `${o.kind ? `<span class="kind" title="what the output is">${esc(o.kind)}</span>` : ''}${o.tags.map((t) => `<span class="tag">${esc(t)}</span>`).join('')}`;
32
+ /** The packages a package uses with a newer version: "ux/crates 1.2 is out". */
33
+ const updateMark = (ups) => `<span class="upd" title="${esc(ups.map((x) => `${x.name} ${x.version} is in use; ${x.newest} is out`).join('\n'))}">${esc(ups.length === 1 ? `update: ${ups[0].name} ${ups[0].newest}` : `${ups.length} updates`)}</span>`;
34
+ /** A package's card in the search results. */
35
+ export function card(c, u) {
36
+ // the search finds a package by the packages it uses too
37
+ const hay = [c.title, c.id, c.lib, c.collection, c.description, ...c.tags, c.pkg?.name ?? '', ...(c.usesPackages ?? [])].join(' ').toLowerCase();
38
+ // a package's outputs: the search shows those it finds by their name, label, kind or tags
39
+ const outs = (c.outputs ?? []).map((o) => `<span class="out" hidden data-hay="${esc([o.type, o.alias ?? '', o.label, o.kind ?? '', ...o.tags].join(' ').toLowerCase())}"><code>${esc(o.type)}</code>${kindTagMarks(o)}</span>`).join('');
40
+ return `<a class="card" href="${esc(c.url ?? u.package(c.lib, c.id))}" data-key="${esc(`${c.lib}/${c.id}`)}" data-hay="${esc(hay)}">
41
+ <span class="thumb"><img src="${esc(u.thumb(c.lib, c.id, c.version))}" alt="" loading="lazy" width="512" height="512"></span>
42
+ <span class="meta">
43
+ <span class="title">${esc(c.title)}</span>
44
+ <span class="sub">${esc(c.lib)}${c.collection ? ` / ${esc(c.collection)}` : ''} / ${esc(c.id)}</span>
45
+ ${c.pkg ? pkgMark(c.pkg) : ''}
46
+ ${c.tags.length ? `<span class="tags">${c.tags.map((t) => `<span class="tag">${esc(t)}</span>`).join('')}</span>` : ''}
47
+ ${outs ? `<span class="outs">${outs}</span>` : ''}
48
+ ${c.updates?.length ? updateMark(c.updates) : ''}
49
+ <span class="status s-${esc(c.status)}">${esc(STATUS[c.status] ?? '')}</span>
50
+ </span>
51
+ </a>`;
52
+ }
53
+ /** Up to four pictures as one tile: one fills it, two side by side, three or four in a grid. */
54
+ export function mosaic(thumbs, fallback) {
55
+ const t = thumbs.slice(0, 4);
56
+ if (!t.length)
57
+ return `<span class="mosaic m0"><span class="mono">${esc(fallback)}</span></span>`;
58
+ return `<span class="mosaic m${t.length}">${t.map((s) => `<img src="${esc(s)}" alt="" loading="lazy">`).join('')}</span>`;
59
+ }
60
+ /** A flag count as a badge (nothing for none). */
61
+ export const flagBadge = (n) => (n ? `<span class="fbadge" title="${esc(count(n, 'flag'))}: things TopoTopo can tell need a look">${esc(count(n, 'flag'))}</span>` : '');
62
+ function rootCard(r) {
63
+ const stat = (n, one, many, cls = '', more = '') => `<span class="stat${cls}"><b>${n.toLocaleString('en')}${more}</b> <span>${n === 1 && !more ? one : many}</span></span>`;
64
+ // the flags first: the figure a look at the card is for
65
+ const stats = [
66
+ stat(r.flags, 'flag', 'flags', r.flags ? ' fstat' : r.cut ? '' : ' ok', r.cut ? '+' : ''),
67
+ stat(r.packages, 'package', 'packages'), stat(r.folders, 'folder', 'folders'), stat(r.files, 'file', 'files'),
68
+ ].join('');
69
+ const sub = r.builtin ? 'TopoTopo\'s built-in library' : r.kind === 'w' ? `Workspace${r.engine ? ` · ${r.engine}` : ''}` : 'Library';
70
+ return `<a class="rcard${r.kind === 'w' ? ' ws' : ''}" href="${esc(r.url)}" data-root="${esc(`${r.kind}/${r.name}`)}">
71
+ ${mosaic(r.thumbs, r.name.slice(0, 2).toUpperCase())}
72
+ <span class="rbody">
73
+ <span class="rsub">${esc(sub)}</span>
74
+ <span class="rtitle">${esc(r.name)}</span>
75
+ <span class="stats">${stats}</span>
76
+ ${r.problem ? `<span class="rprob">${esc(r.problem)}</span>` : ''}
77
+ ${r.cut ? '<span class="rcut">Audited in part: a very large tree (its page says where it stopped)</span>' : ''}
78
+ <span class="path">${esc(r.dir)}</span>
79
+ </span>
80
+ </a>`;
81
+ }
82
+ /**
83
+ * The front page: the registered workspaces as large cards, then the libraries (TopoTopo's built-in one last), each a
84
+ * door to its folder pages; the search finds every package by name, tag and the packages it uses, and their outputs
85
+ * by name, kind and tag.
86
+ */
87
+ export function frontPage(d, u) {
88
+ const outputs = d.packages.reduce((n, c) => n + (c.outputs?.length ?? 0), 0);
89
+ const total = d.packages.length;
90
+ const ws = d.workspaces.length
91
+ ? `<div class="rgrid big">${d.workspaces.map(rootCard).join('\n')}</div>`
92
+ : `<p class="empty">No workspace registered yet. Make a folder one with <code>topotopo workspace init &lt;folder&gt;</code>, or register one with <code>topotopo workspace add &lt;folder&gt;</code>.</p>`;
93
+ const own = d.libraries.filter((l) => !l.builtin);
94
+ const libs = `<div class="rgrid">${d.libraries.map(rootCard).join('\n')}</div>${own.length ? '' : `<p class="empty small">No library of your own yet. Add a folder with <code>topotopo library add &lt;name&gt; &lt;folder&gt;</code>.</p>`}`;
95
+ return shell('TopoTopo', u, `<header class="bar">
96
+ <a class="brand" href="${esc(u.home)}"><b>TopoTopo</b></a>
97
+ <input id="search" type="search" placeholder="Search ${total} package${total === 1 ? '' : 's'}${outputs ? ` and ${outputs} output${outputs === 1 ? '' : 's'}` : ''}" autocomplete="off" aria-label="Search packages${outputs ? ' and their outputs' : ''}">
98
+ <button id="clear" class="btn" type="button" hidden title="clear the search">Clear</button>
99
+ <a class="news" href="https://topotopo.kit.com/54b6b32c3f" target="_blank" rel="noopener" title="releases and new packs, about once a month">Get TopoTopo news</a>
100
+ </header>
101
+ <main class="wrap front">
102
+ ${d.problems.length ? `<details class="problems"><summary>${d.problems.length} problem${d.problems.length > 1 ? 's' : ''}</summary><ul>${d.problems.map((p) => `<li>${esc(p)}</li>`).join('')}</ul></details>` : ''}
103
+ <section class="roots" id="workspaces">
104
+ <h2>Workspaces <span class="count">${d.workspaces.length}</span></h2>
105
+ ${ws}
106
+ </section>
107
+ <section class="roots" id="libraries">
108
+ <h2>Libraries <span class="count">${d.libraries.length}</span></h2>
109
+ ${libs}
110
+ </section>
111
+ <section id="results" hidden>
112
+ <h2>Packages <span class="count" id="found" data-total="${total}">${total}</span></h2>
113
+ <div class="grid">${d.packages.map((c) => card(c, u)).join('\n')}</div>
114
+ <p class="empty" id="nomatch" hidden>Nothing matches. <button class="btn" type="button" data-clear>Clear the search</button></p>
115
+ </section>
116
+ </main>`, { page: 'front' });
117
+ }
118
+ /** A package's versions with their notes and dates, and the outputs its newest version publishes with their kinds and tags. */
119
+ function packageSection(pk) {
120
+ if (!pk.versions.length)
121
+ return `<h2>Versions</h2><p class="dim">No version published yet: <code>topotopo publish --note "…"</code> in the package's folder publishes the first, which other packages can then use as <code>${esc(pk.name)}</code>.</p>${usedBySection(pk.usedBy ?? [])}`;
122
+ const big = (v) => (v.big ? ' <span class="tag" title="something a package relies on goes away or means something else">big</span>' : v.marked ? ' <span class="tag" title="its author marked it big">big</span>' : '');
123
+ const outputs = pk.outputs.map((o) => {
124
+ const what = [`node "${o.node}" of graph "${o.graph}"`, o.params.length ? `params ${o.params.join(', ')}` : '', o.inputs.length ? `input${o.inputs.length > 1 ? 's' : ''} ${o.inputs.join(', ')}` : ''].filter(Boolean).join(' · ');
125
+ const marks = kindTagMarks(o);
126
+ return `<tr><th>${o.thumb ? `<img class="othumb" src="${esc(o.thumb)}" alt="" loading="lazy" width="96" height="96">` : ''}<code>${esc(o.type)}</code>${o.alias ? `<br><code>${esc(o.alias)}</code> <span class="dim">(the default)</span>` : ''}</th><td>${esc(o.label)}${marks ? `<span class="tags">${marks}</span>` : ''}</td><td class="dim">${esc(what)}</td></tr>`;
127
+ }).join('');
128
+ return `<h2>Published outputs <span class="count">${pk.outputs.length}</span></h2>
129
+ <div class="table"><table class="vars outputs"><tbody>${outputs}</tbody></table></div>
130
+ <p class="dim small">The outputs of ${esc(pk.versions[0].version)}: a package's graph uses one as a node type, <code>{"type": "${esc(pk.outputs[0]?.type ?? pk.name)}"}</code>, with its params.</p>
131
+ <h2>Versions <span class="count">${pk.versions.length}</span></h2>
132
+ ${versionList(pk.versions, big)}
133
+ ${usedBySection(pk.usedBy ?? [])}`;
134
+ }
135
+ /** The versions, newest first: each opens to the outputs it published. */
136
+ function versionList(versions, big) {
137
+ return `<div class="versions">${versions.map((v) => `<details class="version" id="v-${esc(v.version)}"><summary><span class="vn">${esc(v.version)}</span>${big(v)}<span class="vd">${esc(day(v.published))}</span><span class="vt">${esc(v.note)}</span></summary>
138
+ ${v.outputs?.length ? `<ul class="vouts">${v.outputs.map((o) => `<li><code>${esc(o.type)}</code>${o.label ? ` ${esc(o.label)}` : ''}${kindTagMarks(o) ? `<span class="tags">${kindTagMarks(o)}</span>` : ''}</li>`).join('')}</ul>` : '<p class="dim small">Its record lists no outputs.</p>'}
139
+ </details>`).join('')}</div>`;
140
+ }
141
+ /** The packages of the libraries and the workspaces that use a package, each linked, with the version it uses. */
142
+ function usedBySection(users) {
143
+ return `<h2>Used by <span class="count">${users.length}</span></h2>${users.length
144
+ ? `<table class="vars uses"><tbody>${users.map((x) => `<tr><th><a href="${esc(x.url)}">${esc(x.title)}</a></th><td>${esc(x.version)}</td><td class="dim">${esc(x.lib)}</td></tr>`).join('')}</tbody></table>`
145
+ : '<p class="dim">No package in the libraries uses it yet.</p>'}`;
146
+ }
147
+ /**
148
+ * The packages a package (or a workspace) uses: the version in use, when a newer one is out, its date and its note
149
+ * (one line; the whole note on hover and on the package's page).
150
+ */
151
+ export function usesSection(uses) {
152
+ if (!uses.length)
153
+ return '';
154
+ return `<h2>Packages it uses <span class="count">${uses.length}</span></h2>
155
+ <table class="vars uses"><tbody>${uses.map((x) => `<tr><th>${x.url ? `<a href="${esc(x.url)}">${esc(x.name)}</a>` : esc(x.name)}</th><td>${esc(x.version)}</td><td class="unotes"><span class="urow">${x.newest ? `<span class="newer">${esc(x.newest)} is out</span>` : ''}${x.published ? `<span class="udate">${esc(day(x.published))}</span>` : ''}${x.note ? `<span class="unote" title="${esc(x.note)}">${esc(x.note)}</span>` : ''}</span></td></tr>`).join('')}</tbody></table>`;
156
+ }
157
+ /**
158
+ * A package on its folder page, the top part: its 3D view (the baked preview) beside what it is, its links, its
159
+ * actions (Open in editor, Re-bake), how its preview cooked and the snippets for a board.
160
+ */
161
+ export function packageBlock(p, u) {
162
+ const edit = u.edit(p.lib, p.id);
163
+ const snippet = (label, value) => `<label class="copy"><span>${label}</span><input readonly value="${esc(value)}"><button type="button" data-copy>Copy</button></label>`;
164
+ const b = p.status === 'empty' || p.builtin ? null : p.bake;
165
+ const example = p.package?.outputs.find((o) => !o.alias)?.type;
166
+ const bakeLine = p.builtin
167
+ ? `One of TopoTopo's own packages: every package can use its outputs. Ask your agent to use one by its name${example ? `, such as ${example}` : ''}.`
168
+ : p.status === 'empty'
169
+ ? (p.graphs.length ? `No default graph yet: its manifest shows "${p.graph}", which this package does not have. Ask your agent to build it, or to show one of its graphs.` : 'No default graph yet: this package has no graphs. Ask your agent to build one; the preview appears here when it exists.')
170
+ : p.status === 'baking' ? 'Baking its preview…'
171
+ : !b ? 'Not baked yet.'
172
+ : b.ok ? `Baked ${when(b.at)} in ${((b.ms ?? 0) / 1000).toFixed(1)} s · ${(b.points ?? 0).toLocaleString('en')} points, ${(b.prims ?? 0).toLocaleString('en')} prims${b.glb ? '' : ' · no 3D preview (too large)'}`
173
+ : `Bake failed ${when(b.at)}`;
174
+ // the 3D view; else the preview picture at its own size; else a short word that there is none yet, and why
175
+ const none = p.status === 'empty' ? 'No preview yet: this package has no graph to bake' : p.status === 'baking' ? 'No preview yet: baking it…' : b && !b.ok ? 'No preview: its graph did not cook' : 'No preview yet';
176
+ const view = p.glb
177
+ ? `<iframe class="view" src="${esc(u.embed(p.lib, p.id))}" title="${esc(p.title)} in 3D" allow="fullscreen"></iframe>`
178
+ : p.thumb ? `<img class="view pic" src="${esc(u.thumb(p.lib, p.id, p.version))}" alt="${esc(p.title)}" width="512" height="512">`
179
+ : `<div class="view none"><span class="cube"></span><p>${esc(none)}</p></div>`;
180
+ // a bake that failed leaves the last good preview: marked as such
181
+ const old = !!b && !b.ok && (p.glb || p.thumb);
182
+ return `<section class="pkgblock" data-key="${esc(`${p.lib}/${p.id}`)}">
183
+ <div class="stage${old ? ' old' : ''}">${view}${old ? '<span class="oldmark">Last good preview: the newest graph did not cook</span>' : ''}</div>
184
+ <aside class="info">
185
+ ${p.pkg ? `<p class="pkgline">Package ${pkgMark(p.pkg)}</p>` : '<p class="pkgline">Package <span class="dim">(publishes no versions)</span></p>'}
186
+ ${p.description ? `<p class="desc">${esc(p.description)}</p>` : ''}
187
+ ${p.tags.length ? `<p class="tags">${p.tags.map((t) => `<span class="tag">${esc(t)}</span>`).join('')}</p>` : ''}
188
+ ${p.links.length ? `<ul class="links">${p.links.map((l) => `<li><a href="${esc(l.url)}" target="_blank" rel="noopener">${esc(l.label)}</a></li>`).join('')}</ul>` : ''}
189
+ <div class="actions">
190
+ ${edit ? `<a class="btn primary" href="${esc(edit)}" target="_blank" rel="noopener">Open in editor</a>` : ''}
191
+ ${p.builtin || p.status === 'empty' ? '' : `<button class="btn" type="button" data-post="${esc(`${u.package(p.lib, p.id)}/bake`)}">Re-bake</button>`}
192
+ </div>
193
+ <p class="bake ${b && !b.ok ? 'err' : ''}${p.status === 'empty' ? ' empty' : ''}" id="bake">${esc(bakeLine)}</p>
194
+ ${b && !b.ok && b.error ? `<pre class="error">${esc(b.error)}</pre>` : ''}
195
+ ${b?.warnings?.length ? `<details class="warn"><summary>${b.warnings.length} warning${b.warnings.length > 1 ? 's' : ''}</summary><pre>${esc(b.warnings.join('\n'))}</pre></details>` : ''}
196
+ <details class="board"><summary>On your board</summary>
197
+ ${snippet('Link', p.share.link)}
198
+ ${snippet('Image', `<a href="${p.share.link}"><img src="${p.share.thumb}" alt="${esc(p.title)}" width="256"></a>`)}
199
+ ${snippet('3D embed', `<iframe src="${p.share.embed}" width="640" height="480" style="border:0" allow="fullscreen" title="${esc(p.title)}"></iframe>`)}
200
+ </details>
201
+ </aside>
202
+ </section>`;
203
+ }
204
+ /**
205
+ * A package on its folder page, right below its preview: its published outputs and versions, the packages that use it
206
+ * and those it uses beside its graphs and their vars and its exports (those older than their graph marked). One column
207
+ * when it publishes no versions and uses no package.
208
+ */
209
+ export function packageCols(p) {
210
+ const graphs = p.graphs.length
211
+ ? `<div class="graphs">${p.graphs.map((g) => `<details class="graph"${p.graphs.length <= 3 ? ' open' : ''}><summary><b>${esc(g.name)}</b>${g.name === p.graph ? ' <span class="tag">default</span>' : ''} <span class="count">${g.nodes} nodes${g.vars.length ? ` · ${g.vars.length} vars` : ''}</span></summary>${g.vars.length ? `<table class="vars"><tbody>${g.vars.map((v) => `<tr><th>${esc(v.name)}</th><td>${esc(JSON.stringify(v.value))}</td><td class="dim">${esc(v.desc ?? '')}${v.min !== undefined || v.max !== undefined ? ` <span class="range">${esc(v.min ?? '')}…${esc(v.max ?? '')}</span>` : ''}</td></tr>`).join('')}</tbody></table>` : ''}</details>`).join('')}</div>`
212
+ : '<p class="dim">No graphs yet. Ask your agent to build one in this package (its workspace tool opens the package); open the editor to watch it appear.</p>';
213
+ const left = `${p.package ? packageSection(p.package) : ''}${usesSection(p.uses)}`;
214
+ return `<section class="pkgmore">
215
+ <div class="pkgcols${left ? '' : ' solo'}">
216
+ ${left ? `<div>${left}</div>` : ''}
217
+ <div>
218
+ <h2>Graphs <span class="count">${p.graphs.length}</span></h2>
219
+ ${graphs}
220
+ ${p.exports.length ? `<h2>Exports <span class="count">${p.exports.length}</span></h2>${fileList(p.exports)}` : ''}
221
+ </div>
222
+ </div>
223
+ </section>`;
224
+ }
225
+ /** A package on its folder page, last: its attachments, where it is and its stable link. */
226
+ export function packageEnd(p, u) {
227
+ return `<section class="pkgend">
228
+ ${attachments(p)}
229
+ <p class="dim small">${esc(p.place)}${p.created ? ` · created ${esc(p.created)}` : ''} · updated ${esc(when(p.updated))} · <a href="${esc(u.package(p.lib, p.id))}">stable link</a></p>
230
+ </section>`;
231
+ }
232
+ /**
233
+ * A package's attachments: its images as tiles and its other files as a list. Many images show one from each
234
+ * folder first (its first by name: a concept before its renders), the rest a click away.
235
+ */
236
+ function attachments(p) {
237
+ if (!p.attachments.length)
238
+ return '';
239
+ const images = p.attachments.filter((f) => f.image), other = p.attachments.filter((f) => !f.image);
240
+ const tile = (f) => `<a class="tile" href="${esc(f.url)}" data-view="image" data-name="${esc(f.path)}"><img src="${esc(f.url)}" alt="" loading="lazy" decoding="async"><span>${esc(f.path)}</span></a>`;
241
+ let shown = images;
242
+ if (images.length > 16) {
243
+ const firsts = new Map();
244
+ for (const f of images) {
245
+ const top = f.path.includes('/') ? f.path.slice(0, f.path.indexOf('/')) : f.path;
246
+ if (!firsts.has(top))
247
+ firsts.set(top, f);
248
+ }
249
+ shown = [...firsts.values()].slice(0, 16);
250
+ }
251
+ const rest = images.length - shown.length;
252
+ return `<h2>Attachments <span class="count">${p.attachments.length}</span></h2>
253
+ ${shown.length ? `<div class="igrid">${shown.map(tile).join('')}</div>` : ''}
254
+ ${rest > 0 ? `<details class="allatt"><summary>All ${images.length} images</summary><div class="igrid">${images.map(tile).join('')}</div></details>` : ''}
255
+ ${other.length ? `<details class="allatt"${other.length <= 8 ? ' open' : ''}><summary>${other.length} other file${other.length === 1 ? '' : 's'}</summary>${fileList(other)}</details>` : ''}`;
256
+ }
257
+ const fileList = (rows) => `<ul class="flist">${rows.map((f) => `<li><a href="${esc(f.url)}"${f.image ? ` data-view="image" data-name="${esc(f.path)}"` : f.model ? ` data-view="model" data-src="${esc(f.model)}" data-name="${esc(f.path)}"` : ''}>${esc(f.path)}</a>${f.stale ? ' <span class="stale" title="its graph changed since it was exported">older than its graph</span>' : ''}<span>${size(f.size)}</span></li>`).join('')}</ul>`;
258
+ /**
259
+ * The page a board embeds in an iframe (and a package's folder page shows): the baked preview.glb under an orbit
260
+ * camera, or the thumbnail. It sits in a page that scrolls, so the wheel scrolls that page until the view is clicked
261
+ * (or with Ctrl held).
262
+ */
263
+ export function embedPage(e, u) {
264
+ return viewPage({ title: e.title, poster: u.thumb(e.lib, e.id, e.version), src: e.glb ? u.glb(e.lib, e.id, e.version) : null, link: e.packageUrl, wheel: 'click' }, u);
265
+ }
266
+ /** The 3D view of a model file (glb, gltf) of a folder: what a page opens when a model is clicked. */
267
+ export function modelPage(m, u) {
268
+ return viewPage({ title: m.title, poster: null, src: m.src, link: m.link, wheel: 'zoom' }, u);
269
+ }
270
+ /** The import map the 3D views load three.js with (inline: its hash is in their content policy). */
271
+ export const importMap = (u) => JSON.stringify({ imports: { three: `${u.three}build/three.module.js`, 'three/addons/': `${u.three}examples/jsm/` } });
272
+ function viewPage(e, u) {
273
+ return `<!doctype html>
274
+ <html lang="en">
275
+ <head>
276
+ <meta charset="utf-8">
277
+ <meta name="viewport" content="width=device-width, initial-scale=1">
278
+ <title>${esc(e.title)} · TopoTopo</title>
279
+ <link rel="icon" href="data:,">
280
+ <style>
281
+ html, body { margin: 0; height: 100%; background: #2b2d31; overflow: hidden; font: 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: #d6d9dd; }
282
+ canvas { display: block; width: 100%; height: 100%; touch-action: none; }
283
+ .poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
284
+ .badge { position: absolute; left: 8px; bottom: 8px; padding: 3px 7px; border-radius: 3px; background: rgba(31, 33, 36, 0.8); color: inherit; text-decoration: none; }
285
+ .badge:hover { color: #f0a030; }
286
+ .note { position: absolute; right: 8px; bottom: 8px; color: #8c939b; }
287
+ .hint { position: absolute; right: 8px; top: 8px; padding: 3px 8px; border-radius: 3px; background: rgba(31, 33, 36, 0.8); color: #8c939b; pointer-events: none; transition: opacity 0.2s; }
288
+ </style>
289
+ ${e.src ? `<script type="importmap">${importMap(u)}</script>
290
+ <script type="module" src="${esc(u.app('embed.js'))}"></script>` : ''}
291
+ </head>
292
+ <body>
293
+ ${e.poster ? `<img class="poster" id="poster" src="${esc(e.poster)}" alt="${esc(e.title)}">` : ''}
294
+ ${e.src ? `<canvas id="gl" data-src="${esc(e.src)}" data-wheel="${e.wheel}"></canvas>` : ''}
295
+ ${e.src && e.wheel === 'click' ? '<span class="hint" id="hint" hidden>Click to zoom with the wheel</span>' : ''}
296
+ <a class="badge" href="${esc(e.link)}" target="_blank" rel="noopener">${esc(e.title)} · TopoTopo</a>
297
+ <span class="note" id="note">${e.src && !e.poster ? 'Loading…' : ''}</span>
298
+ </body>
299
+ </html>
300
+ `;
301
+ }
@@ -0,0 +1,24 @@
1
+ import type { WebConfig } from '../config.ts';
2
+ import { BakeQueue } from './bake.ts';
3
+ import type { WalkLimits } from './folders.ts';
4
+ export interface WebOptions {
5
+ /** default: the config's web.port (7340); 0 picks a free port (tests) */
6
+ port?: number;
7
+ config?: WebConfig;
8
+ /** bake packages whose previews are missing or stale (default true) */
9
+ bake?: boolean;
10
+ log?: (msg: string) => void;
11
+ /** how far the audits walk (tests make them short) */
12
+ walkLimits?: Partial<WalkLimits>;
13
+ }
14
+ export interface WebServer {
15
+ url: string;
16
+ port: number;
17
+ /** read the libraries again (the server does so on file changes and every 5 minutes) */
18
+ rescan: () => void;
19
+ queue: BakeQueue;
20
+ close: () => void;
21
+ }
22
+ /** A web app answers here already: its URL, or null. */
23
+ export declare function runningWeb(port: number): Promise<string | null>;
24
+ export declare function startWeb(o?: WebOptions): Promise<WebServer>;