@nodescript/core
Advanced tools
Comparing version 7.14.5 to 7.15.0
@@ -34,2 +34,3 @@ import { GraphView, NodeView } from '../runtime/index.js'; | ||
private emitEvalJson; | ||
private emitEvalTemplate; | ||
private emitGenericCompute; | ||
@@ -36,0 +37,0 @@ private getSubgraphExpr; |
@@ -251,2 +251,4 @@ import { convertAuto, isSchemaCompatible } from '../util/index.js'; | ||
return this.emitEvalJson(node, resSym); | ||
case '@system/EvalTemplate': | ||
return this.emitEvalTemplate(node, resSym); | ||
default: | ||
@@ -320,2 +322,19 @@ return this.emitGenericCompute(node, resSym); | ||
} | ||
emitEvalTemplate(node, resSym) { | ||
const template = (node.getProp('template')?.value ?? '') | ||
.replace(/`/g, '\\`') | ||
.replace(/\\\\`/g, '\\\\\\`'); | ||
this.code.block(`const $p = {`, `}`, () => { | ||
const prop = node.getProp('args'); | ||
if (prop) { | ||
this.emitProp(prop); | ||
} | ||
}); | ||
const args = node.getProp('args')?.getEntries() ?? []; | ||
const argList = args.map(_ => _.key).join(','); | ||
const argVals = args.map(_ => `$p.args[${JSON.stringify(_.key)}]`).join(','); | ||
this.code.block(`${resSym} = ((${argList}) => {`, `})(${argVals})`, () => { | ||
this.code.line(`return \`${template}\``); | ||
}); | ||
} | ||
emitGenericCompute(node, resSym) { | ||
@@ -322,0 +341,0 @@ const computeSym = this.symbols.getComputeSym(node.ref); |
@@ -15,2 +15,3 @@ import { ModuleSpecSchema } from '../schema/ModuleSpec.js'; | ||
this.addModule('@system/EvalJson', systemNodes.EvalJson); | ||
this.addModule('@system/EvalTemplate', systemNodes.EvalTemplate); | ||
} | ||
@@ -17,0 +18,0 @@ resolveModule(ref) { |
@@ -5,2 +5,3 @@ export * from './Comment.js'; | ||
export * from './EvalSync.js'; | ||
export * from './EvalTemplate.js'; | ||
export * from './Frame.js'; | ||
@@ -7,0 +8,0 @@ export * from './Input.js'; |
@@ -6,2 +6,3 @@ // This file is auto-generated | ||
export * from './EvalSync.js'; | ||
export * from './EvalTemplate.js'; | ||
export * from './Frame.js'; | ||
@@ -8,0 +9,0 @@ export * from './Input.js'; |
{ | ||
"name": "@nodescript/core", | ||
"version": "7.14.5", | ||
"version": "7.15.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Visual programming language for Browser and Node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
207063
227
3620