@shapediver/viewer.session 3.3.3 → 3.3.6
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/SessionApi.d.ts.map +1 -1
- package/dist/implementation/SessionApi.js +8 -4
- package/dist/implementation/SessionApi.js.map +1 -1
- package/dist/implementation/parameter/DrawingParameterApi.d.ts +10 -0
- package/dist/implementation/parameter/DrawingParameterApi.d.ts.map +1 -0
- package/dist/implementation/parameter/DrawingParameterApi.js +37 -0
- package/dist/implementation/parameter/DrawingParameterApi.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/parameter/IDrawingParameterApi.d.ts +3 -0
- package/dist/interfaces/parameter/IDrawingParameterApi.d.ts.map +1 -0
- package/dist/interfaces/parameter/IDrawingParameterApi.js +3 -0
- package/dist/interfaces/parameter/IDrawingParameterApi.js.map +1 -0
- package/package.json +13 -14
- package/src/implementation/ExportApi.ts +0 -158
- package/src/implementation/OutputApi.ts +0 -178
- package/src/implementation/SessionApi.ts +0 -429
- package/src/implementation/data/OutputApiData.ts +0 -53
- package/src/implementation/data/SessionApiData.ts +0 -53
- package/src/implementation/parameter/FileParameterApi.ts +0 -34
- package/src/implementation/parameter/GumballParameterApi.ts +0 -61
- package/src/implementation/parameter/ParameterApi.ts +0 -180
- package/src/implementation/parameter/SelectionParameterApi.ts +0 -49
- package/src/index.ts +0 -258
- package/src/interfaces/IExportApi.ts +0 -29
- package/src/interfaces/IOutputApi.ts +0 -85
- package/src/interfaces/ISessionApi.ts +0 -487
- package/src/interfaces/data/IOutputApiData.ts +0 -16
- package/src/interfaces/data/ISessionApiData.ts +0 -16
- package/src/interfaces/parameter/IFileParameterApi.ts +0 -39
- package/src/interfaces/parameter/IGumballParameterApi.ts +0 -4
- package/src/interfaces/parameter/IInteractionParameterApi.ts +0 -10
- package/src/interfaces/parameter/IParameterApi.ts +0 -57
- package/src/interfaces/parameter/ISelectionParameterApi.ts +0 -4
- package/src/main.ts +0 -100
- package/tsconfig.json +0 -17
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
2
|
-
import { IOutput, ShapeDiverResponseOutputChunk, ShapeDiverResponseOutputContent } from '@shapediver/viewer.session-engine.session-engine';
|
|
3
|
-
import { IOutputApi } from '../interfaces/IOutputApi';
|
|
4
|
-
import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
5
|
-
import { OutputApiData } from './data/OutputApiData';
|
|
6
|
-
import { ShapeDiverResponseModelComputationStatus } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
7
|
-
|
|
8
|
-
export class OutputApi implements IOutputApi {
|
|
9
|
-
// #region Properties (3)
|
|
10
|
-
|
|
11
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
-
readonly #logger: Logger = Logger.instance;
|
|
13
|
-
readonly #output: IOutput;
|
|
14
|
-
|
|
15
|
-
// #endregion Properties (3)
|
|
16
|
-
|
|
17
|
-
// #region Constructors (1)
|
|
18
|
-
|
|
19
|
-
constructor(output: IOutput) {
|
|
20
|
-
this.#output = output;
|
|
21
|
-
this.#output.updateCallback = (newNode?: ITreeNode) => {
|
|
22
|
-
if (newNode && newNode.data.findIndex(d => d instanceof OutputApiData) === -1)
|
|
23
|
-
newNode.addData(new OutputApiData(this));
|
|
24
|
-
};
|
|
25
|
-
this.#output.updateCallback(this.node);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// #endregion Constructors (1)
|
|
29
|
-
|
|
30
|
-
// #region Public Getters And Setters (28)
|
|
31
|
-
|
|
32
|
-
public get bbmax(): number[] | undefined {
|
|
33
|
-
return this.#output.bbmax;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public get bbmin(): number[] | undefined {
|
|
37
|
-
return this.#output.bbmin;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public get chunks(): ShapeDiverResponseOutputChunk[] | undefined {
|
|
41
|
-
return this.#output.chunks;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public get content(): ShapeDiverResponseOutputContent[] | undefined {
|
|
45
|
-
return this.#output.content;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public get delay(): number | undefined {
|
|
49
|
-
return this.#output.delay;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public get dependency(): string[] {
|
|
53
|
-
return this.#output.dependency;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public get displayname(): string | undefined {
|
|
57
|
-
return this.#output.displayname;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public set displayname(value: string | undefined) {
|
|
61
|
-
const scope = 'displayname';
|
|
62
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'string', false);
|
|
63
|
-
this.#output.displayname = value;
|
|
64
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.displayname}.`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public get format(): string[] {
|
|
68
|
-
return this.#output.format;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public get freeze(): boolean {
|
|
72
|
-
return this.#output.freeze;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public set freeze(value: boolean) {
|
|
76
|
-
const scope = 'freeze';
|
|
77
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'boolean');
|
|
78
|
-
this.#output.freeze = value;
|
|
79
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.freeze}.`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public get hidden(): boolean {
|
|
83
|
-
return this.#output.hidden;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public set hidden(value: boolean) {
|
|
87
|
-
const scope = 'hidden';
|
|
88
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'boolean');
|
|
89
|
-
this.#output.hidden = value;
|
|
90
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.hidden}.`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public get id(): string {
|
|
94
|
-
return this.#output.id;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public get material(): string | undefined {
|
|
98
|
-
return this.#output.material;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public get msg(): string | undefined {
|
|
102
|
-
return this.#output.msg;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public get name(): string {
|
|
106
|
-
return this.#output.name;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public get node(): ITreeNode | undefined {
|
|
110
|
-
return this.#output.node;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public get order(): number | undefined {
|
|
114
|
-
return this.#output.order;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public set order(value: number | undefined) {
|
|
118
|
-
const scope = 'order';
|
|
119
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'number', false);
|
|
120
|
-
this.#output.order = value;
|
|
121
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.order}.`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public get status_collect(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
125
|
-
return this.#output.status_collect;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public get status_computation(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
129
|
-
return this.#output.status_computation;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public get tooltip(): string | undefined {
|
|
133
|
-
return this.#output.tooltip;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public set tooltip(value: string | undefined) {
|
|
137
|
-
const scope = 'tooltip';
|
|
138
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'string', false);
|
|
139
|
-
this.#output.tooltip = value;
|
|
140
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.tooltip}.`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
public get uid(): string | undefined {
|
|
144
|
-
return this.#output.uid;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public get updateCallback(): ((newNode?: ITreeNode, oldNode?: ITreeNode) => void | Promise<void>) | null {
|
|
148
|
-
return this.#output.updateCallback;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
public set updateCallback(value: ((newNode?: ITreeNode, oldNode?: ITreeNode) => void | Promise<void>) | null) {
|
|
152
|
-
const scope = 'updateCallback';
|
|
153
|
-
if (value) this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'function', false);
|
|
154
|
-
this.#output.updateCallback = async (newNode?: ITreeNode, oldNode?: ITreeNode) => {
|
|
155
|
-
if (newNode && newNode.data.findIndex(d => d instanceof OutputApiData) === -1)
|
|
156
|
-
newNode.addData(new OutputApiData(this));
|
|
157
|
-
if (value) await Promise.resolve(value(newNode, oldNode));
|
|
158
|
-
};
|
|
159
|
-
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${value}.`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public get version(): string {
|
|
163
|
-
return this.#output.version;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// #endregion Public Getters And Setters (28)
|
|
167
|
-
|
|
168
|
-
// #region Public Methods (1)
|
|
169
|
-
|
|
170
|
-
public async updateOutputContent(outputContent: ShapeDiverResponseOutputContent[], preventUpdate: boolean = false): Promise<ITreeNode | undefined> {
|
|
171
|
-
const scope = 'updateOutputContent';
|
|
172
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, outputContent, 'array');
|
|
173
|
-
this.#inputValidator.validateAndError(`OutputApi.${scope}`, preventUpdate, 'boolean');
|
|
174
|
-
return this.#output.updateOutputContent(outputContent, preventUpdate);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// #endregion Public Methods (1)
|
|
178
|
-
}
|
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
import { CreationControlCenterSession, ICreationControlCenterSession } from '@shapediver/viewer.creation-control-center.session';
|
|
2
|
-
import { ExportApi } from './ExportApi';
|
|
3
|
-
import {
|
|
4
|
-
FileParameter,
|
|
5
|
-
GumballParameter,
|
|
6
|
-
SelectionParameter,
|
|
7
|
-
SessionEngine
|
|
8
|
-
} from '@shapediver/viewer.session-engine.session-engine';
|
|
9
|
-
import { FileParameterApi } from './parameter/FileParameterApi';
|
|
10
|
-
import { GLTFConverter } from '@shapediver/viewer.data-engine.gltf-converter';
|
|
11
|
-
import { GumballParameterApi } from './parameter/GumballParameterApi';
|
|
12
|
-
import { IExportApi } from '../interfaces/IExportApi';
|
|
13
|
-
import {
|
|
14
|
-
InputValidator,
|
|
15
|
-
Logger,
|
|
16
|
-
ShapeDiverViewerSessionError,
|
|
17
|
-
StateEngine
|
|
18
|
-
} from '@shapediver/viewer.shared.services';
|
|
19
|
-
import { IOutputApi } from '../interfaces/IOutputApi';
|
|
20
|
-
import { IParameterApi } from '../interfaces/parameter/IParameterApi';
|
|
21
|
-
import { ISessionApi } from '../interfaces/ISessionApi';
|
|
22
|
-
import { ISettingsSections } from '@shapediver/viewer.shared.types';
|
|
23
|
-
import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
24
|
-
import { OutputApi } from './OutputApi';
|
|
25
|
-
import { ParameterApi } from './parameter/ParameterApi';
|
|
26
|
-
import { SelectionParameterApi } from './parameter/SelectionParameterApi';
|
|
27
|
-
import { SessionApiData } from './data/SessionApiData';
|
|
28
|
-
import { ShapeDiverRequestExport, ShapeDiverResponseDto, ShapeDiverResponseModelState } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
29
|
-
|
|
30
|
-
export class SessionApi implements ISessionApi {
|
|
31
|
-
// #region Properties (9)
|
|
32
|
-
|
|
33
|
-
readonly #creationControlCenterSession: ICreationControlCenterSession = CreationControlCenterSession.instance;
|
|
34
|
-
readonly #exports: { [key: string]: IExportApi; } = {};
|
|
35
|
-
readonly #gltfConverter: GLTFConverter = GLTFConverter.instance;
|
|
36
|
-
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
37
|
-
readonly #logger: Logger = Logger.instance;
|
|
38
|
-
readonly #outputs: { [key: string]: IOutputApi; } = {};
|
|
39
|
-
readonly #parameters: { [key: string]: IParameterApi<unknown>; } = {};
|
|
40
|
-
readonly #sessionEngine: SessionEngine;
|
|
41
|
-
readonly #stateEngine: StateEngine = StateEngine.instance;
|
|
42
|
-
|
|
43
|
-
// #endregion Properties (9)
|
|
44
|
-
|
|
45
|
-
// #region Constructors (1)
|
|
46
|
-
|
|
47
|
-
constructor(sessionEngine: SessionEngine) {
|
|
48
|
-
this.#sessionEngine = sessionEngine;
|
|
49
|
-
if (!this.#sessionEngine.initialized)
|
|
50
|
-
throw new ShapeDiverViewerSessionError('Session could not be initialized.');
|
|
51
|
-
|
|
52
|
-
this.#sessionEngine.updateCallback = (newNode?: ITreeNode) => {
|
|
53
|
-
if (!newNode) return;
|
|
54
|
-
|
|
55
|
-
if (newNode.data.findIndex(d => d instanceof SessionApiData) === -1)
|
|
56
|
-
newNode.addData(new SessionApiData(this));
|
|
57
|
-
};
|
|
58
|
-
this.#sessionEngine.updateCallback(this.node, this.node);
|
|
59
|
-
|
|
60
|
-
for (const o in this.#sessionEngine.outputs)
|
|
61
|
-
this.#outputs[o] = new OutputApi(this.#sessionEngine.outputs[o]);
|
|
62
|
-
|
|
63
|
-
for (const e in this.#sessionEngine.exports)
|
|
64
|
-
this.#exports[e] = new ExportApi(this.#sessionEngine.exports[e]);
|
|
65
|
-
|
|
66
|
-
for (const p in this.#sessionEngine.parameters) {
|
|
67
|
-
if (this.#sessionEngine.parameters[p] instanceof FileParameter) {
|
|
68
|
-
this.#parameters[p] = new FileParameterApi(<FileParameter>this.#sessionEngine.parameters[p]);
|
|
69
|
-
} else if (this.#sessionEngine.parameters[p] instanceof SelectionParameter) {
|
|
70
|
-
this.#parameters[p] = new SelectionParameterApi(<SelectionParameter>this.#sessionEngine.parameters[p]);
|
|
71
|
-
} else if (this.#sessionEngine.parameters[p] instanceof GumballParameter) {
|
|
72
|
-
this.#parameters[p] = new GumballParameterApi(<GumballParameter>this.#sessionEngine.parameters[p]);
|
|
73
|
-
} else {
|
|
74
|
-
this.#parameters[p] = new ParameterApi(this.#sessionEngine.parameters[p]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// #endregion Constructors (1)
|
|
80
|
-
|
|
81
|
-
// #region Public Getters And Setters (29)
|
|
82
|
-
|
|
83
|
-
public get automaticSceneUpdate(): boolean {
|
|
84
|
-
return this.#sessionEngine.automaticSceneUpdate;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public set automaticSceneUpdate(value: boolean) {
|
|
88
|
-
const scope = 'automaticSceneUpdate';
|
|
89
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'boolean');
|
|
90
|
-
this.#sessionEngine.automaticSceneUpdate = value;
|
|
91
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public get commitParameters(): boolean {
|
|
95
|
-
return this.#sessionEngine.settingsEngine.general.commitParameters;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public set commitParameters(value: boolean) {
|
|
99
|
-
const scope = 'commitParameters';
|
|
100
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'boolean');
|
|
101
|
-
this.#sessionEngine.settingsEngine.general.commitParameters = value;
|
|
102
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public get commitSettings(): boolean {
|
|
106
|
-
return this.#sessionEngine.settingsEngine.general.commitSettings;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public set commitSettings(value: boolean) {
|
|
110
|
-
const scope = 'commitSettings';
|
|
111
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'boolean');
|
|
112
|
-
this.#sessionEngine.settingsEngine.general.commitSettings = value;
|
|
113
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public get customizeOnParameterChange(): boolean {
|
|
117
|
-
return this.#sessionEngine.customizeOnParameterChange;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public set customizeOnParameterChange(value: boolean) {
|
|
121
|
-
const scope = 'customizeOnParameterChange';
|
|
122
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'boolean');
|
|
123
|
-
this.#sessionEngine.customizeOnParameterChange = value;
|
|
124
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public get excludeViewports(): string[] {
|
|
128
|
-
return this.#sessionEngine.excludeViewports;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public set excludeViewports(value: string[]) {
|
|
132
|
-
const scope = 'excludeViewports';
|
|
133
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'stringArray');
|
|
134
|
-
this.#sessionEngine.excludeViewports = value;
|
|
135
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public get exports(): { [key: string]: IExportApi; } {
|
|
139
|
-
return this.#exports;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public get guid(): string | undefined {
|
|
143
|
-
return this.#sessionEngine.guid;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public get id(): string {
|
|
147
|
-
return this.#sessionEngine.id;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public get initialized(): boolean {
|
|
151
|
-
return this.#sessionEngine.initialized;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public get jwtToken(): string | undefined {
|
|
155
|
-
return this.#sessionEngine.jwtToken;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public get loadSdtf(): boolean {
|
|
159
|
-
return this.#sessionEngine.loadSdtf;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public set loadSdtf(value: boolean) {
|
|
163
|
-
const scope = 'loadSdtf';
|
|
164
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'boolean');
|
|
165
|
-
this.#sessionEngine.loadSdtf = value;
|
|
166
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
public get modelState(): ShapeDiverResponseModelState | undefined {
|
|
170
|
-
return this.#sessionEngine.modelState;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
public get modelViewUrl(): string {
|
|
174
|
-
return this.#sessionEngine.modelViewUrl;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
public get node(): ITreeNode {
|
|
178
|
-
return this.#sessionEngine.node;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
public get outputs(): { [key: string]: IOutputApi; } {
|
|
182
|
-
return this.#outputs;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
public get parameterDefaultValues(): { [key: string]: unknown; } {
|
|
186
|
-
const parameterDefaultValues: { [key: string]: unknown; } = {};
|
|
187
|
-
for (const key in this.parameters)
|
|
188
|
-
parameterDefaultValues[key] = this.parameters[key].defval;
|
|
189
|
-
return parameterDefaultValues;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public get parameterSessionValues(): { [key: string]: unknown; } {
|
|
193
|
-
const parameterSessionValues: { [key: string]: unknown; } = {};
|
|
194
|
-
for (const key in this.parameters)
|
|
195
|
-
parameterSessionValues[key] = this.parameters[key].sessionValue;
|
|
196
|
-
return parameterSessionValues;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
public get parameterValues(): { [key: string]: unknown; } {
|
|
200
|
-
const parameterValues: { [key: string]: unknown; } = {};
|
|
201
|
-
for (const key in this.parameters)
|
|
202
|
-
parameterValues[key] = this.parameters[key].value;
|
|
203
|
-
return parameterValues;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public get parameters(): { [key: string]: IParameterApi<unknown>; } {
|
|
207
|
-
return this.#parameters;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public get refreshJwtToken(): (() => Promise<string>) | undefined {
|
|
211
|
-
return this.#sessionEngine.refreshJwtToken;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
public set refreshJwtToken(value: (() => Promise<string>) | undefined) {
|
|
215
|
-
const scope = 'refreshJwtToken';
|
|
216
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'function', false);
|
|
217
|
-
this.#sessionEngine.refreshJwtToken = value;
|
|
218
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
public get ticket(): string | undefined {
|
|
222
|
-
return this.#sessionEngine.ticket;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
public get updateCallback(): ((newNode: ITreeNode, oldNode: ITreeNode) => void | Promise<void>) | null {
|
|
226
|
-
return this.#sessionEngine.updateCallback;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
public set updateCallback(value: ((newNode: ITreeNode, oldNode: ITreeNode) => void | Promise<void>) | null) {
|
|
230
|
-
const scope = 'updateCallback';
|
|
231
|
-
if (value) this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'function', false);
|
|
232
|
-
this.#sessionEngine.updateCallback = async (newNode: ITreeNode, oldNode: ITreeNode) => {
|
|
233
|
-
if (newNode.data.findIndex(d => d instanceof SessionApiData) === -1)
|
|
234
|
-
newNode.addData(new SessionApiData(this));
|
|
235
|
-
if (value) await Promise.resolve(value(newNode, oldNode));
|
|
236
|
-
};
|
|
237
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was updated to ${value}.`);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// #endregion Public Getters And Setters (29)
|
|
241
|
-
|
|
242
|
-
// #region Public Methods (30)
|
|
243
|
-
|
|
244
|
-
public applySettings(response: ShapeDiverResponseDto, sections?: ISettingsSections): Promise<void> {
|
|
245
|
-
const scope = 'applySettings';
|
|
246
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, response, 'object');
|
|
247
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, sections, 'object', false);
|
|
248
|
-
return this.#creationControlCenterSession.applySettings(this.id, response, sections);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
public canGoBack(): boolean {
|
|
252
|
-
return this.#sessionEngine.canGoBack();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
public canGoForward(): boolean {
|
|
256
|
-
return this.#sessionEngine.canGoForward();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
public cancelCustomization(): void {
|
|
260
|
-
this.#sessionEngine.cancelCustomization();
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
public async close(): Promise<void> {
|
|
264
|
-
return await this.#creationControlCenterSession.closeSessionEngine(this.id);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
public async convertToGlTF(convertForAr: boolean = false): Promise<Blob> {
|
|
268
|
-
for (const r in this.#stateEngine.viewportEngines)
|
|
269
|
-
this.#stateEngine.viewportEngines[r]?.update('SessionApi.convertToGlTF');
|
|
270
|
-
|
|
271
|
-
const result = await this.#gltfConverter.convert(this.node, convertForAr);
|
|
272
|
-
return new Blob([result], { type: 'application/octet-stream' });
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
public async createModelState(parameterValues?: { [key: string]: unknown; }, omitSessionParameterValues?: boolean, image?: (() => string) | string | Blob | File, data?: Record<string, any>, arScene?: (() => Promise<ArrayBuffer>) | ArrayBuffer | (() => Promise<Blob>) | Blob | File): Promise<string> { const scope = 'createModelState';
|
|
276
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, parameterValues, 'object', false);
|
|
277
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, omitSessionParameterValues, 'boolean', false);
|
|
278
|
-
return await this.#sessionEngine.createModelState(parameterValues, omitSessionParameterValues, image, data, arScene);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
public customize(parameterValues?: { [key: string]: unknown; }, force: boolean = false, waitForViewportUpdate: boolean = false): Promise<ITreeNode> {
|
|
282
|
-
const scope = 'customize';
|
|
283
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, parameterValues, 'object', false);
|
|
284
|
-
|
|
285
|
-
// if there are parameter values specified, we set them directly
|
|
286
|
-
// the validation happens in the setter of the ParameterApi
|
|
287
|
-
if (parameterValues)
|
|
288
|
-
for (const p in parameterValues)
|
|
289
|
-
this.parameters[p].value = parameterValues[p];
|
|
290
|
-
|
|
291
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, force, 'boolean', false);
|
|
292
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, waitForViewportUpdate, 'boolean', false);
|
|
293
|
-
return this.#sessionEngine.customize(force, waitForViewportUpdate);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
public customizeParallel(parameterValues: { [key: string]: unknown; }): Promise<ITreeNode> {
|
|
297
|
-
const scope = 'customizeParallel';
|
|
298
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, parameterValues, 'object');
|
|
299
|
-
return this.#sessionEngine.customizeParallel(parameterValues) as Promise<ITreeNode>;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
public customizeResult(parameterValues: { [key: string]: unknown; }): Promise<ShapeDiverResponseDto> {
|
|
303
|
-
const scope = 'customizeResult';
|
|
304
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, parameterValues, 'object');
|
|
305
|
-
return this.#sessionEngine.customizeParallel(parameterValues, false) as Promise<ShapeDiverResponseDto>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
public getExportById(id: string): IExportApi | null {
|
|
309
|
-
const scope = 'getExportById';
|
|
310
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, id, 'string');
|
|
311
|
-
return this.#exports[id];
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
public getExportByName(name: string): IExportApi[] {
|
|
315
|
-
const scope = 'getExportByName';
|
|
316
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, name, 'string');
|
|
317
|
-
return Object.values(this.#exports).filter(e => e.name === name);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public getExportByType(type: string): IExportApi[] {
|
|
321
|
-
const scope = 'getExportByType';
|
|
322
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, type, 'string');
|
|
323
|
-
return Object.values(this.#exports).filter(e => e.type === type);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
public getOutputByFormat(format: string): IOutputApi[] {
|
|
327
|
-
const scope = 'getOutputByFormat';
|
|
328
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, format, 'string');
|
|
329
|
-
return Object.values(this.#outputs).filter(o => o.format.includes(format));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
public getOutputById(id: string): IOutputApi | null {
|
|
333
|
-
const scope = 'getOutputById';
|
|
334
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, id, 'string');
|
|
335
|
-
return this.#outputs[id];
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public getOutputByName(name: string): IOutputApi[] {
|
|
339
|
-
const scope = 'getOutputByName';
|
|
340
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, name, 'string');
|
|
341
|
-
return Object.values(this.#outputs).filter(o => o.name === name);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
public getParameterById(id: string): IParameterApi<unknown> | null {
|
|
345
|
-
const scope = 'getParameterById';
|
|
346
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, id, 'string');
|
|
347
|
-
return this.#parameters[id];
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
public getParameterByName(name: string): IParameterApi<unknown>[] {
|
|
351
|
-
const scope = 'getParameterByName';
|
|
352
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, name, 'string');
|
|
353
|
-
return Object.values(this.#parameters).filter(p => p.name === name);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
public getParameterByType(type: string): IParameterApi<unknown>[] {
|
|
357
|
-
const scope = 'getParameterByType';
|
|
358
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, type, 'string');
|
|
359
|
-
return Object.values(this.#parameters).filter(p => p.type === type);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
public goBack(): Promise<ITreeNode> {
|
|
363
|
-
return this.#sessionEngine.goBack();
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
public goForward(): Promise<ITreeNode> {
|
|
367
|
-
return this.#sessionEngine.goForward();
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
public async loadCachedOutputs(outputs: { [key: string]: string; }): Promise<{ [key: string]: ITreeNode | undefined }> {
|
|
371
|
-
return await this.#sessionEngine.loadCachedOutputsParallel(outputs);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
public async requestExports(body: ShapeDiverRequestExport, loadOutputs?: boolean, maxWaitMsec?: number): Promise<ShapeDiverResponseDto> {
|
|
375
|
-
const scope = 'requestExports';
|
|
376
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, body, 'object');
|
|
377
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, loadOutputs, 'boolean', false);
|
|
378
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, maxWaitMsec, 'number', false);
|
|
379
|
-
return this.#sessionEngine.requestExports(body, loadOutputs, maxWaitMsec);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
public resetParameterValues(force: boolean = false, waitForViewportUpdate: boolean = false): Promise<ITreeNode> {
|
|
383
|
-
const scope = 'resetParameterValues';
|
|
384
|
-
for (const p in this.parameters)
|
|
385
|
-
this.parameters[p].value = this.parameters[p].defval;
|
|
386
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, force, 'boolean', false);
|
|
387
|
-
return this.#sessionEngine.customize(force, waitForViewportUpdate);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
public resetSettings(sections?: ISettingsSections): Promise<void> {
|
|
391
|
-
const scope = 'applySettings';
|
|
392
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, sections, 'object', false);
|
|
393
|
-
return this.#creationControlCenterSession.resetSettings(this.id, sections);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
public saveDefaultParameterValues(): Promise<boolean> {
|
|
397
|
-
return this.#sessionEngine.saveDefaultParameterValues();
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
public saveSettings(viewportId?: string): Promise<boolean> {
|
|
401
|
-
const scope = 'saveDefaultParameterValues';
|
|
402
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, viewportId, 'string', false);
|
|
403
|
-
return this.#creationControlCenterSession.saveSettings(this.id, viewportId);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
public saveUiProperties(): Promise<boolean> {
|
|
407
|
-
return this.#sessionEngine.saveUiProperties();
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
public async setJwtToken(value: string): Promise<void> {
|
|
411
|
-
const scope = 'setJwtToken';
|
|
412
|
-
this.#inputValidator.validateAndError(`SessionApi.${scope}`, value, 'string', false);
|
|
413
|
-
await this.#sessionEngine.setJwtToken(value);
|
|
414
|
-
this.#logger.debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
public updateOutputs(waitForViewportUpdate: boolean = false): Promise<ITreeNode> {
|
|
419
|
-
return this.#sessionEngine.updateOutputs(undefined, waitForViewportUpdate);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
public async uploadFileParameters(values: { [key: string]: string | File | Blob }): Promise<{ [key: string]: string }> {
|
|
423
|
-
const fileParameters: { [key: string]: string | File | Blob } = values || {};
|
|
424
|
-
const fileParameterIds = await this.#sessionEngine.uploadFileParameters(fileParameters);
|
|
425
|
-
return fileParameterIds;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// #endregion Public Methods (30)
|
|
429
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AbstractTreeNodeData } from '@shapediver/viewer.shared.node-tree';
|
|
2
|
-
import { IOutputApi } from '../../interfaces/IOutputApi';
|
|
3
|
-
import { IOutputApiData } from '../../interfaces/data/IOutputApiData';
|
|
4
|
-
|
|
5
|
-
export class OutputApiData extends AbstractTreeNodeData implements IOutputApiData {
|
|
6
|
-
// #region Properties (1)
|
|
7
|
-
|
|
8
|
-
#api: IOutputApi;
|
|
9
|
-
|
|
10
|
-
// #endregion Properties (1)
|
|
11
|
-
|
|
12
|
-
// #region Constructors (1)
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Creates a OutputApi data node.
|
|
16
|
-
*
|
|
17
|
-
* @param _data the data as key- value pairs
|
|
18
|
-
* @param id the id
|
|
19
|
-
*/
|
|
20
|
-
constructor(
|
|
21
|
-
api: IOutputApi,
|
|
22
|
-
id?: string,
|
|
23
|
-
version?: string
|
|
24
|
-
) {
|
|
25
|
-
super(id, version);
|
|
26
|
-
this.#api = api;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// #endregion Constructors (1)
|
|
30
|
-
|
|
31
|
-
// #region Public Getters And Setters (2)
|
|
32
|
-
|
|
33
|
-
public get api(): IOutputApi {
|
|
34
|
-
return this.#api;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public set api(value: IOutputApi) {
|
|
38
|
-
this.#api = value;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// #endregion Public Getters And Setters (2)
|
|
42
|
-
|
|
43
|
-
// #region Public Methods (1)
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Clones the scene graph data.
|
|
47
|
-
*/
|
|
48
|
-
public clone(): IOutputApiData {
|
|
49
|
-
return new OutputApiData(this.api, this.id, this.version);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// #endregion Public Methods (1)
|
|
53
|
-
}
|