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