native-fn 1.1.9 → 1.2.1

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 (222) hide show
  1. package/README.md +488 -146
  2. package/dist/index.d.ts +138 -119
  3. package/dist/native.cjs +661 -565
  4. package/dist/native.min.cjs +1 -1
  5. package/dist/native.min.mjs +1 -1
  6. package/dist/native.mjs +661 -565
  7. package/dist/native.umd.js +661 -565
  8. package/dist/native.umd.min.js +1 -1
  9. package/dist/plugin/appearance/index.cjs +8 -3
  10. package/dist/plugin/appearance/index.mjs +8 -3
  11. package/dist/plugin/appearance/src/errors/invalid-state-error.d.ts +2 -0
  12. package/dist/plugin/appearance/src/plugin/badge/types/badge.d.ts +1 -1
  13. package/dist/plugin/appearance/src/plugin/battery/types/battery.d.ts +1 -1
  14. package/dist/plugin/appearance/src/plugin/fullscreen/cores/index.d.ts +3 -3
  15. package/dist/plugin/appearance/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  16. package/dist/plugin/appearance/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  17. package/dist/plugin/appearance/src/plugin/open/types/open.d.ts +1 -1
  18. package/dist/plugin/appearance/src/plugin/permission/types/permission.d.ts +1 -0
  19. package/dist/plugin/appearance/src/plugin/pip/cores/index.d.ts +6 -6
  20. package/dist/plugin/appearance/src/plugin/pip/types/pip.d.ts +14 -5
  21. package/dist/plugin/appearance/src/plugin/vibration/types/vibration.d.ts +1 -1
  22. package/dist/plugin/appearance/src/types/subscription-manager.d.ts +1 -1
  23. package/dist/plugin/badge/index.cjs +2 -2
  24. package/dist/plugin/badge/index.d.ts +1 -1
  25. package/dist/plugin/badge/index.mjs +2 -2
  26. package/dist/plugin/badge/src/errors/invalid-state-error.d.ts +2 -0
  27. package/dist/plugin/badge/src/plugin/badge/types/badge.d.ts +1 -1
  28. package/dist/plugin/badge/src/plugin/battery/types/battery.d.ts +1 -1
  29. package/dist/plugin/badge/src/plugin/fullscreen/cores/index.d.ts +3 -3
  30. package/dist/plugin/badge/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  31. package/dist/plugin/badge/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  32. package/dist/plugin/badge/src/plugin/open/types/open.d.ts +1 -1
  33. package/dist/plugin/badge/src/plugin/permission/types/permission.d.ts +1 -0
  34. package/dist/plugin/badge/src/plugin/pip/cores/index.d.ts +6 -6
  35. package/dist/plugin/badge/src/plugin/pip/types/pip.d.ts +14 -5
  36. package/dist/plugin/badge/src/plugin/vibration/types/vibration.d.ts +1 -1
  37. package/dist/plugin/badge/src/types/subscription-manager.d.ts +1 -1
  38. package/dist/plugin/battery/index.cjs +3 -3
  39. package/dist/plugin/battery/index.d.ts +1 -1
  40. package/dist/plugin/battery/index.mjs +3 -3
  41. package/dist/plugin/battery/src/errors/invalid-state-error.d.ts +2 -0
  42. package/dist/plugin/battery/src/plugin/badge/types/badge.d.ts +1 -1
  43. package/dist/plugin/battery/src/plugin/battery/types/battery.d.ts +1 -1
  44. package/dist/plugin/battery/src/plugin/fullscreen/cores/index.d.ts +3 -3
  45. package/dist/plugin/battery/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  46. package/dist/plugin/battery/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  47. package/dist/plugin/battery/src/plugin/open/types/open.d.ts +1 -1
  48. package/dist/plugin/battery/src/plugin/permission/types/permission.d.ts +1 -0
  49. package/dist/plugin/battery/src/plugin/pip/cores/index.d.ts +6 -6
  50. package/dist/plugin/battery/src/plugin/pip/types/pip.d.ts +14 -5
  51. package/dist/plugin/battery/src/plugin/vibration/types/vibration.d.ts +1 -1
  52. package/dist/plugin/battery/src/types/subscription-manager.d.ts +1 -1
  53. package/dist/plugin/clipboard/src/errors/invalid-state-error.d.ts +2 -0
  54. package/dist/plugin/clipboard/src/plugin/badge/types/badge.d.ts +1 -1
  55. package/dist/plugin/clipboard/src/plugin/battery/types/battery.d.ts +1 -1
  56. package/dist/plugin/clipboard/src/plugin/fullscreen/cores/index.d.ts +3 -3
  57. package/dist/plugin/clipboard/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  58. package/dist/plugin/clipboard/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  59. package/dist/plugin/clipboard/src/plugin/open/types/open.d.ts +1 -1
  60. package/dist/plugin/clipboard/src/plugin/permission/types/permission.d.ts +1 -0
  61. package/dist/plugin/clipboard/src/plugin/pip/cores/index.d.ts +6 -6
  62. package/dist/plugin/clipboard/src/plugin/pip/types/pip.d.ts +14 -5
  63. package/dist/plugin/clipboard/src/plugin/vibration/types/vibration.d.ts +1 -1
  64. package/dist/plugin/clipboard/src/types/subscription-manager.d.ts +1 -1
  65. package/dist/plugin/dimension/src/errors/invalid-state-error.d.ts +2 -0
  66. package/dist/plugin/dimension/src/plugin/badge/types/badge.d.ts +1 -1
  67. package/dist/plugin/dimension/src/plugin/battery/types/battery.d.ts +1 -1
  68. package/dist/plugin/dimension/src/plugin/fullscreen/cores/index.d.ts +3 -3
  69. package/dist/plugin/dimension/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  70. package/dist/plugin/dimension/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  71. package/dist/plugin/dimension/src/plugin/open/types/open.d.ts +1 -1
  72. package/dist/plugin/dimension/src/plugin/permission/types/permission.d.ts +1 -0
  73. package/dist/plugin/dimension/src/plugin/pip/cores/index.d.ts +6 -6
  74. package/dist/plugin/dimension/src/plugin/pip/types/pip.d.ts +14 -5
  75. package/dist/plugin/dimension/src/plugin/vibration/types/vibration.d.ts +1 -1
  76. package/dist/plugin/dimension/src/types/subscription-manager.d.ts +1 -1
  77. package/dist/plugin/fullscreen/index.cjs +539 -266
  78. package/dist/plugin/fullscreen/index.d.ts +20 -10
  79. package/dist/plugin/fullscreen/index.mjs +539 -266
  80. package/dist/plugin/fullscreen/src/errors/invalid-state-error.d.ts +2 -0
  81. package/dist/plugin/fullscreen/src/plugin/badge/types/badge.d.ts +1 -1
  82. package/dist/plugin/fullscreen/src/plugin/battery/types/battery.d.ts +1 -1
  83. package/dist/plugin/fullscreen/src/plugin/fullscreen/cores/index.d.ts +3 -3
  84. package/dist/plugin/fullscreen/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  85. package/dist/plugin/fullscreen/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  86. package/dist/plugin/fullscreen/src/plugin/open/types/open.d.ts +1 -1
  87. package/dist/plugin/fullscreen/src/plugin/permission/types/permission.d.ts +1 -0
  88. package/dist/plugin/fullscreen/src/plugin/pip/cores/index.d.ts +6 -6
  89. package/dist/plugin/fullscreen/src/plugin/pip/types/pip.d.ts +14 -5
  90. package/dist/plugin/fullscreen/src/plugin/vibration/types/vibration.d.ts +1 -1
  91. package/dist/plugin/fullscreen/src/types/subscription-manager.d.ts +1 -1
  92. package/dist/plugin/geolocation/index.cjs +6 -0
  93. package/dist/plugin/geolocation/index.d.ts +1 -1
  94. package/dist/plugin/geolocation/index.mjs +6 -0
  95. package/dist/plugin/geolocation/src/errors/invalid-state-error.d.ts +2 -0
  96. package/dist/plugin/geolocation/src/plugin/badge/types/badge.d.ts +1 -1
  97. package/dist/plugin/geolocation/src/plugin/battery/types/battery.d.ts +1 -1
  98. package/dist/plugin/geolocation/src/plugin/fullscreen/cores/index.d.ts +3 -3
  99. package/dist/plugin/geolocation/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  100. package/dist/plugin/geolocation/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  101. package/dist/plugin/geolocation/src/plugin/open/types/open.d.ts +1 -1
  102. package/dist/plugin/geolocation/src/plugin/permission/types/permission.d.ts +1 -0
  103. package/dist/plugin/geolocation/src/plugin/pip/cores/index.d.ts +6 -6
  104. package/dist/plugin/geolocation/src/plugin/pip/types/pip.d.ts +14 -5
  105. package/dist/plugin/geolocation/src/plugin/vibration/types/vibration.d.ts +1 -1
  106. package/dist/plugin/geolocation/src/types/subscription-manager.d.ts +1 -1
  107. package/dist/plugin/notification/index.cjs +6 -0
  108. package/dist/plugin/notification/index.mjs +6 -0
  109. package/dist/plugin/notification/src/errors/invalid-state-error.d.ts +2 -0
  110. package/dist/plugin/notification/src/plugin/badge/types/badge.d.ts +1 -1
  111. package/dist/plugin/notification/src/plugin/battery/types/battery.d.ts +1 -1
  112. package/dist/plugin/notification/src/plugin/fullscreen/cores/index.d.ts +3 -3
  113. package/dist/plugin/notification/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  114. package/dist/plugin/notification/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  115. package/dist/plugin/notification/src/plugin/open/types/open.d.ts +1 -1
  116. package/dist/plugin/notification/src/plugin/permission/types/permission.d.ts +1 -0
  117. package/dist/plugin/notification/src/plugin/pip/cores/index.d.ts +6 -6
  118. package/dist/plugin/notification/src/plugin/pip/types/pip.d.ts +14 -5
  119. package/dist/plugin/notification/src/plugin/vibration/types/vibration.d.ts +1 -1
  120. package/dist/plugin/notification/src/types/subscription-manager.d.ts +1 -1
  121. package/dist/plugin/open/index.cjs +128 -123
  122. package/dist/plugin/open/index.d.ts +35 -35
  123. package/dist/plugin/open/index.mjs +128 -123
  124. package/dist/plugin/open/src/errors/invalid-state-error.d.ts +2 -0
  125. package/dist/plugin/open/src/plugin/badge/types/badge.d.ts +1 -1
  126. package/dist/plugin/open/src/plugin/battery/types/battery.d.ts +1 -1
  127. package/dist/plugin/open/src/plugin/fullscreen/cores/index.d.ts +3 -3
  128. package/dist/plugin/open/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  129. package/dist/plugin/open/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  130. package/dist/plugin/open/src/plugin/open/types/open.d.ts +1 -1
  131. package/dist/plugin/open/src/plugin/permission/types/permission.d.ts +1 -0
  132. package/dist/plugin/open/src/plugin/pip/cores/index.d.ts +6 -6
  133. package/dist/plugin/open/src/plugin/pip/types/pip.d.ts +14 -5
  134. package/dist/plugin/open/src/plugin/vibration/types/vibration.d.ts +1 -1
  135. package/dist/plugin/open/src/types/subscription-manager.d.ts +1 -1
  136. package/dist/plugin/permission/index.cjs +6 -0
  137. package/dist/plugin/permission/index.d.ts +1 -0
  138. package/dist/plugin/permission/index.mjs +6 -0
  139. package/dist/plugin/permission/src/errors/invalid-state-error.d.ts +2 -0
  140. package/dist/plugin/permission/src/plugin/badge/types/badge.d.ts +1 -1
  141. package/dist/plugin/permission/src/plugin/battery/types/battery.d.ts +1 -1
  142. package/dist/plugin/permission/src/plugin/fullscreen/cores/index.d.ts +3 -3
  143. package/dist/plugin/permission/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  144. package/dist/plugin/permission/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  145. package/dist/plugin/permission/src/plugin/open/types/open.d.ts +1 -1
  146. package/dist/plugin/permission/src/plugin/permission/types/permission.d.ts +1 -0
  147. package/dist/plugin/permission/src/plugin/pip/cores/index.d.ts +6 -6
  148. package/dist/plugin/permission/src/plugin/pip/types/pip.d.ts +14 -5
  149. package/dist/plugin/permission/src/plugin/vibration/types/vibration.d.ts +1 -1
  150. package/dist/plugin/permission/src/types/subscription-manager.d.ts +1 -1
  151. package/dist/plugin/pip/index.cjs +651 -268
  152. package/dist/plugin/pip/index.d.ts +22 -12
  153. package/dist/plugin/pip/index.mjs +651 -268
  154. package/dist/plugin/pip/src/errors/invalid-state-error.d.ts +2 -0
  155. package/dist/plugin/pip/src/plugin/badge/types/badge.d.ts +1 -1
  156. package/dist/plugin/pip/src/plugin/battery/types/battery.d.ts +1 -1
  157. package/dist/plugin/pip/src/plugin/fullscreen/cores/index.d.ts +3 -3
  158. package/dist/plugin/pip/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  159. package/dist/plugin/pip/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  160. package/dist/plugin/pip/src/plugin/open/types/open.d.ts +1 -1
  161. package/dist/plugin/pip/src/plugin/permission/types/permission.d.ts +1 -0
  162. package/dist/plugin/pip/src/plugin/pip/cores/index.d.ts +6 -6
  163. package/dist/plugin/pip/src/plugin/pip/types/pip.d.ts +14 -5
  164. package/dist/plugin/pip/src/plugin/vibration/types/vibration.d.ts +1 -1
  165. package/dist/plugin/pip/src/types/subscription-manager.d.ts +1 -1
  166. package/dist/plugin/platform/index.cjs +8 -3
  167. package/dist/plugin/platform/index.d.ts +5 -5
  168. package/dist/plugin/platform/index.mjs +8 -3
  169. package/dist/plugin/platform/src/errors/invalid-state-error.d.ts +2 -0
  170. package/dist/plugin/platform/src/plugin/badge/types/badge.d.ts +1 -1
  171. package/dist/plugin/platform/src/plugin/battery/types/battery.d.ts +1 -1
  172. package/dist/plugin/platform/src/plugin/fullscreen/cores/index.d.ts +3 -3
  173. package/dist/plugin/platform/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  174. package/dist/plugin/platform/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  175. package/dist/plugin/platform/src/plugin/open/types/open.d.ts +1 -1
  176. package/dist/plugin/platform/src/plugin/permission/types/permission.d.ts +1 -0
  177. package/dist/plugin/platform/src/plugin/pip/cores/index.d.ts +6 -6
  178. package/dist/plugin/platform/src/plugin/pip/types/pip.d.ts +14 -5
  179. package/dist/plugin/platform/src/plugin/vibration/types/vibration.d.ts +1 -1
  180. package/dist/plugin/platform/src/types/subscription-manager.d.ts +1 -1
  181. package/dist/plugin/theme/index.cjs +8 -3
  182. package/dist/plugin/theme/index.mjs +8 -3
  183. package/dist/plugin/theme/src/errors/invalid-state-error.d.ts +2 -0
  184. package/dist/plugin/theme/src/plugin/badge/types/badge.d.ts +1 -1
  185. package/dist/plugin/theme/src/plugin/battery/types/battery.d.ts +1 -1
  186. package/dist/plugin/theme/src/plugin/fullscreen/cores/index.d.ts +3 -3
  187. package/dist/plugin/theme/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  188. package/dist/plugin/theme/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  189. package/dist/plugin/theme/src/plugin/open/types/open.d.ts +1 -1
  190. package/dist/plugin/theme/src/plugin/permission/types/permission.d.ts +1 -0
  191. package/dist/plugin/theme/src/plugin/pip/cores/index.d.ts +6 -6
  192. package/dist/plugin/theme/src/plugin/pip/types/pip.d.ts +14 -5
  193. package/dist/plugin/theme/src/plugin/vibration/types/vibration.d.ts +1 -1
  194. package/dist/plugin/theme/src/types/subscription-manager.d.ts +1 -1
  195. package/dist/plugin/vibration/index.cjs +5 -5
  196. package/dist/plugin/vibration/index.d.ts +1 -1
  197. package/dist/plugin/vibration/index.mjs +5 -5
  198. package/dist/plugin/vibration/src/errors/invalid-state-error.d.ts +2 -0
  199. package/dist/plugin/vibration/src/plugin/badge/types/badge.d.ts +1 -1
  200. package/dist/plugin/vibration/src/plugin/battery/types/battery.d.ts +1 -1
  201. package/dist/plugin/vibration/src/plugin/fullscreen/cores/index.d.ts +3 -3
  202. package/dist/plugin/vibration/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  203. package/dist/plugin/vibration/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  204. package/dist/plugin/vibration/src/plugin/open/types/open.d.ts +1 -1
  205. package/dist/plugin/vibration/src/plugin/permission/types/permission.d.ts +1 -0
  206. package/dist/plugin/vibration/src/plugin/pip/cores/index.d.ts +6 -6
  207. package/dist/plugin/vibration/src/plugin/pip/types/pip.d.ts +14 -5
  208. package/dist/plugin/vibration/src/plugin/vibration/types/vibration.d.ts +1 -1
  209. package/dist/plugin/vibration/src/types/subscription-manager.d.ts +1 -1
  210. package/dist/src/errors/invalid-state-error.d.ts +2 -0
  211. package/dist/src/plugin/badge/types/badge.d.ts +1 -1
  212. package/dist/src/plugin/battery/types/battery.d.ts +1 -1
  213. package/dist/src/plugin/fullscreen/cores/index.d.ts +3 -3
  214. package/dist/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
  215. package/dist/src/plugin/geolocation/types/geolocation.d.ts +1 -1
  216. package/dist/src/plugin/open/types/open.d.ts +1 -1
  217. package/dist/src/plugin/permission/types/permission.d.ts +1 -0
  218. package/dist/src/plugin/pip/cores/index.d.ts +6 -6
  219. package/dist/src/plugin/pip/types/pip.d.ts +14 -5
  220. package/dist/src/plugin/vibration/types/vibration.d.ts +1 -1
  221. package/dist/src/types/subscription-manager.d.ts +1 -1
  222. package/package.json +21 -13
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Native = factory());
5
5
  })(this, (function () { 'use strict';
6
6
 
7
- var version = "1.1.9";
7
+ var version = "1.2.1";
8
8
  var packageJSON = {
9
9
  version: version};
10
10
 
@@ -693,10 +693,15 @@
693
693
  parsedFromHighEntropyValuesEngine.version = brandVersion;
694
694
  }
695
695
  if (typeof platformVersion === 'string') {
696
- if (getParsedCache().os.name === OS.Windows)
697
- parsedFromHighEntropyValuesOS.version = parseInt(platformVersion.split('.')[0], 10) >= 13 ? '11' : '10';
698
- else
696
+ if (getParsedCache().os.name === OS.Windows) {
697
+ if (parseInt(platformVersion.split('.')[0], 10) >= 13)
698
+ parsedFromHighEntropyValuesOS.version = '11';
699
+ else
700
+ parsedFromHighEntropyValuesOS.version = '10';
701
+ }
702
+ else {
699
703
  parsedFromHighEntropyValuesOS.version = platformVersion;
704
+ }
700
705
  }
701
706
  if (typeof platform === 'string') {
702
707
  if (/android/i.test(platform))
@@ -859,14 +864,14 @@
859
864
  };
860
865
  }
861
866
 
862
- var onChangeSubscriptionManager$3 = createSubscriptionManager(attachOnChange$3, detachOnChange$3);
867
+ var onChangeSubscriptionManager$5 = createSubscriptionManager(attachOnChange$5, detachOnChange$5);
863
868
  var appearanceRef = null;
864
869
  var pollingIntervalId = null;
865
870
  var Appearance = {
866
871
  get value() {
867
872
  return getAppearance();
868
873
  },
869
- onChange: onChangeSubscriptionManager$3.subscribe,
874
+ onChange: onChangeSubscriptionManager$5.subscribe,
870
875
  Constants: {
871
876
  Appearances: Appearances
872
877
  },
@@ -902,7 +907,7 @@
902
907
  var appearance = getAppearanceFromEngine();
903
908
  if (appearance !== appearanceRef) {
904
909
  appearanceRef = appearance;
905
- onChangeSubscriptionManager$3.emit(appearance);
910
+ onChangeSubscriptionManager$5.emit(appearance);
906
911
  }
907
912
  }, 2000);
908
913
  }
@@ -913,13 +918,13 @@
913
918
  pollingIntervalId = null;
914
919
  }
915
920
  }
916
- function attachOnChange$3() {
921
+ function attachOnChange$5() {
917
922
  appearanceRef = getAppearanceFromMediaQuery();
918
923
  EventListener.add(MEDIA_QUERY_LIST$1, { type: 'change', callback: onMediaChange });
919
924
  if (Platform.browser.name === Browsers.SamsungInternet)
920
925
  startPolling();
921
926
  }
922
- function detachOnChange$3() {
927
+ function detachOnChange$5() {
923
928
  appearanceRef = null;
924
929
  EventListener.remove(MEDIA_QUERY_LIST$1, { type: 'change', callback: onMediaChange });
925
930
  if (Platform.browser.name === Browsers.SamsungInternet)
@@ -932,7 +937,7 @@
932
937
  else
933
938
  appearance = Appearances.Light;
934
939
  if (appearance !== appearanceRef)
935
- onChangeSubscriptionManager$3.emit(appearanceRef = appearance);
940
+ onChangeSubscriptionManager$5.emit(appearanceRef = appearance);
936
941
  }
937
942
 
938
943
  function isSecureContext() {
@@ -1668,14 +1673,14 @@
1668
1673
  var keyboardInsetObserver = createEnvObserver('keyboard-inset');
1669
1674
  var titlebarAreaObserver = createEnvObserver('titlebar-area');
1670
1675
  var viewportSegmentObserver = createEnvObserver('viewport-segment');
1671
- var onChangeSubscriptionManager$2 = createSubscriptionManager(attachOnChange$2, detachOnChange$2);
1676
+ var onChangeSubscriptionManager$4 = createSubscriptionManager(attachOnChange$4, detachOnChange$4);
1672
1677
  var dimensionRef = null;
1673
1678
  var Dimension = {
1674
1679
  get value() {
1675
1680
  return getDimension();
1676
1681
  },
1677
1682
  environment: getEnvironment(),
1678
- onChange: onChangeSubscriptionManager$2.subscribe,
1683
+ onChange: onChangeSubscriptionManager$4.subscribe,
1679
1684
  Constants: {
1680
1685
  Orientation: Orientation,
1681
1686
  },
@@ -1761,7 +1766,7 @@
1761
1766
  }
1762
1767
  return FALLBACK_DIMENSION;
1763
1768
  }
1764
- function attachOnChange$2() {
1769
+ function attachOnChange$4() {
1765
1770
  dimensionRef = getDimension();
1766
1771
  EventListener.add(globalThis, { type: 'resize', callback: onResize });
1767
1772
  if (typeof globalThis.screen.orientation.addEventListener === 'function')
@@ -1771,7 +1776,7 @@
1771
1776
  else if (MEDIA_QUERY_LIST.media !== 'not all')
1772
1777
  EventListener.add(MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
1773
1778
  }
1774
- function detachOnChange$2() {
1779
+ function detachOnChange$4() {
1775
1780
  dimensionRef = null;
1776
1781
  EventListener.remove(globalThis, { type: 'resize', callback: onResize });
1777
1782
  if (typeof globalThis.screen.orientation.removeEventListener === 'function')
@@ -1784,7 +1789,7 @@
1784
1789
  function onResize() {
1785
1790
  var dimension = getDimension();
1786
1791
  if (dimensionRef === null || dimension.innerWidth !== dimensionRef.innerWidth || dimension.innerHeight !== dimensionRef.innerHeight || dimension.outerWidth !== dimensionRef.outerWidth || dimension.outerHeight !== dimensionRef.outerHeight || dimension.scale !== dimensionRef.scale || dimension.orientation !== dimensionRef.orientation)
1787
- onChangeSubscriptionManager$2.emit(dimensionRef = dimension);
1792
+ onChangeSubscriptionManager$4.emit(dimensionRef = dimension);
1788
1793
  }
1789
1794
 
1790
1795
  function createCustomError(name, Base) {
@@ -1871,7 +1876,20 @@
1871
1876
 
1872
1877
  var NotSupportedError = createCustomError('NotSupportedError');
1873
1878
 
1874
- var FS_BRIDGED_KEY = Symbol('fsBridged');
1879
+ var InvalidStateError = createCustomError('InvalidStateError');
1880
+
1881
+ var videoElement$1 = null;
1882
+ var lastFallbackVideoElement$1 = null;
1883
+ var eventsBridged$1 = false;
1884
+ var FS_BRIDGE_KEY = (function () {
1885
+ if (typeof Symbol === 'function') {
1886
+ var existing = globalThis.__nativeFnFsBridgeKey__;
1887
+ if (typeof existing === 'symbol')
1888
+ return existing;
1889
+ return globalThis.__nativeFnFsBridgeKey__ = Symbol('native.fn.fs.bridged');
1890
+ }
1891
+ return '__nativeFnFsBridged__';
1892
+ }());
1875
1893
  var API_VARIANTS = {
1876
1894
  standard: {
1877
1895
  enabled: 'fullscreenEnabled',
@@ -1903,6 +1921,40 @@
1903
1921
  },
1904
1922
  };
1905
1923
  var api = detectApi();
1924
+ var onChangeSubscriptionManager$3 = createSubscriptionManager(attachOnChange$3, detachOnChange$3);
1925
+ var onErrorSubscriptionManager$1 = createSubscriptionManager(attachOnError$1, detachOnError$1);
1926
+ var Fullscreen = {
1927
+ get supported() {
1928
+ return getSupported$1();
1929
+ },
1930
+ get element() {
1931
+ return getElement$1();
1932
+ },
1933
+ get isActive() {
1934
+ return getIsActive$1();
1935
+ },
1936
+ request: request$3,
1937
+ exit: exit$1,
1938
+ toggle: toggle$1,
1939
+ onChange: onChange$1,
1940
+ onError: onError$1,
1941
+ Constants: {},
1942
+ Errors: {
1943
+ NotSupportedError: NotSupportedError,
1944
+ InvalidStateError: InvalidStateError,
1945
+ },
1946
+ };
1947
+ function getHTMLVideoElement$1() {
1948
+ var selected = globalThis.document.querySelector('video');
1949
+ if (selected !== null)
1950
+ return selected;
1951
+ if (videoElement$1 === null)
1952
+ return videoElement$1 = globalThis.document.createElement('video');
1953
+ return videoElement$1;
1954
+ }
1955
+ function hasStandardApi$1() {
1956
+ return api !== null;
1957
+ }
1906
1958
  function detectApi() {
1907
1959
  var element = globalThis.document.documentElement;
1908
1960
  if (typeof globalThis.document.fullscreenEnabled !== 'undefined' || typeof globalThis.document.exitFullscreen !== 'undefined')
@@ -1919,287 +1971,306 @@
1919
1971
  }
1920
1972
  return null;
1921
1973
  }
1922
- function createFullscreen() {
1923
- var lastIOSVideo = null;
1924
- var eventsBridged = false;
1925
- var activeOperation = null;
1926
- var pendingQueue = [];
1927
- var lastIntendedOperation = 'exit';
1928
- var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
1929
- var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
1930
- function getDefaultTarget() {
1931
- if (Platform.os.name === OS.iOS) {
1932
- var video = globalThis.document.querySelector('video');
1933
- if (video === null)
1934
- return undefined;
1974
+ function getDefaultTarget$1() {
1975
+ if (Platform.os.name === OS.iOS) {
1976
+ var video = globalThis.document.querySelector('video');
1977
+ if (video !== null)
1935
1978
  return video;
1936
- }
1937
- return globalThis.document.documentElement;
1938
- }
1939
- function bridgeEvents() {
1940
- if (eventsBridged)
1941
- return;
1942
- eventsBridged = true;
1943
- if (Platform.os.name === OS.iOS) {
1944
- bridgeIOSVideoEvents();
1945
- if (typeof globalThis.MutationObserver !== 'undefined') {
1946
- var observer = new MutationObserver(function () {
1947
- bridgeIOSVideoEvents();
1948
- });
1949
- observer.observe(globalThis.document.documentElement, {
1950
- childList: true,
1951
- subtree: true,
1952
- });
1953
- }
1954
- }
1955
- }
1956
- function bridgeIOSVideoEvents() {
1957
- if (typeof globalThis.document === 'undefined')
1958
- return;
1959
- var videos = globalThis.document.querySelectorAll('video');
1960
- videos.forEach(function (video) {
1961
- if (video[FS_BRIDGED_KEY] === true || !(typeof video.webkitEnterFullscreen !== 'undefined' || typeof video.onwebkitbeginfullscreen !== 'undefined'))
1962
- return;
1963
- EventListener.add(video, {
1964
- type: 'webkitbeginfullscreen',
1965
- callback: onChangeSubscriptionManager.emit,
1966
- options: false,
1967
- });
1968
- EventListener.add(video, {
1969
- type: 'webkitendfullscreen',
1970
- callback: onChangeSubscriptionManager.emit,
1971
- options: false,
1972
- });
1973
- video[FS_BRIDGED_KEY] = true;
1974
- });
1975
- }
1976
- function attachOnChange() {
1977
- var events = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'];
1978
- for (var i = 0; i < events.length; i++) {
1979
- EventListener.add(globalThis.document, {
1980
- type: events[i],
1981
- callback: onChangeSubscriptionManager.emit,
1982
- options: false,
1983
- });
1984
- }
1985
- }
1986
- function detachOnChange() {
1987
- var events = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'];
1988
- for (var i = 0; i < events.length; i++) {
1989
- EventListener.remove(globalThis.document, {
1990
- type: events[i],
1991
- callback: onChangeSubscriptionManager.emit,
1992
- options: false,
1993
- });
1994
- }
1995
- }
1996
- function attachOnError() {
1997
- var events = ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'];
1998
- for (var i = 0; i < events.length; i++) {
1999
- EventListener.add(globalThis.document, {
2000
- type: events[i],
2001
- callback: onErrorSubscriptionManager.emit,
2002
- options: false,
2003
- });
2004
- }
2005
- }
2006
- function detachOnError() {
2007
- var events = ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'];
2008
- for (var i = 0; i < events.length; i++) {
2009
- EventListener.remove(globalThis.document, {
2010
- type: events[i],
2011
- callback: onErrorSubscriptionManager.emit,
2012
- options: false,
2013
- });
2014
- }
1979
+ return undefined;
2015
1980
  }
2016
- function getEnabled() {
2017
- if (api === null)
2018
- return (Platform.os.name === OS.iOS && globalThis.HTMLVideoElement.prototype.webkitSupportsFullscreen === true);
1981
+ return globalThis.document.documentElement;
1982
+ }
1983
+ function getSupported$1() {
1984
+ if (api !== null)
2019
1985
  return globalThis.document[api.enabled] === true;
2020
- }
2021
- function getElement() {
2022
- if (api === null) {
2023
- if (lastIOSVideo !== null && lastIOSVideo.webkitDisplayingFullscreen === true)
2024
- return lastIOSVideo;
2025
- return null;
2026
- }
2027
- var currentElement = globalThis.document[api.element];
2028
- if (typeof currentElement !== 'undefined')
2029
- return currentElement;
1986
+ if (Platform.os.name !== OS.iOS)
1987
+ return false;
1988
+ var video = getHTMLVideoElement$1();
1989
+ return video.webkitSupportsFullscreen === true || typeof video.webkitEnterFullscreen === 'function';
1990
+ }
1991
+ function getElement$1() {
1992
+ if (api === null) {
1993
+ if (lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true)
1994
+ return lastFallbackVideoElement$1;
2030
1995
  return null;
2031
1996
  }
2032
- function getIsFullscreen() {
2033
- return getElement() !== null;
2034
- }
2035
- function drainPendingOperation() {
2036
- var entry = pendingQueue.shift();
2037
- if (typeof entry === 'undefined') {
2038
- activeOperation = null;
2039
- return;
2040
- }
2041
- var next;
2042
- if (entry.operation === 'request')
2043
- next = requestImmediately(entry.target, entry.options);
2044
- else
2045
- next = exitImmediately();
2046
- activeOperation = next
2047
- .then(function () {
2048
- entry.resolve();
2049
- drainPendingOperation();
2050
- })
2051
- .catch(function (error) {
2052
- entry.reject(error);
2053
- drainPendingOperation();
2054
- });
2055
- }
2056
- function request(target, options) {
2057
- lastIntendedOperation = 'request';
2058
- if (activeOperation === null) {
2059
- var next = requestImmediately(target, options);
2060
- activeOperation = next
2061
- .then(drainPendingOperation)
2062
- .catch(drainPendingOperation);
2063
- return next;
2064
- }
2065
- return new Promise(function (resolve, reject) {
2066
- pendingQueue.push({
2067
- operation: 'request',
2068
- target: target,
2069
- options: options,
2070
- resolve: resolve,
2071
- reject: reject,
2072
- });
2073
- });
2074
- }
2075
- function exit() {
2076
- lastIntendedOperation = 'exit';
2077
- if (activeOperation === null) {
2078
- var next = exitImmediately();
2079
- activeOperation = next
2080
- .then(drainPendingOperation)
2081
- .catch(drainPendingOperation);
2082
- return next;
2083
- }
2084
- return new Promise(function (resolve, reject) {
2085
- pendingQueue.push({
2086
- operation: 'exit',
2087
- target: undefined,
2088
- options: undefined,
2089
- resolve: resolve,
2090
- reject: reject,
2091
- });
2092
- });
2093
- }
2094
- function requestImmediately(target, options) {
2095
- return new Promise(function (resolve, reject) {
2096
- if (typeof target === 'undefined')
2097
- target = getDefaultTarget();
2098
- if (typeof target === 'undefined')
2099
- return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
2100
- var tagName = target.tagName.toLowerCase();
2101
- function fallbackToIOSVideo() {
2102
- if (Platform.os.name === OS.iOS && typeof target !== 'undefined' && target.tagName.toUpperCase() === 'VIDEO') {
2103
- var video = target;
2104
- if (video.webkitSupportsFullscreen === true && typeof video.webkitEnterFullscreen === 'function') {
2105
- lastIOSVideo = video;
2106
- bridgeIOSVideoEvents();
2107
- video.webkitEnterFullscreen();
2108
- return resolve();
1997
+ var currentElement = globalThis.document[api.element];
1998
+ if (typeof currentElement !== 'undefined')
1999
+ return currentElement;
2000
+ return null;
2001
+ }
2002
+ function getIsActive$1() {
2003
+ return getElement$1() !== null;
2004
+ }
2005
+ function createEventPayload(nativeEvent, element, isActive) {
2006
+ return {
2007
+ nativeEvent: nativeEvent,
2008
+ element: element,
2009
+ isActive: isActive,
2010
+ };
2011
+ }
2012
+ function emitChange$1(nativeEvent, element, isActive) {
2013
+ onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element, isActive));
2014
+ }
2015
+ function emitError$1(nativeEvent, element, isActive) {
2016
+ onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element, isActive));
2017
+ }
2018
+ function onFullscreenChange(event) {
2019
+ var target = event.target;
2020
+ if (target instanceof globalThis.Element)
2021
+ emitChange$1(event, target, getIsActive$1());
2022
+ if (target instanceof globalThis.Document)
2023
+ emitChange$1(event, globalThis.document.documentElement, getIsActive$1());
2024
+ }
2025
+ function onFullscreenError(event) {
2026
+ var target = event.target;
2027
+ if (target instanceof globalThis.Element)
2028
+ emitError$1(event, target, getIsActive$1());
2029
+ if (target instanceof globalThis.Document)
2030
+ emitError$1(event, globalThis.document.documentElement, getIsActive$1());
2031
+ }
2032
+ function onIOSBeginFullscreen(event) {
2033
+ lastFallbackVideoElement$1 = this;
2034
+ emitChange$1(event, this, true);
2035
+ }
2036
+ function onIOSEndFullscreen(event) {
2037
+ if (lastFallbackVideoElement$1 === this)
2038
+ lastFallbackVideoElement$1 = null;
2039
+ emitChange$1(event, this, false);
2040
+ }
2041
+ function bridgeSingleVideoNode$1(video) {
2042
+ if (video[FS_BRIDGE_KEY])
2043
+ return;
2044
+ if (typeof video.webkitEnterFullscreen === 'undefined' && typeof video.onwebkitbeginfullscreen === 'undefined')
2045
+ return;
2046
+ EventListener.add(video, { type: 'webkitbeginfullscreen', callback: onIOSBeginFullscreen, options: false });
2047
+ EventListener.add(video, { type: 'webkitendfullscreen', callback: onIOSEndFullscreen, options: false });
2048
+ video[FS_BRIDGE_KEY] = true;
2049
+ }
2050
+ function bridgeIOSVideoEvents() {
2051
+ var videos = globalThis.document.querySelectorAll('video');
2052
+ for (var i = 0; i < videos.length; i++)
2053
+ bridgeSingleVideoNode$1(videos[i]);
2054
+ }
2055
+ function bridgeEvents$1() {
2056
+ if (eventsBridged$1)
2057
+ return;
2058
+ eventsBridged$1 = true;
2059
+ if (Platform.os.name !== OS.iOS)
2060
+ return;
2061
+ bridgeIOSVideoEvents();
2062
+ if (typeof globalThis.MutationObserver === 'undefined')
2063
+ return;
2064
+ var observer = new globalThis.MutationObserver(function (records) {
2065
+ if (lastFallbackVideoElement$1 !== null) {
2066
+ var removed = false;
2067
+ for (var i = 0; i < records.length; i++) {
2068
+ var removedNodes = records[i].removedNodes;
2069
+ for (var j = 0; j < removedNodes.length; j++) {
2070
+ var node = removedNodes[j];
2071
+ if (node === lastFallbackVideoElement$1 || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement$1))) {
2072
+ removed = true;
2073
+ break;
2109
2074
  }
2110
2075
  }
2111
- reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2076
+ if (removed)
2077
+ break;
2078
+ }
2079
+ if (removed && !globalThis.document.contains(lastFallbackVideoElement$1))
2080
+ lastFallbackVideoElement$1 = null;
2081
+ }
2082
+ for (var i = 0; i < records.length; i++) {
2083
+ var addedNodes = records[i].addedNodes;
2084
+ for (var j = 0; j < addedNodes.length; j++) {
2085
+ var node = addedNodes[j];
2086
+ if (node.nodeType !== Node.ELEMENT_NODE)
2087
+ continue;
2088
+ var element = node;
2089
+ if (element.tagName === 'VIDEO') {
2090
+ bridgeSingleVideoNode$1(element);
2091
+ continue;
2092
+ }
2093
+ var nested = element.querySelectorAll('video');
2094
+ for (var k = 0; k < nested.length; k++)
2095
+ bridgeSingleVideoNode$1(nested[k]);
2112
2096
  }
2113
- if (api !== null) {
2114
- var method = target[api.request];
2115
- if (typeof method === 'function') {
2116
- var result = method.call(target, options);
2117
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
2118
- result
2119
- .then(resolve)
2120
- .catch(function () {
2097
+ }
2098
+ });
2099
+ observer.observe(globalThis.document.documentElement, { childList: true, subtree: true });
2100
+ }
2101
+ function attachOnChange$3() {
2102
+ if (api != null)
2103
+ EventListener.add(globalThis.document, { type: api.events.change, callback: onFullscreenChange, options: false });
2104
+ if (Platform.os.name === OS.iOS)
2105
+ bridgeIOSVideoEvents();
2106
+ }
2107
+ function detachOnChange$3() {
2108
+ if (api != null)
2109
+ EventListener.remove(globalThis.document, { type: api.events.change, callback: onFullscreenChange, options: false });
2110
+ if (Platform.os.name !== OS.iOS)
2111
+ return;
2112
+ var videos = globalThis.document.querySelectorAll('video');
2113
+ for (var i = 0; i < videos.length; i++) {
2114
+ EventListener.remove(videos[i], { type: 'webkitbeginfullscreen', callback: onIOSBeginFullscreen, options: false });
2115
+ EventListener.remove(videos[i], { type: 'webkitendfullscreen', callback: onIOSEndFullscreen, options: false });
2116
+ videos[i][FS_BRIDGE_KEY] = false;
2117
+ }
2118
+ }
2119
+ function attachOnError$1() {
2120
+ if (api != null)
2121
+ EventListener.add(globalThis.document, { type: api.events.error, callback: onFullscreenError, options: false });
2122
+ }
2123
+ function detachOnError$1() {
2124
+ if (api != null)
2125
+ EventListener.remove(globalThis.document, { type: api.events.error, callback: onFullscreenError, options: false });
2126
+ }
2127
+ function request$3(target, options) {
2128
+ return new Promise(function (resolve, reject) {
2129
+ if (typeof target === 'undefined')
2130
+ target = getDefaultTarget$1();
2131
+ if (typeof target === 'undefined')
2132
+ return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
2133
+ if (getIsActive$1() && getElement$1() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
2134
+ return reject(new NotSupportedError('There is already a Fullscreen element in this document.'));
2135
+ var tagName = target.tagName.toLowerCase();
2136
+ var isIOSFullscreenActive = lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true;
2137
+ if (api !== null) {
2138
+ var method = target[api.request];
2139
+ if (typeof method === 'function' && !isIOSFullscreenActive) {
2140
+ var result = method.call(target, options);
2141
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
2142
+ result
2143
+ .then(resolve)
2144
+ .catch(function () {
2145
+ try {
2121
2146
  if (Platform.os.name !== OS.iOS)
2122
2147
  return reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2123
2148
  fallbackToIOSVideo();
2149
+ }
2150
+ catch (e) {
2151
+ reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2152
+ }
2153
+ });
2154
+ return;
2155
+ }
2156
+ return resolve();
2157
+ }
2158
+ }
2159
+ function fallbackToIOSVideo() {
2160
+ if (Platform.os.name === OS.iOS && typeof target !== 'undefined' && target.tagName.toUpperCase() === 'VIDEO') {
2161
+ var video_1 = target;
2162
+ if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function') {
2163
+ if (!hasStandardApi$1())
2164
+ bridgeSingleVideoNode$1(video_1);
2165
+ if (video_1.played.length === 0) {
2166
+ video_1.play()
2167
+ .then(function () {
2168
+ try {
2169
+ if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function')
2170
+ video_1.webkitEnterFullscreen();
2171
+ }
2172
+ catch (e) {
2173
+ return reject(new InvalidStateError('The object is in an invalid state.'));
2174
+ }
2124
2175
  });
2125
- return;
2126
2176
  }
2177
+ else {
2178
+ try {
2179
+ video_1.webkitEnterFullscreen();
2180
+ }
2181
+ catch (e) {
2182
+ return reject(new InvalidStateError('The object is in an invalid state.'));
2183
+ }
2184
+ }
2185
+ lastFallbackVideoElement$1 = video_1;
2127
2186
  return resolve();
2128
2187
  }
2129
2188
  }
2130
- fallbackToIOSVideo();
2131
- });
2132
- }
2133
- function exitImmediately() {
2134
- return new Promise(function (resolve, reject) {
2135
- if (getElement() === null && lastIOSVideo === null)
2136
- return resolve();
2137
- function fallbackToIOSVideo() {
2138
- if (Platform.os.name === OS.iOS) {
2139
- var candidates = void 0;
2140
- if (lastIOSVideo !== null)
2141
- candidates = [lastIOSVideo];
2142
- else
2143
- candidates = globalThis.document.querySelectorAll('video');
2144
- for (var i = 0; i < candidates.length; i++) {
2145
- var video = candidates[i];
2146
- if (typeof video.webkitExitFullscreen === 'function' && video.webkitDisplayingFullscreen === true) {
2147
- video.webkitExitFullscreen();
2148
- lastIOSVideo = null;
2149
- return resolve();
2150
- }
2151
- }
2189
+ reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2190
+ }
2191
+ fallbackToIOSVideo();
2192
+ });
2193
+ }
2194
+ function exit$1() {
2195
+ return new Promise(function (resolve, reject) {
2196
+ if (api !== null) {
2197
+ var method = globalThis.document[api.exit];
2198
+ if (typeof method === 'function') {
2199
+ var result = method.call(globalThis.document);
2200
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
2201
+ result
2202
+ .then(resolve)
2203
+ .catch(resolve);
2204
+ return;
2152
2205
  }
2206
+ return resolve();
2207
+ }
2208
+ }
2209
+ function fallbackToIOSVideo() {
2210
+ if (Platform.os.name !== OS.iOS) {
2153
2211
  reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2212
+ return;
2154
2213
  }
2155
- if (api !== null) {
2156
- var method = globalThis.document[api.exit];
2157
- if (typeof method === 'function') {
2158
- var result = method.call(globalThis.document);
2159
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
2160
- result
2161
- .then(resolve)
2162
- .catch(function () {
2163
- if (Platform.os.name !== OS.iOS)
2164
- return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2165
- fallbackToIOSVideo();
2166
- });
2167
- return;
2168
- }
2214
+ var target = lastFallbackVideoElement$1;
2215
+ if (target !== null && typeof target.webkitExitFullscreen === 'function' && target.webkitDisplayingFullscreen === true) {
2216
+ target.webkitExitFullscreen();
2217
+ if (target.webkitDisplayingFullscreen)
2218
+ return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2219
+ lastFallbackVideoElement$1 = null;
2220
+ return resolve();
2221
+ }
2222
+ var videos = globalThis.document.querySelectorAll('video');
2223
+ for (var i = 0; i < videos.length; i++) {
2224
+ var video = videos[i];
2225
+ if (typeof video.webkitExitFullscreen === 'function' && video.webkitDisplayingFullscreen === true) {
2226
+ video.webkitExitFullscreen();
2227
+ if (video.webkitDisplayingFullscreen)
2228
+ return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2229
+ lastFallbackVideoElement$1 = null;
2169
2230
  return resolve();
2170
2231
  }
2171
2232
  }
2172
- fallbackToIOSVideo();
2173
- });
2174
- }
2175
- function toggle(target, options) {
2176
- if (lastIntendedOperation === 'request')
2177
- return exit();
2178
- return request(target, options);
2179
- }
2180
- bridgeEvents();
2181
- return {
2182
- get supported() {
2183
- return getEnabled();
2184
- },
2185
- get element() {
2186
- return getElement();
2187
- },
2188
- get isFullscreen() {
2189
- return getIsFullscreen();
2190
- },
2191
- request: request,
2192
- exit: exit,
2193
- toggle: toggle,
2194
- onChange: onChangeSubscriptionManager.subscribe,
2195
- onError: onErrorSubscriptionManager.subscribe,
2196
- Constants: {},
2197
- Errors: {
2198
- NotSupportedError: NotSupportedError,
2199
- },
2200
- };
2233
+ if (getElement$1() === null)
2234
+ return resolve();
2235
+ reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2236
+ }
2237
+ fallbackToIOSVideo();
2238
+ });
2201
2239
  }
2202
- var Fullscreen = createFullscreen();
2240
+ function toggle$1(target, options) {
2241
+ var current = getElement$1();
2242
+ if (typeof target !== 'undefined') {
2243
+ if (current === target)
2244
+ return this.exit();
2245
+ return this.request(target, options);
2246
+ }
2247
+ if (current !== null)
2248
+ return this.exit();
2249
+ return this.request(undefined, options);
2250
+ }
2251
+ function onChange$1(targetOrListener, listenerOrOptions, options) {
2252
+ if (typeof targetOrListener === 'function')
2253
+ return onChangeSubscriptionManager$3.subscribe(targetOrListener, listenerOrOptions);
2254
+ var target = targetOrListener;
2255
+ var listener = listenerOrOptions;
2256
+ function wrappedListener(payload) {
2257
+ if (payload.element === target)
2258
+ listener(payload);
2259
+ }
2260
+ return onChangeSubscriptionManager$3.subscribe(wrappedListener, options);
2261
+ }
2262
+ function onError$1(targetOrListener, listenerOrOptions, options) {
2263
+ if (typeof targetOrListener === 'function')
2264
+ return onErrorSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
2265
+ var target = targetOrListener;
2266
+ var listener = listenerOrOptions;
2267
+ function wrappedListener(payload) {
2268
+ if (payload.element === target)
2269
+ listener(payload);
2270
+ }
2271
+ return onErrorSubscriptionManager$1.subscribe(wrappedListener, options);
2272
+ }
2273
+ bridgeEvents$1();
2203
2274
 
2204
2275
  var PermissionType;
2205
2276
  (function (PermissionType) {
@@ -2241,7 +2312,10 @@
2241
2312
  })();
2242
2313
 
2243
2314
  var Permission = {
2244
- request: request$1,
2315
+ get supported() {
2316
+ return supported$5();
2317
+ },
2318
+ request: request$2,
2245
2319
  check: check,
2246
2320
  Constants: {
2247
2321
  PermissionType: PermissionType,
@@ -2249,7 +2323,10 @@
2249
2323
  },
2250
2324
  Errors: {},
2251
2325
  };
2252
- function request$1(type) {
2326
+ function supported$5() {
2327
+ return typeof globalThis.navigator.permissions !== 'undefined';
2328
+ }
2329
+ function request$2(type) {
2253
2330
  var instance = this;
2254
2331
  return new Promise(function (resolve) {
2255
2332
  function resolveAfterCheck() {
@@ -2339,7 +2416,7 @@
2339
2416
 
2340
2417
  var PermissionNotGrantedError = createCustomError('PermissionNotGrantedError');
2341
2418
 
2342
- function request(url, options) {
2419
+ function request$1(url, options) {
2343
2420
  return new Promise(function (resolve) {
2344
2421
  var method = 'GET';
2345
2422
  var headers = {};
@@ -2421,7 +2498,7 @@
2421
2498
  return to;
2422
2499
  }
2423
2500
 
2424
- var onChangeSubscriptionManager$1 = createSubscriptionManager(attachOnChange$1, detachOnChange$1);
2501
+ var onChangeSubscriptionManager$2 = createSubscriptionManager(attachOnChange$2, detachOnChange$2);
2425
2502
  var watchIdRef = null;
2426
2503
  var Geolocation = {
2427
2504
  get value() {
@@ -2430,7 +2507,7 @@
2430
2507
  get supported() {
2431
2508
  return supported$4();
2432
2509
  },
2433
- onChange: onChangeSubscriptionManager$1.subscribe,
2510
+ onChange: onChangeSubscriptionManager$2.subscribe,
2434
2511
  Constants: {},
2435
2512
  Errors: {
2436
2513
  NotSupportedError: NotSupportedError,
@@ -2467,7 +2544,7 @@
2467
2544
  }
2468
2545
  function getFallbackValue(error) {
2469
2546
  return new Promise(function (resolve, reject) {
2470
- request('http://ip-api.com/json?fields=lat,lon')
2547
+ request$1('http://ip-api.com/json?fields=lat,lon')
2471
2548
  .then(function (response) {
2472
2549
  if (typeof response !== 'undefined') {
2473
2550
  var coordinate_1 = {
@@ -2506,7 +2583,7 @@
2506
2583
  return new NotSupportedError('Unknown error.');
2507
2584
  }
2508
2585
  }
2509
- function attachOnChange$1() {
2586
+ function attachOnChange$2() {
2510
2587
  if (!supported$4())
2511
2588
  return;
2512
2589
  Permission
@@ -2519,13 +2596,13 @@
2519
2596
  }
2520
2597
  });
2521
2598
  }
2522
- function detachOnChange$1() {
2599
+ function detachOnChange$2() {
2523
2600
  if (!supported$4() || watchIdRef === null)
2524
2601
  return;
2525
2602
  globalThis.navigator.geolocation.clearWatch(watchIdRef);
2526
2603
  }
2527
2604
  function onGeolocationCoordinatesChange(coordinates) {
2528
- onChangeSubscriptionManager$1.emit(coordinates);
2605
+ onChangeSubscriptionManager$2.emit(coordinates);
2529
2606
  }
2530
2607
  function supported$4() {
2531
2608
  return typeof globalThis.navigator.geolocation !== 'undefined';
@@ -3976,16 +4053,19 @@
3976
4053
  }
3977
4054
 
3978
4055
  var Vibration = {
3979
- run: run,
3980
- stop: stop,
3981
4056
  get supported() {
3982
4057
  return supported$3();
3983
4058
  },
4059
+ run: run,
4060
+ stop: stop,
3984
4061
  Constants: {},
3985
4062
  Errors: {
3986
4063
  NotSupportedError: NotSupportedError,
3987
4064
  },
3988
4065
  };
4066
+ function supported$3() {
4067
+ return typeof globalThis.navigator.vibrate !== 'undefined';
4068
+ }
3989
4069
  function run(pattern) {
3990
4070
  if (supported$3())
3991
4071
  return globalThis.navigator.vibrate(pattern);
@@ -3994,313 +4074,329 @@
3994
4074
  function stop() {
3995
4075
  return this.run(0);
3996
4076
  }
3997
- function supported$3() {
3998
- return typeof globalThis.navigator.vibrate !== 'undefined';
3999
- }
4000
4077
 
4001
- var PIP_BRIDGED_KEY = Symbol('pipBridged');
4002
4078
  var PIP_PRESENTATION_MODE = 'picture-in-picture';
4003
4079
  var INLINE_PRESENTATION_MODE = 'inline';
4004
- function hasStandardPipEvents() {
4080
+ var videoElement = null;
4081
+ var lastFallbackVideoElement = null;
4082
+ var eventsBridged = false;
4083
+ var PIP_BRIDGE_KEY = (function () {
4084
+ if (typeof Symbol === 'function') {
4085
+ var existing = globalThis.__nativeFnPipBridgeKey__;
4086
+ if (typeof existing === 'symbol')
4087
+ return existing;
4088
+ return globalThis.__nativeFnPipBridgeKey__ = Symbol('native.fn.pip.bridged');
4089
+ }
4090
+ return '__nativeFnPipBridged__';
4091
+ }());
4092
+ var onChangeSubscriptionManager$1 = createSubscriptionManager(attachOnChange$1, detachOnChange$1);
4093
+ var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
4094
+ var Pip = {
4095
+ get supported() {
4096
+ return getSupported();
4097
+ },
4098
+ get element() {
4099
+ return getElement();
4100
+ },
4101
+ get isActive() {
4102
+ return getIsActive();
4103
+ },
4104
+ request: request,
4105
+ exit: exit,
4106
+ toggle: toggle,
4107
+ onChange: onChange,
4108
+ onError: onError,
4109
+ Constants: {},
4110
+ Errors: {
4111
+ NotSupportedError: NotSupportedError,
4112
+ InvalidStateError: InvalidStateError,
4113
+ },
4114
+ };
4115
+ function getHTMLVideoElement() {
4116
+ var selected = globalThis.document.querySelector('video');
4117
+ if (selected !== null)
4118
+ return selected;
4119
+ if (videoElement === null)
4120
+ return videoElement = globalThis.document.createElement('video');
4121
+ return videoElement;
4122
+ }
4123
+ function hasStandardApi() {
4005
4124
  return typeof globalThis.document.pictureInPictureEnabled !== 'undefined';
4006
4125
  }
4007
- function createPip() {
4008
- var lastPipVideo = null;
4009
- var eventsBridged = false;
4010
- var activeOperation = null;
4011
- var pendingQueue = [];
4012
- var lastIntendedOperation = 'exit';
4013
- var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
4014
- var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
4015
- function getEnabled() {
4016
- if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
4017
- return globalThis.document.pictureInPictureEnabled;
4018
- if (typeof HTMLVideoElement === 'undefined')
4019
- return false;
4020
- var videos = globalThis.document.querySelectorAll('video');
4021
- for (var i = 0; i < videos.length; i++) {
4022
- var video = videos[i];
4023
- if (typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE))
4024
- return true;
4025
- }
4026
- return false;
4027
- }
4028
- function getElement() {
4029
- var currentElement = globalThis.document.pictureInPictureElement;
4030
- if (currentElement !== null && typeof currentElement !== 'undefined')
4031
- return currentElement;
4032
- if (lastPipVideo !== null && lastPipVideo.webkitPresentationMode === PIP_PRESENTATION_MODE)
4033
- return lastPipVideo;
4034
- return null;
4035
- }
4036
- function getIsPip() {
4037
- return getElement() !== null;
4038
- }
4039
- function getDefaultTarget() {
4040
- var video = globalThis.document.querySelector('video');
4041
- if (video === null)
4042
- return undefined;
4126
+ function hasWebkitApi() {
4127
+ return typeof getHTMLVideoElement().webkitSetPresentationMode === 'function';
4128
+ }
4129
+ function getDefaultTarget() {
4130
+ var video = globalThis.document.querySelector('video');
4131
+ if (video !== null)
4043
4132
  return video;
4133
+ return undefined;
4134
+ }
4135
+ function createPipEventPayload(nativeEvent, element, isActive) {
4136
+ return {
4137
+ nativeEvent: nativeEvent,
4138
+ element: element,
4139
+ isActive: isActive
4140
+ };
4141
+ }
4142
+ function emitChange(nativeEvent, element, isActive) {
4143
+ onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element, isActive));
4144
+ }
4145
+ function emitError(nativeEvent, element, isActive) {
4146
+ onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
4147
+ }
4148
+ function onEnterPictureInPicture(event) {
4149
+ var target = event.target;
4150
+ if (target instanceof globalThis.HTMLVideoElement)
4151
+ emitChange(event, target, true);
4152
+ }
4153
+ function onLeavePictureInPicture(event) {
4154
+ var target = event.target;
4155
+ if (target instanceof globalThis.HTMLVideoElement)
4156
+ emitChange(event, target, false);
4157
+ }
4158
+ function onPictureInPictureError(event) {
4159
+ var target = event.target;
4160
+ if (target instanceof globalThis.HTMLVideoElement)
4161
+ emitError(event, target, getIsActive());
4162
+ }
4163
+ function onWebkitPresentationModeChanged(event) {
4164
+ if (this.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4165
+ lastFallbackVideoElement = this;
4166
+ emitChange(event, this, true);
4167
+ return;
4044
4168
  }
4045
- function onWebkitPresentationModeChanged(event) {
4046
- if (this.webkitPresentationMode === PIP_PRESENTATION_MODE || (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastPipVideo === this))
4047
- onChangeSubscriptionManager.emit(event);
4169
+ if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastFallbackVideoElement === this) {
4170
+ lastFallbackVideoElement = null;
4171
+ emitChange(event, this, false);
4048
4172
  }
4049
- function bridgeEvents() {
4050
- if (eventsBridged)
4051
- return;
4052
- eventsBridged = true;
4053
- if (!hasStandardPipEvents()) {
4054
- bridgeWebkitVideoEvents();
4055
- if (typeof globalThis.MutationObserver !== 'undefined') {
4056
- var observer = new MutationObserver(function () {
4057
- bridgeWebkitVideoEvents();
4058
- });
4059
- observer.observe(globalThis.document.documentElement, {
4060
- childList: true,
4061
- subtree: true,
4062
- });
4173
+ }
4174
+ function bridgeSingleVideoNode(video) {
4175
+ if (video[PIP_BRIDGE_KEY])
4176
+ return;
4177
+ if (typeof video.webkitSetPresentationMode === 'undefined' && typeof video.onwebkitpresentationmodechanged === 'undefined')
4178
+ return;
4179
+ EventListener.add(video, { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
4180
+ video[PIP_BRIDGE_KEY] = true;
4181
+ }
4182
+ function bridgeWebkitVideoEvents() {
4183
+ var videos = globalThis.document.querySelectorAll('video');
4184
+ for (var i = 0; i < videos.length; i++)
4185
+ bridgeSingleVideoNode(videos[i]);
4186
+ }
4187
+ function bridgeEvents() {
4188
+ if (eventsBridged)
4189
+ return;
4190
+ eventsBridged = true;
4191
+ if (hasStandardApi() && !hasWebkitApi())
4192
+ return;
4193
+ bridgeWebkitVideoEvents();
4194
+ if (typeof globalThis.MutationObserver === 'undefined')
4195
+ return;
4196
+ var observer = new globalThis.MutationObserver(function (records) {
4197
+ if (lastFallbackVideoElement !== null) {
4198
+ var removed = false;
4199
+ for (var i = 0; i < records.length; i++) {
4200
+ var removedNodes = records[i].removedNodes;
4201
+ for (var j = 0; j < removedNodes.length; j++) {
4202
+ var node = removedNodes[j];
4203
+ if (node === lastFallbackVideoElement || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement))) {
4204
+ removed = true;
4205
+ break;
4206
+ }
4207
+ }
4208
+ if (removed)
4209
+ break;
4063
4210
  }
4211
+ if (removed && !globalThis.document.contains(lastFallbackVideoElement))
4212
+ lastFallbackVideoElement = null;
4064
4213
  }
4065
- }
4066
- function bridgeWebkitVideoEvents() {
4067
- if (typeof globalThis.document === 'undefined')
4068
- return;
4069
- var videos = globalThis.document.querySelectorAll('video');
4070
- videos.forEach(function (video) {
4071
- if (video[PIP_BRIDGED_KEY] === true || !(typeof video.webkitSetPresentationMode !== 'undefined' || typeof video.onwebkitpresentationmodechanged !== 'undefined'))
4072
- return;
4073
- EventListener.add(video, {
4074
- type: 'webkitpresentationmodechanged',
4075
- callback: onWebkitPresentationModeChanged,
4076
- options: false,
4077
- });
4078
- video[PIP_BRIDGED_KEY] = true;
4079
- });
4080
- }
4081
- function attachOnChange() {
4082
- if (hasStandardPipEvents()) {
4083
- var changeEvents = ['enterpictureinpicture', 'leavepictureinpicture'];
4084
- for (var i = 0; i < changeEvents.length; i++) {
4085
- EventListener.add(globalThis.document, {
4086
- type: changeEvents[i],
4087
- callback: onChangeSubscriptionManager.emit,
4088
- options: false,
4089
- });
4214
+ for (var i = 0; i < records.length; i++) {
4215
+ var addedNodes = records[i].addedNodes;
4216
+ for (var j = 0; j < addedNodes.length; j++) {
4217
+ var node = addedNodes[j];
4218
+ if (node.nodeType !== Node.ELEMENT_NODE)
4219
+ continue;
4220
+ var element = node;
4221
+ if (element.tagName === 'VIDEO') {
4222
+ bridgeSingleVideoNode(element);
4223
+ continue;
4224
+ }
4225
+ var nested = element.querySelectorAll('video');
4226
+ for (var k = 0; k < nested.length; k++)
4227
+ bridgeSingleVideoNode(nested[k]);
4090
4228
  }
4091
- return;
4092
4229
  }
4093
- bridgeWebkitVideoEvents();
4230
+ });
4231
+ observer.observe(globalThis.document.documentElement, { childList: true, subtree: true });
4232
+ }
4233
+ function attachOnChange$1() {
4234
+ if (hasStandardApi()) {
4235
+ EventListener.add(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
4236
+ EventListener.add(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
4237
+ return;
4094
4238
  }
4095
- function detachOnChange() {
4096
- if (hasStandardPipEvents()) {
4097
- var changeEvents = ['enterpictureinpicture', 'leavepictureinpicture'];
4098
- for (var i = 0; i < changeEvents.length; i++) {
4099
- EventListener.remove(globalThis.document, {
4100
- type: changeEvents[i],
4101
- callback: onChangeSubscriptionManager.emit,
4102
- options: false,
4239
+ bridgeWebkitVideoEvents();
4240
+ }
4241
+ function detachOnChange$1() {
4242
+ if (hasStandardApi()) {
4243
+ EventListener.remove(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
4244
+ EventListener.remove(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
4245
+ return;
4246
+ }
4247
+ var videos = globalThis.document.querySelectorAll('video');
4248
+ for (var i = 0; i < videos.length; i++) {
4249
+ EventListener.remove(videos[i], { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
4250
+ videos[i][PIP_BRIDGE_KEY] = false;
4251
+ }
4252
+ }
4253
+ function attachOnError() {
4254
+ EventListener.add(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
4255
+ }
4256
+ function detachOnError() {
4257
+ EventListener.remove(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
4258
+ }
4259
+ function getSupported() {
4260
+ if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
4261
+ return globalThis.document.pictureInPictureEnabled;
4262
+ var video = getHTMLVideoElement();
4263
+ return typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE);
4264
+ }
4265
+ function getElement() {
4266
+ var currentElement = globalThis.document.pictureInPictureElement;
4267
+ if (currentElement !== null && typeof currentElement !== 'undefined')
4268
+ return currentElement;
4269
+ if (lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE)
4270
+ return lastFallbackVideoElement;
4271
+ return null;
4272
+ }
4273
+ function getIsActive() {
4274
+ return getElement() !== null;
4275
+ }
4276
+ function request(target) {
4277
+ return new Promise(function (resolve, reject) {
4278
+ if (typeof target === 'undefined')
4279
+ target = getDefaultTarget();
4280
+ if (typeof target === 'undefined')
4281
+ return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
4282
+ if (getIsActive() && getElement() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
4283
+ return reject(new NotSupportedError('There is already a Picture-in-Picture element in this document.'));
4284
+ var tagName = target.tagName.toLowerCase();
4285
+ if (tagName !== 'video')
4286
+ return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4287
+ var method = target.requestPictureInPicture;
4288
+ var isWebkitPipActive = lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE;
4289
+ if (typeof method === 'function' && !hasWebkitApi() && !isWebkitPipActive) {
4290
+ var result = method.call(target);
4291
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
4292
+ result
4293
+ .then(resolve)
4294
+ .catch(function () {
4295
+ try {
4296
+ fallbackToWebkit();
4297
+ }
4298
+ catch (e) {
4299
+ reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4300
+ }
4103
4301
  });
4302
+ return;
4104
4303
  }
4105
- return;
4304
+ return resolve();
4106
4305
  }
4107
- var videos = globalThis.document.querySelectorAll('video');
4108
- videos.forEach(function (video) {
4109
- EventListener.remove(video, {
4110
- type: 'webkitpresentationmodechanged',
4111
- callback: onWebkitPresentationModeChanged,
4112
- options: false,
4113
- });
4114
- try {
4115
- delete video[PIP_BRIDGED_KEY];
4116
- }
4117
- catch (_) {
4118
- video[PIP_BRIDGED_KEY] = undefined;
4306
+ function fallbackToWebkit() {
4307
+ if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
4308
+ if (target.disablePictureInPicture)
4309
+ return reject(new NotSupportedError('Picture-in-Picture is disabled on this element.'));
4310
+ bridgeSingleVideoNode(target);
4311
+ target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
4312
+ return resolve();
4119
4313
  }
4120
- });
4121
- }
4122
- function attachOnError() {
4123
- EventListener.add(globalThis.document, {
4124
- type: 'pictureinpictureerror',
4125
- callback: onErrorSubscriptionManager.emit,
4126
- options: false,
4127
- });
4128
- }
4129
- function detachOnError() {
4130
- EventListener.remove(globalThis.document, {
4131
- type: 'pictureinpictureerror',
4132
- callback: onErrorSubscriptionManager.emit,
4133
- options: false,
4134
- });
4135
- }
4136
- function drainPendingOperation() {
4137
- var entry = pendingQueue.shift();
4138
- if (typeof entry === 'undefined') {
4139
- activeOperation = null;
4140
- return;
4141
- }
4142
- var next;
4143
- if (entry.operation === 'request')
4144
- next = requestImmediately(entry.target);
4145
- else
4146
- next = exitImmediately();
4147
- activeOperation = next
4148
- .then(function () {
4149
- entry.resolve();
4150
- drainPendingOperation();
4151
- })
4152
- .catch(function (error) {
4153
- entry.reject(error);
4154
- drainPendingOperation();
4155
- });
4156
- }
4157
- function request(target) {
4158
- lastIntendedOperation = 'request';
4159
- if (activeOperation === null) {
4160
- var next = requestImmediately(target);
4161
- activeOperation = next
4162
- .then(drainPendingOperation)
4163
- .catch(drainPendingOperation);
4164
- return next;
4165
- }
4166
- return new Promise(function (resolve, reject) {
4167
- pendingQueue.push({
4168
- operation: 'request',
4169
- target: target,
4170
- resolve: resolve,
4171
- reject: reject,
4172
- });
4173
- });
4174
- }
4175
- function exit() {
4176
- lastIntendedOperation = 'exit';
4177
- if (activeOperation === null) {
4178
- var next = exitImmediately();
4179
- activeOperation = next
4180
- .then(drainPendingOperation)
4181
- .catch(drainPendingOperation);
4182
- return next;
4314
+ reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4183
4315
  }
4184
- return new Promise(function (resolve, reject) {
4185
- pendingQueue.push({
4186
- operation: 'exit',
4187
- target: undefined,
4188
- resolve: resolve,
4189
- reject: reject,
4190
- });
4191
- });
4192
- }
4193
- function requestImmediately(target) {
4194
- return new Promise(function (resolve, reject) {
4195
- if (typeof target === 'undefined')
4196
- target = getDefaultTarget();
4197
- if (typeof target === 'undefined')
4198
- return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
4199
- var tagName = target.tagName.toLowerCase();
4200
- if (tagName !== 'video')
4201
- return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4202
- function fallbackToWebkitVideo() {
4203
- if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
4204
- if (target.disablePictureInPicture)
4205
- return reject(new NotSupportedError('Picture-in-Picture is disabled on this video element.'));
4206
- lastPipVideo = target;
4207
- bridgeWebkitVideoEvents();
4208
- target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
4209
- return resolve();
4210
- }
4211
- reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4316
+ fallbackToWebkit();
4317
+ });
4318
+ }
4319
+ function exit() {
4320
+ return new Promise(function (resolve, reject) {
4321
+ var method = globalThis.document.exitPictureInPicture;
4322
+ if (typeof method === 'function' && !hasWebkitApi()) {
4323
+ var result = method.call(globalThis.document);
4324
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
4325
+ result
4326
+ .then(resolve)
4327
+ .catch(function () {
4328
+ try {
4329
+ fallbackToWebkit();
4330
+ }
4331
+ catch (e) {
4332
+ reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
4333
+ }
4334
+ });
4335
+ return;
4212
4336
  }
4213
- var method = target.requestPictureInPicture;
4214
- if (typeof method === 'function') {
4215
- var result = method.call(target);
4216
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
4217
- result
4218
- .then(function () {
4219
- resolve();
4220
- })
4221
- .catch(function () {
4222
- fallbackToWebkitVideo();
4223
- });
4224
- return;
4225
- }
4337
+ return resolve();
4338
+ }
4339
+ function fallbackToWebkit() {
4340
+ if (lastFallbackVideoElement !== null && typeof lastFallbackVideoElement.webkitSetPresentationMode === 'function') {
4341
+ lastFallbackVideoElement.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4226
4342
  return resolve();
4227
4343
  }
4228
- fallbackToWebkitVideo();
4229
- });
4230
- }
4231
- function exitImmediately() {
4232
- return new Promise(function (resolve, reject) {
4233
- if (getElement() === null && lastPipVideo === null)
4234
- return resolve();
4235
- function fallbackToWebkitVideo() {
4236
- var candidates;
4237
- if (lastPipVideo !== null && lastPipVideo.webkitPresentationMode === PIP_PRESENTATION_MODE)
4238
- candidates = [lastPipVideo];
4239
- else
4240
- candidates = globalThis.document.querySelectorAll('video');
4241
- for (var i = 0; i < candidates.length; i++) {
4242
- var video = candidates[i];
4243
- if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4244
- video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4245
- lastPipVideo = null;
4246
- return resolve();
4247
- }
4248
- }
4249
- if (getElement() === null)
4344
+ var videos = globalThis.document.querySelectorAll('video');
4345
+ for (var i = 0; i < videos.length; i++) {
4346
+ var video = videos[i];
4347
+ if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4348
+ video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4250
4349
  return resolve();
4251
- reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
4252
- }
4253
- var method = globalThis.document.exitPictureInPicture;
4254
- if (typeof method === 'function') {
4255
- var result = method.call(globalThis.document);
4256
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
4257
- result
4258
- .then(resolve)
4259
- .catch(function () {
4260
- fallbackToWebkitVideo();
4261
- });
4262
- return;
4263
4350
  }
4264
- return resolve();
4265
4351
  }
4266
- fallbackToWebkitVideo();
4267
- });
4268
- }
4269
- function toggle(target) {
4270
- if (lastIntendedOperation === 'request')
4271
- return exit();
4272
- return request(target);
4273
- }
4274
- bridgeEvents();
4275
- return {
4276
- get supported() {
4277
- return getEnabled();
4278
- },
4279
- get element() {
4280
- return getElement();
4281
- },
4282
- get isPip() {
4283
- return getIsPip();
4284
- },
4285
- request: request,
4286
- exit: exit,
4287
- toggle: toggle,
4288
- onChange: onChangeSubscriptionManager.subscribe,
4289
- onError: onErrorSubscriptionManager.subscribe,
4290
- Constants: {},
4291
- Errors: {
4292
- NotSupportedError: NotSupportedError,
4293
- },
4294
- };
4352
+ return resolve();
4353
+ }
4354
+ fallbackToWebkit();
4355
+ });
4295
4356
  }
4296
- var Pip = createPip();
4357
+ function toggle(target) {
4358
+ var current = getElement();
4359
+ if (typeof target !== 'undefined') {
4360
+ if (current === target)
4361
+ return this.exit();
4362
+ else
4363
+ return this.request(target);
4364
+ }
4365
+ if (current !== null)
4366
+ return this.exit();
4367
+ else
4368
+ return this.request(target);
4369
+ }
4370
+ function onChange(targetOrListener, listenerOrOptions, options) {
4371
+ if (typeof targetOrListener === 'function')
4372
+ return onChangeSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
4373
+ var target = targetOrListener;
4374
+ var listener = listenerOrOptions;
4375
+ function wrappedListener(payload) {
4376
+ if (payload.element === target)
4377
+ listener(payload);
4378
+ }
4379
+ return onChangeSubscriptionManager$1.subscribe(wrappedListener, options);
4380
+ }
4381
+ function onError(targetOrListener, listenerOrOptions, options) {
4382
+ if (typeof targetOrListener === 'function')
4383
+ return onErrorSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
4384
+ var target = targetOrListener;
4385
+ var listener = listenerOrOptions;
4386
+ function wrappedListener(payload) {
4387
+ if (payload.element === target)
4388
+ listener(payload);
4389
+ }
4390
+ return onErrorSubscriptionManager.subscribe(wrappedListener, options);
4391
+ }
4392
+ bridgeEvents();
4297
4393
 
4298
4394
  var Badge = {
4299
- set: set,
4300
- clear: clear,
4301
4395
  get supported() {
4302
4396
  return supported$2();
4303
4397
  },
4398
+ set: set,
4399
+ clear: clear,
4304
4400
  Constants: {},
4305
4401
  Errors: {
4306
4402
  NotSupportedError: NotSupportedError,
@@ -4372,12 +4468,12 @@
4372
4468
  var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
4373
4469
  var batteryRef = null;
4374
4470
  var Battery = {
4375
- get value() {
4376
- return getValue();
4377
- },
4378
4471
  get supported() {
4379
4472
  return supported();
4380
4473
  },
4474
+ get value() {
4475
+ return getValue();
4476
+ },
4381
4477
  onChange: onChangeSubscriptionManager.subscribe,
4382
4478
  Constants: {},
4383
4479
  Errors: {