chayns-api 1.0.27 → 1.0.29
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/cjs/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _exportNames = {
|
|
|
7
7
|
ChaynsProvider: true,
|
|
8
8
|
getDeviceInfo: true,
|
|
9
9
|
getScreenSize: true,
|
|
10
|
+
getClientDeviceInfo: true,
|
|
10
11
|
ChaynsHost: true,
|
|
11
12
|
withCompatMode: true,
|
|
12
13
|
DialogHandler: true,
|
|
@@ -31,6 +32,12 @@ Object.defineProperty(exports, "DialogHandler", {
|
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
exports.dialog = exports.default = void 0;
|
|
35
|
+
Object.defineProperty(exports, "getClientDeviceInfo", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return _deviceHelper.getClientDeviceInfo;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
34
41
|
Object.defineProperty(exports, "getDeviceInfo", {
|
|
35
42
|
enumerable: true,
|
|
36
43
|
get: function () {
|
|
@@ -36,6 +36,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
36
36
|
result.os = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os;
|
|
37
37
|
if (typeof window !== 'undefined') {
|
|
38
38
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
39
|
+
result.isTouch = getClientDeviceInfo().isTouch;
|
|
39
40
|
} else {
|
|
40
41
|
// estimate size over user agent, very inaccurate, could be improved by setting a cookie with the screensize
|
|
41
42
|
const screenSizeByUA = /mobi/i.test(userAgent) ? _IChaynsReact.ScreenSize.SM : _IChaynsReact.ScreenSize.XL;
|
|
@@ -46,7 +47,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
46
47
|
|
|
47
48
|
// Infos that are only available on client or iframe side
|
|
48
49
|
const getClientDeviceInfo = () => ({
|
|
49
|
-
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
50
|
+
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)').matches
|
|
50
51
|
});
|
|
51
52
|
exports.getClientDeviceInfo = getClientDeviceInfo;
|
|
52
53
|
const getScreenSize = width => {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as ChaynsProvider } from './components/ChaynsProvider';
|
|
2
|
-
export { default as getDeviceInfo, getScreenSize } from './util/deviceHelper';
|
|
2
|
+
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './util/deviceHelper';
|
|
3
3
|
export { default as ChaynsHost } from './host/ChaynsHost';
|
|
4
4
|
export { withCompatMode } from './components/withCompatMode';
|
|
5
5
|
export * from './calls';
|
|
@@ -30,6 +30,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
30
30
|
result.os = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os;
|
|
31
31
|
if (typeof window !== 'undefined') {
|
|
32
32
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
33
|
+
result.isTouch = getClientDeviceInfo().isTouch;
|
|
33
34
|
} else {
|
|
34
35
|
// estimate size over user agent, very inaccurate, could be improved by setting a cookie with the screensize
|
|
35
36
|
const screenSizeByUA = /mobi/i.test(userAgent) ? ScreenSize.SM : ScreenSize.XL;
|
|
@@ -40,7 +41,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
40
41
|
|
|
41
42
|
// Infos that are only available on client or iframe side
|
|
42
43
|
export const getClientDeviceInfo = () => ({
|
|
43
|
-
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
44
|
+
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)').matches
|
|
44
45
|
});
|
|
45
46
|
export const getScreenSize = width => {
|
|
46
47
|
let value;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as ChaynsProvider } from './components/ChaynsProvider';
|
|
2
|
-
export { default as getDeviceInfo, getScreenSize } from './util/deviceHelper';
|
|
2
|
+
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './util/deviceHelper';
|
|
3
3
|
export { default as ChaynsHost } from './host/ChaynsHost';
|
|
4
4
|
export { withCompatMode } from './components/withCompatMode';
|
|
5
5
|
export * from './calls';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChaynsApiDevice, ScreenSize } from '../types/IChaynsReact';
|
|
2
2
|
declare const getDeviceInfo: (userAgent: string, acceptHeader: string) => ChaynsApiDevice;
|
|
3
3
|
export declare const getClientDeviceInfo: () => {
|
|
4
|
-
isTouch:
|
|
4
|
+
isTouch: boolean;
|
|
5
5
|
};
|
|
6
6
|
export declare const getScreenSize: (width: any) => ScreenSize;
|
|
7
7
|
export default getDeviceInfo;
|