@shapediver/viewer.session-engine.session-engine 2.10.1-rc.0 → 2.11.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/OutputDelayException.js +5 -1
- package/dist/implementation/OutputDelayException.js.map +1 -1
- package/dist/implementation/OutputLoader.js +30 -26
- package/dist/implementation/OutputLoader.js.map +1 -1
- package/dist/implementation/SessionData.js +6 -2
- package/dist/implementation/SessionData.js.map +1 -1
- package/dist/implementation/SessionEngine.d.ts +13 -11
- package/dist/implementation/SessionEngine.d.ts.map +1 -1
- package/dist/implementation/SessionEngine.js +265 -236
- package/dist/implementation/SessionEngine.js.map +1 -1
- package/dist/implementation/SessionOutputData.js +6 -2
- package/dist/implementation/SessionOutputData.js.map +1 -1
- package/dist/implementation/SessionTreeNode.js +6 -2
- package/dist/implementation/SessionTreeNode.js.map +1 -1
- package/dist/implementation/dto/Export.js +17 -13
- package/dist/implementation/dto/Export.js.map +1 -1
- package/dist/implementation/dto/FileParameter.js +34 -7
- package/dist/implementation/dto/FileParameter.js.map +1 -1
- package/dist/implementation/dto/Output.d.ts +6 -6
- package/dist/implementation/dto/Output.d.ts.map +1 -1
- package/dist/implementation/dto/Output.js +19 -14
- package/dist/implementation/dto/Output.js.map +1 -1
- package/dist/implementation/dto/Parameter.js +60 -33
- package/dist/implementation/dto/Parameter.js.map +1 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ISessionData.js +2 -1
- package/dist/interfaces/ISessionEngine.d.ts +6 -7
- package/dist/interfaces/ISessionEngine.d.ts.map +1 -1
- package/dist/interfaces/ISessionEngine.js +7 -5
- package/dist/interfaces/ISessionEngine.js.map +1 -1
- package/dist/interfaces/ISessionOutputData.js +2 -1
- package/dist/interfaces/ISessionTreeNode.js +2 -1
- package/dist/interfaces/dto/IExport.js +2 -1
- package/dist/interfaces/dto/IFileParameter.js +2 -1
- package/dist/interfaces/dto/IOutput.d.ts +1 -1
- package/dist/interfaces/dto/IOutput.d.ts.map +1 -1
- package/dist/interfaces/dto/IOutput.js +2 -1
- package/dist/interfaces/dto/IParameter.js +2 -1
- package/package.json +9 -9
- package/src/implementation/SessionEngine.ts +469 -406
- package/src/implementation/dto/Output.ts +16 -15
- package/src/interfaces/ISessionEngine.ts +49 -43
- package/src/interfaces/dto/IOutput.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,21 +20,24 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
19
20
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
20
21
|
};
|
|
21
22
|
var _SessionEngine_customizationProcess, _SessionEngine_parameterHistory, _SessionEngine_parameterHistoryCall, _SessionEngine_parameterHistoryForward;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SessionEngine = void 0;
|
|
25
|
+
const viewer_settings_1 = require("@shapediver/viewer.settings");
|
|
26
|
+
const sdk_geometry_api_sdk_v2_1 = require("@shapediver/sdk.geometry-api-sdk-v2");
|
|
27
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
28
|
+
const Export_1 = require("./dto/Export");
|
|
29
|
+
const FileParameter_1 = require("./dto/FileParameter");
|
|
30
|
+
const ISessionEngine_1 = require("../interfaces/ISessionEngine");
|
|
31
|
+
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
32
|
+
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
33
|
+
const Output_1 = require("./dto/Output");
|
|
34
|
+
const OutputDelayException_1 = require("./OutputDelayException");
|
|
35
|
+
const OutputLoader_1 = require("./OutputLoader");
|
|
36
|
+
const Parameter_1 = require("./dto/Parameter");
|
|
37
|
+
const SessionData_1 = require("./SessionData");
|
|
38
|
+
const SessionTreeNode_1 = require("./SessionTreeNode");
|
|
39
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
40
|
+
class SessionEngine {
|
|
37
41
|
// #endregion Properties (43)
|
|
38
42
|
// #region Constructors (1)
|
|
39
43
|
/**
|
|
@@ -42,20 +46,20 @@ export class SessionEngine {
|
|
|
42
46
|
*/
|
|
43
47
|
constructor(properties) {
|
|
44
48
|
// #region Properties (43)
|
|
45
|
-
this._eventEngine = EventEngine.instance;
|
|
49
|
+
this._eventEngine = viewer_shared_services_1.EventEngine.instance;
|
|
46
50
|
this._exports = {};
|
|
47
|
-
this._httpClient = HttpClient.instance;
|
|
48
|
-
this._logger = Logger.instance;
|
|
51
|
+
this._httpClient = viewer_shared_services_1.HttpClient.instance;
|
|
52
|
+
this._logger = viewer_shared_services_1.Logger.instance;
|
|
49
53
|
this._outputs = {};
|
|
50
54
|
this._outputsFreeze = {};
|
|
51
55
|
this._parameterValues = {};
|
|
52
56
|
this._parameters = {};
|
|
53
|
-
this._performanceEvaluator = PerformanceEvaluator.instance;
|
|
54
|
-
this._sceneTree = Tree.instance;
|
|
55
|
-
this._sessionEngineId = (UuidGenerator.instance).create();
|
|
56
|
-
this._settingsEngine = new SettingsEngine();
|
|
57
|
-
this._stateEngine = StateEngine.instance;
|
|
58
|
-
this._uuidGenerator = UuidGenerator.instance;
|
|
57
|
+
this._performanceEvaluator = viewer_shared_services_1.PerformanceEvaluator.instance;
|
|
58
|
+
this._sceneTree = viewer_shared_node_tree_1.Tree.instance;
|
|
59
|
+
this._sessionEngineId = (viewer_shared_services_1.UuidGenerator.instance).create();
|
|
60
|
+
this._settingsEngine = new viewer_shared_services_1.SettingsEngine();
|
|
61
|
+
this._stateEngine = viewer_shared_services_1.StateEngine.instance;
|
|
62
|
+
this._uuidGenerator = viewer_shared_services_1.UuidGenerator.instance;
|
|
59
63
|
_SessionEngine_customizationProcess.set(this, void 0);
|
|
60
64
|
_SessionEngine_parameterHistory.set(this, []);
|
|
61
65
|
_SessionEngine_parameterHistoryCall.set(this, false);
|
|
@@ -67,18 +71,18 @@ export class SessionEngine {
|
|
|
67
71
|
this._dataCache = {};
|
|
68
72
|
this._excludeViewports = [];
|
|
69
73
|
this._headers = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
'X-ShapeDiver-Origin': (viewer_shared_services_1.SystemInfo.instance).origin,
|
|
75
|
+
'X-ShapeDiver-SessionEngineId': this._sessionEngineId,
|
|
76
|
+
'X-ShapeDiver-BuildVersion': '',
|
|
77
|
+
'X-ShapeDiver-BuildDate': ''
|
|
74
78
|
};
|
|
75
79
|
this._initialized = false;
|
|
76
80
|
this._retryCounter = 0;
|
|
77
81
|
this._updateCallback = null;
|
|
78
|
-
this._viewerSettingsVersion = latestVersion;
|
|
79
|
-
this._viewerSettingsVersionBackend = latestVersion;
|
|
82
|
+
this._viewerSettingsVersion = viewer_settings_1.latestVersion;
|
|
83
|
+
this._viewerSettingsVersionBackend = viewer_settings_1.latestVersion;
|
|
80
84
|
this._id = properties.id;
|
|
81
|
-
this._node = new TreeNode(properties.id);
|
|
85
|
+
this._node = new viewer_shared_node_tree_1.TreeNode(properties.id);
|
|
82
86
|
this._guid = properties.guid;
|
|
83
87
|
this._ticket = properties.ticket;
|
|
84
88
|
this._modelViewUrl = properties.modelViewUrl;
|
|
@@ -86,17 +90,17 @@ export class SessionEngine {
|
|
|
86
90
|
this._jwtToken = properties.jwtToken;
|
|
87
91
|
this._headers['X-ShapeDiver-BuildDate'] = properties.buildDate;
|
|
88
92
|
this._headers['X-ShapeDiver-BuildVersion'] = properties.buildVersion;
|
|
89
|
-
this._outputLoader = new OutputLoader(this);
|
|
93
|
+
this._outputLoader = new OutputLoader_1.OutputLoader(this);
|
|
90
94
|
try {
|
|
91
|
-
this._sdk = create(this._modelViewUrl, this._jwtToken);
|
|
92
|
-
this._sdk.setConfigurationValue(ShapeDiverSdkConfigType.REQUEST_HEADERS, this._headers);
|
|
95
|
+
this._sdk = (0, sdk_geometry_api_sdk_v2_1.create)(this._modelViewUrl, this._jwtToken);
|
|
96
|
+
this._sdk.setConfigurationValue(sdk_geometry_api_sdk_v2_1.ShapeDiverSdkConfigType.REQUEST_HEADERS, this._headers);
|
|
93
97
|
}
|
|
94
98
|
catch (e) {
|
|
95
99
|
throw this._httpClient.convertError(e);
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
// #endregion Constructors (1)
|
|
99
|
-
// #region Public Accessors (
|
|
103
|
+
// #region Public Accessors (25)
|
|
100
104
|
get automaticSceneUpdate() {
|
|
101
105
|
return this._automaticSceneUpdate;
|
|
102
106
|
}
|
|
@@ -180,8 +184,8 @@ export class SessionEngine {
|
|
|
180
184
|
get viewerSettings() {
|
|
181
185
|
return this._viewerSettings;
|
|
182
186
|
}
|
|
183
|
-
// #endregion Public Accessors (
|
|
184
|
-
// #region Public Methods (
|
|
187
|
+
// #endregion Public Accessors (25)
|
|
188
|
+
// #region Public Methods (25)
|
|
185
189
|
applySettings(response, sections) {
|
|
186
190
|
sections = sections || {};
|
|
187
191
|
if (sections.session === undefined) {
|
|
@@ -201,25 +205,25 @@ export class SessionEngine {
|
|
|
201
205
|
config = response.viewer.config;
|
|
202
206
|
}
|
|
203
207
|
else {
|
|
204
|
-
throw new ShapeDiverViewerSettingsError('Session.applySettings: No config object available.');
|
|
208
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSettingsError('Session.applySettings: No config object available.');
|
|
205
209
|
}
|
|
206
210
|
try {
|
|
207
|
-
validate(config);
|
|
211
|
+
(0, viewer_settings_1.validate)(config);
|
|
208
212
|
}
|
|
209
213
|
catch (e) {
|
|
210
|
-
throw new ShapeDiverViewerSettingsError('Session.applySettings: Was not able to validate config object.');
|
|
214
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSettingsError('Session.applySettings: Was not able to validate config object.');
|
|
211
215
|
}
|
|
212
|
-
const settings = convert(config, latestVersion);
|
|
216
|
+
const settings = (0, viewer_settings_1.convert)(config, viewer_settings_1.latestVersion);
|
|
213
217
|
const exportMappingUid = {};
|
|
214
218
|
if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden)
|
|
215
219
|
if (response.exports)
|
|
216
|
-
for (
|
|
220
|
+
for (const exportId in response.exports)
|
|
217
221
|
if (response.exports[exportId].uid !== undefined)
|
|
218
222
|
exportMappingUid[response.exports[exportId].uid] = exportId;
|
|
219
223
|
const currentSettings = this._settingsEngine.settings;
|
|
220
224
|
// apply parameter settings
|
|
221
225
|
if (sections.session.parameter.displayname || sections.session.parameter.order || sections.session.parameter.hidden || sections.session.parameter.value) {
|
|
222
|
-
for (
|
|
226
|
+
for (const p in this.parameters) {
|
|
223
227
|
if (settings.session[p]) {
|
|
224
228
|
if (sections.session.parameter.displayname)
|
|
225
229
|
this.parameters[p].displayname = settings.session[p].displayname;
|
|
@@ -236,7 +240,7 @@ export class SessionEngine {
|
|
|
236
240
|
}
|
|
237
241
|
// apply export settings
|
|
238
242
|
if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden) {
|
|
239
|
-
for (
|
|
243
|
+
for (const p in this.exports) {
|
|
240
244
|
let idForSettings = '';
|
|
241
245
|
if (settings.session[p]) {
|
|
242
246
|
idForSettings = p;
|
|
@@ -336,7 +340,7 @@ export class SessionEngine {
|
|
|
336
340
|
* @param parameters the parameter set to update the session
|
|
337
341
|
* @returns promise with a scene graph node
|
|
338
342
|
*/
|
|
339
|
-
customize(force = false) {
|
|
343
|
+
customize(force = false, waitForViewportUpdate = false) {
|
|
340
344
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
345
|
const eventId = this._uuidGenerator.create();
|
|
342
346
|
const customizationId = this._uuidGenerator.create();
|
|
@@ -350,60 +354,60 @@ export class SessionEngine {
|
|
|
350
354
|
if (changes === false)
|
|
351
355
|
return this.node;
|
|
352
356
|
}
|
|
353
|
-
const eventStart = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
354
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
357
|
+
const eventStart = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
358
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_START, eventStart);
|
|
355
359
|
const oldNode = this.node.cloneInstance();
|
|
356
360
|
__classPrivateFieldSet(this, _SessionEngine_customizationProcess, customizationId, "f");
|
|
357
361
|
this._logger.debugLow(`Session(${this.id}).customize: Customizing session.`);
|
|
358
|
-
for (
|
|
362
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
359
363
|
if (!this.excludeViewports.includes(r))
|
|
360
364
|
this._stateEngine.renderingEngines[r].busy.push(customizationId);
|
|
361
|
-
const eventFileUpload = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Uploading file parameters' };
|
|
362
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventFileUpload);
|
|
365
|
+
const eventFileUpload = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Uploading file parameters' };
|
|
366
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_PROCESS, eventFileUpload);
|
|
363
367
|
const fileParameterIds = {};
|
|
364
368
|
// load file parameter first
|
|
365
369
|
for (const parameterId in this.parameters) {
|
|
366
|
-
if (this.parameters[parameterId] instanceof FileParameter) {
|
|
370
|
+
if (this.parameters[parameterId] instanceof FileParameter_1.FileParameter) {
|
|
367
371
|
fileParameterIds[parameterId] = yield this.parameters[parameterId].upload();
|
|
368
372
|
// OPTION TO SKIP - PART 1a
|
|
369
373
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
370
|
-
for (
|
|
374
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
371
375
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
372
376
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
373
377
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
374
|
-
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
375
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
376
|
-
return new SessionTreeNode();
|
|
378
|
+
const eventCancel1a = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
379
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
380
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
377
381
|
}
|
|
378
382
|
else if (this._closed === true) {
|
|
379
|
-
for (
|
|
383
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
380
384
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
381
385
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
382
386
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
383
|
-
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
384
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
385
|
-
return new SessionTreeNode();
|
|
387
|
+
const eventCancel1a = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
388
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
389
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
386
390
|
}
|
|
387
391
|
}
|
|
388
392
|
}
|
|
389
393
|
// OPTION TO SKIP - PART 1b
|
|
390
394
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
391
|
-
for (
|
|
395
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
392
396
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
393
397
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
394
|
-
const eventCancel1b = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
395
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
398
|
+
const eventCancel1b = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
399
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
396
400
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
397
|
-
return new SessionTreeNode();
|
|
401
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
398
402
|
}
|
|
399
403
|
else if (this._closed === true) {
|
|
400
|
-
for (
|
|
404
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
401
405
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
402
406
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
403
407
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
404
|
-
const eventCancel1b = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
405
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
406
|
-
return new SessionTreeNode();
|
|
408
|
+
const eventCancel1b = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
409
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1b);
|
|
410
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
407
411
|
}
|
|
408
412
|
// assign the uploaded parameters
|
|
409
413
|
for (const parameterId in fileParameterIds)
|
|
@@ -420,37 +424,37 @@ export class SessionEngine {
|
|
|
420
424
|
for (const parameterId in this.parameters)
|
|
421
425
|
this.parameterValues[parameterId] = parameterSet[parameterId].valueString;
|
|
422
426
|
this._logger.info(`Session(${this.id}).customize: Customizing session with parameters ${JSON.stringify(this.parameterValues)}.`);
|
|
423
|
-
const eventRequest = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Sending customization request' };
|
|
424
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
427
|
+
const eventRequest = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Sending customization request' };
|
|
428
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
425
429
|
const newNode = yield this.customizeInternal(() => __classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId, {
|
|
426
430
|
eventId,
|
|
427
|
-
type: TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
431
|
+
type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
428
432
|
progressRange: {
|
|
429
433
|
min: 0.1,
|
|
430
434
|
max: 0.9
|
|
431
435
|
},
|
|
432
436
|
data: { sessionId: this.id }
|
|
433
437
|
});
|
|
434
|
-
const eventSceneUpdate = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.9, data: { sessionId: this.id }, status: 'Updating scene' };
|
|
435
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
438
|
+
const eventSceneUpdate = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.9, data: { sessionId: this.id }, status: 'Updating scene' };
|
|
439
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
436
440
|
// OPTION TO SKIP - PART 2
|
|
437
441
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
438
|
-
for (
|
|
442
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
439
443
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
440
444
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
441
|
-
const eventCancel2 = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
442
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
445
|
+
const eventCancel2 = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization was exceeded by other customization request' };
|
|
446
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
443
447
|
this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
|
|
444
448
|
return newNode;
|
|
445
449
|
}
|
|
446
450
|
else if (this._closed === true) { // I get a TS warning here that the type of _closed is "false", I think TS doesn't get that there is a promise inbetween
|
|
447
|
-
for (
|
|
451
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
448
452
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
449
453
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
450
454
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
451
|
-
const eventCancel2 = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
452
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
453
|
-
return new SessionTreeNode();
|
|
455
|
+
const eventCancel2 = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
456
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel2);
|
|
457
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
454
458
|
}
|
|
455
459
|
// if this is not a call by the goBack or goForward functions, add the parameter values to the history and delete the forward history
|
|
456
460
|
if (!__classPrivateFieldGet(this, _SessionEngine_parameterHistoryCall, "f")) {
|
|
@@ -474,17 +478,18 @@ export class SessionEngine {
|
|
|
474
478
|
this.exports[exportId].updateExport();
|
|
475
479
|
this._warningCreator();
|
|
476
480
|
this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
477
|
-
for (
|
|
481
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
478
482
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
479
483
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
480
484
|
this._logger.debug(`Session(${this.id}).customize: Session customized.`);
|
|
481
|
-
this._eventEngine.emitEvent(EVENTTYPE.SESSION.SESSION_CUSTOMIZED, { sessionId: this.id });
|
|
482
|
-
const eventEnd = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
483
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
485
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.SESSION.SESSION_CUSTOMIZED, { sessionId: this.id });
|
|
486
|
+
const eventEnd = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
487
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
484
488
|
// update the viewports
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
this._stateEngine.renderingEngines[r].
|
|
489
|
+
if (waitForViewportUpdate)
|
|
490
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
491
|
+
if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
|
|
492
|
+
this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
|
|
488
493
|
// call the update callback function on the session
|
|
489
494
|
if (this._updateCallback)
|
|
490
495
|
this._updateCallback(newNode, oldNode);
|
|
@@ -494,9 +499,9 @@ export class SessionEngine {
|
|
|
494
499
|
return this.node;
|
|
495
500
|
}
|
|
496
501
|
catch (e) {
|
|
497
|
-
const eventCancel = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization failed' };
|
|
498
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel);
|
|
499
|
-
for (
|
|
502
|
+
const eventCancel = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization failed' };
|
|
503
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel);
|
|
504
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
500
505
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
501
506
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
502
507
|
throw this._httpClient.convertError(e);
|
|
@@ -506,15 +511,15 @@ export class SessionEngine {
|
|
|
506
511
|
customizeParallel(parameterValues) {
|
|
507
512
|
return __awaiter(this, void 0, void 0, function* () {
|
|
508
513
|
const eventId = this._uuidGenerator.create();
|
|
509
|
-
const eventStart = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
510
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
514
|
+
const eventStart = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
|
|
515
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_START, eventStart);
|
|
511
516
|
const parameterSet = {};
|
|
512
517
|
// create a set of the current validated parameter values
|
|
513
518
|
for (const parameterId in this.parameters)
|
|
514
519
|
parameterSet[parameterId] = parameterValues[parameterId] !== undefined ? (' ' + parameterValues[parameterId]).slice(1) : this.parameters[parameterId].stringify();
|
|
515
520
|
const newNode = yield this.customizeSession(parameterSet, () => false, {
|
|
516
521
|
eventId,
|
|
517
|
-
type: TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
522
|
+
type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION,
|
|
518
523
|
progressRange: {
|
|
519
524
|
min: 0.0,
|
|
520
525
|
max: 1
|
|
@@ -522,8 +527,8 @@ export class SessionEngine {
|
|
|
522
527
|
data: { sessionId: this.id }
|
|
523
528
|
}, true);
|
|
524
529
|
newNode.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
525
|
-
const eventEnd = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
526
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
530
|
+
const eventEnd = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
|
|
531
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
527
532
|
return newNode;
|
|
528
533
|
});
|
|
529
534
|
}
|
|
@@ -531,7 +536,7 @@ export class SessionEngine {
|
|
|
531
536
|
return __awaiter(this, void 0, void 0, function* () {
|
|
532
537
|
if (!this.canGoBack()) {
|
|
533
538
|
this._logger.debug(`Session(${this.id}).goBack: Cannot go further back.`);
|
|
534
|
-
return new TreeNode();
|
|
539
|
+
return new viewer_shared_node_tree_1.TreeNode();
|
|
535
540
|
}
|
|
536
541
|
// get the current parameter set and store it in the forward history later on
|
|
537
542
|
const currentParameterSet = __classPrivateFieldGet(this, _SessionEngine_parameterHistory, "f").pop();
|
|
@@ -552,7 +557,7 @@ export class SessionEngine {
|
|
|
552
557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
553
558
|
if (!this.canGoForward()) {
|
|
554
559
|
this._logger.debug(`Session(${this.id}).goForward: Cannot go further forward.`);
|
|
555
|
-
return new TreeNode();
|
|
560
|
+
return new viewer_shared_node_tree_1.TreeNode();
|
|
556
561
|
}
|
|
557
562
|
// get the last undone parameter set and apply the values to the parameters
|
|
558
563
|
const lastParameterSet = __classPrivateFieldGet(this, _SessionEngine_parameterHistoryForward, "f").pop();
|
|
@@ -576,7 +581,7 @@ export class SessionEngine {
|
|
|
576
581
|
var _a, _b;
|
|
577
582
|
return __awaiter(this, void 0, void 0, function* () {
|
|
578
583
|
if (this._initialized === true)
|
|
579
|
-
throw new ShapeDiverViewerSessionError('Session.init: Session already initialized.');
|
|
584
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.init: Session already initialized.');
|
|
580
585
|
try {
|
|
581
586
|
this._performanceEvaluator.startSection('sessionResponse');
|
|
582
587
|
const parameterSet = {};
|
|
@@ -591,11 +596,11 @@ export class SessionEngine {
|
|
|
591
596
|
}
|
|
592
597
|
else {
|
|
593
598
|
// we should never get here
|
|
594
|
-
throw new ShapeDiverViewerSessionError(
|
|
599
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.init: Initialization of session failed. Neither a ticket nor a guid are available.');
|
|
595
600
|
}
|
|
596
601
|
this._performanceEvaluator.endSection('sessionResponse');
|
|
597
602
|
this._viewerSettings = (_a = this._responseDto.viewer) === null || _a === void 0 ? void 0 : _a.config;
|
|
598
|
-
this._viewerSettingsVersionBackend = this._responseDto.viewerSettingsVersion || latestVersion;
|
|
603
|
+
this._viewerSettingsVersionBackend = this._responseDto.viewerSettingsVersion || viewer_settings_1.latestVersion;
|
|
599
604
|
this._sessionId = this._responseDto.sessionId;
|
|
600
605
|
this._modelId = (_b = this._responseDto.model) === null || _b === void 0 ? void 0 : _b.id;
|
|
601
606
|
this._httpClient.addDataLoading(this._sessionId, {
|
|
@@ -604,9 +609,9 @@ export class SessionEngine {
|
|
|
604
609
|
});
|
|
605
610
|
this._settingsEngine.loadSettings(this._viewerSettings);
|
|
606
611
|
if (!this._sessionId)
|
|
607
|
-
throw new ShapeDiverViewerSessionError(
|
|
612
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.init: Initialization of session failed. ResponseDto did not have a sessionId.');
|
|
608
613
|
if (!this._modelId)
|
|
609
|
-
throw new ShapeDiverViewerSessionError(
|
|
614
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.init: Initialization of session failed. ResponseDto did not have a model.id.');
|
|
610
615
|
this.updateResponseDto(this._responseDto, parameterSet);
|
|
611
616
|
this._initialized = true;
|
|
612
617
|
}
|
|
@@ -624,50 +629,52 @@ export class SessionEngine {
|
|
|
624
629
|
* @param outputs the outputs to load
|
|
625
630
|
* @returns promise with a scene graph node
|
|
626
631
|
*/
|
|
627
|
-
|
|
632
|
+
loadOutputs(cancelRequest = () => false, taskEventInfo, retry = false) {
|
|
628
633
|
var _a;
|
|
629
634
|
return __awaiter(this, void 0, void 0, function* () {
|
|
630
635
|
this.checkAvailability();
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
for (let outputId in responseDto.outputs) {
|
|
634
|
-
responseDto.outputs[outputId].id = outputId;
|
|
635
|
-
if (this.outputsFreeze[outputId] === undefined)
|
|
636
|
-
outputsFreeze[outputId] = false;
|
|
637
|
-
outputs[outputId] = new Output(responseDto.outputs[outputId], this);
|
|
638
|
-
}
|
|
636
|
+
const o = Object.assign({}, this._outputs);
|
|
637
|
+
const of = Object.assign({}, this._outputsFreeze);
|
|
639
638
|
try {
|
|
640
|
-
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model',
|
|
641
|
-
node.data.push(new SessionData(
|
|
639
|
+
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model', o, of, taskEventInfo);
|
|
640
|
+
node.data.push(new SessionData_1.SessionData(this._responseDto));
|
|
641
|
+
if (cancelRequest())
|
|
642
|
+
return node;
|
|
643
|
+
if (this._automaticSceneUpdate)
|
|
644
|
+
this.removeFromSceneTree(this._node);
|
|
645
|
+
this._node = node;
|
|
646
|
+
if (this._automaticSceneUpdate && this._closed === false)
|
|
647
|
+
this.addToSceneTree(this._node);
|
|
648
|
+
this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
642
649
|
return node;
|
|
643
650
|
}
|
|
644
651
|
catch (e) {
|
|
645
|
-
if (e instanceof OutputDelayException) {
|
|
652
|
+
if (e instanceof OutputDelayException_1.OutputDelayException) {
|
|
646
653
|
yield this.timeout(e.delay);
|
|
647
654
|
}
|
|
648
655
|
else {
|
|
649
656
|
yield this.handleError(e, retry);
|
|
650
657
|
if (cancelRequest())
|
|
651
|
-
return new SessionTreeNode();
|
|
652
|
-
return yield this.
|
|
658
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
659
|
+
return yield this.loadOutputs(cancelRequest, taskEventInfo, true);
|
|
653
660
|
}
|
|
654
661
|
if (cancelRequest())
|
|
655
|
-
return new SessionTreeNode();
|
|
656
|
-
|
|
657
|
-
for (
|
|
658
|
-
outputMapping[output] =
|
|
662
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
663
|
+
const outputMapping = {};
|
|
664
|
+
for (const output in o)
|
|
665
|
+
outputMapping[output] = o[output].version;
|
|
659
666
|
try {
|
|
660
667
|
const responseDto = yield this._sdk.output.getCache(this._sessionId, outputMapping);
|
|
661
668
|
if (cancelRequest())
|
|
662
|
-
return new SessionTreeNode();
|
|
669
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
663
670
|
this.updateResponseDto(responseDto);
|
|
664
|
-
return yield this.
|
|
671
|
+
return yield this.loadOutputs(cancelRequest, taskEventInfo);
|
|
665
672
|
}
|
|
666
673
|
catch (e) {
|
|
667
674
|
yield this.handleError(e, retry);
|
|
668
675
|
if (cancelRequest())
|
|
669
|
-
return new SessionTreeNode();
|
|
670
|
-
return yield this.
|
|
676
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
677
|
+
return yield this.loadOutputs(cancelRequest, taskEventInfo, true);
|
|
671
678
|
}
|
|
672
679
|
}
|
|
673
680
|
});
|
|
@@ -680,52 +687,50 @@ export class SessionEngine {
|
|
|
680
687
|
* @param outputs the outputs to load
|
|
681
688
|
* @returns promise with a scene graph node
|
|
682
689
|
*/
|
|
683
|
-
|
|
690
|
+
loadOutputsParallel(responseDto, cancelRequest = () => false, taskEventInfo, retry = false) {
|
|
684
691
|
var _a;
|
|
685
692
|
return __awaiter(this, void 0, void 0, function* () {
|
|
686
693
|
this.checkAvailability();
|
|
687
|
-
const
|
|
688
|
-
const
|
|
694
|
+
const outputs = {};
|
|
695
|
+
const outputsFreeze = {};
|
|
696
|
+
for (const outputId in responseDto.outputs) {
|
|
697
|
+
responseDto.outputs[outputId].id = outputId;
|
|
698
|
+
if (this.outputsFreeze[outputId] === undefined)
|
|
699
|
+
outputsFreeze[outputId] = false;
|
|
700
|
+
outputs[outputId] = new Output_1.Output(responseDto.outputs[outputId], this);
|
|
701
|
+
}
|
|
689
702
|
try {
|
|
690
|
-
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model',
|
|
691
|
-
node.data.push(new SessionData(
|
|
692
|
-
if (cancelRequest())
|
|
693
|
-
return node;
|
|
694
|
-
if (this._automaticSceneUpdate)
|
|
695
|
-
this.removeFromSceneTree(this._node);
|
|
696
|
-
this._node = node;
|
|
697
|
-
if (this._automaticSceneUpdate && this._closed === false)
|
|
698
|
-
this.addToSceneTree(this._node);
|
|
699
|
-
this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
703
|
+
const node = yield this._outputLoader.loadOutputs(((_a = this._responseDto.model) === null || _a === void 0 ? void 0 : _a.name) || 'model', outputs, outputsFreeze, taskEventInfo);
|
|
704
|
+
node.data.push(new SessionData_1.SessionData(responseDto));
|
|
700
705
|
return node;
|
|
701
706
|
}
|
|
702
707
|
catch (e) {
|
|
703
|
-
if (e instanceof OutputDelayException) {
|
|
708
|
+
if (e instanceof OutputDelayException_1.OutputDelayException) {
|
|
704
709
|
yield this.timeout(e.delay);
|
|
705
710
|
}
|
|
706
711
|
else {
|
|
707
712
|
yield this.handleError(e, retry);
|
|
708
713
|
if (cancelRequest())
|
|
709
|
-
return new SessionTreeNode();
|
|
710
|
-
return yield this.
|
|
714
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
715
|
+
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
|
|
711
716
|
}
|
|
712
717
|
if (cancelRequest())
|
|
713
|
-
return new SessionTreeNode();
|
|
714
|
-
|
|
715
|
-
for (
|
|
716
|
-
outputMapping[output] =
|
|
718
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
719
|
+
const outputMapping = {};
|
|
720
|
+
for (const output in outputs)
|
|
721
|
+
outputMapping[output] = outputs[output].version;
|
|
717
722
|
try {
|
|
718
723
|
const responseDto = yield this._sdk.output.getCache(this._sessionId, outputMapping);
|
|
719
724
|
if (cancelRequest())
|
|
720
|
-
return new SessionTreeNode();
|
|
725
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
721
726
|
this.updateResponseDto(responseDto);
|
|
722
|
-
return yield this.
|
|
727
|
+
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
|
|
723
728
|
}
|
|
724
729
|
catch (e) {
|
|
725
730
|
yield this.handleError(e, retry);
|
|
726
731
|
if (cancelRequest())
|
|
727
|
-
return new SessionTreeNode();
|
|
728
|
-
return yield this.
|
|
732
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
733
|
+
return yield this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
|
|
729
734
|
}
|
|
730
735
|
}
|
|
731
736
|
});
|
|
@@ -734,27 +739,7 @@ export class SessionEngine {
|
|
|
734
739
|
return __awaiter(this, void 0, void 0, function* () {
|
|
735
740
|
this.checkAvailability('export');
|
|
736
741
|
try {
|
|
737
|
-
const requestParameterSet =
|
|
738
|
-
// first step, we convert all our names and displaynames to ids
|
|
739
|
-
for (const parameterIdOrName in parameters) {
|
|
740
|
-
// we prioritize id, then name and then displayname
|
|
741
|
-
// if there are two parameters with the same name or displayname, we take the one that is found first (no way for us to evaluate which one the user meant)
|
|
742
|
-
const parameterObject = Object.values(this._parameters).find(p => p.id === parameterIdOrName || p.name === parameterIdOrName || p.displayname === parameterIdOrName);
|
|
743
|
-
// in case the key of the key value pair was neither the id, name or displayname, skip
|
|
744
|
-
if (!parameterObject)
|
|
745
|
-
continue;
|
|
746
|
-
// deep copy into new dictionary
|
|
747
|
-
requestParameterSet[parameterObject.id] = (' ' + parameters[parameterIdOrName]).slice(1);
|
|
748
|
-
}
|
|
749
|
-
// seconds step, fill all other parameter values that are currently not set
|
|
750
|
-
const currentParameters = this.parameterValues;
|
|
751
|
-
for (const parameterId in currentParameters) {
|
|
752
|
-
// if already set by input values, skip
|
|
753
|
-
if (requestParameterSet[parameterId] !== undefined)
|
|
754
|
-
continue;
|
|
755
|
-
// deep copy into new dictionary
|
|
756
|
-
requestParameterSet[parameterId] = (' ' + currentParameters[parameterId]).slice(1);
|
|
757
|
-
}
|
|
742
|
+
const requestParameterSet = this.cleanExportParameters(parameters);
|
|
758
743
|
const responseDto = yield this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId, { exports: { id: exportId }, parameters: requestParameterSet }, maxWaitTime);
|
|
759
744
|
this.updateResponseDto(responseDto);
|
|
760
745
|
return this.exports[exportId];
|
|
@@ -765,9 +750,24 @@ export class SessionEngine {
|
|
|
765
750
|
}
|
|
766
751
|
});
|
|
767
752
|
}
|
|
753
|
+
requestExports(body, maxWaitMsec, retry = false) {
|
|
754
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
755
|
+
this.checkAvailability('export');
|
|
756
|
+
try {
|
|
757
|
+
const requestParameterSet = this.cleanExportParameters(body.parameters);
|
|
758
|
+
const responseDto = yield this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId, { exports: body.exports, parameters: requestParameterSet, outputs: body.outputs, max_wait_time: body.max_wait_time }, maxWaitMsec);
|
|
759
|
+
this.updateResponseDto(responseDto);
|
|
760
|
+
return responseDto;
|
|
761
|
+
}
|
|
762
|
+
catch (e) {
|
|
763
|
+
yield this.handleError(e, retry);
|
|
764
|
+
return yield this.requestExports(body, maxWaitMsec, true);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
768
|
resetSettings(sections) {
|
|
769
769
|
if (!this._responseDto)
|
|
770
|
-
throw new ShapeDiverViewerSessionError(
|
|
770
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.resetSettings: responseDto not available.');
|
|
771
771
|
sections = sections || {};
|
|
772
772
|
if (sections.session === undefined) {
|
|
773
773
|
sections.session = {
|
|
@@ -791,7 +791,7 @@ export class SessionEngine {
|
|
|
791
791
|
this._logger.debug(`Session(${this.id}).saveDefaultParameters: Saved default parameters.`);
|
|
792
792
|
}
|
|
793
793
|
else {
|
|
794
|
-
throw new ShapeDiverViewerSessionError(`Session(${this.id}).saveDefaultParameters: Could not save default parameters.`);
|
|
794
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError(`Session(${this.id}).saveDefaultParameters: Could not save default parameters.`);
|
|
795
795
|
}
|
|
796
796
|
return response;
|
|
797
797
|
});
|
|
@@ -870,14 +870,14 @@ export class SessionEngine {
|
|
|
870
870
|
return __awaiter(this, void 0, void 0, function* () {
|
|
871
871
|
this.checkAvailability('configure', true);
|
|
872
872
|
try {
|
|
873
|
-
validate(json, this._viewerSettingsVersion);
|
|
873
|
+
(0, viewer_settings_1.validate)(json, this._viewerSettingsVersion);
|
|
874
874
|
// if viewer settings version is higher than backend settings version
|
|
875
875
|
// convert to backend settings version
|
|
876
876
|
if (+this._viewerSettingsVersion > +this._viewerSettingsVersionBackend)
|
|
877
|
-
json = convert(json, this._viewerSettingsVersionBackend);
|
|
877
|
+
json = (0, viewer_settings_1.convert)(json, this._viewerSettingsVersionBackend);
|
|
878
878
|
}
|
|
879
879
|
catch (e) {
|
|
880
|
-
throw new ShapeDiverViewerSettingsError('Session.saveSettings: Settings could not be validated. ' + e.message, e);
|
|
880
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSettingsError('Session.saveSettings: Settings could not be validated. ' + e.message, e);
|
|
881
881
|
}
|
|
882
882
|
try {
|
|
883
883
|
yield this._sdk.model.updateConfig(this._modelId, json);
|
|
@@ -895,7 +895,7 @@ export class SessionEngine {
|
|
|
895
895
|
// settings saving
|
|
896
896
|
this._saveSessionSettings();
|
|
897
897
|
let properties = {};
|
|
898
|
-
for (
|
|
898
|
+
for (const p in this.parameters) {
|
|
899
899
|
properties[p] = {
|
|
900
900
|
displayname: this.parameters[p].displayname !== undefined ? this.parameters[p].displayname : '',
|
|
901
901
|
hidden: this.parameters[p].hidden !== undefined ? this.parameters[p].hidden : false,
|
|
@@ -905,7 +905,7 @@ export class SessionEngine {
|
|
|
905
905
|
}
|
|
906
906
|
const responseP = Object.values(properties).length !== 0 ? yield this.saveParameterProperties(properties) : true;
|
|
907
907
|
properties = {};
|
|
908
|
-
for (
|
|
908
|
+
for (const e in this.exports) {
|
|
909
909
|
properties[e] = {
|
|
910
910
|
displayname: this.exports[e].displayname !== undefined ? this.exports[e].displayname : '',
|
|
911
911
|
hidden: this.exports[e].hidden !== undefined ? this.exports[e].hidden : false,
|
|
@@ -915,7 +915,7 @@ export class SessionEngine {
|
|
|
915
915
|
}
|
|
916
916
|
const responseE = Object.values(properties).length !== 0 ? yield this.saveExportProperties(properties) : true;
|
|
917
917
|
properties = {};
|
|
918
|
-
for (
|
|
918
|
+
for (const o in this.outputs) {
|
|
919
919
|
properties[o] = {
|
|
920
920
|
displayname: this.outputs[o].displayname !== undefined ? this.outputs[o].displayname : '',
|
|
921
921
|
hidden: this.outputs[o].hidden !== undefined ? this.outputs[o].hidden : false,
|
|
@@ -940,7 +940,7 @@ export class SessionEngine {
|
|
|
940
940
|
this.checkAvailability();
|
|
941
941
|
this._jwtToken = value;
|
|
942
942
|
try {
|
|
943
|
-
this._sdk.setConfigurationValue(ShapeDiverSdkConfigType.JWT_TOKEN, value);
|
|
943
|
+
this._sdk.setConfigurationValue(sdk_geometry_api_sdk_v2_1.ShapeDiverSdkConfigType.JWT_TOKEN, value);
|
|
944
944
|
const responseDto = yield this._sdk.session.default(this._sessionId);
|
|
945
945
|
if (this._responseDto)
|
|
946
946
|
this._responseDto.actions = responseDto.actions;
|
|
@@ -950,24 +950,24 @@ export class SessionEngine {
|
|
|
950
950
|
}
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
|
-
updateOutputs(taskEventInfo) {
|
|
953
|
+
updateOutputs(taskEventInfo, waitForViewportUpdate = false) {
|
|
954
954
|
return __awaiter(this, void 0, void 0, function* () {
|
|
955
955
|
const eventId = taskEventInfo ? taskEventInfo.eventId : this._uuidGenerator.create();
|
|
956
|
-
const eventType = taskEventInfo ? taskEventInfo.type : TASK_TYPE.SESSION_OUTPUTS_UPDATE;
|
|
956
|
+
const eventType = taskEventInfo ? taskEventInfo.type : viewer_shared_types_1.TASK_TYPE.SESSION_OUTPUTS_UPDATE;
|
|
957
957
|
const eventData = taskEventInfo ? taskEventInfo.data : { sessionId: this.id };
|
|
958
958
|
if (!taskEventInfo) {
|
|
959
959
|
const eventStart = { type: eventType, id: eventId, progress: 0, data: eventData, status: 'Updating outputs' };
|
|
960
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
|
|
960
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_START, eventStart);
|
|
961
961
|
}
|
|
962
962
|
const customizationId = this._uuidGenerator.create();
|
|
963
963
|
const oldNode = this.node.cloneInstance();
|
|
964
964
|
__classPrivateFieldSet(this, _SessionEngine_customizationProcess, customizationId, "f");
|
|
965
965
|
this._logger.debugLow(`Session(${this.id}).updateOutputs: Updating Outputs.`);
|
|
966
|
-
for (
|
|
966
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
967
967
|
if (!this.excludeViewports.includes(r))
|
|
968
968
|
this._stateEngine.renderingEngines[r].busy.push(customizationId);
|
|
969
969
|
const eventRequest = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 0.1 + taskEventInfo.progressRange.min : 0.1, data: eventData, status: 'Loading outputs' };
|
|
970
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
970
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_PROCESS, eventRequest);
|
|
971
971
|
const newNode = yield this.loadOutputs(() => __classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId, {
|
|
972
972
|
eventId,
|
|
973
973
|
type: eventType,
|
|
@@ -978,25 +978,25 @@ export class SessionEngine {
|
|
|
978
978
|
data: eventData
|
|
979
979
|
});
|
|
980
980
|
const eventSceneUpdate = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 0.9 + taskEventInfo.progressRange.min : 0.9, data: eventData, status: 'Updating scene' };
|
|
981
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
981
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_PROCESS, eventSceneUpdate);
|
|
982
982
|
// OPTION TO SKIP - PART 1
|
|
983
983
|
if (__classPrivateFieldGet(this, _SessionEngine_customizationProcess, "f") !== customizationId) {
|
|
984
|
-
for (
|
|
984
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
985
985
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
986
986
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
987
987
|
const eventCancel1 = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 1 + taskEventInfo.progressRange.min : 1, data: eventData, status: 'Output updating was exceeded by other customization request' };
|
|
988
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1);
|
|
988
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1);
|
|
989
989
|
this._logger.debug(`Session(${this.id}).updateOutputs: Output updating was exceeded by other request.`);
|
|
990
990
|
return newNode;
|
|
991
991
|
}
|
|
992
992
|
else if (this._closed === true) {
|
|
993
|
-
for (
|
|
993
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
994
994
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
995
995
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
996
996
|
this._logger.debug(`Session(${this.id}).customize: Session was closed during customization request.`);
|
|
997
|
-
const eventCancel1a = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
998
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
999
|
-
return new SessionTreeNode();
|
|
997
|
+
const eventCancel1a = { type: viewer_shared_types_1.TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session was closed during customization request' };
|
|
998
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
|
|
999
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
1000
1000
|
}
|
|
1001
1001
|
if (this.automaticSceneUpdate)
|
|
1002
1002
|
this.removeFromSceneTree(this.node);
|
|
@@ -1013,18 +1013,19 @@ export class SessionEngine {
|
|
|
1013
1013
|
this.exports[exportId].updateExport();
|
|
1014
1014
|
this._warningCreator();
|
|
1015
1015
|
this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
|
|
1016
|
-
for (
|
|
1016
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
1017
1017
|
if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
|
|
1018
1018
|
this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
|
|
1019
1019
|
this._logger.debug(`Session(${this.id}).updateOutputs: Updated outputs.`);
|
|
1020
1020
|
if (!taskEventInfo) {
|
|
1021
1021
|
const eventEnd = { type: eventType, id: eventId, progress: 1, data: eventData, status: 'Outputs updated' };
|
|
1022
|
-
this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
1022
|
+
this._eventEngine.emitEvent(viewer_shared_services_1.EVENTTYPE.TASK.TASK_END, eventEnd);
|
|
1023
1023
|
}
|
|
1024
1024
|
// update the viewports
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
this._stateEngine.renderingEngines[r].
|
|
1025
|
+
if (waitForViewportUpdate)
|
|
1026
|
+
for (const r in this._stateEngine.renderingEngines)
|
|
1027
|
+
if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
|
|
1028
|
+
this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).updateOutputs`);
|
|
1028
1029
|
// call the update callback function on the session
|
|
1029
1030
|
if (this._updateCallback)
|
|
1030
1031
|
this._updateCallback(newNode, oldNode);
|
|
@@ -1047,7 +1048,7 @@ export class SessionEngine {
|
|
|
1047
1048
|
return fileAsset.id;
|
|
1048
1049
|
}
|
|
1049
1050
|
else {
|
|
1050
|
-
throw new ShapeDiverViewerSessionError(
|
|
1051
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.uploadFile: Upload reply has not the required format.');
|
|
1051
1052
|
}
|
|
1052
1053
|
}
|
|
1053
1054
|
catch (e) {
|
|
@@ -1056,13 +1057,13 @@ export class SessionEngine {
|
|
|
1056
1057
|
}
|
|
1057
1058
|
});
|
|
1058
1059
|
}
|
|
1059
|
-
uploadGLTF(blob, conversion = ShapeDiverRequestGltfUploadQueryConversion.NONE, retry = false) {
|
|
1060
|
+
uploadGLTF(blob, conversion = sdk_geometry_api_sdk_v2_1.ShapeDiverRequestGltfUploadQueryConversion.NONE, retry = false) {
|
|
1060
1061
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1061
1062
|
this.checkAvailability('gltf-upload');
|
|
1062
1063
|
try {
|
|
1063
1064
|
const responseDto = yield this._sdk.gltf.upload(this._sessionId, yield blob.arrayBuffer(), 'model/gltf-binary', conversion);
|
|
1064
1065
|
if (!responseDto || !responseDto.gltf || !responseDto.gltf.href)
|
|
1065
|
-
throw new ShapeDiverViewerSessionError(
|
|
1066
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.uploadGLTF: Upload reply has not the required format.');
|
|
1066
1067
|
return responseDto;
|
|
1067
1068
|
}
|
|
1068
1069
|
catch (e) {
|
|
@@ -1071,20 +1072,20 @@ export class SessionEngine {
|
|
|
1071
1072
|
}
|
|
1072
1073
|
});
|
|
1073
1074
|
}
|
|
1074
|
-
// #endregion Public Methods (
|
|
1075
|
-
// #region Private Methods (
|
|
1075
|
+
// #endregion Public Methods (25)
|
|
1076
|
+
// #region Private Methods (11)
|
|
1076
1077
|
_saveSessionSettings() {
|
|
1077
1078
|
const parameters = this.parameters;
|
|
1078
1079
|
const exports = this.exports;
|
|
1079
1080
|
const sessionProperties = {};
|
|
1080
|
-
for (
|
|
1081
|
+
for (const p in parameters) {
|
|
1081
1082
|
sessionProperties[p] = {
|
|
1082
1083
|
order: parameters[p].order || 0,
|
|
1083
1084
|
displayname: parameters[p].displayname || '',
|
|
1084
1085
|
hidden: parameters[p].hidden
|
|
1085
1086
|
};
|
|
1086
1087
|
}
|
|
1087
|
-
for (
|
|
1088
|
+
for (const e in exports) {
|
|
1088
1089
|
sessionProperties[e] = {
|
|
1089
1090
|
order: exports[e].order || 0,
|
|
1090
1091
|
displayname: exports[e].displayname || '',
|
|
@@ -1093,10 +1094,10 @@ export class SessionEngine {
|
|
|
1093
1094
|
}
|
|
1094
1095
|
this._settingsEngine.session = sessionProperties;
|
|
1095
1096
|
let orderedOutputs = [];
|
|
1096
|
-
for (
|
|
1097
|
+
for (const o in this.outputs)
|
|
1097
1098
|
orderedOutputs.push(this.outputs[o]);
|
|
1098
1099
|
orderedOutputs.sort((a, b) => ((a.order || Infinity) - (b.order || Infinity)));
|
|
1099
|
-
|
|
1100
|
+
const zerosOutputs = orderedOutputs.filter(x => x.order === 0);
|
|
1100
1101
|
orderedOutputs = orderedOutputs.filter((el) => { return !zerosOutputs.includes(el); });
|
|
1101
1102
|
orderedOutputs = zerosOutputs.concat(orderedOutputs);
|
|
1102
1103
|
const controlOrderOutputs = orderedOutputs.map((value) => { return value.id; });
|
|
@@ -1112,9 +1113,9 @@ export class SessionEngine {
|
|
|
1112
1113
|
let warning = '';
|
|
1113
1114
|
if (this.outputs[outputId].msg)
|
|
1114
1115
|
warning += `\n\t- ${this.outputs[outputId].msg}`;
|
|
1115
|
-
if (this.outputs[outputId].status_collect && this.outputs[outputId].status_collect !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1116
|
+
if (this.outputs[outputId].status_collect && this.outputs[outputId].status_collect !== sdk_geometry_api_sdk_v2_1.ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1116
1117
|
warning += `\n\t- status_collect is ${this.outputs[outputId].status_collect}`;
|
|
1117
|
-
if (this.outputs[outputId].status_computation && this.outputs[outputId].status_computation !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1118
|
+
if (this.outputs[outputId].status_computation && this.outputs[outputId].status_computation !== sdk_geometry_api_sdk_v2_1.ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1118
1119
|
warning += `\n\t- status_computation is ${this.outputs[outputId].status_computation}`;
|
|
1119
1120
|
if (warning)
|
|
1120
1121
|
this._logger.warn(`\nOutput(${outputId}):${warning}`);
|
|
@@ -1124,9 +1125,9 @@ export class SessionEngine {
|
|
|
1124
1125
|
let warning = '';
|
|
1125
1126
|
if (this.exports[exportId].msg)
|
|
1126
1127
|
warning += `\n\t- ${this.exports[exportId].msg}`;
|
|
1127
|
-
if (this.exports[exportId].status_collect && this.exports[exportId].status_collect !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1128
|
+
if (this.exports[exportId].status_collect && this.exports[exportId].status_collect !== sdk_geometry_api_sdk_v2_1.ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1128
1129
|
warning += `\n\t- status_collect is ${this.exports[exportId].status_collect}`;
|
|
1129
|
-
if (this.exports[exportId].status_computation && this.exports[exportId].status_computation !== ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1130
|
+
if (this.exports[exportId].status_computation && this.exports[exportId].status_computation !== sdk_geometry_api_sdk_v2_1.ShapeDiverResponseModelComputationStatus.SUCCESS)
|
|
1130
1131
|
warning += `\n\t- status_computation is ${this.exports[exportId].status_computation}`;
|
|
1131
1132
|
if (warning)
|
|
1132
1133
|
this._logger.warn(`\nExport(${exportId}):${warning}`);
|
|
@@ -1139,16 +1140,40 @@ export class SessionEngine {
|
|
|
1139
1140
|
checkAvailability(action, checkForModelId = false) {
|
|
1140
1141
|
var _a;
|
|
1141
1142
|
if (!this._responseDto)
|
|
1142
|
-
throw new ShapeDiverViewerSessionError(
|
|
1143
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.checkAvailability: responseDto not available.');
|
|
1143
1144
|
if (!this._sessionId)
|
|
1144
|
-
throw new ShapeDiverViewerSessionError(
|
|
1145
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.checkAvailability: sessionId not available.');
|
|
1145
1146
|
if (checkForModelId && !this._modelId)
|
|
1146
|
-
throw new ShapeDiverViewerSessionError(
|
|
1147
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.checkAvailability: modelId not available.');
|
|
1147
1148
|
if (action && !this._responseDto.actions)
|
|
1148
|
-
throw new ShapeDiverViewerSessionError(
|
|
1149
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('Session.checkAvailability: actions not available.');
|
|
1149
1150
|
const responseDtoAction = (_a = this._responseDto.actions) === null || _a === void 0 ? void 0 : _a.find(a => a.name === action);
|
|
1150
1151
|
if (action && !responseDtoAction)
|
|
1151
|
-
throw new ShapeDiverViewerSessionError(`Session.checkAvailability: action ${action} not available.`);
|
|
1152
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError(`Session.checkAvailability: action ${action} not available.`);
|
|
1153
|
+
}
|
|
1154
|
+
cleanExportParameters(parameters) {
|
|
1155
|
+
const requestParameterSet = {};
|
|
1156
|
+
// first step, we convert all our names and displaynames to ids
|
|
1157
|
+
for (const parameterIdOrName in parameters) {
|
|
1158
|
+
// we prioritize id, then name and then displayname
|
|
1159
|
+
// if there are two parameters with the same name or displayname, we take the one that is found first (no way for us to evaluate which one the user meant)
|
|
1160
|
+
const parameterObject = Object.values(this._parameters).find(p => p.id === parameterIdOrName || p.name === parameterIdOrName || p.displayname === parameterIdOrName);
|
|
1161
|
+
// in case the key of the key value pair was neither the id, name or displayname, skip
|
|
1162
|
+
if (!parameterObject)
|
|
1163
|
+
continue;
|
|
1164
|
+
// copy into new dictionary
|
|
1165
|
+
requestParameterSet[parameterObject.id] = parameters[parameterIdOrName];
|
|
1166
|
+
}
|
|
1167
|
+
// seconds step, fill all other parameter values that are currently not set
|
|
1168
|
+
const currentParameters = this.parameterValues;
|
|
1169
|
+
for (const parameterId in currentParameters) {
|
|
1170
|
+
// if already set by input values, skip
|
|
1171
|
+
if (requestParameterSet[parameterId] !== undefined)
|
|
1172
|
+
continue;
|
|
1173
|
+
// deep copy into new dictionary
|
|
1174
|
+
requestParameterSet[parameterId] = (' ' + currentParameters[parameterId]).slice(1);
|
|
1175
|
+
}
|
|
1176
|
+
return requestParameterSet;
|
|
1152
1177
|
}
|
|
1153
1178
|
customizeInternal(cancelRequest, taskEventInfo) {
|
|
1154
1179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1163,7 +1188,7 @@ export class SessionEngine {
|
|
|
1163
1188
|
const responseDto = yield this._sdk.utils.submitAndWaitForCustomization(this._sdk, this._sessionId, parameters);
|
|
1164
1189
|
this._performanceEvaluator.endSection('sessionResponse');
|
|
1165
1190
|
if (cancelRequest())
|
|
1166
|
-
return new SessionTreeNode();
|
|
1191
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
1167
1192
|
if (parallel === false)
|
|
1168
1193
|
this.updateResponseDto(responseDto);
|
|
1169
1194
|
return parallel === false ? this.loadOutputs(cancelRequest, taskEventInfo) : this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
|
|
@@ -1171,18 +1196,18 @@ export class SessionEngine {
|
|
|
1171
1196
|
catch (e) {
|
|
1172
1197
|
yield this.handleError(e, retry);
|
|
1173
1198
|
if (cancelRequest())
|
|
1174
|
-
return new SessionTreeNode();
|
|
1199
|
+
return new SessionTreeNode_1.SessionTreeNode();
|
|
1175
1200
|
return yield this.customizeSession(parameters, cancelRequest, taskEventInfo, parallel, true);
|
|
1176
1201
|
}
|
|
1177
1202
|
});
|
|
1178
1203
|
}
|
|
1179
1204
|
handleError(e, retry = false) {
|
|
1180
1205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1181
|
-
if (isGBResponseError(e)) {
|
|
1182
|
-
if (e.error === ShapeDiverResponseErrorType.SESSION_GONE_ERROR) {
|
|
1206
|
+
if ((0, sdk_geometry_api_sdk_v2_1.isGBResponseError)(e)) {
|
|
1207
|
+
if (e.error === sdk_geometry_api_sdk_v2_1.ShapeDiverResponseErrorType.SESSION_GONE_ERROR) {
|
|
1183
1208
|
// case 1: the session is no longer available
|
|
1184
1209
|
// we try to re-initialize the session 3 times, if that does not work, we close it
|
|
1185
|
-
this._logger.warn(
|
|
1210
|
+
this._logger.warn('The session has been closed, trying to re-initialize.');
|
|
1186
1211
|
if (this._sessionId)
|
|
1187
1212
|
this._httpClient.removeDataLoading(this._sessionId);
|
|
1188
1213
|
if (this._retryCounter < 3) {
|
|
@@ -1194,6 +1219,7 @@ export class SessionEngine {
|
|
|
1194
1219
|
else {
|
|
1195
1220
|
// the retries were exceeded, we close the session
|
|
1196
1221
|
this._logger.warn('Tried to retry the connect multiple times, bearer token still not valid. Closing Session.');
|
|
1222
|
+
// eslint-disable-next-line no-empty
|
|
1197
1223
|
try {
|
|
1198
1224
|
yield this._closeOnFailure();
|
|
1199
1225
|
}
|
|
@@ -1201,7 +1227,7 @@ export class SessionEngine {
|
|
|
1201
1227
|
throw this._httpClient.convertError(e);
|
|
1202
1228
|
}
|
|
1203
1229
|
}
|
|
1204
|
-
else if (e.error === ShapeDiverResponseErrorType.JWT_VALIDATION_ERROR) {
|
|
1230
|
+
else if (e.error === sdk_geometry_api_sdk_v2_1.ShapeDiverResponseErrorType.JWT_VALIDATION_ERROR) {
|
|
1205
1231
|
// if any of the above errors occur, we try to get a new bearer token
|
|
1206
1232
|
// if we get a new one, we retry 3 times (by requiring new bearer tokens every time)
|
|
1207
1233
|
if (this._retryCounter < 3) {
|
|
@@ -1213,6 +1239,7 @@ export class SessionEngine {
|
|
|
1213
1239
|
else {
|
|
1214
1240
|
// no bearer tokens are supplied, we close the session
|
|
1215
1241
|
this._logger.warn('No retry possible, no new bearer token was supplied. Closing Session.');
|
|
1242
|
+
// eslint-disable-next-line no-empty
|
|
1216
1243
|
try {
|
|
1217
1244
|
yield this._closeOnFailure();
|
|
1218
1245
|
}
|
|
@@ -1223,6 +1250,7 @@ export class SessionEngine {
|
|
|
1223
1250
|
else {
|
|
1224
1251
|
// the retries were exceeded, we close the session
|
|
1225
1252
|
this._logger.warn('Tried to retry the connect multiple times, bearer token still not valid. Closing Session.');
|
|
1253
|
+
// eslint-disable-next-line no-empty
|
|
1226
1254
|
try {
|
|
1227
1255
|
yield this._closeOnFailure();
|
|
1228
1256
|
}
|
|
@@ -1261,14 +1289,14 @@ export class SessionEngine {
|
|
|
1261
1289
|
}
|
|
1262
1290
|
// convert parameters
|
|
1263
1291
|
if (responseDto.parameters) {
|
|
1264
|
-
for (
|
|
1292
|
+
for (const parameterId in responseDto.parameters) {
|
|
1265
1293
|
this._responseDto.parameters = this._responseDto.parameters || {};
|
|
1266
1294
|
this._responseDto.parameters[parameterId] = this._responseDto.parameters[parameterId] || responseDto.parameters[parameterId];
|
|
1267
1295
|
}
|
|
1268
1296
|
}
|
|
1269
1297
|
// convert outputs
|
|
1270
1298
|
if (responseDto.outputs) {
|
|
1271
|
-
for (
|
|
1299
|
+
for (const outputId in responseDto.outputs) {
|
|
1272
1300
|
this._responseDto.outputs = this._responseDto.outputs || {};
|
|
1273
1301
|
if ('version' in responseDto.outputs[outputId] || !(this._responseDto.outputs[outputId] && 'version' in this._responseDto.outputs[outputId]))
|
|
1274
1302
|
this._responseDto.outputs[outputId] = responseDto.outputs[outputId];
|
|
@@ -1276,32 +1304,32 @@ export class SessionEngine {
|
|
|
1276
1304
|
}
|
|
1277
1305
|
// convert exports
|
|
1278
1306
|
if (responseDto.exports) {
|
|
1279
|
-
for (
|
|
1307
|
+
for (const exportId in responseDto.exports) {
|
|
1280
1308
|
this._responseDto.exports = this._responseDto.exports || {};
|
|
1281
1309
|
if ('version' in responseDto.exports[exportId] || !(this._responseDto.exports[exportId] && 'version' in this._responseDto.exports[exportId]))
|
|
1282
1310
|
this._responseDto.exports[exportId] = responseDto.exports[exportId];
|
|
1283
1311
|
}
|
|
1284
1312
|
}
|
|
1285
1313
|
const parameterSet = {};
|
|
1286
|
-
for (
|
|
1314
|
+
for (const parameterId in this._responseDto.parameters) {
|
|
1287
1315
|
if (this.parameters[parameterId])
|
|
1288
1316
|
continue;
|
|
1289
1317
|
this._responseDto.parameters[parameterId].id = parameterId;
|
|
1290
1318
|
switch (true) {
|
|
1291
|
-
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.BOOL:
|
|
1292
|
-
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1319
|
+
case this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.BOOL:
|
|
1320
|
+
this.parameters[parameterId] = new Parameter_1.Parameter(this._responseDto.parameters[parameterId], this);
|
|
1293
1321
|
break;
|
|
1294
|
-
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.COLOR:
|
|
1295
|
-
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1322
|
+
case this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.COLOR:
|
|
1323
|
+
this.parameters[parameterId] = new Parameter_1.Parameter(this._responseDto.parameters[parameterId], this);
|
|
1296
1324
|
break;
|
|
1297
|
-
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.FILE:
|
|
1298
|
-
this.parameters[parameterId] = new FileParameter(this._responseDto.parameters[parameterId], this);
|
|
1325
|
+
case this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.FILE:
|
|
1326
|
+
this.parameters[parameterId] = new FileParameter_1.FileParameter(this._responseDto.parameters[parameterId], this);
|
|
1299
1327
|
break;
|
|
1300
|
-
case this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.EVEN || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.FLOAT || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.INT || this._responseDto.parameters[parameterId].type === PARAMETER_TYPE.ODD:
|
|
1301
|
-
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1328
|
+
case this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.EVEN || this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.FLOAT || this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.INT || this._responseDto.parameters[parameterId].type === ISessionEngine_1.PARAMETER_TYPE.ODD:
|
|
1329
|
+
this.parameters[parameterId] = new Parameter_1.Parameter(this._responseDto.parameters[parameterId], this);
|
|
1302
1330
|
break;
|
|
1303
1331
|
default:
|
|
1304
|
-
this.parameters[parameterId] = new Parameter(this._responseDto.parameters[parameterId], this);
|
|
1332
|
+
this.parameters[parameterId] = new Parameter_1.Parameter(this._responseDto.parameters[parameterId], this);
|
|
1305
1333
|
break;
|
|
1306
1334
|
}
|
|
1307
1335
|
// we don't have to do larger restrictions for this as the backend would have already thrown an error if the values were not correct
|
|
@@ -1330,23 +1358,23 @@ export class SessionEngine {
|
|
|
1330
1358
|
// store the initialization as the first parameter set in the history
|
|
1331
1359
|
if (!this.initialized)
|
|
1332
1360
|
__classPrivateFieldGet(this, _SessionEngine_parameterHistory, "f").push(parameterSet);
|
|
1333
|
-
for (
|
|
1334
|
-
if (this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.EMAIL || this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.DOWNLOAD) {
|
|
1361
|
+
for (const exportId in this._responseDto.exports) {
|
|
1362
|
+
if (this._responseDto.exports[exportId].type === sdk_geometry_api_sdk_v2_1.ShapeDiverResponseExportDefinitionType.EMAIL || this._responseDto.exports[exportId].type === sdk_geometry_api_sdk_v2_1.ShapeDiverResponseExportDefinitionType.DOWNLOAD) {
|
|
1335
1363
|
if (!this.exports[exportId]) {
|
|
1336
1364
|
this._responseDto.exports[exportId].id = exportId;
|
|
1337
|
-
this.exports[exportId] = new Export(this._responseDto.exports[exportId], this);
|
|
1365
|
+
this.exports[exportId] = new Export_1.Export(this._responseDto.exports[exportId], this);
|
|
1338
1366
|
}
|
|
1339
1367
|
else {
|
|
1340
1368
|
this.exports[exportId].updateExportDefinition(this._responseDto.exports[exportId]);
|
|
1341
1369
|
}
|
|
1342
1370
|
}
|
|
1343
1371
|
}
|
|
1344
|
-
for (
|
|
1372
|
+
for (const outputId in this._responseDto.outputs) {
|
|
1345
1373
|
if (!this.outputs[outputId]) {
|
|
1346
1374
|
this._responseDto.outputs[outputId].id = outputId;
|
|
1347
1375
|
if (this.outputsFreeze[outputId] === undefined)
|
|
1348
1376
|
this.outputsFreeze[outputId] = false;
|
|
1349
|
-
this.outputs[outputId] = new Output(this._responseDto.outputs[outputId], this);
|
|
1377
|
+
this.outputs[outputId] = new Output_1.Output(this._responseDto.outputs[outputId], this);
|
|
1350
1378
|
}
|
|
1351
1379
|
else {
|
|
1352
1380
|
this.outputs[outputId].updateOutputDefinition(this._responseDto.outputs[outputId]);
|
|
@@ -1354,5 +1382,6 @@ export class SessionEngine {
|
|
|
1354
1382
|
}
|
|
1355
1383
|
}
|
|
1356
1384
|
}
|
|
1385
|
+
exports.SessionEngine = SessionEngine;
|
|
1357
1386
|
_SessionEngine_customizationProcess = new WeakMap(), _SessionEngine_parameterHistory = new WeakMap(), _SessionEngine_parameterHistoryCall = new WeakMap(), _SessionEngine_parameterHistoryForward = new WeakMap();
|
|
1358
1387
|
//# sourceMappingURL=SessionEngine.js.map
|