@babsey/code-graph 0.10.1 → 0.11.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.d.ts CHANGED
@@ -21,7 +21,6 @@ export declare class Code {
21
21
  set lockCode(value: boolean);
22
22
  get modules(): string[];
23
23
  get script(): string;
24
- set script(value: string);
25
24
  get shortId(): string;
26
25
  get state(): UnwrapRef<ICodeState>;
27
26
  /**
@@ -23,7 +23,7 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
23
23
  get connections(): Connection[];
24
24
  set connections(values: Connection[]);
25
25
  get nodeIds(): string[];
26
- get nodes(): AbstractCodeNode[];
26
+ get nodes(): readonly AbstractCodeNode[];
27
27
  set nodes(values: AbstractCodeNode[]);
28
28
  get scriptedCodeNodes(): AbstractCodeNode[];
29
29
  get selectedNodeIds(): string[];
@@ -34,6 +34,7 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
34
34
  * Add code node to graph.
35
35
  * @param node code node
36
36
  * @param props optional
37
+ * @returns code node intstance
37
38
  */
38
39
  addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined;
39
40
  /**
@@ -41,15 +42,16 @@ export declare class CodeGraph extends Graph implements IBaklavaEventEmitter, IB
41
42
  * @param node code node
42
43
  * @param position position
43
44
  * @param props optional
44
- * @returns code node
45
+ * @returns code node instance
45
46
  */
46
47
  addNodeAtCoordinates: (node: AbstractCodeNode, position?: IPosition, props?: unknown) => AbstractCodeNode;
47
48
  /**
48
49
  * Add connection of code nodes
49
50
  * @param from code node interface
50
51
  * @param to code node interface
52
+ * @returns connection intstance
51
53
  */
52
- addConnection(from: CodeNodeInterface, to: CodeNodeInterface): void;
54
+ addConnection(from: CodeNodeInterface, to: CodeNodeInterface): Connection | undefined;
53
55
  /**
54
56
  * Execute calls of nodes before running graph.
55
57
  */
@@ -1,7 +1,7 @@
1
1
  import { AbstractNode, NodeInterface, CalculateFunction, CalculateFunctionReturnType, INodeState, NodeInterfaceDefinition } from '@baklavajs/core';
2
2
  import { UnwrapRef } from 'vue';
3
3
  import { Code } from '../code';
4
- import { CodeNodeInputInterface, CodeNodeInterface, CodeNodeOutputInterface } from '../codeNodeInterfaces';
4
+ import { CodeNodeInterface, CodeNodeInputInterface, CodeNodeOutputInterface } from '../codeNodeInterfaces';
5
5
  import { CodeGraph } from '../codeGraph';
6
6
  export interface IAbstractCodeNodeState {
7
7
  codeTemplate: string;
@@ -128,11 +128,6 @@ export declare abstract class CodeNode<I, O> extends AbstractCodeNode {
128
128
  calculate?: CalculateFunction<I, O>;
129
129
  executeFactory<V, T extends InterfaceFactory<V>>(type: "input" | "output", factory?: T): void;
130
130
  load(state: ICodeNodeState<I, O>): void;
131
+ save(): ICodeNodeState<I, O>;
131
132
  }
132
133
  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[];
@@ -1,5 +1,8 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { CodeNodeInputInterface } from '../codeNodeInput/codeNodeInputInterface';
2
3
  export declare class CheckboxInterface extends CodeNodeInputInterface<boolean> {
4
+ component: ComponentOptions;
5
+ componentName: string;
3
6
  constructor(name: string, value: boolean);
4
7
  getValue: () => string;
5
8
  }
@@ -1,16 +1,17 @@
1
1
  import { NodeInterface, INodeInterfaceState } from '@baklavajs/core';
2
- import { UnwrapRef } from 'vue';
2
+ import { ComponentOptions, UnwrapRef } from 'vue';
3
+ import { AbstractCodeNode } from '../../codeNode';
3
4
  import { Code } from '../../code';
4
5
  export interface ICodeNodeInterfaceRefState {
5
6
  optional: boolean;
6
7
  }
7
8
  export declare class CodeNodeInterface<T = unknown> extends NodeInterface<T> {
9
+ component: ComponentOptions;
8
10
  isCodeNode: boolean;
9
11
  code: Code | undefined;
10
12
  componentName: string;
11
13
  state: UnwrapRef<ICodeNodeInterfaceRefState>;
12
14
  type: string | null;
13
- constructor(name: string, value: T);
14
15
  get optional(): boolean;
15
16
  get shortId(): string;
16
17
  getValue: () => string;
@@ -18,3 +19,4 @@ export declare class CodeNodeInterface<T = unknown> extends NodeInterface<T> {
18
19
  save(): INodeInterfaceState<T>;
19
20
  setOptional(value: boolean): this;
20
21
  }
22
+ export declare const addCodeInterfaces: (codeNode: AbstractCodeNode) => void;
@@ -1,5 +1,7 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { CodeNodeInterface } from '../codeNode/codeNodeInterface';
2
3
  export declare class CodeNodeInputInterface<T = unknown> extends CodeNodeInterface<T> {
4
+ component: ComponentOptions;
3
5
  constructor(name?: string, value?: T);
4
6
  get value(): T;
5
7
  set value(value: T);
@@ -1,9 +1,11 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { AbstractCodeNode } from '../../codeNode';
2
3
  import { CodeNodeInterface } from '../codeNode/codeNodeInterface';
3
- export declare class CodeNodeOutputInterface extends CodeNodeInterface<string> {
4
+ export declare class CodeNodeOutputInterface extends CodeNodeInterface<unknown> {
5
+ component: ComponentOptions;
4
6
  isCodeNodeOutput: boolean;
5
7
  suffix: string;
6
- constructor(name?: string, value?: string);
8
+ constructor(name?: string, suffix?: string);
7
9
  get codeValue(): string;
8
10
  get node(): AbstractCodeNode | undefined;
9
11
  }
@@ -1,12 +1,13 @@
1
- import { CheckboxInterface, IntegerInterface, ListInputInterface, NumberInterface, SelectInterface, TextInputInterface, TupleInputInterface } from '.';
1
+ import { SelectInterfaceItem } from '@baklavajs/renderer-vue';
2
+ import { CheckboxInterface, IntegerInterface, ListInputInterface, NumberInterface, SelectInterface, SliderInterface, TextInputInterface, TupleInputInterface } from '.';
2
3
  export interface IInterfaceProps {
3
4
  forceUpdate?: boolean;
4
5
  hidden?: boolean;
5
6
  id: string;
6
- items?: string[];
7
+ items?: SelectInterfaceItem<unknown>[];
7
8
  max?: number;
8
9
  min?: number;
9
10
  name?: string;
10
11
  value: unknown;
11
12
  }
12
- export declare const createInterface: (name: string, interfaceProps: IInterfaceProps) => CheckboxInterface | IntegerInterface | ListInputInterface | NumberInterface | SelectInterface<number> | TupleInputInterface | TextInputInterface;
13
+ export declare const createInterface: (name: string, interfaceProps: IInterfaceProps) => CheckboxInterface | IntegerInterface | ListInputInterface | NumberInterface | SelectInterface<unknown> | SliderInterface | TupleInputInterface | TextInputInterface;
@@ -0,0 +1,7 @@
1
+ import { CodeNodeInputInterface } from '../main';
2
+ /**
3
+ * Format inputs for mustache templates.
4
+ * @param intfs code node input interfaces
5
+ * @returns a list of string
6
+ */
7
+ export declare const formatInputs: (intfs: Record<string, CodeNodeInputInterface>, withKeywords?: boolean) => string[];
@@ -1,4 +1,5 @@
1
1
  export * from './createInterface';
2
+ export * from './formatInputs';
2
3
  export * from './checkbox/checkboxInterface';
3
4
  export * from './codeNode/codeNodeInterface';
4
5
  export * from './codeNodeInput/codeNodeInputInterface';
@@ -1,5 +1,7 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { BaseNumericInterface } from '../baseNumericInterface';
2
3
  export declare class IntegerInterface extends BaseNumericInterface {
3
- constructor(name: string, value?: number);
4
+ component: ComponentOptions;
5
+ componentName: string;
4
6
  validate(v: number): boolean;
5
7
  }
@@ -1,5 +1,8 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { CodeNodeInputInterface } from '../codeNodeInput/codeNodeInputInterface';
2
3
  export declare class ListInputInterface extends CodeNodeInputInterface {
4
+ component: ComponentOptions;
5
+ componentName: string;
3
6
  constructor(name: string, value?: string);
4
7
  getValue: () => string;
5
8
  }
@@ -2,4 +2,5 @@ import { ComponentOptions } from 'vue';
2
2
  import { BaseNumericInterface } from '../baseNumericInterface';
3
3
  export declare class NumberInterface extends BaseNumericInterface {
4
4
  component: ComponentOptions;
5
+ componentName: string;
5
6
  }
@@ -7,6 +7,7 @@ export interface IAdvancedSelectInterfaceItem<V> {
7
7
  export type SelectInterfaceItem<V> = string | IAdvancedSelectInterfaceItem<V>;
8
8
  export declare class SelectInterface<V = string> extends BaseStringInterface {
9
9
  component: ComponentOptions;
10
+ componentName: string;
10
11
  items: SelectInterfaceItem<V>[];
11
- constructor(name: string, value: V, items: SelectInterfaceItem<V>[]);
12
+ constructor(name: string, value: V, items: SelectInterfaceItem<V>[] | undefined);
12
13
  }
@@ -1,5 +1,9 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { BaseNumericInterface } from '../baseNumericInterface';
2
3
  export declare class SliderInterface extends BaseNumericInterface {
3
- constructor(name: string, value: number, min: number, max: number);
4
+ component: ComponentOptions;
5
+ componentName: string;
6
+ min: number;
7
+ max: number;
4
8
  getValue: () => string;
5
9
  }
@@ -1,5 +1,8 @@
1
+ import { ComponentOptions } from 'vue';
1
2
  import { CodeNodeInputInterface } from '../codeNodeInput/codeNodeInputInterface';
2
3
  export declare class TupleInputInterface extends CodeNodeInputInterface {
4
+ component: ComponentOptions;
5
+ componentName: string;
3
6
  constructor(name: string, value?: string);
4
7
  getValue: () => string;
5
8
  }
package/dist/index.d.ts CHANGED
@@ -11,4 +11,5 @@ export * from './codeNodeInterfaces';
11
11
  export * from './interfaceTypes';
12
12
  export * from './settings';
13
13
  export * from './subgraph';
14
+ export * from './utils';
14
15
  export * from './viewModel';
@@ -1,5 +1,6 @@
1
- import { NodeInterface, CalculateFunction, IGraphInterface } from '@baklavajs/core';
1
+ import { CalculateFunction, IGraphInterface } from '@baklavajs/core';
2
2
  import { AbstractCodeNode, CodeNode, ICodeNodeState } from '../codeNode';
3
+ import { CodeNodeInterface } from '../codeNodeInterfaces';
3
4
  export interface ICodeGraphInterface extends IGraphInterface {
4
5
  id: string;
5
6
  nodeId: string;
@@ -17,6 +18,11 @@ declare abstract class CodeGraphInterfaceNode<I, O> extends CodeNode<I, O> {
17
18
  onPlaced(): void;
18
19
  load(state: IGraphInterfaceNodeState<I, O>): void;
19
20
  save(): IGraphInterfaceNodeState<I, O>;
21
+ afterGraphLoaded(): void;
22
+ afterLoaded(): void;
23
+ beforeRun(): void;
24
+ onConnected(): void;
25
+ onUnconnected(): void;
20
26
  update(): void;
21
27
  }
22
28
  export declare class CodeGraphInputNode extends CodeGraphInterfaceNode<{
@@ -24,13 +30,13 @@ export declare class CodeGraphInputNode extends CodeGraphInterfaceNode<{
24
30
  }, {
25
31
  placeholder: unknown;
26
32
  }> {
27
- static isGraphInputNode(v: AbstractCodeNode): v is CodeGraphInputNode;
33
+ static isGraphInputNode(v: AbstractCodeNode): boolean;
28
34
  readonly type = "__baklava_SubgraphInputNode";
29
35
  inputs: {
30
- name: NodeInterface<string>;
36
+ name: CodeNodeInterface<string>;
31
37
  };
32
38
  outputs: {
33
- placeholder: NodeInterface<undefined>;
39
+ placeholder: CodeNodeInterface<undefined>;
34
40
  };
35
41
  }
36
42
  export type CodeGraphInputNodeState = IGraphInterfaceNodeState<{
@@ -44,14 +50,14 @@ export declare class CodeGraphOutputNode extends CodeGraphInterfaceNode<{
44
50
  }, {
45
51
  output: unknown;
46
52
  }> {
47
- static isGraphOutputNode(v: AbstractCodeNode): v is CodeGraphOutputNode;
53
+ static isGraphOutputNode(v: AbstractCodeNode): boolean;
48
54
  readonly type = "__baklava_SubgraphOutputNode";
49
55
  inputs: {
50
- name: NodeInterface<string>;
51
- placeholder: NodeInterface<undefined>;
56
+ name: CodeNodeInterface<string>;
57
+ placeholder: CodeNodeInterface<undefined>;
52
58
  };
53
59
  outputs: {
54
- output: NodeInterface<undefined>;
60
+ output: CodeNodeInterface<undefined>;
55
61
  };
56
62
  calculate: CalculateFunction<{
57
63
  placeholder: unknown;
@@ -1,27 +1,21 @@
1
- import { NodeInterface } from '@baklavajs/core';
2
- import { TextInputInterface } from '@baklavajs/renderer-vue';
1
+ import { CodeNodeInterface, TextInputInterface } from '../codeNodeInterfaces';
3
2
  import { CodeGraphInputNode, CodeGraphOutputNode } from './graphInterface';
4
- import { CodeNodeInterface } from '../codeNodeInterfaces';
5
3
  export declare class SubgraphInputNode extends CodeGraphInputNode {
6
4
  protected _title: string;
7
5
  inputs: {
8
- _code: CodeNodeInterface<string>;
9
6
  name: TextInputInterface;
10
7
  };
11
8
  outputs: {
12
- _code: CodeNodeInterface<string>;
13
- placeholder: NodeInterface<undefined>;
9
+ placeholder: CodeNodeInterface<undefined>;
14
10
  };
15
11
  }
16
12
  export declare class SubgraphOutputNode extends CodeGraphOutputNode {
17
13
  protected _title: string;
18
14
  inputs: {
19
- _code: CodeNodeInterface<string>;
20
15
  name: TextInputInterface;
21
- placeholder: NodeInterface<undefined>;
16
+ placeholder: CodeNodeInterface<undefined>;
22
17
  };
23
18
  outputs: {
24
- _code: CodeNodeInterface<string>;
25
- output: NodeInterface<undefined>;
19
+ output: CodeNodeInterface<undefined>;
26
20
  };
27
21
  }
@@ -0,0 +1,2 @@
1
+ export * from './download';
2
+ export * from './object';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",