nanoodle 0.1.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/client.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { NanoodleError } from "./errors.mjs";
2
2
  import { b64ImageMime, bytesToDataUrl, dataUrlBytes, MEDIA_INLINE_MAX } from "./media.mjs";
3
+ import { assertPaymentOption, parseNanoInvoice, looksLikeResult } from "./x402.mjs";
3
4
 
4
5
  const AUDIO_MIME = { mp3: "audio/mpeg", opus: "audio/ogg", aac: "audio/aac", flac: "audio/flac", wav: "audio/wav", pcm: "audio/wav" };
5
6
 
@@ -75,29 +76,97 @@ export function sleep(ms, signal) {
75
76
  * pollIntervals / timeouts are per-media-kind knobs (ms).
76
77
  */
77
78
  export class NanoClient {
78
- constructor({ apiKey, baseUrl = "https://nano-gpt.com", fetch = globalThis.fetch, pollIntervals = {}, timeouts = {} } = {}) {
79
+ constructor({ apiKey, baseUrl = "https://nano-gpt.com", fetch = globalThis.fetch, pollIntervals = {}, timeouts = {}, payment } = {}) {
79
80
  // non-enumerable: console.log/util.inspect/JSON.stringify of a client (or a Workflow holding
80
81
  // one) must never print the key
81
82
  Object.defineProperty(this, "apiKey", { value: apiKey, writable: true, enumerable: false, configurable: true });
83
+ assertPaymentOption(payment); // a callback or nothing — never a seed/private key
84
+ this.payment = payment || null;
82
85
  this.baseUrl = String(baseUrl).replace(/\/+$/, "");
83
86
  this.fetch = fetch;
84
- this.pollIntervals = { video: 5000, audio: 3000, ...pollIntervals };
87
+ this.pollIntervals = { video: 5000, audio: 3000, x402: 3000, ...pollIntervals };
85
88
  this.timeouts = { video: 600000, audio: 300000, ...timeouts };
86
89
  }
87
90
 
88
- _auth() { return { Authorization: "Bearer " + this.apiKey, "x-api-key": this.apiKey }; }
91
+ _auth() {
92
+ if (this.apiKey) return { Authorization: "Bearer " + this.apiKey, "x-api-key": this.apiKey };
93
+ if (this.payment) return { "x-x402": "true" }; // keyless: opt into accountless 402 invoices
94
+ return {};
95
+ }
96
+
97
+ /**
98
+ * fetch that settles HTTP 402 via the x402 flow when running keyless with a
99
+ * `payment` callback: parse the Nano invoice → callback sends XNO (its own
100
+ * wallet/signer — the library never touches funds) → poll the complete URL
101
+ * until the deposit is seen → return the replayed result, or re-send the
102
+ * original request stamped with the settled payment id. Each API call pays
103
+ * at most once; a second 402 after settling is an error, never a second send.
104
+ */
105
+ async _paidFetch(url, init, signal) {
106
+ const r = await this.fetch(url, init);
107
+ if (r.status !== 402 || !this.payment || this.apiKey) return r;
108
+ const settled = await this._settle402(r, signal);
109
+ if (settled.response) return settled.response; // complete replayed the stored request
110
+ const r2 = await this.fetch(url, { ...init, headers: { ...init.headers, "x-x402-payment-id": settled.paymentId } });
111
+ if (r2.status === 402) {
112
+ throw new NanoodleError(
113
+ "payment " + settled.paymentId + " settled, but the API still answered 402 on retry — " +
114
+ "check " + (settled.statusUrl || "the payment status") + " before paying again",
115
+ { code: "x402", status: 402, paymentId: settled.paymentId });
116
+ }
117
+ return r2;
118
+ }
119
+
120
+ async _settle402(r, signal) {
121
+ let body = null;
122
+ try { body = await r.json(); } catch { /* fall through to the generic funds error */ }
123
+ const invoice = body && parseNanoInvoice(body, this.baseUrl);
124
+ if (!invoice || !invoice.paymentId || !invoice.completeUrl) {
125
+ throw new NanoodleError(
126
+ "payment required, but the 402 response offered no usable Nano option" +
127
+ (body ? " — " + JSON.stringify(body).slice(0, 200) : ""), { code: "x402", status: 402 });
128
+ }
129
+ await this.payment(invoice); // ← the callback does the actual XNO send
130
+ // The complete endpoint doubles as the poll: 402 = not seen on-chain yet.
131
+ const deadline = invoice.expiresAt || Date.now() + 15 * 60 * 1000;
132
+ while (true) {
133
+ const cr = await this.fetch(invoice.completeUrl, {
134
+ method: "POST", headers: { "Content-Type": "application/json", "x-x402": "true" }, body: "{}", signal,
135
+ });
136
+ if (cr.ok) {
137
+ const ct = ((cr.headers && cr.headers.get && cr.headers.get("content-type")) || "");
138
+ let cj = null;
139
+ if (ct.includes("json")) { try { cj = await cr.json(); } catch { /* treat as settle-only */ } }
140
+ if (looksLikeResult(cj)) {
141
+ // wrap so call sites keep their Response contract (ok/json/text/headers)
142
+ const response = { ok: true, status: 200, headers: cr.headers, json: async () => cj, text: async () => JSON.stringify(cj) };
143
+ return { paymentId: invoice.paymentId, statusUrl: invoice.statusUrl, response };
144
+ }
145
+ return { paymentId: invoice.paymentId, statusUrl: invoice.statusUrl };
146
+ }
147
+ if (cr.status !== 402) throw httpError(cr.status, await cr.text());
148
+ await cr.text().catch(() => {}); // drain the "not verified yet" body
149
+ if (Date.now() >= deadline) {
150
+ throw new NanoodleError(
151
+ "payment window expired before the Nano deposit was detected (payment " + invoice.paymentId + ", " +
152
+ (invoice.amount || invoice.amountRaw) + " to " + invoice.payTo + ") — if you already sent it, check " +
153
+ (invoice.explorerUrl || invoice.statusUrl), { code: "x402-expired", paymentId: invoice.paymentId });
154
+ }
155
+ await sleep(this.pollIntervals.x402, signal);
156
+ }
157
+ }
89
158
 
90
159
  async _postJson(path, body, signal) {
91
160
  const payload = JSON.stringify(body);
92
161
  if (payload.length > MEDIA_INLINE_MAX) {
93
162
  throw new NanoodleError("request body is too large (~4 MB max) — nanoodle sends media inline as base64; use smaller/shorter media");
94
163
  }
95
- return this.fetch(this.baseUrl + path, {
164
+ return this._paidFetch(this.baseUrl + path, {
96
165
  method: "POST",
97
166
  headers: { "Content-Type": "application/json", ...this._auth() },
98
167
  body: payload,
99
168
  signal,
100
- });
169
+ }, signal);
101
170
  }
102
171
 
103
172
  async _get(path, signal) {
@@ -117,7 +186,9 @@ export class NanoClient {
117
186
  if (onCost) onCost(costWithHeaders(j, r));
118
187
  const msg = (j.choices && j.choices[0] && j.choices[0].message) || {};
119
188
  const txt = msg.content;
120
- if (txt == null || txt === "") throw new NanoodleError("no text in response");
189
+ // empty-string content is a billed-but-empty reply, not a protocol failure — return it
190
+ // (showThinking can still surface msg.reasoning), matching the editor/play built-in parsers
191
+ if (txt == null) throw new NanoodleError("no text in response");
121
192
  let out = typeof txt === "string" ? txt : txt.map((p) => p.text || "").join("");
122
193
  if (opts.showThinking && msg.reasoning) {
123
194
  out = "```thinking\n" + msg.reasoning + "\n```\n\n" + out;
@@ -164,11 +235,19 @@ export class NanoClient {
164
235
  }
165
236
 
166
237
  /** POST /api/generate-video then poll GET /api/video/status?requestId= until COMPLETED. */
167
- async video(model, prompt, opts = {}, imageDataUrl, { onCost, onPoll, signal } = {}) {
238
+ // io.onRunId(runId) fires the moment a FRESH submit returns its job id — a caller
239
+ // keeping a resume registry (play's PENDING_VIDEO) records it before any await.
240
+ // io.resume (a runId) skips the submit — and its charge — and goes straight to
241
+ // polling: how a timed-out job is picked back up without paying twice.
242
+ async video(model, prompt, opts = {}, imageDataUrl, { onCost, onPoll, onRunId, resume, signal } = {}) {
168
243
  const body = { model, prompt };
169
244
  if (opts.duration) body.duration = opts.duration;
170
245
  if (opts.aspect_ratio) body.aspect_ratio = opts.aspect_ratio;
171
246
  if (opts.resolution) body.resolution = opts.resolution;
247
+ // catalog-declared wire names (videoDims with an opt-in catalog): Sora-style seconds/orientation
248
+ if (opts.seconds) body.seconds = opts.seconds;
249
+ if (opts.orientation) body.orientation = opts.orientation;
250
+ if (opts.resolution_ratio) body.resolution_ratio = opts.resolution_ratio;
172
251
  if (imageDataUrl) body.imageDataUrl = imageDataUrl;
173
252
  if (opts.last_image) body.last_image = opts.last_image;
174
253
  if (opts.videoUrl) body.videoUrl = opts.videoUrl;
@@ -181,13 +260,20 @@ export class NanoClient {
181
260
  if (opts.duration) body.duration = opts.duration;
182
261
  if (opts.aspect_ratio) body.aspect_ratio = opts.aspect_ratio;
183
262
  if (opts.resolution) body.resolution = opts.resolution;
263
+ if (opts.seconds) body.seconds = opts.seconds;
264
+ if (opts.orientation) body.orientation = opts.orientation;
265
+ if (opts.resolution_ratio) body.resolution_ratio = opts.resolution_ratio;
184
266
  if (opts.refImages && opts.refImages.length) body[opts.refKey || "reference_images"] = opts.refImages; // wired refs win last
185
- const r = await this._postJson("/api/generate-video", body, signal);
186
- if (!r.ok) throw httpError(r.status, await r.text());
187
- const j = await r.json();
188
- if (onCost) onCost(costWithHeaders(j, r));
189
- const runId = j.runId || j.id;
190
- if (!runId) throw new NanoodleError("no runId returned");
267
+ let runId = resume || null;
268
+ if (!runId) {
269
+ const r = await this._postJson("/api/generate-video", body, signal);
270
+ if (!r.ok) throw httpError(r.status, await r.text());
271
+ const j = await r.json();
272
+ if (onCost) onCost(costWithHeaders(j, r));
273
+ runId = j.runId || j.id;
274
+ if (!runId) throw new NanoodleError("no runId returned");
275
+ if (onRunId) onRunId(runId);
276
+ }
191
277
 
192
278
  const t0 = Date.now();
193
279
  while (Date.now() - t0 < this.timeouts.video) {
@@ -214,8 +300,18 @@ export class NanoClient {
214
300
  throw new NanoodleError(`video timed out (${Math.round(this.timeouts.video / 1000)}s) — the job may still be running on NanoGPT's side`, { code: "timeout" });
215
301
  }
216
302
 
217
- /** POST /api/v1/audio/speech (music + tts + remix). Returns an audio URL (https or data:). */
218
- async audio(model, input, extra = {}, { onCost, onPoll, signal } = {}) {
303
+ /**
304
+ * POST /api/v1/audio/speech (music + tts + remix). Returns an audio URL (https or data:).
305
+ * io.onRunId(job) fires when an async job enters the poll branch (job = the submit
306
+ * response — runId + refund metadata the status poll needs); io.resume (that same job
307
+ * object) skips the submit + charge and resumes polling a prior run's job.
308
+ */
309
+ async audio(model, input, extra = {}, { onCost, onPoll, onRunId, resume, signal } = {}) {
310
+ if (resume) {
311
+ const url = await this._pollAudio(model, resume, { onPoll, signal });
312
+ if (!url) throw new NanoodleError("no audio url in response");
313
+ return url;
314
+ }
219
315
  const body = Object.assign({ model, input }, extra);
220
316
  const r = await this._postJson("/api/v1/audio/speech", body, signal);
221
317
  if (!r.ok) throw httpError(r.status, await r.text());
@@ -224,7 +320,10 @@ export class NanoClient {
224
320
  const j = await r.json();
225
321
  if (onCost) onCost(costWithHeaders(j, r));
226
322
  let url = j.url || j.audioUrl || (j.data && j.data.url) || (j.data && j.data.audioUrl);
227
- if (!url && (j.runId || j.id)) url = await this._pollAudio(model, j, { onPoll, signal });
323
+ if (!url && (j.runId || j.id)) {
324
+ if (onRunId) onRunId(j);
325
+ url = await this._pollAudio(model, j, { onPoll, signal });
326
+ }
228
327
  if (!url) throw new NanoodleError("no audio url in response");
229
328
  return url;
230
329
  }
@@ -288,7 +387,7 @@ export class NanoClient {
288
387
  fd.append("model", model);
289
388
  if (language) fd.append("language", language);
290
389
  // no explicit Content-Type — fetch sets the multipart boundary
291
- const r = await this.fetch(this.baseUrl + "/api/v1/audio/transcriptions", { method: "POST", headers: this._auth(), body: fd, signal });
390
+ const r = await this._paidFetch(this.baseUrl + "/api/v1/audio/transcriptions", { method: "POST", headers: this._auth(), body: fd, signal }, signal);
292
391
  if (!r.ok) throw httpError(r.status, await r.text());
293
392
  const j = await r.json();
294
393
  if (onCost) onCost(costWithHeaders(j, r));
package/src/graph.mjs CHANGED
@@ -9,13 +9,31 @@ export const VID_PORT_RE = /^vid\d+$/;
9
9
  export const CLIP_PORT_RE = /^clip\d+$/; // combine clips
10
10
  export const REF_PORT_RE = /^ref\d+$/; // tvideo reference images
11
11
  export const FRAME_PORT_RE = /^frame\d+$/; // vframes outputs
12
+ export const MAX_FRAMES = 12;
12
13
 
13
14
  const DYNAMIC_INPUT_RES = [IMG_PORT_RE, EDIT_IMG_RE, VID_PORT_RE, CLIP_PORT_RE, REF_PORT_RE];
14
15
  const DYNAMIC_INPUT_NAMES = new Set(["audio", "endframe"]);
15
16
 
17
+ /**
18
+ * Highest frameN port wired OUT of a vframes node. fields.frames is shape-affecting:
19
+ * run() emits frame1..frameN and downstream links read fixed frameK ports. A count below
20
+ * the highest wired port starves consumers mid-run (after upstream paid steps). Mirrors
21
+ * play.html wiredFramesFloor — floor is raised at run and in deriveSettings.
22
+ */
23
+ export function wiredFramesFloor(graph, nodeId) {
24
+ let floor = 1;
25
+ for (const l of (graph && graph.links) || []) {
26
+ if (l.from.node !== nodeId) continue;
27
+ const m = /^frame(\d+)$/.exec(String(l.from.port));
28
+ if (m) floor = Math.max(floor, parseInt(m[1], 10) || 1);
29
+ }
30
+ return Math.min(floor, MAX_FRAMES);
31
+ }
32
+
16
33
  /**
17
34
  * Node-type registry (execution-relevant subset of the app's NODE_TYPES).
18
- * flags: local (pure logic) | network (calls NanoGPT) | unsupported (browser-only media op) | note.
35
+ * flags: local (pure logic / on-device media) | network (calls NanoGPT) | note.
36
+ * Local media: pure-JS first (MP4CAT / PCM-WAV / PNG); ffmpeg on PATH is the heavy fallback.
19
37
  */
20
38
  export const NODE_TYPES = {
21
39
  text: { title: "Text", inputs: [], outputs: [{ name: "text", type: "text" }], local: true },
@@ -29,20 +47,20 @@ export const NODE_TYPES = {
29
47
  draw: { title: "Draw", inputs: [], outputs: [{ name: "image", type: "image" }, { name: "text", type: "text" }], network: true },
30
48
  edit: { title: "Edit", inputs: [], outputs: [{ name: "image", type: "image" }], network: true },
31
49
  inpaint: { title: "Inpaint", inputs: ["image", "mask"], outputs: [{ name: "image", type: "image" }], network: true },
32
- resize: { title: "Resize / crop", inputs: ["image"], outputs: [{ name: "image", type: "image" }], unsupported: true },
50
+ resize: { title: "Resize / crop", inputs: ["image"], outputs: [{ name: "image", type: "image" }], local: true },
33
51
  vision: { title: "Vision", inputs: ["image"], outputs: [{ name: "text", type: "text" }], network: true },
34
52
  tvideo: { title: "Text→Video", inputs: [], outputs: [{ name: "video", type: "video" }], network: true },
35
53
  ivideo: { title: "Image→Video", inputs: ["image"], outputs: [{ name: "video", type: "video" }], network: true },
36
54
  vedit: { title: "Video edit", inputs: ["video"], outputs: [{ name: "video", type: "video" }], network: true },
37
- vframes: { title: "Video → frames", inputs: ["video"], outputs: [{ name: "frame1", type: "image" }], unsupported: true },
38
- combine: { title: "Combine videos", inputs: [], outputs: [{ name: "video", type: "video" }], unsupported: true },
39
- soundtrack: { title: "Soundtrack", inputs: ["video", "audio"], outputs: [{ name: "video", type: "video" }], unsupported: true },
55
+ vframes: { title: "Video → frames", inputs: ["video"], outputs: [{ name: "frame1", type: "image" }], local: true, framesOut: true }, // dynamic frame1..N
56
+ combine: { title: "Combine videos", inputs: [], outputs: [{ name: "video", type: "video" }], local: true },
57
+ soundtrack: { title: "Soundtrack", inputs: ["video", "audio"], outputs: [{ name: "video", type: "video" }], local: true },
40
58
  lipsync: { title: "Avatar / lipsync", inputs: ["image", "audio"], outputs: [{ name: "video", type: "video" }], network: true },
41
59
  music: { title: "Music", inputs: [], outputs: [{ name: "audio", type: "audio" }], network: true },
42
60
  remix: { title: "Remix audio", inputs: ["audio"], outputs: [{ name: "audio", type: "audio" }], network: true },
43
61
  tts: { title: "Speech", inputs: [], outputs: [{ name: "audio", type: "audio" }], network: true },
44
- trim: { title: "Trim audio", inputs: ["audio"], outputs: [{ name: "audio", type: "audio" }], unsupported: true },
45
- extractaudio: { title: "Extract audio", inputs: ["video"], outputs: [{ name: "audio", type: "audio" }], unsupported: true },
62
+ trim: { title: "Trim audio", inputs: ["audio"], outputs: [{ name: "audio", type: "audio" }], local: true },
63
+ extractaudio: { title: "Extract audio", inputs: ["video"], outputs: [{ name: "audio", type: "audio" }], local: true },
46
64
  transcribe: { title: "Transcribe", inputs: ["audio"], outputs: [{ name: "text", type: "text" }], network: true },
47
65
  comment: { title: "Comment", inputs: [], outputs: [], note: true, local: true },
48
66
  };
@@ -84,8 +102,6 @@ export function materialize(data) {
84
102
  if (!NODE_TYPES[type]) {
85
103
  n.unknown = true;
86
104
  warnings.push(`unknown node type "${raw.type}" (node ${n.id}) — kept, but running this workflow will fail; you may need a newer nanoodle library`);
87
- } else if (NODE_TYPES[type].unsupported) {
88
- warnings.push(`node "${displayName(n)}" (${n.id}) has type '${type}', which does local media processing this library can't run — run() will refuse`);
89
105
  }
90
106
  nodes.push(n);
91
107
  }
package/src/index.mjs CHANGED
@@ -1,6 +1,12 @@
1
1
  export { Workflow, RunResult } from "./workflow.mjs";
2
2
  export { NanoodleError, UnsupportedNodeError, RunError } from "./errors.mjs";
3
- export { MediaRef, mediaFromFile, MEDIA_INLINE_MAX } from "./media.mjs";
3
+ export {
4
+ MediaRef, mediaFromFile, MEDIA_INLINE_MAX, coerceMediaInput, assertInlineMediaSize,
5
+ bytesToDataUrl, dataUrlBytes, bytesToBase64, base64ToBytes, sniffMime, b64ImageMime, extForMime,
6
+ } from "./media.mjs";
4
7
  export { NanoClient } from "./client.mjs";
5
- export { NODE_TYPES, displayName, materialize, topoSort } from "./graph.mjs";
8
+ export { NODE_TYPES, displayName, materialize, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
6
9
  export { deriveInputs, deriveOutputs, deriveSettings, INPUT_SPECS, SETTING_SPECS } from "./io.mjs";
10
+ export { decodeShareUrl, decodeShareFragment, isShareRef } from "./share.mjs";
11
+ export { parseNanoInvoice } from "./x402.mjs";
12
+ export { qrTerminal, qrModules } from "./qr.mjs";
package/src/io.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NanoodleError } from "./errors.mjs";
2
- import { NODE_TYPES, displayName, topoSort } from "./graph.mjs";
2
+ import { NODE_TYPES, displayName, topoSort, wiredFramesFloor, MAX_FRAMES } from "./graph.mjs";
3
3
 
4
4
  /* ============================== INPUTS ============================== */
5
5
 
@@ -152,7 +152,16 @@ export function deriveOutputs(graph) {
152
152
  const count = (used.get(lower) || 0) + 1;
153
153
  used.set(lower, count);
154
154
  if (count > 1) key = key + " " + count;
155
- return { key, nodeId: n.id, type: n.type, ports: NODE_TYPES[n.type].outputs.map((p) => ({ ...p })) };
155
+ const t = NODE_TYPES[n.type];
156
+ let ports = t.outputs.map((p) => ({ ...p }));
157
+ // vframes grows frame1..frameN from max(fields.frames, wired floor) (mirrors browser)
158
+ if (n.type === "vframes") {
159
+ const authored = Math.max(1, Math.min(MAX_FRAMES, parseInt(n.fields && n.fields.frames, 10) || 1));
160
+ const count = Math.max(authored, wiredFramesFloor(graph, n.id));
161
+ ports = [];
162
+ for (let i = 1; i <= count; i++) ports.push({ name: "frame" + i, type: "image" });
163
+ }
164
+ return { key, nodeId: n.id, type: n.type, ports };
156
165
  });
157
166
  }
158
167
 
@@ -244,6 +253,31 @@ export const SETTING_SPECS = {
244
253
  { f: "size", label: "Image size", kind: "select", options: SIZES, def: "1024x1024" },
245
254
  { f: "seed", label: "Seed", kind: "number" },
246
255
  ],
256
+ // local media knobs (play.html SETTING_SPECS) — shape-affecting fields for vframes/combine
257
+ resize: [
258
+ { f: "mode", label: "Mode", kind: "select", options: ["fit", "fill", "exact"], def: "fit" },
259
+ { f: "width", label: "Width", kind: "number" },
260
+ { f: "height", label: "Height", kind: "number" },
261
+ ],
262
+ vframes: [
263
+ { f: "dir", label: "Start from", kind: "select", options: ["end", "start"], def: "end" },
264
+ { f: "frames", label: "Frames", kind: "number", def: "1", min: 1, max: 12 },
265
+ { f: "gap", label: "Gap (s)", kind: "number", def: "0.5" },
266
+ ],
267
+ combine: [
268
+ { f: "dedup", label: "Trim duplicate seam frame", kind: "boolean", def: true },
269
+ ],
270
+ soundtrack: [
271
+ { f: "loop", label: "Loop audio to fill video", kind: "boolean", def: false },
272
+ ],
273
+ trim: [
274
+ { f: "start", label: "Start (s)", kind: "number", def: "0" },
275
+ { f: "length", label: "Length (s)", kind: "number", def: "30" },
276
+ ],
277
+ extractaudio: [
278
+ { f: "start", label: "Start (s)", kind: "number", def: "0" },
279
+ { f: "length", label: "Length (s)", kind: "number" },
280
+ ],
247
281
  };
248
282
 
249
283
  /**
@@ -259,10 +293,16 @@ export function deriveSettings(graph) {
259
293
  for (const s of specs) {
260
294
  if (graph.links.some((l) => l.to.node === n.id && l.to.port === s.f)) continue; // wired knob is decided upstream
261
295
  const cur = n.fields[s.f];
296
+ // vframes frames is shape-affecting — never offer a floor below the highest wired frameK
297
+ const min = (n.type === "vframes" && s.f === "frames")
298
+ ? Math.max(s.min || 1, wiredFramesFloor(graph, n.id))
299
+ : s.min;
262
300
  out.push({
263
301
  key: `${n.id}.${s.f}`, nodeId: n.id, field: s.f, kind: s.kind, label: s.label,
264
302
  def: cur != null && String(cur) !== "" ? cur : s.def,
265
303
  ...(s.options ? { options: [...s.options] } : {}),
304
+ ...(min != null ? { min } : {}),
305
+ ...(s.max != null ? { max: s.max } : {}),
266
306
  title: displayName(n),
267
307
  });
268
308
  }