Socket
Socket
Sign inDemoInstall

@shapediver/viewer.shared.services

Package Overview
Dependencies
Maintainers
5
Versions
203
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 1.6.1 to 1.6.2

3

dist/logger/Logger.d.ts

@@ -25,3 +25,4 @@ export declare enum LOGGINGLEVEL {

SDTF = "sdtf",
THREE = "three"
THREE = "three",
SETTINGS = "settings"
}

@@ -28,0 +29,0 @@ export declare class Logger {

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

LOGGINGTOPIC["THREE"] = "three";
LOGGINGTOPIC["SETTINGS"] = "settings";
})(LOGGINGTOPIC = exports.LOGGINGTOPIC || (exports.LOGGINGTOPIC = {}));

@@ -67,0 +68,0 @@ let Logger = class Logger {

@@ -11,8 +11,6 @@ import { ISettingsV3 } from '@shapediver/viewer.settings';

export declare class SettingsEngine {
private readonly _eventEngine;
private readonly _logger;
private readonly _settings;
private readonly _eventEngine;
private readonly _stateEngine;
private readonly _sessionSettings;
private _version;
get settings(): ISettingsV3;
private _version?;
get ar(): IARSettings;

@@ -27,10 +25,12 @@ get camera(): ICameraSettings;

set session(value: ISessionSettings);
get settings(): ISettingsV3;
convertToTargetVersion(): any;
loadSettings(json: any, sessionId: string, loadAsPrimary?: boolean): void;
flatten(): {
[key: string]: any;
};
loadSettings(json: any, sessionId: string, loadAsPrimary?: boolean): void;
reset(): void;
private cleanSettings;
}
export {};
//# sourceMappingURL=SettingsEngine.d.ts.map

@@ -14,14 +14,10 @@ "use strict";

const EventTypes_1 = require("../event-engine/EventTypes");
const StateEngine_1 = require("../state-engine/StateEngine");
const Logger_1 = require("../logger/Logger");
const SDError_1 = require("../logger/SDError");
let SettingsEngine = class SettingsEngine {
constructor() {
this._eventEngine = tsyringe_1.container.resolve(EventEngine_1.EventEngine);
this._logger = tsyringe_1.container.resolve(Logger_1.Logger);
this._settings = viewer_settings_1.DefaultsV3();
this._eventEngine = tsyringe_1.container.resolve(EventEngine_1.EventEngine);
this._stateEngine = tsyringe_1.container.resolve(StateEngine_1.StateEngine);
this._sessionSettings = ['commitParameters', 'commitSettings', 'controlNames', 'controlOrder', 'parametersHidden'];
this._version = '3.0';
}
get settings() {
return this._settings;
}
get ar() {

@@ -54,24 +50,8 @@ return this._settings.ar;

}
get settings() {
return this._settings;
}
convertToTargetVersion() {
return viewer_settings_1.convert(this._settings, this._version);
return viewer_settings_1.convert(this._settings, this._version || '3.0');
}
loadSettings(json, sessionId, loadAsPrimary = false) {
try {
viewer_settings_1.validate(json, '3.0');
this._version = '3.0';
}
catch (e) { }
try {
viewer_settings_1.validate(json, '2.0');
this._version = '2.0';
}
catch (e) { }
try {
viewer_settings_1.validate(json, '1.0');
this._version = '1.0';
}
catch (e) { }
this._settings = viewer_settings_1.convert(json, '3.0');
this._eventEngine.emitEvent(EventTypes_1.EVENTTYPE.SETTINGS.SETTINGS_REGISTERED, { sessionId });
}
flatten() {

@@ -99,2 +79,31 @@ const flattenObject = (ob) => {

}
loadSettings(json, sessionId, loadAsPrimary = false) {
try {
viewer_settings_1.validate(json, '3.0');
this._version = '3.0';
}
catch (e) {
if (!(e.message && e.message.includes('The settings do have a different version than the target version.')))
this._logger.error(Logger_1.LOGGINGTOPIC.SETTINGS, new SDError_1.SDError(e.message, e), 'Settings could not be validated.', false, true);
}
try {
viewer_settings_1.validate(json, '2.0');
this._version = '2.0';
}
catch (e) { }
try {
viewer_settings_1.validate(json, '1.0');
this._version = '1.0';
}
catch (e) { }
if (!this._version) {
this._version = '3.0';
this._eventEngine.emitEvent(EventTypes_1.EVENTTYPE.SETTINGS.SETTINGS_REGISTERED, { sessionId });
}
else {
this._settings = viewer_settings_1.convert(json, '3.0');
this.cleanSettings(this._settings);
this._eventEngine.emitEvent(EventTypes_1.EVENTTYPE.SETTINGS.SETTINGS_REGISTERED, { sessionId });
}
}
reset() {

@@ -104,2 +113,44 @@ this._settings = viewer_settings_1.DefaultsV3();

}
cleanSettings(json) {
for (let c in json.camera.cameras) {
const camera = json.camera.cameras[c];
if (camera.type === 'perspective') {
const restrictions = camera.controls.restrictions;
if (restrictions.position.cube.min.x === null)
restrictions.position.cube.min.x = -Infinity;
if (restrictions.position.cube.min.y === null)
restrictions.position.cube.min.y = -Infinity;
if (restrictions.position.cube.min.z === null)
restrictions.position.cube.min.z = -Infinity;
if (restrictions.position.cube.max.x === null)
restrictions.position.cube.max.x = Infinity;
if (restrictions.position.cube.max.y === null)
restrictions.position.cube.max.y = Infinity;
if (restrictions.position.cube.max.z === null)
restrictions.position.cube.max.z = Infinity;
if (restrictions.position.sphere.radius === null)
restrictions.position.sphere.radius = Infinity;
if (restrictions.target.cube.min.x === null)
restrictions.target.cube.min.x = -Infinity;
if (restrictions.target.cube.min.y === null)
restrictions.target.cube.min.y = -Infinity;
if (restrictions.target.cube.min.z === null)
restrictions.target.cube.min.z = -Infinity;
if (restrictions.target.cube.max.x === null)
restrictions.target.cube.max.x = Infinity;
if (restrictions.target.cube.max.y === null)
restrictions.target.cube.max.y = Infinity;
if (restrictions.target.cube.max.z === null)
restrictions.target.cube.max.z = Infinity;
if (restrictions.target.sphere.radius === null)
restrictions.target.sphere.radius = Infinity;
if (restrictions.rotation.minAzimuthAngle === null)
restrictions.rotation.minAzimuthAngle = -Infinity;
if (restrictions.rotation.maxAzimuthAngle === null)
restrictions.rotation.maxAzimuthAngle = Infinity;
if (restrictions.zoom.maxDistance === null)
restrictions.zoom.maxDistance = Infinity;
}
}
}
};

@@ -106,0 +157,0 @@ SettingsEngine = __decorate([

{
"name": "@shapediver/viewer.shared.services",
"version": "1.6.1",
"version": "1.6.2",
"description": "",

@@ -42,4 +42,4 @@ "keywords": [],

"@sentry/tracing": "^6.7.2",
"@shapediver/viewer.settings": "^0.1.10",
"@shapediver/viewer.shared.build-data": "^1.6.1",
"@shapediver/viewer.settings": "^0.1.12",
"@shapediver/viewer.shared.build-data": "^1.6.2",
"@types/ua-parser-js": "^0.7.36",

@@ -53,3 +53,3 @@ "@types/uuid": "^8.3.0",

},
"gitHead": "a1189a4c5abe8c634e5b260e4210686f6210c7ad"
"gitHead": "0365e643386173b2422318862f90da493b062027"
}

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