@baklavajs/core
Advanced tools
Comparing version 2.0.2-beta.3 to 2.0.2-beta.4
@@ -11,3 +11,2 @@ "use strict"; | ||
this.type = definition.type; | ||
this.title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.inputs = {}; | ||
@@ -20,2 +19,3 @@ this.outputs = {}; | ||
: undefined; | ||
this._title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.executeFactory("input", definition.inputs); | ||
@@ -22,0 +22,0 @@ this.executeFactory("output", definition.outputs); |
@@ -18,8 +18,8 @@ "use strict"; | ||
this.type = definition.type; | ||
this.title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.inputs = {}; | ||
this.outputs = {}; | ||
this.preventUpdate = false; | ||
this.staticInputKeys = Object.keys((_b = definition.inputs) !== null && _b !== void 0 ? _b : {}); | ||
this.staticOutputKeys = Object.keys((_c = definition.outputs) !== null && _c !== void 0 ? _c : {}); | ||
this.staticInputKeys = Object.keys((_a = definition.inputs) !== null && _a !== void 0 ? _a : {}); | ||
this.staticOutputKeys = Object.keys((_b = definition.outputs) !== null && _b !== void 0 ? _b : {}); | ||
this._title = (_c = definition.title) !== null && _c !== void 0 ? _c : definition.type; | ||
this.executeFactory("input", definition.inputs); | ||
@@ -26,0 +26,0 @@ this.executeFactory("output", definition.outputs); |
@@ -16,3 +16,2 @@ "use strict"; | ||
this.type = getGraphNodeTypeString(template); | ||
this._title = "GraphNode"; | ||
this.inputs = {}; | ||
@@ -19,0 +18,0 @@ this.outputs = {}; |
@@ -9,2 +9,3 @@ "use strict"; | ||
constructor() { | ||
this._title = ""; | ||
/** Unique identifier of the node */ | ||
@@ -22,2 +23,4 @@ this.id = (0, uuid_1.v4)(); | ||
removeOutput: new events_1.BaklavaEvent(this), | ||
beforeTitleChanged: new events_1.PreventableBaklavaEvent(this), | ||
titleChanged: new events_1.BaklavaEvent(this), | ||
update: new events_1.BaklavaEvent(this), | ||
@@ -37,2 +40,12 @@ }; | ||
} | ||
/** Customizable display name of the node. */ | ||
get title() { | ||
return this._title; | ||
} | ||
set title(v) { | ||
if (!this.events.beforeTitleChanged.emit(v).prevented) { | ||
this._title = v; | ||
this.events.titleChanged.emit(v); | ||
} | ||
} | ||
/** | ||
@@ -80,3 +93,3 @@ * Add an input interface to the node | ||
this.id = state.id; | ||
this.title = state.title; | ||
this._title = state.title; | ||
Object.entries(state.inputs).forEach(([k, v]) => { | ||
@@ -83,0 +96,0 @@ if (this.inputs[k]) { |
@@ -22,3 +22,3 @@ import { InterfaceFactory } from "./defineNode"; | ||
} | ||
export type DynamicNodeDefinition = Record<string, () => NodeInterface<any>>; | ||
export type DynamicNodeDefinition = Record<string, (() => NodeInterface<any>) | undefined>; | ||
export interface DynamicNodeUpdateResult { | ||
@@ -25,0 +25,0 @@ inputs?: DynamicNodeDefinition; |
@@ -87,2 +87,4 @@ import { PreventableBaklavaEvent, BaklavaEvent, SequentialHook, IBaklavaEventEmitter, IBaklavaTapable } from "@baklavajs/events"; | ||
readonly removeOutput: BaklavaEvent<import("./nodeInterface").NodeInterface<any>, AbstractNode>; | ||
readonly beforeTitleChanged: PreventableBaklavaEvent<string, AbstractNode>; | ||
readonly titleChanged: BaklavaEvent<string, AbstractNode>; | ||
readonly update: BaklavaEvent<import("./eventDataTypes").INodeUpdateEventData | null, AbstractNode>; | ||
@@ -99,2 +101,4 @@ } & import("@baklavajs/events").ISubscribableProxy<{ | ||
readonly removeOutput: BaklavaEvent<import("./nodeInterface").NodeInterface<any>, AbstractNode>; | ||
readonly beforeTitleChanged: PreventableBaklavaEvent<string, AbstractNode>; | ||
readonly titleChanged: BaklavaEvent<string, AbstractNode>; | ||
readonly update: BaklavaEvent<import("./eventDataTypes").INodeUpdateEventData | null, AbstractNode>; | ||
@@ -101,0 +105,0 @@ }>; |
@@ -8,3 +8,2 @@ import { Node } from "./node"; | ||
this.type = definition.type; | ||
this.title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.inputs = {}; | ||
@@ -17,2 +16,3 @@ this.outputs = {}; | ||
: undefined; | ||
this._title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.executeFactory("input", definition.inputs); | ||
@@ -19,0 +19,0 @@ this.executeFactory("output", definition.outputs); |
@@ -14,8 +14,8 @@ import { Node } from "./node"; | ||
this.type = definition.type; | ||
this.title = (_a = definition.title) !== null && _a !== void 0 ? _a : definition.type; | ||
this.inputs = {}; | ||
this.outputs = {}; | ||
this.preventUpdate = false; | ||
this.staticInputKeys = Object.keys((_b = definition.inputs) !== null && _b !== void 0 ? _b : {}); | ||
this.staticOutputKeys = Object.keys((_c = definition.outputs) !== null && _c !== void 0 ? _c : {}); | ||
this.staticInputKeys = Object.keys((_a = definition.inputs) !== null && _a !== void 0 ? _a : {}); | ||
this.staticOutputKeys = Object.keys((_b = definition.outputs) !== null && _b !== void 0 ? _b : {}); | ||
this._title = (_c = definition.title) !== null && _c !== void 0 ? _c : definition.type; | ||
this.executeFactory("input", definition.inputs); | ||
@@ -22,0 +22,0 @@ this.executeFactory("output", definition.outputs); |
@@ -12,3 +12,2 @@ import { AbstractNode } from "./node"; | ||
this.type = getGraphNodeTypeString(template); | ||
this._title = "GraphNode"; | ||
this.inputs = {}; | ||
@@ -15,0 +14,0 @@ this.outputs = {}; |
@@ -6,2 +6,3 @@ import { v4 as uuidv4 } from "uuid"; | ||
constructor() { | ||
this._title = ""; | ||
/** Unique identifier of the node */ | ||
@@ -19,2 +20,4 @@ this.id = uuidv4(); | ||
removeOutput: new BaklavaEvent(this), | ||
beforeTitleChanged: new PreventableBaklavaEvent(this), | ||
titleChanged: new BaklavaEvent(this), | ||
update: new BaklavaEvent(this), | ||
@@ -34,2 +37,12 @@ }; | ||
} | ||
/** Customizable display name of the node. */ | ||
get title() { | ||
return this._title; | ||
} | ||
set title(v) { | ||
if (!this.events.beforeTitleChanged.emit(v).prevented) { | ||
this._title = v; | ||
this.events.titleChanged.emit(v); | ||
} | ||
} | ||
/** | ||
@@ -77,3 +90,3 @@ * Add an input interface to the node | ||
this.id = state.id; | ||
this.title = state.title; | ||
this._title = state.title; | ||
Object.entries(state.inputs).forEach(([k, v]) => { | ||
@@ -80,0 +93,0 @@ if (this.inputs[k]) { |
@@ -69,2 +69,4 @@ import { BaklavaEvent, IBaklavaEventEmitter, IBaklavaTapable, PreventableBaklavaEvent, SequentialHook, ParallelHook } from "@baklavajs/events"; | ||
readonly removeOutput: BaklavaEvent<NodeInterface<any>, AbstractNode>; | ||
readonly beforeTitleChanged: PreventableBaklavaEvent<string, AbstractNode>; | ||
readonly titleChanged: BaklavaEvent<string, AbstractNode>; | ||
readonly update: BaklavaEvent<import("./eventDataTypes").INodeUpdateEventData | null, AbstractNode>; | ||
@@ -81,2 +83,4 @@ } & import("@baklavajs/events").ISubscribableProxy<{ | ||
readonly removeOutput: BaklavaEvent<NodeInterface<any>, AbstractNode>; | ||
readonly beforeTitleChanged: PreventableBaklavaEvent<string, AbstractNode>; | ||
readonly titleChanged: BaklavaEvent<string, AbstractNode>; | ||
readonly update: BaklavaEvent<import("./eventDataTypes").INodeUpdateEventData | null, AbstractNode>; | ||
@@ -83,0 +87,0 @@ }>; |
@@ -19,6 +19,5 @@ import { PreventableBaklavaEvent, BaklavaEvent, SequentialHook, IBaklavaEventEmitter, IBaklavaTapable } from "@baklavajs/events"; | ||
export declare abstract class AbstractNode implements IBaklavaEventEmitter, IBaklavaTapable { | ||
protected _title: string; | ||
/** Type of the node */ | ||
abstract readonly type: string; | ||
/** Customizable display name of the node. */ | ||
abstract title: string; | ||
/** Unique identifier of the node */ | ||
@@ -38,2 +37,4 @@ id: string; | ||
readonly removeOutput: BaklavaEvent<NodeInterface<any>, AbstractNode>; | ||
readonly beforeTitleChanged: PreventableBaklavaEvent<string, AbstractNode>; | ||
readonly titleChanged: BaklavaEvent<string, AbstractNode>; | ||
readonly update: BaklavaEvent<INodeUpdateEventData | null, AbstractNode>; | ||
@@ -52,2 +53,5 @@ }; | ||
get graph(): Graph | undefined; | ||
/** Customizable display name of the node. */ | ||
get title(): string; | ||
set title(v: string); | ||
/** | ||
@@ -54,0 +58,0 @@ * Add an input interface to the node |
{ | ||
"name": "@baklavajs/core", | ||
"version": "2.0.2-beta.3", | ||
"version": "2.0.2-beta.4", | ||
"description": "Core logic of BaklavaJS, a graph editor / node editor for the web", | ||
@@ -29,14 +29,14 @@ "author": "newcat <freddy.wagner@web.de>", | ||
"dependencies": { | ||
"@baklavajs/events": "^2.0.2-beta.3", | ||
"@baklavajs/events": "^2.0.2-beta.4", | ||
"uuid": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.2.4", | ||
"@types/uuid": "^9.0.0", | ||
"jest": "^29.3.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^29.0.3", | ||
"@types/jest": "^29.5.2", | ||
"@types/uuid": "^9.0.1", | ||
"jest": "^29.5.0", | ||
"rimraf": "^5.0.1", | ||
"ts-jest": "^29.1.0", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.23", | ||
"typescript": "^4.9.4" | ||
"typedoc": "^0.24.7", | ||
"typescript": "^5.1.3" | ||
}, | ||
@@ -46,3 +46,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "ad6d2ab3a173944d0184adb12ac7cc44ab987554" | ||
"gitHead": "faa9f2d0e96551e57ad870147bab6d9edc39edde" | ||
} |
131025
3194