native-fn 1.2.2 → 1.3.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 (405) hide show
  1. package/README.md +191 -49
  2. package/dist/index.d.ts +148 -98
  3. package/dist/native.cjs +810 -288
  4. package/dist/native.min.cjs +1 -1
  5. package/dist/native.min.mjs +1 -1
  6. package/dist/native.mjs +810 -288
  7. package/dist/native.umd.js +810 -288
  8. package/dist/native.umd.min.js +1 -1
  9. package/dist/plugin/appearance/index.cjs +65 -64
  10. package/dist/plugin/appearance/index.d.ts +5 -5
  11. package/dist/plugin/appearance/index.mjs +66 -65
  12. package/dist/plugin/appearance/src/plugin/appearance/constants/index.d.ts +1 -1
  13. package/dist/plugin/appearance/src/plugin/appearance/types/appearance.d.ts +3 -3
  14. package/dist/plugin/appearance/src/plugin/badge/types/badge.d.ts +3 -3
  15. package/dist/plugin/appearance/src/plugin/battery/types/battery.d.ts +3 -3
  16. package/dist/plugin/appearance/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  17. package/dist/plugin/appearance/src/plugin/dimension/constants/index.d.ts +10 -6
  18. package/dist/plugin/appearance/src/plugin/dimension/cores/index.d.ts +15 -0
  19. package/dist/plugin/appearance/src/plugin/dimension/types/dimensions.d.ts +52 -24
  20. package/dist/plugin/appearance/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  21. package/dist/plugin/appearance/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  22. package/dist/plugin/appearance/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  23. package/dist/plugin/appearance/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  24. package/dist/plugin/appearance/src/plugin/notification/types/notification.d.ts +4 -4
  25. package/dist/plugin/appearance/src/plugin/open/types/open.d.ts +12 -12
  26. package/dist/plugin/appearance/src/plugin/permission/constants/index.d.ts +3 -1
  27. package/dist/plugin/appearance/src/plugin/permission/types/permission.d.ts +7 -4
  28. package/dist/plugin/appearance/src/plugin/pip/types/pip.d.ts +7 -7
  29. package/dist/plugin/appearance/src/plugin/platform/constants/index.d.ts +1 -1
  30. package/dist/plugin/appearance/src/plugin/platform/types/platform.d.ts +13 -13
  31. package/dist/plugin/appearance/src/plugin/theme/types/theme.d.ts +2 -2
  32. package/dist/plugin/appearance/src/plugin/vibration/types/vibration.d.ts +3 -3
  33. package/dist/plugin/appearance/src/types/subscription-manager.d.ts +3 -3
  34. package/dist/plugin/appearance/src/utils/create-subscription-manager.d.ts +1 -1
  35. package/dist/plugin/appearance/src/utils/insert-sort.d.ts +1 -0
  36. package/dist/plugin/badge/index.d.ts +3 -3
  37. package/dist/plugin/badge/src/plugin/appearance/constants/index.d.ts +1 -1
  38. package/dist/plugin/badge/src/plugin/appearance/types/appearance.d.ts +3 -3
  39. package/dist/plugin/badge/src/plugin/badge/types/badge.d.ts +3 -3
  40. package/dist/plugin/badge/src/plugin/battery/types/battery.d.ts +3 -3
  41. package/dist/plugin/badge/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  42. package/dist/plugin/badge/src/plugin/dimension/constants/index.d.ts +10 -6
  43. package/dist/plugin/badge/src/plugin/dimension/cores/index.d.ts +15 -0
  44. package/dist/plugin/badge/src/plugin/dimension/types/dimensions.d.ts +52 -24
  45. package/dist/plugin/badge/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  46. package/dist/plugin/badge/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  47. package/dist/plugin/badge/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  48. package/dist/plugin/badge/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  49. package/dist/plugin/badge/src/plugin/notification/types/notification.d.ts +4 -4
  50. package/dist/plugin/badge/src/plugin/open/types/open.d.ts +12 -12
  51. package/dist/plugin/badge/src/plugin/permission/constants/index.d.ts +3 -1
  52. package/dist/plugin/badge/src/plugin/permission/types/permission.d.ts +7 -4
  53. package/dist/plugin/badge/src/plugin/pip/types/pip.d.ts +7 -7
  54. package/dist/plugin/badge/src/plugin/platform/constants/index.d.ts +1 -1
  55. package/dist/plugin/badge/src/plugin/platform/types/platform.d.ts +13 -13
  56. package/dist/plugin/badge/src/plugin/theme/types/theme.d.ts +2 -2
  57. package/dist/plugin/badge/src/plugin/vibration/types/vibration.d.ts +3 -3
  58. package/dist/plugin/badge/src/types/subscription-manager.d.ts +3 -3
  59. package/dist/plugin/badge/src/utils/create-subscription-manager.d.ts +1 -1
  60. package/dist/plugin/badge/src/utils/insert-sort.d.ts +1 -0
  61. package/dist/plugin/battery/index.cjs +4 -6
  62. package/dist/plugin/battery/index.d.ts +3 -3
  63. package/dist/plugin/battery/index.mjs +4 -6
  64. package/dist/plugin/battery/src/plugin/appearance/constants/index.d.ts +1 -1
  65. package/dist/plugin/battery/src/plugin/appearance/types/appearance.d.ts +3 -3
  66. package/dist/plugin/battery/src/plugin/badge/types/badge.d.ts +3 -3
  67. package/dist/plugin/battery/src/plugin/battery/types/battery.d.ts +3 -3
  68. package/dist/plugin/battery/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  69. package/dist/plugin/battery/src/plugin/dimension/constants/index.d.ts +10 -6
  70. package/dist/plugin/battery/src/plugin/dimension/cores/index.d.ts +15 -0
  71. package/dist/plugin/battery/src/plugin/dimension/types/dimensions.d.ts +52 -24
  72. package/dist/plugin/battery/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  73. package/dist/plugin/battery/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  74. package/dist/plugin/battery/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  75. package/dist/plugin/battery/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  76. package/dist/plugin/battery/src/plugin/notification/types/notification.d.ts +4 -4
  77. package/dist/plugin/battery/src/plugin/open/types/open.d.ts +12 -12
  78. package/dist/plugin/battery/src/plugin/permission/constants/index.d.ts +3 -1
  79. package/dist/plugin/battery/src/plugin/permission/types/permission.d.ts +7 -4
  80. package/dist/plugin/battery/src/plugin/pip/types/pip.d.ts +7 -7
  81. package/dist/plugin/battery/src/plugin/platform/constants/index.d.ts +1 -1
  82. package/dist/plugin/battery/src/plugin/platform/types/platform.d.ts +13 -13
  83. package/dist/plugin/battery/src/plugin/theme/types/theme.d.ts +2 -2
  84. package/dist/plugin/battery/src/plugin/vibration/types/vibration.d.ts +3 -3
  85. package/dist/plugin/battery/src/types/subscription-manager.d.ts +3 -3
  86. package/dist/plugin/battery/src/utils/create-subscription-manager.d.ts +1 -1
  87. package/dist/plugin/battery/src/utils/insert-sort.d.ts +1 -0
  88. package/dist/plugin/clipboard/index.d.ts +2 -2
  89. package/dist/plugin/clipboard/src/plugin/appearance/constants/index.d.ts +1 -1
  90. package/dist/plugin/clipboard/src/plugin/appearance/types/appearance.d.ts +3 -3
  91. package/dist/plugin/clipboard/src/plugin/badge/types/badge.d.ts +3 -3
  92. package/dist/plugin/clipboard/src/plugin/battery/types/battery.d.ts +3 -3
  93. package/dist/plugin/clipboard/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  94. package/dist/plugin/clipboard/src/plugin/dimension/constants/index.d.ts +10 -6
  95. package/dist/plugin/clipboard/src/plugin/dimension/cores/index.d.ts +15 -0
  96. package/dist/plugin/clipboard/src/plugin/dimension/types/dimensions.d.ts +52 -24
  97. package/dist/plugin/clipboard/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  98. package/dist/plugin/clipboard/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  99. package/dist/plugin/clipboard/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  100. package/dist/plugin/clipboard/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  101. package/dist/plugin/clipboard/src/plugin/notification/types/notification.d.ts +4 -4
  102. package/dist/plugin/clipboard/src/plugin/open/types/open.d.ts +12 -12
  103. package/dist/plugin/clipboard/src/plugin/permission/constants/index.d.ts +3 -1
  104. package/dist/plugin/clipboard/src/plugin/permission/types/permission.d.ts +7 -4
  105. package/dist/plugin/clipboard/src/plugin/pip/types/pip.d.ts +7 -7
  106. package/dist/plugin/clipboard/src/plugin/platform/constants/index.d.ts +1 -1
  107. package/dist/plugin/clipboard/src/plugin/platform/types/platform.d.ts +13 -13
  108. package/dist/plugin/clipboard/src/plugin/theme/types/theme.d.ts +2 -2
  109. package/dist/plugin/clipboard/src/plugin/vibration/types/vibration.d.ts +3 -3
  110. package/dist/plugin/clipboard/src/types/subscription-manager.d.ts +3 -3
  111. package/dist/plugin/clipboard/src/utils/create-subscription-manager.d.ts +1 -1
  112. package/dist/plugin/clipboard/src/utils/insert-sort.d.ts +1 -0
  113. package/dist/plugin/dimension/index.cjs +711 -122
  114. package/dist/plugin/dimension/index.d.ts +81 -31
  115. package/dist/plugin/dimension/index.mjs +712 -122
  116. package/dist/plugin/dimension/src/plugin/appearance/constants/index.d.ts +1 -1
  117. package/dist/plugin/dimension/src/plugin/appearance/types/appearance.d.ts +3 -3
  118. package/dist/plugin/dimension/src/plugin/badge/types/badge.d.ts +3 -3
  119. package/dist/plugin/dimension/src/plugin/battery/types/battery.d.ts +3 -3
  120. package/dist/plugin/dimension/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  121. package/dist/plugin/dimension/src/plugin/dimension/constants/index.d.ts +10 -6
  122. package/dist/plugin/dimension/src/plugin/dimension/cores/index.d.ts +15 -0
  123. package/dist/plugin/dimension/src/plugin/dimension/types/dimensions.d.ts +52 -24
  124. package/dist/plugin/dimension/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  125. package/dist/plugin/dimension/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  126. package/dist/plugin/dimension/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  127. package/dist/plugin/dimension/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  128. package/dist/plugin/dimension/src/plugin/notification/types/notification.d.ts +4 -4
  129. package/dist/plugin/dimension/src/plugin/open/types/open.d.ts +12 -12
  130. package/dist/plugin/dimension/src/plugin/permission/constants/index.d.ts +3 -1
  131. package/dist/plugin/dimension/src/plugin/permission/types/permission.d.ts +7 -4
  132. package/dist/plugin/dimension/src/plugin/pip/types/pip.d.ts +7 -7
  133. package/dist/plugin/dimension/src/plugin/platform/constants/index.d.ts +1 -1
  134. package/dist/plugin/dimension/src/plugin/platform/types/platform.d.ts +13 -13
  135. package/dist/plugin/dimension/src/plugin/theme/types/theme.d.ts +2 -2
  136. package/dist/plugin/dimension/src/plugin/vibration/types/vibration.d.ts +3 -3
  137. package/dist/plugin/dimension/src/types/subscription-manager.d.ts +3 -3
  138. package/dist/plugin/dimension/src/utils/create-subscription-manager.d.ts +1 -1
  139. package/dist/plugin/dimension/src/utils/insert-sort.d.ts +1 -0
  140. package/dist/plugin/fullscreen/index.cjs +96 -91
  141. package/dist/plugin/fullscreen/index.d.ts +7 -7
  142. package/dist/plugin/fullscreen/index.mjs +96 -91
  143. package/dist/plugin/fullscreen/src/plugin/appearance/constants/index.d.ts +1 -1
  144. package/dist/plugin/fullscreen/src/plugin/appearance/types/appearance.d.ts +3 -3
  145. package/dist/plugin/fullscreen/src/plugin/badge/types/badge.d.ts +3 -3
  146. package/dist/plugin/fullscreen/src/plugin/battery/types/battery.d.ts +3 -3
  147. package/dist/plugin/fullscreen/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  148. package/dist/plugin/fullscreen/src/plugin/dimension/constants/index.d.ts +10 -6
  149. package/dist/plugin/fullscreen/src/plugin/dimension/cores/index.d.ts +15 -0
  150. package/dist/plugin/fullscreen/src/plugin/dimension/types/dimensions.d.ts +52 -24
  151. package/dist/plugin/fullscreen/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  152. package/dist/plugin/fullscreen/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  153. package/dist/plugin/fullscreen/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  154. package/dist/plugin/fullscreen/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  155. package/dist/plugin/fullscreen/src/plugin/notification/types/notification.d.ts +4 -4
  156. package/dist/plugin/fullscreen/src/plugin/open/types/open.d.ts +12 -12
  157. package/dist/plugin/fullscreen/src/plugin/permission/constants/index.d.ts +3 -1
  158. package/dist/plugin/fullscreen/src/plugin/permission/types/permission.d.ts +7 -4
  159. package/dist/plugin/fullscreen/src/plugin/pip/types/pip.d.ts +7 -7
  160. package/dist/plugin/fullscreen/src/plugin/platform/constants/index.d.ts +1 -1
  161. package/dist/plugin/fullscreen/src/plugin/platform/types/platform.d.ts +13 -13
  162. package/dist/plugin/fullscreen/src/plugin/theme/types/theme.d.ts +2 -2
  163. package/dist/plugin/fullscreen/src/plugin/vibration/types/vibration.d.ts +3 -3
  164. package/dist/plugin/fullscreen/src/types/subscription-manager.d.ts +3 -3
  165. package/dist/plugin/fullscreen/src/utils/create-subscription-manager.d.ts +1 -1
  166. package/dist/plugin/fullscreen/src/utils/insert-sort.d.ts +1 -0
  167. package/dist/plugin/geolocation/index.cjs +249 -182
  168. package/dist/plugin/geolocation/index.d.ts +4 -4
  169. package/dist/plugin/geolocation/index.mjs +249 -182
  170. package/dist/plugin/geolocation/src/plugin/appearance/constants/index.d.ts +1 -1
  171. package/dist/plugin/geolocation/src/plugin/appearance/types/appearance.d.ts +3 -3
  172. package/dist/plugin/geolocation/src/plugin/badge/types/badge.d.ts +3 -3
  173. package/dist/plugin/geolocation/src/plugin/battery/types/battery.d.ts +3 -3
  174. package/dist/plugin/geolocation/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  175. package/dist/plugin/geolocation/src/plugin/dimension/constants/index.d.ts +10 -6
  176. package/dist/plugin/geolocation/src/plugin/dimension/cores/index.d.ts +15 -0
  177. package/dist/plugin/geolocation/src/plugin/dimension/types/dimensions.d.ts +52 -24
  178. package/dist/plugin/geolocation/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  179. package/dist/plugin/geolocation/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  180. package/dist/plugin/geolocation/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  181. package/dist/plugin/geolocation/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  182. package/dist/plugin/geolocation/src/plugin/notification/types/notification.d.ts +4 -4
  183. package/dist/plugin/geolocation/src/plugin/open/types/open.d.ts +12 -12
  184. package/dist/plugin/geolocation/src/plugin/permission/constants/index.d.ts +3 -1
  185. package/dist/plugin/geolocation/src/plugin/permission/types/permission.d.ts +7 -4
  186. package/dist/plugin/geolocation/src/plugin/pip/types/pip.d.ts +7 -7
  187. package/dist/plugin/geolocation/src/plugin/platform/constants/index.d.ts +1 -1
  188. package/dist/plugin/geolocation/src/plugin/platform/types/platform.d.ts +13 -13
  189. package/dist/plugin/geolocation/src/plugin/theme/types/theme.d.ts +2 -2
  190. package/dist/plugin/geolocation/src/plugin/vibration/types/vibration.d.ts +3 -3
  191. package/dist/plugin/geolocation/src/types/subscription-manager.d.ts +3 -3
  192. package/dist/plugin/geolocation/src/utils/create-subscription-manager.d.ts +1 -1
  193. package/dist/plugin/geolocation/src/utils/insert-sort.d.ts +1 -0
  194. package/dist/plugin/notification/index.cjs +288 -13
  195. package/dist/plugin/notification/index.d.ts +4 -4
  196. package/dist/plugin/notification/index.mjs +288 -13
  197. package/dist/plugin/notification/src/plugin/appearance/constants/index.d.ts +1 -1
  198. package/dist/plugin/notification/src/plugin/appearance/types/appearance.d.ts +3 -3
  199. package/dist/plugin/notification/src/plugin/badge/types/badge.d.ts +3 -3
  200. package/dist/plugin/notification/src/plugin/battery/types/battery.d.ts +3 -3
  201. package/dist/plugin/notification/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  202. package/dist/plugin/notification/src/plugin/dimension/constants/index.d.ts +10 -6
  203. package/dist/plugin/notification/src/plugin/dimension/cores/index.d.ts +15 -0
  204. package/dist/plugin/notification/src/plugin/dimension/types/dimensions.d.ts +52 -24
  205. package/dist/plugin/notification/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  206. package/dist/plugin/notification/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  207. package/dist/plugin/notification/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  208. package/dist/plugin/notification/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  209. package/dist/plugin/notification/src/plugin/notification/types/notification.d.ts +4 -4
  210. package/dist/plugin/notification/src/plugin/open/types/open.d.ts +12 -12
  211. package/dist/plugin/notification/src/plugin/permission/constants/index.d.ts +3 -1
  212. package/dist/plugin/notification/src/plugin/permission/types/permission.d.ts +7 -4
  213. package/dist/plugin/notification/src/plugin/pip/types/pip.d.ts +7 -7
  214. package/dist/plugin/notification/src/plugin/platform/constants/index.d.ts +1 -1
  215. package/dist/plugin/notification/src/plugin/platform/types/platform.d.ts +13 -13
  216. package/dist/plugin/notification/src/plugin/theme/types/theme.d.ts +2 -2
  217. package/dist/plugin/notification/src/plugin/vibration/types/vibration.d.ts +3 -3
  218. package/dist/plugin/notification/src/types/subscription-manager.d.ts +3 -3
  219. package/dist/plugin/notification/src/utils/create-subscription-manager.d.ts +1 -1
  220. package/dist/plugin/notification/src/utils/insert-sort.d.ts +1 -0
  221. package/dist/plugin/open/index.cjs +64 -55
  222. package/dist/plugin/open/index.d.ts +28 -12
  223. package/dist/plugin/open/index.mjs +64 -55
  224. package/dist/plugin/open/src/plugin/appearance/constants/index.d.ts +1 -1
  225. package/dist/plugin/open/src/plugin/appearance/types/appearance.d.ts +3 -3
  226. package/dist/plugin/open/src/plugin/badge/types/badge.d.ts +3 -3
  227. package/dist/plugin/open/src/plugin/battery/types/battery.d.ts +3 -3
  228. package/dist/plugin/open/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  229. package/dist/plugin/open/src/plugin/dimension/constants/index.d.ts +10 -6
  230. package/dist/plugin/open/src/plugin/dimension/cores/index.d.ts +15 -0
  231. package/dist/plugin/open/src/plugin/dimension/types/dimensions.d.ts +52 -24
  232. package/dist/plugin/open/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  233. package/dist/plugin/open/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  234. package/dist/plugin/open/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  235. package/dist/plugin/open/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  236. package/dist/plugin/open/src/plugin/notification/types/notification.d.ts +4 -4
  237. package/dist/plugin/open/src/plugin/open/types/open.d.ts +12 -12
  238. package/dist/plugin/open/src/plugin/permission/constants/index.d.ts +3 -1
  239. package/dist/plugin/open/src/plugin/permission/types/permission.d.ts +7 -4
  240. package/dist/plugin/open/src/plugin/pip/types/pip.d.ts +7 -7
  241. package/dist/plugin/open/src/plugin/platform/constants/index.d.ts +1 -1
  242. package/dist/plugin/open/src/plugin/platform/types/platform.d.ts +13 -13
  243. package/dist/plugin/open/src/plugin/theme/types/theme.d.ts +2 -2
  244. package/dist/plugin/open/src/plugin/vibration/types/vibration.d.ts +3 -3
  245. package/dist/plugin/open/src/types/subscription-manager.d.ts +3 -3
  246. package/dist/plugin/open/src/utils/create-subscription-manager.d.ts +1 -1
  247. package/dist/plugin/open/src/utils/insert-sort.d.ts +1 -0
  248. package/dist/plugin/permission/index.cjs +372 -13
  249. package/dist/plugin/permission/index.d.ts +11 -5
  250. package/dist/plugin/permission/index.mjs +372 -13
  251. package/dist/plugin/permission/src/plugin/appearance/constants/index.d.ts +1 -1
  252. package/dist/plugin/permission/src/plugin/appearance/types/appearance.d.ts +3 -3
  253. package/dist/plugin/permission/src/plugin/badge/types/badge.d.ts +3 -3
  254. package/dist/plugin/permission/src/plugin/battery/types/battery.d.ts +3 -3
  255. package/dist/plugin/permission/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  256. package/dist/plugin/permission/src/plugin/dimension/constants/index.d.ts +10 -6
  257. package/dist/plugin/permission/src/plugin/dimension/cores/index.d.ts +15 -0
  258. package/dist/plugin/permission/src/plugin/dimension/types/dimensions.d.ts +52 -24
  259. package/dist/plugin/permission/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  260. package/dist/plugin/permission/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  261. package/dist/plugin/permission/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  262. package/dist/plugin/permission/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  263. package/dist/plugin/permission/src/plugin/notification/types/notification.d.ts +4 -4
  264. package/dist/plugin/permission/src/plugin/open/types/open.d.ts +12 -12
  265. package/dist/plugin/permission/src/plugin/permission/constants/index.d.ts +3 -1
  266. package/dist/plugin/permission/src/plugin/permission/types/permission.d.ts +7 -4
  267. package/dist/plugin/permission/src/plugin/pip/types/pip.d.ts +7 -7
  268. package/dist/plugin/permission/src/plugin/platform/constants/index.d.ts +1 -1
  269. package/dist/plugin/permission/src/plugin/platform/types/platform.d.ts +13 -13
  270. package/dist/plugin/permission/src/plugin/theme/types/theme.d.ts +2 -2
  271. package/dist/plugin/permission/src/plugin/vibration/types/vibration.d.ts +3 -3
  272. package/dist/plugin/permission/src/types/subscription-manager.d.ts +3 -3
  273. package/dist/plugin/permission/src/utils/create-subscription-manager.d.ts +1 -1
  274. package/dist/plugin/permission/src/utils/insert-sort.d.ts +1 -0
  275. package/dist/plugin/pip/index.cjs +58 -57
  276. package/dist/plugin/pip/index.d.ts +7 -7
  277. package/dist/plugin/pip/index.mjs +58 -57
  278. package/dist/plugin/pip/src/plugin/appearance/constants/index.d.ts +1 -1
  279. package/dist/plugin/pip/src/plugin/appearance/types/appearance.d.ts +3 -3
  280. package/dist/plugin/pip/src/plugin/badge/types/badge.d.ts +3 -3
  281. package/dist/plugin/pip/src/plugin/battery/types/battery.d.ts +3 -3
  282. package/dist/plugin/pip/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  283. package/dist/plugin/pip/src/plugin/dimension/constants/index.d.ts +10 -6
  284. package/dist/plugin/pip/src/plugin/dimension/cores/index.d.ts +15 -0
  285. package/dist/plugin/pip/src/plugin/dimension/types/dimensions.d.ts +52 -24
  286. package/dist/plugin/pip/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  287. package/dist/plugin/pip/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  288. package/dist/plugin/pip/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  289. package/dist/plugin/pip/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  290. package/dist/plugin/pip/src/plugin/notification/types/notification.d.ts +4 -4
  291. package/dist/plugin/pip/src/plugin/open/types/open.d.ts +12 -12
  292. package/dist/plugin/pip/src/plugin/permission/constants/index.d.ts +3 -1
  293. package/dist/plugin/pip/src/plugin/permission/types/permission.d.ts +7 -4
  294. package/dist/plugin/pip/src/plugin/pip/types/pip.d.ts +7 -7
  295. package/dist/plugin/pip/src/plugin/platform/constants/index.d.ts +1 -1
  296. package/dist/plugin/pip/src/plugin/platform/types/platform.d.ts +13 -13
  297. package/dist/plugin/pip/src/plugin/theme/types/theme.d.ts +2 -2
  298. package/dist/plugin/pip/src/plugin/vibration/types/vibration.d.ts +3 -3
  299. package/dist/plugin/pip/src/types/subscription-manager.d.ts +3 -3
  300. package/dist/plugin/pip/src/utils/create-subscription-manager.d.ts +1 -1
  301. package/dist/plugin/pip/src/utils/insert-sort.d.ts +1 -0
  302. package/dist/plugin/platform/index.cjs +98 -92
  303. package/dist/plugin/platform/index.d.ts +30 -14
  304. package/dist/plugin/platform/index.mjs +92 -85
  305. package/dist/plugin/platform/src/plugin/appearance/constants/index.d.ts +1 -1
  306. package/dist/plugin/platform/src/plugin/appearance/types/appearance.d.ts +3 -3
  307. package/dist/plugin/platform/src/plugin/badge/types/badge.d.ts +3 -3
  308. package/dist/plugin/platform/src/plugin/battery/types/battery.d.ts +3 -3
  309. package/dist/plugin/platform/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  310. package/dist/plugin/platform/src/plugin/dimension/constants/index.d.ts +10 -6
  311. package/dist/plugin/platform/src/plugin/dimension/cores/index.d.ts +15 -0
  312. package/dist/plugin/platform/src/plugin/dimension/types/dimensions.d.ts +52 -24
  313. package/dist/plugin/platform/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  314. package/dist/plugin/platform/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  315. package/dist/plugin/platform/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  316. package/dist/plugin/platform/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  317. package/dist/plugin/platform/src/plugin/notification/types/notification.d.ts +4 -4
  318. package/dist/plugin/platform/src/plugin/open/types/open.d.ts +12 -12
  319. package/dist/plugin/platform/src/plugin/permission/constants/index.d.ts +3 -1
  320. package/dist/plugin/platform/src/plugin/permission/types/permission.d.ts +7 -4
  321. package/dist/plugin/platform/src/plugin/pip/types/pip.d.ts +7 -7
  322. package/dist/plugin/platform/src/plugin/platform/constants/index.d.ts +1 -1
  323. package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +13 -13
  324. package/dist/plugin/platform/src/plugin/theme/types/theme.d.ts +2 -2
  325. package/dist/plugin/platform/src/plugin/vibration/types/vibration.d.ts +3 -3
  326. package/dist/plugin/platform/src/types/subscription-manager.d.ts +3 -3
  327. package/dist/plugin/platform/src/utils/create-subscription-manager.d.ts +1 -1
  328. package/dist/plugin/platform/src/utils/insert-sort.d.ts +1 -0
  329. package/dist/plugin/theme/index.cjs +63 -54
  330. package/dist/plugin/theme/index.d.ts +2 -2
  331. package/dist/plugin/theme/index.mjs +63 -54
  332. package/dist/plugin/theme/src/plugin/appearance/constants/index.d.ts +1 -1
  333. package/dist/plugin/theme/src/plugin/appearance/types/appearance.d.ts +3 -3
  334. package/dist/plugin/theme/src/plugin/badge/types/badge.d.ts +3 -3
  335. package/dist/plugin/theme/src/plugin/battery/types/battery.d.ts +3 -3
  336. package/dist/plugin/theme/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  337. package/dist/plugin/theme/src/plugin/dimension/constants/index.d.ts +10 -6
  338. package/dist/plugin/theme/src/plugin/dimension/cores/index.d.ts +15 -0
  339. package/dist/plugin/theme/src/plugin/dimension/types/dimensions.d.ts +52 -24
  340. package/dist/plugin/theme/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  341. package/dist/plugin/theme/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  342. package/dist/plugin/theme/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  343. package/dist/plugin/theme/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  344. package/dist/plugin/theme/src/plugin/notification/types/notification.d.ts +4 -4
  345. package/dist/plugin/theme/src/plugin/open/types/open.d.ts +12 -12
  346. package/dist/plugin/theme/src/plugin/permission/constants/index.d.ts +3 -1
  347. package/dist/plugin/theme/src/plugin/permission/types/permission.d.ts +7 -4
  348. package/dist/plugin/theme/src/plugin/pip/types/pip.d.ts +7 -7
  349. package/dist/plugin/theme/src/plugin/platform/constants/index.d.ts +1 -1
  350. package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +13 -13
  351. package/dist/plugin/theme/src/plugin/theme/types/theme.d.ts +2 -2
  352. package/dist/plugin/theme/src/plugin/vibration/types/vibration.d.ts +3 -3
  353. package/dist/plugin/theme/src/types/subscription-manager.d.ts +3 -3
  354. package/dist/plugin/theme/src/utils/create-subscription-manager.d.ts +1 -1
  355. package/dist/plugin/theme/src/utils/insert-sort.d.ts +1 -0
  356. package/dist/plugin/vibration/index.d.ts +3 -3
  357. package/dist/plugin/vibration/src/plugin/appearance/constants/index.d.ts +1 -1
  358. package/dist/plugin/vibration/src/plugin/appearance/types/appearance.d.ts +3 -3
  359. package/dist/plugin/vibration/src/plugin/badge/types/badge.d.ts +3 -3
  360. package/dist/plugin/vibration/src/plugin/battery/types/battery.d.ts +3 -3
  361. package/dist/plugin/vibration/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  362. package/dist/plugin/vibration/src/plugin/dimension/constants/index.d.ts +10 -6
  363. package/dist/plugin/vibration/src/plugin/dimension/cores/index.d.ts +15 -0
  364. package/dist/plugin/vibration/src/plugin/dimension/types/dimensions.d.ts +52 -24
  365. package/dist/plugin/vibration/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  366. package/dist/plugin/vibration/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  367. package/dist/plugin/vibration/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  368. package/dist/plugin/vibration/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  369. package/dist/plugin/vibration/src/plugin/notification/types/notification.d.ts +4 -4
  370. package/dist/plugin/vibration/src/plugin/open/types/open.d.ts +12 -12
  371. package/dist/plugin/vibration/src/plugin/permission/constants/index.d.ts +3 -1
  372. package/dist/plugin/vibration/src/plugin/permission/types/permission.d.ts +7 -4
  373. package/dist/plugin/vibration/src/plugin/pip/types/pip.d.ts +7 -7
  374. package/dist/plugin/vibration/src/plugin/platform/constants/index.d.ts +1 -1
  375. package/dist/plugin/vibration/src/plugin/platform/types/platform.d.ts +13 -13
  376. package/dist/plugin/vibration/src/plugin/theme/types/theme.d.ts +2 -2
  377. package/dist/plugin/vibration/src/plugin/vibration/types/vibration.d.ts +3 -3
  378. package/dist/plugin/vibration/src/types/subscription-manager.d.ts +3 -3
  379. package/dist/plugin/vibration/src/utils/create-subscription-manager.d.ts +1 -1
  380. package/dist/plugin/vibration/src/utils/insert-sort.d.ts +1 -0
  381. package/dist/src/plugin/appearance/constants/index.d.ts +1 -1
  382. package/dist/src/plugin/appearance/types/appearance.d.ts +3 -3
  383. package/dist/src/plugin/badge/types/badge.d.ts +3 -3
  384. package/dist/src/plugin/battery/types/battery.d.ts +3 -3
  385. package/dist/src/plugin/clipboard/types/clipboard.d.ts +2 -2
  386. package/dist/src/plugin/dimension/constants/index.d.ts +10 -6
  387. package/dist/src/plugin/dimension/cores/index.d.ts +15 -0
  388. package/dist/src/plugin/dimension/types/dimensions.d.ts +52 -24
  389. package/dist/src/plugin/dimension/utils/create-env-observer.d.ts +16 -7
  390. package/dist/src/plugin/dimension/utils/create-environment-observer.d.ts +33 -0
  391. package/dist/src/plugin/fullscreen/types/fullscreen.d.ts +7 -7
  392. package/dist/src/plugin/geolocation/types/geolocation.d.ts +4 -4
  393. package/dist/src/plugin/notification/types/notification.d.ts +4 -4
  394. package/dist/src/plugin/open/types/open.d.ts +12 -12
  395. package/dist/src/plugin/permission/constants/index.d.ts +3 -1
  396. package/dist/src/plugin/permission/types/permission.d.ts +7 -4
  397. package/dist/src/plugin/pip/types/pip.d.ts +7 -7
  398. package/dist/src/plugin/platform/constants/index.d.ts +1 -1
  399. package/dist/src/plugin/platform/types/platform.d.ts +13 -13
  400. package/dist/src/plugin/theme/types/theme.d.ts +2 -2
  401. package/dist/src/plugin/vibration/types/vibration.d.ts +3 -3
  402. package/dist/src/types/subscription-manager.d.ts +3 -3
  403. package/dist/src/utils/create-subscription-manager.d.ts +1 -1
  404. package/dist/src/utils/insert-sort.d.ts +1 -0
  405. package/package.json +1 -1
@@ -17,9 +17,20 @@ var FALLBACK_MEDIA_QUERY_LIST = {
17
17
 
18
18
  var Orientation;
19
19
  (function (Orientation) {
20
- Orientation["Portrait"] = "portrait";
21
- Orientation["Landscape"] = "landscape";
22
- Orientation["Unknown"] = "unknown";
20
+ Orientation["PortraitPrimary"] = "portrait-primary";
21
+ Orientation["PortraitSecondary"] = "portrait-secondary";
22
+ Orientation["LandscapePrimary"] = "landscape-primary";
23
+ Orientation["LandscapeSecondary"] = "landscape-secondary";
24
+ })(Orientation || (Orientation = {}));
25
+ (function (Orientation) {
26
+ function isLandscape(orientation) {
27
+ return orientation === Orientation.LandscapePrimary || orientation === Orientation.LandscapeSecondary;
28
+ }
29
+ Orientation.isLandscape = isLandscape;
30
+ function isPortrait(orientation) {
31
+ return orientation === Orientation.PortraitPrimary || orientation === Orientation.PortraitSecondary;
32
+ }
33
+ Orientation.isPortrait = isPortrait;
23
34
  })(Orientation || (Orientation = {}));
24
35
  var ENV_PRESETS = {
25
36
  'safe-area-inset': {
@@ -57,19 +68,16 @@ var ENV_PRESETS = {
57
68
  left: 'viewport-segment-left',
58
69
  },
59
70
  };
60
- var FALLBACK_DIMENSION = {
61
- innerWidth: -1,
62
- innerHeight: -1,
63
- outerWidth: -1,
64
- outerHeight: -1,
65
- scale: 1,
66
- orientation: Orientation.Unknown,
67
- };
68
- var MEDIA_QUERY_LIST;
71
+ var ORIENTATION_MEDIA_QUERY_LIST;
72
+ if (typeof globalThis.matchMedia !== 'undefined')
73
+ ORIENTATION_MEDIA_QUERY_LIST = globalThis.matchMedia('(orientation: portrait)');
74
+ else
75
+ ORIENTATION_MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
76
+ var DEVICE_POSTURE_MEDIA_QUERY_LIST;
69
77
  if (typeof globalThis.matchMedia !== 'undefined')
70
- MEDIA_QUERY_LIST = globalThis.matchMedia('(orientation: portrait)');
78
+ DEVICE_POSTURE_MEDIA_QUERY_LIST = globalThis.matchMedia('(device-posture: folded)');
71
79
  else
72
- MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
80
+ DEVICE_POSTURE_MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
73
81
 
74
82
  var IE_WRAPPER_STORE = [];
75
83
  var MEDIA_QUERY_LIST_WRAPPER_STORE = [];
@@ -304,6 +312,8 @@ function createSubscriptionManager(attach, detach) {
304
312
  },
305
313
  subscribe: function (listener, options) {
306
314
  if (options === void 0) { options = {}; }
315
+ if (typeof options.signal !== 'undefined' && options.signal.aborted)
316
+ return function () { };
307
317
  var entry = { fn: listener, once: false };
308
318
  if (typeof options.once !== 'undefined')
309
319
  entry.once = options.once;
@@ -322,12 +332,8 @@ function createSubscriptionManager(attach, detach) {
322
332
  EventListener.remove(entry.signal, { type: 'abort', callback: cleanup });
323
333
  removeEntry(entry);
324
334
  };
325
- if (typeof entry.signal !== 'undefined') {
326
- if (entry.signal.aborted)
327
- removeEntry(entry);
328
- else
329
- EventListener.add(entry.signal, { type: 'abort', callback: cleanup });
330
- }
335
+ if (typeof entry.signal !== 'undefined')
336
+ EventListener.add(entry.signal, { type: 'abort', callback: cleanup });
331
337
  return function unsubscribe() {
332
338
  removeEntry(entry);
333
339
  };
@@ -364,8 +370,355 @@ function setStyle(element, styles) {
364
370
  }
365
371
  }
366
372
 
373
+ function createHiddenElement(tagName, focusable) {
374
+ if (focusable === void 0) { focusable = true; }
375
+ var element = globalThis.document.createElement(tagName);
376
+ if (typeof element.width !== 'undefined')
377
+ element.width = '0';
378
+ if (typeof element.height !== 'undefined')
379
+ element.height = '0';
380
+ if (typeof element.border !== 'undefined')
381
+ element.border = '0';
382
+ if (typeof element.frameBorder !== 'undefined')
383
+ element.frameBorder = '0';
384
+ if (typeof element.scrolling !== 'undefined')
385
+ element.scrolling = 'no';
386
+ if (typeof element.cellPadding !== 'undefined')
387
+ element.cellPadding = '0';
388
+ if (typeof element.cellSpacing !== 'undefined')
389
+ element.cellSpacing = '0';
390
+ if (typeof element.frame !== 'undefined')
391
+ element.frame = 'void';
392
+ if (typeof element.rules !== 'undefined')
393
+ element.rules = 'none';
394
+ if (typeof element.noWrap !== 'undefined')
395
+ element.noWrap = true;
396
+ element.tabIndex = -1;
397
+ element.setAttribute('role', 'presentation');
398
+ if (focusable) {
399
+ setStyle(element, {
400
+ width: '1px',
401
+ height: '1px',
402
+ });
403
+ }
404
+ else {
405
+ element.setAttribute('aria-hidden', 'true');
406
+ setStyle(element, {
407
+ width: '0',
408
+ height: '0',
409
+ zIndex: '-9999',
410
+ display: 'none',
411
+ visibility: 'hidden',
412
+ pointerEvents: 'none',
413
+ });
414
+ }
415
+ setStyle(element, {
416
+ position: 'absolute',
417
+ top: '0',
418
+ left: '0',
419
+ padding: '0',
420
+ margin: '0',
421
+ border: 'none',
422
+ outline: 'hidden',
423
+ clip: 'rect(1px, 1px, 1px, 1px)',
424
+ clipPath: 'inset(50%)',
425
+ overflow: 'hidden',
426
+ whiteSpace: 'nowrap',
427
+ });
428
+ return element;
429
+ }
430
+
431
+ var MAX_SEGMENTS_PER_AXIS = 4;
367
432
  function noop() {
368
433
  }
434
+ function getSupportedEnvironment() {
435
+ if (typeof globalThis.CSS !== 'undefined' && typeof globalThis.CSS.supports === 'function') {
436
+ if (globalThis.CSS.supports('x: env(x)'))
437
+ return 'env';
438
+ if (globalThis.CSS.supports('x: constant(x)'))
439
+ return 'constant';
440
+ }
441
+ return undefined;
442
+ }
443
+ function getSegmentGrid() {
444
+ if (typeof globalThis.matchMedia !== 'function')
445
+ return { rows: 1, cols: 1 };
446
+ var cols = 1;
447
+ var rows = 1;
448
+ for (var i = MAX_SEGMENTS_PER_AXIS; i >= 2; i--) {
449
+ if (globalThis.matchMedia('(horizontal-viewport-segments: ' + i + ')').matches) {
450
+ cols = i;
451
+ break;
452
+ }
453
+ }
454
+ for (var i = MAX_SEGMENTS_PER_AXIS; i >= 2; i--) {
455
+ if (globalThis.matchMedia('(vertical-viewport-segments: ' + i + ')').matches) {
456
+ rows = i;
457
+ break;
458
+ }
459
+ }
460
+ return { rows: rows, cols: cols };
461
+ }
462
+ function buildSegmentMediaQueryLists() {
463
+ if (typeof globalThis.matchMedia !== 'function')
464
+ return [];
465
+ var mediaQueryLists = [];
466
+ for (var i = 2; i <= MAX_SEGMENTS_PER_AXIS; i++) {
467
+ mediaQueryLists.push(globalThis.matchMedia('(horizontal-viewport-segments: ' + i + ')'));
468
+ mediaQueryLists.push(globalThis.matchMedia('(vertical-viewport-segments: ' + i + ')'));
469
+ }
470
+ return mediaQueryLists;
471
+ }
472
+ function createViewportSegmentObserver() {
473
+ var viewport = globalThis.viewport;
474
+ var visualViewport = globalThis.visualViewport;
475
+ var devicePosture = globalThis.navigator.devicePosture;
476
+ var hasSegmentsAPI = typeof viewport !== 'undefined';
477
+ var hasLegacySegmentsAPI = !hasSegmentsAPI && typeof visualViewport !== 'undefined' && visualViewport !== null && typeof visualViewport.segments !== 'undefined';
478
+ var hasDevicePosture = typeof devicePosture !== 'undefined';
479
+ var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
480
+ var support = getSupportedEnvironment();
481
+ var cachedDiv = null;
482
+ var segmentMediaQueryLists = [];
483
+ var previousSegments = null;
484
+ function attachCSSFallbackListeners() {
485
+ segmentMediaQueryLists = buildSegmentMediaQueryLists();
486
+ for (var i = 0; i < segmentMediaQueryLists.length; i++)
487
+ EventListener.add(segmentMediaQueryLists[i], { type: 'change', callback: onSegmentChange });
488
+ if (DEVICE_POSTURE_MEDIA_QUERY_LIST.media !== 'not all')
489
+ EventListener.add(DEVICE_POSTURE_MEDIA_QUERY_LIST, { type: 'change', callback: onSegmentChange });
490
+ }
491
+ function detachCSSFallbackListeners() {
492
+ for (var i = 0; i < segmentMediaQueryLists.length; i++)
493
+ EventListener.remove(segmentMediaQueryLists[i], { type: 'change', callback: onSegmentChange });
494
+ segmentMediaQueryLists = [];
495
+ if (DEVICE_POSTURE_MEDIA_QUERY_LIST.media !== 'not all')
496
+ EventListener.remove(DEVICE_POSTURE_MEDIA_QUERY_LIST, { type: 'change', callback: onSegmentChange });
497
+ }
498
+ function attachDevicePostureChangeListener() {
499
+ if (hasDevicePosture)
500
+ EventListener.add(devicePosture, { type: 'change', callback: onSegmentChange });
501
+ attachCSSFallbackListeners();
502
+ }
503
+ function detachDevicePostureChangeListener() {
504
+ if (hasDevicePosture)
505
+ EventListener.remove(devicePosture, { type: 'change', callback: onSegmentChange });
506
+ detachCSSFallbackListeners();
507
+ }
508
+ function attachVisualViewportResizeListener() {
509
+ EventListener.add(visualViewport, { type: 'resize', callback: onSegmentChange, options: { passive: true } });
510
+ }
511
+ function detachVisualViewportResizeListener() {
512
+ EventListener.remove(visualViewport, { type: 'resize', callback: onSegmentChange, options: { passive: true } });
513
+ }
514
+ function attachOnChange() {
515
+ EventListener.add(globalThis, { type: 'resize', callback: onSegmentChange });
516
+ if (hasSegmentsAPI) {
517
+ attachDevicePostureChangeListener();
518
+ }
519
+ else if (hasLegacySegmentsAPI) {
520
+ attachVisualViewportResizeListener();
521
+ attachDevicePostureChangeListener();
522
+ }
523
+ else {
524
+ getOrCreateCachedDiv();
525
+ attachVisualViewportResizeListener();
526
+ }
527
+ }
528
+ function detachOnChange() {
529
+ EventListener.remove(globalThis, { type: 'resize', callback: onSegmentChange });
530
+ if (hasSegmentsAPI) {
531
+ detachDevicePostureChangeListener();
532
+ }
533
+ else if (hasLegacySegmentsAPI) {
534
+ detachVisualViewportResizeListener();
535
+ detachDevicePostureChangeListener();
536
+ }
537
+ else {
538
+ detachVisualViewportResizeListener();
539
+ releaseDiv();
540
+ }
541
+ }
542
+ function segmentsEqual(segments1, segments2) {
543
+ if (segments1.length !== segments2.length)
544
+ return false;
545
+ for (var i = 0; i < segments1.length; i++) {
546
+ var segment1 = segments1[i];
547
+ var segment2 = segments2[i];
548
+ if (segment1.width !== segment2.width || segment1.height !== segment2.height || segment1.top !== segment2.top || segment1.left !== segment2.left || segment1.bottom !== segment2.bottom || segment1.right !== segment2.right)
549
+ return false;
550
+ }
551
+ return true;
552
+ }
553
+ function onSegmentChange() {
554
+ var next = getValue();
555
+ if (previousSegments !== null && segmentsEqual(previousSegments, next))
556
+ return;
557
+ previousSegments = next;
558
+ onChangeSubscriptionManager.emit(next);
559
+ }
560
+ function buildDiv() {
561
+ var div = createHiddenElement('div');
562
+ div.setAttribute('data-viewport-segment-observer', '');
563
+ div.style.setProperty('position', 'fixed', 'important');
564
+ div.style.setProperty('top', '0', 'important');
565
+ div.style.setProperty('left', '0', 'important');
566
+ div.style.setProperty('visibility', 'hidden', 'important');
567
+ div.style.setProperty('pointer-events', 'none', 'important');
568
+ div.style.setProperty('z-index', '-1', 'important');
569
+ div.style.setProperty('box-sizing', 'content-box', 'important');
570
+ div.style.setProperty('padding', '0', 'important');
571
+ div.style.setProperty('margin', '0', 'important');
572
+ div.style.setProperty('border', '0', 'important');
573
+ div.style.setProperty('width', '0', 'important');
574
+ div.style.setProperty('height', '0', 'important');
575
+ div.style.setProperty('min-width', '0', 'important');
576
+ div.style.setProperty('min-height', '0', 'important');
577
+ div.style.setProperty('max-width', 'none', 'important');
578
+ div.style.setProperty('max-height', 'none', 'important');
579
+ div.style.setProperty('transition', 'none', 'important');
580
+ div.style.setProperty('animation', 'none', 'important');
581
+ div.style.setProperty('display', 'block', 'important');
582
+ div.style.setProperty('float', 'none', 'important');
583
+ div.style.setProperty('transform', 'none', 'important');
584
+ return div;
585
+ }
586
+ function getOrCreateCachedDiv() {
587
+ if (cachedDiv !== null)
588
+ return cachedDiv;
589
+ cachedDiv = buildDiv();
590
+ globalThis.document.body.appendChild(cachedDiv);
591
+ return cachedDiv;
592
+ }
593
+ function releaseDiv() {
594
+ if (cachedDiv !== null) {
595
+ if (cachedDiv.parentNode !== null)
596
+ cachedDiv.parentNode.removeChild(cachedDiv);
597
+ cachedDiv = null;
598
+ }
599
+ }
600
+ function readFromSegmentsAPI() {
601
+ var segments;
602
+ if (hasSegmentsAPI)
603
+ segments = viewport.segments;
604
+ else
605
+ segments = visualViewport.segments;
606
+ if (segments === null || typeof segments === 'undefined')
607
+ return [];
608
+ var results = [];
609
+ for (var i = 0; i < segments.length; i++) {
610
+ var segment = segments[i];
611
+ results.push({
612
+ width: segment.width,
613
+ height: segment.height,
614
+ top: segment.top,
615
+ left: segment.left,
616
+ bottom: segment.bottom,
617
+ right: segment.right,
618
+ });
619
+ }
620
+ return results;
621
+ }
622
+ function buildFullViewportSegment() {
623
+ var width = globalThis.innerWidth;
624
+ var height = globalThis.innerHeight;
625
+ return {
626
+ width: width,
627
+ height: height,
628
+ top: 0,
629
+ left: 0,
630
+ bottom: height,
631
+ right: width,
632
+ };
633
+ }
634
+ function readFromCSSEnv(div) {
635
+ var grid = getSegmentGrid();
636
+ if (grid.rows === 1 && grid.cols === 1)
637
+ return [buildFullViewportSegment()];
638
+ if (typeof support === 'undefined' || typeof div.style.setProperty === 'undefined')
639
+ return [buildFullViewportSegment()];
640
+ var results = [];
641
+ for (var row = 0; row < grid.rows; row++) {
642
+ for (var col = 0; col < grid.cols; col++) {
643
+ div.style.setProperty('width', support + '(viewport-segment-width ' + row + ' ' + col + ', -1px)', 'important');
644
+ div.style.setProperty('height', support + '(viewport-segment-height ' + row + ' ' + col + ', -1px)', 'important');
645
+ div.style.setProperty('margin-top', support + '(viewport-segment-top ' + row + ' ' + col + ', -1px)', 'important');
646
+ div.style.setProperty('margin-left', support + '(viewport-segment-left ' + row + ' ' + col + ', -1px)', 'important');
647
+ div.style.setProperty('margin-bottom', support + '(viewport-segment-bottom ' + row + ' ' + col + ', -1px)', 'important');
648
+ div.style.setProperty('margin-right', support + '(viewport-segment-right ' + row + ' ' + col + ', -1px)', 'important');
649
+ var computed = globalThis.getComputedStyle(div);
650
+ var top_1 = globalThis.parseFloat(computed.marginTop);
651
+ if (top_1 < 0)
652
+ continue;
653
+ var left = globalThis.parseFloat(computed.marginLeft);
654
+ var bottom = globalThis.parseFloat(computed.marginBottom);
655
+ var right = globalThis.parseFloat(computed.marginRight);
656
+ var width = globalThis.parseFloat(computed.width);
657
+ var height = globalThis.parseFloat(computed.height);
658
+ results.push({
659
+ width: width,
660
+ height: height,
661
+ top: top_1,
662
+ left: left,
663
+ bottom: bottom,
664
+ right: right,
665
+ });
666
+ }
667
+ }
668
+ return results;
669
+ }
670
+ function getValue() {
671
+ if (hasSegmentsAPI || hasLegacySegmentsAPI)
672
+ return readFromSegmentsAPI();
673
+ if (cachedDiv !== null)
674
+ return readFromCSSEnv(cachedDiv);
675
+ var div = buildDiv();
676
+ globalThis.document.body.appendChild(div);
677
+ var results = readFromCSSEnv(div);
678
+ globalThis.document.body.removeChild(div);
679
+ return results;
680
+ }
681
+ function useCssVariable(prefix) {
682
+ if (typeof globalThis.document === 'undefined')
683
+ return noop;
684
+ var attributes = keys(ENV_PRESETS['viewport-segment']);
685
+ var element = globalThis.document.documentElement;
686
+ var lastCount = 0;
687
+ function applySegments(segments) {
688
+ for (var i = segments.length; i < lastCount; i++) {
689
+ for (var j = 0; j < attributes.length; j++) {
690
+ element.style.removeProperty('--' + prefix + '-' + i + '-' + attributes[j]);
691
+ }
692
+ }
693
+ lastCount = segments.length;
694
+ for (var i = 0; i < segments.length; i++) {
695
+ var segment = segments[i];
696
+ for (var j = 0; j < attributes.length; j++) {
697
+ var attribute = attributes[j];
698
+ element.style.setProperty('--' + prefix + '-' + i + '-' + attribute, segment[attribute] + 'px');
699
+ }
700
+ }
701
+ }
702
+ applySegments(getValue());
703
+ var unsubscribe = onChangeSubscriptionManager.subscribe(function (segments) {
704
+ applySegments(segments);
705
+ });
706
+ return function () {
707
+ unsubscribe();
708
+ for (var i = 0; i < lastCount; i++)
709
+ for (var j = 0; j < attributes.length; j++)
710
+ element.style.removeProperty('--' + prefix + '-' + i + '-' + attributes[j]);
711
+ lastCount = 0;
712
+ };
713
+ }
714
+ return {
715
+ get value() {
716
+ return getValue();
717
+ },
718
+ onChange: onChangeSubscriptionManager.subscribe,
719
+ useCssVariable: useCssVariable,
720
+ };
721
+ }
369
722
  function createVirtualKeyboardObserver() {
370
723
  var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
371
724
  function attachOnChange() {
@@ -383,16 +736,16 @@ function createVirtualKeyboardObserver() {
383
736
  var top = rect.y;
384
737
  var width = rect.width;
385
738
  var height = rect.height;
386
- var right = (function () {
387
- if (width === 0)
388
- return 0;
389
- return Math.max(0, globalThis.innerWidth - (left + width));
390
- })();
391
- var bottom = (function () {
392
- if (height === 0)
393
- return 0;
394
- return Math.max(0, globalThis.innerHeight - (top + height));
395
- })();
739
+ var right;
740
+ if (width === 0)
741
+ right = 0;
742
+ else
743
+ right = Math.max(0, globalThis.innerWidth - (left + width));
744
+ var bottom;
745
+ if (height === 0)
746
+ bottom = 0;
747
+ else
748
+ bottom = Math.max(0, globalThis.innerHeight - (top + height));
396
749
  return {
397
750
  top: top,
398
751
  right: right,
@@ -402,17 +755,43 @@ function createVirtualKeyboardObserver() {
402
755
  height: height,
403
756
  };
404
757
  }
758
+ function useCssVariable(prefix) {
759
+ if (typeof globalThis.document === 'undefined')
760
+ return noop;
761
+ var attributes = keys(ENV_PRESETS['keyboard-inset']);
762
+ var element = globalThis.document.documentElement;
763
+ function applyValues(values) {
764
+ for (var i = 0; i < attributes.length; i++) {
765
+ var attribute = attributes[i];
766
+ element.style.setProperty('--' + prefix + '-' + attribute, values[attribute] + 'px');
767
+ }
768
+ }
769
+ applyValues(getValue());
770
+ var unsubscribe = onChangeSubscriptionManager.subscribe(function (values) {
771
+ applyValues(values);
772
+ });
773
+ return function () {
774
+ unsubscribe();
775
+ for (var i = 0; i < attributes.length; i++)
776
+ element.style.removeProperty('--' + prefix + '-' + attributes[i]);
777
+ };
778
+ }
405
779
  return {
406
- get: getValue,
780
+ get value() {
781
+ return getValue();
782
+ },
407
783
  onChange: onChangeSubscriptionManager.subscribe,
784
+ useCssVariable: useCssVariable,
408
785
  };
409
786
  }
410
- function createEnvObserver(preset) {
787
+ function createEnvironmentObserver(preset) {
411
788
  if (preset === 'keyboard-inset' && typeof globalThis.navigator.virtualKeyboard !== 'undefined')
412
789
  return createVirtualKeyboardObserver();
413
- var envMap = ENV_PRESETS[preset];
414
- var attributes = keys(envMap);
415
- var support = getSupportedEnv();
790
+ if (preset === 'viewport-segment')
791
+ return createViewportSegmentObserver();
792
+ var environmentMap = ENV_PRESETS[preset];
793
+ var attributes = keys(environmentMap);
794
+ var support = getSupportedEnvironment();
416
795
  var parentReadyCallbacks = [];
417
796
  var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
418
797
  var elementComputedStyle = {};
@@ -429,15 +808,6 @@ function createEnvObserver(preset) {
429
808
  function detachOnChange() {
430
809
  removeDetector();
431
810
  }
432
- function getSupportedEnv() {
433
- if (typeof globalThis.CSS !== 'undefined' && typeof globalThis.CSS.supports === 'function') {
434
- if (globalThis.CSS.supports('x: env(x)'))
435
- return 'env';
436
- if (globalThis.CSS.supports('x: constant(x)'))
437
- return 'constant';
438
- }
439
- return undefined;
440
- }
441
811
  function isSameValues(a, b) {
442
812
  for (var i = 0; i < attributes.length; i++) {
443
813
  var key = attributes[i];
@@ -477,7 +847,7 @@ function createEnvObserver(preset) {
477
847
  parentReadyCallbacks[i]();
478
848
  }
479
849
  function addChild(parent, attribute) {
480
- var envVar = envMap[attribute];
850
+ var envVar = environmentMap[attribute];
481
851
  var p1 = globalThis.document.createElement('div');
482
852
  var p2 = globalThis.document.createElement('div');
483
853
  var c1 = globalThis.document.createElement('div');
@@ -540,9 +910,8 @@ function createEnvObserver(preset) {
540
910
  }
541
911
  function init() {
542
912
  if (typeof support === 'undefined') {
543
- for (var i = 0; i < attributes.length; i++) {
913
+ for (var i = 0; i < attributes.length; i++)
544
914
  elementComputedStyle[attributes[i]] = 0;
545
- }
546
915
  return;
547
916
  }
548
917
  elementComputedStyle = {};
@@ -586,8 +955,28 @@ function createEnvObserver(preset) {
586
955
  }
587
956
  return result;
588
957
  }
958
+ function useCssVariable(prefix) {
959
+ if (typeof support === 'undefined' || typeof globalThis.document === 'undefined')
960
+ return noop;
961
+ var element = globalThis.document.documentElement;
962
+ function applyValues(values) {
963
+ for (var i = 0; i < attributes.length; i++) {
964
+ var attribute = attributes[i];
965
+ element.style.setProperty('--' + prefix + '-' + String(attributes[i]), values[attribute] + 'px');
966
+ }
967
+ }
968
+ var unsubscribe = onChangeSubscriptionManager.subscribe(function (values) {
969
+ applyValues(values);
970
+ });
971
+ applyValues(readValues());
972
+ return function () {
973
+ unsubscribe();
974
+ for (var i = 0; i < attributes.length; i++)
975
+ element.style.removeProperty('--' + prefix + '-' + String(attributes[i]));
976
+ };
977
+ }
589
978
  return {
590
- get: function () {
979
+ get value() {
591
980
  if (parentDiv !== null)
592
981
  return readValues();
593
982
  init();
@@ -600,55 +989,156 @@ function createEnvObserver(preset) {
600
989
  if (typeof support === 'undefined')
601
990
  return noop;
602
991
  return onChangeSubscriptionManager.subscribe(callback, options);
603
- }
992
+ },
993
+ useCssVariable: useCssVariable
604
994
  };
605
995
  }
606
996
 
607
- var safeAreaInsetObserver = createEnvObserver('safe-area-inset');
608
- var safeAreaMaxInsetObserver = createEnvObserver('safe-area-max-inset');
609
- var keyboardInsetObserver = createEnvObserver('keyboard-inset');
610
- var titlebarAreaObserver = createEnvObserver('titlebar-area');
611
- var viewportSegmentObserver = createEnvObserver('viewport-segment');
612
- var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
997
+ function createCustomError(name, Base) {
998
+ if (Base === void 0) { Base = Error; }
999
+ function CustomError(message) {
1000
+ if (!(this instanceof CustomError))
1001
+ return new CustomError(message);
1002
+ var error = (function () {
1003
+ if (typeof message === 'undefined')
1004
+ return new Base('');
1005
+ return new Base(message);
1006
+ })();
1007
+ if (typeof Object.setPrototypeOf === 'function')
1008
+ Object.setPrototypeOf(error, CustomError.prototype);
1009
+ else
1010
+ error.__proto__ = CustomError.prototype;
1011
+ error.name = name;
1012
+ if (typeof message !== 'undefined')
1013
+ error.message = message;
1014
+ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1015
+ try {
1016
+ Object.defineProperty(error, Symbol.toStringTag, {
1017
+ value: name,
1018
+ writable: false,
1019
+ enumerable: false,
1020
+ configurable: true
1021
+ });
1022
+ }
1023
+ catch (_) {
1024
+ }
1025
+ }
1026
+ if (typeof Error.captureStackTrace === 'function') {
1027
+ Error.captureStackTrace(error, CustomError);
1028
+ }
1029
+ else if (Base.captureStackTrace && typeof Base.captureStackTrace === 'function') {
1030
+ Base.captureStackTrace(error, CustomError);
1031
+ }
1032
+ else {
1033
+ try {
1034
+ var tempError = new Base();
1035
+ if (tempError.stack)
1036
+ error.stack = tempError.stack;
1037
+ }
1038
+ catch (_) {
1039
+ }
1040
+ }
1041
+ return error;
1042
+ }
1043
+ CustomError.prototype = Object.create(Base.prototype, {
1044
+ constructor: {
1045
+ value: CustomError,
1046
+ writable: true,
1047
+ enumerable: false,
1048
+ configurable: true
1049
+ }
1050
+ });
1051
+ try {
1052
+ Object.defineProperty(CustomError.prototype, 'name', {
1053
+ value: name,
1054
+ writable: true,
1055
+ enumerable: false,
1056
+ configurable: true
1057
+ });
1058
+ }
1059
+ catch (_) {
1060
+ try {
1061
+ CustomError.prototype.name = name;
1062
+ }
1063
+ catch (_) {
1064
+ }
1065
+ }
1066
+ try {
1067
+ Object.defineProperty(CustomError, 'name', {
1068
+ value: name,
1069
+ writable: false,
1070
+ enumerable: false,
1071
+ configurable: true
1072
+ });
1073
+ }
1074
+ catch (_) {
1075
+ }
1076
+ return CustomError;
1077
+ }
1078
+
1079
+ var PermissionNotGrantedError = createCustomError('PermissionNotGrantedError');
1080
+
1081
+ var NotSupportedError = createCustomError('NotSupportedError');
1082
+
1083
+ var safeAreaInsetObserver = createEnvironmentObserver('safe-area-inset');
1084
+ var safeAreaMaxInsetObserver = createEnvironmentObserver('safe-area-max-inset');
1085
+ var keyboardInsetObserver = createEnvironmentObserver('keyboard-inset');
1086
+ var titlebarAreaObserver = createEnvironmentObserver('titlebar-area');
1087
+ var viewportSegmentObserver = createEnvironmentObserver('viewport-segment');
1088
+ var onDimensionChangeSubscriptionManager = createSubscriptionManager(attachOnDimensionChange, detachOnDimensionChange);
1089
+ var onScreenOrientationChangeSubscriptionManager = createSubscriptionManager(attachOnScreenOrientationChange, detachOnScreenOrientationChange);
1090
+ var onDeviceOrientationChangeSubscriptionManager = createSubscriptionManager(attachOnDeviceOrientationChange, detachOnDeviceOrientationChange);
613
1091
  var dimensionRef = null;
1092
+ var screenOrientationRef = null;
1093
+ var deviceOrientationRef = null;
614
1094
  var Dimension = {
615
1095
  get value() {
616
1096
  return getDimension();
617
1097
  },
618
1098
  environment: getEnvironment(),
619
- onChange: onChangeSubscriptionManager.subscribe,
1099
+ screenOrientation: getScreenOrientation(),
1100
+ deviceOrientation: getDeviceOrientation(),
1101
+ onChange: onDimensionChangeSubscriptionManager.subscribe,
620
1102
  Constants: {
621
1103
  Orientation: Orientation,
622
1104
  },
623
- Errors: {},
1105
+ Errors: {
1106
+ NotSupportedError: NotSupportedError,
1107
+ PermissionNotGrantedError: PermissionNotGrantedError,
1108
+ },
624
1109
  };
625
1110
  function getOrientation() {
626
- if (typeof globalThis.screen !== 'undefined') {
1111
+ if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.type !== 'undefined') {
627
1112
  switch (globalThis.screen.orientation.type) {
628
1113
  case 'portrait-primary':
1114
+ return Orientation.PortraitPrimary;
629
1115
  case 'portrait-secondary':
630
- return Orientation.Portrait;
1116
+ return Orientation.PortraitSecondary;
631
1117
  case 'landscape-primary':
1118
+ return Orientation.LandscapePrimary;
632
1119
  case 'landscape-secondary':
633
- return Orientation.Landscape;
1120
+ return Orientation.LandscapeSecondary;
634
1121
  }
635
1122
  }
636
1123
  if (typeof globalThis.orientation !== 'undefined') {
637
1124
  switch (globalThis.orientation) {
638
1125
  case 0:
1126
+ return Orientation.PortraitPrimary;
639
1127
  case 180:
640
- return Orientation.Portrait;
1128
+ return Orientation.PortraitSecondary;
641
1129
  case 90:
1130
+ return Orientation.LandscapePrimary;
1131
+ case -90:
642
1132
  case 270:
643
- return Orientation.Landscape;
1133
+ return Orientation.LandscapeSecondary;
644
1134
  }
645
1135
  }
646
- if (MEDIA_QUERY_LIST.media === 'not all')
647
- return Orientation.Unknown;
648
- else if (MEDIA_QUERY_LIST.matches)
649
- return Orientation.Portrait;
1136
+ if (ORIENTATION_MEDIA_QUERY_LIST.media === 'not all')
1137
+ throw new NotSupportedError('\'screen.orientation\', \'window.orientation\', and the orientation media query are all unsupported');
1138
+ if (ORIENTATION_MEDIA_QUERY_LIST.matches)
1139
+ return Orientation.PortraitPrimary;
650
1140
  else
651
- return Orientation.Landscape;
1141
+ return Orientation.LandscapePrimary;
652
1142
  }
653
1143
  function getScale() {
654
1144
  if (typeof globalThis.devicePixelRatio !== 'undefined')
@@ -657,75 +1147,175 @@ function getScale() {
657
1147
  }
658
1148
  function getEnvironment() {
659
1149
  return {
660
- safeAreaInset: {
661
- get value() {
662
- return safeAreaInsetObserver.get();
663
- },
664
- onChange: safeAreaInsetObserver.onChange,
1150
+ safeAreaInset: safeAreaInsetObserver,
1151
+ safeAreaMaxInset: safeAreaMaxInsetObserver,
1152
+ keyboardInset: keyboardInsetObserver,
1153
+ titlebarArea: titlebarAreaObserver,
1154
+ viewportSegment: viewportSegmentObserver,
1155
+ };
1156
+ }
1157
+ function getScreenOrientation() {
1158
+ return {
1159
+ get supported() {
1160
+ return screenOrientationSupported();
665
1161
  },
666
- safeAreaMaxInset: {
667
- get value() {
668
- return safeAreaMaxInsetObserver.get();
669
- },
670
- onChange: safeAreaMaxInsetObserver.onChange,
1162
+ get value() {
1163
+ return getOrientation();
671
1164
  },
672
- keyboardInset: {
673
- get value() {
674
- return keyboardInsetObserver.get();
675
- },
676
- onChange: keyboardInsetObserver.onChange,
1165
+ onChange: onScreenOrientationChangeSubscriptionManager.subscribe,
1166
+ };
1167
+ }
1168
+ function getDeviceOrientation() {
1169
+ return {
1170
+ get supported() {
1171
+ return deviceOrientationSupported();
677
1172
  },
678
- titlebarArea: {
679
- get value() {
680
- return titlebarAreaObserver.get();
681
- },
682
- onChange: titlebarAreaObserver.onChange,
683
- },
684
- viewportSegment: {
685
- get value() {
686
- return viewportSegmentObserver.get();
687
- },
688
- onChange: viewportSegmentObserver.onChange,
1173
+ get value() {
1174
+ return getDeviceOrientationValue();
689
1175
  },
1176
+ onChange: onDeviceOrientationChangeSubscriptionManager.subscribe,
690
1177
  };
691
1178
  }
692
1179
  function getDimension() {
1180
+ var innerWidth = 0;
1181
+ var innerHeight = 0;
1182
+ var outerWidth = 0;
1183
+ var outerHeight = 0;
1184
+ var scale = getScale();
693
1185
  if (typeof globalThis.innerWidth !== 'undefined') {
694
- return {
695
- innerWidth: globalThis.innerWidth,
696
- innerHeight: globalThis.innerHeight,
697
- outerWidth: globalThis.outerWidth,
698
- outerHeight: globalThis.outerHeight,
699
- scale: getScale(),
700
- orientation: getOrientation(),
701
- };
1186
+ innerWidth = globalThis.innerWidth;
1187
+ innerHeight = globalThis.innerHeight;
1188
+ outerWidth = globalThis.outerWidth;
1189
+ outerHeight = globalThis.outerHeight;
702
1190
  }
703
- return FALLBACK_DIMENSION;
1191
+ return {
1192
+ innerWidth: innerWidth,
1193
+ innerHeight: innerHeight,
1194
+ outerWidth: outerWidth,
1195
+ outerHeight: outerHeight,
1196
+ scale: scale,
1197
+ };
704
1198
  }
705
- function attachOnChange() {
1199
+ function attachOnDimensionChange() {
706
1200
  dimensionRef = getDimension();
707
- EventListener.add(globalThis, { type: 'resize', callback: onResize });
708
- if (typeof globalThis.screen.orientation.addEventListener === 'function')
709
- EventListener.add(globalThis.screen.orientation, { type: 'change', callback: onResize });
710
- else if (typeof globalThis.orientation !== 'undefined')
711
- EventListener.add(globalThis, { type: 'orientationChange', callback: onResize });
712
- else if (MEDIA_QUERY_LIST.media !== 'not all')
713
- EventListener.add(MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
1201
+ EventListener.add(globalThis, { type: 'resize', callback: onDimensionChange });
714
1202
  }
715
- function detachOnChange() {
1203
+ function detachOnDimensionChange() {
716
1204
  dimensionRef = null;
717
- EventListener.remove(globalThis, { type: 'resize', callback: onResize });
718
- if (typeof globalThis.screen.orientation.removeEventListener === 'function')
719
- EventListener.remove(globalThis.screen.orientation, { type: 'change', callback: onResize });
720
- else if (typeof globalThis.orientation !== 'undefined')
721
- EventListener.remove(globalThis, { type: 'orientationChange', callback: onResize });
722
- else if (MEDIA_QUERY_LIST.media !== 'not all')
723
- EventListener.remove(MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
1205
+ EventListener.remove(globalThis, { type: 'resize', callback: onDimensionChange });
724
1206
  }
725
- function onResize() {
1207
+ function onDimensionChange() {
726
1208
  var dimension = getDimension();
727
- 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)
728
- onChangeSubscriptionManager.emit(dimensionRef = dimension);
1209
+ if (dimensionRef === null || dimension.innerWidth !== dimensionRef.innerWidth || dimension.innerHeight !== dimensionRef.innerHeight || dimension.outerWidth !== dimensionRef.outerWidth || dimension.outerHeight !== dimensionRef.outerHeight || dimension.scale !== dimensionRef.scale)
1210
+ onDimensionChangeSubscriptionManager.emit(dimensionRef = dimension);
1211
+ }
1212
+ function screenOrientationSupported() {
1213
+ if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.type !== 'undefined')
1214
+ return true;
1215
+ if (typeof globalThis.orientation !== 'undefined')
1216
+ return true;
1217
+ return ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all';
1218
+ }
1219
+ function attachOnScreenOrientationChange() {
1220
+ if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.addEventListener === 'function')
1221
+ EventListener.add(globalThis.screen.orientation, {
1222
+ type: 'change',
1223
+ callback: onScreenOrientationChange
1224
+ });
1225
+ else if (typeof globalThis.orientation !== 'undefined')
1226
+ EventListener.add(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
1227
+ else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
1228
+ EventListener.add(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
1229
+ throw new NotSupportedError('\'screen.orientation\', \'window.orientation\', and the orientation media query are all unsupported');
1230
+ }
1231
+ function detachOnScreenOrientationChange() {
1232
+ if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.removeEventListener === 'function')
1233
+ EventListener.remove(globalThis.screen.orientation, {
1234
+ type: 'change',
1235
+ callback: onScreenOrientationChange
1236
+ });
1237
+ else if (typeof globalThis.orientation !== 'undefined')
1238
+ EventListener.remove(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
1239
+ else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
1240
+ EventListener.remove(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
1241
+ throw new NotSupportedError('\'screen.orientation\', \'window.orientation\', and the orientation media query are all unsupported');
1242
+ }
1243
+ function onScreenOrientationChange() {
1244
+ var orientation = getOrientation();
1245
+ if (screenOrientationRef === null || orientation !== screenOrientationRef)
1246
+ onScreenOrientationChangeSubscriptionManager.emit(screenOrientationRef = orientation);
1247
+ }
1248
+ function deviceOrientationSupported() {
1249
+ return typeof globalThis.DeviceOrientationEvent !== 'undefined';
1250
+ }
1251
+ function attachOnDeviceOrientationChange() {
1252
+ return new Promise(function (resolve, reject) {
1253
+ if (!deviceOrientationSupported())
1254
+ return reject(new NotSupportedError('\'window.DeviceOrientationEvent\' does not supported.'));
1255
+ var DeviceOrientationEventWithPermission = DeviceOrientationEvent;
1256
+ if (typeof DeviceOrientationEventWithPermission.requestPermission === 'function') {
1257
+ DeviceOrientationEventWithPermission.requestPermission().then(function (permission) {
1258
+ if (permission === 'granted') {
1259
+ EventListener.add(globalThis, { type: 'deviceorientation', callback: onDeviceOrientationChange });
1260
+ return resolve();
1261
+ }
1262
+ return reject(new PermissionNotGrantedError('\'deviceorientation\' permission is not granted.'));
1263
+ }).catch(function (_) {
1264
+ return reject(new NotSupportedError('\'window.DeviceOrientationEvent\' does not supported.'));
1265
+ });
1266
+ }
1267
+ else {
1268
+ EventListener.add(globalThis, { type: 'deviceorientation', callback: onDeviceOrientationChange });
1269
+ return resolve();
1270
+ }
1271
+ });
1272
+ }
1273
+ function detachOnDeviceOrientationChange() {
1274
+ EventListener.remove(globalThis, { type: 'deviceorientation', callback: onDeviceOrientationChange });
1275
+ }
1276
+ function onDeviceOrientationChange(event) {
1277
+ deviceOrientationRef = {
1278
+ alpha: event.alpha,
1279
+ beta: event.beta,
1280
+ gamma: event.gamma,
1281
+ absolute: event.absolute,
1282
+ };
1283
+ onDeviceOrientationChangeSubscriptionManager.emit(deviceOrientationRef);
1284
+ }
1285
+ function getDeviceOrientationValue() {
1286
+ return new Promise(function (resolve, reject) {
1287
+ if (deviceOrientationRef !== null)
1288
+ return resolve(deviceOrientationRef);
1289
+ if (!deviceOrientationSupported())
1290
+ return reject(new NotSupportedError('\'window.DeviceOrientationEvent\' does not supported.'));
1291
+ var DeviceOrientationEventWithPermission = DeviceOrientationEvent;
1292
+ var callback = function (event) {
1293
+ var value = {
1294
+ alpha: event.alpha,
1295
+ beta: event.beta,
1296
+ gamma: event.gamma,
1297
+ absolute: event.absolute,
1298
+ };
1299
+ deviceOrientationRef = value;
1300
+ EventListener.remove(globalThis, { type: 'deviceorientation', callback: callback });
1301
+ return resolve(value);
1302
+ };
1303
+ if (typeof DeviceOrientationEventWithPermission.requestPermission === 'function') {
1304
+ DeviceOrientationEventWithPermission.requestPermission().then(function (permission) {
1305
+ if (permission === 'granted') {
1306
+ EventListener.add(globalThis, { type: 'deviceorientation', callback: callback });
1307
+ return;
1308
+ }
1309
+ return reject(new PermissionNotGrantedError('\'deviceorientation\' permission is not granted.'));
1310
+ }).catch(function (_) {
1311
+ return reject(new NotSupportedError('\'window.DeviceOrientationEvent\' does not supported.'));
1312
+ });
1313
+ }
1314
+ else {
1315
+ EventListener.add(globalThis, { type: 'deviceorientation', callback: callback });
1316
+ return;
1317
+ }
1318
+ });
729
1319
  }
730
1320
 
731
- export { ENV_PRESETS, FALLBACK_DIMENSION, MEDIA_QUERY_LIST, Orientation, Dimension as default };
1321
+ export { DEVICE_POSTURE_MEDIA_QUERY_LIST, ENV_PRESETS, ORIENTATION_MEDIA_QUERY_LIST, Orientation, Dimension as default };