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