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
package/dist/native.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.1.9";
3
+ var version = "1.2.1";
4
4
  var packageJSON = {
5
5
  version: version};
6
6
 
@@ -689,10 +689,15 @@ function parseFromHighEntropyValues() {
689
689
  parsedFromHighEntropyValuesEngine.version = brandVersion;
690
690
  }
691
691
  if (typeof platformVersion === 'string') {
692
- if (getParsedCache().os.name === OS.Windows)
693
- parsedFromHighEntropyValuesOS.version = parseInt(platformVersion.split('.')[0], 10) >= 13 ? '11' : '10';
694
- else
692
+ if (getParsedCache().os.name === OS.Windows) {
693
+ if (parseInt(platformVersion.split('.')[0], 10) >= 13)
694
+ parsedFromHighEntropyValuesOS.version = '11';
695
+ else
696
+ parsedFromHighEntropyValuesOS.version = '10';
697
+ }
698
+ else {
695
699
  parsedFromHighEntropyValuesOS.version = platformVersion;
700
+ }
696
701
  }
697
702
  if (typeof platform === 'string') {
698
703
  if (/android/i.test(platform))
@@ -855,14 +860,14 @@ function createSubscriptionManager(attach, detach) {
855
860
  };
856
861
  }
857
862
 
858
- var onChangeSubscriptionManager$3 = createSubscriptionManager(attachOnChange$3, detachOnChange$3);
863
+ var onChangeSubscriptionManager$5 = createSubscriptionManager(attachOnChange$5, detachOnChange$5);
859
864
  var appearanceRef = null;
860
865
  var pollingIntervalId = null;
861
866
  var Appearance = {
862
867
  get value() {
863
868
  return getAppearance();
864
869
  },
865
- onChange: onChangeSubscriptionManager$3.subscribe,
870
+ onChange: onChangeSubscriptionManager$5.subscribe,
866
871
  Constants: {
867
872
  Appearances: Appearances
868
873
  },
@@ -898,7 +903,7 @@ function startPolling() {
898
903
  var appearance = getAppearanceFromEngine();
899
904
  if (appearance !== appearanceRef) {
900
905
  appearanceRef = appearance;
901
- onChangeSubscriptionManager$3.emit(appearance);
906
+ onChangeSubscriptionManager$5.emit(appearance);
902
907
  }
903
908
  }, 2000);
904
909
  }
@@ -909,13 +914,13 @@ function stopPolling() {
909
914
  pollingIntervalId = null;
910
915
  }
911
916
  }
912
- function attachOnChange$3() {
917
+ function attachOnChange$5() {
913
918
  appearanceRef = getAppearanceFromMediaQuery();
914
919
  EventListener.add(MEDIA_QUERY_LIST$1, { type: 'change', callback: onMediaChange });
915
920
  if (Platform.browser.name === Browsers.SamsungInternet)
916
921
  startPolling();
917
922
  }
918
- function detachOnChange$3() {
923
+ function detachOnChange$5() {
919
924
  appearanceRef = null;
920
925
  EventListener.remove(MEDIA_QUERY_LIST$1, { type: 'change', callback: onMediaChange });
921
926
  if (Platform.browser.name === Browsers.SamsungInternet)
@@ -928,7 +933,7 @@ function onMediaChange(event) {
928
933
  else
929
934
  appearance = Appearances.Light;
930
935
  if (appearance !== appearanceRef)
931
- onChangeSubscriptionManager$3.emit(appearanceRef = appearance);
936
+ onChangeSubscriptionManager$5.emit(appearanceRef = appearance);
932
937
  }
933
938
 
934
939
  function isSecureContext() {
@@ -1664,14 +1669,14 @@ var safeAreaMaxInsetObserver = createEnvObserver('safe-area-max-inset');
1664
1669
  var keyboardInsetObserver = createEnvObserver('keyboard-inset');
1665
1670
  var titlebarAreaObserver = createEnvObserver('titlebar-area');
1666
1671
  var viewportSegmentObserver = createEnvObserver('viewport-segment');
1667
- var onChangeSubscriptionManager$2 = createSubscriptionManager(attachOnChange$2, detachOnChange$2);
1672
+ var onChangeSubscriptionManager$4 = createSubscriptionManager(attachOnChange$4, detachOnChange$4);
1668
1673
  var dimensionRef = null;
1669
1674
  var Dimension = {
1670
1675
  get value() {
1671
1676
  return getDimension();
1672
1677
  },
1673
1678
  environment: getEnvironment(),
1674
- onChange: onChangeSubscriptionManager$2.subscribe,
1679
+ onChange: onChangeSubscriptionManager$4.subscribe,
1675
1680
  Constants: {
1676
1681
  Orientation: Orientation,
1677
1682
  },
@@ -1757,7 +1762,7 @@ function getDimension() {
1757
1762
  }
1758
1763
  return FALLBACK_DIMENSION;
1759
1764
  }
1760
- function attachOnChange$2() {
1765
+ function attachOnChange$4() {
1761
1766
  dimensionRef = getDimension();
1762
1767
  EventListener.add(globalThis, { type: 'resize', callback: onResize });
1763
1768
  if (typeof globalThis.screen.orientation.addEventListener === 'function')
@@ -1767,7 +1772,7 @@ function attachOnChange$2() {
1767
1772
  else if (MEDIA_QUERY_LIST.media !== 'not all')
1768
1773
  EventListener.add(MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
1769
1774
  }
1770
- function detachOnChange$2() {
1775
+ function detachOnChange$4() {
1771
1776
  dimensionRef = null;
1772
1777
  EventListener.remove(globalThis, { type: 'resize', callback: onResize });
1773
1778
  if (typeof globalThis.screen.orientation.removeEventListener === 'function')
@@ -1780,7 +1785,7 @@ function detachOnChange$2() {
1780
1785
  function onResize() {
1781
1786
  var dimension = getDimension();
1782
1787
  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)
1783
- onChangeSubscriptionManager$2.emit(dimensionRef = dimension);
1788
+ onChangeSubscriptionManager$4.emit(dimensionRef = dimension);
1784
1789
  }
1785
1790
 
1786
1791
  function createCustomError(name, Base) {
@@ -1867,7 +1872,20 @@ function createCustomError(name, Base) {
1867
1872
 
1868
1873
  var NotSupportedError = createCustomError('NotSupportedError');
1869
1874
 
1870
- var FS_BRIDGED_KEY = Symbol('fsBridged');
1875
+ var InvalidStateError = createCustomError('InvalidStateError');
1876
+
1877
+ var videoElement$1 = null;
1878
+ var lastFallbackVideoElement$1 = null;
1879
+ var eventsBridged$1 = false;
1880
+ var FS_BRIDGE_KEY = (function () {
1881
+ if (typeof Symbol === 'function') {
1882
+ var existing = globalThis.__nativeFnFsBridgeKey__;
1883
+ if (typeof existing === 'symbol')
1884
+ return existing;
1885
+ return globalThis.__nativeFnFsBridgeKey__ = Symbol('native.fn.fs.bridged');
1886
+ }
1887
+ return '__nativeFnFsBridged__';
1888
+ }());
1871
1889
  var API_VARIANTS = {
1872
1890
  standard: {
1873
1891
  enabled: 'fullscreenEnabled',
@@ -1899,6 +1917,40 @@ var API_VARIANTS = {
1899
1917
  },
1900
1918
  };
1901
1919
  var api = detectApi();
1920
+ var onChangeSubscriptionManager$3 = createSubscriptionManager(attachOnChange$3, detachOnChange$3);
1921
+ var onErrorSubscriptionManager$1 = createSubscriptionManager(attachOnError$1, detachOnError$1);
1922
+ var Fullscreen = {
1923
+ get supported() {
1924
+ return getSupported$1();
1925
+ },
1926
+ get element() {
1927
+ return getElement$1();
1928
+ },
1929
+ get isActive() {
1930
+ return getIsActive$1();
1931
+ },
1932
+ request: request$3,
1933
+ exit: exit$1,
1934
+ toggle: toggle$1,
1935
+ onChange: onChange$1,
1936
+ onError: onError$1,
1937
+ Constants: {},
1938
+ Errors: {
1939
+ NotSupportedError: NotSupportedError,
1940
+ InvalidStateError: InvalidStateError,
1941
+ },
1942
+ };
1943
+ function getHTMLVideoElement$1() {
1944
+ var selected = globalThis.document.querySelector('video');
1945
+ if (selected !== null)
1946
+ return selected;
1947
+ if (videoElement$1 === null)
1948
+ return videoElement$1 = globalThis.document.createElement('video');
1949
+ return videoElement$1;
1950
+ }
1951
+ function hasStandardApi$1() {
1952
+ return api !== null;
1953
+ }
1902
1954
  function detectApi() {
1903
1955
  var element = globalThis.document.documentElement;
1904
1956
  if (typeof globalThis.document.fullscreenEnabled !== 'undefined' || typeof globalThis.document.exitFullscreen !== 'undefined')
@@ -1915,287 +1967,306 @@ function detectApi() {
1915
1967
  }
1916
1968
  return null;
1917
1969
  }
1918
- function createFullscreen() {
1919
- var lastIOSVideo = null;
1920
- var eventsBridged = false;
1921
- var activeOperation = null;
1922
- var pendingQueue = [];
1923
- var lastIntendedOperation = 'exit';
1924
- var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
1925
- var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
1926
- function getDefaultTarget() {
1927
- if (Platform.os.name === OS.iOS) {
1928
- var video = globalThis.document.querySelector('video');
1929
- if (video === null)
1930
- return undefined;
1970
+ function getDefaultTarget$1() {
1971
+ if (Platform.os.name === OS.iOS) {
1972
+ var video = globalThis.document.querySelector('video');
1973
+ if (video !== null)
1931
1974
  return video;
1932
- }
1933
- return globalThis.document.documentElement;
1934
- }
1935
- function bridgeEvents() {
1936
- if (eventsBridged)
1937
- return;
1938
- eventsBridged = true;
1939
- if (Platform.os.name === OS.iOS) {
1940
- bridgeIOSVideoEvents();
1941
- if (typeof globalThis.MutationObserver !== 'undefined') {
1942
- var observer = new MutationObserver(function () {
1943
- bridgeIOSVideoEvents();
1944
- });
1945
- observer.observe(globalThis.document.documentElement, {
1946
- childList: true,
1947
- subtree: true,
1948
- });
1949
- }
1950
- }
1951
- }
1952
- function bridgeIOSVideoEvents() {
1953
- if (typeof globalThis.document === 'undefined')
1954
- return;
1955
- var videos = globalThis.document.querySelectorAll('video');
1956
- videos.forEach(function (video) {
1957
- if (video[FS_BRIDGED_KEY] === true || !(typeof video.webkitEnterFullscreen !== 'undefined' || typeof video.onwebkitbeginfullscreen !== 'undefined'))
1958
- return;
1959
- EventListener.add(video, {
1960
- type: 'webkitbeginfullscreen',
1961
- callback: onChangeSubscriptionManager.emit,
1962
- options: false,
1963
- });
1964
- EventListener.add(video, {
1965
- type: 'webkitendfullscreen',
1966
- callback: onChangeSubscriptionManager.emit,
1967
- options: false,
1968
- });
1969
- video[FS_BRIDGED_KEY] = true;
1970
- });
1971
- }
1972
- function attachOnChange() {
1973
- var events = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'];
1974
- for (var i = 0; i < events.length; i++) {
1975
- EventListener.add(globalThis.document, {
1976
- type: events[i],
1977
- callback: onChangeSubscriptionManager.emit,
1978
- options: false,
1979
- });
1980
- }
1981
- }
1982
- function detachOnChange() {
1983
- var events = ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'];
1984
- for (var i = 0; i < events.length; i++) {
1985
- EventListener.remove(globalThis.document, {
1986
- type: events[i],
1987
- callback: onChangeSubscriptionManager.emit,
1988
- options: false,
1989
- });
1990
- }
1991
- }
1992
- function attachOnError() {
1993
- var events = ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'];
1994
- for (var i = 0; i < events.length; i++) {
1995
- EventListener.add(globalThis.document, {
1996
- type: events[i],
1997
- callback: onErrorSubscriptionManager.emit,
1998
- options: false,
1999
- });
2000
- }
2001
- }
2002
- function detachOnError() {
2003
- var events = ['fullscreenerror', 'webkitfullscreenerror', 'mozfullscreenerror', 'MSFullscreenError'];
2004
- for (var i = 0; i < events.length; i++) {
2005
- EventListener.remove(globalThis.document, {
2006
- type: events[i],
2007
- callback: onErrorSubscriptionManager.emit,
2008
- options: false,
2009
- });
2010
- }
1975
+ return undefined;
2011
1976
  }
2012
- function getEnabled() {
2013
- if (api === null)
2014
- return (Platform.os.name === OS.iOS && globalThis.HTMLVideoElement.prototype.webkitSupportsFullscreen === true);
1977
+ return globalThis.document.documentElement;
1978
+ }
1979
+ function getSupported$1() {
1980
+ if (api !== null)
2015
1981
  return globalThis.document[api.enabled] === true;
2016
- }
2017
- function getElement() {
2018
- if (api === null) {
2019
- if (lastIOSVideo !== null && lastIOSVideo.webkitDisplayingFullscreen === true)
2020
- return lastIOSVideo;
2021
- return null;
2022
- }
2023
- var currentElement = globalThis.document[api.element];
2024
- if (typeof currentElement !== 'undefined')
2025
- return currentElement;
1982
+ if (Platform.os.name !== OS.iOS)
1983
+ return false;
1984
+ var video = getHTMLVideoElement$1();
1985
+ return video.webkitSupportsFullscreen === true || typeof video.webkitEnterFullscreen === 'function';
1986
+ }
1987
+ function getElement$1() {
1988
+ if (api === null) {
1989
+ if (lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true)
1990
+ return lastFallbackVideoElement$1;
2026
1991
  return null;
2027
1992
  }
2028
- function getIsFullscreen() {
2029
- return getElement() !== null;
2030
- }
2031
- function drainPendingOperation() {
2032
- var entry = pendingQueue.shift();
2033
- if (typeof entry === 'undefined') {
2034
- activeOperation = null;
2035
- return;
2036
- }
2037
- var next;
2038
- if (entry.operation === 'request')
2039
- next = requestImmediately(entry.target, entry.options);
2040
- else
2041
- next = exitImmediately();
2042
- activeOperation = next
2043
- .then(function () {
2044
- entry.resolve();
2045
- drainPendingOperation();
2046
- })
2047
- .catch(function (error) {
2048
- entry.reject(error);
2049
- drainPendingOperation();
2050
- });
2051
- }
2052
- function request(target, options) {
2053
- lastIntendedOperation = 'request';
2054
- if (activeOperation === null) {
2055
- var next = requestImmediately(target, options);
2056
- activeOperation = next
2057
- .then(drainPendingOperation)
2058
- .catch(drainPendingOperation);
2059
- return next;
2060
- }
2061
- return new Promise(function (resolve, reject) {
2062
- pendingQueue.push({
2063
- operation: 'request',
2064
- target: target,
2065
- options: options,
2066
- resolve: resolve,
2067
- reject: reject,
2068
- });
2069
- });
2070
- }
2071
- function exit() {
2072
- lastIntendedOperation = 'exit';
2073
- if (activeOperation === null) {
2074
- var next = exitImmediately();
2075
- activeOperation = next
2076
- .then(drainPendingOperation)
2077
- .catch(drainPendingOperation);
2078
- return next;
2079
- }
2080
- return new Promise(function (resolve, reject) {
2081
- pendingQueue.push({
2082
- operation: 'exit',
2083
- target: undefined,
2084
- options: undefined,
2085
- resolve: resolve,
2086
- reject: reject,
2087
- });
2088
- });
2089
- }
2090
- function requestImmediately(target, options) {
2091
- return new Promise(function (resolve, reject) {
2092
- if (typeof target === 'undefined')
2093
- target = getDefaultTarget();
2094
- if (typeof target === 'undefined')
2095
- return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
2096
- var tagName = target.tagName.toLowerCase();
2097
- function fallbackToIOSVideo() {
2098
- if (Platform.os.name === OS.iOS && typeof target !== 'undefined' && target.tagName.toUpperCase() === 'VIDEO') {
2099
- var video = target;
2100
- if (video.webkitSupportsFullscreen === true && typeof video.webkitEnterFullscreen === 'function') {
2101
- lastIOSVideo = video;
2102
- bridgeIOSVideoEvents();
2103
- video.webkitEnterFullscreen();
2104
- return resolve();
1993
+ var currentElement = globalThis.document[api.element];
1994
+ if (typeof currentElement !== 'undefined')
1995
+ return currentElement;
1996
+ return null;
1997
+ }
1998
+ function getIsActive$1() {
1999
+ return getElement$1() !== null;
2000
+ }
2001
+ function createEventPayload(nativeEvent, element, isActive) {
2002
+ return {
2003
+ nativeEvent: nativeEvent,
2004
+ element: element,
2005
+ isActive: isActive,
2006
+ };
2007
+ }
2008
+ function emitChange$1(nativeEvent, element, isActive) {
2009
+ onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element, isActive));
2010
+ }
2011
+ function emitError$1(nativeEvent, element, isActive) {
2012
+ onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element, isActive));
2013
+ }
2014
+ function onFullscreenChange(event) {
2015
+ var target = event.target;
2016
+ if (target instanceof globalThis.Element)
2017
+ emitChange$1(event, target, getIsActive$1());
2018
+ if (target instanceof globalThis.Document)
2019
+ emitChange$1(event, globalThis.document.documentElement, getIsActive$1());
2020
+ }
2021
+ function onFullscreenError(event) {
2022
+ var target = event.target;
2023
+ if (target instanceof globalThis.Element)
2024
+ emitError$1(event, target, getIsActive$1());
2025
+ if (target instanceof globalThis.Document)
2026
+ emitError$1(event, globalThis.document.documentElement, getIsActive$1());
2027
+ }
2028
+ function onIOSBeginFullscreen(event) {
2029
+ lastFallbackVideoElement$1 = this;
2030
+ emitChange$1(event, this, true);
2031
+ }
2032
+ function onIOSEndFullscreen(event) {
2033
+ if (lastFallbackVideoElement$1 === this)
2034
+ lastFallbackVideoElement$1 = null;
2035
+ emitChange$1(event, this, false);
2036
+ }
2037
+ function bridgeSingleVideoNode$1(video) {
2038
+ if (video[FS_BRIDGE_KEY])
2039
+ return;
2040
+ if (typeof video.webkitEnterFullscreen === 'undefined' && typeof video.onwebkitbeginfullscreen === 'undefined')
2041
+ return;
2042
+ EventListener.add(video, { type: 'webkitbeginfullscreen', callback: onIOSBeginFullscreen, options: false });
2043
+ EventListener.add(video, { type: 'webkitendfullscreen', callback: onIOSEndFullscreen, options: false });
2044
+ video[FS_BRIDGE_KEY] = true;
2045
+ }
2046
+ function bridgeIOSVideoEvents() {
2047
+ var videos = globalThis.document.querySelectorAll('video');
2048
+ for (var i = 0; i < videos.length; i++)
2049
+ bridgeSingleVideoNode$1(videos[i]);
2050
+ }
2051
+ function bridgeEvents$1() {
2052
+ if (eventsBridged$1)
2053
+ return;
2054
+ eventsBridged$1 = true;
2055
+ if (Platform.os.name !== OS.iOS)
2056
+ return;
2057
+ bridgeIOSVideoEvents();
2058
+ if (typeof globalThis.MutationObserver === 'undefined')
2059
+ return;
2060
+ var observer = new globalThis.MutationObserver(function (records) {
2061
+ if (lastFallbackVideoElement$1 !== null) {
2062
+ var removed = false;
2063
+ for (var i = 0; i < records.length; i++) {
2064
+ var removedNodes = records[i].removedNodes;
2065
+ for (var j = 0; j < removedNodes.length; j++) {
2066
+ var node = removedNodes[j];
2067
+ if (node === lastFallbackVideoElement$1 || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement$1))) {
2068
+ removed = true;
2069
+ break;
2105
2070
  }
2106
2071
  }
2107
- reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2072
+ if (removed)
2073
+ break;
2074
+ }
2075
+ if (removed && !globalThis.document.contains(lastFallbackVideoElement$1))
2076
+ lastFallbackVideoElement$1 = null;
2077
+ }
2078
+ for (var i = 0; i < records.length; i++) {
2079
+ var addedNodes = records[i].addedNodes;
2080
+ for (var j = 0; j < addedNodes.length; j++) {
2081
+ var node = addedNodes[j];
2082
+ if (node.nodeType !== Node.ELEMENT_NODE)
2083
+ continue;
2084
+ var element = node;
2085
+ if (element.tagName === 'VIDEO') {
2086
+ bridgeSingleVideoNode$1(element);
2087
+ continue;
2088
+ }
2089
+ var nested = element.querySelectorAll('video');
2090
+ for (var k = 0; k < nested.length; k++)
2091
+ bridgeSingleVideoNode$1(nested[k]);
2108
2092
  }
2109
- if (api !== null) {
2110
- var method = target[api.request];
2111
- if (typeof method === 'function') {
2112
- var result = method.call(target, options);
2113
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
2114
- result
2115
- .then(resolve)
2116
- .catch(function () {
2093
+ }
2094
+ });
2095
+ observer.observe(globalThis.document.documentElement, { childList: true, subtree: true });
2096
+ }
2097
+ function attachOnChange$3() {
2098
+ if (api != null)
2099
+ EventListener.add(globalThis.document, { type: api.events.change, callback: onFullscreenChange, options: false });
2100
+ if (Platform.os.name === OS.iOS)
2101
+ bridgeIOSVideoEvents();
2102
+ }
2103
+ function detachOnChange$3() {
2104
+ if (api != null)
2105
+ EventListener.remove(globalThis.document, { type: api.events.change, callback: onFullscreenChange, options: false });
2106
+ if (Platform.os.name !== OS.iOS)
2107
+ return;
2108
+ var videos = globalThis.document.querySelectorAll('video');
2109
+ for (var i = 0; i < videos.length; i++) {
2110
+ EventListener.remove(videos[i], { type: 'webkitbeginfullscreen', callback: onIOSBeginFullscreen, options: false });
2111
+ EventListener.remove(videos[i], { type: 'webkitendfullscreen', callback: onIOSEndFullscreen, options: false });
2112
+ videos[i][FS_BRIDGE_KEY] = false;
2113
+ }
2114
+ }
2115
+ function attachOnError$1() {
2116
+ if (api != null)
2117
+ EventListener.add(globalThis.document, { type: api.events.error, callback: onFullscreenError, options: false });
2118
+ }
2119
+ function detachOnError$1() {
2120
+ if (api != null)
2121
+ EventListener.remove(globalThis.document, { type: api.events.error, callback: onFullscreenError, options: false });
2122
+ }
2123
+ function request$3(target, options) {
2124
+ return new Promise(function (resolve, reject) {
2125
+ if (typeof target === 'undefined')
2126
+ target = getDefaultTarget$1();
2127
+ if (typeof target === 'undefined')
2128
+ return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
2129
+ if (getIsActive$1() && getElement$1() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
2130
+ return reject(new NotSupportedError('There is already a Fullscreen element in this document.'));
2131
+ var tagName = target.tagName.toLowerCase();
2132
+ var isIOSFullscreenActive = lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true;
2133
+ if (api !== null) {
2134
+ var method = target[api.request];
2135
+ if (typeof method === 'function' && !isIOSFullscreenActive) {
2136
+ var result = method.call(target, options);
2137
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
2138
+ result
2139
+ .then(resolve)
2140
+ .catch(function () {
2141
+ try {
2117
2142
  if (Platform.os.name !== OS.iOS)
2118
2143
  return reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2119
2144
  fallbackToIOSVideo();
2145
+ }
2146
+ catch (e) {
2147
+ reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2148
+ }
2149
+ });
2150
+ return;
2151
+ }
2152
+ return resolve();
2153
+ }
2154
+ }
2155
+ function fallbackToIOSVideo() {
2156
+ if (Platform.os.name === OS.iOS && typeof target !== 'undefined' && target.tagName.toUpperCase() === 'VIDEO') {
2157
+ var video_1 = target;
2158
+ if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function') {
2159
+ if (!hasStandardApi$1())
2160
+ bridgeSingleVideoNode$1(video_1);
2161
+ if (video_1.played.length === 0) {
2162
+ video_1.play()
2163
+ .then(function () {
2164
+ try {
2165
+ if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function')
2166
+ video_1.webkitEnterFullscreen();
2167
+ }
2168
+ catch (e) {
2169
+ return reject(new InvalidStateError('The object is in an invalid state.'));
2170
+ }
2120
2171
  });
2121
- return;
2122
2172
  }
2173
+ else {
2174
+ try {
2175
+ video_1.webkitEnterFullscreen();
2176
+ }
2177
+ catch (e) {
2178
+ return reject(new InvalidStateError('The object is in an invalid state.'));
2179
+ }
2180
+ }
2181
+ lastFallbackVideoElement$1 = video_1;
2123
2182
  return resolve();
2124
2183
  }
2125
2184
  }
2126
- fallbackToIOSVideo();
2127
- });
2128
- }
2129
- function exitImmediately() {
2130
- return new Promise(function (resolve, reject) {
2131
- if (getElement() === null && lastIOSVideo === null)
2132
- return resolve();
2133
- function fallbackToIOSVideo() {
2134
- if (Platform.os.name === OS.iOS) {
2135
- var candidates = void 0;
2136
- if (lastIOSVideo !== null)
2137
- candidates = [lastIOSVideo];
2138
- else
2139
- candidates = globalThis.document.querySelectorAll('video');
2140
- for (var i = 0; i < candidates.length; i++) {
2141
- var video = candidates[i];
2142
- if (typeof video.webkitExitFullscreen === 'function' && video.webkitDisplayingFullscreen === true) {
2143
- video.webkitExitFullscreen();
2144
- lastIOSVideo = null;
2145
- return resolve();
2146
- }
2147
- }
2185
+ reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
2186
+ }
2187
+ fallbackToIOSVideo();
2188
+ });
2189
+ }
2190
+ function exit$1() {
2191
+ return new Promise(function (resolve, reject) {
2192
+ if (api !== null) {
2193
+ var method = globalThis.document[api.exit];
2194
+ if (typeof method === 'function') {
2195
+ var result = method.call(globalThis.document);
2196
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
2197
+ result
2198
+ .then(resolve)
2199
+ .catch(resolve);
2200
+ return;
2148
2201
  }
2202
+ return resolve();
2203
+ }
2204
+ }
2205
+ function fallbackToIOSVideo() {
2206
+ if (Platform.os.name !== OS.iOS) {
2149
2207
  reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2208
+ return;
2150
2209
  }
2151
- if (api !== null) {
2152
- var method = globalThis.document[api.exit];
2153
- if (typeof method === 'function') {
2154
- var result = method.call(globalThis.document);
2155
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
2156
- result
2157
- .then(resolve)
2158
- .catch(function () {
2159
- if (Platform.os.name !== OS.iOS)
2160
- return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2161
- fallbackToIOSVideo();
2162
- });
2163
- return;
2164
- }
2210
+ var target = lastFallbackVideoElement$1;
2211
+ if (target !== null && typeof target.webkitExitFullscreen === 'function' && target.webkitDisplayingFullscreen === true) {
2212
+ target.webkitExitFullscreen();
2213
+ if (target.webkitDisplayingFullscreen)
2214
+ return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2215
+ lastFallbackVideoElement$1 = null;
2216
+ return resolve();
2217
+ }
2218
+ var videos = globalThis.document.querySelectorAll('video');
2219
+ for (var i = 0; i < videos.length; i++) {
2220
+ var video = videos[i];
2221
+ if (typeof video.webkitExitFullscreen === 'function' && video.webkitDisplayingFullscreen === true) {
2222
+ video.webkitExitFullscreen();
2223
+ if (video.webkitDisplayingFullscreen)
2224
+ return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2225
+ lastFallbackVideoElement$1 = null;
2165
2226
  return resolve();
2166
2227
  }
2167
2228
  }
2168
- fallbackToIOSVideo();
2169
- });
2170
- }
2171
- function toggle(target, options) {
2172
- if (lastIntendedOperation === 'request')
2173
- return exit();
2174
- return request(target, options);
2175
- }
2176
- bridgeEvents();
2177
- return {
2178
- get supported() {
2179
- return getEnabled();
2180
- },
2181
- get element() {
2182
- return getElement();
2183
- },
2184
- get isFullscreen() {
2185
- return getIsFullscreen();
2186
- },
2187
- request: request,
2188
- exit: exit,
2189
- toggle: toggle,
2190
- onChange: onChangeSubscriptionManager.subscribe,
2191
- onError: onErrorSubscriptionManager.subscribe,
2192
- Constants: {},
2193
- Errors: {
2194
- NotSupportedError: NotSupportedError,
2195
- },
2196
- };
2229
+ if (getElement$1() === null)
2230
+ return resolve();
2231
+ reject(new NotSupportedError('Failed to exit fullscreen mode.'));
2232
+ }
2233
+ fallbackToIOSVideo();
2234
+ });
2197
2235
  }
2198
- var Fullscreen = createFullscreen();
2236
+ function toggle$1(target, options) {
2237
+ var current = getElement$1();
2238
+ if (typeof target !== 'undefined') {
2239
+ if (current === target)
2240
+ return this.exit();
2241
+ return this.request(target, options);
2242
+ }
2243
+ if (current !== null)
2244
+ return this.exit();
2245
+ return this.request(undefined, options);
2246
+ }
2247
+ function onChange$1(targetOrListener, listenerOrOptions, options) {
2248
+ if (typeof targetOrListener === 'function')
2249
+ return onChangeSubscriptionManager$3.subscribe(targetOrListener, listenerOrOptions);
2250
+ var target = targetOrListener;
2251
+ var listener = listenerOrOptions;
2252
+ function wrappedListener(payload) {
2253
+ if (payload.element === target)
2254
+ listener(payload);
2255
+ }
2256
+ return onChangeSubscriptionManager$3.subscribe(wrappedListener, options);
2257
+ }
2258
+ function onError$1(targetOrListener, listenerOrOptions, options) {
2259
+ if (typeof targetOrListener === 'function')
2260
+ return onErrorSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
2261
+ var target = targetOrListener;
2262
+ var listener = listenerOrOptions;
2263
+ function wrappedListener(payload) {
2264
+ if (payload.element === target)
2265
+ listener(payload);
2266
+ }
2267
+ return onErrorSubscriptionManager$1.subscribe(wrappedListener, options);
2268
+ }
2269
+ bridgeEvents$1();
2199
2270
 
2200
2271
  var PermissionType;
2201
2272
  (function (PermissionType) {
@@ -2237,7 +2308,10 @@ var GET_USER_MEDIA = (function () {
2237
2308
  })();
2238
2309
 
2239
2310
  var Permission = {
2240
- request: request$1,
2311
+ get supported() {
2312
+ return supported$5();
2313
+ },
2314
+ request: request$2,
2241
2315
  check: check,
2242
2316
  Constants: {
2243
2317
  PermissionType: PermissionType,
@@ -2245,7 +2319,10 @@ var Permission = {
2245
2319
  },
2246
2320
  Errors: {},
2247
2321
  };
2248
- function request$1(type) {
2322
+ function supported$5() {
2323
+ return typeof globalThis.navigator.permissions !== 'undefined';
2324
+ }
2325
+ function request$2(type) {
2249
2326
  var instance = this;
2250
2327
  return new Promise(function (resolve) {
2251
2328
  function resolveAfterCheck() {
@@ -2335,7 +2412,7 @@ function check(type) {
2335
2412
 
2336
2413
  var PermissionNotGrantedError = createCustomError('PermissionNotGrantedError');
2337
2414
 
2338
- function request(url, options) {
2415
+ function request$1(url, options) {
2339
2416
  return new Promise(function (resolve) {
2340
2417
  var method = 'GET';
2341
2418
  var headers = {};
@@ -2417,7 +2494,7 @@ function assign() {
2417
2494
  return to;
2418
2495
  }
2419
2496
 
2420
- var onChangeSubscriptionManager$1 = createSubscriptionManager(attachOnChange$1, detachOnChange$1);
2497
+ var onChangeSubscriptionManager$2 = createSubscriptionManager(attachOnChange$2, detachOnChange$2);
2421
2498
  var watchIdRef = null;
2422
2499
  var Geolocation = {
2423
2500
  get value() {
@@ -2426,7 +2503,7 @@ var Geolocation = {
2426
2503
  get supported() {
2427
2504
  return supported$4();
2428
2505
  },
2429
- onChange: onChangeSubscriptionManager$1.subscribe,
2506
+ onChange: onChangeSubscriptionManager$2.subscribe,
2430
2507
  Constants: {},
2431
2508
  Errors: {
2432
2509
  NotSupportedError: NotSupportedError,
@@ -2463,7 +2540,7 @@ function getValue$1() {
2463
2540
  }
2464
2541
  function getFallbackValue(error) {
2465
2542
  return new Promise(function (resolve, reject) {
2466
- request('http://ip-api.com/json?fields=lat,lon')
2543
+ request$1('http://ip-api.com/json?fields=lat,lon')
2467
2544
  .then(function (response) {
2468
2545
  if (typeof response !== 'undefined') {
2469
2546
  var coordinate_1 = {
@@ -2502,7 +2579,7 @@ function normalizeError(error) {
2502
2579
  return new NotSupportedError('Unknown error.');
2503
2580
  }
2504
2581
  }
2505
- function attachOnChange$1() {
2582
+ function attachOnChange$2() {
2506
2583
  if (!supported$4())
2507
2584
  return;
2508
2585
  Permission
@@ -2515,13 +2592,13 @@ function attachOnChange$1() {
2515
2592
  }
2516
2593
  });
2517
2594
  }
2518
- function detachOnChange$1() {
2595
+ function detachOnChange$2() {
2519
2596
  if (!supported$4() || watchIdRef === null)
2520
2597
  return;
2521
2598
  globalThis.navigator.geolocation.clearWatch(watchIdRef);
2522
2599
  }
2523
2600
  function onGeolocationCoordinatesChange(coordinates) {
2524
- onChangeSubscriptionManager$1.emit(coordinates);
2601
+ onChangeSubscriptionManager$2.emit(coordinates);
2525
2602
  }
2526
2603
  function supported$4() {
2527
2604
  return typeof globalThis.navigator.geolocation !== 'undefined';
@@ -3972,16 +4049,19 @@ function removeThemeColor() {
3972
4049
  }
3973
4050
 
3974
4051
  var Vibration = {
3975
- run: run,
3976
- stop: stop,
3977
4052
  get supported() {
3978
4053
  return supported$3();
3979
4054
  },
4055
+ run: run,
4056
+ stop: stop,
3980
4057
  Constants: {},
3981
4058
  Errors: {
3982
4059
  NotSupportedError: NotSupportedError,
3983
4060
  },
3984
4061
  };
4062
+ function supported$3() {
4063
+ return typeof globalThis.navigator.vibrate !== 'undefined';
4064
+ }
3985
4065
  function run(pattern) {
3986
4066
  if (supported$3())
3987
4067
  return globalThis.navigator.vibrate(pattern);
@@ -3990,313 +4070,329 @@ function run(pattern) {
3990
4070
  function stop() {
3991
4071
  return this.run(0);
3992
4072
  }
3993
- function supported$3() {
3994
- return typeof globalThis.navigator.vibrate !== 'undefined';
3995
- }
3996
4073
 
3997
- var PIP_BRIDGED_KEY = Symbol('pipBridged');
3998
4074
  var PIP_PRESENTATION_MODE = 'picture-in-picture';
3999
4075
  var INLINE_PRESENTATION_MODE = 'inline';
4000
- function hasStandardPipEvents() {
4076
+ var videoElement = null;
4077
+ var lastFallbackVideoElement = null;
4078
+ var eventsBridged = false;
4079
+ var PIP_BRIDGE_KEY = (function () {
4080
+ if (typeof Symbol === 'function') {
4081
+ var existing = globalThis.__nativeFnPipBridgeKey__;
4082
+ if (typeof existing === 'symbol')
4083
+ return existing;
4084
+ return globalThis.__nativeFnPipBridgeKey__ = Symbol('native.fn.pip.bridged');
4085
+ }
4086
+ return '__nativeFnPipBridged__';
4087
+ }());
4088
+ var onChangeSubscriptionManager$1 = createSubscriptionManager(attachOnChange$1, detachOnChange$1);
4089
+ var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
4090
+ var Pip = {
4091
+ get supported() {
4092
+ return getSupported();
4093
+ },
4094
+ get element() {
4095
+ return getElement();
4096
+ },
4097
+ get isActive() {
4098
+ return getIsActive();
4099
+ },
4100
+ request: request,
4101
+ exit: exit,
4102
+ toggle: toggle,
4103
+ onChange: onChange,
4104
+ onError: onError,
4105
+ Constants: {},
4106
+ Errors: {
4107
+ NotSupportedError: NotSupportedError,
4108
+ InvalidStateError: InvalidStateError,
4109
+ },
4110
+ };
4111
+ function getHTMLVideoElement() {
4112
+ var selected = globalThis.document.querySelector('video');
4113
+ if (selected !== null)
4114
+ return selected;
4115
+ if (videoElement === null)
4116
+ return videoElement = globalThis.document.createElement('video');
4117
+ return videoElement;
4118
+ }
4119
+ function hasStandardApi() {
4001
4120
  return typeof globalThis.document.pictureInPictureEnabled !== 'undefined';
4002
4121
  }
4003
- function createPip() {
4004
- var lastPipVideo = null;
4005
- var eventsBridged = false;
4006
- var activeOperation = null;
4007
- var pendingQueue = [];
4008
- var lastIntendedOperation = 'exit';
4009
- var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
4010
- var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
4011
- function getEnabled() {
4012
- if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
4013
- return globalThis.document.pictureInPictureEnabled;
4014
- if (typeof HTMLVideoElement === 'undefined')
4015
- return false;
4016
- var videos = globalThis.document.querySelectorAll('video');
4017
- for (var i = 0; i < videos.length; i++) {
4018
- var video = videos[i];
4019
- if (typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE))
4020
- return true;
4021
- }
4022
- return false;
4023
- }
4024
- function getElement() {
4025
- var currentElement = globalThis.document.pictureInPictureElement;
4026
- if (currentElement !== null && typeof currentElement !== 'undefined')
4027
- return currentElement;
4028
- if (lastPipVideo !== null && lastPipVideo.webkitPresentationMode === PIP_PRESENTATION_MODE)
4029
- return lastPipVideo;
4030
- return null;
4031
- }
4032
- function getIsPip() {
4033
- return getElement() !== null;
4034
- }
4035
- function getDefaultTarget() {
4036
- var video = globalThis.document.querySelector('video');
4037
- if (video === null)
4038
- return undefined;
4122
+ function hasWebkitApi() {
4123
+ return typeof getHTMLVideoElement().webkitSetPresentationMode === 'function';
4124
+ }
4125
+ function getDefaultTarget() {
4126
+ var video = globalThis.document.querySelector('video');
4127
+ if (video !== null)
4039
4128
  return video;
4129
+ return undefined;
4130
+ }
4131
+ function createPipEventPayload(nativeEvent, element, isActive) {
4132
+ return {
4133
+ nativeEvent: nativeEvent,
4134
+ element: element,
4135
+ isActive: isActive
4136
+ };
4137
+ }
4138
+ function emitChange(nativeEvent, element, isActive) {
4139
+ onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element, isActive));
4140
+ }
4141
+ function emitError(nativeEvent, element, isActive) {
4142
+ onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
4143
+ }
4144
+ function onEnterPictureInPicture(event) {
4145
+ var target = event.target;
4146
+ if (target instanceof globalThis.HTMLVideoElement)
4147
+ emitChange(event, target, true);
4148
+ }
4149
+ function onLeavePictureInPicture(event) {
4150
+ var target = event.target;
4151
+ if (target instanceof globalThis.HTMLVideoElement)
4152
+ emitChange(event, target, false);
4153
+ }
4154
+ function onPictureInPictureError(event) {
4155
+ var target = event.target;
4156
+ if (target instanceof globalThis.HTMLVideoElement)
4157
+ emitError(event, target, getIsActive());
4158
+ }
4159
+ function onWebkitPresentationModeChanged(event) {
4160
+ if (this.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4161
+ lastFallbackVideoElement = this;
4162
+ emitChange(event, this, true);
4163
+ return;
4040
4164
  }
4041
- function onWebkitPresentationModeChanged(event) {
4042
- if (this.webkitPresentationMode === PIP_PRESENTATION_MODE || (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastPipVideo === this))
4043
- onChangeSubscriptionManager.emit(event);
4165
+ if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastFallbackVideoElement === this) {
4166
+ lastFallbackVideoElement = null;
4167
+ emitChange(event, this, false);
4044
4168
  }
4045
- function bridgeEvents() {
4046
- if (eventsBridged)
4047
- return;
4048
- eventsBridged = true;
4049
- if (!hasStandardPipEvents()) {
4050
- bridgeWebkitVideoEvents();
4051
- if (typeof globalThis.MutationObserver !== 'undefined') {
4052
- var observer = new MutationObserver(function () {
4053
- bridgeWebkitVideoEvents();
4054
- });
4055
- observer.observe(globalThis.document.documentElement, {
4056
- childList: true,
4057
- subtree: true,
4058
- });
4169
+ }
4170
+ function bridgeSingleVideoNode(video) {
4171
+ if (video[PIP_BRIDGE_KEY])
4172
+ return;
4173
+ if (typeof video.webkitSetPresentationMode === 'undefined' && typeof video.onwebkitpresentationmodechanged === 'undefined')
4174
+ return;
4175
+ EventListener.add(video, { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
4176
+ video[PIP_BRIDGE_KEY] = true;
4177
+ }
4178
+ function bridgeWebkitVideoEvents() {
4179
+ var videos = globalThis.document.querySelectorAll('video');
4180
+ for (var i = 0; i < videos.length; i++)
4181
+ bridgeSingleVideoNode(videos[i]);
4182
+ }
4183
+ function bridgeEvents() {
4184
+ if (eventsBridged)
4185
+ return;
4186
+ eventsBridged = true;
4187
+ if (hasStandardApi() && !hasWebkitApi())
4188
+ return;
4189
+ bridgeWebkitVideoEvents();
4190
+ if (typeof globalThis.MutationObserver === 'undefined')
4191
+ return;
4192
+ var observer = new globalThis.MutationObserver(function (records) {
4193
+ if (lastFallbackVideoElement !== null) {
4194
+ var removed = false;
4195
+ for (var i = 0; i < records.length; i++) {
4196
+ var removedNodes = records[i].removedNodes;
4197
+ for (var j = 0; j < removedNodes.length; j++) {
4198
+ var node = removedNodes[j];
4199
+ if (node === lastFallbackVideoElement || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement))) {
4200
+ removed = true;
4201
+ break;
4202
+ }
4203
+ }
4204
+ if (removed)
4205
+ break;
4059
4206
  }
4207
+ if (removed && !globalThis.document.contains(lastFallbackVideoElement))
4208
+ lastFallbackVideoElement = null;
4060
4209
  }
4061
- }
4062
- function bridgeWebkitVideoEvents() {
4063
- if (typeof globalThis.document === 'undefined')
4064
- return;
4065
- var videos = globalThis.document.querySelectorAll('video');
4066
- videos.forEach(function (video) {
4067
- if (video[PIP_BRIDGED_KEY] === true || !(typeof video.webkitSetPresentationMode !== 'undefined' || typeof video.onwebkitpresentationmodechanged !== 'undefined'))
4068
- return;
4069
- EventListener.add(video, {
4070
- type: 'webkitpresentationmodechanged',
4071
- callback: onWebkitPresentationModeChanged,
4072
- options: false,
4073
- });
4074
- video[PIP_BRIDGED_KEY] = true;
4075
- });
4076
- }
4077
- function attachOnChange() {
4078
- if (hasStandardPipEvents()) {
4079
- var changeEvents = ['enterpictureinpicture', 'leavepictureinpicture'];
4080
- for (var i = 0; i < changeEvents.length; i++) {
4081
- EventListener.add(globalThis.document, {
4082
- type: changeEvents[i],
4083
- callback: onChangeSubscriptionManager.emit,
4084
- options: false,
4085
- });
4210
+ for (var i = 0; i < records.length; i++) {
4211
+ var addedNodes = records[i].addedNodes;
4212
+ for (var j = 0; j < addedNodes.length; j++) {
4213
+ var node = addedNodes[j];
4214
+ if (node.nodeType !== Node.ELEMENT_NODE)
4215
+ continue;
4216
+ var element = node;
4217
+ if (element.tagName === 'VIDEO') {
4218
+ bridgeSingleVideoNode(element);
4219
+ continue;
4220
+ }
4221
+ var nested = element.querySelectorAll('video');
4222
+ for (var k = 0; k < nested.length; k++)
4223
+ bridgeSingleVideoNode(nested[k]);
4086
4224
  }
4087
- return;
4088
4225
  }
4089
- bridgeWebkitVideoEvents();
4226
+ });
4227
+ observer.observe(globalThis.document.documentElement, { childList: true, subtree: true });
4228
+ }
4229
+ function attachOnChange$1() {
4230
+ if (hasStandardApi()) {
4231
+ EventListener.add(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
4232
+ EventListener.add(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
4233
+ return;
4090
4234
  }
4091
- function detachOnChange() {
4092
- if (hasStandardPipEvents()) {
4093
- var changeEvents = ['enterpictureinpicture', 'leavepictureinpicture'];
4094
- for (var i = 0; i < changeEvents.length; i++) {
4095
- EventListener.remove(globalThis.document, {
4096
- type: changeEvents[i],
4097
- callback: onChangeSubscriptionManager.emit,
4098
- options: false,
4235
+ bridgeWebkitVideoEvents();
4236
+ }
4237
+ function detachOnChange$1() {
4238
+ if (hasStandardApi()) {
4239
+ EventListener.remove(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
4240
+ EventListener.remove(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
4241
+ return;
4242
+ }
4243
+ var videos = globalThis.document.querySelectorAll('video');
4244
+ for (var i = 0; i < videos.length; i++) {
4245
+ EventListener.remove(videos[i], { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
4246
+ videos[i][PIP_BRIDGE_KEY] = false;
4247
+ }
4248
+ }
4249
+ function attachOnError() {
4250
+ EventListener.add(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
4251
+ }
4252
+ function detachOnError() {
4253
+ EventListener.remove(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
4254
+ }
4255
+ function getSupported() {
4256
+ if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
4257
+ return globalThis.document.pictureInPictureEnabled;
4258
+ var video = getHTMLVideoElement();
4259
+ return typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE);
4260
+ }
4261
+ function getElement() {
4262
+ var currentElement = globalThis.document.pictureInPictureElement;
4263
+ if (currentElement !== null && typeof currentElement !== 'undefined')
4264
+ return currentElement;
4265
+ if (lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE)
4266
+ return lastFallbackVideoElement;
4267
+ return null;
4268
+ }
4269
+ function getIsActive() {
4270
+ return getElement() !== null;
4271
+ }
4272
+ function request(target) {
4273
+ return new Promise(function (resolve, reject) {
4274
+ if (typeof target === 'undefined')
4275
+ target = getDefaultTarget();
4276
+ if (typeof target === 'undefined')
4277
+ return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
4278
+ if (getIsActive() && getElement() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
4279
+ return reject(new NotSupportedError('There is already a Picture-in-Picture element in this document.'));
4280
+ var tagName = target.tagName.toLowerCase();
4281
+ if (tagName !== 'video')
4282
+ return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4283
+ var method = target.requestPictureInPicture;
4284
+ var isWebkitPipActive = lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE;
4285
+ if (typeof method === 'function' && !hasWebkitApi() && !isWebkitPipActive) {
4286
+ var result = method.call(target);
4287
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
4288
+ result
4289
+ .then(resolve)
4290
+ .catch(function () {
4291
+ try {
4292
+ fallbackToWebkit();
4293
+ }
4294
+ catch (e) {
4295
+ reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4296
+ }
4099
4297
  });
4298
+ return;
4100
4299
  }
4101
- return;
4300
+ return resolve();
4102
4301
  }
4103
- var videos = globalThis.document.querySelectorAll('video');
4104
- videos.forEach(function (video) {
4105
- EventListener.remove(video, {
4106
- type: 'webkitpresentationmodechanged',
4107
- callback: onWebkitPresentationModeChanged,
4108
- options: false,
4109
- });
4110
- try {
4111
- delete video[PIP_BRIDGED_KEY];
4112
- }
4113
- catch (_) {
4114
- video[PIP_BRIDGED_KEY] = undefined;
4302
+ function fallbackToWebkit() {
4303
+ if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
4304
+ if (target.disablePictureInPicture)
4305
+ return reject(new NotSupportedError('Picture-in-Picture is disabled on this element.'));
4306
+ bridgeSingleVideoNode(target);
4307
+ target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
4308
+ return resolve();
4115
4309
  }
4116
- });
4117
- }
4118
- function attachOnError() {
4119
- EventListener.add(globalThis.document, {
4120
- type: 'pictureinpictureerror',
4121
- callback: onErrorSubscriptionManager.emit,
4122
- options: false,
4123
- });
4124
- }
4125
- function detachOnError() {
4126
- EventListener.remove(globalThis.document, {
4127
- type: 'pictureinpictureerror',
4128
- callback: onErrorSubscriptionManager.emit,
4129
- options: false,
4130
- });
4131
- }
4132
- function drainPendingOperation() {
4133
- var entry = pendingQueue.shift();
4134
- if (typeof entry === 'undefined') {
4135
- activeOperation = null;
4136
- return;
4137
- }
4138
- var next;
4139
- if (entry.operation === 'request')
4140
- next = requestImmediately(entry.target);
4141
- else
4142
- next = exitImmediately();
4143
- activeOperation = next
4144
- .then(function () {
4145
- entry.resolve();
4146
- drainPendingOperation();
4147
- })
4148
- .catch(function (error) {
4149
- entry.reject(error);
4150
- drainPendingOperation();
4151
- });
4152
- }
4153
- function request(target) {
4154
- lastIntendedOperation = 'request';
4155
- if (activeOperation === null) {
4156
- var next = requestImmediately(target);
4157
- activeOperation = next
4158
- .then(drainPendingOperation)
4159
- .catch(drainPendingOperation);
4160
- return next;
4161
- }
4162
- return new Promise(function (resolve, reject) {
4163
- pendingQueue.push({
4164
- operation: 'request',
4165
- target: target,
4166
- resolve: resolve,
4167
- reject: reject,
4168
- });
4169
- });
4170
- }
4171
- function exit() {
4172
- lastIntendedOperation = 'exit';
4173
- if (activeOperation === null) {
4174
- var next = exitImmediately();
4175
- activeOperation = next
4176
- .then(drainPendingOperation)
4177
- .catch(drainPendingOperation);
4178
- return next;
4310
+ reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4179
4311
  }
4180
- return new Promise(function (resolve, reject) {
4181
- pendingQueue.push({
4182
- operation: 'exit',
4183
- target: undefined,
4184
- resolve: resolve,
4185
- reject: reject,
4186
- });
4187
- });
4188
- }
4189
- function requestImmediately(target) {
4190
- return new Promise(function (resolve, reject) {
4191
- if (typeof target === 'undefined')
4192
- target = getDefaultTarget();
4193
- if (typeof target === 'undefined')
4194
- return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
4195
- var tagName = target.tagName.toLowerCase();
4196
- if (tagName !== 'video')
4197
- return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4198
- function fallbackToWebkitVideo() {
4199
- if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
4200
- if (target.disablePictureInPicture)
4201
- return reject(new NotSupportedError('Picture-in-Picture is disabled on this video element.'));
4202
- lastPipVideo = target;
4203
- bridgeWebkitVideoEvents();
4204
- target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
4205
- return resolve();
4206
- }
4207
- reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
4312
+ fallbackToWebkit();
4313
+ });
4314
+ }
4315
+ function exit() {
4316
+ return new Promise(function (resolve, reject) {
4317
+ var method = globalThis.document.exitPictureInPicture;
4318
+ if (typeof method === 'function' && !hasWebkitApi()) {
4319
+ var result = method.call(globalThis.document);
4320
+ if (typeof result !== 'undefined' && typeof result.then === 'function') {
4321
+ result
4322
+ .then(resolve)
4323
+ .catch(function () {
4324
+ try {
4325
+ fallbackToWebkit();
4326
+ }
4327
+ catch (e) {
4328
+ reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
4329
+ }
4330
+ });
4331
+ return;
4208
4332
  }
4209
- var method = target.requestPictureInPicture;
4210
- if (typeof method === 'function') {
4211
- var result = method.call(target);
4212
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
4213
- result
4214
- .then(function () {
4215
- resolve();
4216
- })
4217
- .catch(function () {
4218
- fallbackToWebkitVideo();
4219
- });
4220
- return;
4221
- }
4333
+ return resolve();
4334
+ }
4335
+ function fallbackToWebkit() {
4336
+ if (lastFallbackVideoElement !== null && typeof lastFallbackVideoElement.webkitSetPresentationMode === 'function') {
4337
+ lastFallbackVideoElement.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4222
4338
  return resolve();
4223
4339
  }
4224
- fallbackToWebkitVideo();
4225
- });
4226
- }
4227
- function exitImmediately() {
4228
- return new Promise(function (resolve, reject) {
4229
- if (getElement() === null && lastPipVideo === null)
4230
- return resolve();
4231
- function fallbackToWebkitVideo() {
4232
- var candidates;
4233
- if (lastPipVideo !== null && lastPipVideo.webkitPresentationMode === PIP_PRESENTATION_MODE)
4234
- candidates = [lastPipVideo];
4235
- else
4236
- candidates = globalThis.document.querySelectorAll('video');
4237
- for (var i = 0; i < candidates.length; i++) {
4238
- var video = candidates[i];
4239
- if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4240
- video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4241
- lastPipVideo = null;
4242
- return resolve();
4243
- }
4244
- }
4245
- if (getElement() === null)
4340
+ var videos = globalThis.document.querySelectorAll('video');
4341
+ for (var i = 0; i < videos.length; i++) {
4342
+ var video = videos[i];
4343
+ if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
4344
+ video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
4246
4345
  return resolve();
4247
- reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
4248
- }
4249
- var method = globalThis.document.exitPictureInPicture;
4250
- if (typeof method === 'function') {
4251
- var result = method.call(globalThis.document);
4252
- if (typeof result !== 'undefined' && typeof result.then === 'function') {
4253
- result
4254
- .then(resolve)
4255
- .catch(function () {
4256
- fallbackToWebkitVideo();
4257
- });
4258
- return;
4259
4346
  }
4260
- return resolve();
4261
4347
  }
4262
- fallbackToWebkitVideo();
4263
- });
4264
- }
4265
- function toggle(target) {
4266
- if (lastIntendedOperation === 'request')
4267
- return exit();
4268
- return request(target);
4269
- }
4270
- bridgeEvents();
4271
- return {
4272
- get supported() {
4273
- return getEnabled();
4274
- },
4275
- get element() {
4276
- return getElement();
4277
- },
4278
- get isPip() {
4279
- return getIsPip();
4280
- },
4281
- request: request,
4282
- exit: exit,
4283
- toggle: toggle,
4284
- onChange: onChangeSubscriptionManager.subscribe,
4285
- onError: onErrorSubscriptionManager.subscribe,
4286
- Constants: {},
4287
- Errors: {
4288
- NotSupportedError: NotSupportedError,
4289
- },
4290
- };
4348
+ return resolve();
4349
+ }
4350
+ fallbackToWebkit();
4351
+ });
4291
4352
  }
4292
- var Pip = createPip();
4353
+ function toggle(target) {
4354
+ var current = getElement();
4355
+ if (typeof target !== 'undefined') {
4356
+ if (current === target)
4357
+ return this.exit();
4358
+ else
4359
+ return this.request(target);
4360
+ }
4361
+ if (current !== null)
4362
+ return this.exit();
4363
+ else
4364
+ return this.request(target);
4365
+ }
4366
+ function onChange(targetOrListener, listenerOrOptions, options) {
4367
+ if (typeof targetOrListener === 'function')
4368
+ return onChangeSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
4369
+ var target = targetOrListener;
4370
+ var listener = listenerOrOptions;
4371
+ function wrappedListener(payload) {
4372
+ if (payload.element === target)
4373
+ listener(payload);
4374
+ }
4375
+ return onChangeSubscriptionManager$1.subscribe(wrappedListener, options);
4376
+ }
4377
+ function onError(targetOrListener, listenerOrOptions, options) {
4378
+ if (typeof targetOrListener === 'function')
4379
+ return onErrorSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
4380
+ var target = targetOrListener;
4381
+ var listener = listenerOrOptions;
4382
+ function wrappedListener(payload) {
4383
+ if (payload.element === target)
4384
+ listener(payload);
4385
+ }
4386
+ return onErrorSubscriptionManager.subscribe(wrappedListener, options);
4387
+ }
4388
+ bridgeEvents();
4293
4389
 
4294
4390
  var Badge = {
4295
- set: set,
4296
- clear: clear,
4297
4391
  get supported() {
4298
4392
  return supported$2();
4299
4393
  },
4394
+ set: set,
4395
+ clear: clear,
4300
4396
  Constants: {},
4301
4397
  Errors: {
4302
4398
  NotSupportedError: NotSupportedError,
@@ -4368,12 +4464,12 @@ function supported$1() {
4368
4464
  var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
4369
4465
  var batteryRef = null;
4370
4466
  var Battery = {
4371
- get value() {
4372
- return getValue();
4373
- },
4374
4467
  get supported() {
4375
4468
  return supported();
4376
4469
  },
4470
+ get value() {
4471
+ return getValue();
4472
+ },
4377
4473
  onChange: onChangeSubscriptionManager.subscribe,
4378
4474
  Constants: {},
4379
4475
  Errors: {