@shapediver/viewer.shared.node-tree 2.12.7 → 3.0.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/implementation/AbstractTreeNodeData.d.ts +13 -5
- package/dist/implementation/AbstractTreeNodeData.d.ts.map +1 -1
- package/dist/implementation/AbstractTreeNodeData.js +29 -19
- package/dist/implementation/AbstractTreeNodeData.js.map +1 -1
- package/dist/implementation/Tree.d.ts +15 -0
- package/dist/implementation/Tree.d.ts.map +1 -0
- package/dist/implementation/{AbstractTree.js → Tree.js} +26 -20
- package/dist/implementation/Tree.js.map +1 -0
- package/dist/implementation/{AbstractTreeNode.d.ts → TreeNode.d.ts} +35 -27
- package/dist/implementation/TreeNode.d.ts.map +1 -0
- package/dist/implementation/TreeNode.js +348 -0
- package/dist/implementation/TreeNode.js.map +1 -0
- package/dist/index.d.ts +9 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ITree.d.ts +8 -9
- package/dist/interfaces/ITree.d.ts.map +1 -1
- package/dist/interfaces/ITreeNode.d.ts +36 -23
- package/dist/interfaces/ITreeNode.d.ts.map +1 -1
- package/dist/interfaces/ITreeNode.js +1 -0
- package/dist/interfaces/ITreeNode.js.map +1 -1
- package/dist/interfaces/ITreeNodeData.d.ts +20 -10
- package/dist/interfaces/ITreeNodeData.d.ts.map +1 -1
- package/package.json +5 -7
- package/src/implementation/AbstractTreeNodeData.ts +38 -26
- package/src/implementation/{AbstractTree.ts → Tree.ts} +29 -19
- package/src/implementation/{AbstractTreeNode.ts → TreeNode.ts} +124 -96
- package/src/index.ts +12 -13
- package/src/interfaces/ITree.ts +8 -13
- package/src/interfaces/ITreeNode.ts +43 -28
- package/src/interfaces/ITreeNodeData.ts +20 -12
- package/dist/implementation/AbstractTree.d.ts +0 -14
- package/dist/implementation/AbstractTree.d.ts.map +0 -1
- package/dist/implementation/AbstractTree.js.map +0 -1
- package/dist/implementation/AbstractTreeNode.d.ts.map +0 -1
- package/dist/implementation/AbstractTreeNode.js +0 -321
- package/dist/implementation/AbstractTreeNode.js.map +0 -1
- package/dist/implementation/three/AbstractTreeNodeDataThreeJs.d.ts +0 -10
- package/dist/implementation/three/AbstractTreeNodeDataThreeJs.d.ts.map +0 -1
- package/dist/implementation/three/AbstractTreeNodeDataThreeJs.js +0 -23
- package/dist/implementation/three/AbstractTreeNodeDataThreeJs.js.map +0 -1
- package/dist/implementation/three/Tree.d.ts +0 -9
- package/dist/implementation/three/Tree.d.ts.map +0 -1
- package/dist/implementation/three/Tree.js +0 -19
- package/dist/implementation/three/Tree.js.map +0 -1
- package/dist/implementation/three/TreeNodeThreejs.d.ts +0 -13
- package/dist/implementation/three/TreeNodeThreejs.d.ts.map +0 -1
- package/dist/implementation/three/TreeNodeThreejs.js +0 -35
- package/dist/implementation/three/TreeNodeThreejs.js.map +0 -1
- package/dist/interfaces/three/ITreeNodeDataThreeJs.d.ts +0 -11
- package/dist/interfaces/three/ITreeNodeDataThreeJs.d.ts.map +0 -1
- package/dist/interfaces/three/ITreeNodeDataThreeJs.js +0 -3
- package/dist/interfaces/three/ITreeNodeDataThreeJs.js.map +0 -1
- package/dist/interfaces/three/ITreeNodeThreeJs.d.ts +0 -17
- package/dist/interfaces/three/ITreeNodeThreeJs.d.ts.map +0 -1
- package/dist/interfaces/three/ITreeNodeThreeJs.js +0 -3
- package/dist/interfaces/three/ITreeNodeThreeJs.js.map +0 -1
- package/dist/interfaces/three/ITreeThreeJs.d.ts +0 -5
- package/dist/interfaces/three/ITreeThreeJs.d.ts.map +0 -1
- package/dist/interfaces/three/ITreeThreeJs.js +0 -3
- package/dist/interfaces/three/ITreeThreeJs.js.map +0 -1
- package/src/implementation/three/AbstractTreeNodeDataThreeJs.ts +0 -12
- package/src/implementation/three/Tree.ts +0 -28
- package/src/implementation/three/TreeNodeThreeJs.ts +0 -21
- package/src/interfaces/three/ITreeNodeDataThreeJs.ts +0 -13
- package/src/interfaces/three/ITreeNodeThreeJs.ts +0 -19
- package/src/interfaces/three/ITreeThreeJs.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ITreeNode.d.ts","sourceRoot":"","sources":["../../src/interfaces/ITreeNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ITreeNode.d.ts","sourceRoot":"","sources":["../../src/interfaces/ITreeNode.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ITreeNode.js","sourceRoot":"","sources":["../../src/interfaces/ITreeNode.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ITreeNode.js","sourceRoot":"","sources":["../../src/interfaces/ITreeNode.ts"],"names":[],"mappings":";;AAoOA,4BAA4B"}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
export interface ITreeNodeData
|
|
1
|
+
export interface ITreeNodeData {
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
3
|
+
* The converted object of the tree node.
|
|
4
4
|
*/
|
|
5
|
+
convertedObject: {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the tree node data.
|
|
10
|
+
*/
|
|
5
11
|
id: string;
|
|
6
12
|
/**
|
|
7
|
-
* The
|
|
8
|
-
* If the version changes, the node data will be marked for an update.
|
|
9
|
-
* A version change can be triggered via {@link updateVersion}.
|
|
13
|
+
* The update callback for the converted object of the tree node.
|
|
10
14
|
*/
|
|
15
|
+
updateCallbackConvertedObject: ((newObj: unknown, oldObj: unknown, viewport: string) => void) | null;
|
|
16
|
+
/**
|
|
17
|
+
* The version of the tree node data.
|
|
18
|
+
* If the version changes, the node data will be marked for an update.
|
|
19
|
+
* A version change can be triggered via {@link updateVersion}.
|
|
20
|
+
*/
|
|
11
21
|
version: string;
|
|
12
22
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
clone():
|
|
23
|
+
* Clones this node tree data.
|
|
24
|
+
*/
|
|
25
|
+
clone(): ITreeNodeData;
|
|
16
26
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
* Update the version.
|
|
28
|
+
*/
|
|
19
29
|
updateVersion(): void;
|
|
20
30
|
}
|
|
21
31
|
//# sourceMappingURL=ITreeNodeData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ITreeNodeData.d.ts","sourceRoot":"","sources":["../../src/interfaces/ITreeNodeData.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,
|
|
1
|
+
{"version":3,"file":"ITreeNodeData.d.ts","sourceRoot":"","sources":["../../src/interfaces/ITreeNodeData.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAG5B;;OAEG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC5C;;KAEC;IACD,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,6BAA6B,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACrG;;;;KAIC;IACD,OAAO,EAAE,MAAM,CAAC;IAMhB;;KAEC;IACD,KAAK,IAAI,aAAa,CAAC;IACvB;;KAEC;IACD,aAAa,IAAI,IAAI,CAAC;CAGvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.shared.node-tree",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -39,11 +39,9 @@
|
|
|
39
39
|
"testEnvironment": "node"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@shapediver/viewer.shared.math": "
|
|
43
|
-
"@shapediver/viewer.shared.services": "
|
|
44
|
-
"
|
|
45
|
-
"gl-matrix": "3.3.0",
|
|
46
|
-
"three": "0.152.2"
|
|
42
|
+
"@shapediver/viewer.shared.math": "3.0.0",
|
|
43
|
+
"@shapediver/viewer.shared.services": "3.0.0",
|
|
44
|
+
"gl-matrix": "3.3.0"
|
|
47
45
|
},
|
|
48
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b6b0010bf5d5652aa338df8016405d97f33fcabb"
|
|
49
47
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITreeNodeData } from '../interfaces/ITreeNodeData';
|
|
2
|
+
import { UuidGenerator } from '@shapediver/viewer.shared.services';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export abstract class AbstractTreeNodeData<T extends ITreeNodeData<any>> implements ITreeNodeData<T> {
|
|
6
|
-
// #region Properties (3)
|
|
7
|
-
|
|
8
|
-
#version: string;
|
|
4
|
+
export abstract class AbstractTreeNodeData implements ITreeNodeData {
|
|
5
|
+
// #region Properties (5)
|
|
9
6
|
|
|
10
7
|
readonly #id: string;
|
|
11
8
|
readonly #uuidGenerator: UuidGenerator = UuidGenerator.instance;
|
|
12
|
-
readonly #eventEngine: EventEngine = EventEngine.instance;
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
#convertedObject: { [key: string]: unknown } = {};
|
|
11
|
+
#updateCallbackConvertedObject: ((newObj: unknown, oldObj: unknown, viewport: string) => void) | null = null;
|
|
12
|
+
#version: string;
|
|
13
|
+
|
|
14
|
+
// #endregion Properties (5)
|
|
15
15
|
|
|
16
16
|
// #region Constructors (1)
|
|
17
17
|
|
|
@@ -27,38 +27,50 @@ export abstract class AbstractTreeNodeData<T extends ITreeNodeData<any>> impleme
|
|
|
27
27
|
|
|
28
28
|
// #endregion Constructors (1)
|
|
29
29
|
|
|
30
|
-
// #region Public
|
|
30
|
+
// #region Public Getters And Setters (6)
|
|
31
|
+
|
|
32
|
+
public get convertedObject(): { [key: string]: unknown } {
|
|
33
|
+
return this.#convertedObject;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public set convertedObject(value: { [key: string]: unknown }) {
|
|
37
|
+
this.#convertedObject = value;
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
public get id(): string {
|
|
33
41
|
return this.#id;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
public get
|
|
37
|
-
return this.#
|
|
44
|
+
public get updateCallbackConvertedObject(): ((newObj: unknown, oldObj: unknown, viewport: string) => void) | null {
|
|
45
|
+
return this.#updateCallbackConvertedObject;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
// #endregion Public Accessors (2)
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
public set updateCallbackConvertedObject(value: ((newObj: unknown, oldObj: unknown, viewport: string) => void) | null) {
|
|
49
|
+
this.#updateCallbackConvertedObject = value;
|
|
50
|
+
}
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
public updateVersion(): void {
|
|
48
|
-
this.#version = this.#uuidGenerator.create();
|
|
52
|
+
public get version(): string {
|
|
53
|
+
return this.#version;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
// #endregion Public
|
|
56
|
+
// #endregion Public Getters And Setters (6)
|
|
52
57
|
|
|
53
|
-
// #region Public
|
|
58
|
+
// #region Public Methods (2)
|
|
54
59
|
|
|
55
60
|
/**
|
|
56
61
|
* Clones the tree node data.
|
|
57
62
|
*/
|
|
58
|
-
public clone():
|
|
59
|
-
const clone = new (
|
|
63
|
+
public clone(): ITreeNodeData {
|
|
64
|
+
const clone = new (this.constructor as new () => ITreeNodeData)();
|
|
60
65
|
return clone;
|
|
61
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Update the version
|
|
70
|
+
*/
|
|
71
|
+
public updateVersion(): void {
|
|
72
|
+
this.#version = this.#uuidGenerator.create();
|
|
73
|
+
}
|
|
62
74
|
|
|
63
|
-
// #endregion Public
|
|
75
|
+
// #endregion Public Methods (2)
|
|
64
76
|
}
|
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
import { ITree } from '../interfaces/ITree';
|
|
2
2
|
import { ITreeNode } from '../interfaces/ITreeNode';
|
|
3
|
-
import {
|
|
3
|
+
import { TreeNode } from './TreeNode';
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
// #region Properties (
|
|
5
|
+
export class Tree implements ITree {
|
|
6
|
+
// #region Properties (2)
|
|
7
7
|
|
|
8
|
-
readonly #root:
|
|
8
|
+
readonly #root: ITreeNode;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
private static _instance: Tree;
|
|
11
|
+
|
|
12
|
+
// #endregion Properties (2)
|
|
11
13
|
|
|
12
14
|
// #region Constructors (1)
|
|
13
15
|
|
|
14
|
-
constructor(
|
|
15
|
-
this.#root = root;
|
|
16
|
+
private constructor() {
|
|
17
|
+
this.#root = new TreeNode('root');
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
// #endregion Constructors (1)
|
|
19
21
|
|
|
20
|
-
// #region Public
|
|
22
|
+
// #region Public Static Getters And Setters (1)
|
|
23
|
+
|
|
24
|
+
public static get instance() {
|
|
25
|
+
return this._instance || (this._instance = new this());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// #endregion Public Static Getters And Setters (1)
|
|
29
|
+
|
|
30
|
+
// #region Public Getters And Setters (1)
|
|
21
31
|
|
|
22
|
-
public get root():
|
|
32
|
+
public get root(): ITreeNode {
|
|
23
33
|
return this.#root;
|
|
24
34
|
}
|
|
25
35
|
|
|
26
|
-
// #endregion Public
|
|
36
|
+
// #endregion Public Getters And Setters (1)
|
|
27
37
|
|
|
28
|
-
// #region Public Methods (
|
|
38
|
+
// #region Public Methods (5)
|
|
29
39
|
|
|
30
|
-
public addNode(node:
|
|
40
|
+
public addNode(node: ITreeNode, parent: ITreeNode = this.#root, root: ITreeNode = this.#root): boolean {
|
|
31
41
|
if (root === parent) {
|
|
32
42
|
root.addChild(node);
|
|
33
43
|
return true;
|
|
@@ -42,7 +52,7 @@ export abstract class AbstractTree<T extends ITreeNode<any, ITreeNodeData<any>>>
|
|
|
42
52
|
return false;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
public addNodeAtPath(node:
|
|
55
|
+
public addNodeAtPath(node: ITreeNode, path: string = this.root.getPath(), root: ITreeNode = this.#root): boolean {
|
|
46
56
|
if (root.name === path) {
|
|
47
57
|
root.addChild(node);
|
|
48
58
|
return true;
|
|
@@ -62,8 +72,8 @@ export abstract class AbstractTree<T extends ITreeNode<any, ITreeNodeData<any>>>
|
|
|
62
72
|
return false;
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
public getNodeAtPath(path: string = this.root.getPath(), root:
|
|
66
|
-
if (root.name === path)
|
|
75
|
+
public getNodeAtPath(path: string = this.root.getPath(), root: ITreeNode = this.#root): ITreeNode | null {
|
|
76
|
+
if (root.name === path)
|
|
67
77
|
return root;
|
|
68
78
|
|
|
69
79
|
const pathStart = path.substr(0, path.indexOf('.'));
|
|
@@ -73,13 +83,13 @@ export abstract class AbstractTree<T extends ITreeNode<any, ITreeNodeData<any>>>
|
|
|
73
83
|
for (let i = 0; i < root.children.length; i++) {
|
|
74
84
|
const child = root.children[i];
|
|
75
85
|
const res = this.getNodeAtPath(shortenedPath, child);
|
|
76
|
-
if(res) return res;
|
|
86
|
+
if (res) return res;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
return null;
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
public removeNode(node:
|
|
92
|
+
public removeNode(node: ITreeNode, root: ITreeNode = this.#root): boolean {
|
|
83
93
|
if (root.hasChild(node)) {
|
|
84
94
|
root.removeChild(node);
|
|
85
95
|
return true;
|
|
@@ -95,7 +105,7 @@ export abstract class AbstractTree<T extends ITreeNode<any, ITreeNodeData<any>>>
|
|
|
95
105
|
return false;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
public removeNodeAtPath(path: string, root:
|
|
108
|
+
public removeNodeAtPath(path: string, root: ITreeNode = this.#root): boolean {
|
|
99
109
|
if (root.name === path) {
|
|
100
110
|
root.parent?.removeChild(root);
|
|
101
111
|
return true;
|
|
@@ -115,5 +125,5 @@ export abstract class AbstractTree<T extends ITreeNode<any, ITreeNodeData<any>>>
|
|
|
115
125
|
return false;
|
|
116
126
|
}
|
|
117
127
|
|
|
118
|
-
// #endregion Public Methods (
|
|
128
|
+
// #endregion Public Methods (5)
|
|
119
129
|
}
|