@code0-tech/triangulum 0.12.1 → 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.
@@ -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=(e,t,n)=>{let a=i.find(t=>t?.id===e);if(!a||!a.functionDefinition?.identifier)return`undefined`;let o=(a.parameters?.nodes||[]).map((t,n)=>{let i=t.value;if(!i)return r?`/* @pos ${e} ${n} */ {}`:`/* @pos ${e} ${n} */ undefined`;if(i.__typename===`ReferenceValue`){let t=i;if(!t.nodeFunctionId)return`/* @pos ${e} ${n} */ undefined`;let r=typeof t.inputIndex==`number`?`p_${M(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]`:`node_${M(t.nodeFunctionId)}`;return t.referencePath?.forEach(e=>{r+=`?.${e.path}`}),`/* @pos ${e} ${n} */ ${r}`}return i.__typename===`LiteralValue`?`/* @pos ${e} ${n} */ ${E(i?.value)}`:i.__typename===`NodeFunctionIdWrapper`?s(i.id,e,n):r?`/* @pos ${e} ${n} */ ({} as any)`:`/* @pos ${e} ${n} */ undefined`}).join(`, `),c=`${`fn_${a.functionDefinition.identifier.replace(/::/g,`_`)}`}(${o})`;return t!==void 0&&n!==void 0?`${c}`:c},c=(e,t=``)=>{if(o.has(e))return``;let l=i.find(t=>t?.id===e);if(!l||!l.functionDefinition)return``;o.add(e);let u=a.get(l.functionDefinition.identifier);if(!u)return`${t}// Error: Function ${l.functionDefinition.identifier} not found\n`;let d={parameters:[]};r||(d=C(u));let f=(l.parameters?.nodes||[]).map((i,a)=>{let o=i.value;if(!o)return r?`/* @pos ${e} ${a} */ {}`:`/* @pos ${e} ${a} */ undefined`;if(o.__typename===`ReferenceValue`){let t=o;if(!t.nodeFunctionId)return`/* @pos ${e} ${a} */ undefined`;let n=typeof t.inputIndex==`number`?`p_${M(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]`:`node_${M(t.nodeFunctionId)}`;return t.referencePath?.forEach(e=>{n+=`?.${e.path}`}),`/* @pos ${e} ${a} */ ${n}`}if(o.__typename===`LiteralValue`)return`/* @pos ${e} ${a} */ ${E(o?.value)}`;if(o.__typename===`NodeFunctionIdWrapper`){let i=o;if(r)return`/* @pos ${e} ${a} */ (...${`p_${M(e)}_${a}`}) => {\n${c(i.id,t+` `)}${t}}`;{let r=d.parameters[a];return r&&S(r,n)[0].variant===x.NODE?`/* @pos ${e} ${a} */ (...${`p_${M(e)}_${a}`}) => {\n${c(i.id,t+` `)}${t}}`:`/* @pos ${e} ${a} */ ${s(i.id,e,a)}`}}return r?`/* @pos ${e} ${a} */ {}`:`/* @pos ${e} ${a} */ undefined`}).join(`, `),p=`node_${M(l.id)}`,m=`fn_${l?.functionDefinition?.identifier?.replace(/::/g,`_`)}`;f.includes(`undefined`);let h=`${t}${l.functionDefinition.identifier===`std::control::return`?`return `:`const ${p} = `}${m}(${f}) ;\n`;return l.nextNodeId&&(h+=c(l.nextNodeId,t)),h},l=j(n),u=`declare function flow${e?.signature??`(): void`}`,d=t?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,`_`)}${e.signature}`).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=(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
@@ -56,7 +56,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
56
56
  ${t?.map((e,t)=>`const check${t}: TargetType = {} as F${t};`).join(`
57
57
  `)}
58
58
  `,o=`index.ts`,s=k(o,i),c=s.getSourceFile(o),l=s.languageService.getProgram().getSemanticDiagnostics(),u=new Set;l.forEach(e=>{e.file===c&&e.start!==void 0&&u.add(c.getLineAndCharacterOfPosition(e.start).line)}),r=t.filter((e,t)=>{let n=`const check${t}: TargetType = {} as F${t};`,r=i.split(`
59
- `).findIndex(e=>e.includes(n));return r!==-1&&!u.has(r)})}return r?.map(e=>({__typename:`NodeFunction`,id:`gid://sagittarius/NodeFunction/1`,functionDefinition:{__typename:`FunctionDefinition`,id:e.id,identifier:e.identifier},parameters:{__typename:`NodeParameterConnection`,nodes:(e.parameterDefinitions?.nodes||[]).map(e=>({__typename:`NodeParameter`,parameterDefinition:{__typename:`ParameterDefinition`,id:e?.id,identifier:e?.identifier},value:e?.defaultValue?{__typename:`LiteralValue`,value:e.defaultValue.value}:null}))}})).filter(e=>e!==null)??[]},z=e=>{let t=c.default.TypeFlags.String|c.default.TypeFlags.Number|c.default.TypeFlags.Boolean|c.default.TypeFlags.Undefined|c.default.TypeFlags.Null|c.default.TypeFlags.BigInt|c.default.TypeFlags.ESSymbol;return(e.flags&t)===0},B=(e,t,n,r=[])=>{let i=[];if(t.isTypeAssignableTo(e,n)&&i.push({path:r,type:e}),z(e)){let a=e.getProperties();a&&a.length>0&&a.forEach(e=>{let a=t.getTypeOfSymbolAtLocation(e,e.valueDeclaration),o=e.getName(),s=[...r,{path:o}];i.push(...B(a,t,n,s))})}return i},V=(e,t,n,r,i)=>{let a=N(e,r,i,!0),o=`index.ts`,s=k(o,a),l=s.getSourceFile(o),u=s.languageService.getProgram().getTypeChecker(),d=l.getFullText(),f=`/* @pos ${t} ${n} */`,p=d.indexOf(f)+f.length;function m(e,t){let n=e;return c.default.forEachChild(e,e=>{e.getStart(l,!0)<=t&&e.getEnd()>=t&&(n=m(e,t))}),n}let h=m(l,p),g;if(c.default.isCallExpression(h)&&(g=h),!g)return[];let _=u.getResolvedSignature(g);if(!_)return[];let v=_.getParameters(),y=v[n]||v[v.length-1],b=u.getTypeOfSymbolAtLocation(y,h),x=u.getSymbolsInScope(h,c.default.SymbolFlags.Variable),S=[];return x.forEach(e=>{let t=e.getName();if(!t.startsWith(`node_`)&&!t.startsWith(`p_`)&&!t.startsWith(`flow_`))return;let n=e.valueDeclaration||e.declarations?.[0];if(!n||n.getEnd()>=p)return;let r=u.getTypeOfSymbolAtLocation(e,h);if(t.startsWith(`node_`)){if((r.flags&c.default.TypeFlags.Void)===0){let e=t.replace(`node_`,``).replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`);B(r,u,b).forEach(({path:t})=>{let n={__typename:`ReferenceValue`,nodeFunctionId:e};t.length>0&&(n.referencePath=t),S.push(n)})}}else if(t.startsWith(`p_`)){let e=t.replace(`p_`,``),n=e.lastIndexOf(`_`),i=e.substring(0,n),a=parseInt(e.substring(n+1),10),o=i.replace(`p_`,``).replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`);if(u.isTupleType(r)){let e=r;u.getTypeArguments(e).forEach((t,n)=>{B(t,u,b).forEach(({path:t})=>{let r={__typename:`ReferenceValue`,nodeFunctionId:o,parameterIndex:isNaN(a)?0:a,inputIndex:n,inputTypeIdentifier:e.target.labeledElementDeclarations?.[n].name.getText()};t.length>0&&(r.referencePath=t),S.push(r)})})}}else t.startsWith(`flow_`)&&B(r,u,b).forEach(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:null};e.length>0&&(t.referencePath=e),S.push(t)})}),S},H=(e,t)=>{if(!e)return[];let n=`
59
+ `).findIndex(e=>e.includes(n));return r!==-1&&!u.has(r)})}return r?.map(e=>({__typename:`NodeFunction`,id:`gid://sagittarius/NodeFunction/1`,functionDefinition:{__typename:`FunctionDefinition`,id:e.id,identifier:e.identifier},parameters:{__typename:`NodeParameterConnection`,nodes:(e.parameterDefinitions?.nodes||[]).map(e=>({__typename:`NodeParameter`,parameterDefinition:{__typename:`ParameterDefinition`,id:e?.id,identifier:e?.identifier},value:e?.defaultValue?{__typename:`LiteralValue`,value:e.defaultValue.value}:null}))}})).filter(e=>e!==null)??[]},z=e=>{let t=c.default.TypeFlags.String|c.default.TypeFlags.Number|c.default.TypeFlags.Boolean|c.default.TypeFlags.Undefined|c.default.TypeFlags.Null|c.default.TypeFlags.BigInt|c.default.TypeFlags.ESSymbol;return(e.flags&t)===0},B=(e,t,n,r=[])=>{let i=[];if(t.isTypeAssignableTo(e,n)&&i.push({path:r,type:e}),z(e)){let a=e.getProperties();a&&a.length>0&&a.forEach(e=>{let a=t.getTypeOfSymbolAtLocation(e,e.valueDeclaration),o=e.getName(),s=[...r,{path:o}];i.push(...B(a,t,n,s))})}return i},V=(e,t,n,r,i)=>{let a=e?.nodes?.nodes?.findIndex(e=>e?.id==t);typeof a==`number`&&a>=0&&typeof n==`number`&&n>=0&&e?.nodes?.nodes?.[a]?.parameters?.nodes?.[n]&&(e.nodes.nodes[a].parameters.nodes[n].value=null);let o=N(e,r,i,!0),s=`index.ts`,l=k(s,o),u=l.getSourceFile(s),d=l.languageService.getProgram().getTypeChecker(),f=u.getFullText(),p=`/* @pos ${t} ${n} */`,m=f.indexOf(p)+p.length;function h(e,t){let n=e;return c.default.forEachChild(e,e=>{e.getStart(u,!0)<=t&&e.getEnd()>=t&&(n=h(e,t))}),n}let g=h(u,m),_;if(c.default.isCallExpression(g)&&(_=g),!_)return[];let v=d.getResolvedSignature(_);if(!v)return[];let y=v.getParameters(),b=y[n]||y[y.length-1],x=d.getTypeOfSymbolAtLocation(b,g),S=d.getSymbolsInScope(g,c.default.SymbolFlags.Variable),C=[];return S.forEach(e=>{let t=e.getName();if(!t.startsWith(`node_`)&&!t.startsWith(`p_`)&&!t.startsWith(`flow_`))return;let n=e.valueDeclaration||e.declarations?.[0];if(!n||n.getEnd()>=m)return;let r=d.getTypeOfSymbolAtLocation(e,g);if(t.startsWith(`node_`)){if((r.flags&c.default.TypeFlags.Void)===0){let e=t.replace(`node_`,``).replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`);B(r,d,x).forEach(({path:t})=>{let n={__typename:`ReferenceValue`,nodeFunctionId:e};t.length>0&&(n.referencePath=t),C.push(n)})}}else if(t.startsWith(`p_`)){let e=t.replace(`p_`,``),n=e.lastIndexOf(`_`),i=e.substring(0,n),a=parseInt(e.substring(n+1),10),o=i.replace(`p_`,``).replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`);if(d.isTupleType(r)){let e=r;d.getTypeArguments(e).forEach((t,n)=>{B(t,d,x).forEach(({path:t})=>{let r={__typename:`ReferenceValue`,nodeFunctionId:o,parameterIndex:isNaN(a)?0:a,inputIndex:n,inputTypeIdentifier:e.target.labeledElementDeclarations?.[n].name.getText()};t.length>0&&(r.referencePath=t),C.push(r)})})}}else t.startsWith(`flow_`)&&B(r,d,x).forEach(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:null};e.length>0&&(t.referencePath=e),C.push(t)})}),C},H=(e,t)=>{if(!e)return[];let n=`
60
60
  ${j(t)}
61
61
  type VALUE = ${e}; const val: VALUE = {} as any;
62
62
  `,r=`index.ts`,i=k(r,n),a=i.getSourceFile(r),o=i.languageService.getProgram().getTypeChecker(),s=a.statements.find(e=>c.default.isTypeAliasDeclaration(e)&&e.name.text===`VALUE`);if(!s||!c.default.isTypeAliasDeclaration(s))return[];let l=o.getTypeAtLocation(s),u=e=>e.isUnion()?e.types.flatMap(u):e.isStringLiteral()?[e.value]:e.isNumberLiteral()?[e.value.toString()]:e.intrinsicName===`true`?[`true`]:e.intrinsicName===`false`?[`false`]:[];return Array.from(new Set(u(l))).map(e=>({__typename:`LiteralValue`,value:e}))},U=(e,t,n)=>{let r=N(e,t,n),i=`index.ts`,a=k(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getSemanticDiagnostics(o).map(e=>{let t=(0,c.flattenDiagnosticMessageText)(e.messageText,`
@@ -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 = (e, t, n) => {
373
- let a = i.find((t) => t?.id === e);
374
- if (!a || !a.functionDefinition?.identifier) return "undefined";
375
- let o = (a.parameters?.nodes || []).map((t, n) => {
376
- let i = t.value;
377
- if (!i) return r ? `/* @pos ${e} ${n} */ {}` : `/* @pos ${e} ${n} */ undefined`;
378
- if (i.__typename === "ReferenceValue") {
379
- let t = i;
380
- if (!t.nodeFunctionId) return `/* @pos ${e} ${n} */ undefined`;
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 ${e} ${n} */ ${r}`;
382
+ }), `/* @pos ${t} ${i} */ ${r}`;
385
383
  }
386
- return i.__typename === "LiteralValue" ? `/* @pos ${e} ${n} */ ${y(i?.value)}` : i.__typename === "NodeFunctionIdWrapper" ? s(i.id, e, n) : r ? `/* @pos ${e} ${n} */ ({} as any)` : `/* @pos ${e} ${n} */ undefined`;
387
- }).join(", "), c = `${`fn_${a.functionDefinition.identifier.replace(/::/g, "_")}`}(${o})`;
388
- return t !== void 0 && n !== void 0 ? `${c}` : c;
389
- }, c = (e, t = "") => {
390
- if (o.has(e)) return "";
391
- let l = i.find((t) => t?.id === e);
392
- if (!l || !l.functionDefinition) return "";
393
- o.add(e);
394
- let u = a.get(l.functionDefinition.identifier);
395
- if (!u) return `${t}// Error: Function ${l.functionDefinition.identifier} not found\n`;
396
- let d = { parameters: [] };
397
- r || (d = g(u));
398
- let f = (l.parameters?.nodes || []).map((i, a) => {
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 ${e} ${a} */ {}` : `/* @pos ${e} ${a} */ undefined`;
398
+ if (!o) return r ? `/* @pos ${t} ${a} */ {}` : `/* @pos ${t} ${a} */ undefined`;
401
399
  if (o.__typename === "ReferenceValue") {
402
- let t = o;
403
- if (!t.nodeFunctionId) return `/* @pos ${e} ${a} */ undefined`;
404
- let n = typeof t.inputIndex == "number" ? `p_${T(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]` : `node_${T(t.nodeFunctionId)}`;
405
- return t.referencePath?.forEach((e) => {
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 ${e} ${a} */ ${y(o?.value)}`;
405
+ if (o.__typename === "LiteralValue") return `/* @pos ${t} ${a} */ ${y(o?.value)}`;
410
406
  if (o.__typename === "NodeFunctionIdWrapper") {
411
- let i = o;
412
- if (r) return `/* @pos ${e} ${a} */ (...${`p_${T(e)}_${a}`}) => {\n${c(i.id, t + " ")}${t}}`;
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 = d.parameters[a];
415
- return r && h(r, n)[0].variant === m.NODE ? `/* @pos ${e} ${a} */ (...${`p_${T(e)}_${a}`}) => {\n${c(i.id, t + " ")}${t}}` : `/* @pos ${e} ${a} */ ${s(i.id, e, a)}`;
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 ${e} ${a} */ {}` : `/* @pos ${e} ${a} */ undefined`;
419
- }).join(", "), p = `node_${T(l.id)}`, _ = `fn_${l?.functionDefinition?.identifier?.replace(/::/g, "_")}`;
420
- f.includes("undefined");
421
- let v = `${t}${l.functionDefinition.identifier === "std::control::return" ? "return " : `const ${p} = `}${_}(${f}) ;\n`;
422
- return l.nextNodeId && (v += c(l.nextNodeId, t)), v;
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);
@@ -649,41 +645,43 @@ var O = (t, n) => {
649
645
  }
650
646
  return i;
651
647
  }, P = (t, n, r, i, a) => {
652
- let o = E(t, i, a, !0), s = "index.ts", c = S(s, o), l = c.getSourceFile(s), u = c.languageService.getProgram().getTypeChecker(), d = l.getFullText(), f = `/* @pos ${n} ${r} */`, p = d.indexOf(f) + f.length;
653
- function m(t, n) {
648
+ let o = t?.nodes?.nodes?.findIndex((e) => e?.id == n);
649
+ typeof o == "number" && o >= 0 && typeof r == "number" && r >= 0 && t?.nodes?.nodes?.[o]?.parameters?.nodes?.[r] && (t.nodes.nodes[o].parameters.nodes[r].value = null);
650
+ let s = E(t, i, a, !0), c = "index.ts", l = S(c, s), u = l.getSourceFile(c), d = l.languageService.getProgram().getTypeChecker(), f = u.getFullText(), p = `/* @pos ${n} ${r} */`, m = f.indexOf(p) + p.length;
651
+ function h(t, n) {
654
652
  let r = t;
655
653
  return e.forEachChild(t, (e) => {
656
- e.getStart(l, !0) <= n && e.getEnd() >= n && (r = m(e, n));
654
+ e.getStart(u, !0) <= n && e.getEnd() >= n && (r = h(e, n));
657
655
  }), r;
658
656
  }
659
- let h = m(l, p), g;
660
- if (e.isCallExpression(h) && (g = h), !g) return [];
661
- let _ = u.getResolvedSignature(g);
662
- if (!_) return [];
663
- let v = _.getParameters(), y = v[r] || v[v.length - 1], b = u.getTypeOfSymbolAtLocation(y, h), x = u.getSymbolsInScope(h, e.SymbolFlags.Variable), C = [];
664
- return x.forEach((t) => {
657
+ let g = h(u, m), _;
658
+ if (e.isCallExpression(g) && (_ = g), !_) return [];
659
+ let v = d.getResolvedSignature(_);
660
+ if (!v) return [];
661
+ let y = v.getParameters(), b = y[r] || y[y.length - 1], x = d.getTypeOfSymbolAtLocation(b, g), C = d.getSymbolsInScope(g, e.SymbolFlags.Variable), w = [];
662
+ return C.forEach((t) => {
665
663
  let n = t.getName();
666
664
  if (!n.startsWith("node_") && !n.startsWith("p_") && !n.startsWith("flow_")) return;
667
665
  let r = t.valueDeclaration || t.declarations?.[0];
668
- if (!r || r.getEnd() >= p) return;
669
- let i = u.getTypeOfSymbolAtLocation(t, h);
666
+ if (!r || r.getEnd() >= m) return;
667
+ let i = d.getTypeOfSymbolAtLocation(t, g);
670
668
  if (n.startsWith("node_")) {
671
669
  if ((i.flags & e.TypeFlags.Void) === 0) {
672
670
  let e = n.replace("node_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
673
- N(i, u, b).forEach(({ path: t }) => {
671
+ N(i, d, x).forEach(({ path: t }) => {
674
672
  let n = {
675
673
  __typename: "ReferenceValue",
676
674
  nodeFunctionId: e
677
675
  };
678
- t.length > 0 && (n.referencePath = t), C.push(n);
676
+ t.length > 0 && (n.referencePath = t), w.push(n);
679
677
  });
680
678
  }
681
679
  } else if (n.startsWith("p_")) {
682
680
  let e = n.replace("p_", ""), t = e.lastIndexOf("_"), r = e.substring(0, t), a = parseInt(e.substring(t + 1), 10), o = r.replace("p_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
683
- if (u.isTupleType(i)) {
681
+ if (d.isTupleType(i)) {
684
682
  let e = i;
685
- u.getTypeArguments(e).forEach((t, n) => {
686
- N(t, u, b).forEach(({ path: t }) => {
683
+ d.getTypeArguments(e).forEach((t, n) => {
684
+ N(t, d, x).forEach(({ path: t }) => {
687
685
  let r = {
688
686
  __typename: "ReferenceValue",
689
687
  nodeFunctionId: o,
@@ -691,18 +689,18 @@ var O = (t, n) => {
691
689
  inputIndex: n,
692
690
  inputTypeIdentifier: e.target.labeledElementDeclarations?.[n].name.getText()
693
691
  };
694
- t.length > 0 && (r.referencePath = t), C.push(r);
692
+ t.length > 0 && (r.referencePath = t), w.push(r);
695
693
  });
696
694
  });
697
695
  }
698
- } else n.startsWith("flow_") && N(i, u, b).forEach(({ path: e }) => {
696
+ } else n.startsWith("flow_") && N(i, d, x).forEach(({ path: e }) => {
699
697
  let t = {
700
698
  __typename: "ReferenceValue",
701
699
  nodeFunctionId: null
702
700
  };
703
- e.length > 0 && (t.referencePath = e), C.push(t);
701
+ e.length > 0 && (t.referencePath = e), w.push(t);
704
702
  });
705
- }), C;
703
+ }), w;
706
704
  }, F = (t, n) => {
707
705
  if (!t) return [];
708
706
  let r = `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/triangulum",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/code0-tech/triangulum#readme",
6
6
  "bugs": {