@code0-tech/triangulum 0.11.0 → 0.11.1
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 +2 -2
- 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=(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=t.inputIndex
|
|
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(`
|
|
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)})),`${l}\n${u}\n${d}\n\n// --- Flow ---\n${e?`const flow_${M(e.id??``)} = flow(${e.settings?.nodes?.map((e,t)=>`/* @pos undefined ${t} */ ${E(e?.value)}`).join(`, `)??``});`:``}\n${i.filter(e=>e?.id&&!f.has(e.id)&&!p.has(e.id)).map(e=>c(e.id)).join(`
|
|
34
34
|
`)}`}function P(e,t,n){let r=N(e,t,n,!0),i=`index.ts`,a=k(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getTypeChecker(),l=new Map,u=new Map,d=new Map;(e?.nodes?.nodes||[]).forEach(e=>{e?.id&&d.set(M(e.id),e)});let f=e=>{if(c.default.isVariableDeclaration(e)&&e.name.getText().startsWith(`node_`)){let t=e.name.getText().replace(`node_`,``),n=s.getTypeAtLocation(e);if(l.set(t,s.typeToString(n,e,c.default.TypeFormatFlags.NoTruncation)),e.initializer&&c.default.isCallExpression(e.initializer)){let n=s.getResolvedSignature(e.initializer);if(n){let r=n.getParameters().map(t=>{let n=s.getTypeOfSymbolAtLocation(t,e.initializer);return s.typeToString(n,e.initializer,c.default.TypeFormatFlags.NoTruncation)});u.set(t,r)}}}if(c.default.isReturnStatement(e)&&e.expression&&c.default.isCallExpression(e.expression)){let t=e.expression;s.getResolvedSignature(t)}c.default.forEachChild(e,f)};return f(o),{nodes:l,parameters:u}}var F=(e,t)=>{let n=E(e?.value);if(!n)return`any`;let r=`
|
|
35
35
|
${j(t,`unknown`)}
|
package/dist/triangulum.es.js
CHANGED
|
@@ -378,7 +378,7 @@ function E(e, t, n, r = !1) {
|
|
|
378
378
|
if (i.__typename === "ReferenceValue") {
|
|
379
379
|
let t = i;
|
|
380
380
|
if (!t.nodeFunctionId) return `/* @pos ${e} ${n} */ undefined`;
|
|
381
|
-
let r = t.inputIndex
|
|
381
|
+
let r = typeof t.inputIndex == "number" ? `p_${T(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]` : `node_${T(t.nodeFunctionId)}`;
|
|
382
382
|
return t.referencePath?.forEach((e) => {
|
|
383
383
|
r += `?.${e.path}`;
|
|
384
384
|
}), `/* @pos ${e} ${n} */ ${r}`;
|
|
@@ -401,7 +401,7 @@ function E(e, t, n, r = !1) {
|
|
|
401
401
|
if (o.__typename === "ReferenceValue") {
|
|
402
402
|
let t = o;
|
|
403
403
|
if (!t.nodeFunctionId) return `/* @pos ${e} ${a} */ undefined`;
|
|
404
|
-
let n = t.inputIndex
|
|
404
|
+
let n = typeof t.inputIndex == "number" ? `p_${T(t.nodeFunctionId)}_${t.parameterIndex}[${t.inputIndex}]` : `node_${T(t.nodeFunctionId)}`;
|
|
405
405
|
return t.referencePath?.forEach((e) => {
|
|
406
406
|
n += `?.${e.path}`;
|
|
407
407
|
}), `/* @pos ${e} ${a} */ ${n}`;
|