@babsey/code-graph 0.9.6 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,16 @@
1
1
  import { IBaklavaEventEmitter, IBaklavaTapable } from '@baklavajs/events';
2
- import { IEditorState, Editor } from '@baklavajs/core';
2
+ import { IEditorState, IRegisterNodeTypeOptions, Editor } from '@baklavajs/core';
3
3
  import { CodeGraph, CodeGraphTemplate } from './codeGraph';
4
4
  import { Code } from './code';
5
+ import { AbstractCodeNodeConstructor } from './codeNode';
6
+ export interface IRegisterCodeNodeTypeOptions extends IRegisterNodeTypeOptions {
7
+ /** Category of the node. Can be used to structure the node palette view */
8
+ category?: string;
9
+ /** Set rank for sorting order */
10
+ orderRank?: number;
11
+ /** Set the title of the node in the node palette. Will use the `title` property of the node when not specified */
12
+ title?: string;
13
+ }
5
14
  export declare class CodeEditor extends Editor implements IBaklavaEventEmitter, IBaklavaTapable {
6
15
  code: Code;
7
16
  graph: CodeGraph;
@@ -19,6 +28,12 @@ export declare class CodeEditor extends Editor implements IBaklavaEventEmitter,
19
28
  * @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
20
29
  */
21
30
  load(state: IEditorState): string[];
31
+ /**
32
+ * Register a new node type.
33
+ * @param nodeType Actual type / constructor of the node
34
+ * @param options Optionally specify a title and/or a category for this node
35
+ */
36
+ registerNodeType(type: AbstractCodeNodeConstructor, options?: IRegisterCodeNodeTypeOptions): void;
22
37
  /**
23
38
  * Register category module
24
39
  * @param category string
@@ -89,10 +89,6 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
89
89
  * @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
90
90
  */
91
91
  load(state: IGraphState): string[];
92
- /**
93
- * Trigger on graph update.
94
- */
95
- onUpdate(): void;
96
92
  /**
97
93
  * Render code script.
98
94
  */
@@ -103,6 +99,12 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
103
99
  * Sort code nodes.
104
100
  */
105
101
  sortNodes(): void;
102
+ /**
103
+ * Sort nodes by order rank of node types.
104
+ * @remarks Set `orderRank` in `registerNodeType` function,
105
+ * e.g. editor.registerNodeType(nodeType, {orderRank: 0})
106
+ */
107
+ sortNodesByRank(): void;
106
108
  }
107
109
  /**
108
110
  * Get code nodes of current graph.
@@ -50,7 +50,6 @@ export declare abstract class AbstractCodeNode extends AbstractNode {
50
50
  abstract afterLoaded(): void;
51
51
  abstract beforeRun(): void;
52
52
  abstract onConnected(): void;
53
- abstract onGraphUpdate(): void;
54
53
  abstract onUnconnected(): void;
55
54
  abstract update(): void;
56
55
  /**
@@ -10,7 +10,6 @@ export interface ICodeNodeDefinition<I, O> extends INodeDefinition<I, O> {
10
10
  modules?: string[];
11
11
  name?: string;
12
12
  onConnected?: () => void;
13
- onGraphUpdate?: () => void;
14
13
  onUnconnected?: () => void;
15
14
  update?: (node?: AbstractCodeNode) => void;
16
15
  variableName?: string;
@@ -26,7 +26,6 @@ export interface IDynamicCodeNodeDefinition<I, O> extends IDynamicNodeDefinition
26
26
  name?: string;
27
27
  modules?: string[];
28
28
  onConnected?: () => void;
29
- onGraphUpdate?: () => void;
30
29
  onUnconnected?: () => void;
31
30
  update?: (node?: AbstractCodeNode) => void;
32
31
  variableName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.9.6",
3
+ "version": "0.10.0",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",