@babsey/code-graph 0.9.5 → 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.
- package/dist/code-graph.js +297 -261
- package/dist/code-graph.umd.cjs +4 -4
- package/dist/codeEditor.d.ts +16 -1
- package/dist/codeGraph/codeGraph.d.ts +10 -4
- package/dist/codeNode/codeNode.d.ts +1 -1
- package/dist/codeNode/defineCodeNode.d.ts +1 -1
- package/dist/codeNode/dynamicCodeNode.d.ts +1 -1
- package/package.json +1 -1
package/dist/codeEditor.d.ts
CHANGED
|
@@ -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
|
|
@@ -50,6 +50,10 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
|
|
|
50
50
|
* @param to code node interface
|
|
51
51
|
*/
|
|
52
52
|
addConnection(from: CodeNodeInterface, to: CodeNodeInterface): void;
|
|
53
|
+
/**
|
|
54
|
+
* Execute calls of nodes before running graph.
|
|
55
|
+
*/
|
|
56
|
+
beforeRun(): void;
|
|
53
57
|
/**
|
|
54
58
|
* Clear code graph.
|
|
55
59
|
*/
|
|
@@ -85,10 +89,6 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
|
|
|
85
89
|
* @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
|
|
86
90
|
*/
|
|
87
91
|
load(state: IGraphState): string[];
|
|
88
|
-
/**
|
|
89
|
-
* Trigger on graph update.
|
|
90
|
-
*/
|
|
91
|
-
onUpdate(): void;
|
|
92
92
|
/**
|
|
93
93
|
* Render code script.
|
|
94
94
|
*/
|
|
@@ -99,6 +99,12 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
|
|
|
99
99
|
* Sort code nodes.
|
|
100
100
|
*/
|
|
101
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;
|
|
102
108
|
}
|
|
103
109
|
/**
|
|
104
110
|
* Get code nodes of current graph.
|
|
@@ -48,8 +48,8 @@ export declare abstract class AbstractCodeNode extends AbstractNode {
|
|
|
48
48
|
set variableName(value: string);
|
|
49
49
|
abstract afterGraphLoaded(): void;
|
|
50
50
|
abstract afterLoaded(): void;
|
|
51
|
+
abstract beforeRun(): void;
|
|
51
52
|
abstract onConnected(): void;
|
|
52
|
-
abstract onGraphUpdate(): void;
|
|
53
53
|
abstract onUnconnected(): void;
|
|
54
54
|
abstract update(): void;
|
|
55
55
|
/**
|
|
@@ -5,11 +5,11 @@ export type NodeInstanceOf<T> = T extends new () => Node<infer A, infer B> ? Nod
|
|
|
5
5
|
export interface ICodeNodeDefinition<I, O> extends INodeDefinition<I, O> {
|
|
6
6
|
afterGraphLoaded?: () => void;
|
|
7
7
|
afterLoaded?: () => void;
|
|
8
|
+
beforeRun?: () => void;
|
|
8
9
|
codeTemplate?: (node?: AbstractCodeNode) => string;
|
|
9
10
|
modules?: string[];
|
|
10
11
|
name?: string;
|
|
11
12
|
onConnected?: () => void;
|
|
12
|
-
onGraphUpdate?: () => void;
|
|
13
13
|
onUnconnected?: () => void;
|
|
14
14
|
update?: (node?: AbstractCodeNode) => void;
|
|
15
15
|
variableName?: string;
|
|
@@ -21,11 +21,11 @@ export interface DynamicNodeUpdateResult {
|
|
|
21
21
|
export interface IDynamicCodeNodeDefinition<I, O> extends IDynamicNodeDefinition<I, O> {
|
|
22
22
|
afterGraphLoaded?: () => void;
|
|
23
23
|
afterLoaded?: () => void;
|
|
24
|
+
beforeRun?: () => void;
|
|
24
25
|
codeTemplate?: (node?: AbstractCodeNode) => string;
|
|
25
26
|
name?: string;
|
|
26
27
|
modules?: string[];
|
|
27
28
|
onConnected?: () => void;
|
|
28
|
-
onGraphUpdate?: () => void;
|
|
29
29
|
onUnconnected?: () => void;
|
|
30
30
|
update?: (node?: AbstractCodeNode) => void;
|
|
31
31
|
variableName?: string;
|