@babsey/code-graph 0.0.2 → 0.0.3

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.
@@ -517,6 +517,9 @@ class Code {
517
517
  get connections() {
518
518
  return this.graph.connections;
519
519
  }
520
+ set connections(values) {
521
+ this.graph._connections = values;
522
+ }
520
523
  get graph() {
521
524
  return this.viewModel.displayedGraph;
522
525
  }
@@ -538,13 +541,16 @@ class Code {
538
541
  get nodes() {
539
542
  return this.graph.nodes;
540
543
  }
544
+ set nodes(values) {
545
+ this.graph._nodes = values;
546
+ }
541
547
  get scriptedCodeNodes() {
542
548
  return getCodeNodes(this.graph).filter(
543
549
  (codeNode) => codeNode.state?.script.length > 0
544
550
  );
545
551
  }
546
552
  get shortId() {
547
- return this.id.slice(0);
553
+ return this.id.slice(0, 6);
548
554
  }
549
555
  get state() {
550
556
  return this._state;
@@ -561,6 +567,7 @@ class Code {
561
567
  * @param props optional
562
568
  */
563
569
  addNode(node, props) {
570
+ if (!node.code) node.code = this;
564
571
  if (props) node.state.props = props;
565
572
  return this.graph.addNode(node);
566
573
  }
@@ -590,8 +597,8 @@ class Code {
590
597
  * Clear code graph.
591
598
  */
592
599
  clear() {
593
- this.graph._nodes = [];
594
- this.graph._connections = [];
600
+ this.nodes = [];
601
+ this.connections = [];
595
602
  }
596
603
  findNodeById(id) {
597
604
  return this.graph.findNodeById(id);
@@ -675,10 +682,11 @@ class Code {
675
682
  nodeStates.forEach((nodeState, nodeIdx) => {
676
683
  const node = this.nodes[nodeIdx];
677
684
  Object.entries(nodeState.inputs).forEach(([inputKey]) => {
678
- if (node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
685
+ if (nodeState.inputs && node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
679
686
  });
680
687
  Object.entries(nodeState.outputs).forEach(([outputKey]) => {
681
- if (node.inputs[outputKey]) nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
688
+ if (nodeState.outputs && node.outputs[outputKey])
689
+ nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
682
690
  });
683
691
  });
684
692
  }
@@ -698,7 +706,8 @@ class Code {
698
706
  nodeIds.reverse();
699
707
  const unconnected = this.graph.nodes.map((node) => node.id).filter((nodeId) => !nodeIds.includes(nodeId));
700
708
  nodeIds = nodeIds.concat(unconnected);
701
- this.graph._nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
709
+ const nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
710
+ if (nodes) this.nodes = nodes;
702
711
  } catch {
703
712
  console.warn("Failed to sort nodes.");
704
713
  }
@@ -514,6 +514,9 @@
514
514
  get connections() {
515
515
  return this.graph.connections;
516
516
  }
517
+ set connections(values) {
518
+ this.graph._connections = values;
519
+ }
517
520
  get graph() {
518
521
  return this.viewModel.displayedGraph;
519
522
  }
@@ -535,13 +538,16 @@
535
538
  get nodes() {
536
539
  return this.graph.nodes;
537
540
  }
541
+ set nodes(values) {
542
+ this.graph._nodes = values;
543
+ }
538
544
  get scriptedCodeNodes() {
539
545
  return getCodeNodes(this.graph).filter(
540
546
  (codeNode) => codeNode.state?.script.length > 0
541
547
  );
542
548
  }
543
549
  get shortId() {
544
- return this.id.slice(0);
550
+ return this.id.slice(0, 6);
545
551
  }
546
552
  get state() {
547
553
  return this._state;
@@ -558,6 +564,7 @@
558
564
  * @param props optional
559
565
  */
560
566
  addNode(node, props) {
567
+ if (!node.code) node.code = this;
561
568
  if (props) node.state.props = props;
562
569
  return this.graph.addNode(node);
563
570
  }
@@ -587,8 +594,8 @@
587
594
  * Clear code graph.
588
595
  */
589
596
  clear() {
590
- this.graph._nodes = [];
591
- this.graph._connections = [];
597
+ this.nodes = [];
598
+ this.connections = [];
592
599
  }
593
600
  findNodeById(id) {
594
601
  return this.graph.findNodeById(id);
@@ -672,10 +679,11 @@
672
679
  nodeStates.forEach((nodeState, nodeIdx) => {
673
680
  const node = this.nodes[nodeIdx];
674
681
  Object.entries(nodeState.inputs).forEach(([inputKey]) => {
675
- if (node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
682
+ if (nodeState.inputs && node.inputs[inputKey]) nodeState.inputs[inputKey].hidden = node.inputs[inputKey].hidden;
676
683
  });
677
684
  Object.entries(nodeState.outputs).forEach(([outputKey]) => {
678
- if (node.inputs[outputKey]) nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
685
+ if (nodeState.outputs && node.outputs[outputKey])
686
+ nodeState.outputs[outputKey].hidden = node.outputs[outputKey].hidden;
679
687
  });
680
688
  });
681
689
  }
@@ -695,7 +703,8 @@
695
703
  nodeIds.reverse();
696
704
  const unconnected = this.graph.nodes.map((node) => node.id).filter((nodeId) => !nodeIds.includes(nodeId));
697
705
  nodeIds = nodeIds.concat(unconnected);
698
- this.graph._nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
706
+ const nodes = nodeIds.map((nodeId) => this.findNodeById(nodeId));
707
+ if (nodes) this.nodes = nodes;
699
708
  } catch {
700
709
  console.warn("Failed to sort nodes.");
701
710
  }
Binary file
@@ -21,11 +21,13 @@ export declare class Code {
21
21
  constructor(viewModel: ICodeGraphViewModel);
22
22
  get codeNodes(): AbstractCodeNode[];
23
23
  get connections(): Connection[];
24
+ set connections(values: Connection[]);
24
25
  get graph(): Graph;
25
26
  get id(): string;
26
27
  get modules(): string[];
27
28
  get nodeIds(): string[];
28
29
  get nodes(): AbstractCodeNode[];
30
+ set nodes(values: AbstractCodeNode[]);
29
31
  get scriptedCodeNodes(): AbstractCodeNode[];
30
32
  get shortId(): string;
31
33
  get state(): UnwrapRef<ICodeState>;
@@ -69,7 +71,9 @@ export declare class Code {
69
71
  /**
70
72
  * Load template from the file.
71
73
  */
72
- loadTemplate(resolve: Promise<any>): void;
74
+ loadTemplate(resolve: Promise<{
75
+ default: string;
76
+ }>): void;
73
77
  onCodeUpdate(): void;
74
78
  /**
75
79
  * Remove connection from the graph
@@ -0,0 +1,6 @@
1
+ import { CodeNodeInterface } from './codeNodeInterface';
2
+ type __VLS_Props = {
3
+ intf: CodeNodeInterface;
4
+ };
5
+ declare const _default: 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
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { ICodeGraphViewModel } from '../viewModel';
2
+ type __VLS_Props = {
3
+ viewModel: ICodeGraphViewModel;
4
+ };
5
+ declare const _default: 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
+ export default _default;
@@ -0,0 +1,38 @@
1
+ import { AbstractCodeNode } from '../../codeNode';
2
+ type __VLS_Props = {
3
+ node: AbstractCodeNode;
4
+ selected?: boolean;
5
+ dragging?: boolean;
6
+ };
7
+ declare var __VLS_49: {
8
+ type: string;
9
+ node: AbstractCodeNode;
10
+ intf: import('baklavajs').NodeInterface<unknown>;
11
+ }, __VLS_56: {
12
+ node: AbstractCodeNode;
13
+ intf: import('baklavajs').NodeInterface<unknown>;
14
+ type: string;
15
+ };
16
+ type __VLS_Slots = {} & {
17
+ nodeInterface?: (props: typeof __VLS_49) => any;
18
+ } & {
19
+ nodeInterface?: (props: typeof __VLS_56) => any;
20
+ };
21
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
22
+ select: () => any;
23
+ "start-drag": (ev: PointerEvent) => any;
24
+ update: () => any;
25
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
26
+ onSelect?: (() => any) | undefined;
27
+ "onStart-drag"?: ((ev: PointerEvent) => any) | undefined;
28
+ onUpdate?: (() => any) | undefined;
29
+ }>, {
30
+ selected: boolean;
31
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
32
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
33
+ export default _default;
34
+ type __VLS_WithSlots<T, S> = T & {
35
+ new (): {
36
+ $slots: S;
37
+ };
38
+ };
@@ -0,0 +1,18 @@
1
+ import { NodeInterface } from 'baklavajs';
2
+ import { AbstractCodeNode } from '../../codeNode';
3
+ type __VLS_Props = {
4
+ node: AbstractCodeNode;
5
+ intf: NodeInterface;
6
+ };
7
+ declare var __VLS_1: {};
8
+ type __VLS_Slots = {} & {
9
+ default?: (props: typeof __VLS_1) => any;
10
+ };
11
+ declare const __VLS_component: 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>;
12
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
13
+ export default _default;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,30 @@
1
+ interface IMenuItem {
2
+ label: string;
3
+ value: string;
4
+ }
5
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
+ type: {
7
+ type: StringConstructor;
8
+ required: true;
9
+ };
10
+ title: {
11
+ type: StringConstructor;
12
+ required: true;
13
+ };
14
+ }>, {
15
+ showContextMenu: import('vue').Ref<boolean, boolean>;
16
+ hasContextMenu: import('vue').ComputedRef<boolean>;
17
+ contextMenuItems: IMenuItem[];
18
+ openContextMenu: () => void;
19
+ onContextMenuClick: (action: string) => void;
20
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
21
+ type: {
22
+ type: StringConstructor;
23
+ required: true;
24
+ };
25
+ title: {
26
+ type: StringConstructor;
27
+ required: true;
28
+ };
29
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
30
+ export default _default;
@@ -0,0 +1,11 @@
1
+ type __VLS_Props = {
2
+ modelValue: boolean;
3
+ inversed?: boolean;
4
+ name?: string;
5
+ };
6
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
7
+ "update:modelValue": (v: boolean) => any;
8
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ "onUpdate:modelValue"?: ((v: boolean) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
11
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,6 +48,7 @@
48
48
  "@vitejs/plugin-vue": "~6.0",
49
49
  "@vue/eslint-config-prettier": "~10.2",
50
50
  "@vue/eslint-config-typescript": "~14.6",
51
+ "@vue/language-core": "~3.0",
51
52
  "@vue/tsconfig": "~0.8",
52
53
  "eslint": "~9.36",
53
54
  "eslint-plugin-vue": "~10.4",
@@ -57,7 +58,7 @@
57
58
  "rimraf": "~6.0",
58
59
  "sass-embedded": "~1.93",
59
60
  "typescript": "~5.9",
60
- "unplugin-dts": "^1.0.0-beta.6",
61
+ "unplugin-dts": "~1.0.0-beta.6",
61
62
  "vite": "~7.1",
62
63
  "vite-plugin-dts": "~4.5",
63
64
  "vite-plugin-vue-devtools": "~8.0",
@@ -1,3 +0,0 @@
1
- {
2
- "recommendations": ["Vue.volar"]
3
- }