@shapediver/viewer.shared.services 3.16.8 → 3.16.10
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/converter/Converter.d.ts +77 -77
- package/dist/converter/Converter.js +424 -424
- package/dist/converter/Converter.js.map +1 -1
- package/dist/dom-event-engine/DomEventEngine.d.ts +56 -56
- package/dist/dom-event-engine/DomEventEngine.js +275 -275
- package/dist/dom-event-engine/DomEventEngine.js.map +1 -1
- package/dist/dom-event-engine/IDomEventListener.d.ts +10 -10
- package/dist/dom-event-engine/IDomEventListener.js +2 -2
- package/dist/event-engine/EventEngine.d.ts +35 -35
- package/dist/event-engine/EventEngine.js +107 -107
- package/dist/event-engine/EventEngine.js.map +1 -1
- package/dist/event-engine/interfaces/ICallback.d.ts +4 -4
- package/dist/event-engine/interfaces/ICallback.js +2 -2
- package/dist/event-engine/interfaces/IListener.d.ts +5 -5
- package/dist/event-engine/interfaces/IListener.js +2 -2
- package/dist/http-client/HttpClient.d.ts +106 -106
- package/dist/http-client/HttpClient.js +375 -375
- package/dist/http-client/HttpClient.js.map +1 -1
- package/dist/http-client/HttpResponse.d.ts +5 -5
- package/dist/http-client/HttpResponse.js +2 -2
- package/dist/index.d.ts +43 -43
- package/dist/index.js +102 -102
- package/dist/input-validator/InputValidator.d.ts +10 -10
- package/dist/input-validator/InputValidator.d.ts.map +1 -1
- package/dist/input-validator/InputValidator.js +169 -169
- package/dist/input-validator/InputValidator.js.map +1 -1
- package/dist/logger/ErrorTypeGuards.d.ts +41 -41
- package/dist/logger/ErrorTypeGuards.js +158 -159
- package/dist/logger/ErrorTypeGuards.js.map +1 -1
- package/dist/logger/Logger.d.ts +63 -63
- package/dist/logger/Logger.js +179 -179
- package/dist/logger/Logger.js.map +1 -1
- package/dist/logger/ShapeDiverBackendErrors.d.ts +14 -14
- package/dist/logger/ShapeDiverBackendErrors.js +28 -28
- package/dist/logger/ShapeDiverError.d.ts +33 -33
- package/dist/logger/ShapeDiverError.js +43 -43
- package/dist/logger/ShapeDiverError.js.map +1 -1
- package/dist/logger/ShapeDiverViewerErrors.d.ts +87 -87
- package/dist/logger/ShapeDiverViewerErrors.d.ts.map +1 -1
- package/dist/logger/ShapeDiverViewerErrors.js +119 -119
- package/dist/logger/ShapeDiverViewerErrors.js.map +1 -1
- package/dist/parameter-utils/ParameterUtils.d.ts +3 -3
- package/dist/parameter-utils/ParameterUtils.d.ts.map +1 -1
- package/dist/parameter-utils/ParameterUtils.js +161 -161
- package/dist/parameter-utils/ParameterUtils.js.map +1 -1
- package/dist/performance-evaluator/PerformanceEvaluator.d.ts +65 -65
- package/dist/performance-evaluator/PerformanceEvaluator.js +125 -125
- package/dist/settings-engine/SettingsEngine.d.ts +43 -43
- package/dist/settings-engine/SettingsEngine.d.ts.map +1 -1
- package/dist/settings-engine/SettingsEngine.js +162 -162
- package/dist/settings-engine/SettingsEngine.js.map +1 -1
- package/dist/settings-engine/defaults/Defaults.d.ts +2 -2
- package/dist/settings-engine/defaults/Defaults.js +102 -102
- package/dist/settings-engine/defaults/FurnitureDefaults.d.ts +2 -2
- package/dist/settings-engine/defaults/FurnitureDefaults.js +158 -158
- package/dist/settings-engine/defaults/HighPerformanceDefaults.d.ts +2 -2
- package/dist/settings-engine/defaults/HighPerformanceDefaults.js +114 -114
- package/dist/settings-engine/defaults/JewelryDefaults.d.ts +2 -2
- package/dist/settings-engine/defaults/JewelryDefaults.js +91 -91
- package/dist/settings-engine/defaults/MedicalDefaults.d.ts +2 -2
- package/dist/settings-engine/defaults/MedicalDefaults.js +102 -102
- package/dist/settings-engine/defaults/TwoDimensionalDefaults.d.ts +2 -2
- package/dist/settings-engine/defaults/TwoDimensionalDefaults.js +83 -83
- package/dist/state-engine/ISessionGlobalAccessObjectDefinition.d.ts +21 -21
- package/dist/state-engine/ISessionGlobalAccessObjectDefinition.js +2 -2
- package/dist/state-engine/IViewportGlobalAccessObjectDefinition.d.ts +33 -33
- package/dist/state-engine/IViewportGlobalAccessObjectDefinition.js +2 -2
- package/dist/state-engine/StateEngine.d.ts +18 -18
- package/dist/state-engine/StateEngine.js +32 -32
- package/dist/state-engine/StatePromise.d.ts +13 -13
- package/dist/state-engine/StatePromise.js +55 -55
- package/dist/system-info/SystemInfo.d.ts +57 -57
- package/dist/system-info/SystemInfo.js +127 -127
- package/dist/system-info/SystemInfo.js.map +1 -1
- package/dist/type-check/TypeChecker.d.ts +6 -6
- package/dist/type-check/TypeChecker.js +19 -19
- package/dist/utilities/ObservableArray.d.ts +25 -25
- package/dist/utilities/ObservableArray.d.ts.map +1 -1
- package/dist/utilities/ObservableArray.js +64 -64
- package/dist/utilities/ObservableArray.js.map +1 -1
- package/dist/utilities/base64.d.ts +2 -2
- package/dist/utilities/base64.d.ts.map +1 -1
- package/dist/utilities/base64.js +21 -21
- package/dist/utilities/base64.js.map +1 -1
- package/dist/utilities/hashCreator.d.ts +7 -7
- package/dist/utilities/hashCreator.d.ts.map +1 -1
- package/dist/utilities/hashCreator.js +29 -29
- package/dist/utilities/hashCreator.js.map +1 -1
- package/dist/utilities/numberCleaner.d.ts +1 -1
- package/dist/utilities/numberCleaner.d.ts.map +1 -1
- package/dist/utilities/numberCleaner.js +8 -8
- package/dist/uuid-generator/UuidGenerator.d.ts +28 -28
- package/dist/uuid-generator/UuidGenerator.js +46 -46
- package/package.json +7 -7
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringify = exports.isValid = void 0;
|
|
4
|
-
const sdk_geometry_api_sdk_v2_1 = require("@shapediver/sdk.geometry-api-sdk-v2");
|
|
5
|
-
const Converter_1 = require("../converter/Converter");
|
|
6
|
-
const InputValidator_1 = require("../input-validator/InputValidator");
|
|
7
|
-
const ShapeDiverViewerErrors_1 = require("../logger/ShapeDiverViewerErrors");
|
|
8
|
-
const isValid = (definition, value, throwError) => {
|
|
9
|
-
try {
|
|
10
|
-
return validateParameterValue(definition, value);
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
if (throwError)
|
|
14
|
-
throw e;
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.isValid = isValid;
|
|
19
|
-
const validateParameterValue = (definition, value) => {
|
|
20
|
-
const { id, type, min, max, decimalplaces, choices, visualization } = definition;
|
|
21
|
-
switch (true) {
|
|
22
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.BOOL:
|
|
23
|
-
if (typeof value === "string") {
|
|
24
|
-
if (!(value === "true" || value === "false"))
|
|
25
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is a string that is neither true or false.`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "boolean");
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.COLOR:
|
|
32
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "color");
|
|
33
|
-
break;
|
|
34
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.FILE:
|
|
35
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "file");
|
|
36
|
-
break;
|
|
37
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN ||
|
|
38
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.FLOAT ||
|
|
39
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT ||
|
|
40
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD:
|
|
41
|
-
{
|
|
42
|
-
let temp = value;
|
|
43
|
-
if (typeof value === "string")
|
|
44
|
-
temp = +value;
|
|
45
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
46
|
-
if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN) {
|
|
47
|
-
if (temp % 2 !== 0)
|
|
48
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not even.`);
|
|
49
|
-
}
|
|
50
|
-
else if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD) {
|
|
51
|
-
if (temp % 2 === 0)
|
|
52
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not odd.`);
|
|
53
|
-
}
|
|
54
|
-
else if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT) {
|
|
55
|
-
if (!Number.isInteger(temp))
|
|
56
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not an integer.`);
|
|
57
|
-
}
|
|
58
|
-
if (min || min === 0)
|
|
59
|
-
if (temp < min)
|
|
60
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is smaller than the minimum ${min}.`);
|
|
61
|
-
if (max || max === 0)
|
|
62
|
-
if (temp > max)
|
|
63
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is larger than the maximum ${max}.`);
|
|
64
|
-
if (decimalplaces || decimalplaces === 0) {
|
|
65
|
-
const numStr = temp + "";
|
|
66
|
-
let decimalplaces = 0;
|
|
67
|
-
if (numStr.includes("."))
|
|
68
|
-
decimalplaces = numStr.split(".")[1].length;
|
|
69
|
-
if (decimalplaces < decimalplaces)
|
|
70
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} has not the correct number of decimalplaces (${decimalplaces}).`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.STRINGLIST: {
|
|
75
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "string");
|
|
76
|
-
const choicesChecker = (v) => {
|
|
77
|
-
// has to be a single value that is
|
|
78
|
-
// 1. convertible to number
|
|
79
|
-
// 2. between 0 and choices.length -1
|
|
80
|
-
const temp = +v;
|
|
81
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
82
|
-
if (temp < 0 || temp > choices.length - 1)
|
|
83
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${v} is not within the range of the defined number choices.`);
|
|
84
|
-
};
|
|
85
|
-
if (visualization === sdk_geometry_api_sdk_v2_1.ResVisualizationType.CHECKLIST) {
|
|
86
|
-
// comma separated numbers
|
|
87
|
-
if (value.includes(",")) {
|
|
88
|
-
const values = value.split(",");
|
|
89
|
-
for (let i = 0; i < values.length; i++) {
|
|
90
|
-
if (values.filter((item) => item === values[i])
|
|
91
|
-
.length !== 1)
|
|
92
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${values[i]} exists multiple times, but should only exist once.`);
|
|
93
|
-
choicesChecker(values[i]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
// to number
|
|
98
|
-
let temp = value;
|
|
99
|
-
if (typeof value === "string")
|
|
100
|
-
temp = +value;
|
|
101
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
102
|
-
choicesChecker(value);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
// to number
|
|
107
|
-
let temp = value;
|
|
108
|
-
if (typeof value === "string")
|
|
109
|
-
temp = +value;
|
|
110
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
111
|
-
choicesChecker(value);
|
|
112
|
-
}
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
default:
|
|
116
|
-
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "string");
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
};
|
|
121
|
-
const stringify = (definition, value) => {
|
|
122
|
-
const { id, type, decimalplaces } = definition;
|
|
123
|
-
switch (true) {
|
|
124
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.BOOL:
|
|
125
|
-
return typeof value === "string"
|
|
126
|
-
? value
|
|
127
|
-
: value + "";
|
|
128
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.COLOR:
|
|
129
|
-
return Converter_1.Converter.instance.toHex8Color(value);
|
|
130
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.FILE:
|
|
131
|
-
if (typeof value !== "string")
|
|
132
|
-
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).stringify: Error in stringify. Cannot stringify FileParameter that has not been uploaded yet.`);
|
|
133
|
-
return value;
|
|
134
|
-
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN ||
|
|
135
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.FLOAT ||
|
|
136
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT ||
|
|
137
|
-
type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD:
|
|
138
|
-
if (typeof value === "string") {
|
|
139
|
-
// cast to number and round to decimalplaces if they exist
|
|
140
|
-
if (decimalplaces || decimalplaces === 0) {
|
|
141
|
-
const number = +value;
|
|
142
|
-
return number.toFixed(decimalplaces);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return value;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
// round to decimalplaces if they exist
|
|
150
|
-
if (decimalplaces || decimalplaces === 0) {
|
|
151
|
-
return value.toFixed(decimalplaces);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
return value + "";
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
default:
|
|
158
|
-
return value;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
exports.stringify = stringify;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringify = exports.isValid = void 0;
|
|
4
|
+
const sdk_geometry_api_sdk_v2_1 = require("@shapediver/sdk.geometry-api-sdk-v2");
|
|
5
|
+
const Converter_1 = require("../converter/Converter");
|
|
6
|
+
const InputValidator_1 = require("../input-validator/InputValidator");
|
|
7
|
+
const ShapeDiverViewerErrors_1 = require("../logger/ShapeDiverViewerErrors");
|
|
8
|
+
const isValid = (definition, value, throwError) => {
|
|
9
|
+
try {
|
|
10
|
+
return validateParameterValue(definition, value);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
if (throwError)
|
|
14
|
+
throw e;
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.isValid = isValid;
|
|
19
|
+
const validateParameterValue = (definition, value) => {
|
|
20
|
+
const { id, type, min, max, decimalplaces, choices, visualization } = definition;
|
|
21
|
+
switch (true) {
|
|
22
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.BOOL:
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
if (!(value === "true" || value === "false"))
|
|
25
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is a string that is neither true or false.`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "boolean");
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.COLOR:
|
|
32
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "color");
|
|
33
|
+
break;
|
|
34
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.FILE:
|
|
35
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "file");
|
|
36
|
+
break;
|
|
37
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN ||
|
|
38
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.FLOAT ||
|
|
39
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT ||
|
|
40
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD:
|
|
41
|
+
{
|
|
42
|
+
let temp = value;
|
|
43
|
+
if (typeof value === "string")
|
|
44
|
+
temp = +value;
|
|
45
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
46
|
+
if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN) {
|
|
47
|
+
if (temp % 2 !== 0)
|
|
48
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not even.`);
|
|
49
|
+
}
|
|
50
|
+
else if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD) {
|
|
51
|
+
if (temp % 2 === 0)
|
|
52
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not odd.`);
|
|
53
|
+
}
|
|
54
|
+
else if (type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT) {
|
|
55
|
+
if (!Number.isInteger(temp))
|
|
56
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is not an integer.`);
|
|
57
|
+
}
|
|
58
|
+
if (min || min === 0)
|
|
59
|
+
if (temp < min)
|
|
60
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is smaller than the minimum ${min}.`);
|
|
61
|
+
if (max || max === 0)
|
|
62
|
+
if (temp > max)
|
|
63
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} is larger than the maximum ${max}.`);
|
|
64
|
+
if (decimalplaces || decimalplaces === 0) {
|
|
65
|
+
const numStr = temp + "";
|
|
66
|
+
let decimalplaces = 0;
|
|
67
|
+
if (numStr.includes("."))
|
|
68
|
+
decimalplaces = numStr.split(".")[1].length;
|
|
69
|
+
if (decimalplaces < decimalplaces)
|
|
70
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${value} has not the correct number of decimalplaces (${decimalplaces}).`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.STRINGLIST: {
|
|
75
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "string");
|
|
76
|
+
const choicesChecker = (v) => {
|
|
77
|
+
// has to be a single value that is
|
|
78
|
+
// 1. convertible to number
|
|
79
|
+
// 2. between 0 and choices.length -1
|
|
80
|
+
const temp = +v;
|
|
81
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
82
|
+
if (temp < 0 || temp > choices.length - 1)
|
|
83
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${v} is not within the range of the defined number choices.`);
|
|
84
|
+
};
|
|
85
|
+
if (visualization === sdk_geometry_api_sdk_v2_1.ResVisualizationType.CHECKLIST) {
|
|
86
|
+
// comma separated numbers
|
|
87
|
+
if (value.includes(",")) {
|
|
88
|
+
const values = value.split(",");
|
|
89
|
+
for (let i = 0; i < values.length; i++) {
|
|
90
|
+
if (values.filter((item) => item === values[i])
|
|
91
|
+
.length !== 1)
|
|
92
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).isValid: The value ${values[i]} exists multiple times, but should only exist once.`);
|
|
93
|
+
choicesChecker(values[i]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// to number
|
|
98
|
+
let temp = value;
|
|
99
|
+
if (typeof value === "string")
|
|
100
|
+
temp = +value;
|
|
101
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
102
|
+
choicesChecker(value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// to number
|
|
107
|
+
let temp = value;
|
|
108
|
+
if (typeof value === "string")
|
|
109
|
+
temp = +value;
|
|
110
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, temp, "number");
|
|
111
|
+
choicesChecker(value);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
InputValidator_1.InputValidator.instance.validateAndError(`Parameter(${id}).isValid`, value, "string");
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
};
|
|
121
|
+
const stringify = (definition, value) => {
|
|
122
|
+
const { id, type, decimalplaces } = definition;
|
|
123
|
+
switch (true) {
|
|
124
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.BOOL:
|
|
125
|
+
return typeof value === "string"
|
|
126
|
+
? value
|
|
127
|
+
: value + "";
|
|
128
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.COLOR:
|
|
129
|
+
return Converter_1.Converter.instance.toHex8Color(value);
|
|
130
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.FILE:
|
|
131
|
+
if (typeof value !== "string")
|
|
132
|
+
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSessionError(`Parameter(${id}).stringify: Error in stringify. Cannot stringify FileParameter that has not been uploaded yet.`);
|
|
133
|
+
return value;
|
|
134
|
+
case type === sdk_geometry_api_sdk_v2_1.ResParameterType.EVEN ||
|
|
135
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.FLOAT ||
|
|
136
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.INT ||
|
|
137
|
+
type === sdk_geometry_api_sdk_v2_1.ResParameterType.ODD:
|
|
138
|
+
if (typeof value === "string") {
|
|
139
|
+
// cast to number and round to decimalplaces if they exist
|
|
140
|
+
if (decimalplaces || decimalplaces === 0) {
|
|
141
|
+
const number = +value;
|
|
142
|
+
return number.toFixed(decimalplaces);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// round to decimalplaces if they exist
|
|
150
|
+
if (decimalplaces || decimalplaces === 0) {
|
|
151
|
+
return value.toFixed(decimalplaces);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return value + "";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
default:
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
exports.stringify = stringify;
|
|
162
162
|
//# sourceMappingURL=ParameterUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParameterUtils.js","sourceRoot":"","sources":["../../src/parameter-utils/ParameterUtils.ts"],"names":[],"mappings":";;;AAAA,iFAI6C;AAC7C,sDAAiD;AACjD,sEAAiE;AACjE,6EAA8E;AAEvE,MAAM,OAAO,GAAG,CACtB,UAAwB,EACxB,KAAc,EACd,UAAoB,EACV,EAAE;IACZ,IAAI;
|
|
1
|
+
{"version":3,"file":"ParameterUtils.js","sourceRoot":"","sources":["../../src/parameter-utils/ParameterUtils.ts"],"names":[],"mappings":";;;AAAA,iFAI6C;AAC7C,sDAAiD;AACjD,sEAAiE;AACjE,6EAA8E;AAEvE,MAAM,OAAO,GAAG,CACtB,UAAwB,EACxB,KAAc,EACd,UAAoB,EACV,EAAE;IACZ,IAAI,CAAC;QACJ,OAAO,sBAAsB,CAAC,UAAU,EAAE,KA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OAAe,KAAK,CAAC;IACvB,CAAC;AACF,CAAC,CAAC;AAvCW,QAAA,SAAS,aAuCpB"}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
export declare class PerformanceEvaluator {
|
|
2
|
-
private static _instance;
|
|
3
|
-
private _eval;
|
|
4
|
-
static get instance(): PerformanceEvaluator;
|
|
5
|
-
/**
|
|
6
|
-
* Continue the performance evaluation.
|
|
7
|
-
*
|
|
8
|
-
* @param id
|
|
9
|
-
*/
|
|
10
|
-
continueSection(sectionId: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* End the performance evaluation and calculate the duration.
|
|
13
|
-
*
|
|
14
|
-
* @param id
|
|
15
|
-
*/
|
|
16
|
-
end(): void;
|
|
17
|
-
/**
|
|
18
|
-
* End the performance evaluation of a section and calculate the duration.
|
|
19
|
-
*
|
|
20
|
-
* @param id
|
|
21
|
-
*/
|
|
22
|
-
endSection(sectionId: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get the evaluation data for a specific id.
|
|
25
|
-
*
|
|
26
|
-
* @param id
|
|
27
|
-
*/
|
|
28
|
-
getEvaluation(): {
|
|
29
|
-
start: number;
|
|
30
|
-
section: {
|
|
31
|
-
[key: string]: {
|
|
32
|
-
start: number;
|
|
33
|
-
continued?: number;
|
|
34
|
-
end?: number;
|
|
35
|
-
duration?: number;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
end?: number;
|
|
39
|
-
duration?: number;
|
|
40
|
-
} | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Get the evaluation data for a specific id.
|
|
43
|
-
*
|
|
44
|
-
* @param id
|
|
45
|
-
*/
|
|
46
|
-
getEvaluationToString(): string;
|
|
47
|
-
/**
|
|
48
|
-
* Pause the performance evaluation.
|
|
49
|
-
*
|
|
50
|
-
* @param id
|
|
51
|
-
*/
|
|
52
|
-
pauseSection(sectionId: string): void;
|
|
53
|
-
/**
|
|
54
|
-
* Start the evaluation with a specific id.
|
|
55
|
-
*
|
|
56
|
-
* @param id
|
|
57
|
-
*/
|
|
58
|
-
start(time?: number): void;
|
|
59
|
-
/**
|
|
60
|
-
* Start the evaluation of a section with a specific id.
|
|
61
|
-
*
|
|
62
|
-
* @param id
|
|
63
|
-
*/
|
|
64
|
-
startSection(sectionId: string, time?: number): void;
|
|
65
|
-
}
|
|
1
|
+
export declare class PerformanceEvaluator {
|
|
2
|
+
private static _instance;
|
|
3
|
+
private _eval;
|
|
4
|
+
static get instance(): PerformanceEvaluator;
|
|
5
|
+
/**
|
|
6
|
+
* Continue the performance evaluation.
|
|
7
|
+
*
|
|
8
|
+
* @param id
|
|
9
|
+
*/
|
|
10
|
+
continueSection(sectionId: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* End the performance evaluation and calculate the duration.
|
|
13
|
+
*
|
|
14
|
+
* @param id
|
|
15
|
+
*/
|
|
16
|
+
end(): void;
|
|
17
|
+
/**
|
|
18
|
+
* End the performance evaluation of a section and calculate the duration.
|
|
19
|
+
*
|
|
20
|
+
* @param id
|
|
21
|
+
*/
|
|
22
|
+
endSection(sectionId: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the evaluation data for a specific id.
|
|
25
|
+
*
|
|
26
|
+
* @param id
|
|
27
|
+
*/
|
|
28
|
+
getEvaluation(): {
|
|
29
|
+
start: number;
|
|
30
|
+
section: {
|
|
31
|
+
[key: string]: {
|
|
32
|
+
start: number;
|
|
33
|
+
continued?: number;
|
|
34
|
+
end?: number;
|
|
35
|
+
duration?: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
end?: number;
|
|
39
|
+
duration?: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Get the evaluation data for a specific id.
|
|
43
|
+
*
|
|
44
|
+
* @param id
|
|
45
|
+
*/
|
|
46
|
+
getEvaluationToString(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Pause the performance evaluation.
|
|
49
|
+
*
|
|
50
|
+
* @param id
|
|
51
|
+
*/
|
|
52
|
+
pauseSection(sectionId: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Start the evaluation with a specific id.
|
|
55
|
+
*
|
|
56
|
+
* @param id
|
|
57
|
+
*/
|
|
58
|
+
start(time?: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Start the evaluation of a section with a specific id.
|
|
61
|
+
*
|
|
62
|
+
* @param id
|
|
63
|
+
*/
|
|
64
|
+
startSection(sectionId: string, time?: number): void;
|
|
65
|
+
}
|
|
66
66
|
//# sourceMappingURL=PerformanceEvaluator.d.ts.map
|