@shapediver/viewer.session
Version:
This is the npm package for the ShapeDiver Viewer Session API. For more information on ShapeDiver, please visit our [homepage](https://shapediver.com/).
554 lines • 37.4 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _SessionApi_creationControlCenterSession, _SessionApi_exports, _SessionApi_gltfConverter, _SessionApi_inputValidator, _SessionApi_logger, _SessionApi_outputs, _SessionApi_parameters, _SessionApi_sessionEngine, _SessionApi_stateEngine;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSessionApi = exports.SessionApi = void 0;
const viewer_creation_control_center_session_1 = require("@shapediver/viewer.creation-control-center.session");
const viewer_data_engine_gltf_converter_1 = require("@shapediver/viewer.data-engine.gltf-converter");
const viewer_session_engine_session_engine_1 = require("@shapediver/viewer.session-engine.session-engine");
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
const SessionApiData_1 = require("./data/SessionApiData");
const ExportApi_1 = require("./ExportApi");
const OutputApi_1 = require("./OutputApi");
const DraggingParameterApi_1 = require("./parameter/DraggingParameterApi");
const DrawingParameterApi_1 = require("./parameter/DrawingParameterApi");
const FileParameterApi_1 = require("./parameter/FileParameterApi");
const GumballParameterApi_1 = require("./parameter/GumballParameterApi");
const ParameterApi_1 = require("./parameter/ParameterApi");
const SelectionParameterApi_1 = require("./parameter/SelectionParameterApi");
class SessionApi {
// #endregion Properties (9)
// #region Constructors (1)
constructor(sessionEngine) {
// #region Properties (9)
_SessionApi_creationControlCenterSession.set(this, viewer_creation_control_center_session_1.CreationControlCenterSession.instance);
_SessionApi_exports.set(this, {});
_SessionApi_gltfConverter.set(this, viewer_data_engine_gltf_converter_1.GLTFConverter.instance);
_SessionApi_inputValidator.set(this, viewer_shared_services_1.InputValidator.instance);
_SessionApi_logger.set(this, viewer_shared_services_1.Logger.instance);
_SessionApi_outputs.set(this, {});
_SessionApi_parameters.set(this, {});
_SessionApi_sessionEngine.set(this, void 0);
_SessionApi_stateEngine.set(this, viewer_shared_services_1.StateEngine.instance);
__classPrivateFieldSet(this, _SessionApi_sessionEngine, sessionEngine, "f");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").initialized)
throw new viewer_shared_services_1.ShapeDiverViewerSessionError("Session could not be initialized.");
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").updateCallback = (newNode) => {
if (!newNode)
return;
if (newNode.data.findIndex((d) => d instanceof SessionApiData_1.SessionApiData) ===
-1)
newNode.addData(new SessionApiData_1.SessionApiData(this));
};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").updateCallback(this.node, this.node);
for (const o in __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").outputs)
__classPrivateFieldGet(this, _SessionApi_outputs, "f")[o] = new OutputApi_1.OutputApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").outputs[o]);
for (const e in __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").exports)
__classPrivateFieldGet(this, _SessionApi_exports, "f")[e] = new ExportApi_1.ExportApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").exports[e]);
for (const p in __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters) {
if (__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p] instanceof viewer_session_engine_session_engine_1.FileParameter) {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new FileParameterApi_1.FileParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
else if (__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p] instanceof viewer_session_engine_session_engine_1.SelectionParameter) {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new SelectionParameterApi_1.SelectionParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
else if (__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p] instanceof viewer_session_engine_session_engine_1.GumballParameter) {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new GumballParameterApi_1.GumballParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
else if (__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p] instanceof viewer_session_engine_session_engine_1.DrawingParameter) {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new DrawingParameterApi_1.DrawingParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
else if (__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p] instanceof viewer_session_engine_session_engine_1.DraggingParameter) {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new DraggingParameterApi_1.DraggingParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
else {
__classPrivateFieldGet(this, _SessionApi_parameters, "f")[p] = new ParameterApi_1.ParameterApi(__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").parameters[p]);
}
}
}
// #endregion Constructors (1)
// #region Public Getters And Setters (30)
get automaticSceneUpdate() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").automaticSceneUpdate;
}
set automaticSceneUpdate(value) {
const scope = "automaticSceneUpdate";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").automaticSceneUpdate = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get parametersCommit() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.parametersCommit;
}
set parametersCommit(value) {
const scope = "parametersCommit";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.parametersCommit =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get parametersDisable() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.parametersDisable;
}
set parametersDisable(value) {
const scope = "parametersDisable";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.parametersDisable =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideDataOutputs() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideDataOutputs;
}
set hideDataOutputs(value) {
const scope = "hideDataOutputs";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideDataOutputs =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideDataOutputsIframe() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideDataOutputsIframe;
}
set hideDataOutputsIframe(value) {
const scope = "hideDataOutputsIframe";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideDataOutputsIframe =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideDesktopClients() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideDesktopClients;
}
set hideDesktopClients(value) {
const scope = "hideDesktopClients";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideDesktopClients =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideExports() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideExports;
}
set hideExports(value) {
const scope = "hideExports";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideExports = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideExportsIframe() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideExportsIframe;
}
set hideExportsIframe(value) {
const scope = "hideExportsIframe";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideExportsIframe =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideSavedStates() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideSavedStates;
}
set hideSavedStates(value) {
const scope = "hideSavedStates";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideSavedStates =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideSavedStatesIframe() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideSavedStatesIframe;
}
set hideSavedStatesIframe(value) {
const scope = "hideSavedStatesIframe";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideSavedStatesIframe =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideAttributeVisualization() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideAttributeVisualization;
}
set hideAttributeVisualization(value) {
const scope = "hideAttributeVisualization";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideAttributeVisualization =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideAttributeVisualizationIframe() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideAttributeVisualizationIframe;
}
set hideAttributeVisualizationIframe(value) {
const scope = "hideAttributeVisualizationIframe";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideAttributeVisualizationIframe =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideJsonMenu() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideJsonMenu;
}
set hideJsonMenu(value) {
const scope = "hideJsonMenu";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideJsonMenu = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get hideJsonMenuIframe() {
var _a;
return (_a = __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration) === null || _a === void 0 ? void 0 : _a.hideJsonMenuIframe;
}
set hideJsonMenuIframe(value) {
const scope = "hideJsonMenuIframe";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
if (!__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration)
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration = {};
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").settingsEngine.configuration.hideJsonMenuIframe =
value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get customizeOnParameterChange() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customizeOnParameterChange;
}
set customizeOnParameterChange(value) {
const scope = "customizeOnParameterChange";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customizeOnParameterChange = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get excludeViewports() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").excludeViewports;
}
set excludeViewports(value) {
const scope = "excludeViewports";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "stringArray");
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").excludeViewports = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get exports() {
return __classPrivateFieldGet(this, _SessionApi_exports, "f");
}
get guid() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").guid;
}
get hasStoredSettings() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").hasStoredSettings;
}
get id() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").id;
}
get initialized() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").initialized;
}
get jwtToken() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").jwtToken;
}
get loadSdtf() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").loadSdtf;
}
set loadSdtf(value) {
const scope = "loadSdtf";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "boolean");
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").loadSdtf = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get modelState() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").modelState;
}
get modelViewUrl() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").modelViewUrl;
}
get node() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").node;
}
get outputs() {
return __classPrivateFieldGet(this, _SessionApi_outputs, "f");
}
get parameterDefaultValues() {
const parameterDefaultValues = {};
for (const key in this.parameters)
parameterDefaultValues[key] = this.parameters[key].defval;
return parameterDefaultValues;
}
get parameterSessionValues() {
const parameterSessionValues = {};
for (const key in this.parameters)
parameterSessionValues[key] = this.parameters[key].sessionValue;
return parameterSessionValues;
}
get parameterValues() {
const parameterValues = {};
for (const key in this.parameters)
parameterValues[key] = this.parameters[key].value;
return parameterValues;
}
get parameters() {
return __classPrivateFieldGet(this, _SessionApi_parameters, "f");
}
get refreshJwtToken() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").refreshJwtToken;
}
set refreshJwtToken(value) {
const scope = "refreshJwtToken";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "function", false);
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").refreshJwtToken = value;
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
}
get ticket() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").ticket;
}
get updateCallback() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").updateCallback;
}
set updateCallback(value) {
const scope = "updateCallback";
if (value)
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "function", false);
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").updateCallback = (newNode, oldNode) => __awaiter(this, void 0, void 0, function* () {
if (newNode &&
newNode.data.findIndex((d) => d instanceof SessionApiData_1.SessionApiData) ===
-1)
newNode.addData(new SessionApiData_1.SessionApiData(this));
if (value)
yield Promise.resolve(value(newNode, oldNode));
});
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was updated to ${value}.`);
}
// #endregion Public Getters And Setters (30)
// #region Public Methods (32)
applySettings(response, sections) {
const scope = "applySettings";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, response, "object");
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, sections, "object", false);
return __classPrivateFieldGet(this, _SessionApi_creationControlCenterSession, "f").applySettings(this.id, response, sections);
}
canGoBack() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").canGoBack();
}
canGoForward() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").canGoForward();
}
cancelCustomization() {
__classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").cancelCustomization();
}
close() {
return __awaiter(this, void 0, void 0, function* () {
return yield __classPrivateFieldGet(this, _SessionApi_creationControlCenterSession, "f").closeSessionEngine(this.id);
});
}
convertToGlTF(convertForAr = false) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
for (const r in __classPrivateFieldGet(this, _SessionApi_stateEngine, "f").viewportEngines)
(_a = __classPrivateFieldGet(this, _SessionApi_stateEngine, "f").viewportEngines[r]) === null || _a === void 0 ? void 0 : _a.update("SessionApi.convertToGlTF");
const result = yield __classPrivateFieldGet(this, _SessionApi_gltfConverter, "f").convert(this.node, convertForAr);
return new Blob([result], { type: "application/octet-stream" });
});
}
createModelState(parameterValues, omitSessionParameterValues, image, data, arScene) {
return __awaiter(this, void 0, void 0, function* () {
const scope = "createModelState";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, parameterValues, "object", false);
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, omitSessionParameterValues, "boolean", false);
return yield __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").createModelState(parameterValues, omitSessionParameterValues, image, data, arScene);
});
}
customize(parameterValues, force = false, waitForViewportUpdate = false) {
const scope = "customize";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, parameterValues, "object", false);
// if there are parameter values specified, we set them directly
// the validation happens in the setter of the ParameterApi
if (parameterValues)
for (const p in parameterValues)
this.parameters[p].value = parameterValues[p];
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, force, "boolean", false);
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, waitForViewportUpdate, "boolean", false);
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customize(force, waitForViewportUpdate);
}
customizeParallel(parameterValues) {
const scope = "customizeParallel";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, parameterValues, "object");
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customizeParallel(parameterValues);
}
customizeResult(parameterValues) {
const scope = "customizeResult";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, parameterValues, "object");
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customizeParallel(parameterValues, false);
}
customizeWithModelState(modelState) {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customizeWithModelState(modelState);
}
getExportById(id) {
const scope = "getExportById";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, id, "string");
return __classPrivateFieldGet(this, _SessionApi_exports, "f")[id];
}
getExportByName(name) {
const scope = "getExportByName";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, name, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_exports, "f")).filter((e) => e.name === name);
}
getExportByType(type) {
const scope = "getExportByType";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, type, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_exports, "f")).filter((e) => e.type === type);
}
getModelState(modelStateId) {
const scope = "getModelState";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, modelStateId, "string", false);
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").getModelState(modelStateId);
}
getOutputByFormat(format) {
const scope = "getOutputByFormat";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, format, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_outputs, "f")).filter((o) => o.format.includes(format));
}
getOutputById(id) {
const scope = "getOutputById";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, id, "string");
return __classPrivateFieldGet(this, _SessionApi_outputs, "f")[id];
}
getOutputByName(name) {
const scope = "getOutputByName";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, name, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_outputs, "f")).filter((o) => o.name === name);
}
getParameterById(id) {
const scope = "getParameterById";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, id, "string");
return __classPrivateFieldGet(this, _SessionApi_parameters, "f")[id];
}
getParameterByName(name) {
const scope = "getParameterByName";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, name, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_parameters, "f")).filter((p) => p.name === name);
}
getParameterByType(type) {
const scope = "getParameterByType";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, type, "string");
return Object.values(__classPrivateFieldGet(this, _SessionApi_parameters, "f")).filter((p) => p.type === type);
}
goBack() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").goBack();
}
goForward() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").goForward();
}
loadCachedOutputs(outputs) {
return __awaiter(this, void 0, void 0, function* () {
return yield __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").loadCachedOutputsParallel(outputs);
});
}
requestExports(body, loadOutputs, maxWaitMsec) {
return __awaiter(this, void 0, void 0, function* () {
const scope = "requestExports";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, body, "object");
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, loadOutputs, "boolean", false);
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, maxWaitMsec, "number", false);
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").requestExports(body, loadOutputs, maxWaitMsec);
});
}
resetParameterValues(force = false, waitForViewportUpdate = false) {
const scope = "resetParameterValues";
for (const p in this.parameters)
this.parameters[p].value = this.parameters[p].defval;
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, force, "boolean", false);
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").customize(force, waitForViewportUpdate);
}
resetSettings(sections) {
const scope = "applySettings";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, sections, "object", false);
return __classPrivateFieldGet(this, _SessionApi_creationControlCenterSession, "f").resetSettings(this.id, sections);
}
saveDefaultParameterValues() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").saveDefaultParameterValues();
}
saveSettings(viewportId) {
const scope = "saveDefaultParameterValues";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, viewportId, "string", false);
return __classPrivateFieldGet(this, _SessionApi_creationControlCenterSession, "f").saveSettings(this.id, viewportId);
}
saveUiProperties() {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").saveUiProperties();
}
setJwtToken(value) {
return __awaiter(this, void 0, void 0, function* () {
const scope = "setJwtToken";
__classPrivateFieldGet(this, _SessionApi_inputValidator, "f").validateAndError(`SessionApi.${scope}`, value, "string", false);
yield __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").setJwtToken(value);
__classPrivateFieldGet(this, _SessionApi_logger, "f").debug(`SessionApi.${scope}: ${scope} was set to ${value}`);
return;
});
}
updateOutputs(waitForViewportUpdate = false) {
return __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").updateOutputs(undefined, waitForViewportUpdate);
}
uploadFileParameters(values) {
return __awaiter(this, void 0, void 0, function* () {
const fileParameters = values || {};
const fileParameterIds = yield __classPrivateFieldGet(this, _SessionApi_sessionEngine, "f").uploadFileParameters(fileParameters);
return fileParameterIds;
});
}
}
exports.SessionApi = SessionApi;
_SessionApi_creationControlCenterSession = new WeakMap(), _SessionApi_exports = new WeakMap(), _SessionApi_gltfConverter = new WeakMap(), _SessionApi_inputValidator = new WeakMap(), _SessionApi_logger = new WeakMap(), _SessionApi_outputs = new WeakMap(), _SessionApi_parameters = new WeakMap(), _SessionApi_sessionEngine = new WeakMap(), _SessionApi_stateEngine = new WeakMap();
const isSessionApi = (obj) => obj instanceof SessionApi;
exports.isSessionApi = isSessionApi;
//# sourceMappingURL=SessionApi.js.map