@code0-tech/triangulum 0.12.2 → 0.12.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.
- package/dist/triangulum.cjs.js +1 -1
- package/dist/triangulum.es.js +38 -42
- package/package.json +1 -1
package/dist/triangulum.cjs.js
CHANGED
|
@@ -29,7 +29,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
29
29
|
import ReturnType = Utils.ReturnType;
|
|
30
30
|
`;function k(e,t){let n=new Map;return n.set(e,t),n.set(`lib.codezero.d.ts`,O),p(v(n),[e,`lib.codezero.d.ts`],c.default,A)}var A={target:c.default.ScriptTarget.Latest,lib:[`lib.codezero.d.ts`],noEmit:!0,strictNullChecks:!0};function j(e,t=`any`,n=!0){let r=Array.from(new Set(e?.flatMap(e=>e.genericKeys||[]))).map(e=>`type ${e} = ${t};`).join(`
|
|
31
31
|
`),i=e?.map(e=>`type ${e.identifier}${(e.genericKeys?.length??0)>0?`<${e.genericKeys?.join(`,`)}>`:``} = ${e.type};`).join(`
|
|
32
|
-
`);return`${n?r:``}\n${i}`}var M=e=>e.replace(/[^a-zA-Z0-9]/g,`_`);function N(e,t,n,r=!1){let i=e?.nodes?.nodes||[],a=new Map(t?.map(e=>[e.identifier,e])),o=new Set,s=(
|
|
32
|
+
`);return`${n?r:``}\n${i}`}var M=e=>e.replace(/[^a-zA-Z0-9]/g,`_`);function N(e,t,n,r=!1){let i=e?.nodes?.nodes||[],a=new Map(t?.map(e=>[e.identifier,e])),o=new Set,s=(t,n,a)=>{let o=i.find(e=>e?.id===t);if(!o||!o.functionDefinition?.identifier)return`undefined`;let c=(o.parameters?.nodes||[]).map((n,i)=>{let a=n.value;if(!a)return r?`/* @pos ${t} ${i} */ {}`:`/* @pos ${t} ${i} */ undefined`;if(a.__typename===`ReferenceValue`){let n=a,r=typeof n.inputIndex==`number`?`p_${M(n.nodeFunctionId??`undefined`)}_${n.parameterIndex}[${n.inputIndex}]`:n.nodeFunctionId?`node_${M(n.nodeFunctionId)}`:`flow_${M(e?.id??`undefined`)}`;return n.referencePath?.forEach(e=>{r+=`?.${e.path}`}),`/* @pos ${t} ${i} */ ${r}`}return a.__typename===`LiteralValue`?`/* @pos ${t} ${i} */ ${E(a?.value)}`:a.__typename===`NodeFunctionIdWrapper`?s(a.id,t,i):r?`/* @pos ${t} ${i} */ ({} as any)`:`/* @pos ${t} ${i} */ undefined`}).join(`, `),l=`${`fn_${o.functionDefinition.identifier.replace(/::/g,`_`)}`}(${c})`;return n!==void 0&&a!==void 0?`${l}`:l},c=(t,l=``)=>{if(o.has(t))return``;let u=i.find(e=>e?.id===t);if(!u||!u.functionDefinition)return``;o.add(t);let d=a.get(u.functionDefinition.identifier);if(!d)return`${l}// Error: Function ${u.functionDefinition.identifier} not found\n`;let f={parameters:[]};r||(f=C(d));let p=(u.parameters?.nodes||[]).map((i,a)=>{let o=i.value;if(!o)return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`;if(o.__typename===`ReferenceValue`){let n=o,r=typeof n.inputIndex==`number`?`p_${M(n.nodeFunctionId??`undefined`)}_${n.parameterIndex}[${n.inputIndex}]`:n.nodeFunctionId?`node_${M(n.nodeFunctionId)}`:`flow_${M(e?.id??`undefined`)}`;return n.referencePath?.forEach(e=>{r+=`?.${e.path}`}),`/* @pos ${t} ${a} */ ${r}`}if(o.__typename===`LiteralValue`)return`/* @pos ${t} ${a} */ ${E(o?.value)}`;if(o.__typename===`NodeFunctionIdWrapper`){let e=o;if(r)return`/* @pos ${t} ${a} */ (...${`p_${M(t)}_${a}`}) => {\n${c(e.id,l+` `)}${l}}`;{let r=f.parameters[a];return r&&S(r,n)[0].variant===x.NODE?`/* @pos ${t} ${a} */ (...${`p_${M(t)}_${a}`}) => {\n${c(e.id,l+` `)}${l}}`:`/* @pos ${t} ${a} */ ${s(e.id,t,a)}`}}return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`}).join(`, `),m=`node_${M(u.id)}`,h=`fn_${u?.functionDefinition?.identifier?.replace(/::/g,`_`)}`;p.includes(`undefined`);let g=`${l}${u.functionDefinition.identifier===`std::control::return`?`return `:`const ${m} = `}${h}(${p}) ;\n`;return u.nextNodeId&&(g+=c(u.nextNodeId,l)),g},l=j(n),u=`declare function flow${e?.signature??`(): void`}`,d=t?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,`_`)}${e.signature}`).join(`
|
|
33
33
|
`),f=new Set(i.map(e=>e?.nextNodeId).filter(e=>!!e)),p=new Set;return i.forEach(e=>e?.parameters?.nodes?.forEach(e=>{e?.value?.__typename===`NodeFunctionIdWrapper`&&e.value.id&&p.add(e.value.id)})),`
|
|
34
34
|
${l}\n
|
|
35
35
|
${u}\n
|
package/dist/triangulum.es.js
CHANGED
|
@@ -369,57 +369,53 @@ function w(e, t = "any", n = !0) {
|
|
|
369
369
|
}
|
|
370
370
|
var T = (e) => e.replace(/[^a-zA-Z0-9]/g, "_");
|
|
371
371
|
function E(e, t, n, r = !1) {
|
|
372
|
-
let i = e?.nodes?.nodes || [], a = new Map(t?.map((e) => [e.identifier, e])), o = /* @__PURE__ */ new Set(), s = (
|
|
373
|
-
let
|
|
374
|
-
if (!
|
|
375
|
-
let
|
|
376
|
-
let
|
|
377
|
-
if (!
|
|
378
|
-
if (
|
|
379
|
-
let
|
|
380
|
-
|
|
381
|
-
let r = typeof t.inputIndex == "number" ? `p_${T(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]` : `node_${T(t.nodeFunctionId)}`;
|
|
382
|
-
return t.referencePath?.forEach((e) => {
|
|
372
|
+
let i = e?.nodes?.nodes || [], a = new Map(t?.map((e) => [e.identifier, e])), o = /* @__PURE__ */ new Set(), s = (t, n, a) => {
|
|
373
|
+
let o = i.find((e) => e?.id === t);
|
|
374
|
+
if (!o || !o.functionDefinition?.identifier) return "undefined";
|
|
375
|
+
let c = (o.parameters?.nodes || []).map((n, i) => {
|
|
376
|
+
let a = n.value;
|
|
377
|
+
if (!a) return r ? `/* @pos ${t} ${i} */ {}` : `/* @pos ${t} ${i} */ undefined`;
|
|
378
|
+
if (a.__typename === "ReferenceValue") {
|
|
379
|
+
let n = a, r = typeof n.inputIndex == "number" ? `p_${T(n.nodeFunctionId ?? "undefined")}_${n.parameterIndex}[${n.inputIndex}]` : n.nodeFunctionId ? `node_${T(n.nodeFunctionId)}` : `flow_${T(e?.id ?? "undefined")}`;
|
|
380
|
+
return n.referencePath?.forEach((e) => {
|
|
383
381
|
r += `?.${e.path}`;
|
|
384
|
-
}), `/* @pos ${
|
|
382
|
+
}), `/* @pos ${t} ${i} */ ${r}`;
|
|
385
383
|
}
|
|
386
|
-
return
|
|
387
|
-
}).join(", "),
|
|
388
|
-
return
|
|
389
|
-
}, c = (
|
|
390
|
-
if (o.has(
|
|
391
|
-
let
|
|
392
|
-
if (!
|
|
393
|
-
o.add(
|
|
394
|
-
let
|
|
395
|
-
if (!
|
|
396
|
-
let
|
|
397
|
-
r || (
|
|
398
|
-
let
|
|
384
|
+
return a.__typename === "LiteralValue" ? `/* @pos ${t} ${i} */ ${y(a?.value)}` : a.__typename === "NodeFunctionIdWrapper" ? s(a.id, t, i) : r ? `/* @pos ${t} ${i} */ ({} as any)` : `/* @pos ${t} ${i} */ undefined`;
|
|
385
|
+
}).join(", "), l = `${`fn_${o.functionDefinition.identifier.replace(/::/g, "_")}`}(${c})`;
|
|
386
|
+
return n !== void 0 && a !== void 0 ? `${l}` : l;
|
|
387
|
+
}, c = (t, l = "") => {
|
|
388
|
+
if (o.has(t)) return "";
|
|
389
|
+
let u = i.find((e) => e?.id === t);
|
|
390
|
+
if (!u || !u.functionDefinition) return "";
|
|
391
|
+
o.add(t);
|
|
392
|
+
let d = a.get(u.functionDefinition.identifier);
|
|
393
|
+
if (!d) return `${l}// Error: Function ${u.functionDefinition.identifier} not found\n`;
|
|
394
|
+
let f = { parameters: [] };
|
|
395
|
+
r || (f = g(d));
|
|
396
|
+
let p = (u.parameters?.nodes || []).map((i, a) => {
|
|
399
397
|
let o = i.value;
|
|
400
|
-
if (!o) return r ? `/* @pos ${
|
|
398
|
+
if (!o) return r ? `/* @pos ${t} ${a} */ {}` : `/* @pos ${t} ${a} */ undefined`;
|
|
401
399
|
if (o.__typename === "ReferenceValue") {
|
|
402
|
-
let
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
n += `?.${e.path}`;
|
|
407
|
-
}), `/* @pos ${e} ${a} */ ${n}`;
|
|
400
|
+
let n = o, r = typeof n.inputIndex == "number" ? `p_${T(n.nodeFunctionId ?? "undefined")}_${n.parameterIndex}[${n.inputIndex}]` : n.nodeFunctionId ? `node_${T(n.nodeFunctionId)}` : `flow_${T(e?.id ?? "undefined")}`;
|
|
401
|
+
return n.referencePath?.forEach((e) => {
|
|
402
|
+
r += `?.${e.path}`;
|
|
403
|
+
}), `/* @pos ${t} ${a} */ ${r}`;
|
|
408
404
|
}
|
|
409
|
-
if (o.__typename === "LiteralValue") return `/* @pos ${
|
|
405
|
+
if (o.__typename === "LiteralValue") return `/* @pos ${t} ${a} */ ${y(o?.value)}`;
|
|
410
406
|
if (o.__typename === "NodeFunctionIdWrapper") {
|
|
411
|
-
let
|
|
412
|
-
if (r) return `/* @pos ${
|
|
407
|
+
let e = o;
|
|
408
|
+
if (r) return `/* @pos ${t} ${a} */ (...${`p_${T(t)}_${a}`}) => {\n${c(e.id, l + " ")}${l}}`;
|
|
413
409
|
{
|
|
414
|
-
let r =
|
|
415
|
-
return r && h(r, n)[0].variant === m.NODE ? `/* @pos ${
|
|
410
|
+
let r = f.parameters[a];
|
|
411
|
+
return r && h(r, n)[0].variant === m.NODE ? `/* @pos ${t} ${a} */ (...${`p_${T(t)}_${a}`}) => {\n${c(e.id, l + " ")}${l}}` : `/* @pos ${t} ${a} */ ${s(e.id, t, a)}`;
|
|
416
412
|
}
|
|
417
413
|
}
|
|
418
|
-
return r ? `/* @pos ${
|
|
419
|
-
}).join(", "),
|
|
420
|
-
|
|
421
|
-
let
|
|
422
|
-
return
|
|
414
|
+
return r ? `/* @pos ${t} ${a} */ {}` : `/* @pos ${t} ${a} */ undefined`;
|
|
415
|
+
}).join(", "), _ = `node_${T(u.id)}`, v = `fn_${u?.functionDefinition?.identifier?.replace(/::/g, "_")}`;
|
|
416
|
+
p.includes("undefined");
|
|
417
|
+
let b = `${l}${u.functionDefinition.identifier === "std::control::return" ? "return " : `const ${_} = `}${v}(${p}) ;\n`;
|
|
418
|
+
return u.nextNodeId && (b += c(u.nextNodeId, l)), b;
|
|
423
419
|
}, l = w(n), u = `declare function flow${e?.signature ?? "(): void"}`, d = t?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join("\n"), f = new Set(i.map((e) => e?.nextNodeId).filter((e) => !!e)), p = /* @__PURE__ */ new Set();
|
|
424
420
|
return i.forEach((e) => e?.parameters?.nodes?.forEach((e) => {
|
|
425
421
|
e?.value?.__typename === "NodeFunctionIdWrapper" && e.value.id && p.add(e.value.id);
|