@code0-tech/triangulum 0.5.2 → 0.6.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.
@@ -0,0 +1,9 @@
1
+ import { FunctionDefinition } from '@code0-tech/sagittarius-graphql-types';
2
+ export interface FunctionTypes {
3
+ parameters: string[];
4
+ returnType: string;
5
+ }
6
+ /**
7
+ * Resolves the types of the parameters and the return type of a NodeFunction.
8
+ */
9
+ export declare const getTypesFromFunction: (functionDefinition: FunctionDefinition) => FunctionTypes;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './extraction/getTypeFromValue';
2
2
  export * from './extraction/getTypeVariant';
3
3
  export * from './extraction/getValueFromType';
4
4
  export * from './extraction/getTypesFromNode';
5
+ export * from './extraction/getTypesFromFunction';
5
6
  export * from './suggestion/getNodeSuggestions';
6
7
  export * from './suggestion/getReferenceSuggestions';
7
8
  export * from './suggestion/getValueSuggestions';
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("typescript");function R(){return R=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},R.apply(null,arguments)}var Y=!1;try{Y=typeof localStorage<"u"}catch{}var X=typeof process<"u",ee=Y&&typeof localStorage.getItem=="function"&&localStorage.getItem("DEBUG")||X&&process.env.DEBUG,J=ee?console.log:function(t){return""};function te(t,n,i,r,g){r===void 0&&(r={});var l=R({},q(i),r),p=re(t,n,l,i,g),u=p.languageServiceHost,c=p.updateFile,d=p.deleteFile,a=i.createLanguageService(u),F=a.getCompilerOptionsDiagnostics();if(F.length){var s=G(t,r,i);throw new Error(i.formatDiagnostics(F,s.compilerHost))}return{name:"vfs",sys:t,languageService:a,getSourceFile:function(e){var o;return(o=a.getProgram())==null?void 0:o.getSourceFile(e)},createFile:function(e,o){c(i.createSourceFile(e,o,l.target,!1))},updateFile:function(e,o,m){var T=a.getProgram().getSourceFile(e);if(!T)throw new Error("Did not find a source file for "+e);var v=T.text,S=m??i.createTextSpan(0,v.length),C=v.slice(0,S.start)+o+v.slice(S.start+S.length),w=i.updateSourceFile(T,C,{span:S,newLength:o.length});c(w)},deleteFile:function(e){var o=a.getProgram().getSourceFile(e);o&&d(o)}}}function I(t){throw new Error("Method '"+t+"' is not implemented.")}function k(t,n){return function(){for(var i=arguments.length,r=new Array(i),g=0;g<i;g++)r[g]=arguments[g];var l=n.apply(void 0,r),p=typeof l=="string"?l.slice(0,80)+"...":l;return J.apply(void 0,["> "+t].concat(r)),J("< "+p),l}}var q=function(n){return R({},n.getDefaultCompilerOptions(),{jsx:n.JsxEmit.React,strict:!0,esModuleInterop:!0,module:n.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0},n.versionMajorMinor&&Number(n.versionMajorMinor.split(".")[0])>=6?{ignoreDeprecations:"6.0"}:{moduleResolution:n.ModuleResolutionKind.NodeJs})},K=function(n){return n.replace("/","/lib.").toLowerCase()};function ne(t){return{args:[],createDirectory:function(){return I("createDirectory")},directoryExists:k("directoryExists",function(n){return Array.from(t.keys()).some(function(i){return i.startsWith(n)})}),exit:function(){return I("exit")},fileExists:k("fileExists",function(n){return t.has(n)||t.has(K(n))}),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return I("getExecutingFilePath")},readDirectory:k("readDirectory",function(n){return n==="/"?Array.from(t.keys()):[]}),readFile:k("readFile",function(n){var i;return(i=t.get(n))!=null?i:t.get(K(n))}),resolvePath:function(i){return i},newLine:`
2
- `,useCaseSensitiveFileNames:!0,write:function(){return I("write")},writeFile:function(i,r){t.set(i,r)},deleteFile:function(i){t.delete(i)}}}function G(t,n,i){var r=new Map,g=function(u){return r.set(u.fileName,u),u},l={compilerHost:R({},t,{getCanonicalFileName:function(u){return u},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(n)},getNewLine:function(){return t.newLine},getSourceFile:function(u,c){var d;return r.get(u)||g(i.createSourceFile(u,t.readFile(u),(d=c??n.target)!=null?d:q(i).target,!1))},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(u){var c=r.has(u.fileName);return t.writeFile(u.fileName,u.text),r.set(u.fileName,u),c},deleteFile:function(u){var c=r.has(u.fileName);return r.delete(u.fileName),t.deleteFile(u.fileName),c}};return l}function re(t,n,i,r,g){var l=[].concat(n),p=G(t,i,r),u=p.compilerHost,c=p.updateFile,d=p.deleteFile,a=new Map,F=0,s=R({},u,{getProjectVersion:function(){return F.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return g},getScriptFileNames:function(){return l.slice()},getScriptSnapshot:function(o){var m=t.readFile(o);if(m&&typeof m=="string")return r.ScriptSnapshot.fromString(m)},getScriptVersion:function(o){return a.get(o)||"0"},writeFile:t.writeFile}),y={languageServiceHost:s,updateFile:function(o){F++,a.set(o.fileName,F.toString()),l.includes(o.fileName)||l.push(o.fileName),c(o)},deleteFile:function(o){F++,a.set(o.fileName,F.toString());var m=l.indexOf(o.fileName);m!==-1&&l.splice(m,1),d(o)}};return y}const Q=(t,n,i)=>{if(!t)return{parameters:[],returnType:"any"};const r=t.id||"temp_node_id",g={...t,id:r,parameters:{...t.parameters,nodes:t.parameters?.nodes?.map(e=>e?.value?e:{...e,value:null})||[]}},l=r+"_params",p={...g,id:l,parameters:{...g.parameters,nodes:g.parameters.nodes.map(e=>e.value?.__typename==="LiteralValue"&&e.value.value!==null&&typeof e.value.value!="object"?{...e,value:null}:e)}},c=oe({nodes:{__typename:"NodeFunctionConnection",nodes:[g,p]}},n,i),d=L(r),a=L(l),F=c.parameters.get(d)||[],s=c.parameters.get(a)||[];return{parameters:F.map((e,o)=>{const m=s[o];return m&&m!=="any"&&m!=="unknown"?m:e}),returnType:c.nodes.get(d)||"any"}};var j=(t=>(t[t.PRIMITIVE=0]="PRIMITIVE",t[t.TYPE=1]="TYPE",t[t.ARRAY=2]="ARRAY",t[t.OBJECT=3]="OBJECT",t[t.NODE=4]="NODE",t))(j||{});const U=(t,n)=>{const r=`
3
- ${O(n)}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("typescript");function R(){return R=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var i=arguments[n];for(var a in i)({}).hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t},R.apply(null,arguments)}var Y=!1;try{Y=typeof localStorage<"u"}catch{}var X=typeof process<"u",ee=Y&&typeof localStorage.getItem=="function"&&localStorage.getItem("DEBUG")||X&&process.env.DEBUG,J=ee?console.log:function(t){return""};function te(t,n,i,a,c){a===void 0&&(a={});var g=R({},q(i),a),f=re(t,n,g,i,c),p=f.languageServiceHost,u=f.updateFile,m=f.deleteFile,r=i.createLanguageService(p),d=r.getCompilerOptionsDiagnostics();if(d.length){var o=G(t,a,i);throw new Error(i.formatDiagnostics(d,o.compilerHost))}return{name:"vfs",sys:t,languageService:r,getSourceFile:function(e){var s;return(s=r.getProgram())==null?void 0:s.getSourceFile(e)},createFile:function(e,s){u(i.createSourceFile(e,s,g.target,!1))},updateFile:function(e,s,l){var T=r.getProgram().getSourceFile(e);if(!T)throw new Error("Did not find a source file for "+e);var h=T.text,v=l??i.createTextSpan(0,h.length),N=h.slice(0,v.start)+s+h.slice(v.start+v.length),D=i.updateSourceFile(T,N,{span:v,newLength:s.length});u(D)},deleteFile:function(e){var s=r.getProgram().getSourceFile(e);s&&m(s)}}}function O(t){throw new Error("Method '"+t+"' is not implemented.")}function I(t,n){return function(){for(var i=arguments.length,a=new Array(i),c=0;c<i;c++)a[c]=arguments[c];var g=n.apply(void 0,a),f=typeof g=="string"?g.slice(0,80)+"...":g;return J.apply(void 0,["> "+t].concat(a)),J("< "+f),g}}var q=function(n){return R({},n.getDefaultCompilerOptions(),{jsx:n.JsxEmit.React,strict:!0,esModuleInterop:!0,module:n.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0},n.versionMajorMinor&&Number(n.versionMajorMinor.split(".")[0])>=6?{ignoreDeprecations:"6.0"}:{moduleResolution:n.ModuleResolutionKind.NodeJs})},K=function(n){return n.replace("/","/lib.").toLowerCase()};function ne(t){return{args:[],createDirectory:function(){return O("createDirectory")},directoryExists:I("directoryExists",function(n){return Array.from(t.keys()).some(function(i){return i.startsWith(n)})}),exit:function(){return O("exit")},fileExists:I("fileExists",function(n){return t.has(n)||t.has(K(n))}),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return O("getExecutingFilePath")},readDirectory:I("readDirectory",function(n){return n==="/"?Array.from(t.keys()):[]}),readFile:I("readFile",function(n){var i;return(i=t.get(n))!=null?i:t.get(K(n))}),resolvePath:function(i){return i},newLine:`
2
+ `,useCaseSensitiveFileNames:!0,write:function(){return O("write")},writeFile:function(i,a){t.set(i,a)},deleteFile:function(i){t.delete(i)}}}function G(t,n,i){var a=new Map,c=function(p){return a.set(p.fileName,p),p},g={compilerHost:R({},t,{getCanonicalFileName:function(p){return p},getDefaultLibFileName:function(){return"/"+i.getDefaultLibFileName(n)},getNewLine:function(){return t.newLine},getSourceFile:function(p,u){var m;return a.get(p)||c(i.createSourceFile(p,t.readFile(p),(m=u??n.target)!=null?m:q(i).target,!1))},useCaseSensitiveFileNames:function(){return t.useCaseSensitiveFileNames}}),updateFile:function(p){var u=a.has(p.fileName);return t.writeFile(p.fileName,p.text),a.set(p.fileName,p),u},deleteFile:function(p){var u=a.has(p.fileName);return a.delete(p.fileName),t.deleteFile(p.fileName),u}};return g}function re(t,n,i,a,c){var g=[].concat(n),f=G(t,i,a),p=f.compilerHost,u=f.updateFile,m=f.deleteFile,r=new Map,d=0,o=R({},p,{getProjectVersion:function(){return d.toString()},getCompilationSettings:function(){return i},getCustomTransformers:function(){return c},getScriptFileNames:function(){return g.slice()},getScriptSnapshot:function(s){var l=t.readFile(s);if(l&&typeof l=="string")return a.ScriptSnapshot.fromString(l)},getScriptVersion:function(s){return r.get(s)||"0"},writeFile:t.writeFile}),y={languageServiceHost:o,updateFile:function(s){d++,r.set(s.fileName,d.toString()),g.includes(s.fileName)||g.push(s.fileName),u(s)},deleteFile:function(s){d++,r.set(s.fileName,d.toString());var l=g.indexOf(s.fileName);l!==-1&&g.splice(l,1),m(s)}};return y}const Q=(t,n,i)=>{if(!t)return{parameters:[],returnType:"any"};const a=t.id||"temp_node_id",c={...t,id:a,parameters:{...t.parameters,nodes:t.parameters?.nodes?.map(e=>e?.value?e:{...e,value:null})||[]}},g=a+"_params",f={...c,id:g,parameters:{...c.parameters,nodes:c.parameters.nodes.map(e=>e.value?.__typename==="LiteralValue"&&e.value.value!==null&&typeof e.value.value!="object"?{...e,value:null}:e)}},u=oe({nodes:{__typename:"NodeFunctionConnection",nodes:[c,f]}},n,i),m=A(a),r=A(g),d=u.parameters.get(m)||[],o=u.parameters.get(r)||[];return{parameters:d.map((e,s)=>{const l=o[s];return l&&l!=="any"&&l!=="unknown"?l:e}),returnType:u.nodes.get(m)||"any"}};var j=(t=>(t[t.PRIMITIVE=0]="PRIMITIVE",t[t.TYPE=1]="TYPE",t[t.ARRAY=2]="ARRAY",t[t.OBJECT=3]="OBJECT",t[t.NODE=4]="NODE",t))(j||{});const H=(t,n)=>{const a=`
3
+ ${k(n)}
4
4
  type TargetType = ${t};
5
5
  const val: TargetType = {} as any;
6
- `,g="index.ts",l=A(g,r),p=l.getSourceFile(g),c=l.languageService.getProgram().getTypeChecker();let d=1;const a=F=>{if(f.isVariableDeclaration(F)&&F.name.getText()==="val"){const s=c.getTypeAtLocation(F);s.getCallSignatures().length>0?d=4:c.isArrayType(s)?d=2:s.isStringLiteral()||s.isNumberLiteral()||(s.getFlags()&(f.TypeFlags.String|f.TypeFlags.Number|f.TypeFlags.Boolean|f.TypeFlags.EnumLiteral|f.TypeFlags.BigInt|f.TypeFlags.ESSymbol))!==0?d=0:s.isClassOrInterface()||(s.getFlags()&f.TypeFlags.Object)!==0?d=3:d=1}f.forEachChild(F,a)};return a(p),d},ie=`
6
+ `;console.log(a);const c="index.ts",g=L(c,a),f=g.getSourceFile(c),u=g.languageService.getProgram().getTypeChecker();let m=1;const r=d=>{if(F.isVariableDeclaration(d)&&d.name.getText()==="val"){const o=u.getTypeAtLocation(d);o.getCallSignatures().length>0?m=4:u.isArrayType(o)?m=2:o.isStringLiteral()||o.isNumberLiteral()||(o.getFlags()&(F.TypeFlags.String|F.TypeFlags.Number|F.TypeFlags.Boolean|F.TypeFlags.EnumLiteral|F.TypeFlags.BigInt|F.TypeFlags.ESSymbol))!==0?m=0:o.isClassOrInterface()||(o.getFlags()&F.TypeFlags.Object)!==0?m=3:m=1}F.forEachChild(d,r)};return r(f),m},ie=`
7
7
  interface Array<T> {
8
8
  [n: number]: T;
9
9
  length: number;
@@ -19,39 +19,39 @@
19
19
  interface RegExp { }
20
20
  type Record<K extends keyof any, T> = { [P in K]: T; };
21
21
  type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
22
- `;function A(t,n){const i=new Map;i.set(t,n),i.set("lib.codezero.d.ts",ie);const r=ne(i);return te(r,[t,"lib.codezero.d.ts"],f,ae)}const ae={target:f.ScriptTarget.Latest,lib:["lib.codezero.d.ts"],noEmit:!0,strictNullChecks:!0};function O(t){const n=Array.from(new Set(t?.flatMap(r=>r.genericKeys||[]))).map(r=>`type ${r} = any;`).join(`
23
- `),i=t?.map(r=>`type ${r.identifier}${(r.genericKeys?.length??0)>0?`<${r.genericKeys?.join(",")}>`:""} = ${r.type};`).join(`
24
- `);return`${n}
25
- ${i}`}const L=t=>t.replace(/[^a-zA-Z0-9]/g,"_");function z(t,n,i,r=!1){const g=t?.nodes?.nodes||[],l=new Map(n?.map(e=>[e.identifier,e])),p=new Set,u=(e,o,m)=>{const T=g.find(P=>P?.id===e);if(!T||!T.functionDefinition?.identifier)return"undefined";const S=(T.parameters?.nodes||[]).map((P,x)=>{const E=P.value;if(!E)return r?`/* @pos ${e} ${x} */ {}`:`/* @pos ${e} ${x} */ undefined`;if(E.__typename==="ReferenceValue"){const $=E;if(!$.nodeFunctionId)return`/* @pos ${e} ${x} */ undefined`;let N=$.inputIndex!==void 0?`p_${L($.nodeFunctionId)}_${$.parameterIndex}[${$.inputIndex}]`:`node_${L($.nodeFunctionId)}`;return $.referencePath?.forEach(h=>{N+=`?.${h.path}`}),`/* @pos ${e} ${x} */ ${N}`}return E.__typename==="LiteralValue"?`/* @pos ${e} ${x} */ ${JSON.stringify(E.value)}`:E.__typename==="NodeFunctionIdWrapper"?u(E.id,e,x):r?`/* @pos ${e} ${x} */ ({} as any)`:`/* @pos ${e} ${x} */ undefined`}).join(", "),w=`${`fn_${T.functionDefinition.identifier.replace(/::/g,"_")}`}(${S})`;return o!==void 0&&m!==void 0?`${w}`:w},c=(e,o="")=>{if(p.has(e))return"";const m=g.find(N=>N?.id===e);if(!m||!m.functionDefinition)return"";if(p.add(e),!l.get(m.functionDefinition.identifier))return`${o}// Error: Function ${m.functionDefinition.identifier} not found
26
- `;let v={parameters:[]};r||(v=Q(m,n,i));const C=(m.parameters?.nodes||[]).map((N,h)=>{const b=N.value;if(!b)return r?`/* @pos ${e} ${h} */ {}`:`/* @pos ${e} ${h} */ undefined`;if(b.__typename==="ReferenceValue"){const _=b;if(!_.nodeFunctionId)return`/* @pos ${e} ${h} */ undefined`;let D=_.inputIndex!==void 0?`p_${L(_.nodeFunctionId)}_${_.parameterIndex}[${_.inputIndex}]`:`node_${L(_.nodeFunctionId)}`;return _.referencePath?.forEach(V=>{D+=`?.${V.path}`}),`/* @pos ${e} ${h} */ ${D}`}if(b.__typename==="LiteralValue")return`/* @pos ${e} ${h} */ ${JSON.stringify(b.value)}`;if(b.__typename==="NodeFunctionIdWrapper"){const _=b;if(r){const D=`p_${L(e)}_${h}`,V=c(_.id,o+" ");return`/* @pos ${e} ${h} */ (...${D}) => {
27
- ${V}${o}}`}else{const D=v.parameters[h];if(D?U(D,i)===j.NODE:!1){const M=`p_${L(e)}_${h}`,H=c(_.id,o+" ");return`/* @pos ${e} ${h} */ (...${M}) => {
28
- ${H}${o}}`}else{const M=u(_.id,e,h);return`/* @pos ${e} ${h} */ ${M}`}}}return r?`/* @pos ${e} ${h} */ {}`:`/* @pos ${e} ${h} */ undefined`}).join(", "),w=`node_${L(m.id)}`,P=`fn_${m?.functionDefinition?.identifier?.replace(/::/g,"_")}`,x=C.includes("undefined"),E=m.functionDefinition.identifier==="std::control::return";let $=`${o}${E?"return ":`const ${w} = `}${P}(${C}) ;
29
- `;return m.nextNodeId&&($+=c(m.nextNodeId,o)),$},d=O(i),a=n?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,"_")}${e.signature}`).join(`
30
- `),F=new Set(g.map(e=>e?.nextNodeId).filter(e=>!!e)),s=new Set;g.forEach(e=>e?.parameters?.nodes?.forEach(o=>{o?.value?.__typename==="NodeFunctionIdWrapper"&&o.value.id&&s.add(o.value.id)}));const y=g.filter(e=>e?.id&&!F.has(e.id)&&!s.has(e.id)).map(e=>c(e.id)).join(`
31
- `);return`${d}
32
- ${a}
22
+ `;function L(t,n){const i=new Map;i.set(t,n),i.set("lib.codezero.d.ts",ie);const a=ne(i);return te(a,[t,"lib.codezero.d.ts"],F,ae)}const ae={target:F.ScriptTarget.Latest,lib:["lib.codezero.d.ts"],noEmit:!0,strictNullChecks:!0};function k(t,n="any"){const i=Array.from(new Set(t?.flatMap(c=>c.genericKeys||[]))).map(c=>`type ${c} = ${n};`).join(`
23
+ `),a=t?.map(c=>`type ${c.identifier}${(c.genericKeys?.length??0)>0?`<${c.genericKeys?.join(",")}>`:""} = ${c.type};`).join(`
24
+ `);return`${i}
25
+ ${a}`}const A=t=>t.replace(/[^a-zA-Z0-9]/g,"_");function U(t,n,i,a=!1){const c=t?.nodes?.nodes||[],g=new Map(n?.map(e=>[e.identifier,e])),f=new Set,p=(e,s,l)=>{const T=c.find(E=>E?.id===e);if(!T||!T.functionDefinition?.identifier)return"undefined";const v=(T.parameters?.nodes||[]).map((E,S)=>{const w=E.value;if(!w)return a?`/* @pos ${e} ${S} */ {}`:`/* @pos ${e} ${S} */ undefined`;if(w.__typename==="ReferenceValue"){const _=w;if(!_.nodeFunctionId)return`/* @pos ${e} ${S} */ undefined`;let C=_.inputIndex!==void 0?`p_${A(_.nodeFunctionId)}_${_.parameterIndex}[${_.inputIndex}]`:`node_${A(_.nodeFunctionId)}`;return _.referencePath?.forEach($=>{C+=`?.${$.path}`}),`/* @pos ${e} ${S} */ ${C}`}return w.__typename==="LiteralValue"?`/* @pos ${e} ${S} */ ${JSON.stringify(w.value)}`:w.__typename==="NodeFunctionIdWrapper"?p(w.id,e,S):a?`/* @pos ${e} ${S} */ ({} as any)`:`/* @pos ${e} ${S} */ undefined`}).join(", "),D=`${`fn_${T.functionDefinition.identifier.replace(/::/g,"_")}`}(${v})`;return s!==void 0&&l!==void 0?`${D}`:D},u=(e,s="")=>{if(f.has(e))return"";const l=c.find(C=>C?.id===e);if(!l||!l.functionDefinition)return"";if(f.add(e),!g.get(l.functionDefinition.identifier))return`${s}// Error: Function ${l.functionDefinition.identifier} not found
26
+ `;let h={parameters:[]};a||(h=Q(l,n,i));const N=(l.parameters?.nodes||[]).map((C,$)=>{const x=C.value;if(!x)return a?`/* @pos ${e} ${$} */ {}`:`/* @pos ${e} ${$} */ undefined`;if(x.__typename==="ReferenceValue"){const b=x;if(!b.nodeFunctionId)return`/* @pos ${e} ${$} */ undefined`;let P=b.inputIndex!==void 0?`p_${A(b.nodeFunctionId)}_${b.parameterIndex}[${b.inputIndex}]`:`node_${A(b.nodeFunctionId)}`;return b.referencePath?.forEach(V=>{P+=`?.${V.path}`}),`/* @pos ${e} ${$} */ ${P}`}if(x.__typename==="LiteralValue")return`/* @pos ${e} ${$} */ ${JSON.stringify(x.value)}`;if(x.__typename==="NodeFunctionIdWrapper"){const b=x;if(a){const P=`p_${A(e)}_${$}`,V=u(b.id,s+" ");return`/* @pos ${e} ${$} */ (...${P}) => {
27
+ ${V}${s}}`}else{const P=h.parameters[$];if(P?H(P,i)===j.NODE:!1){const M=`p_${A(e)}_${$}`,B=u(b.id,s+" ");return`/* @pos ${e} ${$} */ (...${M}) => {
28
+ ${B}${s}}`}else{const M=p(b.id,e,$);return`/* @pos ${e} ${$} */ ${M}`}}}return a?`/* @pos ${e} ${$} */ {}`:`/* @pos ${e} ${$} */ undefined`}).join(", "),D=`node_${A(l.id)}`,E=`fn_${l?.functionDefinition?.identifier?.replace(/::/g,"_")}`,S=N.includes("undefined"),w=l.functionDefinition.identifier==="std::control::return";let _=`${s}${w?"return ":`const ${D} = `}${E}(${N}) ;
29
+ `;return l.nextNodeId&&(_+=u(l.nextNodeId,s)),_},m=k(i),r=n?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,"_")}${e.signature}`).join(`
30
+ `),d=new Set(c.map(e=>e?.nextNodeId).filter(e=>!!e)),o=new Set;c.forEach(e=>e?.parameters?.nodes?.forEach(s=>{s?.value?.__typename==="NodeFunctionIdWrapper"&&s.value.id&&o.add(s.value.id)}));const y=c.filter(e=>e?.id&&!d.has(e.id)&&!o.has(e.id)).map(e=>u(e.id)).join(`
31
+ `);return`${m}
32
+ ${r}
33
33
 
34
34
  // --- Flow ---
35
- ${y}`}function oe(t,n,i){const r=z(t,n,i,!0),g="index.ts",l=A(g,r),p=l.getSourceFile(g),c=l.languageService.getProgram().getTypeChecker(),d=new Map,a=new Map,F=new Map;(t?.nodes?.nodes||[]).forEach(e=>{e?.id&&F.set(L(e.id),e)});const y=e=>{if(f.isVariableDeclaration(e)&&e.name.getText().startsWith("node_")){const o=e.name.getText().replace("node_",""),m=c.getTypeAtLocation(e);if(d.set(o,c.typeToString(m,e,f.TypeFormatFlags.NoTruncation)),e.initializer&&f.isCallExpression(e.initializer)){const T=c.getResolvedSignature(e.initializer);if(T){const v=T.getParameters().map(S=>{const C=c.getTypeOfSymbolAtLocation(S,e.initializer);return c.typeToString(C,e.initializer,f.TypeFormatFlags.NoTruncation)});a.set(o,v)}}}if(f.isReturnStatement(e)&&e.expression&&f.isCallExpression(e.expression)){const o=e.expression;c.getResolvedSignature(o)}f.forEachChild(e,y)};return y(p),{nodes:d,parameters:a}}const se=t=>{const i=`const tempValue = ${JSON.stringify(t?.value)??"any"};`,r="index.ts",g=A(r,i),l=g.getSourceFile(r),u=g.languageService.getProgram().getTypeChecker();let c="any";const d=a=>{if(f.isVariableDeclaration(a)&&a.name.getText()==="tempValue"){const F=u.getTypeAtLocation(a);c=u.typeToString(F,a,f.TypeFormatFlags.NoTruncation|f.TypeFormatFlags.UseFullyQualifiedType)}f.forEachChild(a,d)};return d(l),c},ce=(t,n)=>{const i=`
36
- ${O(n)}
35
+ ${y}`}function oe(t,n,i){const a=U(t,n,i,!0),c="index.ts",g=L(c,a),f=g.getSourceFile(c),u=g.languageService.getProgram().getTypeChecker(),m=new Map,r=new Map,d=new Map;(t?.nodes?.nodes||[]).forEach(e=>{e?.id&&d.set(A(e.id),e)});const y=e=>{if(F.isVariableDeclaration(e)&&e.name.getText().startsWith("node_")){const s=e.name.getText().replace("node_",""),l=u.getTypeAtLocation(e);if(m.set(s,u.typeToString(l,e,F.TypeFormatFlags.NoTruncation)),e.initializer&&F.isCallExpression(e.initializer)){const T=u.getResolvedSignature(e.initializer);if(T){const h=T.getParameters().map(v=>{const N=u.getTypeOfSymbolAtLocation(v,e.initializer);return u.typeToString(N,e.initializer,F.TypeFormatFlags.NoTruncation)});r.set(s,h)}}}if(F.isReturnStatement(e)&&e.expression&&F.isCallExpression(e.expression)){const s=e.expression;u.getResolvedSignature(s)}F.forEachChild(e,y)};return y(f),{nodes:m,parameters:r}}const se=t=>{const i=`const tempValue = ${JSON.stringify(t?.value)??"any"};`,a="index.ts",c=L(a,i),g=c.getSourceFile(a),p=c.languageService.getProgram().getTypeChecker();let u="any";const m=r=>{if(F.isVariableDeclaration(r)&&r.name.getText()==="tempValue"){const d=p.getTypeAtLocation(r);u=p.typeToString(d,r,F.TypeFormatFlags.NoTruncation|F.TypeFormatFlags.UseFullyQualifiedType)}F.forEachChild(r,m)};return m(g),u},ce=(t,n)=>{const i=`
36
+ ${k(n)}
37
37
  type Target = ${t};
38
- `,r="index.ts",g=A(r,i),l=g.getSourceFile(r),u=g.languageService.getProgram().getTypeChecker(),c=l.statements.find(s=>f.isTypeAliasDeclaration(s)&&s.name.text==="Target");if(!c)return{__typename:"LiteralValue",value:null};const d=u.getTypeAtLocation(c.type),a=(s,y,e=new Set)=>{if(e.has(s))return null;e.add(s);const o=s.getFlags();if(s.isUnion()){if(y.type,f.isTypeAliasDeclaration(y)&&y.type&&f.isUnionTypeNode(y.type)){const v=u.getTypeFromTypeNode(y.type.types[0]);return a(v,y,e)}const m=s.types.filter(v=>{const S=v.getFlags();return!(S&f.TypeFlags.Undefined)&&!(S&f.TypeFlags.Null)}),T=m.length>0?m[0]:s.types[0];return a(T,y,e)}if(o&f.TypeFlags.StringLiteral)return s.value;if(o&f.TypeFlags.String)return"";if(o&f.TypeFlags.NumberLiteral)return s.value;if(o&f.TypeFlags.Number)return 0;if(o&f.TypeFlags.BooleanLiteral)return s.intrinsicName==="true";if(o&f.TypeFlags.Boolean)return!1;if(u.isArrayType(s)){const T=s.typeArguments?.[0]||u.getAnyType();return a(T,y,e)==="null"?[a(T,y,e)]:[]}if(s.isClassOrInterface()||o&f.TypeFlags.Object||s.getProperties().length>0){const m={};return s.getProperties().forEach(v=>{const S=u.getTypeOfSymbolAtLocation(v,y);S&&(m[v.getName()]=a(S,y,e))}),m}return null};return{__typename:"LiteralValue",value:a(d,c)}},le=(t,n,i)=>{let r=n;const g=t?U(t,i):null;if(t&&n&&g!==j.NODE){let l=function(y){const e=y.trim().match(/^<([^>]+)>/);return e?e[1].split(",").map(o=>o.trim()).filter(Boolean).length:0};const p=`
39
- ${O(i)}
38
+ `,a="index.ts",c=L(a,i),g=c.getSourceFile(a),p=c.languageService.getProgram().getTypeChecker(),u=g.statements.find(o=>F.isTypeAliasDeclaration(o)&&o.name.text==="Target");if(!u)return{__typename:"LiteralValue",value:null};const m=p.getTypeAtLocation(u.type),r=(o,y,e=new Set)=>{if(e.has(o))return null;e.add(o);const s=o.getFlags();if(o.isUnion()){if(y.type,F.isTypeAliasDeclaration(y)&&y.type&&F.isUnionTypeNode(y.type)){const h=p.getTypeFromTypeNode(y.type.types[0]);return r(h,y,e)}const l=o.types.filter(h=>{const v=h.getFlags();return!(v&F.TypeFlags.Undefined)&&!(v&F.TypeFlags.Null)}),T=l.length>0?l[0]:o.types[0];return r(T,y,e)}if(s&F.TypeFlags.StringLiteral)return o.value;if(s&F.TypeFlags.String)return"";if(s&F.TypeFlags.NumberLiteral)return o.value;if(s&F.TypeFlags.Number)return 0;if(s&F.TypeFlags.BooleanLiteral)return o.intrinsicName==="true";if(s&F.TypeFlags.Boolean)return!1;if(p.isArrayType(o)){const T=o.typeArguments?.[0]||p.getAnyType(),h=r(T,y,e);return h!==null?[h]:[]}if(o.isClassOrInterface()||s&F.TypeFlags.Object||o.getProperties().length>0){const l={};return o.getProperties().forEach(h=>{const v=p.getTypeOfSymbolAtLocation(h,y);v&&(l[h.getName()]=r(v,y,e))}),l}return null};return{__typename:"LiteralValue",value:r(m,u)}},le=t=>{const n=t.signature;if(!n)return{parameters:[],returnType:"any"};let i=0;if(n.trim().startsWith("<")){let r=0;for(let d=0;d<n.length;d++){const o=n[d];if(o==="<")r++;else if(o===">"&&(r--,r===0)){i=d+1;break}}}const a=n.indexOf("(",i);if(a===-1)return{parameters:[],returnType:"any"};let c=-1,g=0;for(let r=a;r<n.length;r++){const d=n[r];if(d==="(")g++;else if(d===")"&&(g--,g===0)){c=r;break}}if(c===-1)return{parameters:[],returnType:"any"};const f=n.substring(a+1,c);let p=n.substring(c+1).trim();p.startsWith(":")&&(p=p.substring(1).trim());const u=p||"void",m=[];if(f.trim()){let r="",d=0,o=0,y=0,e=0;const s=l=>{let T=-1,h=0,v=0,N=0,D=0;for(let E=0;E<l.length;E++){const S=l[E];if(S==="{")h++;else if(S==="}")h--;else if(S==="[")v++;else if(S==="]")v--;else if(S==="(")N++;else if(S===")")N--;else if(S==="<")D++;else if(S===">")D--;else if(S===":"&&h===0&&v===0&&N===0&&D===0){T=E;break}}T!==-1?m.push(l.substring(T+1).trim()):m.push("any")};for(const l of f){if(l==="(")d++;else if(l===")")d--;else if(l==="<")o++;else if(l===">")o--;else if(l==="{")y++;else if(l==="}")y--;else if(l==="[")e++;else if(l==="]")e--;else if(l===","&&d===0&&o===0&&y===0&&e===0){s(r.trim()),r="";continue}r+=l}r.trim()&&s(r.trim())}return{parameters:m,returnType:u}},ue=(t,n,i)=>{let a=n;const c=t?H(t,i):null;if(t&&n&&c!==j.NODE){let g=function(y){const e=y.trim().match(/^<([^>]+)>/);return e?e[1].split(",").map(s=>s.trim()).filter(Boolean).length:0};const f=`
39
+ ${k(i)}
40
40
  type TargetType = ${t};
41
41
  ${n?.map((y,e)=>`
42
42
  declare function Fu${e}${y.signature};
43
- type F${e} = ReturnType<typeof Fu${e}${l(y.signature)>0?`<${Array(l(y.signature)).fill("any").join(", ")}>`:""}>;
43
+ type F${e} = ReturnType<typeof Fu${e}${g(y.signature)>0?`<${Array(g(y.signature)).fill("any").join(", ")}>`:""}>;
44
44
  `).join(`
45
45
  `)}
46
46
  ${n?.map((y,e)=>`const check${e}: TargetType = {} as F${e};`).join(`
47
47
  `)}
48
- `,u="index.ts",c=A(u,p),d=c.getSourceFile(u),F=c.languageService.getProgram().getSemanticDiagnostics(),s=new Set;F.forEach(y=>{y.file===d&&y.start!==void 0&&s.add(d.getLineAndCharacterOfPosition(y.start).line)}),r=n.filter((y,e)=>{const o=`const check${e}: TargetType = {} as F${e};`,T=p.split(`
49
- `).findIndex(v=>v.includes(o));return T!==-1&&!s.has(T)})}return r?.map(l=>({__typename:"NodeFunction",id:"gid://sagittarius/NodeFunction/1",functionDefinition:{__typename:"FunctionDefinition",id:l.id,identifier:l.identifier},parameters:{__typename:"NodeParameterConnection",nodes:(l.parameterDefinitions?.nodes||[]).map(p=>({__typename:"NodeParameter",parameterDefinition:{__typename:"ParameterDefinition",id:p?.id,identifier:p?.identifier},value:null}))}})).filter(l=>l!==null)??[]},ue=(t,n,i,r,g)=>{const l=z(t,r,g,!0),p="index.ts",u=A(p,l),c=u.getSourceFile(p),a=u.languageService.getProgram().getTypeChecker(),F=c.getFullText(),s=`/* @pos ${n} ${i} */`,e=F.indexOf(s)+s.length;function o($,N){let h=$;return f.forEachChild($,b=>{b.getStart(c,!0)<=N&&b.getEnd()>=N&&(h=o(b,N))}),h}const T=o(c,e);let v;if(f.isCallExpression(T)&&(v=T),!v)return[];const S=a.getResolvedSignature(v);if(!S)return[];const C=S.getParameters(),w=C[i]||C[C.length-1],P=a.getTypeOfSymbolAtLocation(w,T),x=a.getSymbolsInScope(T,f.SymbolFlags.Variable),E=[];return x.forEach($=>{const N=$.getName();if(!N.startsWith("node_")&&!N.startsWith("p_"))return;const h=$.valueDeclaration||$.declarations?.[0];if(!h||h.getEnd()>=e)return;const b=a.getTypeOfSymbolAtLocation($,T);if(N.startsWith("node_")){if((b.flags&f.TypeFlags.Void)===0&&a.isTypeAssignableTo(b,P)){const _=N.replace("node_","").replace(/___/g,"://").replace(/__/g,"/").replace(/_/g,"/");E.push({__typename:"ReferenceValue",nodeFunctionId:_})}}else if(N.startsWith("p_")){const _=N.replace("p_",""),D=_.lastIndexOf("_"),V=_.substring(0,D),M=parseInt(_.substring(D+1),10),H=V.replace("p_","").replace(/___/g,"://").replace(/__/g,"/").replace(/_/g,"/");if(a.isTupleType(b)){const B=b;a.getTypeArguments(B).forEach((Z,W)=>{a.isTypeAssignableTo(Z,P)&&E.push({__typename:"ReferenceValue",nodeFunctionId:H,parameterIndex:isNaN(M)?0:M,inputIndex:W,inputTypeIdentifier:B.target.labeledElementDeclarations?.[W].name.getText()})})}}}),E},ge=(t,n)=>{if(!t)return[];const i=`
50
- ${O(n)}
48
+ `,p="index.ts",u=L(p,f),m=u.getSourceFile(p),d=u.languageService.getProgram().getSemanticDiagnostics(),o=new Set;d.forEach(y=>{y.file===m&&y.start!==void 0&&o.add(m.getLineAndCharacterOfPosition(y.start).line)}),a=n.filter((y,e)=>{const s=`const check${e}: TargetType = {} as F${e};`,T=f.split(`
49
+ `).findIndex(h=>h.includes(s));return T!==-1&&!o.has(T)})}return a?.map(g=>({__typename:"NodeFunction",id:"gid://sagittarius/NodeFunction/1",functionDefinition:{__typename:"FunctionDefinition",id:g.id,identifier:g.identifier},parameters:{__typename:"NodeParameterConnection",nodes:(g.parameterDefinitions?.nodes||[]).map(f=>({__typename:"NodeParameter",parameterDefinition:{__typename:"ParameterDefinition",id:f?.id,identifier:f?.identifier},value:null}))}})).filter(g=>g!==null)??[]},ge=(t,n,i,a,c)=>{const g=U(t,a,c,!0),f="index.ts",p=L(f,g),u=p.getSourceFile(f),r=p.languageService.getProgram().getTypeChecker(),d=u.getFullText(),o=`/* @pos ${n} ${i} */`,e=d.indexOf(o)+o.length;function s(_,C){let $=_;return F.forEachChild(_,x=>{x.getStart(u,!0)<=C&&x.getEnd()>=C&&($=s(x,C))}),$}const T=s(u,e);let h;if(F.isCallExpression(T)&&(h=T),!h)return[];const v=r.getResolvedSignature(h);if(!v)return[];const N=v.getParameters(),D=N[i]||N[N.length-1],E=r.getTypeOfSymbolAtLocation(D,T),S=r.getSymbolsInScope(T,F.SymbolFlags.Variable),w=[];return S.forEach(_=>{const C=_.getName();if(!C.startsWith("node_")&&!C.startsWith("p_"))return;const $=_.valueDeclaration||_.declarations?.[0];if(!$||$.getEnd()>=e)return;const x=r.getTypeOfSymbolAtLocation(_,T);if(C.startsWith("node_")){if((x.flags&F.TypeFlags.Void)===0&&r.isTypeAssignableTo(x,E)){const b=C.replace("node_","").replace(/___/g,"://").replace(/__/g,"/").replace(/_/g,"/");w.push({__typename:"ReferenceValue",nodeFunctionId:b})}}else if(C.startsWith("p_")){const b=C.replace("p_",""),P=b.lastIndexOf("_"),V=b.substring(0,P),M=parseInt(b.substring(P+1),10),B=V.replace("p_","").replace(/___/g,"://").replace(/__/g,"/").replace(/_/g,"/");if(r.isTupleType(x)){const z=x;r.getTypeArguments(z).forEach((Z,W)=>{r.isTypeAssignableTo(Z,E)&&w.push({__typename:"ReferenceValue",nodeFunctionId:B,parameterIndex:isNaN(M)?0:M,inputIndex:W,inputTypeIdentifier:z.target.labeledElementDeclarations?.[W].name.getText()})})}}}),w},pe=(t,n)=>{if(!t)return[];const i=`
50
+ ${k(n)}
51
51
  type VALUE = ${t}; const val: VALUE = {} as any;
52
- `,r="index.ts",g=A(r,i),l=g.getSourceFile(r),u=g.languageService.getProgram().getTypeChecker(),c=l.statements.find(s=>f.isTypeAliasDeclaration(s)&&s.name.text==="VALUE");if(!c||!f.isTypeAliasDeclaration(c))return[];const d=u.getTypeAtLocation(c),a=s=>s.isUnion()?s.types.flatMap(a):s.isStringLiteral()?[s.value]:s.isNumberLiteral()?[s.value.toString()]:s.intrinsicName==="true"?["true"]:s.intrinsicName==="false"?["false"]:[];return Array.from(new Set(a(d))).map(s=>({__typename:"LiteralValue",value:s}))},pe=(t,n,i)=>{const r=z(t,n,i),g="index.ts",l=A(g,r),p=l.getSourceFile(g),d=l.languageService.getProgram().getSemanticDiagnostics(p).map(a=>{const F=f.flattenDiagnosticMessageText(a.messageText,`
53
- `);let s,y;if(a.start!==void 0){const e=p.getFullText(),o=Math.max(0,a.start-300),m=Math.min(e.length,a.start),T=e.substring(o,m),v=/\/\* @pos ([^ ]+) (\d+) \*\//g;let S,C=null,w=-1;for(;(S=v.exec(T))!==null;){const x=o+S.index+S[0].length;x<=a.start&&x>w&&(w=x,C=S)}C&&(s=C[1],y=parseInt(C[2],10))}return{message:F,code:a.code,severity:"error",nodeId:s,parameterIndex:y}}).filter(a=>a!==null);return{isValid:!d.some(a=>a?.severity==="error"),returnType:"void",diagnostics:d}},fe=(t,n,i)=>{const r=JSON.stringify(n?.value),g=`
54
- ${O(i)}
55
- const testValue: ${t} = ${r};
56
- `,l="index.ts",c=A(l,g).languageService.getSemanticDiagnostics(l).map(d=>{const a=f.flattenDiagnosticMessageText(d.messageText,`
57
- `),F=a.includes("not assignable to parameter of type")&&(a.includes("'{}'")||a.includes("undefined"))||a.includes("not assignable to type 'undefined'")||a.includes("not assignable to type 'void'")||a.includes("may be a mistake because neither type sufficiently overlaps");return{message:a,code:d.code,severity:F?"warning":"error"}});return{isValid:!c.some(d=>d.severity==="error"),returnType:"void",diagnostics:c}};exports.DataTypeVariant=j;exports.getFlowValidation=pe;exports.getNodeSuggestions=le;exports.getReferenceSuggestions=ue;exports.getTypeFromValue=se;exports.getTypeVariant=U;exports.getTypesFromNode=Q;exports.getValueFromType=ce;exports.getValueSuggestions=ge;exports.getValueValidation=fe;
52
+ `,a="index.ts",c=L(a,i),g=c.getSourceFile(a),p=c.languageService.getProgram().getTypeChecker(),u=g.statements.find(o=>F.isTypeAliasDeclaration(o)&&o.name.text==="VALUE");if(!u||!F.isTypeAliasDeclaration(u))return[];const m=p.getTypeAtLocation(u),r=o=>o.isUnion()?o.types.flatMap(r):o.isStringLiteral()?[o.value]:o.isNumberLiteral()?[o.value.toString()]:o.intrinsicName==="true"?["true"]:o.intrinsicName==="false"?["false"]:[];return Array.from(new Set(r(m))).map(o=>({__typename:"LiteralValue",value:o}))},fe=(t,n,i)=>{const a=U(t,n,i),c="index.ts",g=L(c,a),f=g.getSourceFile(c),m=g.languageService.getProgram().getSemanticDiagnostics(f).map(r=>{const d=F.flattenDiagnosticMessageText(r.messageText,`
53
+ `);let o,y;if(r.start!==void 0){const e=f.getFullText(),s=Math.max(0,r.start-300),l=Math.min(e.length,r.start),T=e.substring(s,l),h=/\/\* @pos ([^ ]+) (\d+) \*\//g;let v,N=null,D=-1;for(;(v=h.exec(T))!==null;){const S=s+v.index+v[0].length;S<=r.start&&S>D&&(D=S,N=v)}N&&(o=N[1],y=parseInt(N[2],10))}return{message:d,code:r.code,severity:"error",nodeId:o,parameterIndex:y}}).filter(r=>r!==null);return{isValid:!m.some(r=>r?.severity==="error"),returnType:"void",diagnostics:m}},me=(t,n,i)=>{const a=JSON.stringify(n?.value),c=`
54
+ ${k(i)}
55
+ const testValue: ${t} = ${a};
56
+ `,g="index.ts",u=L(g,c).languageService.getSemanticDiagnostics(g).map(m=>{const r=F.flattenDiagnosticMessageText(m.messageText,`
57
+ `),d=r.includes("not assignable to parameter of type")&&(r.includes("'{}'")||r.includes("undefined"))||r.includes("not assignable to type 'undefined'")||r.includes("not assignable to type 'void'")||r.includes("may be a mistake because neither type sufficiently overlaps");return{message:r,code:m.code,severity:d?"warning":"error"}});return{isValid:!u.some(m=>m.severity==="error"),returnType:"void",diagnostics:u}};exports.DataTypeVariant=j;exports.getFlowValidation=fe;exports.getNodeSuggestions=ue;exports.getReferenceSuggestions=ge;exports.getTypeFromValue=se;exports.getTypeVariant=H;exports.getTypesFromFunction=le;exports.getTypesFromNode=Q;exports.getValueFromType=ce;exports.getValueSuggestions=pe;exports.getValueValidation=me;
@@ -1,12 +1,12 @@
1
- import m, { flattenDiagnosticMessageText as Z } from "typescript";
2
- function R() {
3
- return R = Object.assign ? Object.assign.bind() : function(t) {
1
+ import F, { flattenDiagnosticMessageText as Z } from "typescript";
2
+ function k() {
3
+ return k = Object.assign ? Object.assign.bind() : function(t) {
4
4
  for (var n = 1; n < arguments.length; n++) {
5
5
  var i = arguments[n];
6
- for (var r in i) ({}).hasOwnProperty.call(i, r) && (t[r] = i[r]);
6
+ for (var a in i) ({}).hasOwnProperty.call(i, a) && (t[a] = i[a]);
7
7
  }
8
8
  return t;
9
- }, R.apply(null, arguments);
9
+ }, k.apply(null, arguments);
10
10
  }
11
11
  var K = !1;
12
12
  try {
@@ -16,54 +16,54 @@ try {
16
16
  var X = typeof process < "u", ee = K && typeof localStorage.getItem == "function" && /* @__PURE__ */ localStorage.getItem("DEBUG") || X && process.env.DEBUG, W = ee ? console.log : function(t) {
17
17
  return "";
18
18
  };
19
- function te(t, n, i, r, g) {
20
- r === void 0 && (r = {});
21
- var l = R({}, Y(i), r), p = re(t, n, l, i, g), u = p.languageServiceHost, c = p.updateFile, d = p.deleteFile, a = i.createLanguageService(u), F = a.getCompilerOptionsDiagnostics();
22
- if (F.length) {
23
- var s = G(t, r, i);
24
- throw new Error(i.formatDiagnostics(F, s.compilerHost));
19
+ function te(t, n, i, a, c) {
20
+ a === void 0 && (a = {});
21
+ var g = k({}, Y(i), a), f = re(t, n, g, i, c), p = f.languageServiceHost, u = f.updateFile, m = f.deleteFile, r = i.createLanguageService(p), d = r.getCompilerOptionsDiagnostics();
22
+ if (d.length) {
23
+ var o = G(t, a, i);
24
+ throw new Error(i.formatDiagnostics(d, o.compilerHost));
25
25
  }
26
26
  return {
27
27
  // @ts-ignore
28
28
  name: "vfs",
29
29
  sys: t,
30
- languageService: a,
30
+ languageService: r,
31
31
  getSourceFile: function(e) {
32
- var o;
33
- return (o = a.getProgram()) == null ? void 0 : o.getSourceFile(e);
32
+ var s;
33
+ return (s = r.getProgram()) == null ? void 0 : s.getSourceFile(e);
34
34
  },
35
- createFile: function(e, o) {
36
- c(i.createSourceFile(e, o, l.target, !1));
35
+ createFile: function(e, s) {
36
+ u(i.createSourceFile(e, s, g.target, !1));
37
37
  },
38
- updateFile: function(e, o, f) {
39
- var v = a.getProgram().getSourceFile(e);
40
- if (!v)
38
+ updateFile: function(e, s, l) {
39
+ var h = r.getProgram().getSourceFile(e);
40
+ if (!h)
41
41
  throw new Error("Did not find a source file for " + e);
42
- var T = v.text, S = f ?? i.createTextSpan(0, T.length), C = T.slice(0, S.start) + o + T.slice(S.start + S.length), w = i.updateSourceFile(v, C, {
43
- span: S,
44
- newLength: o.length
42
+ var T = h.text, v = l ?? i.createTextSpan(0, T.length), _ = T.slice(0, v.start) + s + T.slice(v.start + v.length), E = i.updateSourceFile(h, _, {
43
+ span: v,
44
+ newLength: s.length
45
45
  });
46
- c(w);
46
+ u(E);
47
47
  },
48
48
  deleteFile: function(e) {
49
- var o = a.getProgram().getSourceFile(e);
50
- o && d(o);
49
+ var s = r.getProgram().getSourceFile(e);
50
+ s && m(s);
51
51
  }
52
52
  };
53
53
  }
54
- function I(t) {
54
+ function O(t) {
55
55
  throw new Error("Method '" + t + "' is not implemented.");
56
56
  }
57
- function k(t, n) {
57
+ function I(t, n) {
58
58
  return function() {
59
- for (var i = arguments.length, r = new Array(i), g = 0; g < i; g++)
60
- r[g] = arguments[g];
61
- var l = n.apply(void 0, r), p = typeof l == "string" ? l.slice(0, 80) + "..." : l;
62
- return W.apply(void 0, ["> " + t].concat(r)), W("< " + p), l;
59
+ for (var i = arguments.length, a = new Array(i), c = 0; c < i; c++)
60
+ a[c] = arguments[c];
61
+ var g = n.apply(void 0, a), f = typeof g == "string" ? g.slice(0, 80) + "..." : g;
62
+ return W.apply(void 0, ["> " + t].concat(a)), W("< " + f), g;
63
63
  };
64
64
  }
65
65
  var Y = function(n) {
66
- return R({}, n.getDefaultCompilerOptions(), {
66
+ return k({}, n.getDefaultCompilerOptions(), {
67
67
  jsx: n.JsxEmit.React,
68
68
  strict: !0,
69
69
  esModuleInterop: !0,
@@ -83,18 +83,18 @@ function ne(t) {
83
83
  return {
84
84
  args: [],
85
85
  createDirectory: function() {
86
- return I("createDirectory");
86
+ return O("createDirectory");
87
87
  },
88
88
  // TODO: could make a real file tree
89
- directoryExists: k("directoryExists", function(n) {
89
+ directoryExists: I("directoryExists", function(n) {
90
90
  return Array.from(t.keys()).some(function(i) {
91
91
  return i.startsWith(n);
92
92
  });
93
93
  }),
94
94
  exit: function() {
95
- return I("exit");
95
+ return O("exit");
96
96
  },
97
- fileExists: k("fileExists", function(n) {
97
+ fileExists: I("fileExists", function(n) {
98
98
  return t.has(n) || t.has(J(n));
99
99
  }),
100
100
  getCurrentDirectory: function() {
@@ -104,12 +104,12 @@ function ne(t) {
104
104
  return [];
105
105
  },
106
106
  getExecutingFilePath: function() {
107
- return I("getExecutingFilePath");
107
+ return O("getExecutingFilePath");
108
108
  },
109
- readDirectory: k("readDirectory", function(n) {
109
+ readDirectory: I("readDirectory", function(n) {
110
110
  return n === "/" ? Array.from(t.keys()) : [];
111
111
  }),
112
- readFile: k("readFile", function(n) {
112
+ readFile: I("readFile", function(n) {
113
113
  var i;
114
114
  return (i = t.get(n)) != null ? i : t.get(J(n));
115
115
  }),
@@ -120,10 +120,10 @@ function ne(t) {
120
120
  `,
121
121
  useCaseSensitiveFileNames: !0,
122
122
  write: function() {
123
- return I("write");
123
+ return O("write");
124
124
  },
125
- writeFile: function(i, r) {
126
- t.set(i, r);
125
+ writeFile: function(i, a) {
126
+ t.set(i, a);
127
127
  },
128
128
  deleteFile: function(i) {
129
129
  t.delete(i);
@@ -131,12 +131,12 @@ function ne(t) {
131
131
  };
132
132
  }
133
133
  function G(t, n, i) {
134
- var r = /* @__PURE__ */ new Map(), g = function(u) {
135
- return r.set(u.fileName, u), u;
136
- }, l = {
137
- compilerHost: R({}, t, {
138
- getCanonicalFileName: function(u) {
139
- return u;
134
+ var a = /* @__PURE__ */ new Map(), c = function(p) {
135
+ return a.set(p.fileName, p), p;
136
+ }, g = {
137
+ compilerHost: k({}, t, {
138
+ getCanonicalFileName: function(p) {
139
+ return p;
140
140
  },
141
141
  getDefaultLibFileName: function() {
142
142
  return "/" + i.getDefaultLibFileName(n);
@@ -146,35 +146,35 @@ function G(t, n, i) {
146
146
  getNewLine: function() {
147
147
  return t.newLine;
148
148
  },
149
- getSourceFile: function(u, c) {
150
- var d;
151
- return r.get(u) || g(i.createSourceFile(u, t.readFile(u), (d = c ?? n.target) != null ? d : Y(i).target, !1));
149
+ getSourceFile: function(p, u) {
150
+ var m;
151
+ return a.get(p) || c(i.createSourceFile(p, t.readFile(p), (m = u ?? n.target) != null ? m : Y(i).target, !1));
152
152
  },
153
153
  useCaseSensitiveFileNames: function() {
154
154
  return t.useCaseSensitiveFileNames;
155
155
  }
156
156
  }),
157
- updateFile: function(u) {
158
- var c = r.has(u.fileName);
159
- return t.writeFile(u.fileName, u.text), r.set(u.fileName, u), c;
157
+ updateFile: function(p) {
158
+ var u = a.has(p.fileName);
159
+ return t.writeFile(p.fileName, p.text), a.set(p.fileName, p), u;
160
160
  },
161
- deleteFile: function(u) {
162
- var c = r.has(u.fileName);
163
- return r.delete(u.fileName), t.deleteFile(u.fileName), c;
161
+ deleteFile: function(p) {
162
+ var u = a.has(p.fileName);
163
+ return a.delete(p.fileName), t.deleteFile(p.fileName), u;
164
164
  }
165
165
  };
166
- return l;
166
+ return g;
167
167
  }
168
- function re(t, n, i, r, g) {
169
- var l = [].concat(n), p = G(t, i, r), u = p.compilerHost, c = p.updateFile, d = p.deleteFile, a = /* @__PURE__ */ new Map(), F = 0, s = R({}, u, {
168
+ function re(t, n, i, a, c) {
169
+ var g = [].concat(n), f = G(t, i, a), p = f.compilerHost, u = f.updateFile, m = f.deleteFile, r = /* @__PURE__ */ new Map(), d = 0, o = k({}, p, {
170
170
  getProjectVersion: function() {
171
- return F.toString();
171
+ return d.toString();
172
172
  },
173
173
  getCompilationSettings: function() {
174
174
  return i;
175
175
  },
176
176
  getCustomTransformers: function() {
177
- return g;
177
+ return c;
178
178
  },
179
179
  // A couple weeks of 4.8 TypeScript nightlies had a bug where the Program's
180
180
  // list of files was just a reference to the array returned by this host method,
@@ -185,73 +185,75 @@ function re(t, n, i, r, g) {
185
185
  // is used in bisecting for changes, it needs to guard against being busted in that
186
186
  // couple-week period, so we defensively make a slice here.
187
187
  getScriptFileNames: function() {
188
- return l.slice();
188
+ return g.slice();
189
189
  },
190
- getScriptSnapshot: function(o) {
191
- var f = t.readFile(o);
192
- if (f && typeof f == "string")
193
- return r.ScriptSnapshot.fromString(f);
190
+ getScriptSnapshot: function(s) {
191
+ var l = t.readFile(s);
192
+ if (l && typeof l == "string")
193
+ return a.ScriptSnapshot.fromString(l);
194
194
  },
195
- getScriptVersion: function(o) {
196
- return a.get(o) || "0";
195
+ getScriptVersion: function(s) {
196
+ return r.get(s) || "0";
197
197
  },
198
198
  writeFile: t.writeFile
199
199
  }), y = {
200
- languageServiceHost: s,
201
- updateFile: function(o) {
202
- F++, a.set(o.fileName, F.toString()), l.includes(o.fileName) || l.push(o.fileName), c(o);
200
+ languageServiceHost: o,
201
+ updateFile: function(s) {
202
+ d++, r.set(s.fileName, d.toString()), g.includes(s.fileName) || g.push(s.fileName), u(s);
203
203
  },
204
- deleteFile: function(o) {
205
- F++, a.set(o.fileName, F.toString());
206
- var f = l.indexOf(o.fileName);
207
- f !== -1 && l.splice(f, 1), d(o);
204
+ deleteFile: function(s) {
205
+ d++, r.set(s.fileName, d.toString());
206
+ var l = g.indexOf(s.fileName);
207
+ l !== -1 && g.splice(l, 1), m(s);
208
208
  }
209
209
  };
210
210
  return y;
211
211
  }
212
212
  const ie = (t, n, i) => {
213
213
  if (!t) return { parameters: [], returnType: "any" };
214
- const r = t.id || "temp_node_id", g = {
214
+ const a = t.id || "temp_node_id", c = {
215
215
  ...t,
216
- id: r,
216
+ id: a,
217
217
  parameters: {
218
218
  ...t.parameters,
219
219
  nodes: t.parameters?.nodes?.map((e) => e?.value ? e : { ...e, value: null }) || []
220
220
  }
221
- }, l = r + "_params", p = {
222
- ...g,
223
- id: l,
221
+ }, g = a + "_params", f = {
222
+ ...c,
223
+ id: g,
224
224
  parameters: {
225
- ...g.parameters,
226
- nodes: g.parameters.nodes.map((e) => e.value?.__typename === "LiteralValue" && e.value.value !== null && typeof e.value.value != "object" ? { ...e, value: null } : e)
225
+ ...c.parameters,
226
+ nodes: c.parameters.nodes.map((e) => e.value?.__typename === "LiteralValue" && e.value.value !== null && typeof e.value.value != "object" ? { ...e, value: null } : e)
227
227
  }
228
- }, c = se({
229
- nodes: { __typename: "NodeFunctionConnection", nodes: [g, p] }
230
- }, n, i), d = L(r), a = L(l), F = c.parameters.get(d) || [], s = c.parameters.get(a) || [];
228
+ }, u = se({
229
+ nodes: { __typename: "NodeFunctionConnection", nodes: [c, f] }
230
+ }, n, i), m = A(a), r = A(g), d = u.parameters.get(m) || [], o = u.parameters.get(r) || [];
231
231
  return {
232
- parameters: F.map((e, o) => {
233
- const f = s[o];
234
- return f && f !== "any" && f !== "unknown" ? f : e;
232
+ parameters: d.map((e, s) => {
233
+ const l = o[s];
234
+ return l && l !== "any" && l !== "unknown" ? l : e;
235
235
  }),
236
- returnType: c.nodes.get(d) || "any"
236
+ returnType: u.nodes.get(m) || "any"
237
237
  };
238
238
  };
239
- var H = /* @__PURE__ */ ((t) => (t[t.PRIMITIVE = 0] = "PRIMITIVE", t[t.TYPE = 1] = "TYPE", t[t.ARRAY = 2] = "ARRAY", t[t.OBJECT = 3] = "OBJECT", t[t.NODE = 4] = "NODE", t))(H || {});
239
+ var B = /* @__PURE__ */ ((t) => (t[t.PRIMITIVE = 0] = "PRIMITIVE", t[t.TYPE = 1] = "TYPE", t[t.ARRAY = 2] = "ARRAY", t[t.OBJECT = 3] = "OBJECT", t[t.NODE = 4] = "NODE", t))(B || {});
240
240
  const q = (t, n) => {
241
- const r = `
242
- ${O(n)}
241
+ const a = `
242
+ ${R(n)}
243
243
  type TargetType = ${t};
244
244
  const val: TargetType = {} as any;
245
- `, g = "index.ts", l = P(g, r), p = l.getSourceFile(g), c = l.languageService.getProgram().getTypeChecker();
246
- let d = 1;
247
- const a = (F) => {
248
- if (m.isVariableDeclaration(F) && F.name.getText() === "val") {
249
- const s = c.getTypeAtLocation(F);
250
- s.getCallSignatures().length > 0 ? d = 4 : c.isArrayType(s) ? d = 2 : s.isStringLiteral() || s.isNumberLiteral() || (s.getFlags() & (m.TypeFlags.String | m.TypeFlags.Number | m.TypeFlags.Boolean | m.TypeFlags.EnumLiteral | m.TypeFlags.BigInt | m.TypeFlags.ESSymbol)) !== 0 ? d = 0 : s.isClassOrInterface() || (s.getFlags() & m.TypeFlags.Object) !== 0 ? d = 3 : d = 1;
245
+ `;
246
+ console.log(a);
247
+ const c = "index.ts", g = L(c, a), f = g.getSourceFile(c), u = g.languageService.getProgram().getTypeChecker();
248
+ let m = 1;
249
+ const r = (d) => {
250
+ if (F.isVariableDeclaration(d) && d.name.getText() === "val") {
251
+ const o = u.getTypeAtLocation(d);
252
+ o.getCallSignatures().length > 0 ? m = 4 : u.isArrayType(o) ? m = 2 : o.isStringLiteral() || o.isNumberLiteral() || (o.getFlags() & (F.TypeFlags.String | F.TypeFlags.Number | F.TypeFlags.Boolean | F.TypeFlags.EnumLiteral | F.TypeFlags.BigInt | F.TypeFlags.ESSymbol)) !== 0 ? m = 0 : o.isClassOrInterface() || (o.getFlags() & F.TypeFlags.Object) !== 0 ? m = 3 : m = 1;
251
253
  }
252
- m.forEachChild(F, a);
254
+ F.forEachChild(d, r);
253
255
  };
254
- return a(p), d;
256
+ return r(f), m;
255
257
  }, ae = `
256
258
  interface Array<T> {
257
259
  [n: number]: T;
@@ -269,356 +271,433 @@ const q = (t, n) => {
269
271
  type Record<K extends keyof any, T> = { [P in K]: T; };
270
272
  type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
271
273
  `;
272
- function P(t, n) {
274
+ function L(t, n) {
273
275
  const i = /* @__PURE__ */ new Map();
274
276
  i.set(t, n), i.set("lib.codezero.d.ts", ae);
275
- const r = ne(i);
276
- return te(r, [t, "lib.codezero.d.ts"], m, oe);
277
+ const a = ne(i);
278
+ return te(a, [t, "lib.codezero.d.ts"], F, oe);
277
279
  }
278
280
  const oe = {
279
- target: m.ScriptTarget.Latest,
281
+ target: F.ScriptTarget.Latest,
280
282
  lib: ["lib.codezero.d.ts"],
281
283
  noEmit: !0,
282
284
  strictNullChecks: !0
283
285
  };
284
- function O(t) {
285
- const n = Array.from(new Set(t?.flatMap((r) => r.genericKeys || []))).map((r) => `type ${r} = any;`).join(`
286
- `), i = t?.map(
287
- (r) => `type ${r.identifier}${(r.genericKeys?.length ?? 0) > 0 ? `<${r.genericKeys?.join(",")}>` : ""} = ${r.type};`
286
+ function R(t, n = "any") {
287
+ const i = Array.from(new Set(t?.flatMap((c) => c.genericKeys || []))).map((c) => `type ${c} = ${n};`).join(`
288
+ `), a = t?.map(
289
+ (c) => `type ${c.identifier}${(c.genericKeys?.length ?? 0) > 0 ? `<${c.genericKeys?.join(",")}>` : ""} = ${c.type};`
288
290
  ).join(`
289
291
  `);
290
- return `${n}
291
- ${i}`;
292
+ return `${i}
293
+ ${a}`;
292
294
  }
293
- const L = (t) => t.replace(/[^a-zA-Z0-9]/g, "_");
294
- function U(t, n, i, r = !1) {
295
- const g = t?.nodes?.nodes || [], l = new Map(n?.map((e) => [e.identifier, e])), p = /* @__PURE__ */ new Set(), u = (e, o, f) => {
296
- const v = g.find((A) => A?.id === e);
297
- if (!v || !v.functionDefinition?.identifier) return "undefined";
298
- const S = (v.parameters?.nodes || []).map((A, x) => {
299
- const E = A.value;
300
- if (!E) return r ? `/* @pos ${e} ${x} */ {}` : `/* @pos ${e} ${x} */ undefined`;
301
- if (E.__typename === "ReferenceValue") {
302
- const $ = E;
303
- if (!$.nodeFunctionId) return `/* @pos ${e} ${x} */ undefined`;
304
- let _ = $.inputIndex !== void 0 ? `p_${L($.nodeFunctionId)}_${$.parameterIndex}[${$.inputIndex}]` : `node_${L($.nodeFunctionId)}`;
305
- return $.referencePath?.forEach((h) => {
306
- _ += `?.${h.path}`;
307
- }), `/* @pos ${e} ${x} */ ${_}`;
295
+ const A = (t) => t.replace(/[^a-zA-Z0-9]/g, "_");
296
+ function H(t, n, i, a = !1) {
297
+ const c = t?.nodes?.nodes || [], g = new Map(n?.map((e) => [e.identifier, e])), f = /* @__PURE__ */ new Set(), p = (e, s, l) => {
298
+ const h = c.find((D) => D?.id === e);
299
+ if (!h || !h.functionDefinition?.identifier) return "undefined";
300
+ const v = (h.parameters?.nodes || []).map((D, S) => {
301
+ const w = D.value;
302
+ if (!w) return a ? `/* @pos ${e} ${S} */ {}` : `/* @pos ${e} ${S} */ undefined`;
303
+ if (w.__typename === "ReferenceValue") {
304
+ const N = w;
305
+ if (!N.nodeFunctionId) return `/* @pos ${e} ${S} */ undefined`;
306
+ let C = N.inputIndex !== void 0 ? `p_${A(N.nodeFunctionId)}_${N.parameterIndex}[${N.inputIndex}]` : `node_${A(N.nodeFunctionId)}`;
307
+ return N.referencePath?.forEach(($) => {
308
+ C += `?.${$.path}`;
309
+ }), `/* @pos ${e} ${S} */ ${C}`;
308
310
  }
309
- return E.__typename === "LiteralValue" ? `/* @pos ${e} ${x} */ ${JSON.stringify(E.value)}` : E.__typename === "NodeFunctionIdWrapper" ? u(E.id, e, x) : r ? `/* @pos ${e} ${x} */ ({} as any)` : `/* @pos ${e} ${x} */ undefined`;
310
- }).join(", "), w = `${`fn_${v.functionDefinition.identifier.replace(/::/g, "_")}`}(${S})`;
311
- return o !== void 0 && f !== void 0 ? `${w}` : w;
312
- }, c = (e, o = "") => {
313
- if (p.has(e)) return "";
314
- const f = g.find((_) => _?.id === e);
315
- if (!f || !f.functionDefinition) return "";
316
- if (p.add(e), !l.get(f.functionDefinition.identifier)) return `${o}// Error: Function ${f.functionDefinition.identifier} not found
311
+ return w.__typename === "LiteralValue" ? `/* @pos ${e} ${S} */ ${JSON.stringify(w.value)}` : w.__typename === "NodeFunctionIdWrapper" ? p(w.id, e, S) : a ? `/* @pos ${e} ${S} */ ({} as any)` : `/* @pos ${e} ${S} */ undefined`;
312
+ }).join(", "), E = `${`fn_${h.functionDefinition.identifier.replace(/::/g, "_")}`}(${v})`;
313
+ return s !== void 0 && l !== void 0 ? `${E}` : E;
314
+ }, u = (e, s = "") => {
315
+ if (f.has(e)) return "";
316
+ const l = c.find((C) => C?.id === e);
317
+ if (!l || !l.functionDefinition) return "";
318
+ if (f.add(e), !g.get(l.functionDefinition.identifier)) return `${s}// Error: Function ${l.functionDefinition.identifier} not found
317
319
  `;
318
320
  let T = { parameters: [] };
319
- r || (T = ie(f, n, i));
320
- const C = (f.parameters?.nodes || []).map((_, h) => {
321
- const b = _.value;
322
- if (!b) return r ? `/* @pos ${e} ${h} */ {}` : `/* @pos ${e} ${h} */ undefined`;
321
+ a || (T = ie(l, n, i));
322
+ const _ = (l.parameters?.nodes || []).map((C, $) => {
323
+ const b = C.value;
324
+ if (!b) return a ? `/* @pos ${e} ${$} */ {}` : `/* @pos ${e} ${$} */ undefined`;
323
325
  if (b.__typename === "ReferenceValue") {
324
- const N = b;
325
- if (!N.nodeFunctionId) return `/* @pos ${e} ${h} */ undefined`;
326
- let D = N.inputIndex !== void 0 ? `p_${L(N.nodeFunctionId)}_${N.parameterIndex}[${N.inputIndex}]` : `node_${L(N.nodeFunctionId)}`;
327
- return N.referencePath?.forEach((V) => {
328
- D += `?.${V.path}`;
329
- }), `/* @pos ${e} ${h} */ ${D}`;
326
+ const x = b;
327
+ if (!x.nodeFunctionId) return `/* @pos ${e} ${$} */ undefined`;
328
+ let P = x.inputIndex !== void 0 ? `p_${A(x.nodeFunctionId)}_${x.parameterIndex}[${x.inputIndex}]` : `node_${A(x.nodeFunctionId)}`;
329
+ return x.referencePath?.forEach((V) => {
330
+ P += `?.${V.path}`;
331
+ }), `/* @pos ${e} ${$} */ ${P}`;
330
332
  }
331
- if (b.__typename === "LiteralValue") return `/* @pos ${e} ${h} */ ${JSON.stringify(b.value)}`;
333
+ if (b.__typename === "LiteralValue") return `/* @pos ${e} ${$} */ ${JSON.stringify(b.value)}`;
332
334
  if (b.__typename === "NodeFunctionIdWrapper") {
333
- const N = b;
334
- if (r) {
335
- const D = `p_${L(e)}_${h}`, V = c(N.id, o + " ");
336
- return `/* @pos ${e} ${h} */ (...${D}) => {
337
- ${V}${o}}`;
335
+ const x = b;
336
+ if (a) {
337
+ const P = `p_${A(e)}_${$}`, V = u(x.id, s + " ");
338
+ return `/* @pos ${e} ${$} */ (...${P}) => {
339
+ ${V}${s}}`;
338
340
  } else {
339
- const D = T.parameters[h];
340
- if (D ? q(D, i) === H.NODE : !1) {
341
- const M = `p_${L(e)}_${h}`, j = c(N.id, o + " ");
342
- return `/* @pos ${e} ${h} */ (...${M}) => {
343
- ${j}${o}}`;
341
+ const P = T.parameters[$];
342
+ if (P ? q(P, i) === B.NODE : !1) {
343
+ const M = `p_${A(e)}_${$}`, j = u(x.id, s + " ");
344
+ return `/* @pos ${e} ${$} */ (...${M}) => {
345
+ ${j}${s}}`;
344
346
  } else {
345
- const M = u(N.id, e, h);
346
- return `/* @pos ${e} ${h} */ ${M}`;
347
+ const M = p(x.id, e, $);
348
+ return `/* @pos ${e} ${$} */ ${M}`;
347
349
  }
348
350
  }
349
351
  }
350
- return r ? `/* @pos ${e} ${h} */ {}` : `/* @pos ${e} ${h} */ undefined`;
351
- }).join(", "), w = `node_${L(f.id)}`, A = `fn_${f?.functionDefinition?.identifier?.replace(/::/g, "_")}`, x = C.includes("undefined"), E = f.functionDefinition.identifier === "std::control::return";
352
- let $ = `${o}${E ? "return " : `const ${w} = `}${A}(${C}) ;
352
+ return a ? `/* @pos ${e} ${$} */ {}` : `/* @pos ${e} ${$} */ undefined`;
353
+ }).join(", "), E = `node_${A(l.id)}`, D = `fn_${l?.functionDefinition?.identifier?.replace(/::/g, "_")}`, S = _.includes("undefined"), w = l.functionDefinition.identifier === "std::control::return";
354
+ let N = `${s}${w ? "return " : `const ${E} = `}${D}(${_}) ;
353
355
  `;
354
- return f.nextNodeId && ($ += c(f.nextNodeId, o)), $;
355
- }, d = O(i), a = n?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join(`
356
- `), F = new Set(g.map((e) => e?.nextNodeId).filter((e) => !!e)), s = /* @__PURE__ */ new Set();
357
- g.forEach((e) => e?.parameters?.nodes?.forEach((o) => {
358
- o?.value?.__typename === "NodeFunctionIdWrapper" && o.value.id && s.add(o.value.id);
356
+ return l.nextNodeId && (N += u(l.nextNodeId, s)), N;
357
+ }, m = R(i), r = n?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join(`
358
+ `), d = new Set(c.map((e) => e?.nextNodeId).filter((e) => !!e)), o = /* @__PURE__ */ new Set();
359
+ c.forEach((e) => e?.parameters?.nodes?.forEach((s) => {
360
+ s?.value?.__typename === "NodeFunctionIdWrapper" && s.value.id && o.add(s.value.id);
359
361
  }));
360
- const y = g.filter((e) => e?.id && !F.has(e.id) && !s.has(e.id)).map((e) => c(e.id)).join(`
362
+ const y = c.filter((e) => e?.id && !d.has(e.id) && !o.has(e.id)).map((e) => u(e.id)).join(`
361
363
  `);
362
- return `${d}
363
- ${a}
364
+ return `${m}
365
+ ${r}
364
366
 
365
367
  // --- Flow ---
366
368
  ${y}`;
367
369
  }
368
370
  function se(t, n, i) {
369
- const r = U(t, n, i, !0), g = "index.ts", l = P(g, r), p = l.getSourceFile(g), c = l.languageService.getProgram().getTypeChecker(), d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
371
+ const a = H(t, n, i, !0), c = "index.ts", g = L(c, a), f = g.getSourceFile(c), u = g.languageService.getProgram().getTypeChecker(), m = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
370
372
  (t?.nodes?.nodes || []).forEach((e) => {
371
- e?.id && F.set(L(e.id), e);
373
+ e?.id && d.set(A(e.id), e);
372
374
  });
373
375
  const y = (e) => {
374
- if (m.isVariableDeclaration(e) && e.name.getText().startsWith("node_")) {
375
- const o = e.name.getText().replace("node_", ""), f = c.getTypeAtLocation(e);
376
- if (d.set(o, c.typeToString(f, e, m.TypeFormatFlags.NoTruncation)), e.initializer && m.isCallExpression(e.initializer)) {
377
- const v = c.getResolvedSignature(e.initializer);
378
- if (v) {
379
- const T = v.getParameters().map((S) => {
380
- const C = c.getTypeOfSymbolAtLocation(S, e.initializer);
381
- return c.typeToString(C, e.initializer, m.TypeFormatFlags.NoTruncation);
376
+ if (F.isVariableDeclaration(e) && e.name.getText().startsWith("node_")) {
377
+ const s = e.name.getText().replace("node_", ""), l = u.getTypeAtLocation(e);
378
+ if (m.set(s, u.typeToString(l, e, F.TypeFormatFlags.NoTruncation)), e.initializer && F.isCallExpression(e.initializer)) {
379
+ const h = u.getResolvedSignature(e.initializer);
380
+ if (h) {
381
+ const T = h.getParameters().map((v) => {
382
+ const _ = u.getTypeOfSymbolAtLocation(v, e.initializer);
383
+ return u.typeToString(_, e.initializer, F.TypeFormatFlags.NoTruncation);
382
384
  });
383
- a.set(o, T);
385
+ r.set(s, T);
384
386
  }
385
387
  }
386
388
  }
387
- if (m.isReturnStatement(e) && e.expression && m.isCallExpression(e.expression)) {
388
- const o = e.expression;
389
- c.getResolvedSignature(o);
389
+ if (F.isReturnStatement(e) && e.expression && F.isCallExpression(e.expression)) {
390
+ const s = e.expression;
391
+ u.getResolvedSignature(s);
390
392
  }
391
- m.forEachChild(e, y);
393
+ F.forEachChild(e, y);
392
394
  };
393
- return y(p), { nodes: d, parameters: a };
395
+ return y(f), { nodes: m, parameters: r };
394
396
  }
395
397
  const ue = (t) => {
396
- const i = `const tempValue = ${JSON.stringify(t?.value) ?? "any"};`, r = "index.ts", g = P(r, i), l = g.getSourceFile(r), u = g.languageService.getProgram().getTypeChecker();
397
- let c = "any";
398
- const d = (a) => {
399
- if (m.isVariableDeclaration(a) && a.name.getText() === "tempValue") {
400
- const F = u.getTypeAtLocation(a);
401
- c = u.typeToString(
402
- F,
403
- a,
404
- m.TypeFormatFlags.NoTruncation | m.TypeFormatFlags.UseFullyQualifiedType
398
+ const i = `const tempValue = ${JSON.stringify(t?.value) ?? "any"};`, a = "index.ts", c = L(a, i), g = c.getSourceFile(a), p = c.languageService.getProgram().getTypeChecker();
399
+ let u = "any";
400
+ const m = (r) => {
401
+ if (F.isVariableDeclaration(r) && r.name.getText() === "tempValue") {
402
+ const d = p.getTypeAtLocation(r);
403
+ u = p.typeToString(
404
+ d,
405
+ r,
406
+ F.TypeFormatFlags.NoTruncation | F.TypeFormatFlags.UseFullyQualifiedType
405
407
  );
406
408
  }
407
- m.forEachChild(a, d);
409
+ F.forEachChild(r, m);
408
410
  };
409
- return d(l), c;
411
+ return m(g), u;
410
412
  }, ge = (t, n) => {
411
413
  const i = `
412
- ${O(n)}
414
+ ${R(n)}
413
415
  type Target = ${t};
414
- `, r = "index.ts", g = P(r, i), l = g.getSourceFile(r), u = g.languageService.getProgram().getTypeChecker(), c = l.statements.find(
415
- (s) => m.isTypeAliasDeclaration(s) && s.name.text === "Target"
416
+ `, a = "index.ts", c = L(a, i), g = c.getSourceFile(a), p = c.languageService.getProgram().getTypeChecker(), u = g.statements.find(
417
+ (o) => F.isTypeAliasDeclaration(o) && o.name.text === "Target"
416
418
  );
417
- if (!c)
419
+ if (!u)
418
420
  return { __typename: "LiteralValue", value: null };
419
- const d = u.getTypeAtLocation(c.type), a = (s, y, e = /* @__PURE__ */ new Set()) => {
420
- if (e.has(s)) return null;
421
- e.add(s);
422
- const o = s.getFlags();
423
- if (s.isUnion()) {
424
- if (y.type, m.isTypeAliasDeclaration(y) && y.type && m.isUnionTypeNode(y.type)) {
425
- const T = u.getTypeFromTypeNode(y.type.types[0]);
426
- return a(T, y, e);
421
+ const m = p.getTypeAtLocation(u.type), r = (o, y, e = /* @__PURE__ */ new Set()) => {
422
+ if (e.has(o)) return null;
423
+ e.add(o);
424
+ const s = o.getFlags();
425
+ if (o.isUnion()) {
426
+ if (y.type, F.isTypeAliasDeclaration(y) && y.type && F.isUnionTypeNode(y.type)) {
427
+ const T = p.getTypeFromTypeNode(y.type.types[0]);
428
+ return r(T, y, e);
427
429
  }
428
- const f = s.types.filter((T) => {
429
- const S = T.getFlags();
430
- return !(S & m.TypeFlags.Undefined) && !(S & m.TypeFlags.Null);
431
- }), v = f.length > 0 ? f[0] : s.types[0];
432
- return a(v, y, e);
430
+ const l = o.types.filter((T) => {
431
+ const v = T.getFlags();
432
+ return !(v & F.TypeFlags.Undefined) && !(v & F.TypeFlags.Null);
433
+ }), h = l.length > 0 ? l[0] : o.types[0];
434
+ return r(h, y, e);
433
435
  }
434
- if (o & m.TypeFlags.StringLiteral) return s.value;
435
- if (o & m.TypeFlags.String) return "";
436
- if (o & m.TypeFlags.NumberLiteral) return s.value;
437
- if (o & m.TypeFlags.Number) return 0;
438
- if (o & m.TypeFlags.BooleanLiteral) return s.intrinsicName === "true";
439
- if (o & m.TypeFlags.Boolean) return !1;
440
- if (u.isArrayType(s)) {
441
- const v = s.typeArguments?.[0] || u.getAnyType();
442
- return a(v, y, e) === "null" ? [a(v, y, e)] : [];
436
+ if (s & F.TypeFlags.StringLiteral) return o.value;
437
+ if (s & F.TypeFlags.String) return "";
438
+ if (s & F.TypeFlags.NumberLiteral) return o.value;
439
+ if (s & F.TypeFlags.Number) return 0;
440
+ if (s & F.TypeFlags.BooleanLiteral) return o.intrinsicName === "true";
441
+ if (s & F.TypeFlags.Boolean) return !1;
442
+ if (p.isArrayType(o)) {
443
+ const h = o.typeArguments?.[0] || p.getAnyType(), T = r(h, y, e);
444
+ return T !== null ? [T] : [];
443
445
  }
444
- if (s.isClassOrInterface() || o & m.TypeFlags.Object || s.getProperties().length > 0) {
445
- const f = {};
446
- return s.getProperties().forEach((T) => {
447
- const S = u.getTypeOfSymbolAtLocation(T, y);
448
- S && (f[T.getName()] = a(S, y, e));
449
- }), f;
446
+ if (o.isClassOrInterface() || s & F.TypeFlags.Object || o.getProperties().length > 0) {
447
+ const l = {};
448
+ return o.getProperties().forEach((T) => {
449
+ const v = p.getTypeOfSymbolAtLocation(T, y);
450
+ v && (l[T.getName()] = r(v, y, e));
451
+ }), l;
450
452
  }
451
453
  return null;
452
454
  };
453
455
  return {
454
456
  __typename: "LiteralValue",
455
- value: a(d, c)
457
+ value: r(m, u)
456
458
  };
457
- }, pe = (t, n, i) => {
458
- let r = n;
459
- const g = t ? q(t, i) : null;
460
- if (t && n && g !== H.NODE) {
461
- let l = function(y) {
459
+ }, pe = (t) => {
460
+ const n = t.signature;
461
+ if (!n)
462
+ return { parameters: [], returnType: "any" };
463
+ let i = 0;
464
+ if (n.trim().startsWith("<")) {
465
+ let r = 0;
466
+ for (let d = 0; d < n.length; d++) {
467
+ const o = n[d];
468
+ if (o === "<") r++;
469
+ else if (o === ">" && (r--, r === 0)) {
470
+ i = d + 1;
471
+ break;
472
+ }
473
+ }
474
+ }
475
+ const a = n.indexOf("(", i);
476
+ if (a === -1)
477
+ return { parameters: [], returnType: "any" };
478
+ let c = -1, g = 0;
479
+ for (let r = a; r < n.length; r++) {
480
+ const d = n[r];
481
+ if (d === "(") g++;
482
+ else if (d === ")" && (g--, g === 0)) {
483
+ c = r;
484
+ break;
485
+ }
486
+ }
487
+ if (c === -1)
488
+ return { parameters: [], returnType: "any" };
489
+ const f = n.substring(a + 1, c);
490
+ let p = n.substring(c + 1).trim();
491
+ p.startsWith(":") && (p = p.substring(1).trim());
492
+ const u = p || "void", m = [];
493
+ if (f.trim()) {
494
+ let r = "", d = 0, o = 0, y = 0, e = 0;
495
+ const s = (l) => {
496
+ let h = -1, T = 0, v = 0, _ = 0, E = 0;
497
+ for (let D = 0; D < l.length; D++) {
498
+ const S = l[D];
499
+ if (S === "{") T++;
500
+ else if (S === "}") T--;
501
+ else if (S === "[") v++;
502
+ else if (S === "]") v--;
503
+ else if (S === "(") _++;
504
+ else if (S === ")") _--;
505
+ else if (S === "<") E++;
506
+ else if (S === ">") E--;
507
+ else if (S === ":" && T === 0 && v === 0 && _ === 0 && E === 0) {
508
+ h = D;
509
+ break;
510
+ }
511
+ }
512
+ h !== -1 ? m.push(l.substring(h + 1).trim()) : m.push("any");
513
+ };
514
+ for (const l of f) {
515
+ if (l === "(") d++;
516
+ else if (l === ")") d--;
517
+ else if (l === "<") o++;
518
+ else if (l === ">") o--;
519
+ else if (l === "{") y++;
520
+ else if (l === "}") y--;
521
+ else if (l === "[") e++;
522
+ else if (l === "]") e--;
523
+ else if (l === "," && d === 0 && o === 0 && y === 0 && e === 0) {
524
+ s(r.trim()), r = "";
525
+ continue;
526
+ }
527
+ r += l;
528
+ }
529
+ r.trim() && s(r.trim());
530
+ }
531
+ return {
532
+ parameters: m,
533
+ returnType: u
534
+ };
535
+ }, fe = (t, n, i) => {
536
+ let a = n;
537
+ const c = t ? q(t, i) : null;
538
+ if (t && n && c !== B.NODE) {
539
+ let g = function(y) {
462
540
  const e = y.trim().match(/^<([^>]+)>/);
463
- return e ? e[1].split(",").map((o) => o.trim()).filter(Boolean).length : 0;
541
+ return e ? e[1].split(",").map((s) => s.trim()).filter(Boolean).length : 0;
464
542
  };
465
- const p = `
466
- ${O(i)}
543
+ const f = `
544
+ ${R(i)}
467
545
  type TargetType = ${t};
468
546
  ${n?.map((y, e) => `
469
547
  declare function Fu${e}${y.signature};
470
- type F${e} = ReturnType<typeof Fu${e}${l(y.signature) > 0 ? `<${Array(l(y.signature)).fill("any").join(", ")}>` : ""}>;
548
+ type F${e} = ReturnType<typeof Fu${e}${g(y.signature) > 0 ? `<${Array(g(y.signature)).fill("any").join(", ")}>` : ""}>;
471
549
  `).join(`
472
550
  `)}
473
551
  ${n?.map((y, e) => `const check${e}: TargetType = {} as F${e};`).join(`
474
552
  `)}
475
- `, u = "index.ts", c = P(u, p), d = c.getSourceFile(u), F = c.languageService.getProgram().getSemanticDiagnostics(), s = /* @__PURE__ */ new Set();
476
- F.forEach((y) => {
477
- y.file === d && y.start !== void 0 && s.add(d.getLineAndCharacterOfPosition(y.start).line);
478
- }), r = n.filter((y, e) => {
479
- const o = `const check${e}: TargetType = {} as F${e};`, v = p.split(`
480
- `).findIndex((T) => T.includes(o));
481
- return v !== -1 && !s.has(v);
553
+ `, p = "index.ts", u = L(p, f), m = u.getSourceFile(p), d = u.languageService.getProgram().getSemanticDiagnostics(), o = /* @__PURE__ */ new Set();
554
+ d.forEach((y) => {
555
+ y.file === m && y.start !== void 0 && o.add(m.getLineAndCharacterOfPosition(y.start).line);
556
+ }), a = n.filter((y, e) => {
557
+ const s = `const check${e}: TargetType = {} as F${e};`, h = f.split(`
558
+ `).findIndex((T) => T.includes(s));
559
+ return h !== -1 && !o.has(h);
482
560
  });
483
561
  }
484
- return r?.map((l) => ({
562
+ return a?.map((g) => ({
485
563
  __typename: "NodeFunction",
486
564
  id: "gid://sagittarius/NodeFunction/1",
487
565
  functionDefinition: {
488
566
  __typename: "FunctionDefinition",
489
- id: l.id,
490
- identifier: l.identifier
567
+ id: g.id,
568
+ identifier: g.identifier
491
569
  },
492
570
  parameters: {
493
571
  __typename: "NodeParameterConnection",
494
- nodes: (l.parameterDefinitions?.nodes || []).map((p) => ({
572
+ nodes: (g.parameterDefinitions?.nodes || []).map((f) => ({
495
573
  __typename: "NodeParameter",
496
574
  parameterDefinition: {
497
575
  __typename: "ParameterDefinition",
498
- id: p?.id,
499
- identifier: p?.identifier
576
+ id: f?.id,
577
+ identifier: f?.identifier
500
578
  },
501
579
  value: null
502
580
  }))
503
581
  }
504
- })).filter((l) => l !== null) ?? [];
505
- }, fe = (t, n, i, r, g) => {
506
- const l = U(t, r, g, !0), p = "index.ts", u = P(p, l), c = u.getSourceFile(p), a = u.languageService.getProgram().getTypeChecker(), F = c.getFullText(), s = `/* @pos ${n} ${i} */`, e = F.indexOf(s) + s.length;
507
- function o($, _) {
508
- let h = $;
509
- return m.forEachChild($, (b) => {
510
- b.getStart(c, !0) <= _ && b.getEnd() >= _ && (h = o(b, _));
511
- }), h;
582
+ })).filter((g) => g !== null) ?? [];
583
+ }, me = (t, n, i, a, c) => {
584
+ const g = H(t, a, c, !0), f = "index.ts", p = L(f, g), u = p.getSourceFile(f), r = p.languageService.getProgram().getTypeChecker(), d = u.getFullText(), o = `/* @pos ${n} ${i} */`, e = d.indexOf(o) + o.length;
585
+ function s(N, C) {
586
+ let $ = N;
587
+ return F.forEachChild(N, (b) => {
588
+ b.getStart(u, !0) <= C && b.getEnd() >= C && ($ = s(b, C));
589
+ }), $;
512
590
  }
513
- const v = o(c, e);
591
+ const h = s(u, e);
514
592
  let T;
515
- if (m.isCallExpression(v) && (T = v), !T)
593
+ if (F.isCallExpression(h) && (T = h), !T)
516
594
  return [];
517
- const S = a.getResolvedSignature(T);
518
- if (!S) return [];
519
- const C = S.getParameters(), w = C[i] || C[C.length - 1], A = a.getTypeOfSymbolAtLocation(w, v), x = a.getSymbolsInScope(v, m.SymbolFlags.Variable), E = [];
520
- return x.forEach(($) => {
521
- const _ = $.getName();
522
- if (!_.startsWith("node_") && !_.startsWith("p_")) return;
523
- const h = $.valueDeclaration || $.declarations?.[0];
524
- if (!h || h.getEnd() >= e)
595
+ const v = r.getResolvedSignature(T);
596
+ if (!v) return [];
597
+ const _ = v.getParameters(), E = _[i] || _[_.length - 1], D = r.getTypeOfSymbolAtLocation(E, h), S = r.getSymbolsInScope(h, F.SymbolFlags.Variable), w = [];
598
+ return S.forEach((N) => {
599
+ const C = N.getName();
600
+ if (!C.startsWith("node_") && !C.startsWith("p_")) return;
601
+ const $ = N.valueDeclaration || N.declarations?.[0];
602
+ if (!$ || $.getEnd() >= e)
525
603
  return;
526
- const b = a.getTypeOfSymbolAtLocation($, v);
527
- if (_.startsWith("node_")) {
528
- if ((b.flags & m.TypeFlags.Void) === 0 && a.isTypeAssignableTo(b, A)) {
529
- const N = _.replace("node_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
530
- E.push({
604
+ const b = r.getTypeOfSymbolAtLocation(N, h);
605
+ if (C.startsWith("node_")) {
606
+ if ((b.flags & F.TypeFlags.Void) === 0 && r.isTypeAssignableTo(b, D)) {
607
+ const x = C.replace("node_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
608
+ w.push({
531
609
  __typename: "ReferenceValue",
532
- nodeFunctionId: N
610
+ nodeFunctionId: x
533
611
  // Bei node_ keine Indizes laut Vorgabe
534
612
  });
535
613
  }
536
- } else if (_.startsWith("p_")) {
537
- const N = _.replace("p_", ""), D = N.lastIndexOf("_"), V = N.substring(0, D), M = parseInt(N.substring(D + 1), 10), j = V.replace("p_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
538
- if (a.isTupleType(b)) {
539
- const z = b;
540
- a.getTypeArguments(z).forEach((Q, B) => {
541
- a.isTypeAssignableTo(Q, A) && E.push({
614
+ } else if (C.startsWith("p_")) {
615
+ const x = C.replace("p_", ""), P = x.lastIndexOf("_"), V = x.substring(0, P), M = parseInt(x.substring(P + 1), 10), j = V.replace("p_", "").replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/");
616
+ if (r.isTupleType(b)) {
617
+ const U = b;
618
+ r.getTypeArguments(U).forEach((Q, z) => {
619
+ r.isTypeAssignableTo(Q, D) && w.push({
542
620
  __typename: "ReferenceValue",
543
621
  nodeFunctionId: j,
544
622
  parameterIndex: isNaN(M) ? 0 : M,
545
- inputIndex: B,
623
+ inputIndex: z,
546
624
  //@ts-ignore
547
- inputTypeIdentifier: z.target.labeledElementDeclarations?.[B].name.getText()
625
+ inputTypeIdentifier: U.target.labeledElementDeclarations?.[z].name.getText()
548
626
  });
549
627
  });
550
628
  }
551
629
  }
552
- }), E;
553
- }, me = (t, n) => {
630
+ }), w;
631
+ }, de = (t, n) => {
554
632
  if (!t) return [];
555
633
  const i = `
556
- ${O(n)}
634
+ ${R(n)}
557
635
  type VALUE = ${t}; const val: VALUE = {} as any;
558
- `, r = "index.ts", g = P(r, i), l = g.getSourceFile(r), u = g.languageService.getProgram().getTypeChecker(), c = l.statements.find(
559
- (s) => m.isTypeAliasDeclaration(s) && s.name.text === "VALUE"
636
+ `, a = "index.ts", c = L(a, i), g = c.getSourceFile(a), p = c.languageService.getProgram().getTypeChecker(), u = g.statements.find(
637
+ (o) => F.isTypeAliasDeclaration(o) && o.name.text === "VALUE"
560
638
  );
561
- if (!c || !m.isTypeAliasDeclaration(c)) return [];
562
- const d = u.getTypeAtLocation(c), a = (s) => s.isUnion() ? s.types.flatMap(a) : s.isStringLiteral() ? [s.value] : s.isNumberLiteral() ? [s.value.toString()] : s.intrinsicName === "true" ? ["true"] : s.intrinsicName === "false" ? ["false"] : [];
563
- return Array.from(new Set(a(d))).map((s) => ({
639
+ if (!u || !F.isTypeAliasDeclaration(u)) return [];
640
+ const m = p.getTypeAtLocation(u), r = (o) => o.isUnion() ? o.types.flatMap(r) : o.isStringLiteral() ? [o.value] : o.isNumberLiteral() ? [o.value.toString()] : o.intrinsicName === "true" ? ["true"] : o.intrinsicName === "false" ? ["false"] : [];
641
+ return Array.from(new Set(r(m))).map((o) => ({
564
642
  __typename: "LiteralValue",
565
- value: s
643
+ value: o
566
644
  }));
567
- }, de = (t, n, i) => {
568
- const r = U(t, n, i), g = "index.ts", l = P(g, r), p = l.getSourceFile(g), d = l.languageService.getProgram().getSemanticDiagnostics(p).map((a) => {
569
- const F = Z(a.messageText, `
645
+ }, ye = (t, n, i) => {
646
+ const a = H(t, n, i), c = "index.ts", g = L(c, a), f = g.getSourceFile(c), m = g.languageService.getProgram().getSemanticDiagnostics(f).map((r) => {
647
+ const d = Z(r.messageText, `
570
648
  `);
571
- let s, y;
572
- if (a.start !== void 0) {
573
- const e = p.getFullText(), o = Math.max(0, a.start - 300), f = Math.min(e.length, a.start), v = e.substring(o, f), T = /\/\* @pos ([^ ]+) (\d+) \*\//g;
574
- let S, C = null, w = -1;
575
- for (; (S = T.exec(v)) !== null; ) {
576
- const x = o + S.index + S[0].length;
577
- x <= a.start && x > w && (w = x, C = S);
649
+ let o, y;
650
+ if (r.start !== void 0) {
651
+ const e = f.getFullText(), s = Math.max(0, r.start - 300), l = Math.min(e.length, r.start), h = e.substring(s, l), T = /\/\* @pos ([^ ]+) (\d+) \*\//g;
652
+ let v, _ = null, E = -1;
653
+ for (; (v = T.exec(h)) !== null; ) {
654
+ const S = s + v.index + v[0].length;
655
+ S <= r.start && S > E && (E = S, _ = v);
578
656
  }
579
- C && (s = C[1], y = parseInt(C[2], 10));
657
+ _ && (o = _[1], y = parseInt(_[2], 10));
580
658
  }
581
659
  return {
582
- message: F,
583
- code: a.code,
660
+ message: d,
661
+ code: r.code,
584
662
  severity: "error",
585
- nodeId: s,
663
+ nodeId: o,
586
664
  parameterIndex: y
587
665
  };
588
- }).filter((a) => a !== null);
666
+ }).filter((r) => r !== null);
589
667
  return {
590
- isValid: !d.some((a) => a?.severity === "error"),
668
+ isValid: !m.some((r) => r?.severity === "error"),
591
669
  returnType: "void",
592
- diagnostics: d
670
+ diagnostics: m
593
671
  };
594
- }, ye = (t, n, i) => {
595
- const r = JSON.stringify(n?.value), g = `
596
- ${O(i)}
597
- const testValue: ${t} = ${r};
598
- `, l = "index.ts", c = P(l, g).languageService.getSemanticDiagnostics(l).map((d) => {
599
- const a = m.flattenDiagnosticMessageText(d.messageText, `
600
- `), F = a.includes("not assignable to parameter of type") && (a.includes("'{}'") || a.includes("undefined")) || a.includes("not assignable to type 'undefined'") || a.includes("not assignable to type 'void'") || a.includes("may be a mistake because neither type sufficiently overlaps");
672
+ }, Fe = (t, n, i) => {
673
+ const a = JSON.stringify(n?.value), c = `
674
+ ${R(i)}
675
+ const testValue: ${t} = ${a};
676
+ `, g = "index.ts", u = L(g, c).languageService.getSemanticDiagnostics(g).map((m) => {
677
+ const r = F.flattenDiagnosticMessageText(m.messageText, `
678
+ `), d = r.includes("not assignable to parameter of type") && (r.includes("'{}'") || r.includes("undefined")) || r.includes("not assignable to type 'undefined'") || r.includes("not assignable to type 'void'") || r.includes("may be a mistake because neither type sufficiently overlaps");
601
679
  return {
602
- message: a,
603
- code: d.code,
604
- severity: F ? "warning" : "error"
680
+ message: r,
681
+ code: m.code,
682
+ severity: d ? "warning" : "error"
605
683
  };
606
684
  });
607
685
  return {
608
- isValid: !c.some((d) => d.severity === "error"),
686
+ isValid: !u.some((m) => m.severity === "error"),
609
687
  returnType: "void",
610
- diagnostics: c
688
+ diagnostics: u
611
689
  };
612
690
  };
613
691
  export {
614
- H as DataTypeVariant,
615
- de as getFlowValidation,
616
- pe as getNodeSuggestions,
617
- fe as getReferenceSuggestions,
692
+ B as DataTypeVariant,
693
+ ye as getFlowValidation,
694
+ fe as getNodeSuggestions,
695
+ me as getReferenceSuggestions,
618
696
  ue as getTypeFromValue,
619
697
  q as getTypeVariant,
698
+ pe as getTypesFromFunction,
620
699
  ie as getTypesFromNode,
621
700
  ge as getValueFromType,
622
- me as getValueSuggestions,
623
- ye as getValueValidation
701
+ de as getValueSuggestions,
702
+ Fe as getValueValidation
624
703
  };
package/dist/utils.d.ts CHANGED
@@ -30,7 +30,7 @@ export declare const DEFAULT_COMPILER_OPTIONS: ts.CompilerOptions;
30
30
  /**
31
31
  * Extracts and returns common type and generic declarations from DATA_TYPES.
32
32
  */
33
- export declare function getSharedTypeDeclarations(dataTypes?: DataType[]): string;
33
+ export declare function getSharedTypeDeclarations(dataTypes?: DataType[], genericType?: string): string;
34
34
  /**
35
35
  * Determines the type along a reference path for objects.
36
36
  * @param value The base value to traverse.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/triangulum",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/code0-tech/triangulum#readme",
6
6
  "bugs": {