New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nodescript/core

Package Overview
Dependencies
Maintainers
1
Versions
267
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodescript/core - npm Package Compare versions

Comparing version 0.16.1 to 0.17.0

74

out/main/runtime/compiler.js

@@ -119,9 +119,9 @@ import { isSchemaCompatible } from '../util/index.js';

if (this.isNodeCached(node)) {
this.code.line(`const $c = ctx.$cache.get("${node.id}");`);
this.code.line(`const $c = ctx.cache.get("${node.id}");`);
this.code.line('if ($c) { if ($c.error) { throw $c.error } return $c.result }');
this.code.block('try {', '}', () => {
this.emitNodeBody(node);
this.emitNodeBodyIntrospect(node);
});
this.code.block('catch (error) {', '}', () => {
this.code.line(`ctx.$cache.set("${node.id}", { error });`);
this.code.line(`ctx.cache.set("${node.id}", { error });`);
this.code.line(`throw error;`);

@@ -131,3 +131,3 @@ });

else {
this.emitNodeBody(node);
this.emitNodeBodyIntrospect(node);
}

@@ -138,29 +138,17 @@ });

this.code.line(`const {` +
`$convertType:${this.sym.convertType},` +
`$toArray:${this.sym.toArray},` +
`$nodeEvaluated:${this.sym.nodeEvaluated},` +
`convertType:${this.sym.convertType},` +
`toArray:${this.sym.toArray},` +
`nodeEvaluated:${this.sym.nodeEvaluated},` +
`} = ctx;`);
}
emitNodeBody(node) {
emitNodeBodyIntrospect(node) {
const resSym = '$r';
const emitBody = () => {
switch (node.$uri) {
case 'core:Param': return this.emitParamNode(node, resSym);
case 'core:Local': return this.emitLocalNode(node, resSym);
case 'core:Result': return this.emitResultNode(node, resSym);
case 'core:Comment': return;
case 'core:Frame': return;
default:
if (node.isExpanded()) {
this.emitExpandedNode(node, resSym);
}
else {
this.emitRegularNode(node, resSym);
}
}
};
this.code.line(`let ${resSym};`);
if (this.options.introspect) {
this.code.block('try {', '}', () => {
emitBody();
this.code.line(`${this.sym.nodeEvaluated}.emit({` +
`nodeId: ${JSON.stringify(node.id)},` +
`progress: 0` +
`});`);
this.emitNodeBodyRaw(node, resSym);
if (this.options.introspect) {

@@ -183,6 +171,22 @@ this.code.line(`${this.sym.nodeEvaluated}.emit({` +

else {
emitBody();
this.emitNodeBodyRaw(node, resSym);
this.code.line(`return ${resSym};`);
}
}
emitNodeBodyRaw(node, resSym) {
switch (node.$uri) {
case 'core:Param': return this.emitParamNode(node, resSym);
case 'core:Local': return this.emitLocalNode(node, resSym);
case 'core:Result': return this.emitResultNode(node, resSym);
case 'core:Comment': return;
case 'core:Frame': return;
default:
if (node.isExpanded()) {
this.emitExpandedNode(node, resSym);
}
else {
this.emitRegularNode(node, resSym);
}
}
}
emitParamNode(node, resSym) {

@@ -213,3 +217,3 @@ const prop = node.getBasePropByKey('key');

if (this.isNodeCached(node)) {
this.code.line(`ctx.$cache.set("${node.id}", { result: ${resSym} });`);
this.code.line(`ctx.cache.set("${node.id}", { result: ${resSym} });`);
}

@@ -254,4 +258,10 @@ }

}
const cond = expSyms.map(s => `i < ${s}.length`).join(' && ');
this.code.block(`for (let i = 0;${cond};i++) {`, `}`, () => {
this.code.line(`const $l = Math.min(${expSyms.map(s => `${s}.length`).join(',')});`);
this.code.block(`for (let $i = 0; $i < $l; $i++) {`, `}`, () => {
if (this.options.introspect) {
this.code.line(`${this.sym.nodeEvaluated}.emit({` +
`nodeId: ${JSON.stringify(node.id)},` +
`progress: $i / $l` +
`});`);
}
const tempSym = `$t`;

@@ -264,3 +274,3 @@ this.code.block(`const ${tempSym} = ${this.awaitSym}${defSym}.compute({`, `}, ctx);`, () => {

if (this.isNodeCached(node)) {
this.code.line(`ctx.$cache.set("${node.id}", { result: ${resSym} });`);
this.code.line(`ctx.cache.set("${node.id}", { result: ${resSym} });`);
}

@@ -331,3 +341,3 @@ }

// Property was expanded
return `${expSym}[i]`;
return `${expSym}[$i]`;
}

@@ -359,3 +369,3 @@ // The rest only applies to non-expanded properties

return `${this.asyncSym}(p) => {
const childCtx = ctx.$newScope(p);
const childCtx = ctx.newScope(p);
const res = ${this.awaitSym}${linkSym}(params, childCtx);

@@ -362,0 +372,0 @@ return ${schemaCompatible ? 'res' : this.convertTypeExpr(`res`, targetSchema)};

@@ -9,8 +9,9 @@ import { Event } from 'typesafe-event';

export declare abstract class BaseContext implements t.GraphEvalContext {
$cache: Map<string, any>;
cache: Map<string, any>;
abstract getLocal(key: string): any;
abstract $nodeEvaluated: Event<t.NodeResult>;
$newScope(locals: Record<string, any>): BaseContext;
$toArray(value: unknown): unknown[];
$convertType<T>(value: unknown, schema: t.DataSchema<T>): T;
abstract nodeEvaluated: Event<t.NodeResult>;
newScope(locals: Record<string, any>): BaseContext;
toArray(value: unknown): unknown[];
getType(value: unknown): t.DataType;
convertType<T>(value: unknown, schema: t.DataSchema<T>): T;
}

@@ -23,3 +24,3 @@ /**

export declare class GraphEvalContext extends BaseContext {
$nodeEvaluated: Event<t.NodeResult>;
nodeEvaluated: Event<t.NodeResult>;
getLocal(_key: string): any;

@@ -38,4 +39,4 @@ }

constructor(parent: GraphEvalContext, locals?: Record<string, any>);
get $nodeEvaluated(): Event<t.NodeResult>;
get nodeEvaluated(): Event<t.NodeResult>;
getLocal(key: string): any;
}

@@ -1,2 +0,2 @@

import { Schema } from 'airtight';
import { getType, Schema } from 'airtight';
import { Event } from 'typesafe-event';

@@ -12,11 +12,14 @@ /**

// and do not delegate to parent contexts.
this.$cache = new Map();
this.cache = new Map();
}
$newScope(locals) {
newScope(locals) {
return new ScopeEvalContext(this, locals);
}
$toArray(value) {
toArray(value) {
return Array.isArray(value) ? value : [value];
}
$convertType(value, schema) {
getType(value) {
return getType(value);
}
convertType(value, schema) {
return new Schema(schema).decode(value);

@@ -33,3 +36,3 @@ }

super(...arguments);
this.$nodeEvaluated = new Event();
this.nodeEvaluated = new Event();
}

@@ -54,3 +57,3 @@ getLocal(_key) {

}
get $nodeEvaluated() { return this.parent.$nodeEvaluated; }
get nodeEvaluated() { return this.parent.nodeEvaluated; }
getLocal(key) {

@@ -57,0 +60,0 @@ const local = this.locals.get(key);

@@ -8,4 +8,5 @@ import { Schema } from 'airtight';

error: { type: 'any', optional: true },
progress: { type: 'number', optional: true },
}
});
//# sourceMappingURL=node-result.js.map

@@ -1,6 +0,7 @@

import { DataSchema } from './data.js';
import { DataSchema, DataType } from './data.js';
export interface GraphEvalContext {
$cache: Map<string, any>;
cache: Map<string, any>;
getLocal(key: string): unknown;
$convertType<T>(value: unknown, schema: DataSchema<T>): T;
getType(value: unknown): DataType;
convertType<T>(value: unknown, schema: DataSchema<T>): T;
}

@@ -5,2 +5,3 @@ export interface NodeResult {

error?: any;
progress?: number;
}
{
"name": "@nodescript/core",
"version": "0.16.1",
"version": "0.17.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc