native-fn 1.0.71 → 1.0.73

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 (195) hide show
  1. package/dist/native.cjs +2 -507
  2. package/dist/native.min.cjs +1 -1
  3. package/dist/native.min.mjs +1 -1
  4. package/dist/native.mjs +2 -507
  5. package/dist/native.umd.js +2 -507
  6. package/dist/native.umd.min.js +1 -1
  7. package/dist/plugin/app/index.cjs +435 -423
  8. package/dist/plugin/app/index.d.ts +8 -33
  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 +435 -423
  12. package/dist/plugin/app/index.umd.js +435 -423
  13. package/dist/plugin/app/index.umd.min.js +1 -1
  14. package/dist/plugin/app/src/plugin/app/cores/index.d.ts +0 -4
  15. package/dist/plugin/app/src/plugin/app/types/app.d.ts +1 -1
  16. package/dist/plugin/app/src/plugin/camera/cores/index.d.ts +2 -2
  17. package/dist/plugin/app/src/plugin/clipboard/cores/index.d.ts +2 -2
  18. package/dist/plugin/app/src/plugin/fullscreen/cores/index.d.ts +2 -2
  19. package/dist/plugin/app/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  20. package/dist/plugin/app/src/plugin/platform/constants/index.d.ts +42 -0
  21. package/dist/plugin/app/src/plugin/platform/cores/index.d.ts +28 -0
  22. package/dist/plugin/app/src/plugin/platform/index.d.ts +3 -2
  23. package/dist/plugin/app/src/plugin/platform/types/index.d.ts +4 -0
  24. package/dist/plugin/app/src/plugin/platform/types/platform.d.ts +5 -2
  25. package/dist/plugin/app/src/plugin/theme/constants/index.d.ts +0 -12
  26. package/dist/plugin/app/src/plugin/theme/cores/index.d.ts +2 -2
  27. package/dist/plugin/app/src/plugin/theme/index.d.ts +1 -13
  28. package/dist/plugin/app/src/plugin/theme/types/index.d.ts +0 -12
  29. package/dist/plugin/app/src/plugin/theme/types/theme.d.ts +2 -22
  30. package/dist/plugin/appearance/index.cjs +30 -16
  31. package/dist/plugin/appearance/index.min.cjs +1 -1
  32. package/dist/plugin/appearance/index.min.mjs +1 -1
  33. package/dist/plugin/appearance/index.mjs +30 -16
  34. package/dist/plugin/appearance/index.umd.js +30 -16
  35. package/dist/plugin/appearance/index.umd.min.js +1 -1
  36. package/dist/plugin/appearance/src/plugin/app/cores/index.d.ts +0 -4
  37. package/dist/plugin/appearance/src/plugin/app/types/app.d.ts +1 -1
  38. package/dist/plugin/appearance/src/plugin/camera/cores/index.d.ts +2 -2
  39. package/dist/plugin/appearance/src/plugin/clipboard/cores/index.d.ts +2 -2
  40. package/dist/plugin/appearance/src/plugin/fullscreen/cores/index.d.ts +2 -2
  41. package/dist/plugin/appearance/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  42. package/dist/plugin/appearance/src/plugin/platform/constants/index.d.ts +42 -0
  43. package/dist/plugin/appearance/src/plugin/platform/cores/index.d.ts +28 -0
  44. package/dist/plugin/appearance/src/plugin/platform/index.d.ts +12 -0
  45. package/dist/plugin/appearance/src/plugin/platform/types/index.d.ts +11 -0
  46. package/dist/plugin/appearance/src/plugin/platform/types/platform.d.ts +18 -0
  47. package/dist/plugin/appearance/src/plugin/theme/constants/index.d.ts +0 -12
  48. package/dist/plugin/appearance/src/plugin/theme/cores/index.d.ts +2 -2
  49. package/dist/plugin/appearance/src/plugin/theme/index.d.ts +1 -13
  50. package/dist/plugin/appearance/src/plugin/theme/types/index.d.ts +0 -12
  51. package/dist/plugin/appearance/src/plugin/theme/types/theme.d.ts +2 -22
  52. package/dist/plugin/camera/index.cjs +118 -109
  53. package/dist/plugin/camera/index.min.cjs +1 -1
  54. package/dist/plugin/camera/index.min.mjs +1 -1
  55. package/dist/plugin/camera/index.mjs +118 -109
  56. package/dist/plugin/camera/index.umd.js +118 -109
  57. package/dist/plugin/camera/index.umd.min.js +1 -1
  58. package/dist/plugin/camera/src/plugin/app/cores/index.d.ts +0 -4
  59. package/dist/plugin/camera/src/plugin/app/types/app.d.ts +1 -1
  60. package/dist/plugin/camera/src/plugin/camera/cores/index.d.ts +2 -2
  61. package/dist/plugin/camera/src/plugin/clipboard/cores/index.d.ts +2 -2
  62. package/dist/plugin/camera/src/plugin/fullscreen/cores/index.d.ts +2 -2
  63. package/dist/plugin/camera/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  64. package/dist/plugin/camera/src/plugin/platform/constants/index.d.ts +42 -0
  65. package/dist/plugin/camera/src/plugin/platform/cores/index.d.ts +28 -0
  66. package/dist/plugin/camera/src/plugin/platform/index.d.ts +3 -2
  67. package/dist/plugin/camera/src/plugin/platform/types/index.d.ts +4 -0
  68. package/dist/plugin/camera/src/plugin/platform/types/platform.d.ts +5 -2
  69. package/dist/plugin/camera/src/plugin/theme/constants/index.d.ts +0 -12
  70. package/dist/plugin/camera/src/plugin/theme/cores/index.d.ts +2 -2
  71. package/dist/plugin/camera/src/plugin/theme/index.d.ts +1 -13
  72. package/dist/plugin/camera/src/plugin/theme/types/index.d.ts +0 -12
  73. package/dist/plugin/camera/src/plugin/theme/types/theme.d.ts +2 -22
  74. package/dist/plugin/clipboard/index.cjs +226 -212
  75. package/dist/plugin/clipboard/index.min.cjs +1 -1
  76. package/dist/plugin/clipboard/index.min.mjs +1 -1
  77. package/dist/plugin/clipboard/index.mjs +226 -212
  78. package/dist/plugin/clipboard/index.umd.js +226 -212
  79. package/dist/plugin/clipboard/index.umd.min.js +1 -1
  80. package/dist/plugin/clipboard/src/plugin/app/cores/index.d.ts +0 -4
  81. package/dist/plugin/clipboard/src/plugin/app/types/app.d.ts +1 -1
  82. package/dist/plugin/clipboard/src/plugin/camera/cores/index.d.ts +2 -2
  83. package/dist/plugin/clipboard/src/plugin/clipboard/cores/index.d.ts +2 -2
  84. package/dist/plugin/clipboard/src/plugin/fullscreen/cores/index.d.ts +2 -2
  85. package/dist/plugin/clipboard/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  86. package/dist/plugin/clipboard/src/plugin/platform/constants/index.d.ts +42 -0
  87. package/dist/plugin/clipboard/src/plugin/platform/cores/index.d.ts +28 -0
  88. package/dist/plugin/clipboard/src/plugin/platform/index.d.ts +3 -2
  89. package/dist/plugin/clipboard/src/plugin/platform/types/index.d.ts +4 -0
  90. package/dist/plugin/clipboard/src/plugin/platform/types/platform.d.ts +5 -2
  91. package/dist/plugin/clipboard/src/plugin/theme/constants/index.d.ts +0 -12
  92. package/dist/plugin/clipboard/src/plugin/theme/cores/index.d.ts +2 -2
  93. package/dist/plugin/clipboard/src/plugin/theme/index.d.ts +1 -13
  94. package/dist/plugin/clipboard/src/plugin/theme/types/index.d.ts +0 -12
  95. package/dist/plugin/clipboard/src/plugin/theme/types/theme.d.ts +2 -22
  96. package/dist/plugin/fullscreen/index.cjs +34 -20
  97. package/dist/plugin/fullscreen/index.d.ts +4 -13
  98. package/dist/plugin/fullscreen/index.min.cjs +1 -1
  99. package/dist/plugin/fullscreen/index.min.mjs +1 -1
  100. package/dist/plugin/fullscreen/index.mjs +34 -20
  101. package/dist/plugin/fullscreen/index.umd.js +34 -20
  102. package/dist/plugin/fullscreen/index.umd.min.js +1 -1
  103. package/dist/plugin/fullscreen/src/plugin/app/cores/index.d.ts +0 -4
  104. package/dist/plugin/fullscreen/src/plugin/app/types/app.d.ts +1 -1
  105. package/dist/plugin/fullscreen/src/plugin/camera/cores/index.d.ts +2 -2
  106. package/dist/plugin/fullscreen/src/plugin/clipboard/cores/index.d.ts +2 -2
  107. package/dist/plugin/fullscreen/src/plugin/fullscreen/cores/index.d.ts +2 -2
  108. package/dist/plugin/fullscreen/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  109. package/dist/plugin/fullscreen/src/plugin/platform/constants/index.d.ts +42 -0
  110. package/dist/plugin/fullscreen/src/plugin/platform/cores/index.d.ts +28 -0
  111. package/dist/plugin/fullscreen/src/plugin/platform/index.d.ts +3 -2
  112. package/dist/plugin/fullscreen/src/plugin/platform/types/index.d.ts +4 -0
  113. package/dist/plugin/fullscreen/src/plugin/platform/types/platform.d.ts +5 -2
  114. package/dist/plugin/fullscreen/src/plugin/theme/constants/index.d.ts +0 -12
  115. package/dist/plugin/fullscreen/src/plugin/theme/cores/index.d.ts +2 -2
  116. package/dist/plugin/fullscreen/src/plugin/theme/index.d.ts +1 -13
  117. package/dist/plugin/fullscreen/src/plugin/theme/types/index.d.ts +0 -12
  118. package/dist/plugin/fullscreen/src/plugin/theme/types/theme.d.ts +2 -22
  119. package/dist/plugin/platform/index.cjs +356 -109
  120. package/dist/plugin/platform/index.d.ts +15 -19
  121. package/dist/plugin/platform/index.min.cjs +1 -1
  122. package/dist/plugin/platform/index.min.mjs +1 -1
  123. package/dist/plugin/platform/index.mjs +356 -109
  124. package/dist/plugin/platform/index.umd.js +356 -109
  125. package/dist/plugin/platform/index.umd.min.js +1 -1
  126. package/dist/plugin/platform/src/plugin/app/constants/index.d.ts +12 -0
  127. package/dist/plugin/platform/src/plugin/app/cores/index.d.ts +13 -0
  128. package/dist/plugin/platform/src/plugin/app/index.d.ts +1 -1
  129. package/dist/plugin/platform/src/plugin/app/types/app.d.ts +11 -2
  130. package/dist/plugin/platform/src/plugin/app/types/index.d.ts +2 -2
  131. package/dist/plugin/platform/src/plugin/appearance/constants/index.d.ts +11 -0
  132. package/dist/plugin/platform/src/plugin/appearance/cores/index.d.ts +3 -0
  133. package/dist/plugin/platform/src/plugin/appearance/index.d.ts +8 -0
  134. package/dist/plugin/platform/src/plugin/appearance/types/appearance.d.ts +12 -0
  135. package/dist/plugin/platform/src/plugin/appearance/types/index.d.ts +13 -0
  136. package/dist/plugin/platform/src/plugin/camera/constants/inedx.d.ts +4 -0
  137. package/dist/plugin/platform/src/plugin/camera/cores/index.d.ts +3 -0
  138. package/dist/plugin/platform/src/plugin/camera/index.d.ts +1 -1
  139. package/dist/plugin/platform/src/plugin/camera/types/camera.d.ts +1 -1
  140. package/dist/plugin/platform/src/plugin/camera/types/index.d.ts +1 -1
  141. package/dist/plugin/platform/src/plugin/camera/utils/try-open-camera.d.ts +1 -1
  142. package/dist/plugin/platform/src/plugin/clipboard/cores/index.d.ts +3 -0
  143. package/dist/plugin/platform/src/plugin/fullscreen/cores/index.d.ts +35 -0
  144. package/dist/plugin/platform/src/plugin/fullscreen/types/fullscreen.d.ts +5 -5
  145. package/dist/plugin/platform/src/plugin/platform/constants/index.d.ts +42 -0
  146. package/dist/plugin/platform/src/plugin/platform/cores/index.d.ts +28 -0
  147. package/dist/plugin/platform/src/plugin/platform/index.d.ts +3 -2
  148. package/dist/plugin/platform/src/plugin/platform/types/index.d.ts +4 -0
  149. package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +5 -2
  150. package/dist/plugin/platform/src/plugin/theme/constants/index.d.ts +2 -0
  151. package/dist/plugin/platform/src/plugin/theme/cores/index.d.ts +3 -0
  152. package/dist/plugin/platform/src/plugin/theme/index.d.ts +1 -13
  153. package/dist/plugin/platform/src/plugin/theme/types/index.d.ts +0 -12
  154. package/dist/plugin/platform/src/plugin/theme/types/theme.d.ts +2 -21
  155. package/dist/plugin/platform/src/utils/create-hidden-element.d.ts +1 -1
  156. package/dist/plugin/theme/index.cjs +63 -906
  157. package/dist/plugin/theme/index.d.ts +4 -87
  158. package/dist/plugin/theme/index.min.cjs +1 -1
  159. package/dist/plugin/theme/index.min.mjs +1 -1
  160. package/dist/plugin/theme/index.mjs +63 -906
  161. package/dist/plugin/theme/index.umd.js +63 -906
  162. package/dist/plugin/theme/index.umd.min.js +1 -1
  163. package/dist/plugin/theme/src/plugin/app/cores/index.d.ts +0 -4
  164. package/dist/plugin/theme/src/plugin/app/types/app.d.ts +1 -1
  165. package/dist/plugin/theme/src/plugin/camera/cores/index.d.ts +2 -2
  166. package/dist/plugin/theme/src/plugin/clipboard/cores/index.d.ts +2 -2
  167. package/dist/plugin/theme/src/plugin/fullscreen/cores/index.d.ts +2 -2
  168. package/dist/plugin/theme/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  169. package/dist/plugin/theme/src/plugin/platform/constants/index.d.ts +42 -0
  170. package/dist/plugin/theme/src/plugin/platform/cores/index.d.ts +28 -0
  171. package/dist/plugin/theme/src/plugin/platform/index.d.ts +3 -2
  172. package/dist/plugin/theme/src/plugin/platform/types/index.d.ts +4 -0
  173. package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +5 -2
  174. package/dist/plugin/theme/src/plugin/theme/constants/index.d.ts +0 -12
  175. package/dist/plugin/theme/src/plugin/theme/cores/index.d.ts +2 -2
  176. package/dist/plugin/theme/src/plugin/theme/index.d.ts +1 -13
  177. package/dist/plugin/theme/src/plugin/theme/types/index.d.ts +0 -12
  178. package/dist/plugin/theme/src/plugin/theme/types/theme.d.ts +2 -22
  179. package/dist/src/plugin/app/cores/index.d.ts +0 -4
  180. package/dist/src/plugin/app/types/app.d.ts +1 -1
  181. package/dist/src/plugin/camera/cores/index.d.ts +2 -2
  182. package/dist/src/plugin/clipboard/cores/index.d.ts +2 -2
  183. package/dist/src/plugin/fullscreen/cores/index.d.ts +2 -2
  184. package/dist/src/plugin/fullscreen/types/fullscreen.d.ts +3 -10
  185. package/dist/src/plugin/platform/constants/index.d.ts +42 -0
  186. package/dist/src/plugin/platform/cores/index.d.ts +28 -0
  187. package/dist/src/plugin/platform/index.d.ts +3 -2
  188. package/dist/src/plugin/platform/types/index.d.ts +4 -0
  189. package/dist/src/plugin/platform/types/platform.d.ts +5 -2
  190. package/dist/src/plugin/theme/constants/index.d.ts +0 -12
  191. package/dist/src/plugin/theme/cores/index.d.ts +2 -2
  192. package/dist/src/plugin/theme/index.d.ts +1 -13
  193. package/dist/src/plugin/theme/types/index.d.ts +0 -12
  194. package/dist/src/plugin/theme/types/theme.d.ts +2 -22
  195. package/package.json +1 -1
@@ -1,17 +1,5 @@
1
1
  import type { NativePlugin } from "../../types";
2
2
  import type { ThemeInstance } from "./types";
3
- import { Appearances } from "./constants";
4
- import { EasingError, UnsupportedEasingFunctionError, StepSyntaxError, LinearSyntaxError, CubicBezierSyntaxError } from "./errors/easing-error";
5
- import { UnsupportedColorError } from "./errors/unsupported-color-error";
6
3
  export * from "./types";
7
- declare const NativeThemePlugin: NativePlugin<'Theme', ThemeInstance, {
8
- Appearances: typeof Appearances;
9
- }, {
10
- EasingError: typeof EasingError;
11
- UnsupportedEasingFunctionError: typeof UnsupportedEasingFunctionError;
12
- StepSyntaxError: typeof StepSyntaxError;
13
- LinearSyntaxError: typeof LinearSyntaxError;
14
- CubicBezierSyntaxError: typeof CubicBezierSyntaxError;
15
- UnsupportedColorError: typeof UnsupportedColorError;
16
- }>;
4
+ declare const NativeThemePlugin: NativePlugin<'Theme', ThemeInstance, {}, {}>;
17
5
  export default NativeThemePlugin;
@@ -1,23 +1,11 @@
1
- export * from "./color";
2
- export * from "./easing-syntax";
3
1
  export * from "./theme";
4
2
  import type { ThemeInstance } from "./theme";
5
- import { Appearances } from "../constants";
6
- import { UnsupportedColorError } from "../errors/unsupported-color-error";
7
- import { CubicBezierSyntaxError, EasingError, LinearSyntaxError, StepSyntaxError, UnsupportedEasingFunctionError } from "../errors/easing-error";
8
3
  declare module 'native-fn' {
9
4
  interface NativePlugins {
10
5
  Theme: ThemeInstance;
11
6
  }
12
7
  interface NativeConstants {
13
- Appearances: typeof Appearances;
14
8
  }
15
9
  interface NativeErrors {
16
- EasingError: typeof EasingError;
17
- UnsupportedEasingFunctionError: typeof UnsupportedEasingFunctionError;
18
- StepSyntaxError: typeof StepSyntaxError;
19
- LinearSyntaxError: typeof LinearSyntaxError;
20
- CubicBezierSyntaxError: typeof CubicBezierSyntaxError;
21
- UnsupportedColorError: typeof UnsupportedColorError;
22
10
  }
23
11
  }
@@ -1,24 +1,4 @@
1
- import { Appearances } from "../constants";
2
- import type { EasingKeyword, EasingSyntax, Color } 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 type ThemeColorMetaAppearanceKeys = 'default' | 'dark' | 'light';
10
- export declare type ThemeColorMetaGroup = Partial<Record<ThemeColorMetaAppearanceKeys, HTMLMetaElement>>;
11
- export declare interface SetThemeColorOptions {
12
- appearance?: ThemeColorMetaAppearanceKeys;
13
- duration?: number;
14
- easingFunction?: EasingSyntax | EasingKeyword;
15
- defaultColor?: string;
16
- }
17
1
  export declare interface ThemeInstance {
18
- setThemeColor(color: Color, options?: SetThemeColorOptions): Promise<string | undefined>;
19
- getThemeColor(): Color | undefined;
20
- removeThemeColor(appearance?: ThemeColorMetaAppearanceKeys): void;
21
- getAppearance(): Promise<Appearances>;
22
- setAppearance(appearances?: Exclude<Appearances, Appearances.Unknown>): void;
23
- onAppearanceChange(listener: (appearance?: Appearances) => any, options?: boolean | AddEventListenerOptions): () => void;
2
+ get value(): string | undefined;
3
+ set value(color: string | undefined);
24
4
  }
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var USER_AGENT = navigator.userAgent;
4
-
5
3
  var OS;
6
4
  (function (OS) {
7
5
  OS["Unknown"] = "Unknown";
@@ -41,42 +39,55 @@ var Browsers;
41
39
  Browsers["IE"] = "IE";
42
40
  Browsers["SamsungInternet"] = "SamsungInternet";
43
41
  })(Browsers || (Browsers = {}));
44
- function resolveWindowsVersion(string) {
45
- if (string === undefined)
46
- return '';
47
- var mapped = {
48
- '4.90': 'ME',
49
- 'NT3.51': 'NT 3.11',
50
- 'NT4.0': 'NT 4.0',
51
- 'NT 5.0': '2000',
52
- 'NT 5.1': 'XP',
53
- 'NT 5.2': 'XP',
54
- 'NT 6.0': 'Vista',
55
- 'NT 6.1': '7',
56
- 'NT 6.2': '8',
57
- 'NT 6.3': '8.1',
58
- 'NT 6.4': '10',
59
- 'NT 10.0': '10',
60
- 'ARM': 'RT'
61
- }[string];
62
- if (mapped !== undefined)
63
- return mapped;
64
- return string;
65
- }
66
- function resolveUnderscoreVersion(string) {
67
- if (string === undefined)
68
- return '';
69
- return string.replace(/_/g, '.');
70
- }
71
- function resolveVersion(string, resolver) {
72
- if (typeof resolver === 'function')
73
- return resolver(string);
74
- if (typeof resolver === 'string')
75
- return resolver;
76
- if (string === undefined)
77
- return '';
78
- return string;
42
+ var CrossPlatformFramework;
43
+ (function (CrossPlatformFramework) {
44
+ CrossPlatformFramework["NotACrossPlatformFramework"] = "NotACrossPlatformFramework";
45
+ CrossPlatformFramework["ReactNative"] = "ReactNative";
46
+ CrossPlatformFramework["Electron"] = "Electron";
47
+ CrossPlatformFramework["Cordova"] = "Cordova";
48
+ })(CrossPlatformFramework || (CrossPlatformFramework = {}));
49
+ var USER_AGENT = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
50
+
51
+ function compareVersion(lhs, rhs) {
52
+ var pa = lhs.split('.');
53
+ var pb = rhs.split('.');
54
+ var length = Math.max(pa.length, pb.length);
55
+ for (var i = 0; i < length; i++) {
56
+ var a = void 0;
57
+ var b = void 0;
58
+ if (i < pa.length)
59
+ a = parseInt(pa[i], 10);
60
+ else
61
+ a = 0;
62
+ if (i < pb.length)
63
+ b = parseInt(pb[i], 10);
64
+ else
65
+ b = 0;
66
+ if (a > b)
67
+ return 1;
68
+ if (a < b)
69
+ return -1;
70
+ }
71
+ return 0;
79
72
  }
73
+
74
+ var Platform = {
75
+ device: Devices.Unknown,
76
+ os: OS.Unknown,
77
+ engine: Engines.Unknown,
78
+ browser: Browsers.Unknown,
79
+ crossPlatformFramework: CrossPlatformFramework.NotACrossPlatformFramework,
80
+ osVersion: '',
81
+ engineVersion: '',
82
+ browserVersion: '',
83
+ renderer: getRenderer(),
84
+ userAgent: USER_AGENT,
85
+ isNode: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined,
86
+ isMobile: false,
87
+ isDesktop: false,
88
+ isStandalone: false,
89
+ isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(USER_AGENT),
90
+ };
80
91
  var OS_RESOLVER_MAP = [
81
92
  [/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
82
93
  [/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
@@ -135,38 +146,247 @@ var BROWSER_RESOLVER_MAP = [
135
146
  [/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
136
147
  [/firefox\/([\w.]+)/i, Browsers.Firefox],
137
148
  ];
138
- var DEVICE_NAME = Devices.Unknown;
139
- var OS_NAME = OS.Unknown;
140
- var OS_VERSION = '';
141
- var ENGINE_NAME = Engines.Unknown;
142
- var ENGINE_VERSION = '';
143
- var BROWSER_NAME = Browsers.Unknown;
144
- var BROWSER_VERSION = '';
149
+ function resolveWindowsVersion(string) {
150
+ if (string === undefined)
151
+ return '';
152
+ var mapped = {
153
+ '4.90': 'ME',
154
+ 'NT3.51': 'NT 3.11',
155
+ 'NT4.0': 'NT 4.0',
156
+ 'NT 5.0': '2000',
157
+ 'NT 5.1': 'XP',
158
+ 'NT 5.2': 'XP',
159
+ 'NT 6.0': 'Vista',
160
+ 'NT 6.1': '7',
161
+ 'NT 6.2': '8',
162
+ 'NT 6.3': '8.1',
163
+ 'NT 6.4': '10',
164
+ 'NT 10.0': '10',
165
+ 'ARM': 'RT'
166
+ }[string];
167
+ if (mapped !== undefined)
168
+ return mapped;
169
+ return string;
170
+ }
171
+ function resolveUnderscoreVersion(string) {
172
+ if (string === undefined)
173
+ return '';
174
+ return string.replace(/_/g, '.');
175
+ }
176
+ function resolveSemanticWindowsVersion(version, defaultValue) {
177
+ if (version.major === 10 && version.minor === 0 && version.build >= 22000)
178
+ return '11';
179
+ if (version.major === 10 && version.minor === 0 && version.build < 22000)
180
+ return '10';
181
+ if (version.major === 6 && version.minor === 3)
182
+ return '8.1';
183
+ if (version.major === 6 && version.minor === 2)
184
+ return '8';
185
+ if (version.major === 6 && version.minor === 1)
186
+ return '7';
187
+ if (version.major === 6 && version.minor === 0)
188
+ return 'Vista';
189
+ if (version.major === 5 && version.minor === 1)
190
+ return 'XP';
191
+ if (version.major === 5 && version.minor === 2)
192
+ return 'XP';
193
+ if (version.major === 5 && version.minor === 0)
194
+ return '2000';
195
+ if (version.major === 4 && version.minor === 90)
196
+ return 'ME';
197
+ if (version.major === 4 && version.minor === 0)
198
+ return 'NT 4.0';
199
+ if (version.major === 3 && version.minor === 51)
200
+ return 'NT 3.11';
201
+ return defaultValue;
202
+ }
203
+ function resolveSemanticDarwinVersion(version, defaultValue) {
204
+ if (version.major >= 24)
205
+ return '' + (version.major - 9) + '.' + version.minor + '.' + version.build;
206
+ if (version.major === 23)
207
+ return '14.' + version.minor + '.' + version.build;
208
+ if (version.major === 22)
209
+ return '13.' + version.minor + '.' + version.build;
210
+ if (version.major === 21)
211
+ return '12.' + version.minor + '.' + version.build;
212
+ if (version.major === 20)
213
+ return '11.' + version.minor + '.' + version.build;
214
+ if (version.major === 19)
215
+ return '10.15.' + version.minor;
216
+ if (version.major === 18)
217
+ return '10.14.' + version.minor;
218
+ if (version.major === 17)
219
+ return '10.13.' + version.minor;
220
+ if (version.major === 16)
221
+ return '10.12.' + version.minor;
222
+ if (version.major === 15)
223
+ return '10.11.' + version.minor;
224
+ if (version.major === 14)
225
+ return '10.10.' + version.minor;
226
+ if (version.major === 13)
227
+ return '10.9.' + version.minor;
228
+ if (version.major >= 5 && version.major <= 12)
229
+ return '10.' + (version.major - 4) + '.' + version.minor;
230
+ return defaultValue;
231
+ }
232
+ function resolveSemanticAndroidVersion(version, defaultValue) {
233
+ if (version.major >= 36)
234
+ return '16';
235
+ if (version.major === 35)
236
+ return '15';
237
+ if (version.major === 34)
238
+ return '14';
239
+ if (version.major === 33)
240
+ return '13';
241
+ if (version.major === 32)
242
+ return '12.1';
243
+ if (version.major === 31)
244
+ return '12';
245
+ if (version.major === 30)
246
+ return '11';
247
+ if (version.major === 29)
248
+ return '10';
249
+ if (version.major === 28)
250
+ return '9';
251
+ if (version.major === 27)
252
+ return '8.1';
253
+ if (version.major === 26)
254
+ return '8.0';
255
+ if (version.major === 25)
256
+ return '7.1';
257
+ if (version.major === 24)
258
+ return '7.0';
259
+ if (version.major === 23)
260
+ return '6.0';
261
+ if (version.major === 22)
262
+ return '5.1';
263
+ if (version.major === 21)
264
+ return '5.0';
265
+ if (version.major === 20)
266
+ return '4.4';
267
+ if (version.major === 19)
268
+ return '4.4';
269
+ if (version.major === 18)
270
+ return '4.3';
271
+ if (version.major === 17)
272
+ return '4.2';
273
+ if (version.major === 16)
274
+ return '4.1';
275
+ if (version.major === 15)
276
+ return '4.0.3';
277
+ if (version.major === 14)
278
+ return '4.0';
279
+ if (version.major === 13)
280
+ return '3.2';
281
+ if (version.major === 12)
282
+ return '3.1';
283
+ if (version.major === 11)
284
+ return '3.0';
285
+ if (version.major === 10)
286
+ return '2.3.3';
287
+ if (version.major === 9)
288
+ return '2.3';
289
+ if (version.major === 8)
290
+ return '2.2';
291
+ if (version.major === 7)
292
+ return '2.1';
293
+ if (version.major === 6)
294
+ return '2.0.1';
295
+ if (version.major === 5)
296
+ return '2.0';
297
+ if (version.major === 4)
298
+ return '1.6';
299
+ if (version.major === 3)
300
+ return '1.5';
301
+ if (version.major === 2)
302
+ return '1.1';
303
+ if (version.major === 1)
304
+ return '1.0';
305
+ return defaultValue;
306
+ }
307
+ function resolveVersion(string, resolver) {
308
+ if (typeof resolver === 'function')
309
+ return resolver(string);
310
+ if (typeof resolver === 'string')
311
+ return resolver;
312
+ if (string === undefined)
313
+ return '';
314
+ return string;
315
+ }
316
+ function normalizeBrand(entry) {
317
+ if (entry === null || entry === undefined)
318
+ return { brand: '', version: '' };
319
+ if (typeof entry === 'string')
320
+ return { brand: entry, version: '' };
321
+ return { brand: entry.brand, version: entry.version };
322
+ }
323
+ function getRenderer() {
324
+ if (typeof globalThis.document === 'undefined')
325
+ return '';
326
+ var canvas = globalThis.document.createElement('canvas');
327
+ if (typeof canvas.getContext !== 'function')
328
+ return '';
329
+ var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
330
+ if (context === null)
331
+ return '';
332
+ if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
333
+ var extension = context.getExtension('WEBGL_debug_renderer_info');
334
+ if (extension === null)
335
+ return context.getParameter(context.RENDERER);
336
+ else
337
+ return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
338
+ }
339
+ else {
340
+ return '';
341
+ }
342
+ }
343
+ function getIsStandalone(os) {
344
+ if (!('matchMedia' in globalThis))
345
+ return false;
346
+ if (os === OS.iOS)
347
+ return 'standalone' in navigator && !!navigator.standalone;
348
+ return globalThis.matchMedia('(display-mode: standalone)').matches;
349
+ }
350
+ function getSemanticVersion(string) {
351
+ var parts = string.split('.');
352
+ return {
353
+ major: parseInt(parts[0] || '0'),
354
+ minor: parseInt(parts[1] || '0'),
355
+ build: parseInt(parts[2] || '0')
356
+ };
357
+ }
358
+ if ((typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(USER_AGENT))) {
359
+ Platform.crossPlatformFramework = CrossPlatformFramework.Electron;
360
+ }
361
+ if (typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative') {
362
+ Platform.crossPlatformFramework = CrossPlatformFramework.ReactNative;
363
+ }
145
364
  for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
146
365
  var map = OS_RESOLVER_MAP[i];
147
366
  var regexp = map[0];
148
367
  var os = map[1];
149
368
  var resolver = map[2];
150
- var matched = USER_AGENT.match(regexp);
369
+ var matched = Platform.userAgent.match(regexp);
151
370
  if (matched !== null) {
152
- OS_NAME = os;
153
- OS_VERSION = resolveVersion(matched[1], resolver);
154
- if (os === OS.iOS || os === OS.Android)
155
- DEVICE_NAME = Devices.Mobile;
156
- else if (os === OS.Windows || os === OS.MacOS)
157
- DEVICE_NAME = Devices.Desktop;
371
+ Platform.os = os;
372
+ Platform.osVersion = resolveVersion(matched[1], resolver);
158
373
  break;
159
374
  }
160
375
  }
376
+ if (Platform.os === OS.iOS && compareVersion(Platform.osVersion, '18.6') === 0) {
377
+ var version = /\) Version\/([\d.]+)/.exec(Platform.userAgent);
378
+ if (version !== null && parseInt(version[1].substring(0, 2), 10) >= 26)
379
+ Platform.osVersion = version[1];
380
+ }
161
381
  for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
162
382
  var map = ENGINE_RESOLVER_MAP[i];
163
383
  var regexp = map[0];
164
384
  var engine = map[1];
165
385
  var resolver = map[2];
166
- var matched = USER_AGENT.match(regexp);
386
+ var matched = Platform.userAgent.match(regexp);
167
387
  if (matched !== null) {
168
- ENGINE_NAME = engine;
169
- ENGINE_VERSION = resolveVersion(matched[1], resolver);
388
+ Platform.engine = engine;
389
+ Platform.engineVersion = resolveVersion(matched[1], resolver);
170
390
  break;
171
391
  }
172
392
  }
@@ -175,68 +395,90 @@ for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
175
395
  var regexp = map[0];
176
396
  var browser = map[1];
177
397
  var resolver = map[2];
178
- var matched = USER_AGENT.match(regexp);
398
+ var matched = Platform.userAgent.match(regexp);
179
399
  if (matched !== null) {
180
- BROWSER_NAME = browser;
181
- BROWSER_VERSION = resolveVersion(matched[1], resolver);
400
+ Platform.browser = browser;
401
+ Platform.browserVersion = resolveVersion(matched[1], resolver);
182
402
  break;
183
403
  }
184
404
  }
185
- var RENDERER = (function () {
186
- if (typeof globalThis.document === 'undefined')
187
- return '';
188
- var canvas = globalThis.document.createElement('canvas');
189
- if (typeof canvas.getContext !== 'function')
190
- return '';
191
- var context = canvas.getContext('webgl2') || canvas.getContext('experimental-webgl') || canvas.getContext('webgl');
192
- if (context === null)
193
- return '';
194
- if (context instanceof WebGLRenderingContext || 'getParameter' in context && typeof context.getParameter === 'function') {
195
- var extension = context.getExtension('WEBGL_debug_renderer_info');
196
- if (extension === null)
197
- return context.getParameter(context.RENDERER);
198
- else
199
- return context.getParameter(extension.UNMASKED_RENDERER_WEBGL);
405
+ if (Platform.crossPlatformFramework === CrossPlatformFramework.ReactNative) {
406
+ try {
407
+ var reactNative = require('react-native');
408
+ var platform = reactNative.Platform;
409
+ var os = platform.OS;
410
+ var release = '' + platform.Version;
411
+ var version = getSemanticVersion(release);
412
+ switch (os) {
413
+ case 'android':
414
+ Platform.os = OS.Android;
415
+ Platform.osVersion = resolveSemanticAndroidVersion(version, release);
416
+ break;
417
+ case 'ios':
418
+ Platform.os = OS.iOS;
419
+ Platform.osVersion = release;
420
+ break;
421
+ case 'windows':
422
+ Platform.os = OS.Windows;
423
+ Platform.osVersion = resolveSemanticWindowsVersion(version, release);
424
+ break;
425
+ case 'macos':
426
+ Platform.os = OS.MacOS;
427
+ Platform.osVersion = release;
428
+ break;
429
+ }
200
430
  }
201
- else {
202
- return '';
431
+ catch (_) {
203
432
  }
204
- })();
205
- var IS_WEBVIEW = /; ?wv|applewebkit(?!.*safari)/i.test(USER_AGENT);
206
- var IS_MOBILE = DEVICE_NAME === Devices.Mobile;
207
- var IS_DESKTOP = DEVICE_NAME === Devices.Desktop;
208
- var IS_STANDALONE = (function () {
209
- if (!('matchMedia' in globalThis))
210
- return false;
211
- if (OS_NAME === OS.iOS)
212
- return 'standalone' in navigator && !!navigator.standalone;
213
- return globalThis.matchMedia('(display-mode: standalone)').matches;
214
- })();
215
-
216
- var Platform = {
217
- os: OS_NAME,
218
- device: DEVICE_NAME,
219
- engine: ENGINE_NAME,
220
- browser: BROWSER_NAME,
221
- osVersion: OS_VERSION,
222
- engineVersion: ENGINE_VERSION,
223
- browserVersion: BROWSER_VERSION,
224
- renderer: RENDERER,
225
- isWebview: IS_WEBVIEW,
226
- isMobile: IS_MOBILE,
227
- isDesktop: IS_DESKTOP,
228
- isStandalone: IS_STANDALONE,
229
- };
230
- function normalizeBrand(entry) {
231
- if (entry === null || entry === undefined)
232
- return { brand: '', version: '' };
233
- if (typeof entry === 'string')
234
- return { brand: entry, version: '' };
235
- return { brand: entry.brand, version: entry.version };
236
433
  }
237
- var navigatorWithUserAgentData = navigator;
238
- if (navigatorWithUserAgentData.userAgentData !== undefined && navigatorWithUserAgentData.userAgentData.getHighEntropyValues !== undefined) {
239
- navigatorWithUserAgentData
434
+ if (Platform.isNode) {
435
+ try {
436
+ var os = require('os');
437
+ var platform = os.platform();
438
+ var release = os.release();
439
+ var version = getSemanticVersion(release);
440
+ switch (platform) {
441
+ case 'win32':
442
+ Platform.os = OS.Windows;
443
+ Platform.osVersion = resolveSemanticWindowsVersion(version, release);
444
+ break;
445
+ case 'darwin':
446
+ Platform.os = OS.MacOS;
447
+ Platform.osVersion = resolveSemanticDarwinVersion(version, release);
448
+ break;
449
+ case 'android':
450
+ Platform.os = OS.Android;
451
+ Platform.osVersion = release;
452
+ break;
453
+ case 'linux':
454
+ if (/android/i.test(release)) {
455
+ Platform.os = OS.Android;
456
+ Platform.osVersion = release;
457
+ }
458
+ break;
459
+ }
460
+ }
461
+ catch (_) {
462
+ }
463
+ }
464
+ if (typeof globalThis.document !== 'undefined') {
465
+ globalThis.document.addEventListener("deviceready", function () {
466
+ Platform.crossPlatformFramework = CrossPlatformFramework.Cordova;
467
+ if (Platform.os === OS.Unknown && typeof globalThis.device !== 'undefined') {
468
+ switch (globalThis.device.platform) {
469
+ case 'Android':
470
+ Platform.os = OS.Android;
471
+ break;
472
+ case 'iOS':
473
+ Platform.os = OS.iOS;
474
+ break;
475
+ }
476
+ Platform.osVersion = globalThis.device.version;
477
+ }
478
+ }, false);
479
+ }
480
+ if (navigator.userAgentData !== undefined && navigator.userAgentData.getHighEntropyValues !== undefined) {
481
+ navigator
240
482
  .userAgentData
241
483
  .getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
242
484
  .then(function (result) {
@@ -259,6 +501,10 @@ if (navigatorWithUserAgentData.userAgentData !== undefined && navigatorWithUserA
259
501
  }
260
502
  });
261
503
  }
504
+ Platform.device = Platform.os === OS.iOS || Platform.os === OS.Android ? Devices.Mobile : Platform.os === OS.Windows || Platform.os === OS.MacOS ? Devices.Desktop : Devices.Unknown;
505
+ Platform.isMobile = Platform.device === Devices.Mobile;
506
+ Platform.isDesktop = Platform.device === Devices.Desktop;
507
+ Platform.isStandalone = getIsStandalone(Platform.os);
262
508
 
263
509
  var NativePlatformPlugin = {
264
510
  installed: false,
@@ -269,6 +515,7 @@ var NativePlatformPlugin = {
269
515
  Devices: Devices,
270
516
  Engines: Engines,
271
517
  Browsers: Browsers,
518
+ CrossPlatformFramework: CrossPlatformFramework,
272
519
  },
273
520
  Errors: {}
274
521
  };
@@ -6,24 +6,6 @@ declare interface NativePlugin<Key extends string, Module, Constants extends Rec
6
6
  Errors: Errors;
7
7
  }
8
8
 
9
- declare global {
10
- interface Navigator {
11
- userAgentData?: UserAgentData;
12
- }
13
- }
14
- interface ModernUserAgentDataBrand {
15
- brand: string;
16
- version: string;
17
- }
18
- type UserAgentDataBrand = ModernUserAgentDataBrand | string | null | undefined;
19
- interface UserAgentDataValues {
20
- brands?: UserAgentDataBrand[];
21
- fullVersionList?: UserAgentDataBrand[];
22
- platformVersion?: string | null | undefined;
23
- }
24
- interface UserAgentData {
25
- getHighEntropyValues?(hints: string[]): Promise<UserAgentDataValues>;
26
- }
27
9
  declare enum OS {
28
10
  Unknown = "Unknown",
29
11
  Android = "Android",
@@ -59,26 +41,39 @@ declare enum Browsers {
59
41
  IE = "IE",
60
42
  SamsungInternet = "SamsungInternet"
61
43
  }
44
+ declare enum CrossPlatformFramework {
45
+ NotACrossPlatformFramework = "NotACrossPlatformFramework",
46
+ ReactNative = "ReactNative",
47
+ Electron = "Electron",
48
+ Cordova = "Cordova"
49
+ }
62
50
 
63
51
  declare interface PlatformInstance {
64
52
  os: OS;
65
53
  device: Devices;
66
54
  engine: Engines;
67
55
  browser: Browsers;
56
+ crossPlatformFramework: CrossPlatformFramework;
68
57
  osVersion: string;
69
58
  engineVersion: string;
70
59
  browserVersion: string;
71
60
  renderer: string;
72
- isWebview: boolean;
61
+ userAgent: string;
62
+ isNode: boolean;
73
63
  isStandalone: boolean;
74
64
  isMobile: boolean;
75
65
  isDesktop: boolean;
66
+ isWebview: boolean;
76
67
  }
77
68
 
78
69
  declare module 'native-fn' {
79
70
  interface NativePlugins {
80
71
  Platform: PlatformInstance;
81
72
  }
73
+ interface NativeConstants {
74
+ }
75
+ interface NativeErrors {
76
+ }
82
77
  }
83
78
 
84
79
  declare const NativePlatformPlugin: NativePlugin<'Platform', PlatformInstance, {
@@ -86,6 +81,7 @@ declare const NativePlatformPlugin: NativePlugin<'Platform', PlatformInstance, {
86
81
  Devices: typeof Devices;
87
82
  Engines: typeof Engines;
88
83
  Browsers: typeof Browsers;
84
+ CrossPlatformFramework: typeof CrossPlatformFramework;
89
85
  }, {}>;
90
86
 
91
87
  export { NativePlatformPlugin as default };