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