native-fn 1.0.81 → 1.0.83

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.
Files changed (201) hide show
  1. package/dist/index.d.ts +8 -1
  2. package/dist/native.cjs +4 -10
  3. package/dist/native.min.cjs +1 -1
  4. package/dist/native.min.mjs +1 -1
  5. package/dist/native.mjs +4 -10
  6. package/dist/native.umd.js +4 -10
  7. package/dist/native.umd.min.js +1 -1
  8. package/dist/plugin/app/index.cjs +189 -224
  9. package/dist/plugin/app/index.min.cjs +1 -1
  10. package/dist/plugin/app/index.min.mjs +1 -1
  11. package/dist/plugin/app/index.mjs +189 -224
  12. package/dist/plugin/app/index.umd.js +189 -224
  13. package/dist/plugin/app/index.umd.min.js +1 -1
  14. package/dist/plugin/app/src/plugin/appearance/constants/index.d.ts +2 -2
  15. package/dist/plugin/app/src/plugin/appearance/types/appearance.d.ts +1 -7
  16. package/dist/plugin/app/src/plugin/clipboard/types/appearance.d.ts +13 -0
  17. package/dist/plugin/app/src/plugin/dimension/constants/index.d.ts +3 -0
  18. package/dist/plugin/app/src/plugin/dimension/cores/index.d.ts +3 -0
  19. package/dist/plugin/app/src/plugin/dimension/index.d.ts +4 -0
  20. package/dist/plugin/app/src/plugin/dimension/types/dimension.d.ts +11 -0
  21. package/dist/plugin/app/src/plugin/dimension/types/dimensions.d.ts +11 -0
  22. package/dist/plugin/app/src/plugin/dimension/types/index.d.ts +13 -0
  23. package/dist/plugin/app/src/plugin/platform/constants/index.d.ts +1 -0
  24. package/dist/plugin/app/src/plugin/platform/cores/index.d.ts +5 -10
  25. package/dist/plugin/app/src/plugin/platform/types/platform.d.ts +7 -18
  26. package/dist/plugin/app/src/types/listener-entry.d.ts +6 -0
  27. package/dist/plugin/app/src/utils/request.d.ts +1 -0
  28. package/dist/plugin/appearance/index.cjs +165 -222
  29. package/dist/plugin/appearance/index.d.ts +2 -8
  30. package/dist/plugin/appearance/index.min.cjs +1 -1
  31. package/dist/plugin/appearance/index.min.mjs +1 -1
  32. package/dist/plugin/appearance/index.mjs +165 -222
  33. package/dist/plugin/appearance/index.umd.js +165 -222
  34. package/dist/plugin/appearance/index.umd.min.js +1 -1
  35. package/dist/plugin/appearance/src/plugin/appearance/constants/index.d.ts +2 -2
  36. package/dist/plugin/appearance/src/plugin/appearance/types/appearance.d.ts +1 -7
  37. package/dist/plugin/appearance/src/plugin/clipboard/types/appearance.d.ts +13 -0
  38. package/dist/plugin/appearance/src/plugin/dimension/constants/index.d.ts +3 -0
  39. package/dist/plugin/appearance/src/plugin/dimension/cores/index.d.ts +3 -0
  40. package/dist/plugin/appearance/src/plugin/dimension/index.d.ts +4 -0
  41. package/dist/plugin/appearance/src/plugin/dimension/types/dimension.d.ts +11 -0
  42. package/dist/plugin/appearance/src/plugin/dimension/types/dimensions.d.ts +11 -0
  43. package/dist/plugin/appearance/src/plugin/dimension/types/index.d.ts +13 -0
  44. package/dist/plugin/appearance/src/plugin/platform/constants/index.d.ts +1 -0
  45. package/dist/plugin/appearance/src/plugin/platform/cores/index.d.ts +5 -10
  46. package/dist/plugin/appearance/src/plugin/platform/types/platform.d.ts +7 -18
  47. package/dist/plugin/appearance/src/types/listener-entry.d.ts +6 -0
  48. package/dist/plugin/appearance/src/utils/request.d.ts +1 -0
  49. package/dist/plugin/clipboard/index.cjs +148 -183
  50. package/dist/plugin/clipboard/index.min.cjs +1 -1
  51. package/dist/plugin/clipboard/index.min.mjs +1 -1
  52. package/dist/plugin/clipboard/index.mjs +148 -183
  53. package/dist/plugin/clipboard/index.umd.js +148 -183
  54. package/dist/plugin/clipboard/index.umd.min.js +1 -1
  55. package/dist/plugin/clipboard/src/plugin/appearance/constants/index.d.ts +2 -2
  56. package/dist/plugin/clipboard/src/plugin/appearance/types/appearance.d.ts +1 -7
  57. package/dist/plugin/clipboard/src/plugin/clipboard/types/appearance.d.ts +13 -0
  58. package/dist/plugin/clipboard/src/plugin/dimension/constants/index.d.ts +3 -0
  59. package/dist/plugin/clipboard/src/plugin/dimension/cores/index.d.ts +3 -0
  60. package/dist/plugin/clipboard/src/plugin/dimension/index.d.ts +4 -0
  61. package/dist/plugin/clipboard/src/plugin/dimension/types/dimension.d.ts +11 -0
  62. package/dist/plugin/clipboard/src/plugin/dimension/types/dimensions.d.ts +11 -0
  63. package/dist/plugin/clipboard/src/plugin/dimension/types/index.d.ts +13 -0
  64. package/dist/plugin/clipboard/src/plugin/platform/constants/index.d.ts +1 -0
  65. package/dist/plugin/clipboard/src/plugin/platform/cores/index.d.ts +5 -10
  66. package/dist/plugin/clipboard/src/plugin/platform/types/platform.d.ts +7 -18
  67. package/dist/plugin/clipboard/src/types/listener-entry.d.ts +6 -0
  68. package/dist/plugin/clipboard/src/utils/request.d.ts +1 -0
  69. package/dist/plugin/dimension/index.cjs +947 -0
  70. package/dist/plugin/dimension/index.d.ts +36 -0
  71. package/dist/plugin/dimension/index.min.cjs +1 -0
  72. package/dist/plugin/dimension/index.min.mjs +1 -0
  73. package/dist/plugin/dimension/index.mjs +945 -0
  74. package/dist/plugin/dimension/index.umd.js +953 -0
  75. package/dist/plugin/dimension/index.umd.min.js +1 -0
  76. package/dist/plugin/dimension/src/errors/plugin-not-extended-error.d.ts +2 -0
  77. package/dist/plugin/dimension/src/plugin/app/constants/index.d.ts +12 -0
  78. package/dist/plugin/dimension/src/plugin/app/cores/index.d.ts +13 -0
  79. package/dist/plugin/dimension/src/plugin/app/errors/url-open-error.d.ts +2 -0
  80. package/dist/plugin/dimension/src/plugin/app/index.d.ts +12 -0
  81. package/dist/plugin/dimension/src/plugin/app/types/app.d.ts +54 -0
  82. package/dist/plugin/dimension/src/plugin/app/types/index.d.ts +16 -0
  83. package/dist/plugin/dimension/src/plugin/appearance/constants/index.d.ts +11 -0
  84. package/dist/plugin/dimension/src/plugin/appearance/cores/index.d.ts +3 -0
  85. package/dist/plugin/dimension/src/plugin/appearance/index.d.ts +8 -0
  86. package/dist/plugin/dimension/src/plugin/appearance/types/appearance.d.ts +6 -0
  87. package/dist/plugin/dimension/src/plugin/appearance/types/index.d.ts +13 -0
  88. package/dist/plugin/dimension/src/plugin/clipboard/cores/index.d.ts +3 -0
  89. package/dist/plugin/dimension/src/plugin/clipboard/index.d.ts +5 -0
  90. package/dist/plugin/dimension/src/plugin/clipboard/types/appearance.d.ts +13 -0
  91. package/dist/plugin/dimension/src/plugin/clipboard/types/clipboard.d.ts +4 -0
  92. package/dist/plugin/dimension/src/plugin/clipboard/types/index.d.ts +11 -0
  93. package/dist/plugin/dimension/src/plugin/dimension/constants/index.d.ts +3 -0
  94. package/dist/plugin/dimension/src/plugin/dimension/cores/index.d.ts +3 -0
  95. package/dist/plugin/dimension/src/plugin/dimension/index.d.ts +4 -0
  96. package/dist/plugin/dimension/src/plugin/dimension/types/dimension.d.ts +11 -0
  97. package/dist/plugin/dimension/src/plugin/dimension/types/dimensions.d.ts +11 -0
  98. package/dist/plugin/dimension/src/plugin/dimension/types/index.d.ts +13 -0
  99. package/dist/plugin/dimension/src/plugin/fullscreen/cores/index.d.ts +35 -0
  100. package/dist/plugin/dimension/src/plugin/fullscreen/index.d.ts +5 -0
  101. package/dist/plugin/dimension/src/plugin/fullscreen/types/fullscreen.d.ts +10 -0
  102. package/dist/plugin/dimension/src/plugin/fullscreen/types/index.d.ts +11 -0
  103. package/dist/plugin/dimension/src/plugin/platform/constants/index.d.ts +43 -0
  104. package/dist/plugin/dimension/src/plugin/platform/cores/index.d.ts +35 -0
  105. package/dist/plugin/dimension/src/plugin/platform/index.d.ts +12 -0
  106. package/dist/plugin/dimension/src/plugin/platform/types/index.d.ts +11 -0
  107. package/dist/plugin/dimension/src/plugin/platform/types/platform.d.ts +27 -0
  108. package/dist/plugin/dimension/src/plugin/theme/constants/index.d.ts +2 -0
  109. package/dist/plugin/dimension/src/plugin/theme/cores/index.d.ts +3 -0
  110. package/dist/plugin/dimension/src/plugin/theme/index.d.ts +5 -0
  111. package/dist/plugin/dimension/src/plugin/theme/types/index.d.ts +11 -0
  112. package/dist/plugin/dimension/src/plugin/theme/types/theme.d.ts +4 -0
  113. package/dist/plugin/dimension/src/types/event-listener-util.d.ts +11 -0
  114. package/dist/plugin/dimension/src/types/index.d.ts +1 -0
  115. package/dist/plugin/dimension/src/types/listener-entry.d.ts +6 -0
  116. package/dist/plugin/dimension/src/types/native.d.ts +27 -0
  117. package/dist/plugin/dimension/src/utils/assign.d.ts +1 -0
  118. package/dist/plugin/dimension/src/utils/compare-version.d.ts +1 -0
  119. package/dist/plugin/dimension/src/utils/create-custom-error.d.ts +6 -0
  120. package/dist/plugin/dimension/src/utils/create-hidden-element.d.ts +1 -0
  121. package/dist/plugin/dimension/src/utils/dispatch-click-event.d.ts +1 -0
  122. package/dist/plugin/dimension/src/utils/event-listener-utils.d.ts +3 -0
  123. package/dist/plugin/dimension/src/utils/get-topmost-window.d.ts +1 -0
  124. package/dist/plugin/dimension/src/utils/is-secure-context.d.ts +1 -0
  125. package/dist/plugin/dimension/src/utils/request.d.ts +1 -0
  126. package/dist/plugin/fullscreen/index.cjs +156 -188
  127. package/dist/plugin/fullscreen/index.min.cjs +1 -1
  128. package/dist/plugin/fullscreen/index.min.mjs +1 -1
  129. package/dist/plugin/fullscreen/index.mjs +156 -188
  130. package/dist/plugin/fullscreen/index.umd.js +156 -188
  131. package/dist/plugin/fullscreen/index.umd.min.js +1 -1
  132. package/dist/plugin/fullscreen/src/plugin/appearance/constants/index.d.ts +2 -2
  133. package/dist/plugin/fullscreen/src/plugin/appearance/types/appearance.d.ts +1 -7
  134. package/dist/plugin/fullscreen/src/plugin/clipboard/types/appearance.d.ts +13 -0
  135. package/dist/plugin/fullscreen/src/plugin/dimension/constants/index.d.ts +3 -0
  136. package/dist/plugin/fullscreen/src/plugin/dimension/cores/index.d.ts +3 -0
  137. package/dist/plugin/fullscreen/src/plugin/dimension/index.d.ts +4 -0
  138. package/dist/plugin/fullscreen/src/plugin/dimension/types/dimension.d.ts +11 -0
  139. package/dist/plugin/fullscreen/src/plugin/dimension/types/dimensions.d.ts +11 -0
  140. package/dist/plugin/fullscreen/src/plugin/dimension/types/index.d.ts +13 -0
  141. package/dist/plugin/fullscreen/src/plugin/platform/constants/index.d.ts +1 -0
  142. package/dist/plugin/fullscreen/src/plugin/platform/cores/index.d.ts +5 -10
  143. package/dist/plugin/fullscreen/src/plugin/platform/types/platform.d.ts +7 -18
  144. package/dist/plugin/fullscreen/src/types/listener-entry.d.ts +6 -0
  145. package/dist/plugin/fullscreen/src/utils/request.d.ts +1 -0
  146. package/dist/plugin/platform/index.cjs +137 -172
  147. package/dist/plugin/platform/index.d.ts +8 -19
  148. package/dist/plugin/platform/index.min.cjs +1 -1
  149. package/dist/plugin/platform/index.min.mjs +1 -1
  150. package/dist/plugin/platform/index.mjs +137 -172
  151. package/dist/plugin/platform/index.umd.js +137 -172
  152. package/dist/plugin/platform/index.umd.min.js +1 -1
  153. package/dist/plugin/platform/src/plugin/appearance/constants/index.d.ts +2 -2
  154. package/dist/plugin/platform/src/plugin/appearance/types/appearance.d.ts +1 -7
  155. package/dist/plugin/platform/src/plugin/clipboard/types/appearance.d.ts +13 -0
  156. package/dist/plugin/platform/src/plugin/dimension/constants/index.d.ts +3 -0
  157. package/dist/plugin/platform/src/plugin/dimension/cores/index.d.ts +3 -0
  158. package/dist/plugin/platform/src/plugin/dimension/index.d.ts +4 -0
  159. package/dist/plugin/platform/src/plugin/dimension/types/dimension.d.ts +11 -0
  160. package/dist/plugin/platform/src/plugin/dimension/types/dimensions.d.ts +11 -0
  161. package/dist/plugin/platform/src/plugin/dimension/types/index.d.ts +13 -0
  162. package/dist/plugin/platform/src/plugin/platform/constants/index.d.ts +1 -0
  163. package/dist/plugin/platform/src/plugin/platform/cores/index.d.ts +5 -10
  164. package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +7 -18
  165. package/dist/plugin/platform/src/types/listener-entry.d.ts +6 -0
  166. package/dist/plugin/platform/src/utils/request.d.ts +1 -0
  167. package/dist/plugin/theme/index.cjs +138 -173
  168. package/dist/plugin/theme/index.min.cjs +1 -1
  169. package/dist/plugin/theme/index.min.mjs +1 -1
  170. package/dist/plugin/theme/index.mjs +138 -173
  171. package/dist/plugin/theme/index.umd.js +138 -173
  172. package/dist/plugin/theme/index.umd.min.js +1 -1
  173. package/dist/plugin/theme/src/plugin/appearance/constants/index.d.ts +2 -2
  174. package/dist/plugin/theme/src/plugin/appearance/types/appearance.d.ts +1 -7
  175. package/dist/plugin/theme/src/plugin/clipboard/types/appearance.d.ts +13 -0
  176. package/dist/plugin/theme/src/plugin/dimension/constants/index.d.ts +3 -0
  177. package/dist/plugin/theme/src/plugin/dimension/cores/index.d.ts +3 -0
  178. package/dist/plugin/theme/src/plugin/dimension/index.d.ts +4 -0
  179. package/dist/plugin/theme/src/plugin/dimension/types/dimension.d.ts +11 -0
  180. package/dist/plugin/theme/src/plugin/dimension/types/dimensions.d.ts +11 -0
  181. package/dist/plugin/theme/src/plugin/dimension/types/index.d.ts +13 -0
  182. package/dist/plugin/theme/src/plugin/platform/constants/index.d.ts +1 -0
  183. package/dist/plugin/theme/src/plugin/platform/cores/index.d.ts +5 -10
  184. package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +7 -18
  185. package/dist/plugin/theme/src/types/listener-entry.d.ts +6 -0
  186. package/dist/plugin/theme/src/utils/request.d.ts +1 -0
  187. package/dist/src/plugin/appearance/constants/index.d.ts +2 -2
  188. package/dist/src/plugin/appearance/types/appearance.d.ts +1 -7
  189. package/dist/src/plugin/clipboard/types/appearance.d.ts +13 -0
  190. package/dist/src/plugin/dimension/constants/index.d.ts +3 -0
  191. package/dist/src/plugin/dimension/cores/index.d.ts +3 -0
  192. package/dist/src/plugin/dimension/index.d.ts +4 -0
  193. package/dist/src/plugin/dimension/types/dimension.d.ts +11 -0
  194. package/dist/src/plugin/dimension/types/dimensions.d.ts +11 -0
  195. package/dist/src/plugin/dimension/types/index.d.ts +13 -0
  196. package/dist/src/plugin/platform/constants/index.d.ts +1 -0
  197. package/dist/src/plugin/platform/cores/index.d.ts +5 -10
  198. package/dist/src/plugin/platform/types/platform.d.ts +7 -18
  199. package/dist/src/types/listener-entry.d.ts +6 -0
  200. package/dist/src/utils/request.d.ts +1 -0
  201. package/package.json +15 -15
@@ -0,0 +1,13 @@
1
+ import { Appearances } from "../constants";
2
+ import { NativeModule } from "../../../types";
3
+ export declare interface ListenerEntry {
4
+ fn: (appearance: Appearances) => any;
5
+ capture: boolean;
6
+ once: boolean;
7
+ signal?: AbortSignal;
8
+ }
9
+ export declare interface AppearanceInstance extends NativeModule {
10
+ get value(): Appearances;
11
+ set value(appearances: Exclude<Appearances, Appearances.Unknown>);
12
+ onchange(listener: (appearance?: Appearances) => any, options?: boolean | AddEventListenerOptions): () => void;
13
+ }
@@ -0,0 +1,3 @@
1
+ import { Dimensions } from "../types";
2
+ import { ListenerEntry } from "../../../types/listener-entry";
3
+ export declare const ENTRIES: ListenerEntry<Dimensions>[];
@@ -0,0 +1,3 @@
1
+ import { DimensionInstance } from "../types";
2
+ declare const Dimension: DimensionInstance;
3
+ export default Dimension;
@@ -0,0 +1,4 @@
1
+ import { NativePlugin } from "../../types";
2
+ import { DimensionInstance } from "./types";
3
+ declare const NativeDimensionPlugin: NativePlugin<'Dimension', DimensionInstance, {}, {}>;
4
+ export default NativeDimensionPlugin;
@@ -0,0 +1,11 @@
1
+ export declare interface DimensionInstance {
2
+ get value(): Dimension;
3
+ onchange: any;
4
+ }
5
+ export declare interface Dimension {
6
+ outerWidth: number;
7
+ outerHeight: number;
8
+ innerWidth: number;
9
+ innerHeight: number;
10
+ scale: number;
11
+ }
@@ -0,0 +1,11 @@
1
+ export declare interface DimensionInstance {
2
+ get value(): Dimensions;
3
+ onchange: any;
4
+ }
5
+ export declare interface Dimensions {
6
+ outerWidth: number;
7
+ outerHeight: number;
8
+ innerWidth: number;
9
+ innerHeight: number;
10
+ scale: number;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { DimensionInstance } from "./dimensions";
2
+ import Dimension from "../cores";
3
+ export * from "./dimensions";
4
+ declare module 'native-fn' {
5
+ interface NativePlugins {
6
+ Dimension: DimensionInstance;
7
+ }
8
+ interface NativeConstants {
9
+ Dimension: typeof Dimension;
10
+ }
11
+ interface NativeErrors {
12
+ }
13
+ }
@@ -40,3 +40,4 @@ export declare enum CrossPlatformFramework {
40
40
  Cordova = "Cordova"
41
41
  }
42
42
  export declare const USER_AGENT: string;
43
+ export declare const HIGH_ENTROPY_BRAND_NAME_MAP: Record<string, string>;
@@ -5,18 +5,13 @@ declare global {
5
5
  interface Navigator {
6
6
  userAgent?: string;
7
7
  userAgentData?: UserAgentData;
8
- connection?: NavigatorConnection;
9
- mozConnection?: NavigatorConnection;
10
- webkitConnection?: NavigatorConnection;
8
+ language?: string;
9
+ languages?: readonly string[];
10
+ browserLanguage?: string;
11
+ systemLanguage?: string;
12
+ userLanguage?: string;
11
13
  }
12
14
  }
13
- interface NavigatorConnection {
14
- effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';
15
- type?: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other';
16
- downlink?: number;
17
- rtt?: number;
18
- saveData?: boolean;
19
- }
20
15
  interface CordovaDevice {
21
16
  platform: string;
22
17
  version: string;
@@ -1,19 +1,17 @@
1
1
  import { Browsers, CrossPlatformFramework, Devices, Engines, OS } from "../constants";
2
+ export declare type VersionResolver = undefined | string | ((string: string | undefined) => string);
2
3
  export declare interface PlatformInstance {
3
4
  os: NameVersionPair<OS>;
4
5
  engine: NameVersionPair<Engines>;
5
6
  browser: NameVersionPair<Browsers>;
6
7
  device: Devices;
7
8
  crossPlatformFramework: CrossPlatformFramework;
8
- network: Network;
9
- dimension: Dimension;
9
+ locale: Locale;
10
10
  renderer: string;
11
11
  userAgent: string;
12
12
  readyState: 'loading' | 'complete';
13
13
  isNode: boolean;
14
14
  isStandalone: boolean;
15
- isMobile: boolean;
16
- isDesktop: boolean;
17
15
  isWebview: boolean;
18
16
  onready(callback: (platform: PlatformInstance) => void): void;
19
17
  }
@@ -21,18 +19,9 @@ export declare interface NameVersionPair<T> {
21
19
  name: T;
22
20
  version: string;
23
21
  }
24
- export declare interface Network {
25
- isOnline: boolean | null;
26
- effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | null;
27
- type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | null;
28
- downlink: number | null;
29
- rtt: number | null;
30
- saveData: boolean | null;
31
- }
32
- export declare interface Dimension {
33
- outerWidth: number;
34
- outerHeight: number;
35
- innerWidth: number;
36
- innerHeight: number;
37
- scale: number;
22
+ export declare interface Locale {
23
+ language: string | null;
24
+ languages: string[];
25
+ timezone: string | null;
26
+ timezoneOffset: number;
38
27
  }
@@ -0,0 +1,6 @@
1
+ export declare interface ListenerEntry<T> {
2
+ fn: (appearance: T) => any;
3
+ capture: boolean;
4
+ once: boolean;
5
+ signal?: AbortSignal;
6
+ }
@@ -0,0 +1 @@
1
+ export default function request<T = unknown>(url: string, options?: Record<string, any>): Promise<T>;
@@ -47,6 +47,14 @@ var CrossPlatformFramework;
47
47
  CrossPlatformFramework["Cordova"] = "Cordova";
48
48
  })(CrossPlatformFramework || (CrossPlatformFramework = {}));
49
49
  var USER_AGENT = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
50
+ var HIGH_ENTROPY_BRAND_NAME_MAP = {
51
+ 'Google Chrome': 'Chrome',
52
+ 'Microsoft Edge': 'Edge',
53
+ 'Microsoft Edge WebView2': 'Edge WebView2',
54
+ 'Android WebView': 'Chrome WebView',
55
+ 'HeadlessChrome': 'Chrome Headless',
56
+ 'OperaMobile': 'Opera Mobi',
57
+ };
50
58
 
51
59
  function compareVersion(lhs, rhs) {
52
60
  var pa = lhs.split('.');
@@ -83,11 +91,8 @@ var Platform = {
83
91
  get readyState() {
84
92
  return readyState;
85
93
  },
86
- get network() {
87
- return getNetwork();
88
- },
89
- get dimension() {
90
- return getDimension();
94
+ get locale() {
95
+ return getLocale();
91
96
  },
92
97
  get device() {
93
98
  if (this.os.name === OS.iOS || this.os.name === OS.Android)
@@ -99,17 +104,11 @@ var Platform = {
99
104
  get renderer() {
100
105
  return getRenderer();
101
106
  },
102
- get isMobile() {
103
- return this.device === Devices.Mobile;
104
- },
105
- get isDesktop() {
106
- return this.device === Devices.Desktop;
107
- },
108
107
  get isWebview() {
109
108
  return /; ?wv|applewebkit(?!.*safari)/i.test(this.userAgent);
110
109
  },
111
110
  get isNode() {
112
- return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
111
+ return typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && typeof globalThis.process.versions.node !== 'undefined';
113
112
  },
114
113
  get isStandalone() {
115
114
  if (this.os.name === OS.iOS)
@@ -131,6 +130,33 @@ var Platform = {
131
130
  }
132
131
  }
133
132
  };
133
+ function resolveWindowsVersion(string) {
134
+ if (typeof string === 'undefined')
135
+ return '';
136
+ var mapped = {
137
+ '4.90': 'ME',
138
+ 'NT3.51': 'NT 3.11',
139
+ 'NT4.0': 'NT 4.0',
140
+ 'NT 5.0': '2000',
141
+ 'NT 5.1': 'XP',
142
+ 'NT 5.2': 'XP',
143
+ 'NT 6.0': 'Vista',
144
+ 'NT 6.1': '7',
145
+ 'NT 6.2': '8',
146
+ 'NT 6.3': '8.1',
147
+ 'NT 6.4': '10',
148
+ 'NT 10.0': '10',
149
+ 'ARM': 'RT'
150
+ }[string];
151
+ if (typeof mapped !== 'undefined')
152
+ return mapped;
153
+ return string;
154
+ }
155
+ function resolveUnderscoreVersion(string) {
156
+ if (typeof string === 'undefined')
157
+ return '';
158
+ return string.replace(/_/g, '.');
159
+ }
134
160
  var OS_RESOLVER_MAP = [
135
161
  [/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
136
162
  [/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
@@ -189,14 +215,6 @@ var BROWSER_RESOLVER_MAP = [
189
215
  [/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
190
216
  [/firefox\/([\w.]+)/i, Browsers.Firefox],
191
217
  ];
192
- var HIGH_ENTROPY_BRAND_NAME_MAP = {
193
- 'Google Chrome': 'Chrome',
194
- 'Microsoft Edge': 'Edge',
195
- 'Microsoft Edge WebView2': 'Edge WebView2',
196
- 'Android WebView': 'Chrome WebView',
197
- 'HeadlessChrome': 'Chrome Headless',
198
- 'OperaMobile': 'Opera Mobi',
199
- };
200
218
  function incrementPendingTasks() {
201
219
  pendingTasks++;
202
220
  }
@@ -217,33 +235,6 @@ function checkReady() {
217
235
  readyCallback.length = 0;
218
236
  }
219
237
  }
220
- function resolveWindowsVersion(string) {
221
- if (string === undefined)
222
- return '';
223
- var mapped = {
224
- '4.90': 'ME',
225
- 'NT3.51': 'NT 3.11',
226
- 'NT4.0': 'NT 4.0',
227
- 'NT 5.0': '2000',
228
- 'NT 5.1': 'XP',
229
- 'NT 5.2': 'XP',
230
- 'NT 6.0': 'Vista',
231
- 'NT 6.1': '7',
232
- 'NT 6.2': '8',
233
- 'NT 6.3': '8.1',
234
- 'NT 6.4': '10',
235
- 'NT 10.0': '10',
236
- 'ARM': 'RT'
237
- }[string];
238
- if (mapped !== undefined)
239
- return mapped;
240
- return string;
241
- }
242
- function resolveUnderscoreVersion(string) {
243
- if (string === undefined)
244
- return '';
245
- return string.replace(/_/g, '.');
246
- }
247
238
  function resolveSemanticWindowsVersion(version, defaultValue) {
248
239
  if (version.major === 10 && version.minor === 0 && version.build >= 22000)
249
240
  return '11';
@@ -380,12 +371,12 @@ function resolveVersion(string, resolver) {
380
371
  return resolver(string);
381
372
  if (typeof resolver === 'string')
382
373
  return resolver;
383
- if (string === undefined)
374
+ if (typeof string === 'undefined')
384
375
  return '';
385
376
  return string;
386
377
  }
387
378
  function normalizeBrand(entry) {
388
- if (entry === null || entry === undefined)
379
+ if (entry === null || typeof entry === 'undefined')
389
380
  return { brand: '', version: '' };
390
381
  if (typeof entry === 'string')
391
382
  return { brand: entry, version: '' };
@@ -439,152 +430,127 @@ function getRenderer() {
439
430
  return '';
440
431
  }
441
432
  }
442
- function getNetwork() {
443
- var network = {
444
- isOnline: null,
445
- effectiveType: null,
446
- type: null,
447
- downlink: null,
448
- rtt: null,
449
- saveData: null,
433
+ function normalizeLocale(locale) {
434
+ if (locale === null || typeof locale === 'undefined')
435
+ return locale;
436
+ if (locale.length === 0)
437
+ return null;
438
+ locale = locale.replace(/_/g, '-');
439
+ if (locale === 'C' || locale.toLowerCase() === 'posix')
440
+ return 'en-US';
441
+ if (locale.indexOf('.') !== -1)
442
+ return normalizeLocale(locale.split('.')[0]);
443
+ if (locale.indexOf('@') !== -1)
444
+ return normalizeLocale(locale.split('@')[0]);
445
+ var parts = locale.split('-');
446
+ if (parts.length === 0)
447
+ return null;
448
+ parts[0] = parts[0].toLowerCase();
449
+ if (parts.length > 1 && parts[1].length === 2)
450
+ parts[1] = parts[1].toUpperCase();
451
+ if (parts.length > 2 && parts[1].length === 4)
452
+ parts[1] = parts[1].charAt(0).toUpperCase() + parts[1].slice(1).toLowerCase();
453
+ return parts.join('-');
454
+ }
455
+ function getLocale() {
456
+ var locale = {
457
+ language: null,
458
+ languages: [],
459
+ timezone: null,
460
+ timezoneOffset: 0,
450
461
  };
451
- if (typeof globalThis.navigator !== 'undefined') {
452
- if (typeof globalThis.navigator.onLine !== 'undefined')
453
- network.isOnline = globalThis.navigator.onLine;
454
- var connection = globalThis.navigator.connection || globalThis.navigator.mozConnection || globalThis.navigator.webkitConnection;
455
- if (typeof connection !== 'undefined') {
456
- if (typeof connection.effectiveType !== 'undefined')
457
- network.effectiveType = connection.effectiveType;
458
- if (typeof connection.type !== 'undefined')
459
- network.type = connection.type;
460
- if (typeof connection.downlink !== 'undefined')
461
- network.downlink = connection.downlink;
462
- if (typeof connection.rtt !== 'undefined')
463
- network.rtt = connection.rtt;
464
- if (typeof connection.saveData !== 'undefined')
465
- network.saveData = connection.saveData;
466
- return network;
467
- }
462
+ function addLanguages(language) {
463
+ for (var i = 0; i < language.length; i++)
464
+ addLanguage(language[i]);
468
465
  }
469
- if (Platform.isNode) {
470
- try {
471
- var os = require('os');
472
- var networkInterfaces = os.networkInterfaces();
473
- var networkInterfaceNames = Object.keys(networkInterfaces);
474
- for (var i = 0; i < networkInterfaceNames.length; i++) {
475
- var name_1 = networkInterfaceNames[i];
476
- var networkInterface = networkInterfaces[name_1];
477
- for (var j = 0; j < networkInterface.length; j++) {
478
- var address = networkInterface[j];
479
- if (!address.internal && address.family === 'IPv4')
480
- network.isOnline = true;
481
- }
482
- if (network.isOnline)
483
- break;
484
- }
485
- }
486
- catch (_) {
466
+ function addLanguage(language) {
467
+ language = normalizeLocale(language);
468
+ if (typeof language === "string" && locale.languages.indexOf(language) === -1) {
469
+ if (locale.language === null)
470
+ locale.language = language;
471
+ locale.languages.push(language);
487
472
  }
473
+ }
474
+ if (Platform.crossPlatformFramework === CrossPlatformFramework.ReactNative) {
488
475
  try {
489
- var childProcess = require('child_process');
490
- if (Platform.os.name === OS.Windows) {
491
- try {
492
- var output = childProcess.execSync('netsh wlan show interfaces', { encoding: 'utf8', timeout: 5000 });
493
- if (output.includes('State') && output.includes('connected'))
494
- network.type = 'wifi';
495
- }
496
- catch (_) {
497
- }
498
- if (network.type === null) {
499
- try {
500
- var output = childProcess.execSync('ipconfig', { encoding: 'utf8', timeout: 5000 });
501
- if (output.includes('Ethernet adapter'))
502
- network.type = 'ethernet';
503
- }
504
- catch (_) {
476
+ var reactNative = require('react-native');
477
+ var nativeModules = reactNative.NativeModules;
478
+ if (typeof nativeModules.SettingsManager !== 'undefined') {
479
+ var settingManager = nativeModules.SettingsManager;
480
+ if (typeof settingManager !== 'undefined') {
481
+ var constant = typeof settingManager.getConstants === 'function'
482
+ ? settingManager.getConstants()
483
+ : settingManager;
484
+ if (typeof constant !== 'undefined' && typeof constant.settings !== 'undefined') {
485
+ var settings = constant.settings;
486
+ if (typeof settings.AppleLocale === 'string')
487
+ addLanguage(settings.AppleLocale);
488
+ if (Array.isArray(settings.AppleLanguages) && settings.AppleLanguages.length > 0)
489
+ addLanguages(settings.AppleLanguages);
505
490
  }
506
491
  }
507
- if (network.type === null)
508
- network.type = 'other';
509
492
  }
510
- else if (Platform.os.name === OS.MacOS) {
511
- try {
512
- var output = childProcess.execSync('networksetup -listallhardwareports', { encoding: 'utf8', timeout: 5000 });
513
- var activeInterface = childProcess.execSync('route -n get default | grep interface', { encoding: 'utf8', timeout: 5000 });
514
- if (activeInterface.includes('en0') && output.includes('Wi-Fi'))
515
- network.type = 'wifi';
516
- else if (activeInterface.includes('en') || output.includes('Ethernet'))
517
- network.type = 'ethernet';
518
- else
519
- network.type = 'other';
520
- }
521
- catch (_) {
522
- network.type = 'other';
493
+ if (typeof nativeModules.I18nManager !== 'undefined') {
494
+ var i18nManager = nativeModules.I18nManager;
495
+ if (typeof i18nManager !== 'undefined') {
496
+ var constant = typeof i18nManager.getConstants === 'function'
497
+ ? i18nManager.getConstants()
498
+ : i18nManager;
499
+ if (typeof constant !== 'undefined' && typeof constant.localeIdentifier !== 'undefined')
500
+ addLanguage(constant.localeIdentifier);
523
501
  }
524
502
  }
525
503
  }
526
504
  catch (_) {
527
505
  }
528
506
  }
529
- return network;
530
- }
531
- function getDimension() {
532
- var dimension = {
533
- innerWidth: -1,
534
- innerHeight: -1,
535
- outerWidth: -1,
536
- outerHeight: -1,
537
- scale: 1,
538
- };
539
- if (typeof globalThis.innerWidth !== 'undefined') {
540
- dimension.innerWidth = globalThis.innerWidth;
541
- dimension.innerHeight = globalThis.innerHeight;
542
- dimension.outerWidth = globalThis.outerWidth;
543
- dimension.outerHeight = globalThis.outerHeight;
544
- dimension.scale = globalThis.devicePixelRatio || 1;
545
- return dimension;
546
- }
547
- if (Platform.crossPlatformFramework === CrossPlatformFramework.ReactNative) {
507
+ if (Platform.crossPlatformFramework === CrossPlatformFramework.Electron) {
548
508
  try {
549
- var reactNative = require('react-native');
550
- var dimensions = reactNative.Dimensions;
551
- var pixelRatio = reactNative.PixelRatio;
552
- var screenDimensions = dimensions.get('screen');
553
- var windowDimensions = dimensions.get('window');
554
- dimension.innerWidth = screenDimensions.width;
555
- dimension.innerHeight = screenDimensions.height;
556
- dimension.outerWidth = windowDimensions.width;
557
- dimension.outerHeight = windowDimensions.height;
558
- dimension.scale = pixelRatio.get();
559
- return dimension;
509
+ var electron = require('electron');
510
+ var app = electron.app;
511
+ if (typeof app.getLocale !== 'undefined')
512
+ addLanguage(app.getLocale());
513
+ if (typeof app.getSystemLocale !== 'undefined')
514
+ addLanguage(app.getSystemLocale());
515
+ if (typeof app.getPreferredSystemLanguages !== 'undefined')
516
+ addLanguages(app.getPreferredSystemLanguages());
560
517
  }
561
518
  catch (_) {
562
519
  }
563
520
  }
564
- if (Platform.crossPlatformFramework === CrossPlatformFramework.Electron) {
521
+ if (typeof Intl !== 'undefined') {
565
522
  try {
566
- var electron = require('electron');
567
- var screen_1 = electron.screen;
568
- var browserWindow = electron.BrowserWindow;
569
- var focusedWindow = browserWindow.getFocusedWindow() || browserWindow.getAllWindows()[0];
570
- if (focusedWindow !== undefined) {
571
- var contentSize = focusedWindow.getContentSize();
572
- var size = focusedWindow.getSize();
573
- dimension.innerWidth = contentSize[0];
574
- dimension.innerHeight = contentSize[1];
575
- dimension.outerWidth = size[0];
576
- dimension.outerHeight = size[1];
577
- dimension.scale = screen_1.getDisplayMatching(focusedWindow.getBounds()).scaleFactor;
578
- }
579
- return dimension;
523
+ addLanguage(Intl.DateTimeFormat().resolvedOptions().locale);
580
524
  }
581
525
  catch (_) {
582
526
  }
527
+ try {
528
+ locale.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
529
+ }
530
+ catch (_) {
531
+ }
532
+ }
533
+ if (typeof globalThis.navigator !== 'undefined') {
534
+ if (typeof globalThis.navigator.languages !== 'undefined')
535
+ addLanguages(globalThis.navigator.languages);
536
+ if (typeof globalThis.navigator.language !== 'undefined')
537
+ addLanguage(globalThis.navigator.language);
538
+ if (typeof globalThis.navigator.userLanguage !== 'undefined')
539
+ addLanguage(globalThis.navigator.userLanguage);
540
+ if (typeof globalThis.navigator.browserLanguage !== 'undefined')
541
+ addLanguage(globalThis.navigator.browserLanguage);
542
+ if (typeof globalThis.navigator.systemLanguage !== 'undefined')
543
+ addLanguage(globalThis.navigator.systemLanguage);
544
+ }
545
+ try {
546
+ locale.timezoneOffset = new Date().getTimezoneOffset();
547
+ }
548
+ catch (_) {
583
549
  }
584
- return dimension;
550
+ return locale;
585
551
  }
586
552
  function init() {
587
- if ((typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(USER_AGENT)))
553
+ if ((typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && typeof globalThis.process.versions.electron !== 'undefined') || (/ electron\//i.test(USER_AGENT)))
588
554
  Platform.crossPlatformFramework = CrossPlatformFramework.Electron;
589
555
  if (typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative')
590
556
  Platform.crossPlatformFramework = CrossPlatformFramework.ReactNative;
@@ -780,8 +746,7 @@ function init() {
780
746
  finally {
781
747
  decrementPendingTasks();
782
748
  }
783
- })
784
- .catch(decrementPendingTasks);
749
+ });
785
750
  }
786
751
  checkReady();
787
752
  }
@@ -48,21 +48,19 @@ declare enum CrossPlatformFramework {
48
48
  Cordova = "Cordova"
49
49
  }
50
50
 
51
+ declare type VersionResolver = undefined | string | ((string: string | undefined) => string);
51
52
  declare interface PlatformInstance {
52
53
  os: NameVersionPair<OS>;
53
54
  engine: NameVersionPair<Engines>;
54
55
  browser: NameVersionPair<Browsers>;
55
56
  device: Devices;
56
57
  crossPlatformFramework: CrossPlatformFramework;
57
- network: Network;
58
- dimension: Dimension;
58
+ locale: Locale;
59
59
  renderer: string;
60
60
  userAgent: string;
61
61
  readyState: 'loading' | 'complete';
62
62
  isNode: boolean;
63
63
  isStandalone: boolean;
64
- isMobile: boolean;
65
- isDesktop: boolean;
66
64
  isWebview: boolean;
67
65
  onready(callback: (platform: PlatformInstance) => void): void;
68
66
  }
@@ -70,20 +68,11 @@ declare interface NameVersionPair<T> {
70
68
  name: T;
71
69
  version: string;
72
70
  }
73
- declare interface Network {
74
- isOnline: boolean | null;
75
- effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | null;
76
- type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | null;
77
- downlink: number | null;
78
- rtt: number | null;
79
- saveData: boolean | null;
80
- }
81
- declare interface Dimension {
82
- outerWidth: number;
83
- outerHeight: number;
84
- innerWidth: number;
85
- innerHeight: number;
86
- scale: number;
71
+ declare interface Locale {
72
+ language: string | null;
73
+ languages: string[];
74
+ timezone: string | null;
75
+ timezoneOffset: number;
87
76
  }
88
77
 
89
78
  declare module 'native-fn' {
@@ -105,4 +94,4 @@ declare const NativePlatformPlugin: NativePlugin<'Platform', PlatformInstance, {
105
94
  }, {}>;
106
95
 
107
96
  export { NativePlatformPlugin as default };
108
- export type { Dimension, NameVersionPair, Network, PlatformInstance };
97
+ export type { Locale, NameVersionPair, PlatformInstance, VersionResolver };