@shapediver/viewer.shared.services 2.7.9 → 2.8.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/converter/Converter.d.ts +8 -6
- package/dist/converter/Converter.d.ts.map +1 -1
- package/dist/converter/Converter.js +63 -61
- package/dist/converter/Converter.js.map +1 -1
- package/dist/dom-event-engine/DomEventEngine.d.ts.map +1 -1
- package/dist/dom-event-engine/DomEventEngine.js +1 -2
- package/dist/dom-event-engine/DomEventEngine.js.map +1 -1
- package/dist/event-engine/EventEngine.d.ts +6 -4
- package/dist/event-engine/EventEngine.d.ts.map +1 -1
- package/dist/event-engine/EventEngine.js +24 -32
- package/dist/event-engine/EventEngine.js.map +1 -1
- package/dist/http-client/HttpClient.d.ts +4 -3
- package/dist/http-client/HttpClient.d.ts.map +1 -1
- package/dist/http-client/HttpClient.js +28 -41
- package/dist/http-client/HttpClient.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/input-validator/InputValidator.d.ts +4 -3
- package/dist/input-validator/InputValidator.d.ts.map +1 -1
- package/dist/input-validator/InputValidator.js +20 -20
- package/dist/input-validator/InputValidator.js.map +1 -1
- package/dist/logger/Logger.d.ts +11 -37
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +79 -235
- package/dist/logger/Logger.js.map +1 -1
- package/dist/logger/ShapeDiverViewerErrors.d.ts +5 -0
- package/dist/logger/ShapeDiverViewerErrors.d.ts.map +1 -1
- package/dist/logger/ShapeDiverViewerErrors.js +9 -1
- package/dist/logger/ShapeDiverViewerErrors.js.map +1 -1
- package/dist/performance-evaluator/PerformanceEvaluator.d.ts +16 -14
- package/dist/performance-evaluator/PerformanceEvaluator.d.ts.map +1 -1
- package/dist/performance-evaluator/PerformanceEvaluator.js +37 -40
- package/dist/performance-evaluator/PerformanceEvaluator.js.map +1 -1
- package/dist/settings-engine/SettingsEngine.d.ts.map +1 -1
- package/dist/settings-engine/SettingsEngine.js +3 -5
- package/dist/settings-engine/SettingsEngine.js.map +1 -1
- package/dist/state-engine/StateEngine.d.ts +11 -11
- package/dist/state-engine/StateEngine.d.ts.map +1 -1
- package/dist/state-engine/StateEngine.js +15 -26
- package/dist/state-engine/StateEngine.js.map +1 -1
- package/dist/system-info/SystemInfo.d.ts +21 -19
- package/dist/system-info/SystemInfo.d.ts.map +1 -1
- package/dist/system-info/SystemInfo.js +45 -61
- package/dist/system-info/SystemInfo.js.map +1 -1
- package/dist/type-check/TypeChecker.d.ts +3 -1
- package/dist/type-check/TypeChecker.d.ts.map +1 -1
- package/dist/type-check/TypeChecker.js +11 -14
- package/dist/type-check/TypeChecker.js.map +1 -1
- package/dist/uuid-generator/UuidGenerator.d.ts +8 -6
- package/dist/uuid-generator/UuidGenerator.d.ts.map +1 -1
- package/dist/uuid-generator/UuidGenerator.js +17 -24
- package/dist/uuid-generator/UuidGenerator.js.map +1 -1
- package/package.json +5 -8
- package/src/converter/Converter.ts +67 -47
- package/src/dom-event-engine/DomEventEngine.ts +1 -2
- package/src/event-engine/EventEngine.ts +34 -22
- package/src/http-client/HttpClient.ts +35 -32
- package/src/index.ts +4 -3
- package/src/input-validator/InputValidator.ts +29 -11
- package/src/logger/Logger.ts +60 -183
- package/src/logger/ShapeDiverViewerErrors.ts +9 -0
- package/src/performance-evaluator/PerformanceEvaluator.ts +45 -31
- package/src/settings-engine/SettingsEngine.ts +4 -6
- package/src/state-engine/StateEngine.ts +32 -30
- package/src/system-info/SystemInfo.ts +66 -47
- package/src/type-check/TypeChecker.ts +19 -5
- package/src/uuid-generator/UuidGenerator.ts +30 -14
package/src/logger/Logger.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/browser'
|
|
2
|
-
import { container, singleton } from 'tsyringe'
|
|
3
|
-
import { build_data } from '@shapediver/viewer.shared.build-data'
|
|
4
|
-
import { ShapeDiverError as ShapeDiverBackendError } from '@shapediver/sdk.geometry-api-sdk-core'
|
|
5
|
-
|
|
6
|
-
import { UuidGenerator } from '../uuid-generator/UuidGenerator'
|
|
7
|
-
import { BrowserClient, Hub } from '@sentry/browser'
|
|
8
|
-
import { ShapeDiverViewerConnectionError, ShapeDiverViewerUnknownError } from './ShapeDiverViewerErrors'
|
|
9
|
-
import { ShapeDiverRequestError, ShapeDiverResponseError, ShapeDiverResponseErrorType } from '@shapediver/sdk.geometry-api-sdk-v2'
|
|
10
|
-
import { ShapeDiverViewerError } from './ShapeDiverError'
|
|
11
|
-
|
|
12
1
|
export enum LOGGING_LEVEL {
|
|
13
2
|
NONE = 'none',
|
|
14
3
|
ERROR = 'error',
|
|
@@ -21,64 +10,24 @@ export enum LOGGING_LEVEL {
|
|
|
21
10
|
DEBUG_LOW = 'debug_low',
|
|
22
11
|
}
|
|
23
12
|
|
|
24
|
-
export enum LOGGING_TOPIC {
|
|
25
|
-
AR = 'ar',
|
|
26
|
-
GENERAL = 'general',
|
|
27
|
-
EXPORT = 'export',
|
|
28
|
-
PARAMETER = 'parameter',
|
|
29
|
-
OUTPUT = 'output',
|
|
30
|
-
SESSION = 'session',
|
|
31
|
-
VIEWPORT = 'viewer',
|
|
32
|
-
CAMERA = 'camera',
|
|
33
|
-
LIGHT = 'light',
|
|
34
|
-
CAMERA_CONTROL = 'camera_control',
|
|
35
|
-
DATA_PROCESSING = 'data_processing',
|
|
36
|
-
SDTF = 'sdtf',
|
|
37
|
-
THREE = 'three',
|
|
38
|
-
SETTINGS = 'settings',
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@singleton()
|
|
42
13
|
export class Logger {
|
|
43
|
-
// #region Properties (
|
|
14
|
+
// #region Properties (8)
|
|
15
|
+
|
|
16
|
+
private static _instance: Logger;
|
|
44
17
|
|
|
45
18
|
private _loggingLevel: LOGGING_LEVEL = LOGGING_LEVEL.WARN;
|
|
46
19
|
private _showMessages: boolean = true;
|
|
47
|
-
private _breadCrumbs: Sentry.Breadcrumb[] = [];
|
|
48
|
-
private _breadCrumbCounter: number = 0;
|
|
49
|
-
private _sentryHub: Hub;
|
|
50
|
-
private _uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
|
|
51
|
-
private _userId = this._uuidGenerator.create();
|
|
52
|
-
|
|
53
|
-
// #endregion Properties (2)
|
|
54
20
|
|
|
55
|
-
|
|
56
|
-
const client = new BrowserClient({
|
|
57
|
-
dsn: "https://0510990697b04b9da3ad07868e94e378@o363881.ingest.sentry.io/5828729",
|
|
58
|
-
environment: 'local',
|
|
59
|
-
release: build_data.build_version,
|
|
60
|
-
maxBreadcrumbs: 100,
|
|
61
|
-
beforeBreadcrumb: (breadcrumb: Sentry.Breadcrumb, hint?: Sentry.BreadcrumbHint | undefined): Sentry.Breadcrumb | null => {
|
|
62
|
-
this._breadCrumbCounter++;
|
|
63
|
-
return breadcrumb;
|
|
64
|
-
},
|
|
65
|
-
beforeSend: (event: Sentry.Event, hint?: Sentry.EventHint | undefined): Sentry.Event | PromiseLike<Sentry.Event | null> | null => {
|
|
66
|
-
if (event.level === Sentry.Severity.Debug) event.fingerprint ? event.fingerprint.push(this._userId + '') : event.fingerprint = [this._userId + ''];
|
|
67
|
-
return event;
|
|
68
|
-
},
|
|
69
|
-
// Set tracesSampleRate to 1.0 to capture 100%
|
|
70
|
-
// of transactions for performance monitoring.
|
|
71
|
-
// We recommend adjusting this value in production
|
|
72
|
-
tracesSampleRate: 1.0
|
|
73
|
-
});
|
|
21
|
+
// #endregion Properties (8)
|
|
74
22
|
|
|
75
|
-
|
|
23
|
+
// #region Public Static Accessors (1)
|
|
76
24
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
})
|
|
25
|
+
public static get instance() {
|
|
26
|
+
return this._instance || (this._instance = new this());
|
|
80
27
|
}
|
|
81
28
|
|
|
29
|
+
// #endregion Public Static Accessors (1)
|
|
30
|
+
|
|
82
31
|
// #region Public Accessors (4)
|
|
83
32
|
|
|
84
33
|
public get loggingLevel(): LOGGING_LEVEL {
|
|
@@ -97,118 +46,15 @@ export class Logger {
|
|
|
97
46
|
this._showMessages = value;
|
|
98
47
|
}
|
|
99
48
|
|
|
100
|
-
private canLog(loggingLevel: LOGGING_LEVEL): boolean {
|
|
101
|
-
switch (this.loggingLevel) {
|
|
102
|
-
case LOGGING_LEVEL.ERROR:
|
|
103
|
-
if (loggingLevel === LOGGING_LEVEL.FATAL) return false;
|
|
104
|
-
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
|
|
105
|
-
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
106
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
107
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
108
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
109
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
110
|
-
case LOGGING_LEVEL.FATAL:
|
|
111
|
-
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
|
|
112
|
-
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
113
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
114
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
115
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
116
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
117
|
-
case LOGGING_LEVEL.WARN:
|
|
118
|
-
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
119
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
120
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
121
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
122
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
123
|
-
case LOGGING_LEVEL.INFO:
|
|
124
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
125
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
126
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
127
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
128
|
-
case LOGGING_LEVEL.DEBUG_HIGH:
|
|
129
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
130
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
131
|
-
case LOGGING_LEVEL.DEBUG_MEDIUM:
|
|
132
|
-
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
133
|
-
case LOGGING_LEVEL.DEBUG_LOW:
|
|
134
|
-
case LOGGING_LEVEL.DEBUG:
|
|
135
|
-
default:
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
49
|
// #endregion Public Accessors (4)
|
|
141
50
|
|
|
142
|
-
// #region Public Methods (
|
|
143
|
-
|
|
144
|
-
public handleError(topic: LOGGING_TOPIC, scope: string, e: ShapeDiverBackendError | ShapeDiverViewerError | Error | unknown, logToSentry = true) {
|
|
145
|
-
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
|
|
146
|
-
//console.error('(ERROR) ', e);
|
|
147
|
-
if(e instanceof ShapeDiverRequestError) {
|
|
148
|
-
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
|
|
149
|
-
if(logToSentry) this.sentryError(topic, e, messageProperty);
|
|
150
|
-
throw e;
|
|
151
|
-
} else if(e instanceof ShapeDiverResponseError && e.error === ShapeDiverResponseErrorType.UNKNOWN) {
|
|
152
|
-
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
|
|
153
|
-
if(logToSentry) this.sentryError(topic, e, messageProperty);
|
|
154
|
-
throw e;
|
|
155
|
-
} else if(e instanceof ShapeDiverResponseError) {
|
|
156
|
-
throw e;
|
|
157
|
-
} else if (e instanceof ShapeDiverViewerError) {
|
|
158
|
-
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
|
|
159
|
-
if(logToSentry) {
|
|
160
|
-
if(!(e instanceof ShapeDiverViewerConnectionError) || (e.status && e.status >= 500)) {
|
|
161
|
-
this.sentryError(topic, e, messageProperty);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
throw e;
|
|
165
|
-
} else if(e) {
|
|
166
|
-
const error = <any>e;
|
|
167
|
-
const messageProperty = error.message ? error.message : `An unknown issue occurred in ${scope}.`;
|
|
168
|
-
const viewerError = new ShapeDiverViewerUnknownError(messageProperty, error);
|
|
169
|
-
if(logToSentry) this.sentryError(topic, viewerError, messageProperty);
|
|
170
|
-
throw viewerError;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
public sentryError(topic: LOGGING_TOPIC, error: ShapeDiverBackendError | ShapeDiverViewerError | Error, msg?: string) {
|
|
175
|
-
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
|
|
176
|
-
|
|
177
|
-
const breadcrumbCounter = this._breadCrumbCounter > 100 ? 100 : this._breadCrumbCounter;
|
|
178
|
-
for(let i = breadcrumbCounter; i < this._breadCrumbs.length + breadcrumbCounter; i++) {
|
|
179
|
-
if(i%100 === 0 && i !== 0) {
|
|
180
|
-
this._sentryHub.setTag('topic', topic);
|
|
181
|
-
this._sentryHub.setUser({ id: this._userId })
|
|
182
|
-
this._sentryHub.captureMessage('Breadcrumb Issue ' + (i/100 - 1) + ' (' + this._userId + ')', Sentry.Severity.Debug);
|
|
183
|
-
this._sentryHub.getScope()?.clear()
|
|
184
|
-
}
|
|
185
|
-
this._sentryHub.addBreadcrumb(this._breadCrumbs[i-breadcrumbCounter]);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
this._sentryHub.setTag('topic', topic);
|
|
189
|
-
this._sentryHub.setUser({ id: this._userId })
|
|
190
|
-
|
|
191
|
-
if(error instanceof ShapeDiverBackendError || error instanceof ShapeDiverViewerError) {
|
|
192
|
-
this._sentryHub.captureMessage(error.message, Sentry.Severity.Error);
|
|
193
|
-
} else {
|
|
194
|
-
this._sentryHub.captureException(error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public sentryBreadcrumb(topic: LOGGING_TOPIC, msg: string, level: Sentry.Severity) {
|
|
199
|
-
this._breadCrumbs.push({
|
|
200
|
-
category: topic,
|
|
201
|
-
message: msg,
|
|
202
|
-
level: Sentry.Severity.Debug,
|
|
203
|
-
timestamp: Math.floor(new Date().getTime() / 1000)
|
|
204
|
-
})
|
|
205
|
-
}
|
|
51
|
+
// #region Public Methods (11)
|
|
206
52
|
|
|
207
53
|
/**
|
|
208
54
|
* Logging a debug message.
|
|
209
55
|
* @param msg the message
|
|
210
56
|
*/
|
|
211
|
-
public debug(
|
|
57
|
+
public debug(msg: string): void {
|
|
212
58
|
if (this.canLog(LOGGING_LEVEL.DEBUG) && this.showMessages === true)
|
|
213
59
|
console.debug('(DEBUG) ' + this.messageConstruction(msg));
|
|
214
60
|
}
|
|
@@ -217,7 +63,7 @@ export class Logger {
|
|
|
217
63
|
* Logging a debug message with high priority.
|
|
218
64
|
* @param msg the message
|
|
219
65
|
*/
|
|
220
|
-
public debugHigh(
|
|
66
|
+
public debugHigh(msg: string): void {
|
|
221
67
|
if (this.canLog(LOGGING_LEVEL.DEBUG_HIGH) && this.showMessages === true)
|
|
222
68
|
console.debug('(DEBUG_HIGH) ' + this.messageConstruction(msg));
|
|
223
69
|
}
|
|
@@ -226,7 +72,7 @@ export class Logger {
|
|
|
226
72
|
* Logging a debug message with low priority.
|
|
227
73
|
* @param msg the message
|
|
228
74
|
*/
|
|
229
|
-
public debugLow(
|
|
75
|
+
public debugLow(msg: string): void {
|
|
230
76
|
if (this.canLog(LOGGING_LEVEL.DEBUG_LOW) && this.showMessages === true)
|
|
231
77
|
console.debug('(DEBUG_LOW) ' + this.messageConstruction(msg));
|
|
232
78
|
}
|
|
@@ -235,7 +81,7 @@ export class Logger {
|
|
|
235
81
|
* Logging a debug message with medium priority.
|
|
236
82
|
* @param msg the message
|
|
237
83
|
*/
|
|
238
|
-
public debugMedium(
|
|
84
|
+
public debugMedium(msg: string): void {
|
|
239
85
|
if (this.canLog(LOGGING_LEVEL.DEBUG_MEDIUM) && this.showMessages === true)
|
|
240
86
|
console.debug('(DEBUG_MEDIUM) ' + this.messageConstruction(msg));
|
|
241
87
|
}
|
|
@@ -244,33 +90,25 @@ export class Logger {
|
|
|
244
90
|
* Logging an error.
|
|
245
91
|
* @param msg the message
|
|
246
92
|
*/
|
|
247
|
-
public error(
|
|
248
|
-
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
|
|
249
|
-
if(notifySentry)
|
|
250
|
-
this.sentryError(topic, error, msg);
|
|
93
|
+
public error(msg: string): void {
|
|
251
94
|
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
|
|
252
|
-
console.error('(ERROR) ' + this.messageConstruction(msg
|
|
253
|
-
if(throwError) throw error;
|
|
95
|
+
console.error('(ERROR) ' + this.messageConstruction(msg));
|
|
254
96
|
}
|
|
255
97
|
|
|
256
98
|
/**
|
|
257
99
|
* Logging a fatal error.
|
|
258
100
|
* @param msg the message
|
|
259
101
|
*/
|
|
260
|
-
public fatal(
|
|
261
|
-
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Fatal);
|
|
262
|
-
this.sentryError(topic, error, msg);
|
|
102
|
+
public fatal(msg: string): void {
|
|
263
103
|
if (this.canLog(LOGGING_LEVEL.FATAL) && this.showMessages === true)
|
|
264
104
|
console.error('(FATAL) ' + this.messageConstruction(msg));
|
|
265
|
-
if(throwError) throw error;
|
|
266
105
|
}
|
|
267
106
|
|
|
268
107
|
/**
|
|
269
108
|
* Logging an info.
|
|
270
109
|
* @param msg the message
|
|
271
110
|
*/
|
|
272
|
-
public info(
|
|
273
|
-
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Info);
|
|
111
|
+
public info(msg: string): void {
|
|
274
112
|
if (this.canLog(LOGGING_LEVEL.INFO) && this.showMessages === true)
|
|
275
113
|
console.info('(INFO) ' + this.messageConstruction(msg));
|
|
276
114
|
}
|
|
@@ -279,16 +117,55 @@ export class Logger {
|
|
|
279
117
|
* Logging a warning.
|
|
280
118
|
* @param msg the message
|
|
281
119
|
*/
|
|
282
|
-
public warn(
|
|
283
|
-
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Warning);
|
|
120
|
+
public warn(msg: string): void {
|
|
284
121
|
if (this.canLog(LOGGING_LEVEL.WARN) && this.showMessages === true)
|
|
285
122
|
console.warn('(WARN) ' + this.messageConstruction(msg));
|
|
286
123
|
}
|
|
287
124
|
|
|
288
|
-
// #endregion Public Methods (
|
|
125
|
+
// #endregion Public Methods (11)
|
|
289
126
|
|
|
290
127
|
// #region Private Methods (2)
|
|
291
128
|
|
|
129
|
+
private canLog(loggingLevel: LOGGING_LEVEL): boolean {
|
|
130
|
+
switch (this.loggingLevel) {
|
|
131
|
+
case LOGGING_LEVEL.ERROR:
|
|
132
|
+
if (loggingLevel === LOGGING_LEVEL.FATAL) return false;
|
|
133
|
+
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
|
|
134
|
+
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
135
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
136
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
137
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
138
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
139
|
+
case LOGGING_LEVEL.FATAL:
|
|
140
|
+
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
|
|
141
|
+
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
142
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
143
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
144
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
145
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
146
|
+
case LOGGING_LEVEL.WARN:
|
|
147
|
+
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
|
|
148
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
149
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
150
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
151
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
152
|
+
case LOGGING_LEVEL.INFO:
|
|
153
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
|
|
154
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
|
|
155
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
156
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
157
|
+
case LOGGING_LEVEL.DEBUG_HIGH:
|
|
158
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
|
|
159
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
160
|
+
case LOGGING_LEVEL.DEBUG_MEDIUM:
|
|
161
|
+
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
|
|
162
|
+
case LOGGING_LEVEL.DEBUG_LOW:
|
|
163
|
+
case LOGGING_LEVEL.DEBUG:
|
|
164
|
+
default:
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
292
169
|
private messageConstruction(msg: string): string {
|
|
293
170
|
return new Date().toISOString() + ': ' + msg;
|
|
294
171
|
}
|
|
@@ -57,6 +57,15 @@ export class ShapeDiverViewerSessionError extends ShapeDiverViewerError {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export class ShapeDiverViewerViewportError extends ShapeDiverViewerError {
|
|
61
|
+
constructor(
|
|
62
|
+
public readonly message: string,
|
|
63
|
+
public readonly errorObject?: Error | unknown
|
|
64
|
+
) {
|
|
65
|
+
super(ShapeDiverViewerErrorType.SESSION_ERROR, 'An error occurred while working with the viewport.', message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
export class ShapeDiverViewerLightError extends ShapeDiverViewerError {
|
|
61
70
|
constructor(
|
|
62
71
|
public readonly message: string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { singleton } from 'tsyringe'
|
|
2
|
-
|
|
3
|
-
@singleton()
|
|
4
1
|
export class PerformanceEvaluator {
|
|
2
|
+
// #region Properties (2)
|
|
3
|
+
|
|
4
|
+
private static _instance: PerformanceEvaluator;
|
|
5
5
|
|
|
6
6
|
private _eval: {
|
|
7
7
|
start: number;
|
|
@@ -16,29 +16,29 @@ export class PerformanceEvaluator {
|
|
|
16
16
|
duration?: number;
|
|
17
17
|
} | undefined;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this._eval = {
|
|
26
|
-
start: time || performance.now(),
|
|
27
|
-
section: {}
|
|
28
|
-
}
|
|
19
|
+
// #endregion Properties (2)
|
|
20
|
+
|
|
21
|
+
// #region Public Static Accessors (1)
|
|
22
|
+
|
|
23
|
+
public static get instance() {
|
|
24
|
+
return this._instance || (this._instance = new this());
|
|
29
25
|
}
|
|
30
26
|
|
|
27
|
+
// #endregion Public Static Accessors (1)
|
|
28
|
+
|
|
29
|
+
// #region Public Methods (6)
|
|
30
|
+
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* End the performance evaluation and calculate the duration.
|
|
33
33
|
*
|
|
34
34
|
* @param id
|
|
35
35
|
*/
|
|
36
|
-
public
|
|
36
|
+
public end(): void {
|
|
37
37
|
if (!this._eval) return;
|
|
38
38
|
if (this._eval.end) return;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
|
|
40
|
+
this._eval.end = performance.now();
|
|
41
|
+
this._eval.duration = this._eval.end! - this._eval.start;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -57,19 +57,6 @@ export class PerformanceEvaluator {
|
|
|
57
57
|
this._eval.section[sectionId].duration = this._eval.section[sectionId].end! - this._eval.section[sectionId].start;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
* End the performance evaluation and calculate the duration.
|
|
62
|
-
*
|
|
63
|
-
* @param id
|
|
64
|
-
*/
|
|
65
|
-
public end(): void {
|
|
66
|
-
if (!this._eval) return;
|
|
67
|
-
if (this._eval.end) return;
|
|
68
|
-
|
|
69
|
-
this._eval.end = performance.now();
|
|
70
|
-
this._eval.duration = this._eval.end! - this._eval.start;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
60
|
/**
|
|
74
61
|
* Get the evaluation data for a specific id.
|
|
75
62
|
*
|
|
@@ -99,4 +86,31 @@ export class PerformanceEvaluator {
|
|
|
99
86
|
const e = this._eval;
|
|
100
87
|
return `Performance Evaluation: ${e!.duration}ms\n`;
|
|
101
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Start the evaluation with a specific id.
|
|
92
|
+
*
|
|
93
|
+
* @param id
|
|
94
|
+
*/
|
|
95
|
+
public start(time?: number): void {
|
|
96
|
+
this._eval = {
|
|
97
|
+
start: time || performance.now(),
|
|
98
|
+
section: {}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Start the evaluation of a section with a specific id.
|
|
104
|
+
*
|
|
105
|
+
* @param id
|
|
106
|
+
*/
|
|
107
|
+
public startSection(sectionId: string, time?: number): void {
|
|
108
|
+
if (!this._eval) return;
|
|
109
|
+
if (this._eval.end) return;
|
|
110
|
+
this._eval.section[sectionId] = {
|
|
111
|
+
start: time || performance.now(),
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// #endregion Public Methods (6)
|
|
102
116
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { convert, validate, DefaultsV3_3 as Defaults, ISettingsV3_3 as ISettings, versions, latestVersion } from '@shapediver/viewer.settings';
|
|
2
|
-
import { container, singleton } from 'tsyringe'
|
|
3
2
|
|
|
4
3
|
import { EventEngine } from '../event-engine/EventEngine'
|
|
5
|
-
import { Logger
|
|
4
|
+
import { Logger } from '../logger/Logger';
|
|
6
5
|
import { ShapeDiverViewerSettingsError } from '../logger/ShapeDiverViewerErrors';
|
|
7
6
|
|
|
8
7
|
type IARSettings = ISettings["ar"];
|
|
@@ -17,8 +16,8 @@ type ISessionSettings = ISettings["session"];
|
|
|
17
16
|
export class SettingsEngine {
|
|
18
17
|
// #region Properties (8)
|
|
19
18
|
|
|
20
|
-
private readonly _eventEngine: EventEngine =
|
|
21
|
-
private readonly _logger: Logger =
|
|
19
|
+
private readonly _eventEngine: EventEngine = EventEngine.instance;
|
|
20
|
+
private readonly _logger: Logger = Logger.instance;
|
|
22
21
|
private readonly _settings: ISettings = Defaults();
|
|
23
22
|
private _settingsJson: any;
|
|
24
23
|
private _settings_version: versions = latestVersion;
|
|
@@ -123,8 +122,7 @@ export class SettingsEngine {
|
|
|
123
122
|
this.cleanSettings(this._settings);
|
|
124
123
|
return;
|
|
125
124
|
} catch (e) {
|
|
126
|
-
|
|
127
|
-
throw this._logger.handleError(LOGGING_TOPIC.SETTINGS, `SettingsEngine.loadSettings`, error);
|
|
125
|
+
throw new ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + (<Error>e).message, <Error>e);
|
|
128
126
|
}
|
|
129
127
|
} else {
|
|
130
128
|
this._settings_version = latestVersion;
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import { container, singleton } from 'tsyringe'
|
|
2
|
-
|
|
3
|
-
import { EventEngine } from '../index'
|
|
4
1
|
import { StatePromise } from './StatePromise'
|
|
5
2
|
|
|
6
|
-
@singleton()
|
|
7
3
|
export class StateEngine {
|
|
8
|
-
// #region Properties (
|
|
4
|
+
// #region Properties (6)
|
|
9
5
|
|
|
10
|
-
private readonly
|
|
11
|
-
[key: string]: StatePromise<boolean>
|
|
12
|
-
} = {};
|
|
13
|
-
private readonly _eventEngine: EventEngine = <EventEngine>container.resolve(EventEngine);
|
|
14
|
-
private readonly _fontLoaded: StatePromise<boolean>;
|
|
15
|
-
private readonly _sessionEngines: {
|
|
16
|
-
[key: string]: {
|
|
17
|
-
id: string,
|
|
18
|
-
initialized: StatePromise<boolean>,
|
|
19
|
-
settingsRegistered: StatePromise<boolean>,
|
|
20
|
-
}
|
|
21
|
-
} = {};
|
|
6
|
+
private readonly _fontLoaded: StatePromise<boolean> = new StatePromise();
|
|
22
7
|
private readonly _renderingEngines: {
|
|
23
8
|
[key: string]: {
|
|
24
9
|
id: string,
|
|
@@ -29,45 +14,62 @@ export class StateEngine {
|
|
|
29
14
|
busy: string[]
|
|
30
15
|
}
|
|
31
16
|
} = {};
|
|
17
|
+
private readonly _sessionEngines: {
|
|
18
|
+
[key: string]: {
|
|
19
|
+
id: string,
|
|
20
|
+
initialized: StatePromise<boolean>,
|
|
21
|
+
settingsRegistered: StatePromise<boolean>,
|
|
22
|
+
}
|
|
23
|
+
} = {};
|
|
24
|
+
|
|
25
|
+
private static _instance: StateEngine;
|
|
32
26
|
|
|
33
|
-
// #endregion Properties (
|
|
27
|
+
// #endregion Properties (6)
|
|
34
28
|
|
|
35
29
|
// #region Constructors (1)
|
|
36
30
|
|
|
37
|
-
constructor() {
|
|
31
|
+
private constructor() {
|
|
38
32
|
this._fontLoaded = new StatePromise();
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
// #endregion Constructors (1)
|
|
42
36
|
|
|
43
|
-
// #region Public Accessors (
|
|
37
|
+
// #region Public Static Accessors (1)
|
|
38
|
+
|
|
39
|
+
public static get instance() {
|
|
40
|
+
return this._instance || (this._instance = new this());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// #endregion Public Static Accessors (1)
|
|
44
|
+
|
|
45
|
+
// #region Public Accessors (3)
|
|
44
46
|
|
|
45
47
|
public get fontLoaded(): StatePromise<boolean> {
|
|
46
48
|
return this._fontLoaded;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
public get
|
|
51
|
+
public get renderingEngines(): {
|
|
50
52
|
[key: string]: {
|
|
51
53
|
id: string,
|
|
52
54
|
initialized: StatePromise<boolean>,
|
|
53
|
-
|
|
55
|
+
settingsAssigned: StatePromise<boolean>,
|
|
56
|
+
environmentMapLoaded: StatePromise<boolean>,
|
|
57
|
+
boundingBoxCreated: StatePromise<boolean>,
|
|
58
|
+
busy: string[]
|
|
54
59
|
}
|
|
55
60
|
} {
|
|
56
|
-
return this.
|
|
61
|
+
return this._renderingEngines;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
public get
|
|
64
|
+
public get sessionEngines(): {
|
|
60
65
|
[key: string]: {
|
|
61
66
|
id: string,
|
|
62
67
|
initialized: StatePromise<boolean>,
|
|
63
|
-
|
|
64
|
-
environmentMapLoaded: StatePromise<boolean>,
|
|
65
|
-
boundingBoxCreated: StatePromise<boolean>,
|
|
66
|
-
busy: string[]
|
|
68
|
+
settingsRegistered: StatePromise<boolean>,
|
|
67
69
|
}
|
|
68
70
|
} {
|
|
69
|
-
return this.
|
|
71
|
+
return this._sessionEngines;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
// #endregion Public Accessors (
|
|
74
|
+
// #endregion Public Accessors (3)
|
|
73
75
|
}
|