@combeenation/3d-viewer 5.0.1 → 5.0.3-beta2
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/README.md +111 -114
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +1 -1
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +187 -187
- package/dist/lib-cjs/api/classes/element.d.ts +139 -139
- package/dist/lib-cjs/api/classes/element.js +794 -794
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +14 -0
- package/dist/lib-cjs/api/classes/elementParameterizable.js +135 -0
- package/dist/lib-cjs/api/classes/elementParameterizable.js.map +1 -0
- package/dist/lib-cjs/api/classes/event.d.ts +326 -326
- package/dist/lib-cjs/api/classes/event.js +371 -371
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +53 -53
- package/dist/lib-cjs/api/classes/parameter.d.ts +316 -259
- package/dist/lib-cjs/api/classes/parameter.js +451 -388
- package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +101 -101
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +149 -149
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +44 -44
- package/dist/lib-cjs/api/classes/placementAnimation.js +163 -163
- package/dist/lib-cjs/api/classes/variant.d.ts +234 -234
- package/dist/lib-cjs/api/classes/variant.js +1154 -1154
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +45 -45
- package/dist/lib-cjs/api/classes/variantInstance.js +108 -108
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +99 -99
- package/dist/lib-cjs/api/classes/viewer.d.ts +177 -175
- package/dist/lib-cjs/api/classes/viewer.js +717 -701
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +392 -392
- package/dist/lib-cjs/api/internal/debugViewer.d.ts +13 -13
- package/dist/lib-cjs/api/internal/debugViewer.js +86 -86
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -10
- package/dist/lib-cjs/api/internal/sceneSetup.js +238 -234
- package/dist/lib-cjs/api/internal/sceneSetup.js.map +1 -1
- package/dist/lib-cjs/api/manager/animationManager.d.ts +29 -29
- package/dist/lib-cjs/api/manager/animationManager.js +130 -130
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +65 -65
- package/dist/lib-cjs/api/manager/gltfExportManager.js +223 -222
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +31 -32
- package/dist/lib-cjs/api/manager/sceneManager.js +153 -132
- package/dist/lib-cjs/api/manager/sceneManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +92 -92
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +335 -335
- package/dist/lib-cjs/api/store/specStorage.d.ts +24 -24
- package/dist/lib-cjs/api/store/specStorage.js +51 -51
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +174 -166
- package/dist/lib-cjs/api/util/babylonHelper.js +575 -497
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +366 -356
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -53
- package/dist/lib-cjs/api/util/resourceHelper.js +257 -242
- package/dist/lib-cjs/api/util/resourceHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/stringHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/stringHelper.js +25 -25
- package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/structureHelper.js +48 -44
- package/dist/lib-cjs/api/util/structureHelper.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/index.d.ts +49 -49
- package/dist/lib-cjs/index.js +89 -89
- package/dist/webpack-stats.json +0 -0
- package/package.json +87 -87
- package/src/api/classes/animationInterface.ts +10 -10
- package/src/api/classes/dottedPath.ts +181 -181
- package/src/api/classes/element.ts +690 -692
- package/src/api/classes/event.ts +367 -367
- package/src/api/classes/eventBroadcaster.ts +52 -52
- package/src/api/classes/parameter.ts +474 -405
- package/src/api/classes/parameterObservable.ts +100 -100
- package/src/api/classes/parameterizable.ts +87 -87
- package/src/api/classes/placementAnimation.ts +160 -160
- package/src/api/classes/variant.ts +845 -845
- package/src/api/classes/variantInstance.ts +97 -97
- package/src/api/classes/variantParameterizable.ts +85 -85
- package/src/api/classes/viewer.ts +650 -624
- package/src/api/classes/viewerLight.ts +334 -334
- package/src/api/internal/debugViewer.ts +90 -90
- package/src/api/internal/lensRendering.ts +10 -10
- package/src/api/internal/sceneSetup.ts +204 -201
- package/src/api/manager/animationManager.ts +142 -142
- package/src/api/manager/gltfExportManager.ts +191 -191
- package/src/api/manager/sceneManager.ts +128 -102
- package/src/api/manager/variantInstanceManager.ts +265 -265
- package/src/api/store/specStorage.ts +51 -51
- package/src/api/util/babylonHelper.ts +628 -538
- package/src/api/util/globalTypes.ts +413 -402
- package/src/api/util/resourceHelper.ts +189 -173
- package/src/api/util/stringHelper.ts +23 -23
- package/src/api/util/structureHelper.ts +49 -43
- package/src/buildinfo.json +3 -3
- package/src/commonjs.tsconfig.json +10 -10
- package/src/declaration.tsconfig.json +8 -8
- package/src/dev.ts +42 -42
- package/src/es6.tsconfig.json +10 -10
- package/src/index.ts +94 -94
- package/src/pagesconfig.json +77 -73
- package/src/tsconfig.json +32 -32
- package/src/tsconfig.types.json +9 -9
- package/src/types.d.ts +3 -3
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
2
|
-
import { Element } from './element';
|
|
3
|
-
import { ViewerLight } from './viewerLight';
|
|
4
|
-
import { EventBroadcaster } from './eventBroadcaster';
|
|
5
|
-
import { ParameterObservable } from './parameterObservable';
|
|
6
|
-
import { Variant } from './variant';
|
|
7
|
-
/**
|
|
8
|
-
* Class VariantInstance.
|
|
9
|
-
*/
|
|
10
|
-
export declare class VariantInstance extends EventBroadcaster {
|
|
11
|
-
variant: Variant;
|
|
12
|
-
name: string;
|
|
13
|
-
/**
|
|
14
|
-
* Constructor
|
|
15
|
-
*/
|
|
16
|
-
constructor(variant: Variant, name: string);
|
|
17
|
-
/**
|
|
18
|
-
* WORK IN PROGRESS
|
|
19
|
-
*/
|
|
20
|
-
translate(joint: DottedPathArgument, variantInstance: VariantInstance, variantInstanceJoint: DottedPathArgument): VariantInstance;
|
|
21
|
-
/**
|
|
22
|
-
* A proxy for {@link Variant.getElement}.
|
|
23
|
-
*/
|
|
24
|
-
getElement(dottedPath: DottedPathArgument): Promise<Element>;
|
|
25
|
-
/**
|
|
26
|
-
* A proxy for {@link Variant.getViewerLight}.
|
|
27
|
-
*/
|
|
28
|
-
getViewerLight(dottedPath: DottedPathArgument): Promise<ViewerLight>;
|
|
29
|
-
/**
|
|
30
|
-
* A proxy for {@link Variant.getNode}.
|
|
31
|
-
*/
|
|
32
|
-
getNode(elementDottedPath: DottedPathArgument, nodeDottedPath: DottedPathArgument): Promise<TransformNode>;
|
|
33
|
-
/**
|
|
34
|
-
* A proxy for {@link Variant.getMesh}.
|
|
35
|
-
*/
|
|
36
|
-
getMesh(elementDottedPath: DottedPathArgument, meshDottedPath: DottedPathArgument): Promise<Mesh | null>;
|
|
37
|
-
/**
|
|
38
|
-
* A proxy for {@link Variant.commitParameters}.
|
|
39
|
-
*/
|
|
40
|
-
commitParameters(parameters?: ParameterBag): Promise<Variant>;
|
|
41
|
-
/**
|
|
42
|
-
* A proxy for {@link ParameterObservable.commitParameter}.
|
|
43
|
-
*/
|
|
44
|
-
commitParameter(parameter: string, value: ParameterValue): Promise<ParameterObservable>;
|
|
45
|
-
}
|
|
1
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
2
|
+
import { Element } from './element';
|
|
3
|
+
import { ViewerLight } from './viewerLight';
|
|
4
|
+
import { EventBroadcaster } from './eventBroadcaster';
|
|
5
|
+
import { ParameterObservable } from './parameterObservable';
|
|
6
|
+
import { Variant } from './variant';
|
|
7
|
+
/**
|
|
8
|
+
* Class VariantInstance.
|
|
9
|
+
*/
|
|
10
|
+
export declare class VariantInstance extends EventBroadcaster {
|
|
11
|
+
variant: Variant;
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor(variant: Variant, name: string);
|
|
17
|
+
/**
|
|
18
|
+
* WORK IN PROGRESS
|
|
19
|
+
*/
|
|
20
|
+
translate(joint: DottedPathArgument, variantInstance: VariantInstance, variantInstanceJoint: DottedPathArgument): VariantInstance;
|
|
21
|
+
/**
|
|
22
|
+
* A proxy for {@link Variant.getElement}.
|
|
23
|
+
*/
|
|
24
|
+
getElement(dottedPath: DottedPathArgument): Promise<Element>;
|
|
25
|
+
/**
|
|
26
|
+
* A proxy for {@link Variant.getViewerLight}.
|
|
27
|
+
*/
|
|
28
|
+
getViewerLight(dottedPath: DottedPathArgument): Promise<ViewerLight>;
|
|
29
|
+
/**
|
|
30
|
+
* A proxy for {@link Variant.getNode}.
|
|
31
|
+
*/
|
|
32
|
+
getNode(elementDottedPath: DottedPathArgument, nodeDottedPath: DottedPathArgument): Promise<TransformNode>;
|
|
33
|
+
/**
|
|
34
|
+
* A proxy for {@link Variant.getMesh}.
|
|
35
|
+
*/
|
|
36
|
+
getMesh(elementDottedPath: DottedPathArgument, meshDottedPath: DottedPathArgument): Promise<Mesh | null>;
|
|
37
|
+
/**
|
|
38
|
+
* A proxy for {@link Variant.commitParameters}.
|
|
39
|
+
*/
|
|
40
|
+
commitParameters(parameters?: ParameterBag): Promise<Variant>;
|
|
41
|
+
/**
|
|
42
|
+
* A proxy for {@link ParameterObservable.commitParameter}.
|
|
43
|
+
*/
|
|
44
|
+
commitParameter(parameter: string, value: ParameterValue): Promise<ParameterObservable>;
|
|
45
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VariantInstance = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var eventBroadcaster_1 = require("./eventBroadcaster");
|
|
6
|
-
/**
|
|
7
|
-
* Class VariantInstance.
|
|
8
|
-
*/
|
|
9
|
-
var VariantInstance = /** @class */ (function (_super) {
|
|
10
|
-
tslib_1.__extends(VariantInstance, _super);
|
|
11
|
-
/**
|
|
12
|
-
* Constructor
|
|
13
|
-
*/
|
|
14
|
-
function VariantInstance(variant, name) {
|
|
15
|
-
var _this = _super.call(this) || this;
|
|
16
|
-
_this.variant = variant;
|
|
17
|
-
_this.name = name;
|
|
18
|
-
return _this;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* WORK IN PROGRESS
|
|
22
|
-
*/
|
|
23
|
-
VariantInstance.prototype.translate = function (joint, variantInstance, variantInstanceJoint) {
|
|
24
|
-
/*
|
|
25
|
-
joint = DottedPath.create( joint );
|
|
26
|
-
variantInstanceJoint = DottedPath.create( variantInstanceJoint );
|
|
27
|
-
const jointNode = variantInstance.variant.getNode( joint.path );
|
|
28
|
-
const variantInstanceJointNode = variantInstance.variant.getNode( variantInstanceJoint.path );
|
|
29
|
-
const differenceVector = variantInstanceJointNode.getAbsolutePosition().subtract( jointNode.getAbsolutePosition() );
|
|
30
|
-
const differenceVectorRotation = variantInstanceJointNode.rotation.subtract( jointNode.rotation );
|
|
31
|
-
|
|
32
|
-
console.log( variantInstanceJointNode.rotationQuaternion, 'ROTATION' );
|
|
33
|
-
|
|
34
|
-
this.variant.nodes.forEach( node => {
|
|
35
|
-
node.translate( Axis.X, differenceVector.x, Space.WORLD );
|
|
36
|
-
node.translate( Axis.Y, differenceVector.y, Space.WORLD );
|
|
37
|
-
node.translate( Axis.Z, differenceVector.z, Space.WORLD );
|
|
38
|
-
|
|
39
|
-
node.rotateAround( Axis.Y, differenceVectorRotation, 20 );
|
|
40
|
-
// node.rotate(Axis.Y, differenceVectorRotation.y, Space.WORLD );
|
|
41
|
-
// node.rotate(Axis.Z, differenceVectorRotation.z, Space.WORLD );
|
|
42
|
-
} );
|
|
43
|
-
*/
|
|
44
|
-
return this;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* A proxy for {@link Variant.getElement}.
|
|
48
|
-
*/
|
|
49
|
-
VariantInstance.prototype.getElement = function (dottedPath) {
|
|
50
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
51
|
-
return tslib_1.__generator(this, function (_a) {
|
|
52
|
-
return [2 /*return*/, this.variant.getElement(dottedPath)];
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* A proxy for {@link Variant.getViewerLight}.
|
|
58
|
-
*/
|
|
59
|
-
VariantInstance.prototype.getViewerLight = function (dottedPath) {
|
|
60
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
61
|
-
return tslib_1.__generator(this, function (_a) {
|
|
62
|
-
return [2 /*return*/, this.variant.getViewerLight(dottedPath)];
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* A proxy for {@link Variant.getNode}.
|
|
68
|
-
*/
|
|
69
|
-
VariantInstance.prototype.getNode = function (elementDottedPath, nodeDottedPath) {
|
|
70
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
71
|
-
return tslib_1.__generator(this, function (_a) {
|
|
72
|
-
return [2 /*return*/, this.variant.getNode(elementDottedPath, nodeDottedPath)];
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* A proxy for {@link Variant.getMesh}.
|
|
78
|
-
*/
|
|
79
|
-
VariantInstance.prototype.getMesh = function (elementDottedPath, meshDottedPath) {
|
|
80
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
81
|
-
return tslib_1.__generator(this, function (_a) {
|
|
82
|
-
return [2 /*return*/, this.variant.getMesh(elementDottedPath, meshDottedPath)];
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* A proxy for {@link Variant.commitParameters}.
|
|
88
|
-
*/
|
|
89
|
-
VariantInstance.prototype.commitParameters = function (parameters) {
|
|
90
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
91
|
-
return tslib_1.__generator(this, function (_a) {
|
|
92
|
-
return [2 /*return*/, this.variant.commitParameters(parameters)];
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* A proxy for {@link ParameterObservable.commitParameter}.
|
|
98
|
-
*/
|
|
99
|
-
VariantInstance.prototype.commitParameter = function (parameter, value) {
|
|
100
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
101
|
-
return tslib_1.__generator(this, function (_a) {
|
|
102
|
-
return [2 /*return*/, this.variant.commitParameter(parameter, value)];
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
return VariantInstance;
|
|
107
|
-
}(eventBroadcaster_1.EventBroadcaster));
|
|
108
|
-
exports.VariantInstance = VariantInstance;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VariantInstance = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var eventBroadcaster_1 = require("./eventBroadcaster");
|
|
6
|
+
/**
|
|
7
|
+
* Class VariantInstance.
|
|
8
|
+
*/
|
|
9
|
+
var VariantInstance = /** @class */ (function (_super) {
|
|
10
|
+
tslib_1.__extends(VariantInstance, _super);
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
*/
|
|
14
|
+
function VariantInstance(variant, name) {
|
|
15
|
+
var _this = _super.call(this) || this;
|
|
16
|
+
_this.variant = variant;
|
|
17
|
+
_this.name = name;
|
|
18
|
+
return _this;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* WORK IN PROGRESS
|
|
22
|
+
*/
|
|
23
|
+
VariantInstance.prototype.translate = function (joint, variantInstance, variantInstanceJoint) {
|
|
24
|
+
/*
|
|
25
|
+
joint = DottedPath.create( joint );
|
|
26
|
+
variantInstanceJoint = DottedPath.create( variantInstanceJoint );
|
|
27
|
+
const jointNode = variantInstance.variant.getNode( joint.path );
|
|
28
|
+
const variantInstanceJointNode = variantInstance.variant.getNode( variantInstanceJoint.path );
|
|
29
|
+
const differenceVector = variantInstanceJointNode.getAbsolutePosition().subtract( jointNode.getAbsolutePosition() );
|
|
30
|
+
const differenceVectorRotation = variantInstanceJointNode.rotation.subtract( jointNode.rotation );
|
|
31
|
+
|
|
32
|
+
console.log( variantInstanceJointNode.rotationQuaternion, 'ROTATION' );
|
|
33
|
+
|
|
34
|
+
this.variant.nodes.forEach( node => {
|
|
35
|
+
node.translate( Axis.X, differenceVector.x, Space.WORLD );
|
|
36
|
+
node.translate( Axis.Y, differenceVector.y, Space.WORLD );
|
|
37
|
+
node.translate( Axis.Z, differenceVector.z, Space.WORLD );
|
|
38
|
+
|
|
39
|
+
node.rotateAround( Axis.Y, differenceVectorRotation, 20 );
|
|
40
|
+
// node.rotate(Axis.Y, differenceVectorRotation.y, Space.WORLD );
|
|
41
|
+
// node.rotate(Axis.Z, differenceVectorRotation.z, Space.WORLD );
|
|
42
|
+
} );
|
|
43
|
+
*/
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A proxy for {@link Variant.getElement}.
|
|
48
|
+
*/
|
|
49
|
+
VariantInstance.prototype.getElement = function (dottedPath) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
51
|
+
return tslib_1.__generator(this, function (_a) {
|
|
52
|
+
return [2 /*return*/, this.variant.getElement(dottedPath)];
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A proxy for {@link Variant.getViewerLight}.
|
|
58
|
+
*/
|
|
59
|
+
VariantInstance.prototype.getViewerLight = function (dottedPath) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
61
|
+
return tslib_1.__generator(this, function (_a) {
|
|
62
|
+
return [2 /*return*/, this.variant.getViewerLight(dottedPath)];
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A proxy for {@link Variant.getNode}.
|
|
68
|
+
*/
|
|
69
|
+
VariantInstance.prototype.getNode = function (elementDottedPath, nodeDottedPath) {
|
|
70
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
71
|
+
return tslib_1.__generator(this, function (_a) {
|
|
72
|
+
return [2 /*return*/, this.variant.getNode(elementDottedPath, nodeDottedPath)];
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A proxy for {@link Variant.getMesh}.
|
|
78
|
+
*/
|
|
79
|
+
VariantInstance.prototype.getMesh = function (elementDottedPath, meshDottedPath) {
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
81
|
+
return tslib_1.__generator(this, function (_a) {
|
|
82
|
+
return [2 /*return*/, this.variant.getMesh(elementDottedPath, meshDottedPath)];
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A proxy for {@link Variant.commitParameters}.
|
|
88
|
+
*/
|
|
89
|
+
VariantInstance.prototype.commitParameters = function (parameters) {
|
|
90
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
91
|
+
return tslib_1.__generator(this, function (_a) {
|
|
92
|
+
return [2 /*return*/, this.variant.commitParameters(parameters)];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A proxy for {@link ParameterObservable.commitParameter}.
|
|
98
|
+
*/
|
|
99
|
+
VariantInstance.prototype.commitParameter = function (parameter, value) {
|
|
100
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
101
|
+
return tslib_1.__generator(this, function (_a) {
|
|
102
|
+
return [2 /*return*/, this.variant.commitParameter(parameter, value)];
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return VariantInstance;
|
|
107
|
+
}(eventBroadcaster_1.EventBroadcaster));
|
|
108
|
+
exports.VariantInstance = VariantInstance;
|
|
109
109
|
//# sourceMappingURL=variantInstance.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Parameterizable } from './../classes/parameterizable';
|
|
2
|
-
import { Variant } from './../classes/variant';
|
|
3
|
-
export declare abstract class VariantParameterizable extends Parameterizable {
|
|
4
|
-
readonly variant: Variant;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
|
|
7
|
-
protected constructor(variant: Variant, name: string);
|
|
8
|
-
/**
|
|
9
|
-
* Gets the inherited parameters from the {@link Variant} with cleaned {@link Parameterizable} prefix.
|
|
10
|
-
*/
|
|
11
|
-
get inheritedParameters(): ParameterBag;
|
|
12
|
-
/**
|
|
13
|
-
* Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in the
|
|
14
|
-
* {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
|
|
15
|
-
*/
|
|
16
|
-
commitParameters(parameters?: ParameterBag): Promise<VariantParameterizable>;
|
|
17
|
-
}
|
|
1
|
+
import { Parameterizable } from './../classes/parameterizable';
|
|
2
|
+
import { Variant } from './../classes/variant';
|
|
3
|
+
export declare abstract class VariantParameterizable extends Parameterizable {
|
|
4
|
+
readonly variant: Variant;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
protected readonly _parameterObservers: Map<string, ParameterObserver[]>;
|
|
7
|
+
protected constructor(variant: Variant, name: string);
|
|
8
|
+
/**
|
|
9
|
+
* Gets the inherited parameters from the {@link Variant} with cleaned {@link Parameterizable} prefix.
|
|
10
|
+
*/
|
|
11
|
+
get inheritedParameters(): ParameterBag;
|
|
12
|
+
/**
|
|
13
|
+
* Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in the
|
|
14
|
+
* {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
|
|
15
|
+
*/
|
|
16
|
+
commitParameters(parameters?: ParameterBag): Promise<VariantParameterizable>;
|
|
17
|
+
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VariantParameterizable = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var lodash_es_1 = require("lodash-es");
|
|
6
|
-
var dottedPath_1 = require("./../classes/dottedPath");
|
|
7
|
-
var event_1 = require("./../classes/event");
|
|
8
|
-
var parameterizable_1 = require("./../classes/parameterizable");
|
|
9
|
-
var resourceHelper_1 = require("./../util/resourceHelper");
|
|
10
|
-
var stringHelper_1 = require("./../util/stringHelper");
|
|
11
|
-
var VariantParameterizable = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(VariantParameterizable, _super);
|
|
13
|
-
function VariantParameterizable(variant, name) {
|
|
14
|
-
var _this = _super.call(this) || this;
|
|
15
|
-
_this.variant = variant;
|
|
16
|
-
_this.name = name;
|
|
17
|
-
_this._parameterObservers = new Map();
|
|
18
|
-
return _this;
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(VariantParameterizable.prototype, "inheritedParameters", {
|
|
21
|
-
/**
|
|
22
|
-
* Gets the inherited parameters from the {@link Variant} with cleaned {@link Parameterizable} prefix.
|
|
23
|
-
*/
|
|
24
|
-
get: function () {
|
|
25
|
-
var parameterBag = {};
|
|
26
|
-
for (var parameter in this.variant.inheritedParameters) {
|
|
27
|
-
var dpp = dottedPath_1.DottedPath.create(parameter);
|
|
28
|
-
if (dpp.parts.length !== 1) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
parameterBag[parameter] = this.variant.inheritedParameters[parameter];
|
|
32
|
-
}
|
|
33
|
-
for (var parameter in this.variant.inheritedParameters) {
|
|
34
|
-
var dpp = dottedPath_1.DottedPath.create(parameter);
|
|
35
|
-
if (dpp.firstPart !== this.name) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
dpp.shiftPart();
|
|
39
|
-
parameterBag[dpp.path] = this.variant.inheritedParameters[parameter];
|
|
40
|
-
}
|
|
41
|
-
return parameterBag;
|
|
42
|
-
},
|
|
43
|
-
enumerable: false,
|
|
44
|
-
configurable: true
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in the
|
|
48
|
-
* {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
|
|
49
|
-
*/
|
|
50
|
-
VariantParameterizable.prototype.commitParameters = function (parameters) {
|
|
51
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var oldParameters, observerPromises, _loop_1, this_1, parameter;
|
|
53
|
-
var _this = this;
|
|
54
|
-
return tslib_1.__generator(this, function (_a) {
|
|
55
|
-
switch (_a.label) {
|
|
56
|
-
case 0:
|
|
57
|
-
if (!parameters) {
|
|
58
|
-
parameters = {};
|
|
59
|
-
}
|
|
60
|
-
oldParameters = lodash_es_1.cloneDeep(this.parameters);
|
|
61
|
-
lodash_es_1.merge(this.parameters, parameters);
|
|
62
|
-
observerPromises = [];
|
|
63
|
-
_loop_1 = function (parameter) {
|
|
64
|
-
var oldParameterValue = oldParameters[parameter];
|
|
65
|
-
var newParameterValue = this_1.parameters[parameter];
|
|
66
|
-
this_1.variant.assertParameter(this_1.variant.inheritedParameterDeclaration, parameter, newParameterValue);
|
|
67
|
-
if (oldParameterValue === newParameterValue) {
|
|
68
|
-
return "continue";
|
|
69
|
-
}
|
|
70
|
-
// parameter changed
|
|
71
|
-
var parameterObservers = resourceHelper_1.mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
|
|
72
|
-
if (parameterObservers.has(parameter)) {
|
|
73
|
-
var observers = parameterObservers.get(parameter);
|
|
74
|
-
observerPromises = lodash_es_1.concat(observerPromises, observers.map(function (observer) {
|
|
75
|
-
var observerResult = observer(_this, oldParameterValue, newParameterValue);
|
|
76
|
-
var observerPromise = Promise.resolve(observerResult);
|
|
77
|
-
observerPromise.then(function () {
|
|
78
|
-
var clsName = stringHelper_1.camelToSnakeCase(_this.constructor.name).toUpperCase();
|
|
79
|
-
_this.broadcastEvent(lodash_es_1.get(event_1.Event, clsName + '_PARAMETER_COMMITTED'), _this, parameter, oldParameterValue, newParameterValue);
|
|
80
|
-
});
|
|
81
|
-
return observerPromise;
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
this_1 = this;
|
|
86
|
-
for (parameter in this.parameters) {
|
|
87
|
-
_loop_1(parameter);
|
|
88
|
-
}
|
|
89
|
-
return [4 /*yield*/, Promise.all(observerPromises)];
|
|
90
|
-
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2 /*return*/, this];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
return VariantParameterizable;
|
|
98
|
-
}(parameterizable_1.Parameterizable));
|
|
99
|
-
exports.VariantParameterizable = VariantParameterizable;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VariantParameterizable = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var lodash_es_1 = require("lodash-es");
|
|
6
|
+
var dottedPath_1 = require("./../classes/dottedPath");
|
|
7
|
+
var event_1 = require("./../classes/event");
|
|
8
|
+
var parameterizable_1 = require("./../classes/parameterizable");
|
|
9
|
+
var resourceHelper_1 = require("./../util/resourceHelper");
|
|
10
|
+
var stringHelper_1 = require("./../util/stringHelper");
|
|
11
|
+
var VariantParameterizable = /** @class */ (function (_super) {
|
|
12
|
+
tslib_1.__extends(VariantParameterizable, _super);
|
|
13
|
+
function VariantParameterizable(variant, name) {
|
|
14
|
+
var _this = _super.call(this) || this;
|
|
15
|
+
_this.variant = variant;
|
|
16
|
+
_this.name = name;
|
|
17
|
+
_this._parameterObservers = new Map();
|
|
18
|
+
return _this;
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(VariantParameterizable.prototype, "inheritedParameters", {
|
|
21
|
+
/**
|
|
22
|
+
* Gets the inherited parameters from the {@link Variant} with cleaned {@link Parameterizable} prefix.
|
|
23
|
+
*/
|
|
24
|
+
get: function () {
|
|
25
|
+
var parameterBag = {};
|
|
26
|
+
for (var parameter in this.variant.inheritedParameters) {
|
|
27
|
+
var dpp = dottedPath_1.DottedPath.create(parameter);
|
|
28
|
+
if (dpp.parts.length !== 1) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
parameterBag[parameter] = this.variant.inheritedParameters[parameter];
|
|
32
|
+
}
|
|
33
|
+
for (var parameter in this.variant.inheritedParameters) {
|
|
34
|
+
var dpp = dottedPath_1.DottedPath.create(parameter);
|
|
35
|
+
if (dpp.firstPart !== this.name) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
dpp.shiftPart();
|
|
39
|
+
parameterBag[dpp.path] = this.variant.inheritedParameters[parameter];
|
|
40
|
+
}
|
|
41
|
+
return parameterBag;
|
|
42
|
+
},
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Places the given {@link ParameterBag} in the {@link VariantParameterizable}'s parameters, replaces all patterns in the
|
|
48
|
+
* {@link StructureJson} and broadcasts all {@link ParameterObserver}s.
|
|
49
|
+
*/
|
|
50
|
+
VariantParameterizable.prototype.commitParameters = function (parameters) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var oldParameters, observerPromises, _loop_1, this_1, parameter;
|
|
53
|
+
var _this = this;
|
|
54
|
+
return tslib_1.__generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
if (!parameters) {
|
|
58
|
+
parameters = {};
|
|
59
|
+
}
|
|
60
|
+
oldParameters = lodash_es_1.cloneDeep(this.parameters);
|
|
61
|
+
lodash_es_1.merge(this.parameters, parameters);
|
|
62
|
+
observerPromises = [];
|
|
63
|
+
_loop_1 = function (parameter) {
|
|
64
|
+
var oldParameterValue = oldParameters[parameter];
|
|
65
|
+
var newParameterValue = this_1.parameters[parameter];
|
|
66
|
+
this_1.variant.assertParameter(this_1.variant.inheritedParameterDeclaration, parameter, newParameterValue);
|
|
67
|
+
if (oldParameterValue === newParameterValue) {
|
|
68
|
+
return "continue";
|
|
69
|
+
}
|
|
70
|
+
// parameter changed
|
|
71
|
+
var parameterObservers = resourceHelper_1.mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
|
|
72
|
+
if (parameterObservers.has(parameter)) {
|
|
73
|
+
var observers = parameterObservers.get(parameter);
|
|
74
|
+
observerPromises = lodash_es_1.concat(observerPromises, observers.map(function (observer) {
|
|
75
|
+
var observerResult = observer(_this, oldParameterValue, newParameterValue);
|
|
76
|
+
var observerPromise = Promise.resolve(observerResult);
|
|
77
|
+
observerPromise.then(function () {
|
|
78
|
+
var clsName = stringHelper_1.camelToSnakeCase(_this.constructor.name).toUpperCase();
|
|
79
|
+
_this.broadcastEvent(lodash_es_1.get(event_1.Event, clsName + '_PARAMETER_COMMITTED'), _this, parameter, oldParameterValue, newParameterValue);
|
|
80
|
+
});
|
|
81
|
+
return observerPromise;
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
this_1 = this;
|
|
86
|
+
for (parameter in this.parameters) {
|
|
87
|
+
_loop_1(parameter);
|
|
88
|
+
}
|
|
89
|
+
return [4 /*yield*/, Promise.all(observerPromises)];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [2 /*return*/, this];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
return VariantParameterizable;
|
|
98
|
+
}(parameterizable_1.Parameterizable));
|
|
99
|
+
exports.VariantParameterizable = VariantParameterizable;
|
|
100
100
|
//# sourceMappingURL=variantParameterizable.js.map
|