Skip to content

Commit

Permalink
update deps, eslint/typing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Sep 30, 2022
1 parent 2a3d81c commit 4227d01
Show file tree
Hide file tree
Showing 18 changed files with 8,821 additions and 7,282 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-parameter-properties": "off"
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-empty-function": "warn"
},
"env": {
"es6": true,
"mocha": true,
"browser": true
},
"globals": {
"WindowEventMap": true
}
}
15,877 changes: 8,706 additions & 7,171 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"build": "rete --build rete.config.js",
"build:dev": "rete --build rete.config.js --watch",
"prepublishOnly": "npm run lint && npm run build",
"prebuild": "npm run lint & npm test && npm run types",
"prebuild": "npm run lint && npm test && npm run types",
"postinstall": "node postinstall.js",
"lint": "tsc && eslint --ext .ts --ext .js src",
"test": "BABEL_ENV=test mocha -r ts-node/register test/**.ts",
"coverage": "nyc npm run test",
"types": "tsc src/index.ts --target es5 --declaration --outDir ./types --downlevelIteration --emitDeclarationOnly"
"types": "tsc src/index.ts --target es5 --declaration --skipLibCheck --outDir ./types --downlevelIteration --emitDeclarationOnly"
},
"repository": {
"type": "git",
Expand All @@ -33,20 +33,20 @@
},
"homepage": "https://github.com/retejs/rete#readme",
"devDependencies": {
"@babel/preset-typescript": "^7.3.3",
"@types/jsdom": "^12.2.2",
"@types/mocha": "^5.2.6",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.12.1",
"jsdom": "^13.2.0",
"jsdom-global": "^3.0.2",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"rete-cli": "0.6.0-rc.5",
"terminal-kit": "^2.4.0",
"ts-node": "^8.0.2",
"typescript": "^3.3.3333"
"@babel/preset-typescript": "7.18.6",
"@types/jsdom": "12.2.2",
"@types/mocha": "5.2.6",
"@typescript-eslint/eslint-plugin": "5.38.1",
"@typescript-eslint/parser": "5.38.1",
"babel-eslint": "10.1.0",
"eslint": "8.24.0",
"jsdom": "13.2.0",
"jsdom-global": "3.0.2",
"mocha": "5.2.0",
"nyc": "14.1.1",
"rete-cli": "0.6.1",
"terminal-kit": "2.4.0",
"ts-node": "8.0.2",
"typescript": "4.8.4"
}
}
6 changes: 3 additions & 3 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export abstract class Component extends ComponentWorker {
super(name);
}

abstract async builder(node: Node): Promise<void>;
abstract builder(node: Node): Promise<void>;

async build(node: Node) {
await this.builder(node);
Expand All @@ -21,10 +21,10 @@ export abstract class Component extends ComponentWorker {

async createNode(data = {}) {
const node = new Node(this.name);

node.data = data;
await this.build(node);

return node;
}
}
}
6 changes: 3 additions & 3 deletions src/core/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export class Emitter<EventTypes> {

trigger<K extends keyof EventTypes>(name: K, params: EventTypes[K] | {} = {}) {
if (!(name in this.events))
throw new Error(`The event ${name} cannot be triggered`);
throw new Error(`The event ${String(name)} cannot be triggered`);

return this.events[name as string].reduce((r: boolean, e: Function) => {
return (e(params) !== false) && r
}, true); // return false if at least one event is false
}, true); // return false if at least one event is false
}

bind(name: string) {
Expand All @@ -40,4 +40,4 @@ export class Emitter<EventTypes> {
exist(name: string) {
return Array.isArray(this.events[name]);
}
}
}
6 changes: 3 additions & 3 deletions src/core/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export class Validator {
static validate(id: string, data: Data) {
const id1 = id.split('@');
const id2 = data.id.split('@');
let msg = [];
const msg = [];

if (!this.isValidData(data))
msg.push('Data is not suitable');
msg.push('Data is not suitable');
if (id !== data.id)
msg.push('IDs not equal');
if (id1[0] !== id2[0])
Expand All @@ -28,4 +28,4 @@ export class Validator {

return { success: Boolean(!msg.length), msg: msg.join('. ') };
}
}
}
30 changes: 15 additions & 15 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class NodeEditor extends Context<EventsTypes> {

constructor(id: string, container: HTMLElement) {
super(id, new EditorEvents());

this.view = new EditorView(container, this.components, this);

this.on('destroy', listenWindow('keydown', e => this.trigger('keydown', e)));
Expand All @@ -43,7 +43,7 @@ export class NodeEditor extends Context<EventsTypes> {

this.nodes.push(node);
this.view.addNode(node);

this.trigger('nodecreated', node);
}

Expand All @@ -69,27 +69,27 @@ export class NodeEditor extends Context<EventsTypes> {

this.trigger('connectioncreated', connection);
} catch (e) {
this.trigger('warn', e)
this.trigger('warn', e as Error)
}
}

removeConnection(connection: Connection) {
if (!this.trigger('connectionremove', connection)) return;

this.view.removeConnection(connection);
connection.remove();

this.trigger('connectionremoved', connection);
}

selectNode(node: Node, accumulate: boolean = false) {
if (this.nodes.indexOf(node) === -1)
selectNode(node: Node, accumulate = false) {
if (this.nodes.indexOf(node) === -1)
throw new Error('Node not exist in list');

if (!this.trigger('nodeselect', node)) return;

this.selected.add(node, accumulate);

this.trigger('nodeselected', node);
}

Expand All @@ -98,7 +98,7 @@ export class NodeEditor extends Context<EventsTypes> {

if (!component)
throw `Component ${name} not found`;

return component as Component;
}

Expand All @@ -114,20 +114,20 @@ export class NodeEditor extends Context<EventsTypes> {

toJSON() {
const data: Data = { id: this.id, nodes: {} };

this.nodes.forEach(node => data.nodes[node.id] = node.toJSON());
this.trigger('export', data);
return data;
}

beforeImport(json: Data) {
const checking = Validator.validate(this.id, json);

if (!checking.success) {
this.trigger('warn', checking.msg);
return false;
}

this.silent = true;
this.clear();
this.trigger('import', json);
Expand All @@ -151,11 +151,11 @@ export class NodeEditor extends Context<EventsTypes> {
nodes[id] = await component.build(Node.fromJSON(node));
this.addNode(nodes[id]);
}));

Object.keys(json.nodes).forEach(id => {
const jsonNode = json.nodes[id];
const node = nodes[id];

Object.keys(jsonNode.outputs).forEach(key => {
const outputJson = jsonNode.outputs[key];

Expand All @@ -175,7 +175,7 @@ export class NodeEditor extends Context<EventsTypes> {

});
} catch (e) {
this.trigger('warn', e);
this.trigger('warn', e as Error);
return !this.afterImport();
}

Expand Down
Loading

0 comments on commit 4227d01

Please sign in to comment.