topotopo 0.4.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.
Files changed (336) hide show
  1. package/NOTICE +10 -10
  2. package/README.md +460 -117
  3. package/dist/cli.js +323 -146
  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 +196 -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 +44 -5
  191. package/dist/render/preview.d.ts +15 -4
  192. package/dist/render/preview.js +6 -4
  193. package/dist/render/raster.d.ts +66 -5
  194. package/dist/render/raster.js +506 -138
  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 +17 -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,124 @@
1
+ import type { Geometry } from '../core/geometry.ts';
2
+ import type { DiffResult } from '../explain.ts';
3
+ import type { StopSignal } from '../graph/engine.ts';
4
+ import type { Scope } from '../graph/scope.ts';
5
+ import type { NodeSpec } from '../graph/types.ts';
6
+ import type { PackageUses, UpdateTarget } from './registry.ts';
7
+ type GraphKind = 'graph' | 'asset' | 'file';
8
+ /** A node of the updated package's type in a graph of the package. */
9
+ export interface UsePlace {
10
+ file: string;
11
+ kind: GraphKind;
12
+ /** the node: "pine", or "loop/pine" for one in the nested graph of node "loop" */
13
+ node: string;
14
+ type: string;
15
+ spec: NodeSpec;
16
+ }
17
+ /** How one side of a comparison cooked; `cooked`: the nodes it cooked, the others came from the cache. */
18
+ export interface CookedSide {
19
+ ok: boolean;
20
+ geo: Geometry | null;
21
+ errors: string[];
22
+ warnings: string[];
23
+ cooked: number;
24
+ }
25
+ /** A node of a graph cooked with each version: a use, or the node whose nested graph holds uses. */
26
+ export interface Compared {
27
+ file: string;
28
+ kind: GraphKind;
29
+ node: string;
30
+ /** the uses it holds: the node itself, or those in its nested graphs */
31
+ uses: UsePlace[];
32
+ before: CookedSide;
33
+ after: CookedSide;
34
+ /** when both cooked: what changed, and the two results compared (packed ones expanded) */
35
+ diff?: DiffResult;
36
+ geo?: [Geometry, Geometry];
37
+ /** what expanding packed results says (a subset above the triangle budget) */
38
+ notes: string[];
39
+ }
40
+ export interface BeforeAfter {
41
+ target: UpdateTarget;
42
+ /** "package forest" */
43
+ package: string;
44
+ /** every place the package uses the updated package, and the cooks that compare them */
45
+ uses: UsePlace[];
46
+ compared: Compared[];
47
+ /** how many cooks compare all the places (compared is shorter when stopped) */
48
+ total: number;
49
+ /** what goes away or means something else between the two versions, and the other changes (compareInterfaces) */
50
+ interfaceBig: string[];
51
+ interfaceSmall: string[];
52
+ /** what the package's graphs must change for the version the update goes to */
53
+ mustChange: string[];
54
+ /** stopped (BeforeAfterOptions.signal) before every place was compared */
55
+ stopped: boolean;
56
+ /** graph files that could not be read, the new version's own problems */
57
+ problems: string[];
58
+ ms: number;
59
+ }
60
+ export interface BeforeAfterOptions {
61
+ /** the version to go to (default: the newest with the same big number) */
62
+ to?: string;
63
+ /** a person's stop: the cooks stop at their next node and the comparison ends there */
64
+ signal?: StopSignal;
65
+ /** before each cook: the cooks done, of all, and what cooks now */
66
+ progress?: (done: number, total: number, what: string) => void;
67
+ /**
68
+ * Where the package's graphs and assets are when the engine's root does not hold them (the viewer of a graph file
69
+ * keeps its session in a scratch folder): a scope that holds them (loadPackage), whose packages are the package's
70
+ * resolver, and the package folder their relative paths read.
71
+ */
72
+ package?: {
73
+ scope: Scope;
74
+ folder: string;
75
+ };
76
+ }
77
+ /**
78
+ * The before/after of updating a package in use (to `o.to`, or the newest version with the same big
79
+ * number): every place it is used, cooked with both versions and compared, the notes of the versions between, and
80
+ * for a big version what the graphs must change. Throws when there is no update (PackageUses.updateTarget).
81
+ */
82
+ export declare function beforeAfter(pk: PackageUses, pkg: string, o?: BeforeAfterOptions): Promise<BeforeAfter>;
83
+ /**
84
+ * Apply an update, the step after its before/after, from the version in use to the version it showed (both named: what
85
+ * the person saw, and refused when the manifest uses another version now): copy the version in with what it uses, name
86
+ * it in "uses" and the lock, delete the copies nothing uses any more, and say what the graphs must change for it (a big
87
+ * version is applied anyway: the graphs report those errors until they change). The CLI, the workspace tool and the
88
+ * viewer apply updates through it.
89
+ */
90
+ export declare function applyUpdate(pk: PackageUses, pkg: string, o: {
91
+ from: string;
92
+ to: string;
93
+ }): {
94
+ target: UpdateTarget;
95
+ text: string;
96
+ mustChange: string[];
97
+ };
98
+ /**
99
+ * Remove a package in use (PackageUses.remove): refused while a graph of the package still names it (in
100
+ * graphs/, assets/ or a graph file in its folder, nested graphs included), which it lists.
101
+ */
102
+ export declare function removePackage(pk: PackageUses, pkg: string): {
103
+ deleted: string[];
104
+ text: string;
105
+ };
106
+ /** A node's params and wiring, short (with a space before it, empty when it sets none). */
107
+ export declare function setText(spec: NodeSpec): string;
108
+ /** A before/after as the CLI and the workspace tool say it, ending with `closing` (how to apply it). */
109
+ export declare function beforeAfterText(r: BeforeAfter, closing: string): string;
110
+ /**
111
+ * Overlay renders of the places that changed most (at most `max`): b where it lies on a grey, b away from a blue (moved
112
+ * or new with the new version), a away from b orange (moved from or gone).
113
+ */
114
+ export declare function overlayRenders(r: BeforeAfter, max?: number): {
115
+ title: string;
116
+ png: Uint8Array;
117
+ }[];
118
+ /**
119
+ * The out-of-date packages of a package as the CLI (or, `mcp`, the workspace tool) says them: each with the notes of the
120
+ * versions after the one in use (and the outputs of another kind), then one line for those up to date, what could not
121
+ * be checked, and the update to run for each. `folder`: the package folder as the command named it, for those lines.
122
+ */
123
+ export declare function outdatedText(pk: PackageUses, mcp?: boolean, folder?: string): string;
124
+ export {};
@@ -0,0 +1,476 @@
1
+ // Out of date and Update (the registry is src/packages/registry.ts): the newer versions of the packages a package uses,
2
+ // and the before/after of an update. The before/after finds every place the package uses the updated package (each node of
3
+ // its type in the package's graphs, assets and graph files, nested graphs included, with its params and inputs as they
4
+ // are; in a workspace, in every package that shares the workspace's copies, as an update changes them all), cooks each with the version in use and with the version the update goes to, says what changed (diffGeometry)
5
+ // and draws an overlay; with it come the notes of the versions between them and, for a big version, what the graphs
6
+ // must change. Nothing is written: the new version is read where its library holds it. Applying is a step of its own,
7
+ // taken when the person says so.
8
+ //
9
+ // Graphs and assets cook in the package's root scope (as a session has them; a command reads them with
10
+ // loadPackage, the viewer of a graph file into a scope of their own: BeforeAfterOptions.package), with the version in
11
+ // use, and in a scope like it whose packages resolve the update's version. A graph file elsewhere in the folder cooks
12
+ // in a scope of its folder, as `topotopo <file>` cooks it. A use inside a nested graph (a foreach or solver body) is
13
+ // compared through the node that holds it. Each cook gets only what its node needs, so another node's error stays out
14
+ // of it, and reuses the engine's cache.
15
+ import { isGraph } from '../graph/types.js';
16
+ import fs from 'node:fs';
17
+ import path from 'node:path';
18
+ import zlib from 'node:zlib';
19
+ import { expandPacked } from '../core/packed.js';
20
+ import { diffGeometry, diffOverlay } from '../explain.js';
21
+ import { wiringOf } from '../graph/engine.js';
22
+ import { upstreamOf } from '../graph/packages.js';
23
+ import { didYouMean, resolveParamName } from '../graph/params.js';
24
+ import { parsePackageName } from '../graph/scope.js';
25
+ import { encodePNG } from '../render/png.js';
26
+ import { renderGeometry } from '../render/raster.js';
27
+ import { NAME_RE, topoFiles } from '../session.js';
28
+ import { copiesFor, program } from '../package.js';
29
+ import { scanWorkspace } from '../workspace.js';
30
+ import { compareInterfaces, compareVersions, kindChanges, loadPackage } from './registry.js';
31
+ /**
32
+ * Folders a search for graph files does not enter: anywhere, those holding data and exports (a graph file has its own
33
+ * inputs/ and exports/ beside it) and node_modules; at the top of the package, its own folders (graphs/ and assets/
34
+ * are read as such); never dot-folders or another package's folder.
35
+ */
36
+ const NO_GRAPHS = new Set(['inputs', 'exports', 'node_modules']);
37
+ const OWN = new Set(['graphs', 'assets', 'attachments', 'versions', 'packages']);
38
+ /** Graph files are read up to this size (a graph is up to about 100 KB). */
39
+ const MAX_GRAPH_BYTES = 16 * 2 ** 20;
40
+ /** Packed results are compared expanded, up to this many triangles. */
41
+ const MAX_TRIANGLES = 4_000_000;
42
+ /**
43
+ * The packages whose graphs use the copies an update or a remove changes: the open package, and in a workspace every
44
+ * other package that shares its copies (one version of each package for the whole game).
45
+ */
46
+ function packagesOf(pk) {
47
+ const { dir } = pk.package();
48
+ const out = [{ dir, rel: '' }];
49
+ const ws = pk.store?.workspace;
50
+ if (!ws)
51
+ return out;
52
+ let found = [];
53
+ try {
54
+ found = scanWorkspace(ws).packages;
55
+ }
56
+ catch { /* its file cannot be read: the open package alone */ }
57
+ for (const p of found) {
58
+ if (path.resolve(p.dir).toLowerCase() === path.resolve(dir).toLowerCase() || copiesFor(p.dir).workspace !== ws)
59
+ continue;
60
+ out.push({ dir: p.dir, rel: p.rel });
61
+ }
62
+ return out;
63
+ }
64
+ // ---------------------------------------------------------------------------------------------- the package's uses
65
+ /** The graphs of the package that name the updated package: in graphs/, in assets/, and graph files elsewhere in its folder. */
66
+ function graphsNaming(dir, pkg, problems) {
67
+ const out = [];
68
+ const read = (abs, file, kind) => {
69
+ let text;
70
+ try {
71
+ if (fs.statSync(abs).size > MAX_GRAPH_BYTES)
72
+ return;
73
+ text = fs.readFileSync(abs, 'utf8');
74
+ }
75
+ catch (e) {
76
+ problems.push(`${file}: ${e.message}`);
77
+ return;
78
+ }
79
+ // only graphs that name the package matter: its name starts a node's type
80
+ if (!text.includes(`"${pkg}`))
81
+ return;
82
+ let spec;
83
+ try {
84
+ spec = JSON.parse(text);
85
+ }
86
+ catch (e) {
87
+ if (kind !== 'file')
88
+ problems.push(`${file}: ${e.message}`);
89
+ return;
90
+ }
91
+ if (!isGraph(spec))
92
+ return;
93
+ try {
94
+ out.push({ file, kind, spec: spec, ...(kind === 'file' ? { folder: path.dirname(abs) } : {}) });
95
+ }
96
+ catch (e) {
97
+ problems.push(`${file}: ${e.message}`);
98
+ }
99
+ };
100
+ for (const [sub, kind] of [['graphs', 'graph'], ['assets', 'asset']]) {
101
+ let files = [];
102
+ try {
103
+ files = fs.readdirSync(path.join(dir, sub)).filter((f) => f.endsWith('.json')).sort();
104
+ }
105
+ catch { /* none */ }
106
+ for (const f of files)
107
+ if (kind === 'asset' || NAME_RE.test(f.slice(0, -5)))
108
+ read(path.join(dir, sub, f), `${sub}/${f}`, kind);
109
+ }
110
+ // graph files elsewhere in the folder, which `topotopo <file>` and `topotopo view` cook; not those of another package
111
+ const walk = (d, rel, depth) => {
112
+ let entries;
113
+ try {
114
+ entries = fs.readdirSync(d, { withFileTypes: true });
115
+ }
116
+ catch {
117
+ return;
118
+ }
119
+ for (const e of entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
120
+ if (e.name.startsWith('.'))
121
+ continue;
122
+ const abs = path.join(d, e.name), r = rel ? `${rel}/${e.name}` : e.name;
123
+ if (e.isDirectory()) {
124
+ if (!NO_GRAPHS.has(e.name) && !(depth === 0 && OWN.has(e.name)) && depth < 8 && !topoFiles(abs).length)
125
+ walk(abs, r, depth + 1);
126
+ }
127
+ else if (e.isFile() && e.name.endsWith('.json'))
128
+ read(abs, r, 'file');
129
+ }
130
+ };
131
+ walk(dir, '', 0);
132
+ return out;
133
+ }
134
+ /** The nodes of a graph whose type is an output of `pkg`, nested graphs included, and the top-level node holding each. */
135
+ function usesIn(g, pkg) {
136
+ const out = [];
137
+ const walk = (x, prefix, top, depth) => {
138
+ if (depth > 64)
139
+ return;
140
+ for (const [name, spec] of Object.entries(x.nodes)) {
141
+ if (!spec || typeof spec !== 'object')
142
+ continue;
143
+ if (typeof spec.type === 'string' && spec.type.includes('/')) {
144
+ const n = parsePackageName(spec.type);
145
+ if (typeof n !== 'string' && n.package === pkg)
146
+ out.push({ node: prefix + name, top: top ?? name, spec });
147
+ }
148
+ if (spec.params && typeof spec.params === 'object')
149
+ for (const v of Object.values(spec.params))
150
+ if (isGraph(v))
151
+ walk(v, `${prefix}${name}/`, top ?? name, depth + 1);
152
+ }
153
+ };
154
+ walk(g, '', null, 0);
155
+ return out;
156
+ }
157
+ /**
158
+ * Every place the packages use the updated package, and the cooks that compare them: a graph's node with the uses it holds.
159
+ * The files of another package are named from the workspace.
160
+ */
161
+ function placesOf(packages, pkg, problems) {
162
+ const uses = [], units = [];
163
+ const graphs = packages.flatMap((p) => {
164
+ const said = [];
165
+ const found = graphsNaming(p.dir, pkg, said);
166
+ problems.push(...said.map((x) => (p.rel ? `${p.rel}/${x}` : x)));
167
+ return p.rel ? found.map((g) => ({ ...g, file: `${p.rel}/${g.file}`, home: p.dir })) : found;
168
+ });
169
+ for (const g of graphs) {
170
+ const byTop = new Map();
171
+ for (const u of usesIn(g.spec, pkg)) {
172
+ const place = { file: g.file, kind: g.kind, node: u.node, type: u.spec.type, spec: u.spec };
173
+ uses.push(place);
174
+ if (!byTop.has(u.top))
175
+ byTop.set(u.top, []);
176
+ byTop.get(u.top).push(place);
177
+ }
178
+ for (const [node, list] of byTop)
179
+ units.push({ g, node, uses: list });
180
+ }
181
+ return { uses, units };
182
+ }
183
+ /**
184
+ * What the package's graphs must change for the version the update goes to: outputs they use that it does not have,
185
+ * params they set that it does not have (with did-you-mean over its params), values they set that its narrower range
186
+ * clamps or that are options it no longer has, inputs they wire that it does not have.
187
+ */
188
+ function mustChange(uses, before, after, t) {
189
+ const must = [], problems = [], at = `${t.package} ${t.to}`;
190
+ // the version loads when the resolver names its outputs; else what it says is a problem of the version, not a change
191
+ const loads = after.names().some((n) => n === t.package || n.startsWith(`${t.package}/`));
192
+ for (const u of uses) {
193
+ const where = `${u.file} ${u.node}`;
194
+ const was = before.resolve(u.type), now = after.resolve(u.type);
195
+ if ('error' in now) {
196
+ const said = `${now.error}${now.hint ? ` (${now.hint})` : ''}`;
197
+ if (loads)
198
+ must.push(`${where}: uses ${u.type}, and ${said}`);
199
+ else if (!problems.includes(said))
200
+ problems.push(said);
201
+ continue;
202
+ }
203
+ // a use that does not resolve now does not resolve after either: the update changes nothing about it
204
+ if ('error' in was)
205
+ continue;
206
+ for (const [k, value] of Object.entries(u.spec.params ?? {})) {
207
+ if (!resolveParamName(was, k))
208
+ continue;
209
+ const pn = resolveParamName(now, k);
210
+ if (!pn) {
211
+ const s = didYouMean(k, Object.keys(now.params));
212
+ must.push(`${where}: sets param "${k}", which ${at} does not have${s.length ? ` — did you mean ${s.map((x) => `"${x}"`).join(' or ')}?` : ''} (its params: ${Object.keys(now.params).join(', ') || 'none'})`);
213
+ continue;
214
+ }
215
+ // a value the new version takes otherwise: clamped to a narrower range, or an option it no longer has
216
+ const p = now.params[pn];
217
+ if (typeof value === 'number') {
218
+ const clamped = Math.min(p.max ?? Infinity, Math.max(p.min ?? -Infinity, value));
219
+ if (clamped !== value)
220
+ must.push(`${where}: sets "${k}" ${value}, which ${at} clamps to ${clamped} (its range is ${p.min ?? ''}..${p.max ?? ''})`);
221
+ }
222
+ if (p.options && (typeof value === 'number' || (typeof value === 'string' && !value.startsWith('='))) && !p.options.includes(value))
223
+ must.push(`${where}: sets "${k}" ${JSON.stringify(value)}, an option ${at} does not have (its options: ${p.options.map((x) => JSON.stringify(x)).join(', ')})`);
224
+ }
225
+ wiringOf(u.spec, was).list.forEach((ref, i) => {
226
+ if (!ref)
227
+ return;
228
+ const label = was.inputs[i]?.desc ?? `input ${i}`, there = now.inputs.findIndex((x) => x.desc === label);
229
+ if (i >= now.inputs.length)
230
+ must.push(`${where}: wires input ${i} ("${label}"), which ${at} does not have${there >= 0 ? `: it is input ${there} there` : ` (it has ${now.inputs.length === 1 ? '1 input' : `${now.inputs.length} inputs`})`}`);
231
+ else if (there >= 0 && there !== i && now.inputs[i].desc !== label)
232
+ must.push(`${where}: wires input ${i} ("${label}"), which is input ${there} in ${at}`);
233
+ });
234
+ }
235
+ return { must, problems };
236
+ }
237
+ // ---------------------------------------------------------------------------------------------------- cooking
238
+ /** The graph with only what `target` needs, upstream: its inputs and the nodes its expressions read. */
239
+ function needed(g, target) {
240
+ const keep = new Set(upstreamOf(g, target));
241
+ const out = { ...g, nodes: Object.fromEntries(Object.entries(g.nodes).filter(([k]) => keep.has(k))), output: target };
242
+ delete out.outputs;
243
+ delete out.export;
244
+ return out;
245
+ }
246
+ /** A cook's progress hook that lets the event loop turn every 15 ms or so, so a stop and other requests get through. */
247
+ function yielding() {
248
+ let last = performance.now();
249
+ return (ev) => {
250
+ if (ev.phase === 'end' || performance.now() - last < 15)
251
+ return;
252
+ last = performance.now();
253
+ return new Promise((resolve) => setImmediate(resolve));
254
+ };
255
+ }
256
+ const sideOf = (r) => ({
257
+ ok: r.ok && !!r.geo, geo: r.ok ? r.geo : null,
258
+ errors: r.errors.map((e) => `[${e.node}] ${e.message}${e.hint ? ` (hint: ${e.hint})` : ''}`),
259
+ warnings: r.warnings.map((w) => `[${w.node}] ${w.message}`),
260
+ cooked: [...r.results.values()].filter((x) => !x.cached && !x.error).length,
261
+ });
262
+ /**
263
+ * The before/after of updating a package in use (to `o.to`, or the newest version with the same big
264
+ * number): every place it is used, cooked with both versions and compared, the notes of the versions between, and
265
+ * for a big version what the graphs must change. Throws when there is no update (PackageUses.updateTarget).
266
+ */
267
+ export async function beforeAfter(pk, pkg, o = {}) {
268
+ const t0 = performance.now();
269
+ const t = pk.updateTarget(pkg, o.to);
270
+ const engine = pk.engine, root = o.package?.scope ?? engine.root;
271
+ const { before, after, key, problems: versionProblems } = pk.updateResolvers(t);
272
+ const problems = [];
273
+ const { uses, units } = placesOf(packagesOf(pk), pkg, problems);
274
+ // another package of the workspace: its graphs and assets in a scope of their own, as its session has them
275
+ const homes = new Map();
276
+ const homeOf = (dir) => {
277
+ let s = homes.get(dir);
278
+ if (!s) {
279
+ s = engine.createScope(`update home ${key} ${dir}`, { folder: dir, packages: pk.resolver });
280
+ problems.push(...loadPackage(engine, dir, s));
281
+ homes.set(dir, s);
282
+ }
283
+ return s;
284
+ };
285
+ // graphs and assets: the package's root (or another package's), and a scope like it with the update's packages;
286
+ // graph files: their folder
287
+ const scopes = new Map();
288
+ const scopesOf = (g) => {
289
+ const id = g.folder ?? g.home ?? '';
290
+ let s = scopes.get(id);
291
+ if (!s) {
292
+ const base = g.home ? homeOf(g.home) : root, folder = g.home ?? o.package?.folder;
293
+ const like = (name, packages) => (g.folder
294
+ ? engine.createScope(`update ${name} ${key} ${g.folder}`, { folder: g.folder, packages })
295
+ : engine.createScope(`update ${name} ${key}${folder ? ` ${folder}` : ''}`, { assets: base.assets, graphs: (n) => base.graphs?.(n), packages, ...(folder ? { folder } : {}) }));
296
+ s = { before: !g.folder && before === pk.resolver ? base : like('before', before), after: like('after', after) };
297
+ scopes.set(id, s);
298
+ }
299
+ return s;
300
+ };
301
+ const onNode = yielding();
302
+ const total = units.length * 2;
303
+ const compared = [];
304
+ let done = 0, stopped = false;
305
+ const cook = async (u, scope, v) => {
306
+ o.progress?.(done, total, `${u.g.file} ${u.node} with ${t.package} ${v}`);
307
+ const r = await engine.cook(needed(u.g.spec, u.node), { target: u.node, scope, signal: o.signal, onNode });
308
+ done++;
309
+ return r;
310
+ };
311
+ for (const u of units) {
312
+ if (o.signal?.aborted) {
313
+ stopped = true;
314
+ break;
315
+ }
316
+ const s = scopesOf(u.g);
317
+ const rb = await cook(u, s.before, t.from);
318
+ const ra = rb.stopped ? rb : await cook(u, s.after, t.to);
319
+ if (rb.stopped || ra.stopped) {
320
+ stopped = true;
321
+ break;
322
+ }
323
+ const c = { file: u.g.file, kind: u.g.kind, node: u.node, uses: u.uses, before: sideOf(rb), after: sideOf(ra), notes: [] };
324
+ if (c.before.geo && c.after.geo) {
325
+ const [x, y] = [c.before.geo, c.after.geo].map((g) => (g.hasPacked() ? expandPacked(g, { maxTriangles: MAX_TRIANGLES }) : { geo: g, notes: [] }));
326
+ if (c.before.geo.hasPacked() || c.after.geo.hasPacked())
327
+ c.notes.push('packed instances compared expanded', ...new Set([...x.notes, ...y.notes]));
328
+ c.diff = diffGeometry(x.geo, y.geo, [`${t.package} ${t.from}`, `${t.package} ${t.to}`]);
329
+ c.geo = [x.geo, y.geo];
330
+ }
331
+ compared.push(c);
332
+ }
333
+ const m = mustChange(uses, before, after, t);
334
+ const ic = t.fromInfo ? compareInterfaces(t.fromInfo, t.toInfo) : { big: [], small: [] };
335
+ return {
336
+ target: t, package: pk.holder, uses, compared, total, interfaceBig: ic.big, interfaceSmall: ic.small, mustChange: m.must, stopped,
337
+ problems: [...new Set([...problems, ...m.problems, ...versionProblems()])], ms: performance.now() - t0,
338
+ };
339
+ }
340
+ /**
341
+ * Apply an update, the step after its before/after, from the version in use to the version it showed (both named: what
342
+ * the person saw, and refused when the manifest uses another version now): copy the version in with what it uses, name
343
+ * it in "uses" and the lock, delete the copies nothing uses any more, and say what the graphs must change for it (a big
344
+ * version is applied anyway: the graphs report those errors until they change). The CLI, the workspace tool and the
345
+ * viewer apply updates through it.
346
+ */
347
+ export function applyUpdate(pk, pkg, o) {
348
+ if (typeof o?.from !== 'string' || typeof o?.to !== 'string')
349
+ throw new Error('applying an update needs "from" and "to": the version in use and the version of the before/after the person saw');
350
+ pk.refresh();
351
+ const now = pk.uses()[pkg];
352
+ if (now !== undefined && now !== o.from)
353
+ throw new Error(`${pk.usesFileName} uses ${pkg} ${now} now, not ${o.from}: look at the before/after again`);
354
+ const t = pk.updateTarget(pkg, o.to);
355
+ const { before, after } = pk.updateResolvers(t);
356
+ const m = mustChange(placesOf(packagesOf(pk), pkg, []).uses, before, after, t);
357
+ const r = pk.applyUpdate(t);
358
+ const lines = [r.text];
359
+ if (m.must.length)
360
+ lines.push(`${pk.store?.workspace ? 'the graphs of the workspace\'s packages' : 'the package\'s graphs'} must change for ${t.package} ${t.to}; until they do, they report these errors:`, ...m.must.map((x) => ` ${x}`));
361
+ return { target: t, text: lines.join('\n'), mustChange: m.must };
362
+ }
363
+ /**
364
+ * Remove a package in use (PackageUses.remove): refused while a graph of the package still names it (in
365
+ * graphs/, assets/ or a graph file in its folder, nested graphs included), which it lists.
366
+ */
367
+ export function removePackage(pk, pkg) {
368
+ pk.refresh();
369
+ const places = typeof parsePackageName(pkg) === 'string' ? [] : placesOf(packagesOf(pk), pkg, []).uses.map((u) => `${u.file} ${u.node}`);
370
+ return pk.remove(pkg, places);
371
+ }
372
+ // ---------------------------------------------------------------------------------------------- what is said
373
+ /** A node's params and wiring, short (with a space before it, empty when it sets none). */
374
+ export function setText(spec) {
375
+ const parts = [];
376
+ if (spec.params && Object.keys(spec.params).length)
377
+ parts.push(JSON.stringify(spec.params));
378
+ if (spec.in !== undefined && spec.in !== null && (typeof spec.in !== 'object' || Object.keys(spec.in).length))
379
+ parts.push(`in ${JSON.stringify(spec.in)}`);
380
+ const s = parts.join(' ');
381
+ return s ? ` ${s.length > 120 ? `${s.slice(0, 117)}…` : s}` : '';
382
+ }
383
+ /** A before/after as the CLI and the workspace tool say it, ending with `closing` (how to apply it). */
384
+ export function beforeAfterText(r, closing) {
385
+ const t = r.target, up = compareVersions(t.to, t.from) > 0;
386
+ const kind = t.big ? (up ? 'a big update' : 'back to an older big version') : up ? 'a small update' : 'back to an older version';
387
+ const lines = [`before/after: ${t.package} ${t.from} → ${t.to} (${kind}) in ${r.package}; nothing has changed yet`];
388
+ lines.push(`${t.package} ${t.to} is in ${t.place}. ${up ? `The versions after ${t.from}` : `The versions it goes back over`}:`, ...t.between.map((v) => ` ${v.version} "${v.note}"`));
389
+ if (t.big) {
390
+ const step = up ? `${t.to} is a big version` : `going back to ${t.to} crosses a big version`;
391
+ lines.push(r.interfaceBig.length ? `${step}; what goes away or means something else:` : `${step}: nothing goes away between the two, and a version between was marked big by its author, its meaning changed in a way the tools cannot see (its note says how)`);
392
+ lines.push(...r.interfaceBig.map((x) => ` ${x}`));
393
+ }
394
+ if (r.mustChange.length)
395
+ lines.push(`what ${r.package.startsWith('workspace ') ? 'the graphs of its packages' : 'the package\'s graphs'} must change (updating is allowed; until they change, they report these errors):`, ...r.mustChange.map((x) => ` ${x}`));
396
+ if (!r.uses.length)
397
+ lines.push(`no graph of ${r.package} uses ${t.package}: the update changes no geometry`);
398
+ else {
399
+ lines.push(`${r.uses.length === 1 ? '1 place uses' : `${r.uses.length} places use`} ${t.package}; each cooked with ${t.from} (a) and with ${t.to} (b):`);
400
+ for (const c of r.compared) {
401
+ const self = c.uses.length === 1 && c.uses[0].node === c.node;
402
+ lines.push(` ${c.file} ${c.node}: ${self ? `${c.uses[0].type}${setText(c.uses[0].spec)}` : `holds ${c.uses.map((u) => `${u.node} (${u.type}${setText(u.spec)})`).join(', ')}; its result compared`}`);
403
+ if (!c.before.ok)
404
+ lines.push(` with ${t.from} it does not cook: ${c.before.errors.join('; ') || 'no geometry'}`);
405
+ if (!c.after.ok)
406
+ lines.push(` with ${t.to} it does not cook: ${c.after.errors.join('; ') || 'no geometry'}`);
407
+ if (c.diff) {
408
+ if (c.diff.identical)
409
+ lines.push(` ${/^verdict: (.*)$/m.exec(c.diff.text)?.[1] ?? 'no geometric change'}`);
410
+ else
411
+ lines.push(...c.diff.text.split('\n').slice(1).map((l) => ` ${l}`));
412
+ }
413
+ if (c.notes.length)
414
+ lines.push(` (${c.notes.join('; ')})`);
415
+ }
416
+ const changed = r.compared.filter((c) => c.diff && !c.diff.identical).length, failed = r.compared.filter((c) => !c.after.ok).length;
417
+ lines.push(`in short: ${changed} of the ${r.compared.length} compared changed${failed ? `, ${failed} ${failed === 1 ? 'does' : 'do'} not cook with ${t.to}` : ''}${r.stopped ? `; stopped after ${r.compared.length} of ${r.total / 2} comparisons: the others are not listed` : ''}`);
418
+ }
419
+ if (r.problems.length)
420
+ lines.push('problems:', ...r.problems.map((p) => ` ${p}`));
421
+ lines.push(closing);
422
+ return lines.join('\n');
423
+ }
424
+ /**
425
+ * Overlay renders of the places that changed most (at most `max`): b where it lies on a grey, b away from a blue (moved
426
+ * or new with the new version), a away from b orange (moved from or gone).
427
+ */
428
+ export function overlayRenders(r, max = 6) {
429
+ const far = (c) => (Number.isFinite(c.diff.hausdorff) ? c.diff.hausdorff : Number.MAX_VALUE);
430
+ return r.compared
431
+ .filter((c) => c.diff && !c.diff.identical && c.geo && c.geo[0].numPoints && c.geo[1].numPoints)
432
+ .sort((a, b) => far(b) - far(a))
433
+ .slice(0, max)
434
+ .map((c) => {
435
+ const img = renderGeometry(diffOverlay(c.geo[0], c.geo[1]), { size: 300, title: `${c.file} ${c.node}: orange ${r.target.from}, blue ${r.target.to}` });
436
+ return { title: `${c.file} ${c.node}`, png: encodePNG(img.rgba, img.width, img.height, (d) => zlib.deflateSync(d, { level: 6 })) };
437
+ });
438
+ }
439
+ /**
440
+ * The out-of-date packages of a package as the CLI (or, `mcp`, the workspace tool) says them: each with the notes of the
441
+ * versions after the one in use (and the outputs of another kind), then one line for those up to date, what could not
442
+ * be checked, and the update to run for each. `folder`: the package folder as the command named it, for those lines.
443
+ */
444
+ export function outdatedText(pk, mcp = false, folder) {
445
+ const problems = [];
446
+ const list = pk.outdated(problems);
447
+ if (!list.length)
448
+ return `${pk.holder} uses no packages${problems.length ? `\ncould not check ${problems.length}:\n${problems.map((p) => ` ${p}`).join('\n')}` : ''}`;
449
+ const late = list.filter((o) => o.small || o.big), fine = list.filter((o) => !o.error && !o.small && !o.big), failed = list.filter((o) => o.error);
450
+ const counts = [late.length ? `${late.length} out of date` : '', fine.length ? `${fine.length} up to date` : '', failed.length || problems.length ? `could not check ${failed.length + problems.length}` : ''].filter(Boolean);
451
+ const lines = [`${pk.holder} uses ${list.length} package${list.length === 1 ? '' : 's'}: ${counts.join(', ')}`];
452
+ for (const o of late) {
453
+ lines.push(` ${o.package} ${o.version}: ${[o.small ? `${o.small} is out` : '', o.big ? `${o.big} is out (big)` : ''].filter(Boolean).join(', ')} [${o.places.join(', ')}]`);
454
+ // each newer version's note, and its outputs of another kind
455
+ let was = pk.copyInfo(o.package, o.version);
456
+ for (const v of o.newer) {
457
+ const kinds = was ? kindChanges(was, v) : [];
458
+ lines.push(` ${v.version} "${v.note}"${kinds.length ? ` (another kind: ${kinds.join('; ')})` : ''}`);
459
+ was = v;
460
+ }
461
+ }
462
+ if (fine.length)
463
+ lines.push(`${fine.length} up to date: ${fine.map((o) => `${o.package} ${o.version}`).join(', ')}`);
464
+ if (failed.length || problems.length)
465
+ lines.push(`could not check ${failed.length + problems.length}:`, ...failed.map((o) => ` ${o.package} ${o.version}: ${o.error}`), ...problems.map((p) => ` ${p}`));
466
+ const at = folder ? ` ${/\s/.test(folder) ? JSON.stringify(folder) : folder}` : '';
467
+ for (const o of late) {
468
+ const to = o.small ?? o.big;
469
+ lines.push(mcp
470
+ ? `workspace {action:"update", package:"${o.package}"${o.small ? '' : `, to:"${to}"`}} shows the before/after of ${o.version} → ${to}; nothing changes until the person says so`
471
+ : `${program()} update ${o.package}${at}${o.small ? '' : ` --to ${to}`} shows the before/after of ${o.version} → ${to}; nothing changes until you apply it`);
472
+ if (o.small && o.big)
473
+ lines.push(mcp ? ` the big one: workspace {action:"update", package:"${o.package}", to:"${o.big}"}` : ` the big one: ${program()} update ${o.package}${at} --to ${o.big}`);
474
+ }
475
+ return lines.join('\n');
476
+ }
@@ -5,5 +5,7 @@ export declare function parsePlane(s: string, key: string): {
5
5
  offset: number;
6
6
  absolute: boolean;
7
7
  };
8
+ /** Pixels per view: 800, "800", "1600x900" (also 1600×900 or 1600,900) or [1600, 900]. */
9
+ export declare function parseSize(v: unknown): number | [number, number];
8
10
  /** Map tool-style arguments (snake_case; camelCase also accepted) to RenderOptions. */
9
11
  export declare function renderArgs(a: Record<string, any>): RenderOptions;