@nodish/core 0.1.3 → 0.2.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/dist/index.d.ts +519 -0
- package/dist/{vue.js → index.js} +76 -174
- package/package.json +9 -12
- package/dist/pack.d.ts +0 -326
- package/dist/pack.js +0 -43
- package/dist/src/components/AddNodePanel.vue.d.ts +0 -20
- package/dist/src/components/GraphInterfacePanel.vue.d.ts +0 -13
- package/dist/src/components/GraphNode.vue.d.ts +0 -26
- package/dist/src/components/GroupPanel.vue.d.ts +0 -13
- package/dist/src/components/InspectorPanel.vue.d.ts +0 -43
- package/dist/src/components/NodePanel.vue.d.ts +0 -18
- package/dist/src/components/NodePort.vue.d.ts +0 -21
- package/dist/src/components/NodeViewer.vue.d.ts +0 -14
- package/dist/src/components/WireLayer.vue.d.ts +0 -8
- package/dist/src/components/inspector/InspectorCheckboxField.vue.d.ts +0 -10
- package/dist/src/components/inspector/InspectorColorField.vue.d.ts +0 -12
- package/dist/src/components/inspector/InspectorError.vue.d.ts +0 -5
- package/dist/src/components/inspector/InspectorPositionField.vue.d.ts +0 -12
- package/dist/src/components/inspector/InspectorSection.vue.d.ts +0 -24
- package/dist/src/components/inspector/InspectorWidthField.vue.d.ts +0 -12
- package/dist/src/components/layout.d.ts +0 -26
- package/dist/src/components/types/NumberWidget.vue.d.ts +0 -15
- package/dist/src/components/types/PortValueWidget.vue.d.ts +0 -17
- package/dist/src/components/types/ReadonlyWidget.vue.d.ts +0 -9
- package/dist/src/components/types/TextWidget.vue.d.ts +0 -15
- package/dist/src/components/types/registerDefaultTypeWidgets.d.ts +0 -6
- package/dist/src/components/types/registry.d.ts +0 -13
- package/dist/src/pack/index.d.ts +0 -5
- package/dist/src/store/composite/editContext.d.ts +0 -14
- package/dist/src/store/composite/guards.d.ts +0 -7
- package/dist/src/store/composite/index.d.ts +0 -12
- package/dist/src/store/graph/connect.d.ts +0 -8
- package/dist/src/store/graph/createNodeMap.d.ts +0 -22
- package/dist/src/store/graph/document.d.ts +0 -25
- package/dist/src/store/graph/dynamicPorts.d.ts +0 -9
- package/dist/src/store/graph/evaluate.d.ts +0 -18
- package/dist/src/store/graph/expandIO.d.ts +0 -2
- package/dist/src/store/graph/instance.d.ts +0 -7
- package/dist/src/store/graph/pruneConnections.d.ts +0 -2
- package/dist/src/store/graph/removeNode.d.ts +0 -3
- package/dist/src/store/graph/stacking.d.ts +0 -5
- package/dist/src/store/graph/validateGraphTypes.d.ts +0 -2
- package/dist/src/store/interface/editor.d.ts +0 -5
- package/dist/src/store/interface/graphInterface.d.ts +0 -20
- package/dist/src/store/model.d.ts +0 -241
- package/dist/src/store/nodes/index.d.ts +0 -2
- package/dist/src/store/nodes/io.d.ts +0 -46
- package/dist/src/store/nodes/math.d.ts +0 -4
- package/dist/src/store/packs/core.d.ts +0 -3
- package/dist/src/store/packs/installPack.d.ts +0 -4
- package/dist/src/store/registry/defineNode.d.ts +0 -50
- package/dist/src/store/registry/defineType.d.ts +0 -31
- package/dist/src/store/registry/groups.d.ts +0 -9
- package/dist/src/store/registry/index.d.ts +0 -39
- package/dist/src/store/types/effectiveWidget.d.ts +0 -4
- package/dist/src/store/types/index.d.ts +0 -4
- package/dist/src/store/utils/clonePlain.d.ts +0 -1
- package/dist/src/vue/attachLoadPack.d.ts +0 -2
- package/dist/src/vue/createNodeMap.d.ts +0 -11
- package/dist/src/vue/index.d.ts +0 -10
- /package/dist/{vue.css → index.css} +0 -0
package/dist/{vue.js → index.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, nextTick as c, normalizeClass as l, normalizeStyle as u, onMounted as d, onUnmounted as f, openBlock as p, ref as m, renderList as h, renderSlot as g, resolveDynamicComponent as _, toDisplayString as v, unref as y, useCssVars as b, vModelText as x, watch as ee, withCtx as S, withDirectives as C, withModifiers as w } from "vue";
|
|
2
|
-
import './
|
|
2
|
+
import './index.css';//#region src/store/graph/pruneConnections.ts
|
|
3
3
|
function T(e, t) {
|
|
4
4
|
e.graph.connections = e.graph.connections.filter((e) => !(e.from.node === t.id && !t.outputs[e.from.port] || e.to.node === t.id && !t.inputs[e.to.port]));
|
|
5
5
|
}
|
|
@@ -63,17 +63,8 @@ function j(e) {
|
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/store/model.ts
|
|
65
65
|
var M = {
|
|
66
|
-
parameters: {
|
|
67
|
-
|
|
68
|
-
type: "number",
|
|
69
|
-
defaultValue: 0
|
|
70
|
-
},
|
|
71
|
-
b: {
|
|
72
|
-
type: "number",
|
|
73
|
-
defaultValue: 0
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
returns: { result: { type: "number" } }
|
|
66
|
+
parameters: {},
|
|
67
|
+
returns: {}
|
|
77
68
|
};
|
|
78
69
|
//#endregion
|
|
79
70
|
//#region src/store/registry/defineNode.ts
|
|
@@ -2247,139 +2238,8 @@ function In() {
|
|
|
2247
2238
|
Je("number", Q), Je("string", $);
|
|
2248
2239
|
}
|
|
2249
2240
|
//#endregion
|
|
2250
|
-
//#region src/store/nodes/math.ts
|
|
2251
|
-
var Ln = {
|
|
2252
|
-
typeId: "math/add",
|
|
2253
|
-
displayName: "Add",
|
|
2254
|
-
color: "#4a7a4a",
|
|
2255
|
-
description: "Add two numbers",
|
|
2256
|
-
group: ["math", "basic operations"],
|
|
2257
|
-
inputs: {
|
|
2258
|
-
a: {
|
|
2259
|
-
type: "number",
|
|
2260
|
-
defaultValue: 0
|
|
2261
|
-
},
|
|
2262
|
-
b: {
|
|
2263
|
-
type: "number",
|
|
2264
|
-
defaultValue: 0
|
|
2265
|
-
}
|
|
2266
|
-
},
|
|
2267
|
-
outputs: { sum: { type: "number" } },
|
|
2268
|
-
execute: (e) => ({ sum: Number(e.a ?? 0) + Number(e.b ?? 0) })
|
|
2269
|
-
}, Rn = {
|
|
2270
|
-
typeId: "math/multiply",
|
|
2271
|
-
displayName: "Multiply",
|
|
2272
|
-
color: "#4a7a4a",
|
|
2273
|
-
description: "Multiply two numbers",
|
|
2274
|
-
group: ["math", "basic operations"],
|
|
2275
|
-
inputs: {
|
|
2276
|
-
a: {
|
|
2277
|
-
type: "number",
|
|
2278
|
-
defaultValue: 0
|
|
2279
|
-
},
|
|
2280
|
-
b: {
|
|
2281
|
-
type: "number",
|
|
2282
|
-
defaultValue: 0
|
|
2283
|
-
}
|
|
2284
|
-
},
|
|
2285
|
-
outputs: { product: { type: "number" } },
|
|
2286
|
-
execute: (e) => ({ product: Number(e.a ?? 0) * Number(e.b ?? 0) })
|
|
2287
|
-
}, zn = {
|
|
2288
|
-
typeId: "math/divide",
|
|
2289
|
-
displayName: "Divide",
|
|
2290
|
-
color: "#4a7a4a",
|
|
2291
|
-
description: "Divide two numbers",
|
|
2292
|
-
group: ["math", "basic operations"],
|
|
2293
|
-
inputs: {
|
|
2294
|
-
a: {
|
|
2295
|
-
type: "number",
|
|
2296
|
-
defaultValue: 0
|
|
2297
|
-
},
|
|
2298
|
-
b: {
|
|
2299
|
-
type: "number",
|
|
2300
|
-
defaultValue: 1
|
|
2301
|
-
}
|
|
2302
|
-
},
|
|
2303
|
-
outputs: { quotient: { type: "number" } },
|
|
2304
|
-
execute: (e) => {
|
|
2305
|
-
let t = Number(e.a ?? 0), n = Number(e.b ?? 1);
|
|
2306
|
-
if (n === 0) throw Error("Division by zero");
|
|
2307
|
-
return { quotient: t / n };
|
|
2308
|
-
}
|
|
2309
|
-
}, Bn = {
|
|
2310
|
-
[Ln.typeId]: Ln,
|
|
2311
|
-
[Rn.typeId]: Rn,
|
|
2312
|
-
[zn.typeId]: zn
|
|
2313
|
-
};
|
|
2314
|
-
//#endregion
|
|
2315
|
-
//#region src/store/registry/defineType.ts
|
|
2316
|
-
function Vn(e) {
|
|
2317
|
-
let t = e.widget, n = Wn(t);
|
|
2318
|
-
return {
|
|
2319
|
-
id: e.id,
|
|
2320
|
-
label: e.label ?? Hn(e.id),
|
|
2321
|
-
color: e.color ?? "#888",
|
|
2322
|
-
validate: e.validate,
|
|
2323
|
-
accepts: e.accepts,
|
|
2324
|
-
defaultValue: e.defaultValue,
|
|
2325
|
-
widget: t,
|
|
2326
|
-
parse: e.parse ?? n.parse,
|
|
2327
|
-
format: e.format ?? n.format,
|
|
2328
|
-
coerce: e.coerce ?? n.coerce
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
function Hn(e) {
|
|
2332
|
-
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
2333
|
-
}
|
|
2334
|
-
function Un(e, t, n) {
|
|
2335
|
-
let r = Number(e);
|
|
2336
|
-
return Number.isNaN(r) && (r = 0), t !== void 0 && (r = Math.max(t, r)), n !== void 0 && (r = Math.min(n, r)), r;
|
|
2337
|
-
}
|
|
2338
|
-
function Wn(e) {
|
|
2339
|
-
if (!e) return {
|
|
2340
|
-
parse: (e) => e,
|
|
2341
|
-
format: (e) => e == null ? "" : String(e)
|
|
2342
|
-
};
|
|
2343
|
-
switch (e.kind) {
|
|
2344
|
-
case "number": return {
|
|
2345
|
-
parse: (e) => Number(e),
|
|
2346
|
-
format: (e) => e == null ? "" : String(e),
|
|
2347
|
-
coerce: (t) => Un(t, e.min, e.max)
|
|
2348
|
-
};
|
|
2349
|
-
case "text": return {
|
|
2350
|
-
parse: (e) => e,
|
|
2351
|
-
format: (e) => e == null ? "" : String(e)
|
|
2352
|
-
};
|
|
2353
|
-
case "custom": return { format: (e) => e == null ? "" : String(e) };
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
//#endregion
|
|
2357
|
-
//#region src/store/types/index.ts
|
|
2358
|
-
var Gn = Vn({
|
|
2359
|
-
id: "number",
|
|
2360
|
-
label: "Number",
|
|
2361
|
-
color: "#7dd3fc",
|
|
2362
|
-
validate: (e) => typeof e == "number" && !Number.isNaN(e),
|
|
2363
|
-
defaultValue: 0,
|
|
2364
|
-
widget: { kind: "number" }
|
|
2365
|
-
}), Kn = Vn({
|
|
2366
|
-
id: "string",
|
|
2367
|
-
label: "String",
|
|
2368
|
-
color: "#c4b5fd",
|
|
2369
|
-
validate: (e) => typeof e == "string",
|
|
2370
|
-
defaultValue: "",
|
|
2371
|
-
widget: { kind: "text" }
|
|
2372
|
-
}), qn = {
|
|
2373
|
-
id: "@local/core",
|
|
2374
|
-
types: {
|
|
2375
|
-
[Gn.id]: Gn,
|
|
2376
|
-
[Kn.id]: Kn
|
|
2377
|
-
},
|
|
2378
|
-
nodeTypes: Bn
|
|
2379
|
-
};
|
|
2380
|
-
//#endregion
|
|
2381
2241
|
//#region src/store/graph/createNodeMap.ts
|
|
2382
|
-
function
|
|
2242
|
+
function Ln(e = {}) {
|
|
2383
2243
|
let t = {
|
|
2384
2244
|
graph: e.graph ?? {
|
|
2385
2245
|
nodes: [],
|
|
@@ -2395,7 +2255,7 @@ function Jn(e = {}) {
|
|
|
2395
2255
|
}
|
|
2396
2256
|
//#endregion
|
|
2397
2257
|
//#region src/store/packs/installPack.ts
|
|
2398
|
-
function
|
|
2258
|
+
function Rn(e, t, n) {
|
|
2399
2259
|
if (e.extensions.includes(t.id)) return [];
|
|
2400
2260
|
let r = [];
|
|
2401
2261
|
if (t.types) for (let n of Object.keys(t.types)) e.types[n] && r.push(`type "${n}" already registered by another pack`);
|
|
@@ -2404,53 +2264,53 @@ function Yn(e, t, n) {
|
|
|
2404
2264
|
}
|
|
2405
2265
|
//#endregion
|
|
2406
2266
|
//#region src/vue/attachLoadPack.ts
|
|
2407
|
-
function
|
|
2267
|
+
function zn() {
|
|
2408
2268
|
return {
|
|
2409
2269
|
registerTypeWidget: Je,
|
|
2410
2270
|
registerComponentWidget: Ye
|
|
2411
2271
|
};
|
|
2412
2272
|
}
|
|
2413
|
-
function
|
|
2414
|
-
e.loadPack = (t) =>
|
|
2273
|
+
function Bn(e) {
|
|
2274
|
+
e.loadPack = (t) => Rn(e, t, zn());
|
|
2415
2275
|
}
|
|
2416
2276
|
//#endregion
|
|
2417
2277
|
//#region src/vue/createNodeMap.ts
|
|
2418
|
-
var
|
|
2419
|
-
function
|
|
2420
|
-
|
|
2421
|
-
let t =
|
|
2422
|
-
|
|
2278
|
+
var Vn = !1;
|
|
2279
|
+
function Hn(e = {}) {
|
|
2280
|
+
Vn ||= (In(), !0);
|
|
2281
|
+
let t = Ln(e);
|
|
2282
|
+
Bn(t);
|
|
2423
2283
|
for (let n of e.packs ?? []) t.loadPack(n);
|
|
2424
2284
|
return t;
|
|
2425
2285
|
}
|
|
2426
2286
|
//#endregion
|
|
2427
2287
|
//#region src/store/graph/validateGraphTypes.ts
|
|
2428
|
-
function
|
|
2288
|
+
function Un(e, t, n, r, i) {
|
|
2429
2289
|
e.types[n.type] || i.push(`node "${t.label ?? t.typeId}" (${t.id}): unknown ${r} port type "${n.type}" on port "${n.name}"`);
|
|
2430
2290
|
}
|
|
2431
|
-
function
|
|
2291
|
+
function Wn(e, t, n) {
|
|
2432
2292
|
e.nodeTypes[t.typeId] || n.push(`node "${t.label ?? t.id}": unknown typeId "${t.typeId}"`);
|
|
2433
|
-
for (let r of Object.values(t.inputs))
|
|
2434
|
-
for (let r of Object.values(t.outputs))
|
|
2435
|
-
t.composite?.graph &&
|
|
2293
|
+
for (let r of Object.values(t.inputs)) Un(e, t, r, "input", n);
|
|
2294
|
+
for (let r of Object.values(t.outputs)) Un(e, t, r, "output", n);
|
|
2295
|
+
t.composite?.graph && Gn(e, t.composite.graph, n);
|
|
2436
2296
|
}
|
|
2437
|
-
function
|
|
2438
|
-
for (let r of t.nodes)
|
|
2297
|
+
function Gn(e, t, n = []) {
|
|
2298
|
+
for (let r of t.nodes) Wn(e, r, n);
|
|
2439
2299
|
return n;
|
|
2440
2300
|
}
|
|
2441
2301
|
//#endregion
|
|
2442
2302
|
//#region src/store/graph/document.ts
|
|
2443
|
-
function
|
|
2303
|
+
function Kn(e) {
|
|
2444
2304
|
return {
|
|
2445
2305
|
graph: z(e.graph),
|
|
2446
2306
|
interface: z(e.graphInterface),
|
|
2447
2307
|
extensions: e.extensions.length ? [...e.extensions] : void 0
|
|
2448
2308
|
};
|
|
2449
2309
|
}
|
|
2450
|
-
function
|
|
2451
|
-
return
|
|
2310
|
+
function qn(e) {
|
|
2311
|
+
return Kn(e);
|
|
2452
2312
|
}
|
|
2453
|
-
function
|
|
2313
|
+
function Jn(e) {
|
|
2454
2314
|
let t;
|
|
2455
2315
|
try {
|
|
2456
2316
|
t = JSON.parse(e);
|
|
@@ -2466,22 +2326,64 @@ function ar(e) {
|
|
|
2466
2326
|
if (n.extensions !== void 0 && (!Array.isArray(n.extensions) || n.extensions.some((e) => typeof e != "string"))) throw Error("extensions must be an array of strings");
|
|
2467
2327
|
return n;
|
|
2468
2328
|
}
|
|
2469
|
-
function
|
|
2329
|
+
function Yn(e, t) {
|
|
2470
2330
|
return t?.length ? t.filter((t) => !e.extensions.includes(t)).map((e) => `missing pack "${e}" (call map.loadPack() before import)`) : [];
|
|
2471
2331
|
}
|
|
2472
|
-
function
|
|
2332
|
+
function Xn(e, t) {
|
|
2473
2333
|
let n = [];
|
|
2474
|
-
return n.push(...
|
|
2334
|
+
return n.push(...Yn(e, t.extensions)), n.push(...se({
|
|
2475
2335
|
...e,
|
|
2476
2336
|
graph: t.graph
|
|
2477
|
-
})), n.push(...B(e, t.interface)), n.push(...
|
|
2337
|
+
})), n.push(...B(e, t.interface)), n.push(...Gn(e, t.graph)), n;
|
|
2478
2338
|
}
|
|
2479
|
-
function
|
|
2480
|
-
let n =
|
|
2481
|
-
return n.length ? n : (e.graph = z(t.graph), e.graphInterface = z(t.interface), ie(e, e.graphInterface), oe(e), n.push(...
|
|
2339
|
+
function Zn(e, t) {
|
|
2340
|
+
let n = Yn(e, t.extensions);
|
|
2341
|
+
return n.length ? n : (e.graph = z(t.graph), e.graphInterface = z(t.interface), ie(e, e.graphInterface), oe(e), n.push(...Xn(e, t)), n);
|
|
2482
2342
|
}
|
|
2483
|
-
function
|
|
2484
|
-
return
|
|
2343
|
+
function Qn(e, t) {
|
|
2344
|
+
return Zn(e, t);
|
|
2345
|
+
}
|
|
2346
|
+
//#endregion
|
|
2347
|
+
//#region src/store/registry/defineType.ts
|
|
2348
|
+
function $n(e) {
|
|
2349
|
+
let t = e.widget, n = nr(t);
|
|
2350
|
+
return {
|
|
2351
|
+
id: e.id,
|
|
2352
|
+
label: e.label ?? er(e.id),
|
|
2353
|
+
color: e.color ?? "#888",
|
|
2354
|
+
validate: e.validate,
|
|
2355
|
+
accepts: e.accepts,
|
|
2356
|
+
defaultValue: e.defaultValue,
|
|
2357
|
+
widget: t,
|
|
2358
|
+
parse: e.parse ?? n.parse,
|
|
2359
|
+
format: e.format ?? n.format,
|
|
2360
|
+
coerce: e.coerce ?? n.coerce
|
|
2361
|
+
};
|
|
2362
|
+
}
|
|
2363
|
+
function er(e) {
|
|
2364
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
2365
|
+
}
|
|
2366
|
+
function tr(e, t, n) {
|
|
2367
|
+
let r = Number(e);
|
|
2368
|
+
return Number.isNaN(r) && (r = 0), t !== void 0 && (r = Math.max(t, r)), n !== void 0 && (r = Math.min(n, r)), r;
|
|
2369
|
+
}
|
|
2370
|
+
function nr(e) {
|
|
2371
|
+
if (!e) return {
|
|
2372
|
+
parse: (e) => e,
|
|
2373
|
+
format: (e) => e == null ? "" : String(e)
|
|
2374
|
+
};
|
|
2375
|
+
switch (e.kind) {
|
|
2376
|
+
case "number": return {
|
|
2377
|
+
parse: (e) => Number(e),
|
|
2378
|
+
format: (e) => e == null ? "" : String(e),
|
|
2379
|
+
coerce: (t) => tr(t, e.min, e.max)
|
|
2380
|
+
};
|
|
2381
|
+
case "text": return {
|
|
2382
|
+
parse: (e) => e,
|
|
2383
|
+
format: (e) => e == null ? "" : String(e)
|
|
2384
|
+
};
|
|
2385
|
+
case "custom": return { format: (e) => e == null ? "" : String(e) };
|
|
2386
|
+
}
|
|
2485
2387
|
}
|
|
2486
2388
|
//#endregion
|
|
2487
|
-
export { V as INPUT_TYPE, Fn as NodeViewer, H as OUTPUT_TYPE,
|
|
2389
|
+
export { V as INPUT_TYPE, Fn as NodeViewer, H as OUTPUT_TYPE, Zn as applyDocument, ae as boundaryNodes, Hn as createNodeMap, $n as defineType, qn as exportGraph, Qn as importGraph, R as instantiate, Jn as parseGraphDocument, Ye as registerComponentWidget, In as registerDefaultTypeWidgets, Je as registerTypeWidget, he as runGraph, Kn as serializeDocument, Xn as validateDocument };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodish/core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.css"
|
|
@@ -9,22 +9,20 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
12
13
|
"exports": {
|
|
13
|
-
"
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/
|
|
16
|
-
|
|
17
|
-
"./vue": {
|
|
18
|
-
"types": "./dist/src/vue/index.d.ts",
|
|
19
|
-
"import": "./dist/vue.js",
|
|
20
|
-
"style": "./dist/vue.css"
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"style": "./dist/index.css"
|
|
21
18
|
}
|
|
22
19
|
},
|
|
23
20
|
"scripts": {
|
|
24
21
|
"setup:local": "node scripts/copy-dev-to-local.mjs",
|
|
25
22
|
"dev": "node scripts/copy-dev-to-local.mjs && vite --config vite.config.dev.ts",
|
|
26
|
-
"build": "vite build
|
|
27
|
-
"typecheck": "tsc --noEmit"
|
|
23
|
+
"build": "vite build",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"typecheck:dev": "tsc --noEmit -p tsconfig.dev.json"
|
|
28
26
|
},
|
|
29
27
|
"peerDependencies": {
|
|
30
28
|
"vue": "^3.5.0"
|
|
@@ -32,7 +30,6 @@
|
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"@types/node": "^26.0.1",
|
|
34
32
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
35
|
-
"dts-bundle-generator": "^9.5.1",
|
|
36
33
|
"typescript": "~6.0.2",
|
|
37
34
|
"vite": "^8.0.12",
|
|
38
35
|
"vite-plugin-dts": "^4.5.4",
|
package/dist/pack.d.ts
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
import { Component } from 'vue';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A publishable bundle of custom types and/or node types (npm package contents).
|
|
7
|
-
* Load onto a {@link NodeMap} with {@link NodeMap.loadPack}.
|
|
8
|
-
*/
|
|
9
|
-
export interface NodePack {
|
|
10
|
-
/** Unique pack id (e.g. `"@my-org/my-pack"`). Recorded in {@link GraphDocument.extensions}. */
|
|
11
|
-
id: string;
|
|
12
|
-
/** Custom {@link PortTypeDefinition}s to register. */
|
|
13
|
-
types?: TypeRegistry;
|
|
14
|
-
/** Custom node definitions to register (authoring form). */
|
|
15
|
-
nodeTypes?: NodeSpecRegistry;
|
|
16
|
-
/**
|
|
17
|
-
* Optional hook to register Vue widgets after types and nodes are merged.
|
|
18
|
-
* Runs once per pack load.
|
|
19
|
-
*/
|
|
20
|
-
setup?: (ctx: PackSetupContext) => void;
|
|
21
|
-
}
|
|
22
|
-
/** Context passed to {@link NodePack.setup} for widget registration. */
|
|
23
|
-
export interface PackSetupContext {
|
|
24
|
-
/**
|
|
25
|
-
* Bind a Vue component to all editable ports of a type id.
|
|
26
|
-
* Overrides the generic widget for that type.
|
|
27
|
-
*/
|
|
28
|
-
registerTypeWidget: (typeId: string, component: Component) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Bind a Vue component to a custom widget id
|
|
31
|
-
* ({@link TypeWidgetSpec} `kind: "custom"`).
|
|
32
|
-
*/
|
|
33
|
-
registerComponentWidget: (componentId: string, component: Component) => void;
|
|
34
|
-
}
|
|
35
|
-
export type NodeId = string;
|
|
36
|
-
export type PortId = string;
|
|
37
|
-
export type ConnectionId = string;
|
|
38
|
-
export type NodeTypeId = string;
|
|
39
|
-
export type NodeLocation = {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
};
|
|
43
|
-
/** Key into the {@link TypeRegistry} (e.g. `"number"`). */
|
|
44
|
-
export type PortTypeId = string;
|
|
45
|
-
export type PortType = PortTypeId;
|
|
46
|
-
/**
|
|
47
|
-
* Serializable widget descriptor for port value editing and display. Lives on the
|
|
48
|
-
* type definition; the Vue viewer resolves it to a concrete component.
|
|
49
|
-
*/
|
|
50
|
-
export type TypeWidgetSpec = {
|
|
51
|
-
kind: "number";
|
|
52
|
-
min?: number;
|
|
53
|
-
max?: number;
|
|
54
|
-
step?: number;
|
|
55
|
-
/** Port row height in px; defaults to one line (20px). */
|
|
56
|
-
rowHeight?: number;
|
|
57
|
-
} | {
|
|
58
|
-
kind: "text";
|
|
59
|
-
/** Multiline row count; height is `rows × 20px` unless `rowHeight` is set. */
|
|
60
|
-
rows?: number;
|
|
61
|
-
/** Port row height in px; overrides `rows`. */
|
|
62
|
-
rowHeight?: number;
|
|
63
|
-
} | {
|
|
64
|
-
kind: "custom";
|
|
65
|
-
/** Id passed to `registerComponentWidget` in a pack's `setup` hook. */
|
|
66
|
-
componentId: string;
|
|
67
|
-
/** Port row height in px; defaults to one line (20px). */
|
|
68
|
-
rowHeight?: number;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* A registered data type. Carries validation, connection compatibility, and
|
|
72
|
-
* optional value lifecycle hooks. Registered at startup — only {@link PortTypeId}
|
|
73
|
-
* keys on ports are serialized in documents.
|
|
74
|
-
*/
|
|
75
|
-
export interface PortTypeDefinition {
|
|
76
|
-
id: PortTypeId;
|
|
77
|
-
label: string;
|
|
78
|
-
color: string;
|
|
79
|
-
validate: (value: unknown) => boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Whether an output of type `from` may connect into an input of this type.
|
|
82
|
-
* Decided by the destination type. Omitted means strict identity (`from === id`).
|
|
83
|
-
*/
|
|
84
|
-
accepts?: (from: PortTypeId) => boolean;
|
|
85
|
-
/** Fallback when a port of this type omits its own default. */
|
|
86
|
-
defaultValue?: unknown;
|
|
87
|
-
/** Display/edit descriptor for the viewer (no functions). */
|
|
88
|
-
widget?: TypeWidgetSpec;
|
|
89
|
-
/** Parse a raw string (e.g. from an input field) into a value. */
|
|
90
|
-
parse?: (raw: string) => unknown;
|
|
91
|
-
/** Format a value for display in the viewer. */
|
|
92
|
-
format?: (value: unknown) => string;
|
|
93
|
-
/** Normalize or clamp a value after edit or connection. */
|
|
94
|
-
coerce?: (value: unknown) => unknown;
|
|
95
|
-
}
|
|
96
|
-
/** Library of available data types, keyed by id. */
|
|
97
|
-
export type TypeRegistry = Record<PortTypeId, PortTypeDefinition>;
|
|
98
|
-
export type PortDirection = "input" | "output";
|
|
99
|
-
/**
|
|
100
|
-
* Port template declared by a node type ({@link IndefiniteNode}). Has no id and
|
|
101
|
-
* no live value — only describes ports that instances will receive.
|
|
102
|
-
*/
|
|
103
|
-
export type PortDefinition = {
|
|
104
|
-
/** Stable, human-authored key; referenced inside `execute()`. */
|
|
105
|
-
name: string;
|
|
106
|
-
type: PortType;
|
|
107
|
-
/** Used by an input when nothing is connected to it. */
|
|
108
|
-
defaultValue?: unknown;
|
|
109
|
-
description?: string;
|
|
110
|
-
/**
|
|
111
|
-
* Input-only. Never accepts a connection — no socket, always shows its widget.
|
|
112
|
-
* Also feeds parameters into {@link IndefiniteNode.resolvePorts}.
|
|
113
|
-
*/
|
|
114
|
-
userOnly?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Input-only. Accepts any number of incoming connections; `execute()` receives
|
|
117
|
-
* values as an unordered array of `type`.
|
|
118
|
-
*/
|
|
119
|
-
multi?: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Widget-specific configuration merged on top of the type's widget spec.
|
|
122
|
-
* Recognized keys: `options`, `min`, `max`, `step`, `rows`, `rowHeight`.
|
|
123
|
-
*/
|
|
124
|
-
customProps?: Record<string, unknown>;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Materialized port on a placed node ({@link DefiniteNode}). Has a unique id so
|
|
128
|
-
* connections and the DOM can reference it directly.
|
|
129
|
-
*/
|
|
130
|
-
export type Port = {
|
|
131
|
-
id: PortId;
|
|
132
|
-
/** Matches the {@link PortDefinition.name} it came from. */
|
|
133
|
-
name: string;
|
|
134
|
-
type: PortType;
|
|
135
|
-
direction: PortDirection;
|
|
136
|
-
/** Input: value when disconnected. Output: optional cache of last computed value. */
|
|
137
|
-
value?: unknown;
|
|
138
|
-
userOnly?: boolean;
|
|
139
|
-
multi?: boolean;
|
|
140
|
-
customProps?: Record<string, unknown>;
|
|
141
|
-
};
|
|
142
|
-
/** Port templates on a definition, keyed by name (authoring-friendly). */
|
|
143
|
-
export type NodeIODefinition = Record<string, PortDefinition>;
|
|
144
|
-
/** Materialized ports on an instance, keyed by id (connection/DOM-friendly). */
|
|
145
|
-
export type NodeIO = Record<PortId, Port>;
|
|
146
|
-
/** Reference to one port on one node. */
|
|
147
|
-
export type PortRef = {
|
|
148
|
-
node: NodeId;
|
|
149
|
-
port: PortId;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Node type template that {@link DefiniteNode} instances are created from. Lives
|
|
153
|
-
* in the runtime registry only (never in a saved graph). Authors ship types via
|
|
154
|
-
* {@link NodePack}.
|
|
155
|
-
*
|
|
156
|
-
* - **Primitive:** implements {@link IndefiniteNode.execute}.
|
|
157
|
-
* - **Composite:** supplies a nested {@link IndefiniteNode.graph} instead of `execute`.
|
|
158
|
-
*/
|
|
159
|
-
export interface IndefiniteNode {
|
|
160
|
-
/** Unique node type id (e.g. `"my-pack/add"`). */
|
|
161
|
-
typeId: NodeTypeId;
|
|
162
|
-
displayName: string;
|
|
163
|
-
color: string;
|
|
164
|
-
description: string;
|
|
165
|
-
/**
|
|
166
|
-
* Hierarchical menu category, broadest first, e.g. `["Math", "Basic Operations"]`.
|
|
167
|
-
* Empty or omitted places the node at the menu root.
|
|
168
|
-
*/
|
|
169
|
-
group?: string[];
|
|
170
|
-
inputs: NodeIODefinition;
|
|
171
|
-
outputs: NodeIODefinition;
|
|
172
|
-
/**
|
|
173
|
-
* Runtime evaluation, keyed by port name (not id). Omit for composite types.
|
|
174
|
-
* @returns Output values keyed by port name.
|
|
175
|
-
*/
|
|
176
|
-
execute?: (inputs: Record<string, unknown>) => Record<string, unknown>;
|
|
177
|
-
/** Nested subgraph for composite types (registry-only, not evaluated standalone). */
|
|
178
|
-
graph?: NodeGraph;
|
|
179
|
-
/**
|
|
180
|
-
* Dynamic port count driven by user-only inputs. When present, static
|
|
181
|
-
* `inputs`/`outputs` are initial defaults; reconciliation re-materializes
|
|
182
|
-
* ports by name so existing ids and connections survive a recount.
|
|
183
|
-
*/
|
|
184
|
-
resolvePorts?: (params: Record<string, unknown>) => {
|
|
185
|
-
inputs: NodeIODefinition;
|
|
186
|
-
outputs: NodeIODefinition;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* A node placed on the workspace. Serializable data only — behaviour lives on
|
|
191
|
-
* the {@link IndefiniteNode} referenced by {@link DefiniteNode.typeId}.
|
|
192
|
-
*/
|
|
193
|
-
export interface DefiniteNode {
|
|
194
|
-
id: NodeId;
|
|
195
|
-
/** {@link IndefiniteNode} this instance was created from. */
|
|
196
|
-
typeId: NodeTypeId;
|
|
197
|
-
location: NodeLocation;
|
|
198
|
-
inputs: NodeIO;
|
|
199
|
-
outputs: NodeIO;
|
|
200
|
-
label?: string;
|
|
201
|
-
color?: string;
|
|
202
|
-
/** Node width in px. Falls back to layout default when undefined. */
|
|
203
|
-
width?: number;
|
|
204
|
-
/**
|
|
205
|
-
* Stacking order — higher paints on top. Stored for save/load. Undefined until
|
|
206
|
-
* first assigned.
|
|
207
|
-
*/
|
|
208
|
-
z?: number;
|
|
209
|
-
/** Nested graph for composite/group instances. Serializable with the node. */
|
|
210
|
-
composite?: CompositeState;
|
|
211
|
-
}
|
|
212
|
-
/** Serializable nested graph owned by a composite instance. */
|
|
213
|
-
export interface CompositeState {
|
|
214
|
-
graph: NodeGraph;
|
|
215
|
-
interface: GraphInterface;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Directed wire from an output port to an input port. Stored centrally on the
|
|
219
|
-
* graph so either endpoint can be looked up uniformly.
|
|
220
|
-
*/
|
|
221
|
-
export interface Connection {
|
|
222
|
-
id: ConnectionId;
|
|
223
|
-
/** Must reference an output port. */
|
|
224
|
-
from: PortRef;
|
|
225
|
-
/** Must reference an input port. */
|
|
226
|
-
to: PortRef;
|
|
227
|
-
}
|
|
228
|
-
/** Serializable port template for boundary definitions (object key = port name). */
|
|
229
|
-
export type GraphPortSpec = Omit<PortDefinition, "name">;
|
|
230
|
-
/**
|
|
231
|
-
* External signature of a graph. Parameters become the Input node's output ports;
|
|
232
|
-
* returns become the Output node's input ports.
|
|
233
|
-
*/
|
|
234
|
-
export interface GraphInterface {
|
|
235
|
-
/** Graph inputs (function parameters). Key = port name. */
|
|
236
|
-
parameters?: Record<string, GraphPortSpec>;
|
|
237
|
-
/** Graph outputs (return values). Key = port name. */
|
|
238
|
-
returns?: Record<string, GraphPortSpec>;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Placed nodes and connections. Every graph must contain exactly one Input node
|
|
242
|
-
* and one Output node.
|
|
243
|
-
*/
|
|
244
|
-
export interface NodeGraph {
|
|
245
|
-
nodes: DefiniteNode[];
|
|
246
|
-
connections: Connection[];
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Port in a node spec — same as {@link GraphPortSpec}; the name comes from the
|
|
250
|
-
* object key so authors do not repeat it.
|
|
251
|
-
*/
|
|
252
|
-
export type PortSpec = GraphPortSpec;
|
|
253
|
-
/** Input or output port templates keyed by port name. */
|
|
254
|
-
export type IOSpec = Record<string, PortSpec>;
|
|
255
|
-
/**
|
|
256
|
-
* Authoring form of {@link IndefiniteNode.resolvePorts}. Returns ports in
|
|
257
|
-
* {@link IOSpec} shape; normalized when registered via {@link registerNodeTypes}.
|
|
258
|
-
*/
|
|
259
|
-
export type DynamicPortsSpec = (params: Record<string, unknown>) => {
|
|
260
|
-
inputs?: IOSpec;
|
|
261
|
-
outputs?: IOSpec;
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Authoring format for a node type. Normalized into a full {@link IndefiniteNode}
|
|
265
|
-
* when registered on a {@link NodeMap} (via {@link NodePack} or
|
|
266
|
-
* {@link registerNodeTypes}).
|
|
267
|
-
*/
|
|
268
|
-
export interface NodeSpec {
|
|
269
|
-
/** Unique node type id (e.g. `"my-pack/add"`). */
|
|
270
|
-
typeId: NodeTypeId;
|
|
271
|
-
displayName: string;
|
|
272
|
-
color?: string;
|
|
273
|
-
description?: string;
|
|
274
|
-
/**
|
|
275
|
-
* Hierarchical menu category, broadest first. See {@link IndefiniteNode.group}.
|
|
276
|
-
*/
|
|
277
|
-
group?: string[];
|
|
278
|
-
inputs?: IOSpec;
|
|
279
|
-
outputs?: IOSpec;
|
|
280
|
-
/**
|
|
281
|
-
* Runtime evaluation, keyed by port name. Omit for composite node packs.
|
|
282
|
-
* @returns Output values keyed by port name.
|
|
283
|
-
*/
|
|
284
|
-
execute?: (inputs: Record<string, unknown>) => Record<string, unknown>;
|
|
285
|
-
/** Nested subgraph for composite types in a published pack. Not evaluated yet. */
|
|
286
|
-
graph?: NodeGraph;
|
|
287
|
-
/**
|
|
288
|
-
* Dynamic port count driven by user-only inputs. Static `inputs`/`outputs`
|
|
289
|
-
* act as initial defaults when present.
|
|
290
|
-
*/
|
|
291
|
-
resolvePorts?: DynamicPortsSpec;
|
|
292
|
-
}
|
|
293
|
-
/** Node types in authoring form, keyed by {@link NodeTypeId}. */
|
|
294
|
-
export type NodeSpecRegistry = Record<NodeTypeId, NodeSpec>;
|
|
295
|
-
/**
|
|
296
|
-
* Authoring format for a data type. {@link defineType} expands this into a full
|
|
297
|
-
* {@link PortTypeDefinition} (default label, color, and widget lifecycle hooks).
|
|
298
|
-
*/
|
|
299
|
-
export interface TypeSpec {
|
|
300
|
-
/** Unique type id (e.g. `"number"`, `"my-pack/label"`). */
|
|
301
|
-
id: PortTypeId;
|
|
302
|
-
label?: string;
|
|
303
|
-
color?: string;
|
|
304
|
-
validate: (value: unknown) => boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Whether an output of type `from` may connect into ports of this type.
|
|
307
|
-
* Omitted means strict identity.
|
|
308
|
-
*/
|
|
309
|
-
accepts?: (from: PortTypeId) => boolean;
|
|
310
|
-
/** Fallback when a port of this type omits its own default. */
|
|
311
|
-
defaultValue?: unknown;
|
|
312
|
-
/** Viewer widget descriptor for ports of this type. */
|
|
313
|
-
widget?: TypeWidgetSpec;
|
|
314
|
-
/** Override default parse behaviour for this type's widget. */
|
|
315
|
-
parse?: (raw: string) => unknown;
|
|
316
|
-
/** Override default format behaviour for this type's widget. */
|
|
317
|
-
format?: (value: unknown) => string;
|
|
318
|
-
/** Override default coerce behaviour for this type's widget. */
|
|
319
|
-
coerce?: (value: unknown) => unknown;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Turn a {@link TypeSpec} into a complete {@link PortTypeDefinition}.
|
|
323
|
-
*/
|
|
324
|
-
export declare function defineType(spec: TypeSpec): PortTypeDefinition;
|
|
325
|
-
|
|
326
|
-
export {};
|