native-fn 1.0.71 → 1.0.72

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 +2 -2
  23. package/dist/plugin/app/src/plugin/platform/types/index.d.ts +5 -1
  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 +11 -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 +2 -2
  67. package/dist/plugin/camera/src/plugin/platform/types/index.d.ts +5 -1
  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 +2 -2
  89. package/dist/plugin/clipboard/src/plugin/platform/types/index.d.ts +5 -1
  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 +2 -2
  112. package/dist/plugin/fullscreen/src/plugin/platform/types/index.d.ts +5 -1
  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 +355 -109
  120. package/dist/plugin/platform/index.d.ts +15 -20
  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 +355 -109
  124. package/dist/plugin/platform/index.umd.js +355 -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 +2 -2
  148. package/dist/plugin/platform/src/plugin/platform/types/index.d.ts +5 -1
  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 +2 -2
  172. package/dist/plugin/theme/src/plugin/platform/types/index.d.ts +5 -1
  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 +2 -2
  188. package/dist/src/plugin/platform/types/index.d.ts +5 -1
  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
@@ -66,24 +66,31 @@
66
66
  Browsers["IE"] = "IE";
67
67
  Browsers["SamsungInternet"] = "SamsungInternet";
68
68
  })(Browsers || (Browsers = {}));
69
- var userAgent = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
70
- var IS_NODE_JS = typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined;
71
- var IS_ELECTRON = (typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(userAgent));
72
- var IS_REACT_NATIVE = typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative';
69
+ var CrossPlatformFramework;
70
+ (function (CrossPlatformFramework) {
71
+ CrossPlatformFramework["NotACrossPlatformFramework"] = "NotACrossPlatformFramework";
72
+ CrossPlatformFramework["ReactNative"] = "ReactNative";
73
+ CrossPlatformFramework["Electron"] = "Electron";
74
+ CrossPlatformFramework["Cordova"] = "Cordova";
75
+ })(CrossPlatformFramework || (CrossPlatformFramework = {}));
76
+ var USER_AGENT = typeof globalThis.navigator !== 'undefined' && typeof globalThis.navigator.userAgent === 'string' ? globalThis.navigator.userAgent : '';
77
+
73
78
  var Platform = {
74
79
  device: Devices.Unknown,
75
80
  os: OS.Unknown,
76
- osVersion: '',
77
81
  engine: Engines.Unknown,
78
- engineVersion: '',
79
82
  browser: Browsers.Unknown,
83
+ crossPlatformFramework: CrossPlatformFramework.NotACrossPlatformFramework,
84
+ osVersion: '',
85
+ engineVersion: '',
80
86
  browserVersion: '',
81
87
  renderer: getRenderer(),
82
- userAgent: userAgent,
88
+ userAgent: USER_AGENT,
89
+ isNode: typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.node !== undefined,
83
90
  isMobile: false,
84
91
  isDesktop: false,
85
92
  isStandalone: false,
86
- isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(userAgent),
93
+ isWebview: /; ?wv|applewebkit(?!.*safari)/i.test(USER_AGENT),
87
94
  };
88
95
  var OS_RESOLVER_MAP = [
89
96
  [/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
@@ -352,6 +359,12 @@
352
359
  build: parseInt(parts[2] || '0')
353
360
  };
354
361
  }
362
+ if ((typeof globalThis.process !== 'undefined' && typeof globalThis.process.versions !== 'undefined' && globalThis.process.versions.electron !== undefined) || (/ electron\//i.test(USER_AGENT))) {
363
+ Platform.crossPlatformFramework = CrossPlatformFramework.Electron;
364
+ }
365
+ if (typeof globalThis.navigator !== 'undefined' && globalThis.navigator.product === 'ReactNative') {
366
+ Platform.crossPlatformFramework = CrossPlatformFramework.ReactNative;
367
+ }
355
368
  for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
356
369
  var map = OS_RESOLVER_MAP[i];
357
370
  var regexp = map[0];
@@ -393,7 +406,7 @@
393
406
  break;
394
407
  }
395
408
  }
396
- if (IS_REACT_NATIVE) {
409
+ if (Platform.crossPlatformFramework === CrossPlatformFramework.ReactNative) {
397
410
  try {
398
411
  var reactNative = require('react-native');
399
412
  var platform = reactNative.Platform;
@@ -422,7 +435,7 @@
422
435
  catch (_) {
423
436
  }
424
437
  }
425
- if (IS_NODE_JS) {
438
+ if (Platform.isNode) {
426
439
  try {
427
440
  var os = require('os');
428
441
  var platform = os.platform();
@@ -454,6 +467,7 @@
454
467
  }
455
468
  if (typeof globalThis.document !== 'undefined') {
456
469
  globalThis.document.addEventListener("deviceready", function () {
470
+ Platform.crossPlatformFramework = CrossPlatformFramework.Cordova;
457
471
  if (Platform.os === OS.Unknown && typeof globalThis.device !== 'undefined') {
458
472
  switch (globalThis.device.platform) {
459
473
  case 'Android':
@@ -496,922 +510,65 @@
496
510
  Platform.isDesktop = Platform.device === Devices.Desktop;
497
511
  Platform.isStandalone = getIsStandalone(Platform.os);
498
512
 
499
- var Appearances;
500
- (function (Appearances) {
501
- Appearances["Unknown"] = "unknown";
502
- Appearances["Light"] = "light";
503
- Appearances["Dark"] = "dark";
504
- })(Appearances || (Appearances = {}));
505
- var FALLBACK_MEDIA_QUERY_LIST = {
506
- matches: false,
507
- media: 'not all',
508
- onchange: null,
509
- addListener: function () {
510
- },
511
- removeListener: function () {
512
- },
513
- addEventListener: function () {
514
- },
515
- removeEventListener: function () {
516
- },
517
- dispatchEvent: function () {
518
- return false;
519
- },
520
- };
521
- var MEDIA_QUERY_LIST = 'matchMedia' in globalThis ? globalThis.matchMedia('(prefers-color-scheme: dark)') : FALLBACK_MEDIA_QUERY_LIST;
522
- var SUPPORT_PREFERS_COLOR_SCHEME = MEDIA_QUERY_LIST.media !== 'not all';
523
- var IS_FULL_SUPPORT_THEME_COLOR = Platform.browser !== Browsers.Chrome || (Platform.isMobile && compareVersion(Platform.browserVersion, '92') >= 0);
524
- var CONTEXT = 'document' in globalThis ? globalThis.document.createElement('canvas').getContext('2d', { willReadFrequently: true }) : null;
525
- var SVG_PIXEL_DATA_URL = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IndoaXRlIi8+PC9zdmc+';
526
513
  var IS_IE_MOBILE = /iemobile/i.test(Platform.userAgent);
527
514
  var IS_WINDOWS_PHONE = /windows phone/i.test(Platform.userAgent);
528
- var ENTRIES = [];
529
-
530
- /******************************************************************************
531
- Copyright (c) Microsoft Corporation.
532
-
533
- Permission to use, copy, modify, and/or distribute this software for any
534
- purpose with or without fee is hereby granted.
535
-
536
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
537
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
538
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
539
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
540
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
541
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
542
- PERFORMANCE OF THIS SOFTWARE.
543
- ***************************************************************************** */
544
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
545
-
546
-
547
- function __values(o) {
548
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
549
- if (m) return m.call(o);
550
- if (o && typeof o.length === "number") return {
551
- next: function () {
552
- if (o && i >= o.length) o = void 0;
553
- return { value: o && o[i++], done: !o };
554
- }
555
- };
556
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
557
- }
558
-
559
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
560
- var e = new Error(message);
561
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
562
- };
563
515
 
564
- function createCustomError(name, Base) {
565
- if (Base === void 0) { Base = Error; }
566
- function CustomError(message) {
567
- if (!(this instanceof CustomError))
568
- return new CustomError(message);
569
- var error = new Base(message || '');
570
- if (typeof Object.setPrototypeOf === 'function')
571
- Object.setPrototypeOf(error, CustomError.prototype);
516
+ var metaElement = null;
517
+ var Theme = {
518
+ get value() {
519
+ return getThemeColor();
520
+ },
521
+ set value(color) {
522
+ if (color === undefined)
523
+ removeThemeColor();
572
524
  else
573
- error.__proto__ = CustomError.prototype;
574
- error.name = name;
575
- if (message !== undefined)
576
- error.message = message;
577
- if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
578
- try {
579
- Object.defineProperty(error, Symbol.toStringTag, {
580
- value: name,
581
- writable: false,
582
- enumerable: false,
583
- configurable: true
584
- });
585
- }
586
- catch (_) {
587
- }
588
- }
589
- if (typeof Error.captureStackTrace === 'function') {
590
- Error.captureStackTrace(error, CustomError);
591
- }
592
- else if (Base.captureStackTrace && typeof Base.captureStackTrace === 'function') {
593
- Base.captureStackTrace(error, CustomError);
594
- }
595
- else {
596
- try {
597
- var tempError = new Base();
598
- if (tempError.stack)
599
- error.stack = tempError.stack;
600
- }
601
- catch (_) {
602
- }
603
- }
604
- return error;
605
- }
606
- CustomError.prototype = Object.create(Base.prototype, {
607
- constructor: {
608
- value: CustomError,
609
- writable: true,
610
- enumerable: false,
611
- configurable: true
612
- }
613
- });
614
- try {
615
- Object.defineProperty(CustomError.prototype, 'name', {
616
- value: name,
617
- writable: true,
618
- enumerable: false,
619
- configurable: true
620
- });
621
- }
622
- catch (_) {
623
- try {
624
- CustomError.prototype.name = name;
625
- }
626
- catch (_) {
627
- }
628
- }
629
- try {
630
- Object.defineProperty(CustomError, 'name', {
631
- value: name,
632
- writable: false,
633
- enumerable: false,
634
- configurable: true
635
- });
636
- }
637
- catch (_) {
638
- }
639
- return CustomError;
640
- }
641
-
642
- var EasingError = createCustomError('EasingError');
643
- var CubicBezierSyntaxError = createCustomError('CubicBezierSyntaxError', EasingError);
644
- var LinearSyntaxError = createCustomError('LinearSyntaxError', EasingError);
645
- var StepSyntaxError = createCustomError('StepSyntaxError', EasingError);
646
- var UnsupportedEasingFunctionError = createCustomError('UnsupportedEasingFunctionError', EasingError);
647
-
648
- var EASING_KEYWORD = {
649
- 'linear': 'linear(0, 1)',
650
- 'ease': 'cubic-bezier(0.25, 0.1, 0.25, 1)',
651
- 'ease-in': 'cubic-bezier(0.42, 0, 1, 1)',
652
- 'ease-out': 'cubic-bezier(0, 0, 0.58, 1)',
653
- 'ease-in-out': 'cubic-bezier(0.42, 0, 0.58, 1)',
654
- 'step-start': 'steps(1, jump-start)',
655
- 'step-end': 'steps(1, jump-end)',
656
- };
657
- function clamp(n, min, max) {
658
- if (n < min)
659
- return min;
660
- if (n > max)
661
- return max;
662
- return n;
663
- }
664
- function isEasingKeyword(easingFunction) {
665
- return !/(linear|cubic-bezier|steps)\((.*)\)/.test(easingFunction);
666
- }
667
- function isCubicBezierString(easingFunction) {
668
- return /cubic-bezier\(/.test(easingFunction);
669
- }
670
- function isLinearString(easingFunction) {
671
- return /linear\(/.test(easingFunction);
672
- }
673
- function isStepString(easingFunction) {
674
- return /steps\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end)\s*)?\)$/.test(easingFunction);
675
- }
676
- function parseCubicBezier(easingFunction) {
677
- var match = easingFunction.match(/cubic-bezier\((.*)\)/);
678
- if (match === null)
679
- throw new CubicBezierSyntaxError('Invalid cubic-bezier syntax');
680
- var content = match[1].trim();
681
- var split = content.split(',');
682
- var values = [];
683
- if (split.length !== 4)
684
- throw new CubicBezierSyntaxError('Cubic-bezier must have exactly 4 numeric values');
685
- for (var i = 0; i < 4; i++) {
686
- var value = parseFloat(split[i]);
687
- if (isNaN(value))
688
- throw new CubicBezierSyntaxError('Cubic-bezier must have exactly 4 numeric values');
689
- if (i % 2 === 0 && (value < 0 || value > 1))
690
- throw new CubicBezierSyntaxError('x1 and x2 must be between 0 and 1');
691
- values.push(value);
692
- }
693
- return {
694
- x1: values[0],
695
- y1: values[1],
696
- x2: values[2],
697
- y2: values[3]
698
- };
699
- }
700
- function getCubicBezierValue(easingFunction) {
701
- var cubicBezier = parseCubicBezier(easingFunction);
702
- var x1 = cubicBezier.x1;
703
- var x2 = cubicBezier.x2;
704
- var y1 = cubicBezier.y1;
705
- var y2 = cubicBezier.y2;
706
- function findT(x, tolerance, maxIterations) {
707
- if (tolerance === void 0) { tolerance = 1e-6; }
708
- if (maxIterations === void 0) { maxIterations = 50; }
709
- if (x <= 0)
710
- return 0;
711
- if (x >= 1)
712
- return 1;
713
- var t = x;
714
- for (var i = 0; i < maxIterations; i++) {
715
- var xt = 3 * (1 - t) * (1 - t) * t * x1 + 3 * (1 - t) * t * t * x2 + t * t * t;
716
- var dx = 3 * (1 - t) * (1 - t) * x1 + 6 * (1 - t) * t * (x2 - x1) + 3 * t * t * (1 - x2);
717
- if (Math.abs(dx) < tolerance)
718
- break;
719
- var newT = t - (xt - x) / dx;
720
- if (Math.abs(newT - t) < tolerance) {
721
- t = newT;
722
- break;
723
- }
724
- t = Math.max(0, Math.min(1, newT));
725
- }
726
- return t;
727
- }
728
- return function (x) {
729
- x = clamp(x, 0, 1);
730
- if (x === 0 || x === 1)
731
- return x;
732
- var t = findT(x);
733
- return 3 * (1 - t) * (1 - t) * t * y1 + 3 * (1 - t) * t * t * y2 + t * t * t;
734
- };
735
- }
736
- function parseLinear(easingFunction) {
737
- var e_1, _a;
738
- var match = easingFunction.match(/linear\((.*)\)/);
739
- if (match === null)
740
- throw new LinearSyntaxError('Invalid linear syntax');
741
- var content = match[1].trim();
742
- if (content === '')
743
- throw new LinearSyntaxError('Linear function must have at least one point');
744
- var split = content.split(',');
745
- var points = [];
746
- for (var i = 0; i < split.length; i++) {
747
- var part = split[i].trim();
748
- var percentage2 = part.match(/^([+-]?\d*\.?\d+)((?:\s+[+-]?\d*\.?\d+%){2,})$/);
749
- if (percentage2 !== null) {
750
- var value = parseFloat(percentage2[1]);
751
- var percents = percentage2[2].trim().split(/\s+/);
752
- try {
753
- for (var percents_1 = (e_1 = void 0, __values(percents)), percents_1_1 = percents_1.next(); !percents_1_1.done; percents_1_1 = percents_1.next()) {
754
- var percent = percents_1_1.value;
755
- points.push({
756
- value: value,
757
- position: parseFloat(percent) / 100,
758
- });
759
- }
760
- }
761
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
762
- finally {
763
- try {
764
- if (percents_1_1 && !percents_1_1.done && (_a = percents_1.return)) _a.call(percents_1);
765
- }
766
- finally { if (e_1) throw e_1.error; }
767
- }
768
- continue;
769
- }
770
- var percentage1 = part.match(/^([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)%$/);
771
- if (percentage1 !== null) {
772
- points.push({
773
- position: parseFloat(percentage1[2]) / 100,
774
- value: parseFloat(percentage1[1])
775
- });
776
- continue;
777
- }
778
- var number = part.match(/^([+-]?\d*\.?\d+)$/);
779
- if (number !== null) {
780
- points.push({
781
- position: split.length === 1 ? 0 : i / (split.length - 1),
782
- value: parseFloat(number[1])
783
- });
784
- continue;
785
- }
786
- throw new LinearSyntaxError('Invalid linear point format: \"' + part + '\"');
787
- }
788
- if (points.length === 0)
789
- throw new LinearSyntaxError('No valid points found in linear function');
790
- points.sort(function (a, b) { return a.position - b.position; });
791
- if (points[0].position > 0)
792
- points.unshift({ position: 0, value: 0 });
793
- if (points[points.length - 1].position < 1)
794
- points.push({ position: 1, value: 1 });
795
- return points;
796
- }
797
- function getLinearValue(string) {
798
- var points = parseLinear(string);
799
- return function (t) {
800
- t = clamp(t, 0, 1);
801
- if (t <= points[0].position)
802
- return points[0].value;
803
- if (t >= points[points.length - 1].position)
804
- return points[points.length - 1].value;
805
- for (var i = 0; i < points.length - 1; i++) {
806
- var p1 = points[i];
807
- var p2 = points[i + 1];
808
- if (t >= p1.position && t <= p2.position) {
809
- if (p1.position === p2.position)
810
- return p2.value;
811
- var ratio = (t - p1.position) / (p2.position - p1.position);
812
- return p1.value + (p2.value - p1.value) * ratio;
813
- }
814
- }
815
- return points[points.length - 1].value;
816
- };
817
- }
818
- function getStepValue(easingFunction) {
819
- var match = easingFunction.match(/steps\(\s*(\d+)\s*(?:,\s*(jump-start|jump-end|jump-none|jump-both|start|end)\s*)?\)$/);
820
- if (match === null)
821
- throw new StepSyntaxError('Invalid steps syntax');
822
- var count = parseInt(match[1], 10);
823
- var position = match[2];
824
- if (count <= 0)
825
- throw new StepSyntaxError('Steps count must be a positive integer');
826
- if (position === 'jump-none' && count < 2)
827
- throw new StepSyntaxError('jump-none requires at least 2 steps');
828
- return function (t) {
829
- t = clamp(t, 0, 1);
830
- switch (position) {
831
- case 'start':
832
- case 'jump-start':
833
- if (t === 0)
834
- return 1 / count;
835
- if (t === 1)
836
- return 1;
837
- return Math.ceil(t * count) / count;
838
- case undefined:
839
- case 'end':
840
- case 'jump-end':
841
- if (t === 1)
842
- return 1;
843
- return Math.floor(t * count) / count;
844
- case 'jump-both':
845
- if (t === 0)
846
- return 0;
847
- if (t === 1)
848
- return 1;
849
- return Math.round(t * (count + 1)) / (count + 1);
850
- case 'jump-none':
851
- if (t === 0)
852
- return 0;
853
- if (t === 1)
854
- return 1;
855
- return Math.floor(t * (count - 1)) / (count - 1);
856
- default:
857
- throw new StepSyntaxError('Unsupported step position: \"' + position + '\"');
858
- }
859
- };
860
- }
861
- function parseEasingFunction(easingFunction) {
862
- if (isEasingKeyword(easingFunction))
863
- easingFunction = EASING_KEYWORD[easingFunction];
864
- if (isCubicBezierString(easingFunction))
865
- return getCubicBezierValue(easingFunction);
866
- if (isLinearString(easingFunction))
867
- return getLinearValue(easingFunction);
868
- if (isStepString(easingFunction))
869
- return getStepValue(easingFunction);
870
- throw new UnsupportedEasingFunctionError('Unsupported easing function: \"' + easingFunction + '\"');
871
- }
872
-
873
- var UnsupportedColorError = createCustomError('UnsupportedColorError');
874
-
875
- function createHiddenElement(tagName, focusable) {
876
- if (focusable === void 0) { focusable = true; }
877
- if (typeof globalThis.document === 'undefined')
878
- return undefined;
879
- var element = globalThis.document.createElement(tagName);
880
- if ('width' in element)
881
- element.width = '0';
882
- if ('height' in element)
883
- element.height = '0';
884
- if ('border' in element)
885
- element.border = '0';
886
- if ('frameBorder' in element)
887
- element.frameBorder = '0';
888
- if ('scrolling' in element)
889
- element.scrolling = 'no';
890
- if ('cellPadding' in element)
891
- element.cellPadding = '0';
892
- if ('cellSpacing' in element)
893
- element.cellSpacing = '0';
894
- if ('frame' in element)
895
- element.frame = 'void';
896
- if ('rules' in element)
897
- element.rules = 'none';
898
- if ('noWrap' in element)
899
- element.noWrap = true;
900
- element.tabIndex = -1;
901
- element.setAttribute('role', 'presentation');
902
- if (focusable) {
903
- element.style.width = '1px';
904
- element.style.height = '1px';
905
- }
906
- else {
907
- element.setAttribute('aria-hidden', 'true');
908
- element.style.width = '0';
909
- element.style.height = '0';
910
- element.style.zIndex = '-9999';
911
- element.style.display = 'none';
912
- element.style.visibility = 'hidden';
913
- element.style.pointerEvents = 'none';
914
- }
915
- element.style.position = 'absolute';
916
- element.style.top = '0';
917
- element.style.left = '0';
918
- element.style.padding = '0';
919
- element.style.margin = '0';
920
- element.style.border = 'none';
921
- element.style.outline = 'none';
922
- element.style.clip = 'rect(1px, 1px, 1px, 1px)';
923
- element.style.clipPath = 'inset(50%)';
924
- element.style.overflow = 'hidden';
925
- element.style.whiteSpace = 'nowrap';
926
- return element;
927
- }
928
-
929
- function parseColor(color) {
930
- if (typeof CSS !== 'undefined' && CSS.supports && !CSS.supports('color', color))
931
- throw new UnsupportedColorError('Unsupported color: \"' + color + '\".');
932
- if (CONTEXT !== null) {
933
- try {
934
- CONTEXT.clearRect(0, 0, 1, 1);
935
- CONTEXT.fillStyle = color;
936
- CONTEXT.fillRect(0, 0, 1, 1);
937
- var data = CONTEXT.getImageData(0, 0, 1, 1).data;
938
- return {
939
- red: data[0],
940
- green: data[1],
941
- blue: data[2],
942
- alpha: parseFloat((data[3] / 255).toFixed(2))
943
- };
944
- }
945
- catch (_) {
946
- }
947
- }
948
- var div = createHiddenElement('div');
949
- if (div === undefined)
950
- throw new UnsupportedColorError('Failed to parse color values from: \"' + color + '\".');
951
- div.style.color = color;
952
- globalThis.document.body.appendChild(div);
953
- try {
954
- var computedColor = globalThis.getComputedStyle(div).color;
955
- var legacyMatch = computedColor.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);
956
- var modernMatch = computedColor.match(/rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)\s*(?:\/\s*([\d.]+%?))?\s*\)/);
957
- var matched = legacyMatch || modernMatch;
958
- if (matched === null)
959
- throw new UnsupportedColorError('Unsupported color: \"' + color + '\".');
960
- var red = parseInt(matched[1], 10);
961
- var green = parseInt(matched[2], 10);
962
- var blue = parseInt(matched[3], 10);
963
- var alpha = 1;
964
- if (matched[4] !== undefined) {
965
- var alphaString = matched[4];
966
- if (alphaString.charAt(alphaString.length - 1) === '%')
967
- alpha = parseFloat((parseFloat(alphaString) / 100).toFixed(2));
968
- else
969
- alpha = parseFloat(parseFloat(alphaString).toFixed(2));
970
- }
971
- if (isNaN(red) || isNaN(green) || isNaN(blue) || isNaN(alpha))
972
- throw new UnsupportedColorError('Failed to parse color values from: \"' + color + '\".');
973
- return {
974
- red: red,
975
- green: green,
976
- blue: blue,
977
- alpha: alpha
978
- };
979
- }
980
- finally {
981
- globalThis.document.body.removeChild(div);
982
- }
983
- }
984
-
985
- var themeColorMetaGroup = {};
986
- var themeIntervalId = null;
987
- var currentResolve = null;
988
- var currentAppearance = null;
989
- var appearanceIntervalId = null;
990
- var Index = {
991
- setAppearance: setAppearance,
992
- getAppearance: getAppearance,
993
- removeThemeColor: removeThemeColor,
994
- setThemeColor: setThemeColor,
995
- getThemeColor: getThemeColor,
996
- onAppearanceChange: onAppearanceChange,
525
+ setThemeColor(color);
526
+ },
997
527
  };
998
- function getThemeColorMeta(appearance) {
999
- if (appearance === void 0) { appearance = 'default'; }
1000
- var effective;
1001
- if (!IS_FULL_SUPPORT_THEME_COLOR || !SUPPORT_PREFERS_COLOR_SCHEME || IS_IE_MOBILE || IS_WINDOWS_PHONE)
1002
- effective = 'default';
1003
- else
1004
- effective = appearance;
1005
- var meta = themeColorMetaGroup[effective];
1006
- if (meta !== undefined)
1007
- return meta;
1008
- meta = globalThis.document.createElement('meta');
528
+ function getMetaName() {
1009
529
  if (IS_IE_MOBILE)
1010
- meta.setAttribute('name', 'msapplication-navbutton-color');
1011
- else if (IS_WINDOWS_PHONE)
1012
- meta.setAttribute('name', 'msapplication-TileColor');
1013
- else
1014
- meta.setAttribute('name', 'theme-color');
1015
- if (appearance !== 'default')
1016
- meta.setAttribute('media', '(prefers-color-scheme: ' + effective + ')');
1017
- globalThis.document.head.prepend(meta);
1018
- return themeColorMetaGroup[appearance] = meta;
1019
- }
1020
- function estimateDefaultThemeColor() {
1021
- if (Platform.browser === Browsers.Safari) {
1022
- if (Platform.isStandalone) {
1023
- if (detectFromMediaQuery() === Appearances.Dark)
1024
- return '#ffffffff';
1025
- else
1026
- return '#000000ff';
1027
- }
1028
- return rgbaToHex(parseColor(globalThis.getComputedStyle(globalThis.document.body).backgroundColor));
1029
- }
1030
- if (Platform.browser === Browsers.Chrome) {
1031
- if (detectFromMediaQuery() === Appearances.Dark)
1032
- return '#28292cff';
1033
- else
1034
- return '#ffffffff';
1035
- }
1036
- return undefined;
1037
- }
1038
- function toHex(n) {
1039
- var hex = n.toString(16);
1040
- switch (hex.length) {
1041
- case 0:
1042
- return '00';
1043
- case 1:
1044
- return '0' + hex;
1045
- default:
1046
- return hex;
1047
- }
1048
- }
1049
- function rgbaToHex(rgba) {
1050
- return '#'
1051
- + toHex(rgba.red)
1052
- + toHex(rgba.green)
1053
- + toHex(rgba.blue)
1054
- + toHex(Math.round(rgba.alpha * 255));
1055
- }
1056
- function setThemeColorReactNative(appearance) {
1057
- try {
1058
- var reactNative = require('react-native');
1059
- reactNative.Appearance.setColorScheme(appearance);
1060
- }
1061
- catch (_) {
1062
- }
1063
- }
1064
- function setThemeColorElectron(appearance) {
1065
- try {
1066
- var electron = require('electron');
1067
- electron.nativeTheme.themeSource = appearance || 'system';
1068
- }
1069
- catch (_) {
1070
- }
1071
- }
1072
- function detectFromReactNative() {
1073
- return new Promise(function (resolve) {
1074
- try {
1075
- var reactNative = require('react-native');
1076
- resolve(reactNative.Appearance.getColorScheme() || Appearances.Unknown);
1077
- }
1078
- catch (_) {
1079
- resolve(Appearances.Unknown);
1080
- }
1081
- });
1082
- }
1083
- function detectFromElectron() {
1084
- return new Promise(function (resolve) {
1085
- try {
1086
- var electron = require('electron');
1087
- resolve(electron.nativeTheme.shouldUseDarkColors ? Appearances.Dark : Appearances.Light);
1088
- }
1089
- catch (_) {
1090
- resolve(Appearances.Unknown);
1091
- }
1092
- });
1093
- }
1094
- function detectFromEngine() {
1095
- return new Promise(function (resolve) {
1096
- var img = new Image();
1097
- img.onload = function () {
1098
- if (CONTEXT === null)
1099
- return resolve(Appearances.Light);
1100
- CONTEXT.drawImage(img, 0, 0);
1101
- var data = CONTEXT.getImageData(0, 0, 1, 1).data;
1102
- if ((data[0] & data[1] & data[2]) < 255)
1103
- resolve(Appearances.Dark);
1104
- else
1105
- resolve(Appearances.Light);
1106
- };
1107
- img.onerror = function () {
1108
- resolve(Appearances.Unknown);
1109
- };
1110
- img.src = SVG_PIXEL_DATA_URL;
1111
- });
1112
- }
1113
- function detectFromMediaQuery() {
1114
- if (!SUPPORT_PREFERS_COLOR_SCHEME)
1115
- return Appearances.Unknown;
1116
- if (MEDIA_QUERY_LIST.matches)
1117
- return Appearances.Dark;
1118
- return Appearances.Light;
1119
- }
1120
- function startPolling() {
1121
- detectFromEngine()
1122
- .then(function (appearance) {
1123
- currentAppearance = appearance;
1124
- });
1125
- appearanceIntervalId = globalThis.setInterval(function () {
1126
- detectFromEngine()
1127
- .then(function (appearance) {
1128
- if (appearance !== currentAppearance) {
1129
- currentAppearance = appearance;
1130
- notify(appearance);
1131
- }
1132
- });
1133
- }, 2000);
1134
- }
1135
- function stopPolling() {
1136
- currentAppearance = null;
1137
- if (appearanceIntervalId !== null) {
1138
- clearInterval(appearanceIntervalId);
1139
- appearanceIntervalId = null;
1140
- }
1141
- }
1142
- function addListener(capture) {
1143
- currentAppearance = detectFromMediaQuery();
1144
- if (typeof MEDIA_QUERY_LIST.addEventListener === 'function')
1145
- MEDIA_QUERY_LIST.addEventListener('change', onMediaChange, capture);
1146
- else if (typeof MEDIA_QUERY_LIST.addListener === 'function')
1147
- MEDIA_QUERY_LIST.addListener(onMediaChange);
1148
- }
1149
- function removeListener(capture) {
1150
- currentAppearance = null;
1151
- if (typeof MEDIA_QUERY_LIST.removeEventListener === 'function')
1152
- MEDIA_QUERY_LIST.removeEventListener('change', onMediaChange, capture);
1153
- else if (typeof MEDIA_QUERY_LIST.removeListener === 'function')
1154
- MEDIA_QUERY_LIST.removeListener(onMediaChange);
1155
- }
1156
- function onMediaChange(ev) {
1157
- var appearance;
1158
- if (ev.matches)
1159
- appearance = Appearances.Dark;
1160
- else
1161
- appearance = Appearances.Light;
1162
- if (appearance !== currentAppearance)
1163
- notify(currentAppearance = appearance);
1164
- }
1165
- function notify(appearance) {
1166
- for (var i = 0; i < ENTRIES.length; i++) {
1167
- var entry = ENTRIES[i];
1168
- entry.fn(appearance);
1169
- if (entry.once)
1170
- removeEntry(entry);
1171
- }
1172
- }
1173
- function removeEntry(entry) {
1174
- var index = indexOfEntry(entry);
1175
- if (index !== -1)
1176
- ENTRIES.splice(index, 1);
1177
- if (ENTRIES.length === 0) {
1178
- if (Platform.browser === Browsers.SamsungInternet)
1179
- stopPolling();
1180
- else
1181
- removeListener(entry.capture);
1182
- }
1183
- }
1184
- function indexOfEntry(entry) {
1185
- for (var i = 0; i < ENTRIES.length; i++)
1186
- if (ENTRIES[i].fn === entry.fn && ENTRIES[i].capture === entry.capture)
1187
- return i;
1188
- return -1;
1189
- }
1190
- function syncThemeColorMeta() {
1191
- themeColorMetaGroup = {};
1192
- var selector;
1193
- if (IS_IE_MOBILE)
1194
- selector = 'meta[name=\"msapplication-navbutton-color\"]';
1195
- else if (IS_WINDOWS_PHONE)
1196
- selector = 'meta[name=\"msapplication-TileColor\"]';
1197
- else
1198
- selector = 'meta[name=\"theme-color\"]';
1199
- var nodes = globalThis.document.querySelectorAll(selector);
1200
- if (!IS_FULL_SUPPORT_THEME_COLOR || !SUPPORT_PREFERS_COLOR_SCHEME || IS_IE_MOBILE || IS_WINDOWS_PHONE) {
1201
- themeColorMetaGroup.default = nodes[0];
1202
- return;
1203
- }
1204
- for (var i = 0; i < nodes.length; i++) {
1205
- var element = nodes.item(i);
1206
- var media = element.getAttribute('media');
1207
- if (media === '(prefers-color-scheme: dark)' && themeColorMetaGroup.dark === undefined)
1208
- themeColorMetaGroup.dark = element;
1209
- else if (media === '(prefers-color-scheme: light)' && themeColorMetaGroup.light === undefined)
1210
- themeColorMetaGroup.light = element;
1211
- else if (media === null && themeColorMetaGroup.default === undefined)
1212
- themeColorMetaGroup.default = element;
1213
- if (themeColorMetaGroup.dark !== undefined && themeColorMetaGroup.light !== undefined && themeColorMetaGroup.default !== undefined)
1214
- return;
1215
- }
1216
- }
1217
- function getCurrentAppliedThemeColorMeta() {
1218
- if (IS_IE_MOBILE)
1219
- return globalThis.document.querySelector('meta[name=\"msapplication-navbutton-color\"]');
530
+ return 'msapplication-navbutton-color';
1220
531
  if (IS_WINDOWS_PHONE)
1221
- return globalThis.document.querySelector('meta[name=\"msapplication-TileColor\"]');
1222
- if (!IS_FULL_SUPPORT_THEME_COLOR || !SUPPORT_PREFERS_COLOR_SCHEME)
1223
- return globalThis.document.querySelector('meta[name=\"theme-color\"]');
1224
- var nodes = globalThis.document.querySelectorAll('meta[name=\"theme-color\"]');
1225
- var isDark = detectFromMediaQuery() === Appearances.Dark;
1226
- var query;
1227
- if (isDark)
1228
- query = '(prefers-color-scheme: dark)';
1229
- else
1230
- query = '(prefers-color-scheme: light)';
1231
- for (var i = 0; i < nodes.length; i++) {
1232
- var element = nodes.item(i);
1233
- if (!element.hasAttribute('content'))
1234
- continue;
1235
- var media = element.getAttribute('media');
1236
- if (media === null || media === query)
1237
- return element;
1238
- }
1239
- return null;
532
+ return 'msapplication-TileColor';
533
+ return 'theme-color';
1240
534
  }
1241
- function init() {
1242
- if (typeof globalThis.MutationObserver !== 'undefined') {
1243
- var observer = new MutationObserver(function (mutations) {
1244
- for (var i = 0; i < mutations.length; i++) {
1245
- var mutation = mutations[i];
1246
- var addedNodes = mutation.addedNodes;
1247
- var removedNodes = mutation.removedNodes;
1248
- for (var j = 0; j < addedNodes.length; j++)
1249
- if (addedNodes[j] instanceof HTMLMetaElement)
1250
- return syncThemeColorMeta();
1251
- for (var j = 0; j < removedNodes.length; j++)
1252
- if (removedNodes[j] instanceof HTMLMetaElement)
1253
- return syncThemeColorMeta();
1254
- }
1255
- });
1256
- if (typeof MEDIA_QUERY_LIST.addEventListener === 'function')
1257
- MEDIA_QUERY_LIST.addEventListener('change', syncThemeColorMeta);
1258
- else if (typeof MEDIA_QUERY_LIST.addListener === 'function')
1259
- MEDIA_QUERY_LIST.addListener(syncThemeColorMeta);
1260
- observer.observe(globalThis.document.head, { childList: true });
1261
- syncThemeColorMeta();
1262
- }
535
+ function getMeta() {
536
+ if (metaElement !== null && metaElement.isConnected)
537
+ return metaElement;
538
+ return metaElement = globalThis.document.querySelector("meta[name=\"" + getMetaName() + "\"]");
1263
539
  }
1264
- init();
1265
- function setThemeColor(color, options) {
1266
- if (options === void 0) { options = { duration: 0, easingFunction: 'linear', appearance: 'default' }; }
1267
- var duration = options.duration;
1268
- var easingFn = parseEasingFunction(options.easingFunction);
1269
- var appearance = options.appearance;
1270
- if (themeIntervalId !== null) {
1271
- globalThis.cancelAnimationFrame(themeIntervalId);
1272
- themeIntervalId = null;
1273
- if (currentResolve !== null) {
1274
- currentResolve(getThemeColor());
1275
- currentResolve = null;
1276
- }
1277
- }
1278
- var themeColor = getThemeColor();
1279
- if (themeColor === undefined) {
1280
- if (options.defaultColor !== undefined) {
1281
- themeColor = options.defaultColor;
1282
- }
1283
- else {
1284
- if (detectFromMediaQuery() === Appearances.Dark)
1285
- themeColor = '#181818ff';
1286
- else
1287
- themeColor = '#dcdcdcff';
1288
- }
1289
- }
1290
- var startColor = parseColor(themeColor);
1291
- var endColor = parseColor(color);
1292
- return new Promise(function (resolve) {
1293
- currentResolve = resolve;
1294
- var startTime = null;
1295
- function animate(timestamp) {
1296
- if (startTime === null)
1297
- startTime = timestamp;
1298
- var elapsed = timestamp - startTime;
1299
- var t;
1300
- if (duration === 0)
1301
- t = 1;
1302
- else
1303
- t = Math.min(elapsed / duration, 1);
1304
- var easedT = easingFn(t);
1305
- var current = {
1306
- red: Math.round(startColor.red + (endColor.red - startColor.red) * easedT),
1307
- green: Math.round(startColor.green + (endColor.green - startColor.green) * easedT),
1308
- blue: Math.round(startColor.blue + (endColor.blue - startColor.blue) * easedT),
1309
- alpha: +(startColor.alpha + (endColor.alpha - startColor.alpha) * easedT).toFixed(2),
1310
- };
1311
- getThemeColorMeta(appearance).setAttribute('content', rgbaToHex(current));
1312
- if (t < 1) {
1313
- themeIntervalId = globalThis.requestAnimationFrame(animate);
1314
- }
1315
- else {
1316
- themeIntervalId = null;
1317
- if (currentResolve !== null) {
1318
- resolve(getThemeColor());
1319
- themeIntervalId = null;
1320
- }
1321
- }
1322
- }
1323
- themeIntervalId = globalThis.requestAnimationFrame(animate);
1324
- });
540
+ function createMeta() {
541
+ var meta = globalThis.document.createElement('meta');
542
+ meta.setAttribute('name', getMetaName());
543
+ globalThis.document.head.prepend(meta);
544
+ return metaElement = meta;
545
+ }
546
+ function setThemeColor(color) {
547
+ var meta = getMeta();
548
+ if (meta === null)
549
+ meta = createMeta();
550
+ meta.setAttribute('content', color);
1325
551
  }
1326
552
  function getThemeColor() {
1327
- if (IS_REACT_NATIVE || IS_ELECTRON)
553
+ var meta = getMeta();
554
+ if (!meta)
1328
555
  return undefined;
1329
- var meta = getCurrentAppliedThemeColorMeta();
1330
- if (meta !== null)
1331
- return meta.getAttribute('content');
1332
- return estimateDefaultThemeColor();
556
+ return meta.getAttribute('content') || undefined;
1333
557
  }
1334
- function removeThemeColor(appearance) {
1335
- if (appearance === void 0) { appearance = 'default'; }
1336
- var meta = themeColorMetaGroup[appearance];
1337
- if (meta !== undefined)
558
+ function removeThemeColor() {
559
+ var meta = getMeta();
560
+ if (meta) {
1338
561
  meta.remove();
1339
- themeColorMetaGroup[appearance] = undefined;
1340
- }
1341
- function setAppearance(appearance) {
1342
- if (IS_REACT_NATIVE)
1343
- return setThemeColorReactNative(appearance);
1344
- else if (IS_ELECTRON)
1345
- return setThemeColorElectron(appearance);
1346
- }
1347
- function getAppearance() {
1348
- if (IS_REACT_NATIVE)
1349
- return detectFromReactNative();
1350
- else if (IS_ELECTRON)
1351
- return detectFromElectron();
1352
- else if (Platform.browser === Browsers.SamsungInternet)
1353
- return detectFromEngine();
1354
- else
1355
- return Promise.resolve(detectFromMediaQuery());
1356
- }
1357
- function onAppearanceChange(listener, options) {
1358
- if (options === void 0) { options = false; }
1359
- var entry = { fn: listener, capture: false, once: false };
1360
- if (typeof options === 'boolean')
1361
- options = { capture: options };
1362
- if (options.capture !== undefined)
1363
- entry.capture = options.capture;
1364
- if (options.once !== undefined)
1365
- entry.once = options.once;
1366
- if (options.signal !== undefined)
1367
- entry.signal = options.signal;
1368
- var index = indexOfEntry(entry);
1369
- if (index === -1) {
1370
- ENTRIES.push(entry);
1371
- if (ENTRIES.length === 1) {
1372
- if (Platform.browser === Browsers.SamsungInternet)
1373
- startPolling();
1374
- else
1375
- addListener(entry.capture);
1376
- }
1377
- this.getAppearance()
1378
- .then(notify);
1379
- }
1380
- else if (ENTRIES[index].once && !entry.once) {
1381
- ENTRIES[index].once = false;
562
+ metaElement = null;
1382
563
  }
1383
- if (entry.signal !== undefined) {
1384
- if (entry.signal.aborted) {
1385
- removeEntry(entry);
1386
- }
1387
- else {
1388
- entry.signal.addEventListener('abort', function onAbort() {
1389
- if (entry.signal !== undefined)
1390
- entry.signal.removeEventListener('abort', onAbort);
1391
- removeEntry(entry);
1392
- });
1393
- }
1394
- }
1395
- return function () {
1396
- removeEntry(entry);
1397
- };
1398
564
  }
1399
565
 
1400
566
  var NativeThemePlugin = {
1401
567
  installed: false,
1402
568
  name: 'Theme',
1403
- module: Index,
1404
- Constants: {
1405
- Appearances: Appearances
1406
- },
1407
- Errors: {
1408
- EasingError: EasingError,
1409
- UnsupportedEasingFunctionError: UnsupportedEasingFunctionError,
1410
- StepSyntaxError: StepSyntaxError,
1411
- LinearSyntaxError: LinearSyntaxError,
1412
- CubicBezierSyntaxError: CubicBezierSyntaxError,
1413
- UnsupportedColorError: UnsupportedColorError
1414
- }
569
+ module: Theme,
570
+ Constants: {},
571
+ Errors: {}
1415
572
  };
1416
573
 
1417
574
  return NativeThemePlugin;