@shapediver/viewer.shared.services 3.3.4 → 3.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -6
- package/src/converter/Converter.ts +0 -407
- package/src/dom-event-engine/DomEventEngine.ts +0 -310
- package/src/dom-event-engine/IDomEventListener.ts +0 -14
- package/src/event-engine/EventEngine.ts +0 -131
- package/src/event-engine/EventTypes.ts +0 -334
- package/src/event-engine/interfaces/ICallback.ts +0 -5
- package/src/event-engine/interfaces/IEvent.ts +0 -1
- package/src/event-engine/interfaces/IListener.ts +0 -8
- package/src/http-client/HttpClient.ts +0 -353
- package/src/http-client/HttpResponse.ts +0 -6
- package/src/index.ts +0 -166
- package/src/input-validator/InputValidator.ts +0 -123
- package/src/logger/ErrorTypeGuards.ts +0 -130
- package/src/logger/Logger.ts +0 -174
- package/src/logger/ShapeDiverBackendErrors.ts +0 -40
- package/src/logger/ShapeDiverError.ts +0 -58
- package/src/logger/ShapeDiverViewerErrors.ts +0 -121
- package/src/performance-evaluator/PerformanceEvaluator.ts +0 -146
- package/src/settings-engine/SettingsEngine.ts +0 -182
- package/src/state-engine/ISessionGlobalAccessObjectDefinition.ts +0 -25
- package/src/state-engine/IViewportGlobalAccessObjectDefinition.ts +0 -29
- package/src/state-engine/StateEngine.ts +0 -47
- package/src/state-engine/StatePromise.ts +0 -54
- package/src/system-info/SystemInfo.ts +0 -143
- package/src/type-check/TypeChecker.ts +0 -27
- package/src/utilities/base64.ts +0 -15
- package/src/uuid-generator/UuidGenerator.ts +0 -57
- package/tsconfig.json +0 -17
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
convert,
|
|
3
|
-
Defaults,
|
|
4
|
-
ISettings,
|
|
5
|
-
latestVersion,
|
|
6
|
-
previousVersion,
|
|
7
|
-
validate
|
|
8
|
-
} from '@shapediver/viewer.settings';
|
|
9
|
-
import { ShapeDiverViewerSettingsError } from '../logger/ShapeDiverViewerErrors';
|
|
10
|
-
|
|
11
|
-
// #region Type aliases (8)
|
|
12
|
-
|
|
13
|
-
type IARSettings = ISettings['ar'];
|
|
14
|
-
type ICameraSettings = ISettings['camera'];
|
|
15
|
-
type IEnvironmentGeometrySettings = ISettings['environmentGeometry'];
|
|
16
|
-
type IEnvironmentSettings = ISettings['environment'];
|
|
17
|
-
type IGeneralSettings = ISettings['general'];
|
|
18
|
-
type ILightSettings = ISettings['light'];
|
|
19
|
-
type IRenderingSettings = ISettings['rendering'];
|
|
20
|
-
type ISessionSettings = ISettings['session'];
|
|
21
|
-
|
|
22
|
-
// #endregion Type aliases (8)
|
|
23
|
-
|
|
24
|
-
// #region Classes (1)
|
|
25
|
-
|
|
26
|
-
export class SettingsEngine {
|
|
27
|
-
// #region Properties (4)
|
|
28
|
-
|
|
29
|
-
private _settings: ISettings = Defaults();
|
|
30
|
-
private _settingsJson: unknown;
|
|
31
|
-
|
|
32
|
-
// #endregion Properties (4)
|
|
33
|
-
|
|
34
|
-
// #region Public Getters And Setters (11)
|
|
35
|
-
|
|
36
|
-
public get ar(): IARSettings {
|
|
37
|
-
return this._settings.ar;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public get camera(): ICameraSettings {
|
|
41
|
-
return this._settings.camera;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public get environment(): IEnvironmentSettings {
|
|
45
|
-
return this._settings.environment;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public get environmentGeometry(): IEnvironmentGeometrySettings {
|
|
49
|
-
return this._settings.environmentGeometry;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public get general(): IGeneralSettings {
|
|
53
|
-
return this._settings.general;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public get light(): ILightSettings {
|
|
57
|
-
return this._settings.light;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public get rendering(): IRenderingSettings {
|
|
61
|
-
return this._settings.rendering;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public get session(): ISessionSettings {
|
|
65
|
-
return this._settings.session;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public set session(value: ISessionSettings) {
|
|
69
|
-
this._settings.session = value;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public get settings(): ISettings {
|
|
73
|
-
return this._settings;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public get settingsJson(): unknown {
|
|
77
|
-
return this._settingsJson;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// #endregion Public Getters And Setters (11)
|
|
81
|
-
|
|
82
|
-
// #region Public Methods (2)
|
|
83
|
-
|
|
84
|
-
public loadSettings(json: unknown) {
|
|
85
|
-
this._settingsJson = json;
|
|
86
|
-
if (JSON.stringify(json) !== JSON.stringify({})) {
|
|
87
|
-
for (let i = 0; i < previousVersion.length; i++) {
|
|
88
|
-
const v = previousVersion[i];
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
validate(json, v);
|
|
92
|
-
this._settings = convert(json, latestVersion) as ISettings;
|
|
93
|
-
this.cleanSettings(this._settings);
|
|
94
|
-
return;
|
|
95
|
-
} catch (e) {
|
|
96
|
-
// it's ok, we just try the next version
|
|
97
|
-
// only the latest version is expected to be valid
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
validate(json, latestVersion);
|
|
103
|
-
this._settings = convert(json, latestVersion) as ISettings;
|
|
104
|
-
this.cleanSettings(this._settings);
|
|
105
|
-
return;
|
|
106
|
-
} catch (e) {
|
|
107
|
-
throw new ShapeDiverViewerSettingsError('SettingsEngine.loadSettings: Settings could not be validated. ' + (<Error>e).message, <Error>e);
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
this._settings = Defaults();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public reset() {
|
|
116
|
-
this._settings = Defaults();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// #endregion Public Methods (2)
|
|
120
|
-
|
|
121
|
-
// #region Private Methods (1)
|
|
122
|
-
|
|
123
|
-
private cleanSettings(json: ISettings) {
|
|
124
|
-
for (const c in json.camera.cameras) {
|
|
125
|
-
const camera = json.camera.cameras[c];
|
|
126
|
-
if (camera.type === 'perspective') {
|
|
127
|
-
const restrictions = camera.controls.restrictions;
|
|
128
|
-
if (restrictions.position.cube.min.x === null) restrictions.position.cube.min.x = -Infinity;
|
|
129
|
-
if (restrictions.position.cube.min.y === null) restrictions.position.cube.min.y = -Infinity;
|
|
130
|
-
if (restrictions.position.cube.min.z === null) restrictions.position.cube.min.z = -Infinity;
|
|
131
|
-
if (restrictions.position.cube.max.x === null) restrictions.position.cube.max.x = Infinity;
|
|
132
|
-
if (restrictions.position.cube.max.y === null) restrictions.position.cube.max.y = Infinity;
|
|
133
|
-
if (restrictions.position.cube.max.z === null) restrictions.position.cube.max.z = Infinity;
|
|
134
|
-
if (restrictions.position.sphere.radius === null) restrictions.position.sphere.radius = Infinity;
|
|
135
|
-
if (restrictions.target.cube.min.x === null) restrictions.target.cube.min.x = -Infinity;
|
|
136
|
-
if (restrictions.target.cube.min.y === null) restrictions.target.cube.min.y = -Infinity;
|
|
137
|
-
if (restrictions.target.cube.min.z === null) restrictions.target.cube.min.z = -Infinity;
|
|
138
|
-
if (restrictions.target.cube.max.x === null) restrictions.target.cube.max.x = Infinity;
|
|
139
|
-
if (restrictions.target.cube.max.y === null) restrictions.target.cube.max.y = Infinity;
|
|
140
|
-
if (restrictions.target.cube.max.z === null) restrictions.target.cube.max.z = Infinity;
|
|
141
|
-
if (restrictions.target.sphere.radius === null) restrictions.target.sphere.radius = Infinity;
|
|
142
|
-
if (restrictions.rotation.minAzimuthAngle === null) restrictions.rotation.minAzimuthAngle = -Infinity;
|
|
143
|
-
if (restrictions.rotation.maxAzimuthAngle === null) restrictions.rotation.maxAzimuthAngle = Infinity;
|
|
144
|
-
if (restrictions.zoom.maxDistance === null) restrictions.zoom.maxDistance = Infinity;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// #endregion Private Methods (1)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// #endregion Classes (1)
|
|
153
|
-
|
|
154
|
-
// #region Enums (1)
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Session settings to be used by a viewport.
|
|
158
|
-
*
|
|
159
|
-
* The {@link https://help.shapediver.com/doc/Geometry-Backend.1863942173.html|ShapeDiver Geometry Backend}
|
|
160
|
-
* allows to persist settings of the viewer, individually for each model that it hosts. Persisting the settings
|
|
161
|
-
* of the viewer requires permissions which are typically only granted to the owner of the model. Editing
|
|
162
|
-
* of the settings typically happens on the model edit page of the ShapeDiver Platform.
|
|
163
|
-
*
|
|
164
|
-
* Whenever an instance of the viewer creates a session with a model, the settings are made available to the viewer.
|
|
165
|
-
* It is possible to use multiple sessions with different models from a single instance of the viewer.
|
|
166
|
-
* Therefore the viewer offers a choice on which settings to use.
|
|
167
|
-
*/
|
|
168
|
-
export enum SESSION_SETTINGS_MODE {
|
|
169
|
-
/** No settings of a session will be used for the viewport. */
|
|
170
|
-
NONE = 'none',
|
|
171
|
-
/**
|
|
172
|
-
* The settings of the very first session created will be used for the viewport.
|
|
173
|
-
*/
|
|
174
|
-
FIRST = 'first',
|
|
175
|
-
/**
|
|
176
|
-
* Use this mode in case you want to assign a specific session identifier
|
|
177
|
-
* to the viewport, whose settings will be used.
|
|
178
|
-
*/
|
|
179
|
-
MANUAL = 'manual',
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// #endregion Enums (1)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SettingsEngine } from '../settings-engine/SettingsEngine';
|
|
2
|
-
import { ShapeDiverRequestGltfUploadQueryConversion, ShapeDiverResponseDto } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
3
|
-
import { StatePromise } from './StatePromise';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Interface for the global access definition of a session.
|
|
7
|
-
* This interface is used to define the properties and methods that are available via the state engine for a session.
|
|
8
|
-
* This means that they can be called without having a direct reference to the session engine.
|
|
9
|
-
*/
|
|
10
|
-
export interface ISessionGlobalAccessObjectDefinition {
|
|
11
|
-
// #region Properties (9)
|
|
12
|
-
|
|
13
|
-
readonly canUploadGLTF: boolean,
|
|
14
|
-
readonly id: string,
|
|
15
|
-
readonly initialOutputsLoaded: StatePromise<boolean>,
|
|
16
|
-
readonly initialized: StatePromise<boolean>,
|
|
17
|
-
readonly modelViewUrl: string,
|
|
18
|
-
readonly settingsEngine: SettingsEngine,
|
|
19
|
-
readonly settingsRegistered: StatePromise<boolean>,
|
|
20
|
-
|
|
21
|
-
isFirstSession: boolean,
|
|
22
|
-
uploadGLTF: (gltf: Blob, name: ShapeDiverRequestGltfUploadQueryConversion | undefined) => Promise<ShapeDiverResponseDto>,
|
|
23
|
-
|
|
24
|
-
// #endregion Properties (9)
|
|
25
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SESSION_SETTINGS_MODE, SettingsEngine } from '../settings-engine/SettingsEngine';
|
|
2
|
-
import { StatePromise } from './StatePromise';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Interface for the global access definition of a viewport.
|
|
6
|
-
* This interface is used to define the properties and methods that are available via the state engine for a viewport.
|
|
7
|
-
* This means that they can be called without having a direct reference to the viewport engine.
|
|
8
|
-
*/
|
|
9
|
-
export interface IViewportGlobalAccessObjectDefinition {
|
|
10
|
-
// #region Properties (14)
|
|
11
|
-
|
|
12
|
-
readonly boundingBoxCreated: StatePromise<boolean>,
|
|
13
|
-
readonly busy: string[],
|
|
14
|
-
readonly id: string,
|
|
15
|
-
readonly initialized: StatePromise<boolean>,
|
|
16
|
-
readonly sessionSettingsId?: string,
|
|
17
|
-
readonly sessionSettingsMode: SESSION_SETTINGS_MODE,
|
|
18
|
-
readonly settingsAssigned: StatePromise<boolean>,
|
|
19
|
-
|
|
20
|
-
applySettings: (sections?: { ar?: boolean, scene?: boolean, camera?: boolean, light?: boolean, environment?: boolean, general?: boolean, postprocessing?: boolean }, settingsEngine?: SettingsEngine, updateViewport?: boolean) => Promise<void>,
|
|
21
|
-
assignSettingsEngine: (settingsEngine: SettingsEngine) => void,
|
|
22
|
-
displayErrorMessage: (message: string) => void,
|
|
23
|
-
environmentMapLoaded: StatePromise<boolean>,
|
|
24
|
-
reset: () => void,
|
|
25
|
-
saveSettings: (settingsEngine?: SettingsEngine) => void,
|
|
26
|
-
update: (id: string) => void,
|
|
27
|
-
|
|
28
|
-
// #endregion Properties (14)
|
|
29
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ISessionGlobalAccessObjectDefinition } from './ISessionGlobalAccessObjectDefinition';
|
|
2
|
-
import { IViewportGlobalAccessObjectDefinition } from './IViewportGlobalAccessObjectDefinition';
|
|
3
|
-
import { StatePromise } from './StatePromise';
|
|
4
|
-
|
|
5
|
-
export class StateEngine {
|
|
6
|
-
// #region Properties (4)
|
|
7
|
-
|
|
8
|
-
private readonly _fontLoaded: StatePromise<boolean> = new StatePromise();
|
|
9
|
-
private readonly _sessionEngines: { [key: string]: ISessionGlobalAccessObjectDefinition | undefined } = {};
|
|
10
|
-
private readonly _viewportEngines: { [key: string]: IViewportGlobalAccessObjectDefinition | undefined } = {};
|
|
11
|
-
|
|
12
|
-
private static _instance: StateEngine;
|
|
13
|
-
|
|
14
|
-
// #endregion Properties (4)
|
|
15
|
-
|
|
16
|
-
// #region Constructors (1)
|
|
17
|
-
|
|
18
|
-
private constructor() {
|
|
19
|
-
this._fontLoaded = new StatePromise();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// #endregion Constructors (1)
|
|
23
|
-
|
|
24
|
-
// #region Public Static Getters And Setters (1)
|
|
25
|
-
|
|
26
|
-
public static get instance() {
|
|
27
|
-
return this._instance || (this._instance = new this());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// #endregion Public Static Getters And Setters (1)
|
|
31
|
-
|
|
32
|
-
// #region Public Getters And Setters (3)
|
|
33
|
-
|
|
34
|
-
public get fontLoaded(): StatePromise<boolean> {
|
|
35
|
-
return this._fontLoaded;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public get sessionEngines(): { [key: string]: ISessionGlobalAccessObjectDefinition | undefined } {
|
|
39
|
-
return this._sessionEngines;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public get viewportEngines(): { [key: string]: IViewportGlobalAccessObjectDefinition | undefined } {
|
|
43
|
-
return this._viewportEngines;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// #endregion Public Getters And Setters (3)
|
|
47
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export class StatePromise<T> {
|
|
2
|
-
private _resolved: boolean = false;
|
|
3
|
-
private _resolve!: (value: T | PromiseLike<T>) => void;
|
|
4
|
-
private _reject!: (value: T | PromiseLike<T>) => void;
|
|
5
|
-
|
|
6
|
-
private _promise: Promise<T>;
|
|
7
|
-
private _callbacks: (() => void)[] = [];
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this._promise = new Promise((resolve, reject) => {
|
|
11
|
-
this._resolve = resolve;
|
|
12
|
-
this._reject = reject;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
this._promise.finally(() => {
|
|
16
|
-
this._resolved = true;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public get resolved(): boolean {
|
|
21
|
-
return this._resolved;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public get resolve(): (value: T | PromiseLike<T>) => void {
|
|
25
|
-
return this._resolve;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public get reject(): (value: T | PromiseLike<T>) => void {
|
|
29
|
-
return this._reject;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public async then(callback: () => void ) {
|
|
33
|
-
this._callbacks.push(callback);
|
|
34
|
-
this.resolved === true ? callback() : this._promise.then(callback);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public reset() {
|
|
38
|
-
this._resolved = false;
|
|
39
|
-
|
|
40
|
-
this._promise = new Promise((resolve, reject) => {
|
|
41
|
-
this._resolve = resolve;
|
|
42
|
-
this._reject = reject;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this._promise.finally(() => {
|
|
46
|
-
this._resolved = true;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const callbackCopy = [...this._callbacks];
|
|
50
|
-
this._callbacks = [];
|
|
51
|
-
for(let i = 0; i < callbackCopy.length; i++)
|
|
52
|
-
this.then(callbackCopy[i])
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import UAParser from 'ua-parser-js';
|
|
2
|
-
|
|
3
|
-
export class SystemInfo {
|
|
4
|
-
// #region Properties (5)
|
|
5
|
-
|
|
6
|
-
private readonly _isBrowser: boolean;
|
|
7
|
-
private readonly _isIframe: boolean;
|
|
8
|
-
private readonly _origin: string;
|
|
9
|
-
private readonly _parser: UAParser;
|
|
10
|
-
|
|
11
|
-
private static _instance: SystemInfo;
|
|
12
|
-
|
|
13
|
-
// #endregion Properties (5)
|
|
14
|
-
|
|
15
|
-
// #region Constructors (1)
|
|
16
|
-
|
|
17
|
-
private constructor() {
|
|
18
|
-
this._parser = new UAParser();
|
|
19
|
-
const isInternetExplorer = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent.indexOf('Trident') > -1;
|
|
20
|
-
this._isBrowser = isInternetExplorer ||
|
|
21
|
-
(typeof document !== 'undefined'
|
|
22
|
-
&& typeof document.getElementById === 'function'
|
|
23
|
-
&& window
|
|
24
|
-
&& typeof window.Event === 'function'
|
|
25
|
-
);
|
|
26
|
-
this._isIframe = false;
|
|
27
|
-
if (this._isBrowser) {
|
|
28
|
-
// in case we are running in an iframe, parent and window are different, in
|
|
29
|
-
// that case we use the referrer
|
|
30
|
-
this._isIframe = parent !== window;
|
|
31
|
-
this._origin = this._isIframe ? document.referrer : window.location.origin;
|
|
32
|
-
} else {
|
|
33
|
-
this._origin = 'direct';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// #endregion Constructors (1)
|
|
38
|
-
|
|
39
|
-
// #region Public Static Accessors (1)
|
|
40
|
-
|
|
41
|
-
public static get instance() {
|
|
42
|
-
return this._instance || (this._instance = new this());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// #endregion Public Static Accessors (1)
|
|
46
|
-
|
|
47
|
-
// #region Public Accessors (11)
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check if we are on an Android device
|
|
51
|
-
*/
|
|
52
|
-
public get isAndroid(): boolean {
|
|
53
|
-
const osName = this._parser.getOS().name;
|
|
54
|
-
return osName === 'Android';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check if we are running in a browser
|
|
59
|
-
*/
|
|
60
|
-
public get isBrowser(): boolean {
|
|
61
|
-
return this._isBrowser;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Check if we are running in Safari
|
|
66
|
-
*/
|
|
67
|
-
public get isChrome(): boolean {
|
|
68
|
-
const browserName = this._parser.getBrowser().name;
|
|
69
|
-
return !!(browserName && browserName.includes('Chrome'));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Check if we are running in Firefox
|
|
74
|
-
*/
|
|
75
|
-
public get isFirefox(): boolean {
|
|
76
|
-
const browserName = this._parser.getBrowser().name;
|
|
77
|
-
return !!(browserName && browserName.includes('Firefox'));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check if we are running in internet explorer (arrrggghhhh!!!!)
|
|
82
|
-
*/
|
|
83
|
-
public get isIE(): boolean {
|
|
84
|
-
const browserName = this._parser.getBrowser().name;
|
|
85
|
-
return !!(browserName && browserName.includes('IE'));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Check if we are on an IOS device
|
|
90
|
-
*/
|
|
91
|
-
public get isIOS(): boolean {
|
|
92
|
-
const osName = this._parser.getOS().name;
|
|
93
|
-
return osName === 'iOS' ||
|
|
94
|
-
(typeof window !== undefined && window.navigator && window.navigator.maxTouchPoints === 5 && window.navigator.platform === 'MacIntel');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Check if we are running in an iframe
|
|
99
|
-
*/
|
|
100
|
-
public get isIframe(): boolean {
|
|
101
|
-
return this._isIframe;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Check if we are running in an instagram browser
|
|
106
|
-
*/
|
|
107
|
-
public get isInstagram(): boolean {
|
|
108
|
-
return this._parser.getBrowser().name === "Instagram";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Check if we are on a Mac OS device
|
|
113
|
-
*/
|
|
114
|
-
public get isMacOS(): boolean {
|
|
115
|
-
const osName = this._parser.getOS().name;
|
|
116
|
-
return osName === 'Mac OS';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Check if we are on a mobile device
|
|
121
|
-
*/
|
|
122
|
-
public get isMobile(): boolean {
|
|
123
|
-
const type = this._parser.getDevice().type;
|
|
124
|
-
return type === 'mobile' || type === 'tablet';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Check if we are running in Safari
|
|
129
|
-
*/
|
|
130
|
-
public get isSafari(): boolean {
|
|
131
|
-
const browserName = this._parser.getBrowser().name;
|
|
132
|
-
return !!(browserName && browserName.includes('Safari'));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Get guessed origin of embedding website
|
|
137
|
-
*/
|
|
138
|
-
public get origin(): string {
|
|
139
|
-
return this._origin + '';
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// #endregion Public Accessors (11)
|
|
143
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export class TypeChecker {
|
|
2
|
-
// #region Properties (1)
|
|
3
|
-
|
|
4
|
-
private static _instance: TypeChecker;
|
|
5
|
-
|
|
6
|
-
// #endregion Properties (1)
|
|
7
|
-
|
|
8
|
-
// #region Public Static Accessors (1)
|
|
9
|
-
|
|
10
|
-
public static get instance() {
|
|
11
|
-
return this._instance || (this._instance = new this());
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// #endregion Public Static Accessors (1)
|
|
15
|
-
|
|
16
|
-
// #region Public Methods (2)
|
|
17
|
-
|
|
18
|
-
public isHTMLCanvasElement(value: any): boolean {
|
|
19
|
-
return value instanceof HTMLCanvasElement;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public isTypeOf(value: any, type: string): boolean {
|
|
23
|
-
return typeof value === type;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// #endregion Public Methods (2)
|
|
27
|
-
}
|
package/src/utilities/base64.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const atobCustom = (str: string): string => {
|
|
2
|
-
if(typeof window !== 'undefined' && window.atob) {
|
|
3
|
-
return window.atob(str);
|
|
4
|
-
} else {
|
|
5
|
-
return Buffer.from(str, 'base64').toString();
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const btoaCustom = (str: string): string => {
|
|
10
|
-
if(typeof window !== 'undefined' && window.btoa) {
|
|
11
|
-
return window.btoa(str);
|
|
12
|
-
} else {
|
|
13
|
-
return Buffer.from(str).toString('base64');
|
|
14
|
-
}
|
|
15
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { parse as parseUUID, stringify as stringifyUUID, v4, validate as validateUUID } from 'uuid'
|
|
2
|
-
|
|
3
|
-
export class UuidGenerator {
|
|
4
|
-
// #region Properties (1)
|
|
5
|
-
|
|
6
|
-
private static _instance: UuidGenerator;
|
|
7
|
-
|
|
8
|
-
// #endregion Properties (1)
|
|
9
|
-
|
|
10
|
-
// #region Public Static Accessors (1)
|
|
11
|
-
|
|
12
|
-
public static get instance() {
|
|
13
|
-
return this._instance || (this._instance = new this());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// #endregion Public Static Accessors (1)
|
|
17
|
-
|
|
18
|
-
// #region Public Methods (4)
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new uuid v4.
|
|
22
|
-
*/
|
|
23
|
-
public create(): string {
|
|
24
|
-
return v4();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parse the uuid to array of bytes
|
|
29
|
-
*
|
|
30
|
-
* @param uuid the uuid to convert
|
|
31
|
-
* @returns ArrayLike collection of 16 values
|
|
32
|
-
*/
|
|
33
|
-
public parse(uuid: string): ArrayLike<number> {
|
|
34
|
-
return parseUUID(uuid);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Stringify an array of bytes to an uuid
|
|
39
|
-
*
|
|
40
|
-
* @param uuid the array of bytes
|
|
41
|
-
* @returns the converted uuid
|
|
42
|
-
*/
|
|
43
|
-
public stringify(uuid: ArrayLike<number>): string {
|
|
44
|
-
return stringifyUUID(uuid);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Checks if the provided string is a valid uuid.
|
|
49
|
-
*
|
|
50
|
-
* @param uuid the uuid to check
|
|
51
|
-
*/
|
|
52
|
-
public validate(uuid: string): boolean {
|
|
53
|
-
return validateUUID(uuid);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// #endregion Public Methods (4)
|
|
57
|
-
}
|
package/tsconfig.json
DELETED