New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shapediver/viewer.shared.services

Package Overview
Dependencies
Maintainers
5
Versions
229
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shapediver/viewer.shared.services - npm Package Compare versions

Comparing version 2.7.10 to 2.8.0

14

dist/converter/Converter.d.ts

@@ -5,3 +5,8 @@ import { vec3 } from 'gl-matrix';

private readonly _httpClient;
private tinyColorToString;
private static _instance;
static get instance(): Converter;
processSVG(blob: Blob): Promise<HTMLImageElement>;
responseToImage(response: HttpResponse<ArrayBuffer>): Promise<HTMLImageElement>;
toAlpha(color: any): number;
toColorArray(color: any): number[];
/**

@@ -12,6 +17,2 @@ * @param color

toHex8Color(color: any, defColorString?: string): string;
toColorArray(color: any): number[];
toAlpha(color: any): number;
toThreeJsColorInput(color: any): string;
processSVG(blob: Blob): Promise<HTMLImageElement>;
/**

@@ -25,5 +26,6 @@ * This color converter is mostly left 'as-is' from viewer v2.

toHexColor(color: any, defColorString?: string): string;
toThreeJsColorInput(color: any): string;
toVec3(point: any): vec3;
responseToImage(response: HttpResponse<ArrayBuffer>): Promise<HTMLImageElement>;
private tinyColorToString;
}
//# sourceMappingURL=Converter.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -21,38 +15,16 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const tinycolor_1 = require("@ctrl/tinycolor");
const tsyringe_1 = require("tsyringe");
const HttpClient_1 = require("../http-client/HttpClient");
let Converter = class Converter {
class Converter {
constructor() {
this._httpClient = tsyringe_1.container.resolve(HttpClient_1.HttpClient);
// #region Properties (2)
this._httpClient = HttpClient_1.HttpClient.instance;
// #endregion Private Methods (1)
}
tinyColorToString(color) {
return color.toHex8String();
// #endregion Properties (2)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
/**
* @param color
* @param defColor
*/
toHex8Color(color, defColorString = '#199b9b') {
const c = this.toHexColor(color, defColorString);
const tColor = new tinycolor_1.TinyColor(c);
const cH8 = tColor.toHex8String();
return cH8.replace('#', '0x');
}
toColorArray(color) {
if (typeof color !== 'string' || !color.startsWith("#"))
color = this.toHexColor(color);
const tColor = new tinycolor_1.TinyColor(color);
const rgb = tColor.toRgb();
return [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0];
}
toAlpha(color) {
const c = this.toHexColor(color);
if (c.length <= 8)
return 1;
return parseInt(c.slice(c.length - 2, c.length), 16) / 255;
}
toThreeJsColorInput(color) {
const c = this.toHexColor(color);
return c.slice(0, c.length - 2);
}
// #endregion Public Static Accessors (1)
// #region Public Methods (8)
processSVG(blob) {

@@ -161,3 +133,47 @@ return __awaiter(this, void 0, void 0, function* () {

}
responseToImage(response) {
return __awaiter(this, void 0, void 0, function* () {
const arrayBufferView = new Uint8Array(response.data);
const blob = new Blob([arrayBufferView], { type: response.headers['content-type'] });
if (response.headers['content-type'] === 'image/svg+xml') {
const img = yield this.processSVG(blob);
return img;
}
else {
const img = new Image();
const promise = new Promise(resolve => {
img.onload = () => resolve();
});
img.crossOrigin = "anonymous";
img.src = URL.createObjectURL(blob);
yield promise;
URL.revokeObjectURL(img.src);
return img;
}
});
}
toAlpha(color) {
const c = this.toHexColor(color);
if (c.length <= 8)
return 1;
return parseInt(c.slice(c.length - 2, c.length), 16) / 255;
}
toColorArray(color) {
if (typeof color !== 'string' || !color.startsWith("#"))
color = this.toHexColor(color);
const tColor = new tinycolor_1.TinyColor(color);
const rgb = tColor.toRgb();
return [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0];
}
/**
* @param color
* @param defColor
*/
toHex8Color(color, defColorString = '#199b9b') {
const c = this.toHexColor(color, defColorString);
const tColor = new tinycolor_1.TinyColor(c);
const cH8 = tColor.toHex8String();
return cH8.replace('#', '0x');
}
/**
* This color converter is mostly left 'as-is' from viewer v2.

@@ -246,2 +262,6 @@ * I didn't want to break something that works.

}
toThreeJsColorInput(color) {
const c = this.toHexColor(color);
return c.slice(0, c.length - 2);
}
toVec3(point) {

@@ -256,27 +276,9 @@ if (Array.isArray(point) && point.length >= 3 && typeof point[0] === 'number' && typeof point[1] === 'number' && typeof point[2] === 'number')

}
responseToImage(response) {
return __awaiter(this, void 0, void 0, function* () {
const arrayBufferView = new Uint8Array(response.data);
const blob = new Blob([arrayBufferView], { type: response.headers['content-type'] });
if (response.headers['content-type'] === 'image/svg+xml') {
const img = yield this.processSVG(blob);
return img;
}
else {
const img = new Image();
const promise = new Promise(resolve => {
img.onload = () => resolve();
});
img.crossOrigin = "anonymous";
img.src = URL.createObjectURL(blob);
yield promise;
return img;
}
});
// #endregion Public Methods (8)
// #region Private Methods (1)
tinyColorToString(color) {
return color.toHex8String();
}
};
Converter = __decorate([
(0, tsyringe_1.singleton)()
], Converter);
}
exports.Converter = Converter;
//# sourceMappingURL=Converter.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DomEventEngine = void 0;
const tsyringe_1 = require("tsyringe");
const UuidGenerator_1 = require("../uuid-generator/UuidGenerator");

@@ -12,3 +11,3 @@ class DomEventEngine {

this._domEventListeners = {};
this._uuidGenerator = tsyringe_1.container.resolve(UuidGenerator_1.UuidGenerator);
this._uuidGenerator = UuidGenerator_1.UuidGenerator.instance;
this._allowListeners = {

@@ -15,0 +14,0 @@ mousewheel: true,

@@ -7,7 +7,8 @@ import { MainEventTypes } from './EventTypes';

export declare class EventEngine {
private static _instance;
private _eventListeners;
protected readonly _logger: Logger;
protected readonly _uuidGenerator: UuidGenerator;
protected readonly _logger: Logger;
private _eventListeners;
constructor();
private convertTypeToString;
private constructor();
static get instance(): EventEngine;
/**

@@ -35,3 +36,4 @@ * Adds a listener that listenes to the provided type. If no valid type is specified, an error is thrown.

removeListener(token: string): boolean;
private convertTypeToString;
}
//# sourceMappingURL=EventEngine.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventEngine = void 0;
const tsyringe_1 = require("tsyringe");
const EventTypes_1 = require("./EventTypes");
const UuidGenerator_1 = require("../uuid-generator/UuidGenerator");
const Logger_1 = require("../logger/Logger");
let EventEngine = class EventEngine {
// #endregion Properties (2)
class EventEngine {
// #endregion Properties (4)
// #region Constructors (1)
constructor() {
// #region Properties (2)
this._uuidGenerator = tsyringe_1.container.resolve(UuidGenerator_1.UuidGenerator);
this._logger = tsyringe_1.container.resolve(Logger_1.Logger);
this._logger = Logger_1.Logger.instance;
this._uuidGenerator = UuidGenerator_1.UuidGenerator.instance;
this._eventListeners = {};

@@ -34,15 +23,7 @@ for (const type in EventTypes_1.EVENTTYPE) {

// #endregion Constructors (1)
convertTypeToString(type) {
let typeString = '';
if (typeof type === 'string')
typeString = type;
for (const mainType in EventTypes_1.EVENTTYPE)
if (type === EventTypes_1.EVENTTYPE[mainType])
typeString = mainType.toLowerCase();
if (!typeString || !this._eventListeners[typeString]) {
this._logger.warn(Logger_1.LOGGING_TOPIC.GENERAL, 'EventEngine.convertTypeToString: No valid type provided.');
return '';
}
return typeString;
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (3)

@@ -109,8 +90,19 @@ /**

}
};
EventEngine = __decorate([
(0, tsyringe_1.singleton)(),
__metadata("design:paramtypes", [])
], EventEngine);
// #endregion Public Methods (3)
// #region Private Methods (1)
convertTypeToString(type) {
let typeString = '';
if (typeof type === 'string')
typeString = type;
for (const mainType in EventTypes_1.EVENTTYPE)
if (type === EventTypes_1.EVENTTYPE[mainType])
typeString = mainType.toLowerCase();
if (!typeString || !this._eventListeners[typeString]) {
this._logger.warn('EventEngine.convertTypeToString: No valid type provided.');
return '';
}
return typeString;
}
}
exports.EventEngine = EventEngine;
//# sourceMappingURL=EventEngine.js.map
import { AxiosRequestConfig } from 'axios';
import { HttpResponse } from './HttpResponse';
export declare class HttpClient {
private _dataCache;
private static _instance;
private _sessionLoading;
constructor();
private getSessionId;
private constructor();
static get instance(): HttpClient;
addDataLoading(sessionId: string, callbacks: {

@@ -15,3 +15,4 @@ getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>;

removeDataLoading(sessionId: string): void;
private getSessionId;
}
//# sourceMappingURL=HttpClient.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -26,3 +17,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const axios_1 = __importDefault(require("axios"));
const tsyringe_1 = require("tsyringe");
const ShapeDiverViewerErrors_1 = require("../logger/ShapeDiverViewerErrors");

@@ -45,8 +35,6 @@ const errorHandler = (error) => {

};
let HttpClient = class HttpClient {
// #endregion Properties (2)
class HttpClient {
// #endregion Properties (3)
// #region Constructors (1)
constructor() {
// #region Properties (2)
this._dataCache = {};
this._sessionLoading = {};

@@ -65,17 +53,8 @@ axios_1.default.interceptors.response.use(response => {

// #endregion Constructors (1)
// #region Public Methods (7)
getSessionId(href) {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"
const parts = href.split('/');
const sessionPartIndex = parts.indexOf('session');
// There have to be at exactly 4 parts, including the session
if (sessionPartIndex !== -1 && parts.length === sessionPartIndex + 4) {
const sessionId = parts[sessionPartIndex + 1];
// no such session has been registered, should never happen
if (!this._sessionLoading[sessionId])
return;
return sessionId;
}
return;
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (4)
addDataLoading(sessionId, callbacks) {

@@ -86,5 +65,2 @@ this._sessionLoading[sessionId] = callbacks;

return __awaiter(this, void 0, void 0, function* () {
const dataKey = btoa(href);
if (dataKey in this._dataCache)
return yield this._dataCache[dataKey];
// try to get sessionId from href

@@ -104,3 +80,3 @@ let sessionId = this.getSessionId(href);

// take first session to load a texture that is not session related
this._dataCache[dataKey] = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
sessionLoading.downloadTexture(sessionId, href).then((result) => {

@@ -121,3 +97,3 @@ resolve({

// or load it directly if we don't have a session
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
return (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
}

@@ -128,7 +104,7 @@ }

// if there is no session to load from, we use the fallback option
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
return (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
}
else {
// all data links where we could somehow find a session to load it with
this._dataCache[dataKey] = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
sessionLoading.getAsset(href)

@@ -150,3 +126,2 @@ .then((result) => {

}
return this._dataCache[dataKey];
});

@@ -162,8 +137,20 @@ }

}
};
HttpClient = __decorate([
(0, tsyringe_1.singleton)(),
__metadata("design:paramtypes", [])
], HttpClient);
// #endregion Public Methods (4)
// #region Private Methods (1)
getSessionId(href) {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"
const parts = href.split('/');
const sessionPartIndex = parts.indexOf('session');
// There have to be at exactly 4 parts, including the session
if (sessionPartIndex !== -1 && parts.length === sessionPartIndex + 4) {
const sessionId = parts[sessionPartIndex + 1];
// no such session has been registered, should never happen
if (!this._sessionLoading[sessionId])
return;
return sessionId;
}
return;
}
}
exports.HttpClient = HttpClient;
//# sourceMappingURL=HttpClient.js.map

@@ -15,5 +15,5 @@ import { EventEngine } from './event-engine/EventEngine';

import { PerformanceEvaluator } from './performance-evaluator/PerformanceEvaluator';
import { Logger, LOGGING_LEVEL, LOGGING_TOPIC } from './logger/Logger';
import { Logger, LOGGING_LEVEL } from './logger/Logger';
import { StatePromise } from './state-engine/StatePromise';
import { ShapeDiverViewerArError, ShapeDiverViewerCameraError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerLightError, ShapeDiverViewerSessionError, ShapeDiverViewerSettingsError, ShapeDiverViewerUnknownError, ShapeDiverViewerValidationError, ShapeDiverViewerGeneralError, ShapeDiverViewerWebGLError, ShapeDiverViewerInteractionError } from './logger/ShapeDiverViewerErrors';
import { ShapeDiverViewerArError, ShapeDiverViewerCameraError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerLightError, ShapeDiverViewerSessionError, ShapeDiverViewerSettingsError, ShapeDiverViewerUnknownError, ShapeDiverViewerValidationError, ShapeDiverViewerGeneralError, ShapeDiverViewerWebGLError, ShapeDiverViewerInteractionError, ShapeDiverViewerViewportError } from './logger/ShapeDiverViewerErrors';
import { ShapeDiverError as ShapeDiverBackendError } from '@shapediver/sdk.geometry-api-sdk-v2';

@@ -32,4 +32,4 @@ import { ShapeDiverViewerError } from './logger/ShapeDiverError';

export { InputValidator };
export { Logger, LOGGING_LEVEL, LOGGING_TOPIC, ShapeDiverViewerError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerWebGLError, ShapeDiverViewerSettingsError, ShapeDiverViewerSessionError, ShapeDiverViewerGeneralError, ShapeDiverViewerUnknownError, ShapeDiverViewerArError, ShapeDiverViewerLightError, ShapeDiverViewerCameraError, ShapeDiverViewerValidationError, ShapeDiverViewerInteractionError, ShapeDiverBackendError };
export { Logger, LOGGING_LEVEL, ShapeDiverViewerError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerWebGLError, ShapeDiverViewerSettingsError, ShapeDiverViewerSessionError, ShapeDiverViewerViewportError, ShapeDiverViewerGeneralError, ShapeDiverViewerUnknownError, ShapeDiverViewerArError, ShapeDiverViewerLightError, ShapeDiverViewerCameraError, ShapeDiverViewerValidationError, ShapeDiverViewerInteractionError, ShapeDiverBackendError };
export { PerformanceEvaluator };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PerformanceEvaluator = exports.ShapeDiverBackendError = exports.ShapeDiverViewerInteractionError = exports.ShapeDiverViewerValidationError = exports.ShapeDiverViewerCameraError = exports.ShapeDiverViewerLightError = exports.ShapeDiverViewerArError = exports.ShapeDiverViewerUnknownError = exports.ShapeDiverViewerGeneralError = exports.ShapeDiverViewerSessionError = exports.ShapeDiverViewerSettingsError = exports.ShapeDiverViewerWebGLError = exports.ShapeDiverViewerEnvironmentMapError = exports.ShapeDiverViewerDataProcessingError = exports.ShapeDiverViewerError = exports.LOGGING_TOPIC = exports.LOGGING_LEVEL = exports.Logger = exports.InputValidator = exports.TypeChecker = exports.Converter = exports.UuidGenerator = exports.HttpClient = exports.DomEventEngine = exports.SystemInfo = exports.StatePromise = exports.StateEngine = exports.SettingsEngine = exports.EVENTTYPE_TASK = exports.EVENTTYPE_INTERACTION = exports.EVENTTYPE_VIEWPORT = exports.EVENTTYPE_SESSION = exports.EVENTTYPE_SCENE = exports.EVENTTYPE_RENDERING = exports.EVENTTYPE_CAMERA = exports.EVENTTYPE = exports.EventEngine = void 0;
exports.PerformanceEvaluator = exports.ShapeDiverBackendError = exports.ShapeDiverViewerInteractionError = exports.ShapeDiverViewerValidationError = exports.ShapeDiverViewerCameraError = exports.ShapeDiverViewerLightError = exports.ShapeDiverViewerArError = exports.ShapeDiverViewerUnknownError = exports.ShapeDiverViewerGeneralError = exports.ShapeDiverViewerViewportError = exports.ShapeDiverViewerSessionError = exports.ShapeDiverViewerSettingsError = exports.ShapeDiverViewerWebGLError = exports.ShapeDiverViewerEnvironmentMapError = exports.ShapeDiverViewerDataProcessingError = exports.ShapeDiverViewerError = exports.LOGGING_LEVEL = exports.Logger = exports.InputValidator = exports.TypeChecker = exports.Converter = exports.UuidGenerator = exports.HttpClient = exports.DomEventEngine = exports.SystemInfo = exports.StatePromise = exports.StateEngine = exports.SettingsEngine = exports.EVENTTYPE_TASK = exports.EVENTTYPE_INTERACTION = exports.EVENTTYPE_VIEWPORT = exports.EVENTTYPE_SESSION = exports.EVENTTYPE_SCENE = exports.EVENTTYPE_RENDERING = exports.EVENTTYPE_CAMERA = exports.EVENTTYPE = exports.EventEngine = void 0;
const EventEngine_1 = require("./event-engine/EventEngine");

@@ -38,3 +38,2 @@ Object.defineProperty(exports, "EventEngine", { enumerable: true, get: function () { return EventEngine_1.EventEngine; } });

Object.defineProperty(exports, "LOGGING_LEVEL", { enumerable: true, get: function () { return Logger_1.LOGGING_LEVEL; } });
Object.defineProperty(exports, "LOGGING_TOPIC", { enumerable: true, get: function () { return Logger_1.LOGGING_TOPIC; } });
const StatePromise_1 = require("./state-engine/StatePromise");

@@ -55,2 +54,3 @@ Object.defineProperty(exports, "StatePromise", { enumerable: true, get: function () { return StatePromise_1.StatePromise; } });

Object.defineProperty(exports, "ShapeDiverViewerInteractionError", { enumerable: true, get: function () { return ShapeDiverViewerErrors_1.ShapeDiverViewerInteractionError; } });
Object.defineProperty(exports, "ShapeDiverViewerViewportError", { enumerable: true, get: function () { return ShapeDiverViewerErrors_1.ShapeDiverViewerViewportError; } });
const sdk_geometry_api_sdk_v2_1 = require("@shapediver/sdk.geometry-api-sdk-v2");

@@ -57,0 +57,0 @@ Object.defineProperty(exports, "ShapeDiverBackendError", { enumerable: true, get: function () { return sdk_geometry_api_sdk_v2_1.ShapeDiverError; } });

@@ -1,2 +0,1 @@

import { LOGGING_TOPIC } from '../logger/Logger';
export declare type Types = 'string' | 'boolean' | 'function' | 'HTMLCanvasElement' | 'enum' | 'number' | 'factor' | 'positive' | 'vec3' | 'mat4' | 'cubeMap' | 'array' | 'stringArray' | 'object' | 'file' | 'color';

@@ -6,6 +5,8 @@ export declare class InputValidator {

private readonly _typeChecker;
validateAndError(topic: LOGGING_TOPIC, scope: string, value: any, type: Types, defined?: boolean, enumValues?: string[]): void;
private static _instance;
static get instance(): InputValidator;
sanitize(input: string): string;
validateAndError(scope: string, value: any, type: Types, defined?: boolean, enumValues?: string[]): void;
private validate;
sanitize(input: string): string;
}
//# sourceMappingURL=InputValidator.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -13,3 +7,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.InputValidator = void 0;
const tsyringe_1 = require("tsyringe");
const dompurify_1 = __importDefault(require("dompurify"));

@@ -19,14 +12,27 @@ const Logger_1 = require("../logger/Logger");

const TypeChecker_1 = require("../type-check/TypeChecker");
let InputValidator = class InputValidator {
class InputValidator {
constructor() {
this._logger = tsyringe_1.container.resolve(Logger_1.Logger);
this._typeChecker = tsyringe_1.container.resolve(TypeChecker_1.TypeChecker);
// #region Properties (3)
this._logger = Logger_1.Logger.instance;
this._typeChecker = TypeChecker_1.TypeChecker.instance;
// #endregion Private Methods (1)
}
validateAndError(topic, scope, value, type, defined = true, enumValues = []) {
// #endregion Properties (3)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (2)
sanitize(input) {
return dompurify_1.default.sanitize(input);
}
validateAndError(scope, value, type, defined = true, enumValues = []) {
const res = this.validate(value, type, defined, enumValues);
if (res)
return;
const error = new ShapeDiverViewerErrors_1.ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${value} is not of type ${type}.${defined === false ? ' (Can also be undefined)' : ''}`, value, type);
throw this._logger.handleError(Logger_1.LOGGING_TOPIC.GENERAL, 'InputValidator.validateAndError', error, false);
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${value} is not of type ${type}.${defined === false ? ' (Can also be undefined)' : ''}`, value, type);
}
// #endregion Public Methods (2)
// #region Private Methods (1)
validate(value, stringLiteral, defined = true, enumValues = []) {

@@ -120,10 +126,4 @@ if (defined === false && typeof value === 'undefined')

}
sanitize(input) {
return dompurify_1.default.sanitize(input);
}
};
InputValidator = __decorate([
(0, tsyringe_1.singleton)()
], InputValidator);
}
exports.InputValidator = InputValidator;
//# sourceMappingURL=InputValidator.js.map

@@ -1,4 +0,1 @@

import * as Sentry from '@sentry/browser';
import { ShapeDiverError as ShapeDiverBackendError } from '@shapediver/sdk.geometry-api-sdk-core';
import { ShapeDiverViewerError } from './ShapeDiverError';
export declare enum LOGGING_LEVEL {

@@ -15,27 +12,7 @@ NONE = "none",

}
export declare enum LOGGING_TOPIC {
AR = "ar",
GENERAL = "general",
EXPORT = "export",
PARAMETER = "parameter",
OUTPUT = "output",
SESSION = "session",
VIEWPORT = "viewer",
CAMERA = "camera",
LIGHT = "light",
CAMERA_CONTROL = "camera_control",
DATA_PROCESSING = "data_processing",
SDTF = "sdtf",
THREE = "three",
SETTINGS = "settings"
}
export declare class Logger {
private static _instance;
private _loggingLevel;
private _showMessages;
private _breadCrumbs;
private _breadCrumbCounter;
private _sentryHub;
private _uuidGenerator;
private _userId;
constructor();
static get instance(): Logger;
get loggingLevel(): LOGGING_LEVEL;

@@ -45,6 +22,2 @@ set loggingLevel(value: LOGGING_LEVEL);

set showMessages(value: boolean);
private canLog;
handleError(topic: LOGGING_TOPIC, scope: string, e: ShapeDiverBackendError | ShapeDiverViewerError | Error | unknown, logToSentry?: boolean): void;
sentryError(topic: LOGGING_TOPIC, error: ShapeDiverBackendError | ShapeDiverViewerError | Error, msg?: string): void;
sentryBreadcrumb(topic: LOGGING_TOPIC, msg: string, level: Sentry.Severity): void;
/**

@@ -54,3 +27,3 @@ * Logging a debug message.

*/
debug(topic: LOGGING_TOPIC, msg: string): void;
debug(msg: string): void;
/**

@@ -60,3 +33,3 @@ * Logging a debug message with high priority.

*/
debugHigh(topic: LOGGING_TOPIC, msg: string): void;
debugHigh(msg: string): void;
/**

@@ -66,3 +39,3 @@ * Logging a debug message with low priority.

*/
debugLow(topic: LOGGING_TOPIC, msg: string): void;
debugLow(msg: string): void;
/**

@@ -72,3 +45,3 @@ * Logging a debug message with medium priority.

*/
debugMedium(topic: LOGGING_TOPIC, msg: string): void;
debugMedium(msg: string): void;
/**

@@ -78,3 +51,3 @@ * Logging an error.

*/
error(topic: LOGGING_TOPIC, error: Error, msg?: string, throwError?: boolean, notifySentry?: boolean): void;
error(msg: string): void;
/**

@@ -84,3 +57,3 @@ * Logging a fatal error.

*/
fatal(topic: LOGGING_TOPIC, msg: string, error: Error, throwError?: boolean): void;
fatal(msg: string): void;
/**

@@ -90,3 +63,3 @@ * Logging an info.

*/
info(topic: LOGGING_TOPIC, msg: string): void;
info(msg: string): void;
/**

@@ -96,5 +69,6 @@ * Logging a warning.

*/
warn(topic: LOGGING_TOPIC, msg: string): void;
warn(msg: string): void;
private canLog;
private messageConstruction;
}
//# sourceMappingURL=Logger.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = exports.LOGGING_TOPIC = exports.LOGGING_LEVEL = void 0;
const Sentry = __importStar(require("@sentry/browser"));
const tsyringe_1 = require("tsyringe");
const viewer_shared_build_data_1 = require("@shapediver/viewer.shared.build-data");
const sdk_geometry_api_sdk_core_1 = require("@shapediver/sdk.geometry-api-sdk-core");
const UuidGenerator_1 = require("../uuid-generator/UuidGenerator");
const browser_1 = require("@sentry/browser");
const ShapeDiverViewerErrors_1 = require("./ShapeDiverViewerErrors");
const sdk_geometry_api_sdk_v2_1 = require("@shapediver/sdk.geometry-api-sdk-v2");
const ShapeDiverError_1 = require("./ShapeDiverError");
exports.Logger = exports.LOGGING_LEVEL = void 0;
var LOGGING_LEVEL;

@@ -53,53 +16,15 @@ (function (LOGGING_LEVEL) {

})(LOGGING_LEVEL = exports.LOGGING_LEVEL || (exports.LOGGING_LEVEL = {}));
var LOGGING_TOPIC;
(function (LOGGING_TOPIC) {
LOGGING_TOPIC["AR"] = "ar";
LOGGING_TOPIC["GENERAL"] = "general";
LOGGING_TOPIC["EXPORT"] = "export";
LOGGING_TOPIC["PARAMETER"] = "parameter";
LOGGING_TOPIC["OUTPUT"] = "output";
LOGGING_TOPIC["SESSION"] = "session";
LOGGING_TOPIC["VIEWPORT"] = "viewer";
LOGGING_TOPIC["CAMERA"] = "camera";
LOGGING_TOPIC["LIGHT"] = "light";
LOGGING_TOPIC["CAMERA_CONTROL"] = "camera_control";
LOGGING_TOPIC["DATA_PROCESSING"] = "data_processing";
LOGGING_TOPIC["SDTF"] = "sdtf";
LOGGING_TOPIC["THREE"] = "three";
LOGGING_TOPIC["SETTINGS"] = "settings";
})(LOGGING_TOPIC = exports.LOGGING_TOPIC || (exports.LOGGING_TOPIC = {}));
let Logger = class Logger {
// #endregion Properties (2)
class Logger {
constructor() {
// #region Properties (2)
// #region Properties (8)
this._loggingLevel = LOGGING_LEVEL.WARN;
this._showMessages = true;
this._breadCrumbs = [];
this._breadCrumbCounter = 0;
this._uuidGenerator = tsyringe_1.container.resolve(UuidGenerator_1.UuidGenerator);
this._userId = this._uuidGenerator.create();
const client = new browser_1.BrowserClient({
dsn: "https://0510990697b04b9da3ad07868e94e378@o363881.ingest.sentry.io/5828729",
environment: 'local',
release: viewer_shared_build_data_1.build_data.build_version,
maxBreadcrumbs: 100,
beforeBreadcrumb: (breadcrumb, hint) => {
this._breadCrumbCounter++;
return breadcrumb;
},
beforeSend: (event, hint) => {
if (event.level === Sentry.Severity.Debug)
event.fingerprint ? event.fingerprint.push(this._userId + '') : event.fingerprint = [this._userId + ''];
return event;
},
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0
});
this._sentryHub = new browser_1.Hub(client);
this._sentryHub.setUser({
id: this._userId
});
// #endregion Private Methods (2)
}
// #endregion Properties (8)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Accessors (4)

@@ -118,2 +43,70 @@ get loggingLevel() {

}
// #endregion Public Accessors (4)
// #region Public Methods (11)
/**
* Logging a debug message.
* @param msg the message
*/
debug(msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG) && this.showMessages === true)
console.debug('(DEBUG) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with high priority.
* @param msg the message
*/
debugHigh(msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_HIGH) && this.showMessages === true)
console.debug('(DEBUG_HIGH) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with low priority.
* @param msg the message
*/
debugLow(msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_LOW) && this.showMessages === true)
console.debug('(DEBUG_LOW) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with medium priority.
* @param msg the message
*/
debugMedium(msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_MEDIUM) && this.showMessages === true)
console.debug('(DEBUG_MEDIUM) ' + this.messageConstruction(msg));
}
/**
* Logging an error.
* @param msg the message
*/
error(msg) {
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
console.error('(ERROR) ' + this.messageConstruction(msg));
}
/**
* Logging a fatal error.
* @param msg the message
*/
fatal(msg) {
if (this.canLog(LOGGING_LEVEL.FATAL) && this.showMessages === true)
console.error('(FATAL) ' + this.messageConstruction(msg));
}
/**
* Logging an info.
* @param msg the message
*/
info(msg) {
if (this.canLog(LOGGING_LEVEL.INFO) && this.showMessages === true)
console.info('(INFO) ' + this.messageConstruction(msg));
}
/**
* Logging a warning.
* @param msg the message
*/
warn(msg) {
if (this.canLog(LOGGING_LEVEL.WARN) && this.showMessages === true)
console.warn('(WARN) ' + this.messageConstruction(msg));
}
// #endregion Public Methods (11)
// #region Private Methods (2)
canLog(loggingLevel) {

@@ -183,156 +176,7 @@ switch (this.loggingLevel) {

}
// #endregion Public Accessors (4)
// #region Public Methods (8)
handleError(topic, scope, e, logToSentry = true) {
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
//console.error('(ERROR) ', e);
if (e instanceof sdk_geometry_api_sdk_v2_1.ShapeDiverRequestError) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if (logToSentry)
this.sentryError(topic, e, messageProperty);
throw e;
}
else if (e instanceof sdk_geometry_api_sdk_v2_1.ShapeDiverResponseError && e.error === sdk_geometry_api_sdk_v2_1.ShapeDiverResponseErrorType.UNKNOWN) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if (logToSentry)
this.sentryError(topic, e, messageProperty);
throw e;
}
else if (e instanceof sdk_geometry_api_sdk_v2_1.ShapeDiverResponseError) {
throw e;
}
else if (e instanceof ShapeDiverError_1.ShapeDiverViewerError) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if (logToSentry) {
if (!(e instanceof ShapeDiverViewerErrors_1.ShapeDiverViewerConnectionError) || (e.status && e.status >= 500)) {
this.sentryError(topic, e, messageProperty);
}
}
throw e;
}
else if (e) {
const error = e;
const messageProperty = error.message ? error.message : `An unknown issue occurred in ${scope}.`;
const viewerError = new ShapeDiverViewerErrors_1.ShapeDiverViewerUnknownError(messageProperty, error);
if (logToSentry)
this.sentryError(topic, viewerError, messageProperty);
throw viewerError;
}
}
sentryError(topic, error, msg) {
var _a;
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
const breadcrumbCounter = this._breadCrumbCounter > 100 ? 100 : this._breadCrumbCounter;
for (let i = breadcrumbCounter; i < this._breadCrumbs.length + breadcrumbCounter; i++) {
if (i % 100 === 0 && i !== 0) {
this._sentryHub.setTag('topic', topic);
this._sentryHub.setUser({ id: this._userId });
this._sentryHub.captureMessage('Breadcrumb Issue ' + (i / 100 - 1) + ' (' + this._userId + ')', Sentry.Severity.Debug);
(_a = this._sentryHub.getScope()) === null || _a === void 0 ? void 0 : _a.clear();
}
this._sentryHub.addBreadcrumb(this._breadCrumbs[i - breadcrumbCounter]);
}
this._sentryHub.setTag('topic', topic);
this._sentryHub.setUser({ id: this._userId });
if (error instanceof sdk_geometry_api_sdk_core_1.ShapeDiverError || error instanceof ShapeDiverError_1.ShapeDiverViewerError) {
this._sentryHub.captureMessage(error.message, Sentry.Severity.Error);
}
else {
this._sentryHub.captureException(error);
}
}
sentryBreadcrumb(topic, msg, level) {
this._breadCrumbs.push({
category: topic,
message: msg,
level: Sentry.Severity.Debug,
timestamp: Math.floor(new Date().getTime() / 1000)
});
}
/**
* Logging a debug message.
* @param msg the message
*/
debug(topic, msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG) && this.showMessages === true)
console.debug('(DEBUG) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with high priority.
* @param msg the message
*/
debugHigh(topic, msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_HIGH) && this.showMessages === true)
console.debug('(DEBUG_HIGH) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with low priority.
* @param msg the message
*/
debugLow(topic, msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_LOW) && this.showMessages === true)
console.debug('(DEBUG_LOW) ' + this.messageConstruction(msg));
}
/**
* Logging a debug message with medium priority.
* @param msg the message
*/
debugMedium(topic, msg) {
if (this.canLog(LOGGING_LEVEL.DEBUG_MEDIUM) && this.showMessages === true)
console.debug('(DEBUG_MEDIUM) ' + this.messageConstruction(msg));
}
/**
* Logging an error.
* @param msg the message
*/
error(topic, error, msg, throwError = false, notifySentry = true) {
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
if (notifySentry)
this.sentryError(topic, error, msg);
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
console.error('(ERROR) ' + this.messageConstruction(msg || error.message));
if (throwError)
throw error;
}
/**
* Logging a fatal error.
* @param msg the message
*/
fatal(topic, msg, error, throwError = false) {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Fatal);
this.sentryError(topic, error, msg);
if (this.canLog(LOGGING_LEVEL.FATAL) && this.showMessages === true)
console.error('(FATAL) ' + this.messageConstruction(msg));
if (throwError)
throw error;
}
/**
* Logging an info.
* @param msg the message
*/
info(topic, msg) {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Info);
if (this.canLog(LOGGING_LEVEL.INFO) && this.showMessages === true)
console.info('(INFO) ' + this.messageConstruction(msg));
}
/**
* Logging a warning.
* @param msg the message
*/
warn(topic, msg) {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Warning);
if (this.canLog(LOGGING_LEVEL.WARN) && this.showMessages === true)
console.warn('(WARN) ' + this.messageConstruction(msg));
}
// #endregion Public Methods (8)
// #region Private Methods (2)
messageConstruction(msg) {
return new Date().toISOString() + ': ' + msg;
}
};
Logger = __decorate([
(0, tsyringe_1.singleton)(),
__metadata("design:paramtypes", [])
], Logger);
}
exports.Logger = Logger;
//# sourceMappingURL=Logger.js.map

@@ -33,2 +33,7 @@ import { ShapeDiverViewerError } from "./ShapeDiverError";

}
export declare class ShapeDiverViewerViewportError extends ShapeDiverViewerError {
readonly message: string;
readonly errorObject?: unknown;
constructor(message: string, errorObject?: unknown);
}
export declare class ShapeDiverViewerLightError extends ShapeDiverViewerError {

@@ -35,0 +40,0 @@ readonly message: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeDiverViewerInteractionError = exports.ShapeDiverViewerConnectionError = exports.ShapeDiverViewerValidationError = exports.ShapeDiverViewerArError = exports.ShapeDiverViewerGeneralError = exports.ShapeDiverViewerCameraError = exports.ShapeDiverViewerLightError = exports.ShapeDiverViewerSessionError = exports.ShapeDiverViewerSettingsError = exports.ShapeDiverViewerWebGLError = exports.ShapeDiverViewerEnvironmentMapError = exports.ShapeDiverViewerDataProcessingError = exports.ShapeDiverViewerUnknownError = void 0;
exports.ShapeDiverViewerInteractionError = exports.ShapeDiverViewerConnectionError = exports.ShapeDiverViewerValidationError = exports.ShapeDiverViewerArError = exports.ShapeDiverViewerGeneralError = exports.ShapeDiverViewerCameraError = exports.ShapeDiverViewerLightError = exports.ShapeDiverViewerViewportError = exports.ShapeDiverViewerSessionError = exports.ShapeDiverViewerSettingsError = exports.ShapeDiverViewerWebGLError = exports.ShapeDiverViewerEnvironmentMapError = exports.ShapeDiverViewerDataProcessingError = exports.ShapeDiverViewerUnknownError = void 0;
const ShapeDiverError_1 = require("./ShapeDiverError");

@@ -56,2 +56,10 @@ class ShapeDiverViewerUnknownError extends ShapeDiverError_1.ShapeDiverViewerError {

exports.ShapeDiverViewerSessionError = ShapeDiverViewerSessionError;
class ShapeDiverViewerViewportError extends ShapeDiverError_1.ShapeDiverViewerError {
constructor(message, errorObject) {
super(ShapeDiverError_1.ShapeDiverViewerErrorType.SESSION_ERROR, 'An error occurred while working with the viewport.', message);
this.message = message;
this.errorObject = errorObject;
}
}
exports.ShapeDiverViewerViewportError = ShapeDiverViewerViewportError;
class ShapeDiverViewerLightError extends ShapeDiverError_1.ShapeDiverViewerError {

@@ -58,0 +66,0 @@ constructor(message, errorObject) {

export declare class PerformanceEvaluator {
private static _instance;
private _eval;
static get instance(): PerformanceEvaluator;
/**
* Start the evaluation with a specific id.
* End the performance evaluation and calculate the duration.
*
* @param id
*/
start(time?: number): void;
end(): void;
/**
* Start the evaluation of a section with a specific id.
*
* @param id
*/
startSection(sectionId: string, time?: number): void;
/**
* End the performance evaluation of a section and calculate the duration.

@@ -22,8 +18,2 @@ *

/**
* End the performance evaluation and calculate the duration.
*
* @param id
*/
end(): void;
/**
* Get the evaluation data for a specific id.

@@ -51,3 +41,15 @@ *

getEvaluationToString(): string;
/**
* Start the evaluation with a specific id.
*
* @param id
*/
start(time?: number): void;
/**
* Start the evaluation of a section with a specific id.
*
* @param id
*/
startSection(sectionId: string, time?: number): void;
}
//# sourceMappingURL=PerformanceEvaluator.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PerformanceEvaluator = void 0;
const tsyringe_1 = require("tsyringe");
let PerformanceEvaluator = class PerformanceEvaluator {
/**
* Start the evaluation with a specific id.
*
* @param id
*/
start(time) {
this._eval = {
start: time || performance.now(),
section: {}
};
class PerformanceEvaluator {
// #endregion Properties (2)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (6)
/**
* Start the evaluation of a section with a specific id.
* End the performance evaluation and calculate the duration.
*
* @param id
*/
startSection(sectionId, time) {
end() {
if (!this._eval)

@@ -33,5 +22,4 @@ return;

return;
this._eval.section[sectionId] = {
start: time || performance.now(),
};
this._eval.end = performance.now();
this._eval.duration = this._eval.end - this._eval.start;
}

@@ -56,15 +44,2 @@ /**

/**
* End the performance evaluation and calculate the duration.
*
* @param id
*/
end() {
if (!this._eval)
return;
if (this._eval.end)
return;
this._eval.end = performance.now();
this._eval.duration = this._eval.end - this._eval.start;
}
/**
* Get the evaluation data for a specific id.

@@ -86,7 +61,29 @@ *

}
};
PerformanceEvaluator = __decorate([
(0, tsyringe_1.singleton)()
], PerformanceEvaluator);
/**
* Start the evaluation with a specific id.
*
* @param id
*/
start(time) {
this._eval = {
start: time || performance.now(),
section: {}
};
}
/**
* Start the evaluation of a section with a specific id.
*
* @param id
*/
startSection(sectionId, time) {
if (!this._eval)
return;
if (this._eval.end)
return;
this._eval.section[sectionId] = {
start: time || performance.now(),
};
}
}
exports.PerformanceEvaluator = PerformanceEvaluator;
//# sourceMappingURL=PerformanceEvaluator.js.map

@@ -5,3 +5,2 @@ "use strict";

const viewer_settings_1 = require("@shapediver/viewer.settings");
const tsyringe_1 = require("tsyringe");
const EventEngine_1 = require("../event-engine/EventEngine");

@@ -13,4 +12,4 @@ const Logger_1 = require("../logger/Logger");

// #region Properties (8)
this._eventEngine = tsyringe_1.container.resolve(EventEngine_1.EventEngine);
this._logger = tsyringe_1.container.resolve(Logger_1.Logger);
this._eventEngine = EventEngine_1.EventEngine.instance;
this._logger = Logger_1.Logger.instance;
this._settings = (0, viewer_settings_1.DefaultsV3_3)();

@@ -105,4 +104,3 @@ this._settings_version = viewer_settings_1.latestVersion;

catch (e) {
const error = new ShapeDiverViewerErrors_1.ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + e.message, e);
throw this._logger.handleError(Logger_1.LOGGING_TOPIC.SETTINGS, `SettingsEngine.loadSettings`, error);
throw new ShapeDiverViewerErrors_1.ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + e.message, e);
}

@@ -109,0 +107,0 @@ }

import { StatePromise } from './StatePromise';
export declare class StateEngine {
private readonly _customStates;
private readonly _eventEngine;
private readonly _fontLoaded;
private readonly _renderingEngines;
private readonly _sessionEngines;
private readonly _renderingEngines;
constructor();
private static _instance;
private constructor();
static get instance(): StateEngine;
get fontLoaded(): StatePromise<boolean>;
get sessionEngines(): {
[key: string]: {
id: string;
initialized: StatePromise<boolean>;
settingsRegistered: StatePromise<boolean>;
};
};
get renderingEngines(): {

@@ -27,3 +20,10 @@ [key: string]: {

};
get sessionEngines(): {
[key: string]: {
id: string;
initialized: StatePromise<boolean>;
settingsRegistered: StatePromise<boolean>;
};
};
}
//# sourceMappingURL=StateEngine.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateEngine = void 0;
const tsyringe_1 = require("tsyringe");
const index_1 = require("../index");
const StatePromise_1 = require("./StatePromise");
let StateEngine = class StateEngine {
// #endregion Properties (8)
class StateEngine {
// #endregion Properties (6)
// #region Constructors (1)
constructor() {
// #region Properties (8)
this._customStates = {};
this._eventEngine = tsyringe_1.container.resolve(index_1.EventEngine);
// #region Properties (6)
this._fontLoaded = new StatePromise_1.StatePromise();
this._renderingEngines = {};
this._sessionEngines = {};
this._renderingEngines = {};
this._fontLoaded = new StatePromise_1.StatePromise();
}
// #endregion Constructors (1)
// #region Public Accessors (7)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Accessors (3)
get fontLoaded() {
return this._fontLoaded;
}
get renderingEngines() {
return this._renderingEngines;
}
get sessionEngines() {
return this._sessionEngines;
}
get renderingEngines() {
return this._renderingEngines;
}
};
StateEngine = __decorate([
(0, tsyringe_1.singleton)(),
__metadata("design:paramtypes", [])
], StateEngine);
}
exports.StateEngine = StateEngine;
//# sourceMappingURL=StateEngine.js.map

@@ -6,19 +6,21 @@ export declare class SystemInfo {

private readonly _parser;
constructor();
private static _instance;
private constructor();
static get instance(): SystemInfo;
/**
* Check if we are on a Mac OS device
* Check if we are on an Android device
*/
get isMacOS(): boolean;
get isAndroid(): boolean;
/**
* Check if we are on an IOS device
* Check if we are running in a browser
*/
get isIOS(): boolean;
get isBrowser(): boolean;
/**
* Check if we are on an Android device
* Check if we are running in Safari
*/
get isAndroid(): boolean;
get isChrome(): boolean;
/**
* Check if we are on a mobile device
* Check if we are running in Firefox
*/
get isMobile(): boolean;
get isFirefox(): boolean;
/**

@@ -29,21 +31,21 @@ * Check if we are running in internet explorer (arrrggghhhh!!!!)

/**
* Check if we are running in Safari
* Check if we are on an IOS device
*/
get isChrome(): boolean;
get isIOS(): boolean;
/**
* Check if we are running in Safari
* Check if we are running in an iframe
*/
get isSafari(): boolean;
get isIframe(): boolean;
/**
* Check if we are running in Firefox
* Check if we are on a Mac OS device
*/
get isFirefox(): boolean;
get isMacOS(): boolean;
/**
* Check if we are running in a browser
* Check if we are on a mobile device
*/
get isBrowser(): boolean;
get isMobile(): boolean;
/**
* Check if we are running in an iframe
* Check if we are running in Safari
*/
get isIframe(): boolean;
get isSafari(): boolean;
/**

@@ -50,0 +52,0 @@ * Get guessed origin of embedding website

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -16,5 +7,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.SystemInfo = void 0;
const tsyringe_1 = require("tsyringe");
const ua_parser_js_1 = __importDefault(require("ua-parser-js"));
let SystemInfo = class SystemInfo {
class SystemInfo {
// #endregion Properties (5)
// #region Constructors (1)
constructor() {

@@ -39,20 +31,10 @@ this._parser = new ua_parser_js_1.default();

}
/**
* Check if we are on a Mac OS device
*/
get isMacOS() {
const osName = this._parser.getOS().name;
return osName === 'Mac OS';
// #endregion Constructors (1)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
;
// #endregion Public Static Accessors (1)
// #region Public Accessors (11)
/**
* Check if we are on an IOS device
*/
get isIOS() {
const osName = this._parser.getOS().name;
return osName === 'iOS' ||
(window.navigator && window.navigator.maxTouchPoints === 5 && window.navigator.platform === 'MacIntel');
}
;
/**
* Check if we are on an Android device

@@ -64,20 +46,9 @@ */

}
;
/**
* Check if we are on a mobile device
* Check if we are running in a browser
*/
get isMobile() {
const type = this._parser.getDevice().type;
return type === 'mobile' || type === 'tablet';
get isBrowser() {
return this._isBrowser;
}
;
/**
* Check if we are running in internet explorer (arrrggghhhh!!!!)
*/
get isIE() {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('IE'));
}
;
/**
* Check if we are running in Safari

@@ -89,26 +60,24 @@ */

}
;
/**
* Check if we are running in Safari
* Check if we are running in Firefox
*/
get isSafari() {
get isFirefox() {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Safari'));
return !!(browserName && browserName.includes('Firefox'));
}
;
/**
* Check if we are running in Firefox
* Check if we are running in internet explorer (arrrggghhhh!!!!)
*/
get isFirefox() {
get isIE() {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Firefox'));
return !!(browserName && browserName.includes('IE'));
}
;
/**
* Check if we are running in a browser
* Check if we are on an IOS device
*/
get isBrowser() {
return this._isBrowser;
get isIOS() {
const osName = this._parser.getOS().name;
return osName === 'iOS' ||
(window.navigator && window.navigator.maxTouchPoints === 5 && window.navigator.platform === 'MacIntel');
}
;
/**

@@ -120,4 +89,24 @@ * Check if we are running in an iframe

}
;
/**
* Check if we are on a Mac OS device
*/
get isMacOS() {
const osName = this._parser.getOS().name;
return osName === 'Mac OS';
}
/**
* Check if we are on a mobile device
*/
get isMobile() {
const type = this._parser.getDevice().type;
return type === 'mobile' || type === 'tablet';
}
/**
* Check if we are running in Safari
*/
get isSafari() {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Safari'));
}
/**
* Get guessed origin of embedding website

@@ -128,9 +117,4 @@ */

}
;
};
SystemInfo = __decorate([
(0, tsyringe_1.singleton)(),
__metadata("design:paramtypes", [])
], SystemInfo);
}
exports.SystemInfo = SystemInfo;
//# sourceMappingURL=SystemInfo.js.map
export declare class TypeChecker {
private static _instance;
static get instance(): TypeChecker;
isHTMLCanvasElement(value: any): boolean;
isTypeOf(value: any, type: string): boolean;
isHTMLCanvasElement(value: any): boolean;
}
//# sourceMappingURL=TypeChecker.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeChecker = void 0;
const tsyringe_1 = require("tsyringe");
let TypeChecker = class TypeChecker {
isTypeOf(value, type) {
return typeof value === type;
class TypeChecker {
// #endregion Properties (1)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (2)
isHTMLCanvasElement(value) {
return value instanceof HTMLCanvasElement;
}
};
TypeChecker = __decorate([
(0, tsyringe_1.singleton)()
], TypeChecker);
isTypeOf(value, type) {
return typeof value === type;
}
}
exports.TypeChecker = TypeChecker;
//# sourceMappingURL=TypeChecker.js.map
export declare class UuidGenerator {
private static _instance;
static get instance(): UuidGenerator;
/**

@@ -7,8 +9,2 @@ * Creates a new uuid v4.

/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
validate(uuid: string): boolean;
/**
* Parse the uuid to array of bytes

@@ -27,3 +23,9 @@ *

stringify(uuid: ArrayLike<number>): string;
/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
validate(uuid: string): boolean;
}
//# sourceMappingURL=UuidGenerator.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UuidGenerator = void 0;
const tsyringe_1 = require("tsyringe");
const uuid_1 = require("uuid");
let UuidGenerator = class UuidGenerator {
class UuidGenerator {
// #endregion Properties (1)
// #region Public Static Accessors (1)
static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (4)
/**

@@ -19,13 +19,3 @@ * Creates a new uuid v4.

}
;
/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
validate(uuid) {
return (0, uuid_1.validate)(uuid);
}
;
/**
* Parse the uuid to array of bytes

@@ -39,3 +29,2 @@ *

}
;
/**

@@ -50,8 +39,12 @@ * Stringify an array of bytes to an uuid

}
;
};
UuidGenerator = __decorate([
(0, tsyringe_1.singleton)()
], UuidGenerator);
/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
validate(uuid) {
return (0, uuid_1.validate)(uuid);
}
}
exports.UuidGenerator = UuidGenerator;
//# sourceMappingURL=UuidGenerator.js.map
{
"name": "@shapediver/viewer.shared.services",
"version": "2.7.10",
"version": "2.8.0",
"description": "",

@@ -43,18 +43,15 @@ "keywords": [],

"@ctrl/tinycolor": "^3.4.0",
"@sentry/browser": "^6.7.2",
"@sentry/tracing": "^6.7.2",
"@shapediver/sdk.geometry-api-sdk-v2": "1.3.0",
"@shapediver/viewer.settings": "0.3.0",
"@shapediver/viewer.shared.build-data": "2.7.10",
"@shapediver/viewer.shared.build-data": "2.8.0",
"@types/dompurify": "^2.3.1",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^8.3.0",
"@types/uuid": "^9.0.0",
"axios": "^1.2.6",
"dompurify": "^2.3.3",
"gl-matrix": "3.3.0",
"tsyringe": "^4.5.0",
"ua-parser-js": "^0.7.28",
"uuid": "^8.3.2"
"uuid": "^9.0.0"
},
"gitHead": "08d9680d3b199406d1c6bedc8fbeed3d1ad6a385"
"gitHead": "9caee20107c5d71e43de33edc14ee19d62ec268b"
}
import { vec3, vec4 } from 'gl-matrix'
import { TinyColor } from '@ctrl/tinycolor'
import { container, singleton } from 'tsyringe'
import { HttpClient } from '../http-client/HttpClient';
import { HttpResponse } from '../http-client/HttpResponse';
@singleton()
export class Converter {
private readonly _httpClient: HttpClient = <HttpClient>container.resolve(HttpClient);
// #region Properties (2)
private tinyColorToString(color: TinyColor): string {
return color.toHex8String();
}
private readonly _httpClient: HttpClient = HttpClient.instance;
/**
* @param color
* @param defColor
*/
public toHex8Color(color: any, defColorString: string = '#199b9b'): string {
const c = this.toHexColor(color, defColorString);
const tColor = new TinyColor(c);
const cH8 = tColor.toHex8String();
return cH8.replace('#', '0x');
}
private static _instance: Converter;
public toColorArray(color: any): number[] {
if(typeof color !== 'string' || !color.startsWith("#"))
color = this.toHexColor(color);
const tColor = new TinyColor(color);
const rgb = tColor.toRgb()
return [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0];
}
// #endregion Properties (2)
public toAlpha(color: any): number {
const c = this.toHexColor(color);
if (c.length <= 8) return 1;
return parseInt(c.slice(c.length - 2, c.length), 16) / 255;
}
// #region Public Static Accessors (1)
public toThreeJsColorInput(color: any): string {
const c = this.toHexColor(color);
return c.slice(0, c.length - 2);
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (8)
public async processSVG(blob: Blob): Promise<HTMLImageElement> {

@@ -171,3 +150,47 @@ let data = <string>await new Promise((resolve, _) => {

public async responseToImage(response: HttpResponse<ArrayBuffer>): Promise<HTMLImageElement> {
const arrayBufferView = new Uint8Array( response.data );
const blob = new Blob([ arrayBufferView ], { type: response.headers['content-type'] } );
if (response.headers['content-type'] === 'image/svg+xml') {
const img = await this.processSVG(blob);
return img;
} else {
const img = new Image();
const promise = new Promise<void>(resolve => {
img.onload = () => resolve();
})
img.crossOrigin = "anonymous";
img.src = URL.createObjectURL(blob);
await promise;
URL.revokeObjectURL(img.src);
return img;
}
}
public toAlpha(color: any): number {
const c = this.toHexColor(color);
if (c.length <= 8) return 1;
return parseInt(c.slice(c.length - 2, c.length), 16) / 255;
}
public toColorArray(color: any): number[] {
if(typeof color !== 'string' || !color.startsWith("#"))
color = this.toHexColor(color);
const tColor = new TinyColor(color);
const rgb = tColor.toRgb()
return [rgb.r / 255.0, rgb.g / 255.0, rgb.b / 255.0];
}
/**
* @param color
* @param defColor
*/
public toHex8Color(color: any, defColorString: string = '#199b9b'): string {
const c = this.toHexColor(color, defColorString);
const tColor = new TinyColor(c);
const cH8 = tColor.toHex8String();
return cH8.replace('#', '0x');
}
/**
* This color converter is mostly left 'as-is' from viewer v2.

@@ -266,2 +289,7 @@ * I didn't want to break something that works.

public toThreeJsColorInput(color: any): string {
const c = this.toHexColor(color);
return c.slice(0, c.length - 2);
}
public toVec3(point: any): vec3 {

@@ -280,19 +308,11 @@ if (Array.isArray(point) && point.length >= 3 && typeof point[0] === 'number' && typeof point[1] === 'number' && typeof point[2] === 'number')

public async responseToImage(response: HttpResponse<ArrayBuffer>): Promise<HTMLImageElement> {
const arrayBufferView = new Uint8Array( response.data );
const blob = new Blob([ arrayBufferView ], { type: response.headers['content-type'] } );
if (response.headers['content-type'] === 'image/svg+xml') {
const img = await this.processSVG(blob);
return img;
} else {
const img = new Image();
const promise = new Promise<void>(resolve => {
img.onload = () => resolve();
})
img.crossOrigin = "anonymous";
img.src = URL.createObjectURL(blob);
await promise;
return img;
}
// #endregion Public Methods (8)
// #region Private Methods (1)
private tinyColorToString(color: TinyColor): string {
return color.toHex8String();
}
// #endregion Private Methods (1)
}

@@ -1,2 +0,1 @@

import { container } from 'tsyringe'
import { UuidGenerator } from '../uuid-generator/UuidGenerator';

@@ -12,3 +11,3 @@

} = {};
private readonly _uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
private readonly _uuidGenerator: UuidGenerator = UuidGenerator.instance;

@@ -15,0 +14,0 @@ private _allowListeners = {

@@ -1,3 +0,1 @@

import { container, singleton } from 'tsyringe'
import { EVENTTYPE, MainEventTypes } from './EventTypes'

@@ -8,10 +6,9 @@ import { IListener } from './interfaces/IListener'

import { UuidGenerator } from '../uuid-generator/UuidGenerator'
import { Logger, LOGGING_TOPIC } from '../logger/Logger'
import { Logger } from '../logger/Logger'
@singleton()
export class EventEngine {
// #region Properties (2)
// #region Properties (4)
protected readonly _uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
protected readonly _logger: Logger = <Logger>container.resolve(Logger);
private static _instance: EventEngine;
private _eventListeners: {

@@ -21,7 +18,10 @@ [key: string]: IListener[]

// #endregion Properties (2)
protected readonly _logger: Logger = Logger.instance;
protected readonly _uuidGenerator: UuidGenerator = UuidGenerator.instance;
// #endregion Properties (4)
// #region Constructors (1)
constructor() {
private constructor() {
this._eventListeners = {};

@@ -39,18 +39,10 @@ for (const type in EVENTTYPE) {

private convertTypeToString(type: string | MainEventTypes): string {
let typeString: string = '';
if(typeof type === 'string') typeString = type;
// #region Public Static Accessors (1)
for (const mainType in EVENTTYPE)
if(type === EVENTTYPE[mainType as keyof typeof EVENTTYPE])
typeString = mainType.toLowerCase();
if(!typeString || !this._eventListeners[typeString]) {
this._logger.warn(LOGGING_TOPIC.GENERAL, 'EventEngine.convertTypeToString: No valid type provided.');
return '';
}
return typeString;
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (3)

@@ -122,2 +114,22 @@

// #endregion Public Methods (3)
// #region Private Methods (1)
private convertTypeToString(type: string | MainEventTypes): string {
let typeString: string = '';
if(typeof type === 'string') typeString = type;
for (const mainType in EVENTTYPE)
if(type === EVENTTYPE[mainType as keyof typeof EVENTTYPE])
typeString = mainType.toLowerCase();
if(!typeString || !this._eventListeners[typeString]) {
this._logger.warn('EventEngine.convertTypeToString: No valid type provided.');
return '';
}
return typeString;
}
// #endregion Private Methods (1)
}
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
import { singleton } from 'tsyringe'
import { ShapeDiverViewerConnectionError } from '../logger/ShapeDiverViewerErrors';

@@ -20,9 +19,6 @@ import { HttpResponse } from './HttpResponse';

@singleton()
export class HttpClient {
// #region Properties (2)
// #region Properties (3)
private _dataCache: {
[key: string]: Promise<HttpResponse<any>>
} = {};
private static _instance: HttpClient;

@@ -36,7 +32,7 @@ private _sessionLoading: {

// #endregion Properties (2)
// #endregion Properties (3)
// #region Constructors (1)
constructor() {
private constructor() {
axios.interceptors.response.use(

@@ -60,19 +56,12 @@ response => {

// #region Public Methods (7)
// #region Public Static Accessors (1)
private getSessionId(href: string): string | undefined {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"
const parts = href.split('/');
const sessionPartIndex = parts.indexOf('session');
// There have to be at exactly 4 parts, including the session
if (sessionPartIndex !== -1 && parts.length === sessionPartIndex + 4) {
const sessionId = parts[sessionPartIndex + 1];
// no such session has been registered, should never happen
if (!this._sessionLoading[sessionId]) return;
return sessionId;
}
return;
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (4)
public addDataLoading(sessionId: string, callbacks: {

@@ -86,5 +75,2 @@ getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>,

public async get(href: string, config: AxiosRequestConfig = { responseType: 'arraybuffer' }, textureLoading: boolean = false): Promise<HttpResponse<any>> {
const dataKey = btoa(href);
if (dataKey in this._dataCache) return await this._dataCache[dataKey];
// try to get sessionId from href

@@ -110,3 +96,3 @@ let sessionId = this.getSessionId(href);

// take first session to load a texture that is not session related
this._dataCache[dataKey] = new Promise<HttpResponse<any>>((resolve, reject) => {
return new Promise<HttpResponse<any>>((resolve, reject) => {
sessionLoading!.downloadTexture(sessionId!, href).then((result) => {

@@ -126,3 +112,3 @@ resolve({

// or load it directly if we don't have a session
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
return axios(href, Object.assign({ method: 'get' }, config));
}

@@ -132,6 +118,6 @@ } else {

// if there is no session to load from, we use the fallback option
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
return axios(href, Object.assign({ method: 'get' }, config));
} else {
// all data links where we could somehow find a session to load it with
this._dataCache[dataKey] = new Promise<HttpResponse<ArrayBuffer>>((resolve, reject) => {
return new Promise<HttpResponse<ArrayBuffer>>((resolve, reject) => {
sessionLoading!.getAsset(href)

@@ -153,4 +139,2 @@ .then((result) => {

}
return this._dataCache[dataKey];
}

@@ -166,3 +150,22 @@

// #endregion Public Methods (7)
// #endregion Public Methods (4)
// #region Private Methods (1)
private getSessionId(href: string): string | undefined {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"
const parts = href.split('/');
const sessionPartIndex = parts.indexOf('session');
// There have to be at exactly 4 parts, including the session
if (sessionPartIndex !== -1 && parts.length === sessionPartIndex + 4) {
const sessionId = parts[sessionPartIndex + 1];
// no such session has been registered, should never happen
if (!this._sessionLoading[sessionId]) return;
return sessionId;
}
return;
}
// #endregion Private Methods (1)
}

@@ -15,5 +15,5 @@ import { EventEngine } from './event-engine/EventEngine'

import { PerformanceEvaluator } from './performance-evaluator/PerformanceEvaluator'
import { Logger, LOGGING_LEVEL, LOGGING_TOPIC } from './logger/Logger'
import { Logger, LOGGING_LEVEL } from './logger/Logger'
import { StatePromise } from './state-engine/StatePromise'
import { ShapeDiverViewerArError, ShapeDiverViewerCameraError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerLightError, ShapeDiverViewerSessionError, ShapeDiverViewerSettingsError, ShapeDiverViewerUnknownError, ShapeDiverViewerValidationError, ShapeDiverViewerGeneralError, ShapeDiverViewerWebGLError, ShapeDiverViewerInteractionError } from './logger/ShapeDiverViewerErrors'
import { ShapeDiverViewerArError, ShapeDiverViewerCameraError, ShapeDiverViewerDataProcessingError, ShapeDiverViewerEnvironmentMapError, ShapeDiverViewerLightError, ShapeDiverViewerSessionError, ShapeDiverViewerSettingsError, ShapeDiverViewerUnknownError, ShapeDiverViewerValidationError, ShapeDiverViewerGeneralError, ShapeDiverViewerWebGLError, ShapeDiverViewerInteractionError, ShapeDiverViewerViewportError } from './logger/ShapeDiverViewerErrors'
import { ShapeDiverError as ShapeDiverBackendError } from '@shapediver/sdk.geometry-api-sdk-v2'

@@ -65,3 +65,3 @@ import { ShapeDiverViewerError } from './logger/ShapeDiverError'

export {
Logger, LOGGING_LEVEL, LOGGING_TOPIC,
Logger, LOGGING_LEVEL,
ShapeDiverViewerError,

@@ -73,2 +73,3 @@ ShapeDiverViewerDataProcessingError,

ShapeDiverViewerSessionError,
ShapeDiverViewerViewportError,
ShapeDiverViewerGeneralError,

@@ -75,0 +76,0 @@ ShapeDiverViewerUnknownError,

@@ -1,4 +0,3 @@

import { container, singleton } from 'tsyringe'
import DOMPurify from 'dompurify';
import { Logger, LOGGING_TOPIC } from '../logger/Logger'
import { Logger } from '../logger/Logger'
import { ShapeDiverViewerValidationError } from '../logger/ShapeDiverViewerErrors';

@@ -12,16 +11,37 @@ import { TypeChecker } from '../type-check/TypeChecker'

@singleton()
export class InputValidator {
// #region Properties (3)
private readonly _logger: Logger = <Logger>container.resolve(Logger);
private readonly _typeChecker: TypeChecker = <TypeChecker>container.resolve(TypeChecker);
private readonly _logger: Logger = Logger.instance;
private readonly _typeChecker: TypeChecker = TypeChecker.instance;
public validateAndError(topic: LOGGING_TOPIC, scope: string, value: any, type: Types, defined: boolean = true, enumValues: string[] = []) {
private static _instance: InputValidator;
// #endregion Properties (3)
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (2)
public sanitize(input: string): string {
return DOMPurify.sanitize(input);
}
public validateAndError(scope: string, value: any, type: Types, defined: boolean = true, enumValues: string[] = []) {
const res = this.validate(value, type, defined, enumValues);
if(res) return;
const error = new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${value} is not of type ${type}.${defined === false ? ' (Can also be undefined)' : ''}`, value, type);
throw this._logger.handleError(LOGGING_TOPIC.GENERAL, 'InputValidator.validateAndError', error, false);
throw new ShapeDiverViewerValidationError(`${scope}: Input could not be validated. ${value} is not of type ${type}.${defined === false ? ' (Can also be undefined)' : ''}`, value, type);
}
// #endregion Public Methods (2)
// #region Private Methods (1)
private validate(value: any, stringLiteral: Types, defined: boolean = true, enumValues: string[] = []): boolean {

@@ -98,5 +118,3 @@ if (defined === false && typeof value === 'undefined') return true;

public sanitize(input: string): string {
return DOMPurify.sanitize(input);
}
// #endregion Private Methods (1)
}

@@ -1,12 +0,1 @@

import * as Sentry from '@sentry/browser'
import { container, singleton } from 'tsyringe'
import { build_data } from '@shapediver/viewer.shared.build-data'
import { ShapeDiverError as ShapeDiverBackendError } from '@shapediver/sdk.geometry-api-sdk-core'
import { UuidGenerator } from '../uuid-generator/UuidGenerator'
import { BrowserClient, Hub } from '@sentry/browser'
import { ShapeDiverViewerConnectionError, ShapeDiverViewerUnknownError } from './ShapeDiverViewerErrors'
import { ShapeDiverRequestError, ShapeDiverResponseError, ShapeDiverResponseErrorType } from '@shapediver/sdk.geometry-api-sdk-v2'
import { ShapeDiverViewerError } from './ShapeDiverError'
export enum LOGGING_LEVEL {

@@ -24,60 +13,20 @@ NONE = 'none',

export enum LOGGING_TOPIC {
AR = 'ar',
GENERAL = 'general',
EXPORT = 'export',
PARAMETER = 'parameter',
OUTPUT = 'output',
SESSION = 'session',
VIEWPORT = 'viewer',
CAMERA = 'camera',
LIGHT = 'light',
CAMERA_CONTROL = 'camera_control',
DATA_PROCESSING = 'data_processing',
SDTF = 'sdtf',
THREE = 'three',
SETTINGS = 'settings',
}
@singleton()
export class Logger {
// #region Properties (2)
// #region Properties (8)
private static _instance: Logger;
private _loggingLevel: LOGGING_LEVEL = LOGGING_LEVEL.WARN;
private _showMessages: boolean = true;
private _breadCrumbs: Sentry.Breadcrumb[] = [];
private _breadCrumbCounter: number = 0;
private _sentryHub: Hub;
private _uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
private _userId = this._uuidGenerator.create();
// #endregion Properties (2)
// #endregion Properties (8)
constructor() {
const client = new BrowserClient({
dsn: "https://0510990697b04b9da3ad07868e94e378@o363881.ingest.sentry.io/5828729",
environment: 'local',
release: build_data.build_version,
maxBreadcrumbs: 100,
beforeBreadcrumb: (breadcrumb: Sentry.Breadcrumb, hint?: Sentry.BreadcrumbHint | undefined): Sentry.Breadcrumb | null => {
this._breadCrumbCounter++;
return breadcrumb;
},
beforeSend: (event: Sentry.Event, hint?: Sentry.EventHint | undefined): Sentry.Event | PromiseLike<Sentry.Event | null> | null => {
if (event.level === Sentry.Severity.Debug) event.fingerprint ? event.fingerprint.push(this._userId + '') : event.fingerprint = [this._userId + ''];
return event;
},
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0
});
// #region Public Static Accessors (1)
this._sentryHub = new Hub(client);
this._sentryHub.setUser({
id: this._userId
})
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Accessors (4)

@@ -101,109 +50,6 @@

private canLog(loggingLevel: LOGGING_LEVEL): boolean {
switch (this.loggingLevel) {
case LOGGING_LEVEL.ERROR:
if (loggingLevel === LOGGING_LEVEL.FATAL) return false;
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.FATAL:
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.WARN:
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.INFO:
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_HIGH:
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_MEDIUM:
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_LOW:
case LOGGING_LEVEL.DEBUG:
default:
return true;
}
}
// #endregion Public Accessors (4)
// #region Public Methods (8)
public handleError(topic: LOGGING_TOPIC, scope: string, e: ShapeDiverBackendError | ShapeDiverViewerError | Error | unknown, logToSentry = true) {
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
//console.error('(ERROR) ', e);
if(e instanceof ShapeDiverRequestError) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if(logToSentry) this.sentryError(topic, e, messageProperty);
throw e;
} else if(e instanceof ShapeDiverResponseError && e.error === ShapeDiverResponseErrorType.UNKNOWN) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if(logToSentry) this.sentryError(topic, e, messageProperty);
throw e;
} else if(e instanceof ShapeDiverResponseError) {
throw e;
} else if (e instanceof ShapeDiverViewerError) {
const messageProperty = e && e.message ? e.message : `An unknown issue occurred in ${scope}.`;
if(logToSentry) {
if(!(e instanceof ShapeDiverViewerConnectionError) || (e.status && e.status >= 500)) {
this.sentryError(topic, e, messageProperty);
}
}
throw e;
} else if(e) {
const error = <any>e;
const messageProperty = error.message ? error.message : `An unknown issue occurred in ${scope}.`;
const viewerError = new ShapeDiverViewerUnknownError(messageProperty, error);
if(logToSentry) this.sentryError(topic, viewerError, messageProperty);
throw viewerError;
}
}
// #region Public Methods (11)
public sentryError(topic: LOGGING_TOPIC, error: ShapeDiverBackendError | ShapeDiverViewerError | Error, msg?: string) {
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
const breadcrumbCounter = this._breadCrumbCounter > 100 ? 100 : this._breadCrumbCounter;
for(let i = breadcrumbCounter; i < this._breadCrumbs.length + breadcrumbCounter; i++) {
if(i%100 === 0 && i !== 0) {
this._sentryHub.setTag('topic', topic);
this._sentryHub.setUser({ id: this._userId })
this._sentryHub.captureMessage('Breadcrumb Issue ' + (i/100 - 1) + ' (' + this._userId + ')', Sentry.Severity.Debug);
this._sentryHub.getScope()?.clear()
}
this._sentryHub.addBreadcrumb(this._breadCrumbs[i-breadcrumbCounter]);
}
this._sentryHub.setTag('topic', topic);
this._sentryHub.setUser({ id: this._userId })
if(error instanceof ShapeDiverBackendError || error instanceof ShapeDiverViewerError) {
this._sentryHub.captureMessage(error.message, Sentry.Severity.Error);
} else {
this._sentryHub.captureException(error);
}
}
public sentryBreadcrumb(topic: LOGGING_TOPIC, msg: string, level: Sentry.Severity) {
this._breadCrumbs.push({
category: topic,
message: msg,
level: Sentry.Severity.Debug,
timestamp: Math.floor(new Date().getTime() / 1000)
})
}
/**

@@ -213,3 +59,3 @@ * Logging a debug message.

*/
public debug(topic: LOGGING_TOPIC, msg: string): void {
public debug(msg: string): void {
if (this.canLog(LOGGING_LEVEL.DEBUG) && this.showMessages === true)

@@ -223,3 +69,3 @@ console.debug('(DEBUG) ' + this.messageConstruction(msg));

*/
public debugHigh(topic: LOGGING_TOPIC, msg: string): void {
public debugHigh(msg: string): void {
if (this.canLog(LOGGING_LEVEL.DEBUG_HIGH) && this.showMessages === true)

@@ -233,3 +79,3 @@ console.debug('(DEBUG_HIGH) ' + this.messageConstruction(msg));

*/
public debugLow(topic: LOGGING_TOPIC, msg: string): void {
public debugLow(msg: string): void {
if (this.canLog(LOGGING_LEVEL.DEBUG_LOW) && this.showMessages === true)

@@ -243,3 +89,3 @@ console.debug('(DEBUG_LOW) ' + this.messageConstruction(msg));

*/
public debugMedium(topic: LOGGING_TOPIC, msg: string): void {
public debugMedium(msg: string): void {
if (this.canLog(LOGGING_LEVEL.DEBUG_MEDIUM) && this.showMessages === true)

@@ -253,9 +99,5 @@ console.debug('(DEBUG_MEDIUM) ' + this.messageConstruction(msg));

*/
public error(topic: LOGGING_TOPIC, error: Error, msg?: string, throwError: boolean = false, notifySentry: boolean = true): void {
this.sentryBreadcrumb(topic, msg || error.message, Sentry.Severity.Error);
if(notifySentry)
this.sentryError(topic, error, msg);
public error(msg: string): void {
if (this.canLog(LOGGING_LEVEL.ERROR) && this.showMessages === true)
console.error('(ERROR) ' + this.messageConstruction(msg || error.message));
if(throwError) throw error;
console.error('(ERROR) ' + this.messageConstruction(msg));
}

@@ -267,8 +109,5 @@

*/
public fatal(topic: LOGGING_TOPIC, msg: string, error: Error, throwError: boolean = false): void {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Fatal);
this.sentryError(topic, error, msg);
public fatal(msg: string): void {
if (this.canLog(LOGGING_LEVEL.FATAL) && this.showMessages === true)
console.error('(FATAL) ' + this.messageConstruction(msg));
if(throwError) throw error;
}

@@ -280,4 +119,3 @@

*/
public info(topic: LOGGING_TOPIC, msg: string): void {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Info);
public info(msg: string): void {
if (this.canLog(LOGGING_LEVEL.INFO) && this.showMessages === true)

@@ -291,4 +129,3 @@ console.info('(INFO) ' + this.messageConstruction(msg));

*/
public warn(topic: LOGGING_TOPIC, msg: string): void {
this.sentryBreadcrumb(topic, msg, Sentry.Severity.Warning);
public warn(msg: string): void {
if (this.canLog(LOGGING_LEVEL.WARN) && this.showMessages === true)

@@ -298,6 +135,46 @@ console.warn('(WARN) ' + this.messageConstruction(msg));

// #endregion Public Methods (8)
// #endregion Public Methods (11)
// #region Private Methods (2)
private canLog(loggingLevel: LOGGING_LEVEL): boolean {
switch (this.loggingLevel) {
case LOGGING_LEVEL.ERROR:
if (loggingLevel === LOGGING_LEVEL.FATAL) return false;
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.FATAL:
if (loggingLevel === LOGGING_LEVEL.WARN) return false;
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.WARN:
if (loggingLevel === LOGGING_LEVEL.INFO) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.INFO:
if (loggingLevel === LOGGING_LEVEL.DEBUG) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_HIGH) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_HIGH:
if (loggingLevel === LOGGING_LEVEL.DEBUG_MEDIUM) return false;
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_MEDIUM:
if (loggingLevel === LOGGING_LEVEL.DEBUG_LOW) return false;
case LOGGING_LEVEL.DEBUG_LOW:
case LOGGING_LEVEL.DEBUG:
default:
return true;
}
}
private messageConstruction(msg: string): string {

@@ -304,0 +181,0 @@ return new Date().toISOString() + ': ' + msg;

@@ -60,2 +60,11 @@ import { ShapeDiverViewerError, ShapeDiverViewerErrorType } from "./ShapeDiverError";

export class ShapeDiverViewerViewportError extends ShapeDiverViewerError {
constructor(
public readonly message: string,
public readonly errorObject?: Error | unknown
) {
super(ShapeDiverViewerErrorType.SESSION_ERROR, 'An error occurred while working with the viewport.', message);
}
}
export class ShapeDiverViewerLightError extends ShapeDiverViewerError {

@@ -62,0 +71,0 @@ constructor(

@@ -1,6 +0,6 @@

import { singleton } from 'tsyringe'
@singleton()
export class PerformanceEvaluator {
// #region Properties (2)
private static _instance: PerformanceEvaluator;
private _eval: {

@@ -19,25 +19,25 @@ start: number;

/**
* Start the evaluation with a specific id.
*
* @param id
*/
public start(time?: number): void {
this._eval = {
start: time || performance.now(),
section: {}
}
// #endregion Properties (2)
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (6)
/**
* Start the evaluation of a section with a specific id.
* End the performance evaluation and calculate the duration.
*
* @param id
*/
public startSection(sectionId: string, time?: number): void {
public end(): void {
if (!this._eval) return;
if (this._eval.end) return;
this._eval.section[sectionId] = {
start: time || performance.now(),
}
this._eval.end = performance.now();
this._eval.duration = this._eval.end! - this._eval.start;
}

@@ -62,15 +62,2 @@

/**
* End the performance evaluation and calculate the duration.
*
* @param id
*/
public end(): void {
if (!this._eval) return;
if (this._eval.end) return;
this._eval.end = performance.now();
this._eval.duration = this._eval.end! - this._eval.start;
}
/**
* Get the evaluation data for a specific id.

@@ -104,2 +91,29 @@ *

}
/**
* Start the evaluation with a specific id.
*
* @param id
*/
public start(time?: number): void {
this._eval = {
start: time || performance.now(),
section: {}
}
}
/**
* Start the evaluation of a section with a specific id.
*
* @param id
*/
public startSection(sectionId: string, time?: number): void {
if (!this._eval) return;
if (this._eval.end) return;
this._eval.section[sectionId] = {
start: time || performance.now(),
}
}
// #endregion Public Methods (6)
}
import { convert, validate, DefaultsV3_3 as Defaults, ISettingsV3_3 as ISettings, versions, latestVersion } from '@shapediver/viewer.settings';
import { container, singleton } from 'tsyringe'
import { EventEngine } from '../event-engine/EventEngine'
import { Logger, LOGGING_TOPIC } from '../logger/Logger';
import { Logger } from '../logger/Logger';
import { ShapeDiverViewerSettingsError } from '../logger/ShapeDiverViewerErrors';

@@ -20,4 +19,4 @@

private readonly _eventEngine: EventEngine = <EventEngine>container.resolve(EventEngine);
private readonly _logger: Logger = <Logger>container.resolve(Logger);
private readonly _eventEngine: EventEngine = EventEngine.instance;
private readonly _logger: Logger = Logger.instance;
private readonly _settings: ISettings = Defaults();

@@ -127,4 +126,3 @@ private _settingsJson: any;

} catch (e) {
const error = new ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + (<Error>e).message, <Error>e);
throw this._logger.handleError(LOGGING_TOPIC.SETTINGS, `SettingsEngine.loadSettings`, error);
throw new ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + (<Error>e).message, <Error>e);
}

@@ -131,0 +129,0 @@ } else {

@@ -1,22 +0,7 @@

import { container, singleton } from 'tsyringe'
import { EventEngine } from '../index'
import { StatePromise } from './StatePromise'
@singleton()
export class StateEngine {
// #region Properties (8)
// #region Properties (6)
private readonly _customStates: {
[key: string]: StatePromise<boolean>
} = {};
private readonly _eventEngine: EventEngine = <EventEngine>container.resolve(EventEngine);
private readonly _fontLoaded: StatePromise<boolean>;
private readonly _sessionEngines: {
[key: string]: {
id: string,
initialized: StatePromise<boolean>,
settingsRegistered: StatePromise<boolean>,
}
} = {};
private readonly _fontLoaded: StatePromise<boolean> = new StatePromise();
private readonly _renderingEngines: {

@@ -32,8 +17,17 @@ [key: string]: {

} = {};
private readonly _sessionEngines: {
[key: string]: {
id: string,
initialized: StatePromise<boolean>,
settingsRegistered: StatePromise<boolean>,
}
} = {};
// #endregion Properties (8)
private static _instance: StateEngine;
// #endregion Properties (6)
// #region Constructors (1)
constructor() {
private constructor() {
this._fontLoaded = new StatePromise();

@@ -44,4 +38,12 @@ }

// #region Public Accessors (7)
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Accessors (3)
public get fontLoaded(): StatePromise<boolean> {

@@ -51,26 +53,26 @@ return this._fontLoaded;

public get sessionEngines(): {
public get renderingEngines(): {
[key: string]: {
id: string,
initialized: StatePromise<boolean>,
settingsRegistered: StatePromise<boolean>,
settingsAssigned: StatePromise<boolean>,
environmentMapLoaded: StatePromise<boolean>,
boundingBoxCreated: StatePromise<boolean>,
busy: string[]
}
} {
return this._sessionEngines;
return this._renderingEngines;
}
public get renderingEngines(): {
public get sessionEngines(): {
[key: string]: {
id: string,
initialized: StatePromise<boolean>,
settingsAssigned: StatePromise<boolean>,
environmentMapLoaded: StatePromise<boolean>,
boundingBoxCreated: StatePromise<boolean>,
busy: string[]
settingsRegistered: StatePromise<boolean>,
}
} {
return this._renderingEngines;
return this._sessionEngines;
}
// #endregion Public Accessors (7)
// #endregion Public Accessors (3)
}

@@ -1,6 +0,5 @@

import { singleton } from 'tsyringe'
import UAParser from 'ua-parser-js';
@singleton()
export class SystemInfo {
// #region Properties (5)

@@ -12,3 +11,9 @@ private readonly _isBrowser: boolean;

constructor() {
private static _instance: SystemInfo;
// #endregion Properties (5)
// #region Constructors (1)
private constructor() {
this._parser = new UAParser();

@@ -33,19 +38,14 @@ const isInternetExplorer = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent.indexOf('Trident') > -1;

/**
* Check if we are on a Mac OS device
*/
public get isMacOS(): boolean {
const osName = this._parser.getOS().name;
return osName === 'Mac OS';
};
// #endregion Constructors (1)
/**
* Check if we are on an IOS device
*/
public get isIOS(): boolean {
const osName = this._parser.getOS().name;
return osName === 'iOS' ||
(window.navigator && window.navigator.maxTouchPoints === 5 && window.navigator.platform === 'MacIntel');
};
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Accessors (11)
/**

@@ -57,21 +57,12 @@ * Check if we are on an Android device

return osName === 'Android';
};
}
/**
* Check if we are on a mobile device
* Check if we are running in a browser
*/
public get isMobile(): boolean {
const type = this._parser.getDevice().type;
return type === 'mobile' || type === 'tablet';
};
public get isBrowser(): boolean {
return this._isBrowser;
}
/**
* Check if we are running in internet explorer (arrrggghhhh!!!!)
*/
public get isIE(): boolean {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('IE'));
};
/**
* Check if we are running in Safari

@@ -82,26 +73,28 @@ */

return !!(browserName && browserName.includes('Chrome'));
};
}
/**
* Check if we are running in Safari
* Check if we are running in Firefox
*/
public get isSafari(): boolean {
public get isFirefox(): boolean {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Safari'));
};
return !!(browserName && browserName.includes('Firefox'));
}
/**
* Check if we are running in Firefox
* Check if we are running in internet explorer (arrrggghhhh!!!!)
*/
public get isFirefox(): boolean {
public get isIE(): boolean {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Firefox'));
};
return !!(browserName && browserName.includes('IE'));
}
/**
* Check if we are running in a browser
* Check if we are on an IOS device
*/
public get isBrowser(): boolean {
return this._isBrowser;
};
public get isIOS(): boolean {
const osName = this._parser.getOS().name;
return osName === 'iOS' ||
(window.navigator && window.navigator.maxTouchPoints === 5 && window.navigator.platform === 'MacIntel');
}

@@ -113,5 +106,29 @@ /**

return this._isIframe;
};
}
/**
* Check if we are on a Mac OS device
*/
public get isMacOS(): boolean {
const osName = this._parser.getOS().name;
return osName === 'Mac OS';
}
/**
* Check if we are on a mobile device
*/
public get isMobile(): boolean {
const type = this._parser.getDevice().type;
return type === 'mobile' || type === 'tablet';
}
/**
* Check if we are running in Safari
*/
public get isSafari(): boolean {
const browserName = this._parser.getBrowser().name;
return !!(browserName && browserName.includes('Safari'));
}
/**
* Get guessed origin of embedding website

@@ -121,3 +138,5 @@ */

return this._origin + '';
};
}
// #endregion Public Accessors (11)
}

@@ -1,13 +0,27 @@

import { singleton } from 'tsyringe'
@singleton()
export class TypeChecker {
// #region Properties (1)
public isTypeOf(value: any, type: string): boolean {
return typeof value === type;
private static _instance: TypeChecker;
// #endregion Properties (1)
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (2)
public isHTMLCanvasElement(value: any): boolean {
return value instanceof HTMLCanvasElement;
}
public isTypeOf(value: any, type: string): boolean {
return typeof value === type;
}
// #endregion Public Methods (2)
}

@@ -1,6 +0,20 @@

import { singleton } from 'tsyringe'
import { parse as parseUUID, stringify as stringifyUUID, v4, validate as validateUUID } from 'uuid'
@singleton()
export class UuidGenerator {
// #region Properties (1)
private static _instance: UuidGenerator;
// #endregion Properties (1)
// #region Public Static Accessors (1)
public static get instance() {
return this._instance || (this._instance = new this());
}
// #endregion Public Static Accessors (1)
// #region Public Methods (4)
/**

@@ -11,14 +25,5 @@ * Creates a new uuid v4.

return v4();
};
}
/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
public validate(uuid: string): boolean {
return validateUUID(uuid);
};
/**
* Parse the uuid to array of bytes

@@ -31,3 +36,3 @@ *

return parseUUID(uuid);
};
}

@@ -42,3 +47,14 @@ /**

return stringifyUUID(uuid);
};
}
/**
* Checks if the provided string is a valid uuid.
*
* @param uuid the uuid to check
*/
public validate(uuid: string): boolean {
return validateUUID(uuid);
}
// #endregion Public Methods (4)
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc