topotopo 0.5.1 → 0.5.3

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 (41) hide show
  1. package/dist/cli.js +42 -18
  2. package/dist/core/manifold.d.ts +11 -2
  3. package/dist/core/manifold.js +7 -4
  4. package/dist/core/materials.d.ts +3 -2
  5. package/dist/core/materials.js +3 -2
  6. package/dist/core/tangents.d.ts +11 -1
  7. package/dist/core/tangents.js +87 -14
  8. package/dist/core/texture.d.ts +1 -1
  9. package/dist/core/texture.js +12 -3
  10. package/dist/core/topology.d.ts +5 -1
  11. package/dist/core/topology.js +35 -4
  12. package/dist/graph/engine.d.ts +7 -0
  13. package/dist/graph/engine.js +54 -6
  14. package/dist/io/gltf.js +8 -7
  15. package/dist/io/source.d.ts +2 -0
  16. package/dist/io/source.js +10 -1
  17. package/dist/mcp/docs.js +35 -8
  18. package/dist/mcp/tools.js +35 -10
  19. package/dist/nodes/attributes.js +12 -3
  20. package/dist/nodes/bake.js +2 -2
  21. package/dist/nodes/curves.js +7 -7
  22. package/dist/nodes/material.js +3 -3
  23. package/dist/nodes/solid.js +42 -15
  24. package/dist/nodes/texture.js +16 -9
  25. package/dist/nodes/topology.js +3 -2
  26. package/dist/packages/registry.d.ts +21 -8
  27. package/dist/packages/registry.js +57 -24
  28. package/dist/render/options.js +9 -1
  29. package/dist/render/pbr.d.ts +22 -2
  30. package/dist/render/pbr.js +113 -38
  31. package/dist/render/preview.d.ts +2 -0
  32. package/dist/render/raster.d.ts +13 -1
  33. package/dist/render/raster.js +112 -19
  34. package/dist/session.d.ts +25 -6
  35. package/dist/session.js +98 -43
  36. package/dist/viewer/app/api.js +5 -2
  37. package/dist/viewer/app/cooking.js +9 -3
  38. package/dist/viewer/app/main.js +18 -4
  39. package/dist/viewer/server.js +20 -3
  40. package/integrations/godot/addons/topotopo/plugin.cfg +1 -1
  41. package/package.json +3 -3
package/dist/session.d.ts CHANGED
@@ -145,11 +145,24 @@ export interface SessionPackages {
145
145
  revision(): string;
146
146
  /**
147
147
  * while this session follows working folders (for looking): the scope exports cook in, resolving packages to their
148
- * published copies; null while nothing is followed
148
+ * published copies, those in `follow` (an export told to use their working folders) to their working folders; null
149
+ * while nothing is followed but those
149
150
  */
150
- published?(): Scope | null;
151
- /** what an export of the graph made while following says: the published versions it used (null: nothing to say) */
152
- publishedNote?(graph: GraphSpec): string | null;
151
+ published?(follow?: readonly string[]): Scope | null;
152
+ /**
153
+ * what an export of the graph made while following says: the working folders it used (`follow`) and the published
154
+ * versions it used for the others (null: nothing to say)
155
+ */
156
+ publishedNote?(graph: GraphSpec, follow?: readonly string[]): string | null;
157
+ /** the followed packages the graph names that an export not following them cannot cook (no published version in use) */
158
+ unpublished?(graph: GraphSpec, follow?: readonly string[]): {
159
+ package: string;
160
+ dir: string;
161
+ }[];
162
+ /** the packages this session follows */
163
+ following?(): {
164
+ package: string;
165
+ }[];
153
166
  }
154
167
  export declare class Session {
155
168
  dir: string;
@@ -287,21 +300,27 @@ export declare class Session {
287
300
  * Cook a graph (its output, or `target`) with its session values, as a cook of `kind`. Session.stop and `signal`
288
301
  * stop it at a node boundary; activity() reports it while it runs. A cook of the whole graph records its outcome
289
302
  * (lastCook) and, unless it was stopped, its report (lastReport), when no cook started after it has done so first.
290
- * An export cooks with the published copies of the packages the session shows live, and records nothing.
303
+ * An export cooks with the published copies of the packages the session shows live (the working folders of those
304
+ * `follow` names), and records nothing.
291
305
  */
292
306
  cook(name: string, target?: string, frame?: number, opts?: {
293
307
  kind?: CookKind;
294
308
  signal?: StopSignal;
309
+ follow?: readonly string[];
295
310
  }): Promise<CookReport>;
311
+ /** the folder each watcher follows; a folder that is missing has none until it is made again */
296
312
  private watchers;
297
313
  private watchTimers;
314
+ private watching;
298
315
  /**
299
316
  * Follow what other processes write into graphs/ and assets/, and in a package the graph files beside its manifest (a
300
317
  * second Session on the same folder: the web app's editor next to an MCP server, or a person editing the JSON). A
301
318
  * graph file whose content differs from the stored graph replaces it and notifies the listeners; a removed file
302
319
  * removes the graph. Our own writes read back equal, so they change nothing. An asset whose content changed is
303
320
  * registered again and every graph is notified (any may use it); a removed asset stays registered until the next
304
- * load(). Two writers to one graph: the last write wins.
321
+ * load(). Two writers to one graph: the last write wins. graphs/ and assets/ may be removed and made again (a git
322
+ * checkout, stash or branch switch): the package folder is followed too, and a folder made again is followed again
323
+ * and read again whole, as if each of its files had changed.
305
324
  */
306
325
  watch(): void;
307
326
  /** Stop following the folders (watch()). */
package/dist/session.js CHANGED
@@ -661,7 +661,8 @@ export class Session {
661
661
  * Cook a graph (its output, or `target`) with its session values, as a cook of `kind`. Session.stop and `signal`
662
662
  * stop it at a node boundary; activity() reports it while it runs. A cook of the whole graph records its outcome
663
663
  * (lastCook) and, unless it was stopped, its report (lastReport), when no cook started after it has done so first.
664
- * An export cooks with the published copies of the packages the session shows live, and records nothing.
664
+ * An export cooks with the published copies of the packages the session shows live (the working folders of those
665
+ * `follow` names), and records nothing.
665
666
  */
666
667
  async cook(name, target, frame, opts = {}) {
667
668
  const g = this.getGraph(name);
@@ -686,8 +687,9 @@ export class Session {
686
687
  this.notifyActivity(name);
687
688
  try {
688
689
  const s = this.sessions.get(name);
689
- // an export uses the published copies of the packages this session shows live (SessionPackages.published)
690
- const scope = run.kind === 'export' ? this.packages?.published?.() ?? null : null;
690
+ // an export uses the published copies of the packages this session shows live (SessionPackages.published), but
691
+ // the working folders of those it is told to follow
692
+ const scope = run.kind === 'export' ? this.packages?.published?.(opts.follow) ?? null : null;
691
693
  const r = await this.engine.cook(g, { target, frame, signal, onNode: (ev) => this.onNode(name, run, ev), ...(s?.size ? { vars: this.sessionVars(name) } : {}), ...(scope ? { scope } : {}) });
692
694
  if (seq && !scope && !(r.stopped && run.superseded) && seq > (this.recordedSeq.get(name) ?? 0)) {
693
695
  this.recordedSeq.set(name, seq);
@@ -710,51 +712,93 @@ export class Session {
710
712
  this.notifyActivity(name);
711
713
  }
712
714
  }
713
- watchers = [];
715
+ /** the folder each watcher follows; a folder that is missing has none until it is made again */
716
+ watchers = new Map();
714
717
  watchTimers = new Map();
718
+ watching = false;
715
719
  /**
716
720
  * Follow what other processes write into graphs/ and assets/, and in a package the graph files beside its manifest (a
717
721
  * second Session on the same folder: the web app's editor next to an MCP server, or a person editing the JSON). A
718
722
  * graph file whose content differs from the stored graph replaces it and notifies the listeners; a removed file
719
723
  * removes the graph. Our own writes read back equal, so they change nothing. An asset whose content changed is
720
724
  * registered again and every graph is notified (any may use it); a removed asset stays registered until the next
721
- * load(). Two writers to one graph: the last write wins.
725
+ * load(). Two writers to one graph: the last write wins. graphs/ and assets/ may be removed and made again (a git
726
+ * checkout, stash or branch switch): the package folder is followed too, and a folder made again is followed again
727
+ * and read again whole, as if each of its files had changed.
722
728
  */
723
729
  watch() {
724
- if (this.watchers.length)
730
+ if (this.watching)
725
731
  return;
726
- const on = (dir, apply) => {
732
+ this.watching = true;
733
+ const later = (key, ms, fn) => {
734
+ clearTimeout(this.watchTimers.get(key));
735
+ this.watchTimers.set(key, setTimeout(() => { this.watchTimers.delete(key); if (this.watching)
736
+ fn(); }, ms).unref());
737
+ };
738
+ // persist() is not atomic: let the writer finish, and read again if the JSON is still half written
739
+ const settle = (dir, name, apply) => {
740
+ let tries = 0;
741
+ const run = () => {
742
+ try {
743
+ apply(name, path.join(dir, name + '.json'));
744
+ }
745
+ catch (e) {
746
+ if (e instanceof SyntaxError && ++tries < 5)
747
+ later(dir + '|' + name, 100, run);
748
+ }
749
+ };
750
+ later(dir + '|' + name, 150, run);
751
+ };
752
+ const attach = (dir, onFile, onGone, onEntry) => {
753
+ const old = this.watchers.get(dir);
754
+ this.watchers.delete(dir);
755
+ old?.close();
756
+ let w;
727
757
  try {
728
- const w = fs.watch(dir, (_ev, f) => {
758
+ w = fs.watch(dir, (ev, f) => {
729
759
  const rel = f ? String(f) : '';
730
- // Windows names a removed folder by its absolute path: stop rather than follow a folder that is gone
731
- if (path.isAbsolute(rel)) {
732
- w.close();
760
+ // the folder itself was removed: Windows names it by its absolute path, Linux by its own name
761
+ if (path.isAbsolute(rel) || (rel === path.basename(dir) && !fs.existsSync(dir))) {
762
+ gone();
733
763
  return;
734
764
  }
765
+ if (ev === 'rename' && onEntry)
766
+ onEntry(rel);
735
767
  if (!rel.endsWith('.json') || rel.includes(path.sep) || rel.startsWith('.'))
736
768
  return;
737
- const name = rel.slice(0, -'.json'.length), key = dir + '|' + name;
738
- clearTimeout(this.watchTimers.get(key));
739
- // persist() is not atomic: let the writer finish, and read again if the JSON is still half written
740
- let tries = 0;
741
- const run = () => {
742
- this.watchTimers.delete(key);
743
- try {
744
- apply(name, path.join(dir, rel));
745
- }
746
- catch (e) {
747
- if (e instanceof SyntaxError && ++tries < 5)
748
- this.watchTimers.set(key, setTimeout(run, 100).unref());
749
- }
750
- };
751
- this.watchTimers.set(key, setTimeout(run, 150).unref());
769
+ onFile(rel.slice(0, -'.json'.length));
752
770
  });
753
- w.on('error', () => w.close());
754
- w.unref();
755
- this.watchers.push(w);
756
771
  }
757
- catch { /* no folder: nothing to follow */ }
772
+ catch {
773
+ return; /* no folder: the package folder's watcher hears when it is made */
774
+ }
775
+ // a removed folder: close at once (Windows keeps a watched folder from going while its handle is open)
776
+ const gone = () => {
777
+ if (this.watchers.get(dir) !== w)
778
+ return;
779
+ this.watchers.delete(dir);
780
+ w.close();
781
+ onGone();
782
+ };
783
+ w.on('error', gone);
784
+ w.on('close', gone);
785
+ w.unref();
786
+ this.watchers.set(dir, w);
787
+ };
788
+ // graphs/ or assets/: follow its files; when it goes or comes back, follow the folder now there and read it again
789
+ const child = (dir, apply, known) => {
790
+ const reopen = () => {
791
+ attach(dir, (name) => settle(dir, name, apply), () => later(dir, 150, reopen));
792
+ let files = [];
793
+ try {
794
+ files = fs.readdirSync(dir).filter((f) => f.endsWith('.json') && !f.startsWith('.')).map((f) => f.slice(0, -'.json'.length));
795
+ }
796
+ catch { /* gone */ }
797
+ for (const name of new Set([...known(), ...files]))
798
+ settle(dir, name, apply);
799
+ };
800
+ attach(dir, (name) => settle(dir, name, apply), () => later(dir, 150, reopen));
801
+ return () => later(dir, 150, reopen);
758
802
  };
759
803
  const graphChanged = (name, file) => {
760
804
  if (!NAME_RE.test(name) || this.graphFile(name) !== file)
@@ -779,17 +823,8 @@ export class Session {
779
823
  this.lastReport.delete(name);
780
824
  this.bump(name);
781
825
  };
782
- on(this.graphDir, graphChanged);
783
- // a package's graph files beside its manifest, when graphs/ has no graph of that name
784
- if (topoFiles(this.dir).length)
785
- on(this.dir, (name, file) => {
786
- if (fs.existsSync(path.join(this.graphDir, name + '.json')))
787
- return;
788
- if (!this.graphs.has(name) && fs.existsSync(file))
789
- this.besidePackage.set(name, file);
790
- graphChanged(name, file);
791
- });
792
- on(this.assetDir, (name, file) => {
826
+ const graphsBack = child(this.graphDir, graphChanged, () => [...this.graphs.keys()].filter((n) => this.graphFile(n) === path.join(this.graphDir, n + '.json')));
827
+ const assetsBack = child(this.assetDir, (name, file) => {
793
828
  if (!fs.existsSync(file))
794
829
  return;
795
830
  const spec = JSON.parse(fs.readFileSync(file, 'utf8'));
@@ -801,15 +836,35 @@ export class Session {
801
836
  this.lastReport.delete(g);
802
837
  this.bump(g);
803
838
  }
839
+ }, () => []);
840
+ // the package folder: graphs/ and assets/ removed or made again, and a package's graph files beside its manifest,
841
+ // when graphs/ has no graph of that name
842
+ const beside = (name, file) => {
843
+ if (fs.existsSync(path.join(this.graphDir, name + '.json')))
844
+ return;
845
+ if (!this.graphs.has(name) && fs.existsSync(file))
846
+ this.besidePackage.set(name, file);
847
+ graphChanged(name, file);
848
+ };
849
+ const isPackage = topoFiles(this.dir).length > 0;
850
+ const top = path.basename(this.graphDir), assets = path.basename(this.assetDir);
851
+ attach(this.dir, (name) => { if (isPackage)
852
+ settle(this.dir, name, beside); }, () => { }, (rel) => {
853
+ if (rel === top)
854
+ graphsBack();
855
+ else if (rel === assets)
856
+ assetsBack();
804
857
  });
805
858
  }
806
859
  /** Stop following the folders (watch()). */
807
860
  unwatch() {
808
- for (const w of this.watchers)
861
+ this.watching = false;
862
+ const ws = [...this.watchers.values()];
863
+ this.watchers.clear();
864
+ for (const w of ws)
809
865
  w.close();
810
866
  for (const t of this.watchTimers.values())
811
867
  clearTimeout(t);
812
- this.watchers = [];
813
868
  this.watchTimers.clear();
814
869
  }
815
870
  }
@@ -11,11 +11,14 @@ async function json(url, init) {
11
11
  const j = await res.json().catch(() => ({ ok: false, error: `${res.status} ${res.statusText}` }));
12
12
  return { status: res.status, j };
13
13
  }
14
- /** A GLB route: {ok, buf} or {ok: false, error, stopped?} (stopped: the node its cook was stopped at). */
14
+ /**
15
+ * A GLB route: {ok, buf} or {ok: false, error, stopped?, preview?} (stopped: the node its cook was stopped at; preview:
16
+ * the result cooked but its GLB could not be written).
17
+ */
15
18
  async function glb(url) {
16
19
  let res;
17
20
  try { res = await fetch(url); } catch { return fail(offline); }
18
- if (!res.ok) { const j = await res.json().catch(() => ({})); return { ...fail(j.error ?? `${res.status} ${res.statusText}`), ...(j.stopped ? { stopped: j.stopped } : {}) }; }
21
+ if (!res.ok) { const j = await res.json().catch(() => ({})); return { ...fail(j.error ?? `${res.status} ${res.statusText}`), ...(j.stopped ? { stopped: j.stopped } : {}), ...(j.preview ? { preview: true } : {}) }; }
19
22
  return { ok: true, buf: await res.arrayBuffer() };
20
23
  }
21
24
  const post = (body) => ({ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
@@ -20,9 +20,11 @@ export const SHOW_AFTER = 150;
20
20
  /**
21
21
  * The line for a graph's cook state: {kind, text, title}. kind: "running", "stopping", "ok", "failed", "stopped" or
22
22
  * "none". `state`: {running: {cooks, kinds, elapsed, node, nodeElapsed, inner, stopping} | null, last: {ok, ms,
23
- * stopped?, error?: {node, message}} | null}; `since`: ms since it arrived, added to the running times.
23
+ * stopped?, error?: {node, message}} | null}; `since`: ms since it arrived, added to the running times. `preview`: why the
24
+ * cooked result could not be shown ("preview failed: …", the GLB route's or the page's), a failure the view keeps the
25
+ * last shown result through.
24
26
  */
25
- export function cookLine(state, since = 0) {
27
+ export function cookLine(state, since = 0, preview = null) {
26
28
  const r = state?.running;
27
29
  if (r && (r.elapsed + since >= SHOW_AFTER || r.stopping)) {
28
30
  const where = r.node ? `${r.node}${r.inner ? ` › ${r.inner}` : ''}` : '';
@@ -44,12 +46,16 @@ export function cookLine(state, since = 0) {
44
46
  return { kind: 'running', text: `${verb}${where ? ` ${where}` : ''} · ${total}`, title: `${node}${r.cooks > 1 ? ` (${r.cooks} cooks of this graph)` : ''}. Stop ends it at the next node; changing a value starts over with the new value.` };
45
47
  }
46
48
  const l = state?.last;
47
- if (!l) return { kind: 'none', text: '', title: '' };
49
+ // the cook ended well but its result cannot be shown: said like a failed cook (a failed or stopped one says more)
50
+ const shown = preview && !l?.stopped && l?.ok !== false
51
+ ? { kind: 'failed', text: firstLine(preview), title: `${preview} (the cook finished; the view keeps the last result it could show)` } : null;
52
+ if (!l) return shown ?? { kind: 'none', text: '', title: '' };
48
53
  if (l.stopped) return { kind: 'stopped', text: `stopped at ${l.stopped} · the view shows the last finished cook`, title: 'change a value (or save the graph file) to cook again' };
49
54
  if (!l.ok) {
50
55
  const msg = l.error?.message ?? 'failed';
51
56
  return { kind: 'failed', text: `failed at ${l.error?.node ?? 'the graph'}: ${firstLine(msg)}`, title: `${l.error?.node ?? ''}: ${msg}` };
52
57
  }
58
+ if (shown) return shown;
53
59
  return { kind: 'ok', text: `cooked in ${fmtDuration(l.ms)}`, title: `the last cook of the whole graph took ${fmtDuration(l.ms)}` };
54
60
  }
55
61
 
@@ -72,7 +72,8 @@ ctx.cookState = (graph) => cooks.get(graph)?.state ?? null;
72
72
  function setCook(graph, state) { cooks.set(graph, { state, at: performance.now() }); renderCook(); }
73
73
  function renderCook() {
74
74
  const c = cooks.get(ctx.graph?.name), compare = ctx.packages?.running;
75
- const line = compare ? compareLine(compare, performance.now() - compare.at) : cookLine(c?.state, c ? performance.now() - c.at : 0);
75
+ const pe = ctx.output?.previewError, preview = pe && pe.at === `${ctx.graph?.name}/${ctx.graph?.node ?? ''}` ? pe.message : null;
76
+ const line = compare ? compareLine(compare, performance.now() - compare.at) : cookLine(c?.state, c ? performance.now() - c.at : 0, preview);
76
77
  for (const el of cookLines) {
77
78
  el.className = `cookline ${line.kind}`;
78
79
  const t = el.querySelector('.ctext');
@@ -164,6 +165,8 @@ ctx.setHover = (id) => { if (ctx.hover === id) return; ctx.hover = id; ctx.emit(
164
165
  // the output: the node being shown, its display mode and visibility remembered
165
166
  ctx.output = {
166
167
  mesh: null, summary: '', error: null, report: null, loading: false,
168
+ /** {at: "graph/node", message: "preview failed: …"} when that node's result cooked but could not be shown */
169
+ previewError: null,
167
170
  visible: local.get('output.visible', true), display: local.get('output.display', 'view'),
168
171
  setVisible(v) { this.visible = v; local.set('output.visible', v); outEntry(); ctx.emit('output'); ctx.requestRender(); },
169
172
  setDisplay(m) { this.display = m; local.set('output.display', m); outEntry(); ctx.emit('output'); ctx.requestRender(); },
@@ -259,19 +262,30 @@ const loadGeo = ctx.coalesce(async () => {
259
262
  const r = await api.geo(graph, node, ctx.sceneLayer.get());
260
263
  o.loading = false;
261
264
  if (graph !== G.name || node !== (G.node ?? '') || ctx.outputs?.active) { ctx.emit('output'); return; }
265
+ // the result cooked but cannot be shown (its GLB was not written, or does not load here): the cook line says so and
266
+ // the view keeps the last result it showed
267
+ const previewFailed = (e) => {
268
+ const msg = String(e?.message ?? e);
269
+ o.previewError = { at: `${graph}/${node}`, message: msg.startsWith('preview failed') ? msg : `preview failed: ${msg}` };
270
+ if (e?.stack) console.error(e);
271
+ ctx.emit('output'); updateCook(); renderCook();
272
+ };
262
273
  if (!r.ok) {
263
274
  // the last good geometry stays; a stopped cook is no error (the cook line says where it stopped)
275
+ if (r.preview) return previewFailed(r.error);
264
276
  if (!r.stopped) o.error = r.error;
265
277
  ctx.emit('output'); updateCook();
266
278
  return;
267
279
  }
268
- let src;
269
- try { src = await parseGLB(r.buf); } catch (e) { o.error = String(e?.message ?? e); ctx.emit('output'); updateCook(); return; }
280
+ let src, mesh;
281
+ try { src = await parseGLB(r.buf); } catch (e) { return previewFailed(e); }
270
282
  if (graph !== G.name || node !== (G.node ?? '') || ctx.outputs?.active) { new MeshObject('', src).dispose(); return; }
283
+ try { mesh = new MeshObject('out', src); } catch (e) { return previewFailed(e); }
271
284
  const prev = o.mesh;
272
- o.mesh = new MeshObject('out', src);
285
+ o.mesh = mesh;
273
286
  o.mesh.onReady = () => { ctx.requestRender(); ctx.emit('output'); };
274
287
  o.error = null;
288
+ if (o.previewError) { o.previewError = null; renderCook(); }
275
289
  ctx.outputRoot.add(o.mesh.root);
276
290
  if (prev) prev.dispose();
277
291
  outEntry();
@@ -67,8 +67,25 @@ function outputsLine(v, most = 6) {
67
67
  const names = Object.entries(v.outputs).filter(([, o]) => !isDefaultOutput(v, o)).map(([k]) => k);
68
68
  return `${names.length} output${names.length === 1 ? '' : 's'}${names.length ? `: ${names.slice(0, most).join(', ')}${names.length > most ? ' …' : ''}` : ''}`;
69
69
  }
70
+ /** The preview GLB could not be written: the result cooked, the page cannot be shown it (500, {preview: true}). */
71
+ class PreviewError extends HttpError {
72
+ constructor(msg) { super(500, `preview failed: ${msg}`); }
73
+ }
74
+ /**
75
+ * The GLB a geometry route serves (previewGLB). Writing it fails as the preview's error, not the cook's, and the stack
76
+ * goes to the server's log (stderr) so the step that failed is named.
77
+ */
78
+ async function previewOf(g, o = {}) {
79
+ try {
80
+ return await previewGLB(g, o);
81
+ }
82
+ catch (e) {
83
+ console.error(`preview failed: ${e?.stack ?? e}`);
84
+ throw new PreviewError(String(e?.message ?? e));
85
+ }
86
+ }
70
87
  /** The shape every geometry route serves: the same GLB options as /api/geo; images alone show as textured quads. */
71
- const toGLB = (g) => previewGLB(g);
88
+ const toGLB = (g) => previewOf(g);
72
89
  const issueText = (e) => `[${e.node}] ${e.message}`;
73
90
  /**
74
91
  * A dropped file's name as stored in inputs/: a plain basename with its extension. Path separators and ".." are
@@ -748,7 +765,7 @@ export async function startViewer(ws, port = Number(process.env.TOPOTOPO_PORT ??
748
765
  if (u.pathname === '/api/info')
749
766
  return send(200, JSON.stringify({ target: r.target, summary: summarize(r.geo), ms: r.ms, about: outputKind(r.geo) }), MIME['.json']);
750
767
  // heightfields: the layer drawn in red (the page's layer picker; the mask by default)
751
- return send(200, await previewGLB(r.geo, { heightfieldLayer: u.searchParams.get('heightfield_layer') || undefined }), MIME['.glb']);
768
+ return send(200, await previewOf(r.geo, { heightfieldLayer: u.searchParams.get('heightfield_layer') || undefined }), MIME['.glb']);
752
769
  }
753
770
  send(404, 'not found');
754
771
  }
@@ -758,7 +775,7 @@ export async function startViewer(ws, port = Number(process.env.TOPOTOPO_PORT ??
758
775
  const status = e instanceof HttpError ? e.status : 500;
759
776
  const msg = String(e?.message ?? e);
760
777
  res.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store', ...(status === 413 ? { connection: 'close' } : {}) });
761
- res.end(JSON.stringify(route === '/api/vars' ? { ok: false, ms: 0, errors: [msg] } : { ok: false, error: msg }));
778
+ res.end(JSON.stringify(route === '/api/vars' ? { ok: false, ms: 0, errors: [msg] } : { ok: false, error: msg, ...(e instanceof PreviewError ? { preview: true } : {}) }));
762
779
  }
763
780
  });
764
781
  const listen = (p) => new Promise((resolve, reject) => {
@@ -3,5 +3,5 @@
3
3
  name="TopoTopo"
4
4
  description="Imports TopoTopo packages (<id>.topo): their published outputs are cooked into GLBs and PNGs that Godot imports itself, and kept current while the package changes."
5
5
  author="TopoTopo"
6
- version="0.5.1"
6
+ version="0.5.3"
7
7
  script="plugin.gd"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topotopo",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "An open-source procedural geometry engine: node graphs in JSON, cooked headless and deterministic, exported to Unreal, Blender and Houdini. Built for LLM agents through MCP, and for people through the CLI.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "mcp": "node src/mcp/server.ts",
40
40
  "preview": "node scripts/preview.ts --examples",
41
41
  "cook": "node src/cli.ts",
42
- "test": "node test/smoke.ts && node test/golden.ts && node test/property.ts && node test/fuzz.ts && node test/docs.ts && node test/portability.ts && node test/examples.ts && node scripts/gen-notice.ts --check && node test/io.ts && node test/import.ts && node test/interop.ts && node test/mcp.ts && node test/engine.ts && node test/scopes.ts && node test/packages.ts && node test/cook.ts && node test/viewer.ts && node test/viewer-logic.ts && node test/topology.ts && node test/deform.ts && node test/cloth.ts && node test/arrays.ts && node test/bugs.ts && node test/uv.ts && node test/polyedit.ts && node test/bevel.ts && node test/meshops.ts && node test/measure.ts && node test/render.ts && node test/packed.ts && node test/heightfield.ts && node test/remesh.ts && node test/pcg.ts && node test/scatterkernel.ts && node test/splines.ts && node test/builtin.ts && node test/textures.ts && node test/texnodes.ts && node test/imageops.ts && node test/pool.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts && node test/particles.ts && node test/rbd.ts && node test/limits.ts && node test/viewer-outputs.ts && node test/viewer-packages.ts && node test/library.ts && node test/web.ts && node test/tangents.ts && node test/pbr.ts && node test/materials.ts && node test/sockets.ts && node test/uvreport.ts && node test/solidify.ts",
42
+ "test": "node test/smoke.ts && node test/golden.ts && node test/property.ts && node test/fuzz.ts && node test/docs.ts && node test/portability.ts && node test/examples.ts && node scripts/gen-notice.ts --check && node test/io.ts && node test/import.ts && node test/interop.ts && node test/mcp.ts && node test/engine.ts && node test/scopes.ts && node test/packages.ts && node test/cook.ts && node test/viewer.ts && node test/session-watch.ts && node test/viewer-logic.ts && node test/topology.ts && node test/deform.ts && node test/cloth.ts && node test/arrays.ts && node test/bugs.ts && node test/uv.ts && node test/polyedit.ts && node test/bevel.ts && node test/meshops.ts && node test/measure.ts && node test/render.ts && node test/packed.ts && node test/heightfield.ts && node test/remesh.ts && node test/pcg.ts && node test/scatterkernel.ts && node test/splines.ts && node test/builtin.ts && node test/textures.ts && node test/texnodes.ts && node test/imageops.ts && node test/pool.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts && node test/particles.ts && node test/rbd.ts && node test/limits.ts && node test/viewer-outputs.ts && node test/viewer-packages.ts && node test/library.ts && node test/web.ts && node test/tangents.ts && node test/pbr.ts && node test/materials.ts && node test/sockets.ts && node test/uvreport.ts && node test/solidify.ts",
43
43
  "test:limits": "node test/limits.ts",
44
44
  "kernels:build": "node scripts/kernels-build.ts",
45
45
  "test:kernels": "node test/scatterkernel.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts",
@@ -74,7 +74,7 @@
74
74
  "test:examples": "node test/examples.ts",
75
75
  "test:interop": "node test/interop.ts",
76
76
  "test:web": "node test/library.ts && node test/web.ts",
77
- "test:viewer": "node test/viewer.ts && node test/viewer-logic.ts && node test/viewer-outputs.ts && node test/viewer-packages.ts",
77
+ "test:viewer": "node test/viewer.ts && node test/session-watch.ts && node test/viewer-logic.ts && node test/viewer-outputs.ts && node test/viewer-packages.ts",
78
78
  "showcase": "node test/showcase.ts",
79
79
  "export:demo": "node scripts/export-demo.ts",
80
80
  "demo:footage": "node scripts/demo-footage.ts",