@shapediver/viewer.session 3.3.4 → 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,57 +0,0 @@
|
|
|
1
|
-
import { ShapeDiverResponseParameter } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The api for a parameter of a corresponding [session]{@link ISessionApi}.
|
|
5
|
-
*
|
|
6
|
-
* Parameters represent the channels through which data can be input into the model
|
|
7
|
-
* represented by a session.
|
|
8
|
-
*
|
|
9
|
-
* The current value can be changed by setting the {@link value} property.
|
|
10
|
-
*/
|
|
11
|
-
export interface IParameterApi<T> extends ShapeDiverResponseParameter {
|
|
12
|
-
// #region Properties (2)
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The value that corresponds to the latest successful call to {@link ISessionApi.customize}.
|
|
16
|
-
* This property will be updated immediately before {@link ISessionApi.customize} returns.
|
|
17
|
-
*/
|
|
18
|
-
sessionValue: T | string;
|
|
19
|
-
/**
|
|
20
|
-
* The current value.
|
|
21
|
-
*
|
|
22
|
-
* Validation happens immediately when setting this property. An error will be thrown in case
|
|
23
|
-
* validation fails. Use {@link isValid} to test whether a value passes validation.
|
|
24
|
-
*
|
|
25
|
-
* In case {@link ISessionApi.automaticSceneUpdate} is true, setting the value will immediately
|
|
26
|
-
* trigger a customization (see {@link ISessionApi.customize}).
|
|
27
|
-
*/
|
|
28
|
-
value: T | string;
|
|
29
|
-
|
|
30
|
-
// #endregion Properties (2)
|
|
31
|
-
|
|
32
|
-
// #region Public Methods (4)
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Evaluates if a given value is valid for this parameter.
|
|
36
|
-
*
|
|
37
|
-
* @param value the value to evaluate
|
|
38
|
-
* @param throwError if true, an error is thrown if validation does not pass (default: false)
|
|
39
|
-
*/
|
|
40
|
-
isValid(value: unknown, throwError?: boolean): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Resets the value to the default value.
|
|
43
|
-
*/
|
|
44
|
-
resetToDefaultValue(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Resets the value to {@link sessionValue}.
|
|
47
|
-
*/
|
|
48
|
-
resetToSessionValue(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the current value as a string, or attempts to stringify a given value if provided.
|
|
51
|
-
*
|
|
52
|
-
* @param value the value to stringify
|
|
53
|
-
*/
|
|
54
|
-
stringify(value?: unknown): string;
|
|
55
|
-
|
|
56
|
-
// #endregion Public Methods (4)
|
|
57
|
-
}
|
package/src/main.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { CreationControlCenterSession, ICreationControlCenterSession, SessionCreationDefinition } from '@shapediver/viewer.creation-control-center.session';
|
|
2
|
-
import { InputValidator, Logger, ShapeDiverViewerSessionError } from '@shapediver/viewer.shared.services';
|
|
3
|
-
import { ISessionApi } from './interfaces/ISessionApi';
|
|
4
|
-
import { SessionApi } from './implementation/SessionApi';
|
|
5
|
-
import { SessionEngine } from '@shapediver/viewer.session-engine.session-engine';
|
|
6
|
-
import { showConsoleMessage } from '@shapediver/viewer.api.general';
|
|
7
|
-
|
|
8
|
-
const creationControlCenterSession: ICreationControlCenterSession = CreationControlCenterSession.instance;
|
|
9
|
-
const inputValidator: InputValidator = InputValidator.instance;
|
|
10
|
-
const logger: Logger = Logger.instance;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The sessions that are currently being used.
|
|
14
|
-
*/
|
|
15
|
-
export const sessions: { [key: string]: ISessionApi; } = {};
|
|
16
|
-
|
|
17
|
-
// Whenever a session or viewport is added or removed, this update is called.
|
|
18
|
-
creationControlCenterSession.updateSessions = (
|
|
19
|
-
sessionEngines: { [key: string]: SessionEngine; }
|
|
20
|
-
) => {
|
|
21
|
-
for (const s in sessionEngines)
|
|
22
|
-
if (!sessions[s])
|
|
23
|
-
sessions[s] = new SessionApi(sessionEngines[s]);
|
|
24
|
-
|
|
25
|
-
for (const s in sessions)
|
|
26
|
-
if (!sessionEngines[s])
|
|
27
|
-
delete sessions[s];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Create and initialize a session with a model hosted on a
|
|
32
|
-
* {@link https://help.shapediver.com/doc/Geometry-Backend.1863942173.html|ShapeDiver Geometry Backend},
|
|
33
|
-
* using the provided ticket/guid and modelViewUrl.
|
|
34
|
-
* Returns a session api object allowing to control the session.
|
|
35
|
-
*
|
|
36
|
-
* A JWT can be specified for authorizing the API calls to the Geometry Backend.
|
|
37
|
-
* The model's settings on the Geometry Backend might require a JWT to be provided.
|
|
38
|
-
*
|
|
39
|
-
* By default the outputs of the model for its default parameter values will be loaded.
|
|
40
|
-
*
|
|
41
|
-
* An optional identifier for the session can be provided. This identifier can be used to retrieve the
|
|
42
|
-
* api object from {@link sessions}. In case no identifier is provided, a unique one will be generated.
|
|
43
|
-
*
|
|
44
|
-
* @param properties.ticket The ticket for direct embedding of the model represented by the session. This identifies the model on the Geometry Backend. If no ticket was provided, a {@link guid} has to be provided instead.
|
|
45
|
-
* @param properties.guid The geometry backend model id (guid). This identifies the model on the Geometry Backend. A {@link jwtToken} is needed for authentication. If no guid was provided, a {@link ticket} has to be provided instead.
|
|
46
|
-
* @param properties.modelViewUrl The modelViewUrl of the {@link https://help.shapediver.com/doc/Geometry-Backend.1863942173.html|ShapeDiver Geometry Backend} hosting the model.
|
|
47
|
-
* @param properties.jwtToken The JWT to use for authorizing the API calls to the Geometry Backend.
|
|
48
|
-
* @param properties.id The unique identifier to use for the session.
|
|
49
|
-
* @param properties.waitForOutputs Option to wait for the outputs to be loaded, or return immediately after creation of the session. (default: true)
|
|
50
|
-
* @param properties.loadOutputs Option to load the outputs, or not load them until the first call of {@link ISession.customize}. (default: true)
|
|
51
|
-
* @param properties.loadSdtf Option to load the SDTF data. The data is not loaded by default as it can be quite large. (default: false)
|
|
52
|
-
* @param properties.excludeViewports Option to exclude some viewports from the start. Can be accessed via {@link ISession.excludeViewports}.
|
|
53
|
-
* @param properties.initialParameterValues The initial set of parameter values to use. Map from parameter id to parameter value. The default value will be used for any parameter not specified.
|
|
54
|
-
* @param properties.allowOutputLoading Option to allow the outputs to be loaded, or to prevent them from being loaded. (default: true)
|
|
55
|
-
* @param properties.modelStateId The optional model state id to use for the session. If not provided, no model state will be loaded.
|
|
56
|
-
* @param properties.modelStateValidationMode The optional model state validation mode to use for the session. If not provided, the default validation mode of the Geometry SDK will be used.
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
export const createSession = async (properties: SessionCreationDefinition): Promise<ISessionApi> => {
|
|
60
|
-
showConsoleMessage();
|
|
61
|
-
|
|
62
|
-
logger.debug(`createSession: Creating and initializing session with properties ${JSON.stringify(properties)}.`);
|
|
63
|
-
// input validation
|
|
64
|
-
inputValidator.validateAndError('createSession', properties, 'object');
|
|
65
|
-
inputValidator.validateAndError('createSession', properties.ticket, 'string', false);
|
|
66
|
-
inputValidator.validateAndError('createSession', properties.guid, 'string', false);
|
|
67
|
-
inputValidator.validateAndError('createSession', properties.modelViewUrl, 'string');
|
|
68
|
-
inputValidator.validateAndError('createSession', properties.jwtToken, 'string', false);
|
|
69
|
-
inputValidator.validateAndError('createSession', properties.id, 'string', false);
|
|
70
|
-
inputValidator.validateAndError('createSession', properties.waitForOutputs, 'boolean', false);
|
|
71
|
-
inputValidator.validateAndError('createSession', properties.loadOutputs, 'boolean', false);
|
|
72
|
-
inputValidator.validateAndError('createSession', properties.loadSdtf, 'boolean', false);
|
|
73
|
-
inputValidator.validateAndError('createSession', properties.excludeViewports, 'stringArray', false);
|
|
74
|
-
inputValidator.validateAndError('createSession', properties.initialParameterValues, 'object', false);
|
|
75
|
-
inputValidator.validateAndError('createSession', properties.allowOutputLoading, 'boolean', false);
|
|
76
|
-
inputValidator.validateAndError('createSession', properties.modelStateId, 'string', false);
|
|
77
|
-
inputValidator.validateAndError('createSession', properties.modelStateValidationMode, 'boolean', false);
|
|
78
|
-
if (properties.initialParameterValues)
|
|
79
|
-
for (const p in properties.initialParameterValues)
|
|
80
|
-
inputValidator.validateAndError('createSession', properties.initialParameterValues[p], 'string');
|
|
81
|
-
|
|
82
|
-
// we either expect a ticket or guid + jwtToken, error if we get both
|
|
83
|
-
if (properties.ticket !== undefined && properties.guid !== undefined)
|
|
84
|
-
throw new ShapeDiverViewerSessionError('createSession: A ticket and a guid were provided for the session creation. Please only provide one or the other. The session was not created.');
|
|
85
|
-
|
|
86
|
-
// we either expect a ticket or guid + jwtToken, error if we get none
|
|
87
|
-
if (properties.ticket === undefined && properties.guid === undefined)
|
|
88
|
-
throw new ShapeDiverViewerSessionError('createSession: Neither a ticket nor a guid were provided for the session creation. Please provide one or the other. The session was not created.');
|
|
89
|
-
|
|
90
|
-
// we either expect a guid + jwtToken, error if the jwtToken is missing
|
|
91
|
-
if (properties.guid !== undefined && properties.jwtToken === undefined)
|
|
92
|
-
throw new ShapeDiverViewerSessionError('createSession: When creating a session with a guid, a jwtToken is required, please provide one. The session was not created.');
|
|
93
|
-
|
|
94
|
-
if (properties.waitForOutputs === undefined) properties.waitForOutputs = true;
|
|
95
|
-
if (properties.loadOutputs === undefined) properties.loadOutputs = true;
|
|
96
|
-
|
|
97
|
-
const sessionEngine = await creationControlCenterSession.createSessionEngine(properties);
|
|
98
|
-
sessions[sessionEngine.id] = new SessionApi(sessionEngine);
|
|
99
|
-
return sessions[sessionEngine.id];
|
|
100
|
-
};
|
package/tsconfig.json
DELETED