/
index.ts
56 lines (53 loc) · 1.38 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
export * from "./account_defs";
export * from "./web3_defs";
export * from "./ws_defs";
export * from "./url_defs";
export * from "./loopring_constants";
export * from "./loopring_enums";
export * from "./loopring_defs";
export * from "./error_codes";
export const IsMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return (
navigator.userAgent.match(/IEMobile/i) ||
navigator.userAgent.match(/WPDesktop/i)
);
},
Ethereum: function () {
return window?.ethereum && window?.ethereum.isImToken;
},
any: function () {
if (typeof global.navigator === 'undefined' || typeof navigator === 'undefined') {
console.log("IsMobile any navigator is undefined")
return false;
}
return (
IsMobile.Android() ||
IsMobile.BlackBerry() ||
IsMobile.iOS() ||
IsMobile.Opera() ||
IsMobile.Windows() ||
IsMobile.Ethereum()
);
},
};
type Ethereum = any;
declare global {
interface Window {
ethereum?: Ethereum;
// socketEventMap: {[key:string]:any
// imageConfig:{[key:string]:any}|undefined
}
}