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