Skip to content

Commit da58089

Browse files
committed
v1.3.1-rc.1, rename interfaces and fix worker params
1 parent 2fe75b9 commit da58089

File tree

7 files changed

+277
-269
lines changed

7 files changed

+277
-269
lines changed

package-lock.json

+243-237
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rete",
3-
"version": "1.3.0",
3+
"version": "1.3.1-rc.1",
44
"description": "JavaScript framework",
55
"main": "build/rete.common.js",
66
"module": "build/rete.esm.js",

src/core/data.ts

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
1-
export interface Connection {
1+
export interface ConnectionData {
22
node: number;
33
data: any;
44
}
55

6-
export type InputConnection = Connection & {
6+
export type InputConnectionData = ConnectionData & {
77
output: string;
88
}
9-
export type OutputConnection = Connection & {
9+
export type OutputConnectionData = ConnectionData & {
1010
input: string;
1111
}
1212

13-
export interface Input {
14-
connections: InputConnection[];
13+
export interface InputData {
14+
connections: InputConnectionData[];
1515
}
16-
export interface Output {
17-
connections: OutputConnection[];
16+
export interface OutputData {
17+
connections: OutputConnectionData[];
1818
}
1919

20-
export interface Inputs { [key: string]: Input }
21-
export interface Outputs { [key: string]: Output }
20+
export interface InputsData { [key: string]: InputData }
21+
export interface OutputsData { [key: string]: OutputData }
2222

23-
export interface Node {
23+
export interface NodeData {
2424
id: number;
2525
name: string;
26-
inputs: Inputs;
27-
outputs: Outputs;
26+
inputs: InputsData;
27+
outputs: OutputsData;
2828
data: any;
2929
position: [number, number];
3030
}
3131

32-
export interface Nodes { [id: string]: Node }
32+
export interface NodesData { [id: string]: NodeData }
3333

3434
export interface Data {
3535
id: string;
36-
nodes: Nodes;
37-
}
36+
nodes: NodesData;
37+
}
38+
39+
export interface WorkerInputs { [key: string]: any[] }
40+
41+
export interface WorkerOutputs { [key: string]: any }

src/engine/component.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Engine } from './index';
2-
import { Node } from '../core/data';
3-
4-
export interface IOs { [key: string]: any }
2+
import { NodeData, WorkerInputs, WorkerOutputs } from '../core/data';
53

64
export abstract class Component {
75

@@ -13,5 +11,5 @@ export abstract class Component {
1311
this.name = name;
1412
}
1513

16-
abstract worker(node: Node, inputs: IOs, outputs: IOs, ...args: any): any;
14+
abstract worker(node: NodeData, inputs: WorkerInputs, outputs: WorkerOutputs, ...args: any): any;
1715
}

src/engine/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Context } from '../core/context';
33
import { Recursion } from './recursion';
44
import { State } from './state';
55
import { Validator } from '../core/validator';
6-
import { Data, Node } from '../core/data';
6+
import { Data, NodeData } from '../core/data';
77
import { EngineEvents, EventsTypes } from './events';
88

99
export { Component, Recursion };
1010

11-
interface EngineNode extends Node {
11+
interface EngineNode extends NodeData {
1212
busy: boolean;
1313
unlockPool: any[];
1414
outputData: any;
@@ -102,7 +102,7 @@ export class Engine extends Context<EventsTypes> {
102102
node.busy = false;
103103
}
104104

105-
private async extractInputData(node: Node) {
105+
private async extractInputData(node: NodeData) {
106106
const obj: {[id: string]: any} = {};
107107

108108
for (let key of Object.keys(node.inputs)) {
@@ -125,7 +125,7 @@ export class Engine extends Context<EventsTypes> {
125125
return obj;
126126
}
127127

128-
private async processWorker(node: Node) {
128+
private async processWorker(node: NodeData) {
129129
const inputData = await this.extractInputData(node);
130130
const component = this.components.get(node.name) as Component;
131131
const outputData = {};
@@ -154,7 +154,7 @@ export class Engine extends Context<EventsTypes> {
154154
return node.outputData;
155155
}
156156

157-
private async forwardProcess(node: Node) {
157+
private async forwardProcess(node: NodeData) {
158158
if (this.state === State.ABORT)
159159
return null;
160160

src/engine/recursion.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { Node, Nodes } from '../core/data';
1+
import { NodeData, NodesData } from '../core/data';
22

33
function intersect(array1: any[], array2: any[]) {
44
return array1.filter(value => -1 !== array2.indexOf(value));
55
}
66

77
export class Recursion {
88

9-
nodes: Nodes;
9+
nodes: NodesData;
1010

11-
constructor(nodes: Nodes) {
11+
constructor(nodes: NodesData) {
1212
this.nodes = nodes;
1313
}
1414

15-
extractInputNodes(node: Node): Node[] {
15+
extractInputNodes(node: NodeData): NodeData[] {
1616
return Object.keys(node.inputs).reduce((a: any[], key: string) => {
1717
const { connections } = node.inputs[key];
1818

1919
return [...a, ...(connections || []).reduce((b: any[], c: any) => [...b, this.nodes[c.node]], [])]
2020
}, []);
2121
}
2222

23-
findSelf(list: any[], inputNodes: Node[]): Node | null {
23+
findSelf(list: any[], inputNodes: NodeData[]): NodeData | null {
2424
const inters = intersect(list, inputNodes);
2525

2626
if (inters.length)
@@ -37,7 +37,7 @@ export class Recursion {
3737
return null;
3838
}
3939

40-
detect(): Node | null {
40+
detect(): NodeData | null {
4141
const nodesArr = Object.keys(this.nodes).map(id => this.nodes[id]);
4242

4343
for (let node of nodesArr) {

src/node.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Connection } from './connection';
22
import { Control } from './control';
33
import { Input } from './input';
4-
import { Node as NodeData } from './core/data';
4+
import { NodeData } from './core/data';
55
import { Output } from './output';
66

77
export class Node {

0 commit comments

Comments
 (0)