@babsey/code-graph 0.8.7 → 0.9.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.
Files changed (79) hide show
  1. package/dist/code.d.ts +57 -0
  2. package/dist/codeEditor.d.ts +28 -0
  3. package/dist/codeEngine/codeEngine.d.ts +16 -0
  4. package/dist/codeEngine/index.d.ts +3 -0
  5. package/dist/codeEngine/register.d.ts +11 -0
  6. package/dist/codeEngine/runEngine.command.d.ts +8 -0
  7. package/dist/codeGraph/codeGraph.d.ts +122 -0
  8. package/dist/codeGraph/codeGraphNode.d.ts +12 -0
  9. package/dist/codeGraph/codeGraphTemplate.d.ts +16 -0
  10. package/dist/codeGraph/index.d.ts +4 -0
  11. package/dist/codeGraph/switchCodeGraph.d.ts +8 -0
  12. package/dist/codeNode/codeNode.d.ts +138 -0
  13. package/dist/codeNode/defineCodeNode.d.ts +17 -0
  14. package/dist/codeNode/dynamicCodeNode.d.ts +34 -0
  15. package/dist/codeNode/index.d.ts +3 -0
  16. package/dist/codeNodeInterfaces/baseNumericInterface.d.ts +23 -0
  17. package/dist/codeNodeInterfaces/baseStringInterface.d.ts +5 -0
  18. package/dist/codeNodeInterfaces/checkbox/checkboxInterface.d.ts +5 -0
  19. package/dist/codeNodeInterfaces/codeNode/CodeNodeInterface.vue.d.ts +7 -0
  20. package/dist/codeNodeInterfaces/codeNode/codeNodeInterface.d.ts +21 -0
  21. package/dist/codeNodeInterfaces/codeNode/index.d.ts +2 -0
  22. package/dist/codeNodeInterfaces/codeNodeInput/codeNodeInputInterface.d.ts +6 -0
  23. package/dist/codeNodeInterfaces/codeNodeOutput/codeNodeOutputInterface.d.ts +9 -0
  24. package/dist/codeNodeInterfaces/createInterface.d.ts +12 -0
  25. package/dist/codeNodeInterfaces/index.d.ts +13 -0
  26. package/dist/codeNodeInterfaces/integer/integerInterface.d.ts +6 -0
  27. package/dist/codeNodeInterfaces/listInput/listInputInterface.d.ts +5 -0
  28. package/dist/codeNodeInterfaces/number/numberInterface.d.ts +5 -0
  29. package/dist/codeNodeInterfaces/select/selectInterface.d.ts +12 -0
  30. package/dist/codeNodeInterfaces/slider/sliderInterface.d.ts +9 -0
  31. package/dist/codeNodeInterfaces/textInput/TextInputInterface.vue.d.ts +26 -0
  32. package/dist/codeNodeInterfaces/textInput/textInputInterface.d.ts +7 -0
  33. package/dist/codeNodeInterfaces/textareaInput/textareaInputInterface.d.ts +5 -0
  34. package/dist/codeNodeInterfaces/tupleInput/tupleInputInterface.d.ts +5 -0
  35. package/dist/components/CodeGraphEditor.vue.d.ts +19 -0
  36. package/dist/components/dev/CodeGraphInfo.vue.d.ts +7 -0
  37. package/dist/components/editor/CodeEditor.vue.d.ts +19 -0
  38. package/dist/components/editor/CopyToClipboard.vue.d.ts +7 -0
  39. package/dist/components/index.d.ts +11 -0
  40. package/dist/components/nav/NavBar.vue.d.ts +29 -0
  41. package/dist/components/nav/NavItem.vue.d.ts +17 -0
  42. package/dist/components/node/CodeGraphNode.vue.d.ts +39 -0
  43. package/dist/components/nodeInterface/CodeGraphNodeInterface.vue.d.ts +19 -0
  44. package/dist/components/nodePalette/CodeNodePalette.vue.d.ts +3 -0
  45. package/dist/components/sidebar/CodeGraphSidebar.vue.d.ts +15 -0
  46. package/dist/components/sidebar/SidebarCheckbox.vue.d.ts +13 -0
  47. package/dist/components.d.ts +2 -0
  48. package/dist/icons/Check.vue.d.ts +3 -0
  49. package/dist/icons/CodeVariable.vue.d.ts +3 -0
  50. package/dist/icons/Copy.vue.d.ts +3 -0
  51. package/dist/icons/DotsVertical.vue.d.ts +3 -0
  52. package/dist/icons/Download.vue.d.ts +3 -0
  53. package/dist/icons/LayoutSidebarLeftCollapse.vue.d.ts +3 -0
  54. package/dist/icons/LayoutSidebarLeftExpand.vue.d.ts +3 -0
  55. package/dist/icons/LayoutSidebarRight.vue.d.ts +3 -0
  56. package/dist/icons/LayoutSidebarRightCollapse.vue.d.ts +3 -0
  57. package/dist/icons/LayoutSidebarRightExpand.vue.d.ts +3 -0
  58. package/dist/icons/LockCode.vue.d.ts +3 -0
  59. package/dist/icons/PlayerPlay.vue.d.ts +3 -0
  60. package/dist/icons/Plus.vue.d.ts +3 -0
  61. package/dist/icons/Restore.vue.d.ts +3 -0
  62. package/dist/icons/Schema.vue.d.ts +3 -0
  63. package/dist/icons/SchemaOff.vue.d.ts +3 -0
  64. package/dist/icons/TransitionBottom.vue.d.ts +3 -0
  65. package/dist/icons/Upload.vue.d.ts +3 -0
  66. package/dist/icons/X.vue.d.ts +3 -0
  67. package/dist/icons/index.d.ts +19 -0
  68. package/dist/index.d.ts +14 -0
  69. package/dist/interfaceTypes/default.d.ts +10 -0
  70. package/dist/interfaceTypes/index.d.ts +1 -0
  71. package/dist/settings.d.ts +15 -0
  72. package/dist/subgraph/createSubgraph.command.d.ts +6 -0
  73. package/dist/subgraph/graphInterface.d.ts +68 -0
  74. package/dist/subgraph/index.d.ts +3 -0
  75. package/dist/subgraph/subgraphInterfaceNodes.d.ts +27 -0
  76. package/dist/utils/download.d.ts +2 -0
  77. package/dist/utils/object.d.ts +7 -0
  78. package/dist/viewModel.d.ts +46 -0
  79. package/package.json +4 -3
package/dist/code.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { UnwrapRef } from 'vue';
2
+ import { AbstractCodeNode } from './codeNode';
3
+ import { CodeGraph } from './codeGraph';
4
+ import { CodeEngine } from './codeEngine';
5
+ import { ICodeGraphViewModel } from './viewModel';
6
+ export interface ICodeState {
7
+ lockCode: boolean;
8
+ modules: Record<string, string>;
9
+ script: string;
10
+ template: string;
11
+ }
12
+ export declare class Code {
13
+ private _id;
14
+ private _state;
15
+ viewModel: ICodeGraphViewModel | undefined;
16
+ constructor();
17
+ get engine(): CodeEngine | undefined;
18
+ get graph(): CodeGraph | undefined;
19
+ get id(): string;
20
+ get lockCode(): boolean;
21
+ set lockCode(value: boolean);
22
+ get modules(): string[];
23
+ get script(): string;
24
+ set script(value: string);
25
+ get shortId(): string;
26
+ get state(): UnwrapRef<ICodeState>;
27
+ /**
28
+ * Clear code.
29
+ */
30
+ clear(): void;
31
+ /**
32
+ * Load template from the file.
33
+ * @param resolve: default string in promise resolve (from import)
34
+ */
35
+ loadTemplate(resolve: Promise<{
36
+ default: string;
37
+ }>): Promise<void>;
38
+ /**
39
+ * Register code view model instance.
40
+ * @param viewModel view model
41
+ */
42
+ registerViewModel(viewModel: ICodeGraphViewModel): void;
43
+ /**
44
+ * Render code script.
45
+ * @param data data for render template.
46
+ */
47
+ renderCode(data?: {
48
+ nodes: AbstractCodeNode[];
49
+ modules: string[];
50
+ }): void;
51
+ }
52
+ export declare class PythonCode extends Code {
53
+ constructor();
54
+ }
55
+ export declare class JavascriptCode extends Code {
56
+ constructor();
57
+ }
@@ -0,0 +1,28 @@
1
+ import { IBaklavaEventEmitter, IBaklavaTapable } from '@baklavajs/events';
2
+ import { IEditorState, Editor } from '@baklavajs/core';
3
+ import { CodeGraph, CodeGraphTemplate } from './codeGraph';
4
+ import { Code } from './code';
5
+ export declare class CodeEditor extends Editor implements IBaklavaEventEmitter, IBaklavaTapable {
6
+ code: Code;
7
+ graph: CodeGraph;
8
+ constructor(code: Code);
9
+ get graphIds(): string;
10
+ get graphTemplateIds(): string;
11
+ /**
12
+ * Add code graph template.
13
+ * @param template code graph template
14
+ */
15
+ addGraphTemplate(template: CodeGraphTemplate): void;
16
+ /**
17
+ * Load a state
18
+ * @param state State to load
19
+ * @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
20
+ */
21
+ load(state: IEditorState): string[];
22
+ /**
23
+ * Register category module
24
+ * @param category string
25
+ * @param module string
26
+ */
27
+ registerCategoryModule(category: string, module: string): void;
28
+ }
@@ -0,0 +1,16 @@
1
+ import { CalculationResult } from '@baklavajs/core';
2
+ import { BaseEngine } from '@baklavajs/engine';
3
+ import { CodeGraph } from '../codeGraph';
4
+ import { CodeEditor } from '../codeEditor';
5
+ import { CodeNodeInterface } from '../codeNodeInterfaces';
6
+ export declare const allowMultipleConnections: <T extends Array<unknown>>(intf: CodeNodeInterface<T>) => void;
7
+ export declare class CodeEngine<CalculationData = unknown> extends BaseEngine<CalculationData, []> {
8
+ private order;
9
+ constructor(editor: CodeEditor);
10
+ start(): void;
11
+ runGraph(graph: CodeGraph, inputs: Map<string, unknown>, calculationData: CalculationData): Promise<CalculationResult>;
12
+ protected execute(calculationData: CalculationData): Promise<CalculationResult>;
13
+ getInputValues(graph: CodeGraph): Map<string, unknown>;
14
+ protected onChange(recalculateOrder: boolean): void;
15
+ private getInterfaceValue;
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './codeEngine';
2
+ export * from './register';
3
+ export * from './runEngine.command';
@@ -0,0 +1,11 @@
1
+ import { INodeState } from '@baklavajs/core';
2
+ import { ICodeGraphViewModel } from '../viewModel';
3
+ export interface IViewNodeState extends INodeState<unknown, unknown> {
4
+ position: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ width: number;
9
+ twoColumn: boolean;
10
+ }
11
+ export declare function registerCodeEngine(viewModel: ICodeGraphViewModel): void;
@@ -0,0 +1,8 @@
1
+ import { ICommandHandler } from '@baklavajs/renderer-vue';
2
+ import { CodeGraph } from '../codeGraph';
3
+ import { CodeEngine } from './codeEngine';
4
+ /**
5
+ * Reister run engine commands.
6
+ * @param viewModel view model instance
7
+ */
8
+ export declare const registerRunEngineCommands: (graph: CodeGraph, engine: CodeEngine, handler: ICommandHandler) => void;
@@ -0,0 +1,122 @@
1
+ import { Graph, GraphTemplate, Connection, NodeInterface, IGraphState } from '@baklavajs/core';
2
+ import { UnwrapRef } from 'vue';
3
+ import { IBaklavaEventEmitter, IBaklavaTapable } from '@baklavajs/events';
4
+ import { AbstractCodeNode } from '../codeNode';
5
+ import { Code } from '../code';
6
+ import { CodeEditor } from '../codeEditor';
7
+ import { CodeNodeInterface } from '../codeNodeInterfaces';
8
+ export declare const NODE_DEFAULT_WITH = 350;
9
+ interface IPosition {
10
+ x: number;
11
+ y: number;
12
+ }
13
+ export interface ICodeGraphState {
14
+ codeTemplate: string;
15
+ lockCode: boolean;
16
+ }
17
+ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IBaklavaTapable {
18
+ code: Code | null;
19
+ editor: CodeEditor;
20
+ private _state;
21
+ constructor(editor: CodeEditor, template?: GraphTemplate);
22
+ get codeNodes(): AbstractCodeNode[];
23
+ get connections(): Connection[];
24
+ set connections(values: Connection[]);
25
+ get nodeIds(): string[];
26
+ get nodes(): AbstractCodeNode[];
27
+ set nodes(values: AbstractCodeNode[]);
28
+ get scriptedCodeNodes(): AbstractCodeNode[];
29
+ get selectedNodeIds(): string[];
30
+ get shortId(): string;
31
+ get state(): UnwrapRef<ICodeGraphState>;
32
+ get visibleNodes(): AbstractCodeNode[];
33
+ /**
34
+ * Add code node to graph.
35
+ * @param node code node
36
+ * @param props optional
37
+ */
38
+ addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined;
39
+ /**
40
+ * Add code node at coordinates.
41
+ * @param node code node
42
+ * @param position position
43
+ * @param props optional
44
+ * @returns code node
45
+ */
46
+ addNodeAtCoordinates: (node: AbstractCodeNode, position?: IPosition, props?: unknown) => AbstractCodeNode;
47
+ /**
48
+ * Add connection of code nodes
49
+ * @param from code node interface
50
+ * @param to code node interface
51
+ */
52
+ addConnection(from: CodeNodeInterface, to: CodeNodeInterface): void;
53
+ /**
54
+ * Clear code graph.
55
+ */
56
+ clear(): void;
57
+ /**
58
+ * Find node by type.
59
+ * @param nodeType node type
60
+ * @returns node instance
61
+ */
62
+ findNodeByType(nodeType: string): AbstractCodeNode | undefined;
63
+ /**
64
+ * Get nodes of the type.
65
+ * @param type node type
66
+ * @returns a list of node instances
67
+ */
68
+ getNodesByType(type: string): AbstractCodeNode[];
69
+ /**
70
+ * Get nodes of the variable name.
71
+ * @param variableName variable name
72
+ * @returns a list of node instances
73
+ */
74
+ getNodesByVariableName(variableName: string): AbstractCodeNode[];
75
+ /**
76
+ * Check whether the graph has this connection.
77
+ * @param from node interface
78
+ * @param to node interface
79
+ * @returns boolean
80
+ */
81
+ hasConnection(from: NodeInterface, to: NodeInterface): boolean;
82
+ /**
83
+ * Load a state.
84
+ * @param state State to load
85
+ * @returns An array of warnings that occured during loading. If the array is empty, the state was successfully loaded.
86
+ */
87
+ load(state: IGraphState): string[];
88
+ /**
89
+ * Trigger on graph update.
90
+ */
91
+ onUpdate(): void;
92
+ /**
93
+ * Render code script.
94
+ */
95
+ renderCode(data: {
96
+ nodes: AbstractCodeNode[];
97
+ }): string;
98
+ /**
99
+ * Sort code nodes.
100
+ */
101
+ sortNodes(): void;
102
+ }
103
+ /**
104
+ * Get code nodes of current graph.
105
+ * @param graph graph / subgraph
106
+ * @returns list of code nodes
107
+ */
108
+ export declare const getCodeNodes: (graph: CodeGraph) => AbstractCodeNode[];
109
+ /**
110
+ * Get position at specific column.
111
+ * @param col column
112
+ * @param offset number
113
+ * @returns position
114
+ */
115
+ export declare const getPositionAtColumn: (col?: number, offset?: number) => IPosition;
116
+ /**
117
+ * Get position before target node.
118
+ * @param node code node
119
+ * @returns position
120
+ */
121
+ export declare const getPositionBeforeNode: (node: AbstractCodeNode) => IPosition;
122
+ export {};
@@ -0,0 +1,12 @@
1
+ import { GraphTemplate, IGraphNode, INodeState } from '@baklavajs/core';
2
+ import { AbstractCodeNode } from '../codeNode';
3
+ import { CodeGraph, ICodeGraphState } from './codeGraph';
4
+ import { CodeGraphTemplate } from './codeGraphTemplate';
5
+ export interface IGraphCodeNodeState extends INodeState<unknown, unknown> {
6
+ graphState: ICodeGraphState;
7
+ }
8
+ export interface IGraphCodeNode extends IGraphNode {
9
+ template: CodeGraphTemplate;
10
+ subgraph: CodeGraph | undefined;
11
+ }
12
+ export declare function createCodeGraphNodeType(template: GraphTemplate): new () => AbstractCodeNode & IGraphNode;
@@ -0,0 +1,16 @@
1
+ import { GraphTemplate, IGraphTemplateState } from '@baklavajs/core';
2
+ import { CodeEditor } from '../codeEditor';
3
+ import { CodeGraph, ICodeGraphState } from './codeGraph';
4
+ type Optional<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
5
+ export declare class CodeGraphTemplate extends GraphTemplate implements ICodeGraphState {
6
+ /** Create a new GraphTemplate from the nodes and connections inside the graph instance */
7
+ static fromGraph(graph: CodeGraph, editor: CodeEditor): CodeGraphTemplate;
8
+ constructor(state: Optional<IGraphTemplateState, "id" | "name">, editor: CodeEditor);
9
+ get shortId(): string;
10
+ /**
11
+ * Create a new graph instance from this template
12
+ * or load the state into the provided graph instance.
13
+ */
14
+ createGraph(graph?: CodeGraph): CodeGraph;
15
+ }
16
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './codeGraph';
2
+ export * from './codeGraphNode';
3
+ export * from './codeGraphTemplate';
4
+ export * from './switchCodeGraph';
@@ -0,0 +1,8 @@
1
+ import { Ref } from 'vue';
2
+ import { CodeEditor } from '../codeEditor';
3
+ import { CodeGraph } from './codeGraph';
4
+ import { CodeGraphTemplate } from './codeGraphTemplate';
5
+ export type SwitchCodeGraph = (newGraph: CodeGraph | CodeGraphTemplate) => void;
6
+ export declare function useSwitchCodeGraph(editor: Ref<CodeEditor>, displayedGraph: Ref<CodeGraph>): {
7
+ switchGraph: SwitchCodeGraph;
8
+ };
@@ -0,0 +1,138 @@
1
+ import { AbstractNode, NodeInterface, CalculateFunction, CalculateFunctionReturnType, INodeState, NodeInterfaceDefinition } from '@baklavajs/core';
2
+ import { UnwrapRef } from 'vue';
3
+ import { Code } from '../code';
4
+ import { CodeNodeInputInterface, CodeNodeInterface, CodeNodeOutputInterface } from '../codeNodeInterfaces';
5
+ import { CodeGraph } from '../codeGraph';
6
+ export interface IAbstractCodeNodeState {
7
+ codeTemplate: string;
8
+ hidden: boolean;
9
+ integrated: boolean;
10
+ lockCode: boolean;
11
+ modules: string[];
12
+ position?: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ props?: unknown | null;
17
+ script: string;
18
+ variableName: string;
19
+ }
20
+ export declare abstract class AbstractCodeNode extends AbstractNode {
21
+ private _variableName;
22
+ codeTemplate: () => string;
23
+ readonly isCodeNode = true;
24
+ mask: unknown;
25
+ name: string;
26
+ state: UnwrapRef<IAbstractCodeNodeState>;
27
+ inputs: Record<string, CodeNodeInterface<unknown>>;
28
+ outputs: Record<string, CodeNodeInterface<unknown>>;
29
+ constructor();
30
+ get code(): Code | null;
31
+ get codeNodeInputs(): Record<string, CodeNodeInputInterface>;
32
+ get codeNodeOutputs(): Record<string, CodeNodeOutputInterface>;
33
+ get graph(): CodeGraph;
34
+ get hasConnectedOutputNodes(): boolean;
35
+ get idx(): number;
36
+ get idxByType(): number;
37
+ get idxByVariableNames(): number;
38
+ get isSelected(): boolean;
39
+ get lockCode(): boolean;
40
+ set lockCode(value: boolean);
41
+ get optionalInputs(): Record<string, CodeNodeInputInterface>;
42
+ get requiredInputs(): Record<string, CodeNodeInputInterface>;
43
+ get script(): string;
44
+ set script(value: string);
45
+ get shortId(): string;
46
+ get subgraph(): CodeGraph | undefined;
47
+ get variableName(): string;
48
+ set variableName(value: string);
49
+ abstract afterGraphLoaded(): void;
50
+ abstract afterLoaded(): void;
51
+ abstract onConnected(): void;
52
+ abstract onGraphUpdate(): void;
53
+ abstract onUnconnected(): void;
54
+ abstract update(): void;
55
+ /**
56
+ * Get connected node to the node interface.
57
+ * @param nodeInterface string
58
+ * @returns code node instance or null
59
+ */
60
+ getConnectedNodeByInterface(nodeInterface: string, type?: "inputs" | "outputs"): AbstractCodeNode | null;
61
+ /**
62
+ * Get connected nodes to the node.
63
+ * @param type inputs or outputs
64
+ * @returns code node instances
65
+ */
66
+ getConnectedNodes(type?: "inputs" | "outputs"): AbstractCodeNode[];
67
+ /**
68
+ * Get connected nodes to the node interface.
69
+ * @param nodeInterface string
70
+ * @returns code node instances
71
+ */
72
+ getConnectedNodesByInterface(nodeInterface: string, type?: "inputs" | "outputs"): AbstractCodeNode[];
73
+ /**
74
+ * Remove this node from the graph.
75
+ */
76
+ remove(): void;
77
+ /**
78
+ * Render code of this node.
79
+ */
80
+ renderCode(data: {
81
+ inputs: Record<string, unknown>;
82
+ }): string;
83
+ /**
84
+ * Update code templates.
85
+ */
86
+ updateCodeTemplate(): void;
87
+ /**
88
+ * Update modules.
89
+ * @param modules a list of modules
90
+ */
91
+ updateModules(modules?: string[]): void;
92
+ /**
93
+ * Update output names.
94
+ */
95
+ updateOutputNames(): void;
96
+ /**
97
+ * Update output values.
98
+ * @param output return data of calculate function
99
+ */
100
+ updateOutputValues(outputs: CalculateFunctionReturnType<unknown>): void;
101
+ /**
102
+ * Update state props.
103
+ * @param props
104
+ */
105
+ updateProps(props: unknown): void;
106
+ /**
107
+ * Update input values
108
+ * @param inputs input values
109
+ */
110
+ updateInputValues(inputs: Record<string, unknown>): void;
111
+ }
112
+ export interface ICodeNodeState<I, O> extends INodeState<I, O>, IAbstractCodeNodeState {
113
+ }
114
+ export type NodeInterfaceFactory<T> = () => NodeInterface<T>;
115
+ export type InterfaceFactory<T> = {
116
+ [K in keyof T]: NodeInterfaceFactory<T[K]>;
117
+ };
118
+ export declare abstract class CodeNode<I, O> extends AbstractCodeNode {
119
+ abstract inputs: NodeInterfaceDefinition<I>;
120
+ abstract outputs: NodeInterfaceDefinition<O>;
121
+ /**
122
+ * The default implementation does nothing.
123
+ * Overwrite this method to do calculation.
124
+ * @param inputs Values of all input interfaces
125
+ * @param globalValues Set of values passed to every node by the engine plugin
126
+ * @return Values for output interfaces
127
+ */
128
+ calculate?: CalculateFunction<I, O>;
129
+ executeFactory<V, T extends InterfaceFactory<V>>(type: "input" | "output", factory?: T): void;
130
+ load(state: ICodeNodeState<I, O>): void;
131
+ }
132
+ export type AbstractCodeNodeConstructor = new () => AbstractCodeNode;
133
+ /**
134
+ * Format inputs for mustache templates.
135
+ * @param intfs code node input interfaces
136
+ * @returns a list of string
137
+ */
138
+ export declare const formatInputs: (intfs: Record<string, CodeNodeInputInterface>, withKeywords?: boolean) => string[];
@@ -0,0 +1,17 @@
1
+ import { INodeDefinition, Node } from '@baklavajs/core';
2
+ import { CodeNode, AbstractCodeNode } from './codeNode';
3
+ export type NodeConstructor<I, O> = new () => Node<I, O>;
4
+ export type NodeInstanceOf<T> = T extends new () => Node<infer A, infer B> ? Node<A, B> : never;
5
+ export interface ICodeNodeDefinition<I, O> extends INodeDefinition<I, O> {
6
+ afterGraphLoaded?: () => void;
7
+ afterLoaded?: () => void;
8
+ codeTemplate?: (node?: AbstractCodeNode) => string;
9
+ modules?: string[];
10
+ name?: string;
11
+ onConnected?: () => void;
12
+ onGraphUpdate?: () => void;
13
+ onUnconnected?: () => void;
14
+ update?: (node?: AbstractCodeNode) => void;
15
+ variableName?: string;
16
+ }
17
+ export declare function defineCodeNode<I, O>(definition: ICodeNodeDefinition<I, O>): new () => CodeNode<I, O>;
@@ -0,0 +1,34 @@
1
+ import { IDynamicNodeDefinition, NodeInterface, NodeInterfaceDefinition } from '@baklavajs/core';
2
+ import { CodeNode, AbstractCodeNode, ICodeNodeState } from './codeNode';
3
+ type Dynamic<T> = T & Record<string, unknown>;
4
+ /**
5
+ * @internal
6
+ * Abstract base class for every dynamic node
7
+ */
8
+ export declare abstract class DynamicCodeNode<I, O> extends CodeNode<Dynamic<I>, Dynamic<O>> {
9
+ abstract inputs: NodeInterfaceDefinition<Dynamic<I>>;
10
+ abstract outputs: NodeInterfaceDefinition<Dynamic<O>>;
11
+ abstract load(state: ICodeNodeState<Dynamic<I>, Dynamic<O>>): void;
12
+ abstract save(): ICodeNodeState<Dynamic<I>, Dynamic<O>>;
13
+ }
14
+ export type DynamicNodeDefinition = Record<string, (() => NodeInterface<unknown>) | undefined>;
15
+ export interface DynamicNodeUpdateResult {
16
+ inputs?: DynamicNodeDefinition;
17
+ outputs?: DynamicNodeDefinition;
18
+ forceUpdateInputs?: string[];
19
+ forceUpdateOutputs?: string[];
20
+ }
21
+ export interface IDynamicCodeNodeDefinition<I, O> extends IDynamicNodeDefinition<I, O> {
22
+ afterGraphLoaded?: () => void;
23
+ afterLoaded?: () => void;
24
+ codeTemplate?: (node?: AbstractCodeNode) => string;
25
+ name?: string;
26
+ modules?: string[];
27
+ onConnected?: () => void;
28
+ onGraphUpdate?: () => void;
29
+ onUnconnected?: () => void;
30
+ update?: (node?: AbstractCodeNode) => void;
31
+ variableName?: string;
32
+ }
33
+ export declare function defineDynamicCodeNode<I, O>(definition: IDynamicCodeNodeDefinition<I, O>): new () => DynamicCodeNode<I, O>;
34
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './codeNode';
2
+ export * from './defineCodeNode';
3
+ export * from './dynamicCodeNode';
@@ -0,0 +1,23 @@
1
+ import { Ref } from 'vue';
2
+ import { NodeInterface } from '@baklavajs/core';
3
+ import { CodeNodeInputInterface } from './codeNodeInput/codeNodeInputInterface';
4
+ export interface IValidator {
5
+ validate: (v: number) => boolean;
6
+ }
7
+ export declare class BaseNumericInterface extends CodeNodeInputInterface<number> implements IValidator {
8
+ min?: number;
9
+ max?: number;
10
+ constructor(name: string, value: number, min?: number, max?: number);
11
+ validate(v: number): boolean;
12
+ }
13
+ export declare const useBaseNumericInterface: (intf: Ref<NodeInterface<number>>, precision?: number) => {
14
+ editMode: Ref<boolean, boolean>;
15
+ invalid: Ref<boolean, boolean>;
16
+ tempValue: Ref<string, string>;
17
+ inputEl: Ref<HTMLInputElement | null, HTMLInputElement | null>;
18
+ stringRepresentation: import('vue').ComputedRef<string>;
19
+ validate: (v: number) => boolean;
20
+ setValue: (newValue: number) => void;
21
+ enterEditMode: () => Promise<void>;
22
+ leaveEditMode: () => void;
23
+ };
@@ -0,0 +1,5 @@
1
+ import { CodeNodeInputInterface } from './codeNodeInput/codeNodeInputInterface';
2
+ export declare class BaseStringInterface extends CodeNodeInputInterface<string> {
3
+ constructor(name: string, value: string);
4
+ getValue: () => string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { CodeNodeInputInterface } from '../codeNodeInput/codeNodeInputInterface';
2
+ export declare class CheckboxInterface extends CodeNodeInputInterface<boolean> {
3
+ constructor(name: string, value: boolean);
4
+ getValue: () => string;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { CodeNodeInterface } from './codeNodeInterface';
2
+ type __VLS_Props = {
3
+ intf: CodeNodeInterface;
4
+ };
5
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { NodeInterface, INodeInterfaceState } from '@baklavajs/core';
2
+ import { UnwrapRef } from 'vue';
3
+ import { default as CodeNodeInterfaceComponent } from './CodeNodeInterface.vue';
4
+ import { Code } from '../../code';
5
+ export interface ICodeNodeInterfaceRefState {
6
+ optional: boolean;
7
+ }
8
+ export declare class CodeNodeInterface<T = unknown> extends NodeInterface<T> {
9
+ isCodeNode: boolean;
10
+ code: Code | undefined;
11
+ state: UnwrapRef<ICodeNodeInterfaceRefState>;
12
+ type: string | null;
13
+ constructor(name: string, value: T);
14
+ get optional(): boolean;
15
+ get shortId(): string;
16
+ getValue: () => string;
17
+ load(state: INodeInterfaceState<T>): void;
18
+ save(): INodeInterfaceState<T>;
19
+ setOptional(value: boolean): this;
20
+ }
21
+ export { CodeNodeInterfaceComponent };
@@ -0,0 +1,2 @@
1
+ export * from './codeNodeInterface';
2
+ export { default as CodeNodeInterfaceComponent } from './CodeNodeInterface.vue';
@@ -0,0 +1,6 @@
1
+ import { CodeNodeInterface } from '../codeNode';
2
+ export declare class CodeNodeInputInterface<T = unknown> extends CodeNodeInterface<T> {
3
+ constructor(name?: string, value?: T);
4
+ get value(): T;
5
+ set value(value: T);
6
+ }
@@ -0,0 +1,9 @@
1
+ import { AbstractCodeNode } from '../../codeNode';
2
+ import { CodeNodeInterface } from '../codeNode';
3
+ export declare class CodeNodeOutputInterface extends CodeNodeInterface<string> {
4
+ isCodeNodeOutput: boolean;
5
+ suffix: string;
6
+ constructor(name?: string, value?: string);
7
+ get codeValue(): string;
8
+ get node(): AbstractCodeNode | undefined;
9
+ }
@@ -0,0 +1,12 @@
1
+ import { CodeNodeInputInterface } from '.';
2
+ export interface IInterfaceProps {
3
+ forceUpdate?: boolean;
4
+ hidden?: boolean;
5
+ id: string;
6
+ items?: string[];
7
+ max?: number;
8
+ min?: number;
9
+ name?: string;
10
+ value: unknown;
11
+ }
12
+ export declare const createInterface: (name: string, interfaceProps: IInterfaceProps) => CodeNodeInputInterface;
@@ -0,0 +1,13 @@
1
+ export * from './createInterface';
2
+ export * from './checkbox/checkboxInterface';
3
+ export * from './codeNode/codeNodeInterface';
4
+ export * from './codeNodeInput/codeNodeInputInterface';
5
+ export * from './codeNodeOutput/codeNodeOutputInterface';
6
+ export * from './integer/integerInterface';
7
+ export * from './listInput/listInputInterface';
8
+ export * from './number/numberInterface';
9
+ export * from './select/selectInterface';
10
+ export * from './slider/sliderInterface';
11
+ export * from './textInput/textInputInterface';
12
+ export * from './textareaInput/textareaInputInterface';
13
+ export * from './tupleInput/tupleInputInterface';
@@ -0,0 +1,6 @@
1
+ import { ComponentOptions } from 'vue';
2
+ import { BaseNumericInterface } from '../baseNumericInterface';
3
+ export declare class IntegerInterface extends BaseNumericInterface {
4
+ component: ComponentOptions;
5
+ validate(v: number): boolean;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { CodeNodeInputInterface } from '../codeNodeInput/codeNodeInputInterface';
2
+ export declare class ListInputInterface extends CodeNodeInputInterface {
3
+ constructor(name?: string, value?: string);
4
+ getValue: () => string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ComponentOptions } from 'vue';
2
+ import { BaseNumericInterface } from '../baseNumericInterface';
3
+ export declare class NumberInterface extends BaseNumericInterface {
4
+ component: ComponentOptions;
5
+ }
@@ -0,0 +1,12 @@
1
+ import { ComponentOptions } from 'vue';
2
+ import { BaseStringInterface } from '../baseStringInterface';
3
+ export interface IAdvancedSelectInterfaceItem<V> {
4
+ text: string;
5
+ value: V;
6
+ }
7
+ export type SelectInterfaceItem<V> = string | IAdvancedSelectInterfaceItem<V>;
8
+ export declare class SelectInterface<V = string> extends BaseStringInterface {
9
+ component: ComponentOptions;
10
+ items: SelectInterfaceItem<V>[];
11
+ constructor(name: string, value: V, items: SelectInterfaceItem<V>[]);
12
+ }
@@ -0,0 +1,9 @@
1
+ import { ComponentOptions } from 'vue';
2
+ import { BaseNumericInterface } from '../baseNumericInterface';
3
+ export declare class SliderInterface extends BaseNumericInterface {
4
+ component: ComponentOptions;
5
+ min: number;
6
+ max: number;
7
+ constructor(name: string, value: number, min: number, max: number);
8
+ getValue: () => string;
9
+ }