@cuemath/web-utils 1.0.7-santosh1.2 → 1.0.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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
- package/src/index.ts +0 -1
- package/dist/device-details/index.d.ts +0 -29
- package/dist/device-details/index.js +0 -67
- package/dist/device-details/index.js.map +0 -1
- package/src/device-details/index.ts +0 -95
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,5 +21,4 @@ __exportStar(require("./date-time-helper"), exports);
|
|
|
21
21
|
__exportStar(require("./object"), exports);
|
|
22
22
|
__exportStar(require("./growth-source"), exports);
|
|
23
23
|
__exportStar(require("./e-cna"), exports);
|
|
24
|
-
__exportStar(require("./device-details"), exports);
|
|
25
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,kDAAgC;AAChC,qDAAmC;AACnC,2CAAyB;AACzB,kDAAgC;AAChC,0CAAwB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,kDAAgC;AAChC,qDAAmC;AACnC,2CAAyB;AACzB,kDAAgC;AAChC,0CAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuemath/web-utils",
|
|
3
|
-
"version": "1.0.7
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Shared web utils package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,8 +41,6 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@types/node": "^18.11.18",
|
|
44
|
-
"
|
|
45
|
-
"dayjs": "^1.11.7",
|
|
46
|
-
"ua-parser-js": "^1.0.35"
|
|
44
|
+
"dayjs": "^1.11.7"
|
|
47
45
|
}
|
|
48
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
interface DeviceDimension {
|
|
2
|
-
screen_height?: number;
|
|
3
|
-
screen_width?: number;
|
|
4
|
-
viewport_height?: number;
|
|
5
|
-
viewport_width?: number;
|
|
6
|
-
}
|
|
7
|
-
interface DeviceConnection {
|
|
8
|
-
effective_type?: string;
|
|
9
|
-
rtt?: string;
|
|
10
|
-
downlink?: string;
|
|
11
|
-
}
|
|
12
|
-
interface DeviceDetails {
|
|
13
|
-
model?: string;
|
|
14
|
-
vendor?: string;
|
|
15
|
-
browser_name?: string;
|
|
16
|
-
browser_version?: string;
|
|
17
|
-
os_name?: string;
|
|
18
|
-
os_version?: string;
|
|
19
|
-
}
|
|
20
|
-
interface DeviceInformation {
|
|
21
|
-
device_details: DeviceDetails;
|
|
22
|
-
device_connection: DeviceConnection;
|
|
23
|
-
device_dimension: DeviceDimension;
|
|
24
|
-
}
|
|
25
|
-
export declare const getDeviceDetails: () => DeviceDetails;
|
|
26
|
-
export declare const getDeviceConnection: () => DeviceConnection;
|
|
27
|
-
export declare const getDeviceDimension: () => DeviceDimension;
|
|
28
|
-
export declare const getDetailedDeviceInformation: () => DeviceInformation;
|
|
29
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDetailedDeviceInformation = exports.getDeviceDimension = exports.getDeviceConnection = exports.getDeviceDetails = void 0;
|
|
7
|
-
const ua_parser_js_1 = __importDefault(require("ua-parser-js"));
|
|
8
|
-
const getDeviceDetails = () => {
|
|
9
|
-
if (typeof navigator === 'undefined' || !navigator.userAgent)
|
|
10
|
-
return {};
|
|
11
|
-
const parser = new ua_parser_js_1.default(navigator.userAgent).getResult();
|
|
12
|
-
const { device: { model = '', vendor = '' } = {}, browser: { name: browserName = '', version: browserVersion = '' } = {}, os: { name: osName = '', version: osVersion = '' } = {}, } = parser || {};
|
|
13
|
-
return {
|
|
14
|
-
model,
|
|
15
|
-
vendor,
|
|
16
|
-
browser_name: browserName,
|
|
17
|
-
browser_version: browserVersion,
|
|
18
|
-
os_name: osName,
|
|
19
|
-
os_version: osVersion,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.getDeviceDetails = getDeviceDetails;
|
|
23
|
-
const getDeviceConnection = () => {
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
|
-
// @ts-expect-error
|
|
26
|
-
if (typeof navigator === 'undefined' || !navigator.connection)
|
|
27
|
-
return {};
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
29
|
-
// @ts-expect-error
|
|
30
|
-
const { downlink, effectiveType, rtt } = navigator.connection || {};
|
|
31
|
-
return {
|
|
32
|
-
downlink,
|
|
33
|
-
effective_type: effectiveType,
|
|
34
|
-
rtt,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.getDeviceConnection = getDeviceConnection;
|
|
38
|
-
const getDeviceDimension = () => {
|
|
39
|
-
if (typeof window === 'undefined')
|
|
40
|
-
return {};
|
|
41
|
-
const screenHeight = window.screen.height;
|
|
42
|
-
const screenWidth = window.screen.width;
|
|
43
|
-
const viewportHeight = window.innerHeight;
|
|
44
|
-
const viewportWidth = window.innerWidth;
|
|
45
|
-
return {
|
|
46
|
-
screen_height: screenHeight,
|
|
47
|
-
screen_width: screenWidth,
|
|
48
|
-
viewport_height: viewportHeight,
|
|
49
|
-
viewport_width: viewportWidth,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
exports.getDeviceDimension = getDeviceDimension;
|
|
53
|
-
const getDetailedDeviceInformation = () => {
|
|
54
|
-
return {
|
|
55
|
-
device_details: {
|
|
56
|
-
...(0, exports.getDeviceDetails)(),
|
|
57
|
-
},
|
|
58
|
-
device_connection: {
|
|
59
|
-
...(0, exports.getDeviceConnection)(),
|
|
60
|
-
},
|
|
61
|
-
device_dimension: {
|
|
62
|
-
...(0, exports.getDeviceDimension)(),
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
exports.getDetailedDeviceInformation = getDetailedDeviceInformation;
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/device-details/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AA8B7B,MAAM,gBAAgB,GAAG,GAAkB,EAAE;IAClD,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAExE,MAAM,MAAM,GAAqB,IAAI,sBAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,CAAC;IAC/E,MAAM,EACJ,MAAM,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,EACxC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,EAAE,EACtE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,EAAE,GACxD,GAAG,MAAM,IAAI,EAAE,CAAC;IAEjB,OAAO;QACL,KAAK;QACL,MAAM;QACN,YAAY,EAAE,WAAW;QACzB,eAAe,EAAE,cAA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KACF,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,4BAA4B,gCAYvC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import UAParser from 'ua-parser-js';
|
|
2
|
-
|
|
3
|
-
interface DeviceDimension {
|
|
4
|
-
screen_height?: number;
|
|
5
|
-
screen_width?: number;
|
|
6
|
-
viewport_height?: number;
|
|
7
|
-
viewport_width?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface DeviceConnection {
|
|
11
|
-
effective_type?: string;
|
|
12
|
-
rtt?: string;
|
|
13
|
-
downlink?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface DeviceDetails {
|
|
17
|
-
model?: string;
|
|
18
|
-
vendor?: string;
|
|
19
|
-
browser_name?: string;
|
|
20
|
-
browser_version?: string;
|
|
21
|
-
os_name?: string;
|
|
22
|
-
os_version?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface DeviceInformation {
|
|
26
|
-
device_details: DeviceDetails;
|
|
27
|
-
device_connection: DeviceConnection;
|
|
28
|
-
device_dimension: DeviceDimension;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const getDeviceDetails = (): DeviceDetails => {
|
|
32
|
-
if (typeof navigator === 'undefined' || !navigator.userAgent) return {};
|
|
33
|
-
|
|
34
|
-
const parser: UAParser.IResult = new UAParser(navigator.userAgent).getResult();
|
|
35
|
-
const {
|
|
36
|
-
device: { model = '', vendor = '' } = {},
|
|
37
|
-
browser: { name: browserName = '', version: browserVersion = '' } = {},
|
|
38
|
-
os: { name: osName = '', version: osVersion = '' } = {},
|
|
39
|
-
} = parser || {};
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
model,
|
|
43
|
-
vendor,
|
|
44
|
-
browser_name: browserName,
|
|
45
|
-
browser_version: browserVersion,
|
|
46
|
-
os_name: osName,
|
|
47
|
-
os_version: osVersion,
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const getDeviceConnection = (): DeviceConnection => {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
-
// @ts-expect-error
|
|
54
|
-
if (typeof navigator === 'undefined' || !navigator.connection) return {};
|
|
55
|
-
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
-
// @ts-expect-error
|
|
58
|
-
const { downlink, effectiveType, rtt } = navigator.connection || {};
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
downlink,
|
|
62
|
-
effective_type: effectiveType,
|
|
63
|
-
rtt,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const getDeviceDimension = (): DeviceDimension => {
|
|
68
|
-
if (typeof window === 'undefined') return {};
|
|
69
|
-
|
|
70
|
-
const screenHeight = window.screen.height;
|
|
71
|
-
const screenWidth = window.screen.width;
|
|
72
|
-
const viewportHeight = window.innerHeight;
|
|
73
|
-
const viewportWidth = window.innerWidth;
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
screen_height: screenHeight,
|
|
77
|
-
screen_width: screenWidth,
|
|
78
|
-
viewport_height: viewportHeight,
|
|
79
|
-
viewport_width: viewportWidth,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const getDetailedDeviceInformation = (): DeviceInformation => {
|
|
84
|
-
return {
|
|
85
|
-
device_details: {
|
|
86
|
-
...getDeviceDetails(),
|
|
87
|
-
},
|
|
88
|
-
device_connection: {
|
|
89
|
-
...getDeviceConnection(),
|
|
90
|
-
},
|
|
91
|
-
device_dimension: {
|
|
92
|
-
...getDeviceDimension(),
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
};
|