native-fn 1.2.1 → 1.3.0
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 +175 -39
- package/dist/index.d.ts +42 -21
- package/dist/native.cjs +412 -110
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +412 -110
- package/dist/native.umd.js +412 -110
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/appearance/index.cjs +16 -18
- package/dist/plugin/appearance/index.d.ts +2 -2
- package/dist/plugin/appearance/index.mjs +17 -19
- package/dist/plugin/appearance/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/appearance/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/appearance/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/appearance/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/appearance/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/badge/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/badge/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/badge/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.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.mjs +4 -6
- package/dist/plugin/battery/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/battery/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/battery/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/battery/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/clipboard/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/clipboard/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/clipboard/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/clipboard/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/dimension/index.cjs +456 -97
- package/dist/plugin/dimension/index.d.ts +45 -24
- package/dist/plugin/dimension/index.mjs +457 -97
- package/dist/plugin/dimension/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/dimension/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/dimension/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/dimension/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/fullscreen/index.cjs +9 -11
- package/dist/plugin/fullscreen/index.mjs +9 -11
- package/dist/plugin/fullscreen/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/fullscreen/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/fullscreen/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/fullscreen/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/fullscreen/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/geolocation/index.cjs +4 -6
- package/dist/plugin/geolocation/index.mjs +4 -6
- package/dist/plugin/geolocation/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/geolocation/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/geolocation/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/geolocation/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/notification/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/notification/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/notification/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/notification/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/open/index.cjs +6 -6
- package/dist/plugin/open/index.d.ts +16 -0
- package/dist/plugin/open/index.mjs +6 -6
- package/dist/plugin/open/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/open/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/open/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/open/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/open/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/permission/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/permission/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/permission/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/permission/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/pip/index.cjs +9 -11
- package/dist/plugin/pip/index.mjs +9 -11
- package/dist/plugin/pip/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/pip/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/pip/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/pip/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/pip/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/platform/index.cjs +11 -12
- package/dist/plugin/platform/index.d.ts +17 -1
- package/dist/plugin/platform/index.mjs +5 -5
- package/dist/plugin/platform/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/platform/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/platform/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/platform/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/platform/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/theme/index.cjs +5 -5
- package/dist/plugin/theme/index.mjs +5 -5
- package/dist/plugin/theme/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/theme/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/theme/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/theme/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/plugin/theme/src/utils/insert-sort.d.ts +1 -0
- package/dist/plugin/vibration/src/plugin/appearance/constants/index.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/dimension/constants/index.d.ts +2 -3
- package/dist/plugin/vibration/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/plugin/vibration/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.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/dimension/constants/index.d.ts +2 -3
- package/dist/src/plugin/dimension/cores/index.d.ts +15 -0
- package/dist/src/plugin/dimension/types/dimensions.d.ts +26 -20
- 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/platform/constants/index.d.ts +1 -1
- package/dist/src/utils/insert-sort.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,9 +56,10 @@ yarn add native-fn
|
|
|
56
56
|
- **[fullscreen](#fullscreen)**
|
|
57
57
|
- [supported](#fullscreen-supported)
|
|
58
58
|
- [element](#fullscreen-element)
|
|
59
|
-
- [isActive](#fullscreen-
|
|
59
|
+
- [isActive](#fullscreen-isactive)
|
|
60
60
|
- [request](#fullscreen-request)
|
|
61
61
|
- [exit](#fullscreen-exit)
|
|
62
|
+
- [toggle](#fullscreen-toggle)
|
|
62
63
|
- [onChange](#fullscreen-onchange)
|
|
63
64
|
- [onError](#fullscreen-onerror)
|
|
64
65
|
- **[geolocation](#geolocation)**
|
|
@@ -87,9 +88,10 @@ yarn add native-fn
|
|
|
87
88
|
- **[pip](#pip)**
|
|
88
89
|
- [supported](#pip-supported)
|
|
89
90
|
- [element](#pip-element)
|
|
90
|
-
- [isActive](#pip-
|
|
91
|
+
- [isActive](#pip-isactive)
|
|
91
92
|
- [request](#pip-request)
|
|
92
93
|
- [exit](#pip-exit)
|
|
94
|
+
- [toggle](#pip-toggle)
|
|
93
95
|
- [onChange](#pip-onchange)
|
|
94
96
|
- [onError](#pip-onerror)
|
|
95
97
|
- **[platform](#platform)**
|
|
@@ -299,7 +301,7 @@ Returns whether battery is supported in the current environment.
|
|
|
299
301
|
```ts
|
|
300
302
|
if (Native.battery.supported) {
|
|
301
303
|
const battery = await Native.battery.value;
|
|
302
|
-
|
|
304
|
+
|
|
303
305
|
console.log(battery.level); // 0.0 – 1.0
|
|
304
306
|
}
|
|
305
307
|
```
|
|
@@ -334,7 +336,7 @@ Returns the current battery status.
|
|
|
334
336
|
const battery = await Native.battery.value;
|
|
335
337
|
|
|
336
338
|
console.log(battery.level); // 0.0 – 1.0
|
|
337
|
-
console.log(battery.charging); //
|
|
339
|
+
console.log(battery.charging); // boolean
|
|
338
340
|
console.log(battery.chargingTime); // seconds until full
|
|
339
341
|
console.log(battery.dischargingTime); // seconds until empty
|
|
340
342
|
```
|
|
@@ -378,7 +380,7 @@ Subscribes to battery status changes.
|
|
|
378
380
|
```ts
|
|
379
381
|
const unsubscribe = Native.battery.onChange((battery) => {
|
|
380
382
|
console.log(battery.level); // 0.0 – 1.0
|
|
381
|
-
console.log(battery.charging); //
|
|
383
|
+
console.log(battery.charging); // boolean
|
|
382
384
|
});
|
|
383
385
|
|
|
384
386
|
unsubscribe();
|
|
@@ -590,6 +592,16 @@ const unsubscribe = Native.dimension.environment.safeAreaInset.onChange((inset)
|
|
|
590
592
|
document.body.style.paddingBottom = inset.bottom + 'px';
|
|
591
593
|
});
|
|
592
594
|
unsubscribe();
|
|
595
|
+
|
|
596
|
+
// Sync safe area insets to CSS variables
|
|
597
|
+
// Usage in CSS: var(--sai-top), var(--sai-bottom), var(--sai-left), var(--sai-right)
|
|
598
|
+
const releaseSai = Native.dimension.environment.safeAreaInset.useCssVariable('sai');
|
|
599
|
+
releaseSai(); // removes all --sai-* variables
|
|
600
|
+
|
|
601
|
+
// Sync viewport segments to CSS variables (e.g. foldable devices)
|
|
602
|
+
// Usage in CSS: var(--vs-0-width), var(--vs-0-height), var(--vs-1-top), ...
|
|
603
|
+
const releaseVs = Native.dimension.environment.viewportSegment.useCssVariable('vs');
|
|
604
|
+
releaseVs(); // removes all --vs-{index}-* variables
|
|
593
605
|
```
|
|
594
606
|
|
|
595
607
|
**Returns**
|
|
@@ -601,16 +613,30 @@ Environment
|
|
|
601
613
|
|
|
602
614
|
```ts
|
|
603
615
|
interface Environment {
|
|
604
|
-
safeAreaInset:
|
|
605
|
-
safeAreaMaxInset:
|
|
606
|
-
keyboardInset:
|
|
607
|
-
titlebarArea:
|
|
608
|
-
viewportSegment:
|
|
616
|
+
safeAreaInset: EnvironmentObserver<'safe-area-inset'>;
|
|
617
|
+
safeAreaMaxInset: EnvironmentObserver<'safe-area-max-inset'>;
|
|
618
|
+
keyboardInset: EnvironmentObserver<'keyboard-inset'>;
|
|
619
|
+
titlebarArea: EnvironmentObserver<'titlebar-area'>;
|
|
620
|
+
viewportSegment: EnvironmentObserver<'viewport-segment'>;
|
|
609
621
|
}
|
|
610
622
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
623
|
+
type EnvironmentObserver<K extends EnvironmentPresetKey> =
|
|
624
|
+
K extends 'viewport-segment'
|
|
625
|
+
? SegmentsObserver
|
|
626
|
+
: {
|
|
627
|
+
get value(): EnvironmentPresetValues<K>;
|
|
628
|
+
|
|
629
|
+
onChange(listener: (value: EnvironmentPresetValues<K>) => void, options?: AddEventListenerOptions): () => void;
|
|
630
|
+
|
|
631
|
+
useCssVariable(prefix: string): () => void;
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
interface SegmentsObserver {
|
|
635
|
+
get value(): EnvironmentPresetValues<'viewport-segment'>[];
|
|
636
|
+
|
|
637
|
+
onChange(listener: (value: EnvironmentPresetValues<'viewport-segment'>[]) => void, options?: AddEventListenerOptions): () => void;
|
|
638
|
+
|
|
639
|
+
useCssVariable(prefix: string): () => void;
|
|
614
640
|
}
|
|
615
641
|
```
|
|
616
642
|
|
|
@@ -653,7 +679,7 @@ unsubscribe();
|
|
|
653
679
|
|
|
654
680
|
## fullscreen
|
|
655
681
|
|
|
656
|
-
[`supported`](#fullscreen-supported) · [`element`](#fullscreen-element) · [`isActive`](#fullscreen-
|
|
682
|
+
[`supported`](#fullscreen-supported) · [`element`](#fullscreen-element) · [`isActive`](#fullscreen-isactive) · [`request`](#fullscreen-request) · [`exit`](#fullscreen-exit) · [`toggle`](#fullscreen-toggle) · [`onChange`](#fullscreen-onchange) · [`onError`](#fullscreen-onerror)
|
|
657
683
|
|
|
658
684
|
<h3 id="fullscreen-supported"><code>fullscreen.supported</code></h3>
|
|
659
685
|
|
|
@@ -702,7 +728,7 @@ Returns the element currently displayed in fullscreen, or null if not in fullscr
|
|
|
702
728
|
|
|
703
729
|
```ts
|
|
704
730
|
const el = Native.fullscreen.element;
|
|
705
|
-
|
|
731
|
+
|
|
706
732
|
if (el !== null) {
|
|
707
733
|
console.log(el.tagName); // e.g. 'VIDEO', 'DIV'
|
|
708
734
|
}
|
|
@@ -722,7 +748,7 @@ Element | null
|
|
|
722
748
|
|
|
723
749
|
---
|
|
724
750
|
|
|
725
|
-
<h3 id="fullscreen-
|
|
751
|
+
<h3 id="fullscreen-isactive"><code>fullscreen.isActive</code></h3>
|
|
726
752
|
|
|
727
753
|
**Signature**
|
|
728
754
|
|
|
@@ -735,7 +761,7 @@ Returns whether fullscreen is currently active.
|
|
|
735
761
|
**Example**
|
|
736
762
|
|
|
737
763
|
```ts
|
|
738
|
-
console.log(Native.fullscreen.isActive); //
|
|
764
|
+
console.log(Native.fullscreen.isActive); // boolean
|
|
739
765
|
```
|
|
740
766
|
|
|
741
767
|
**Returns**
|
|
@@ -783,10 +809,10 @@ flowchart TD
|
|
|
783
809
|
```ts
|
|
784
810
|
// Default: documentElement on desktop, first video on iOS
|
|
785
811
|
await Native.fullscreen.request();
|
|
786
|
-
|
|
812
|
+
|
|
787
813
|
// Specific element
|
|
788
814
|
await Native.fullscreen.request(document.getElementById('player'));
|
|
789
|
-
|
|
815
|
+
|
|
790
816
|
// With options
|
|
791
817
|
await Native.fullscreen.request(element, { navigationUI: 'hide' });
|
|
792
818
|
```
|
|
@@ -863,12 +889,60 @@ throw new NotSupportedError // failed to exit fullscreen
|
|
|
863
889
|
|
|
864
890
|
---
|
|
865
891
|
|
|
892
|
+
<h3 id="fullscreen-toggle"><code>fullscreen.toggle</code></h3>
|
|
893
|
+
|
|
894
|
+
**Signature**
|
|
895
|
+
|
|
896
|
+
```ts
|
|
897
|
+
toggle(target?: Element, options?: FullscreenOptions): Promise<void>
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
Toggles fullscreen for an element.
|
|
901
|
+
|
|
902
|
+
**Example**
|
|
903
|
+
|
|
904
|
+
```ts
|
|
905
|
+
// Default: documentElement on desktop, first video on iOS
|
|
906
|
+
await Native.fullscreen.toggle();
|
|
907
|
+
|
|
908
|
+
// Specific element
|
|
909
|
+
await Native.fullscreen.toggle(document.getElementById('player'));
|
|
910
|
+
|
|
911
|
+
// With options
|
|
912
|
+
await Native.fullscreen.toggle(element, { navigationUI: 'hide' });
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
**Returns**
|
|
916
|
+
|
|
917
|
+
```ts
|
|
918
|
+
Promise<void>
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
**Throws**
|
|
923
|
+
|
|
924
|
+
```ts
|
|
925
|
+
throw new NotSupportedError // element does not support fullscreen
|
|
926
|
+
```
|
|
927
|
+
```ts
|
|
928
|
+
throw new NotSupportedError // iOS video lacks webkitEnterFullscreen
|
|
929
|
+
```
|
|
930
|
+
```ts
|
|
931
|
+
throw new NotSupportedError // failed to exit fullscreen
|
|
932
|
+
```
|
|
933
|
+
```ts
|
|
934
|
+
throw new InvalidStateError // iOS video not yet played
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
---
|
|
938
|
+
|
|
866
939
|
<h3 id="fullscreen-onchange"><code>fullscreen.onChange</code></h3>
|
|
867
940
|
|
|
868
941
|
**Signature**
|
|
869
942
|
|
|
870
943
|
```ts
|
|
871
944
|
onChange(listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
945
|
+
onChange(target: Element, listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
872
946
|
```
|
|
873
947
|
|
|
874
948
|
Subscribes to fullscreen state changes.
|
|
@@ -877,11 +951,11 @@ Subscribes to fullscreen state changes.
|
|
|
877
951
|
|
|
878
952
|
```ts
|
|
879
953
|
const unsubscribe = Native.fullscreen.onChange((payload) => {
|
|
880
|
-
console.log(payload.isActive);
|
|
954
|
+
console.log(payload.isActive); // boolean
|
|
881
955
|
console.log(payload.element); // Element
|
|
882
956
|
console.log(payload.nativeEvent); // Event
|
|
883
957
|
});
|
|
884
|
-
|
|
958
|
+
|
|
885
959
|
unsubscribe();
|
|
886
960
|
```
|
|
887
961
|
|
|
@@ -905,6 +979,7 @@ unsubscribe();
|
|
|
905
979
|
|
|
906
980
|
```ts
|
|
907
981
|
onError(listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
982
|
+
onError(target: Element, listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
908
983
|
```
|
|
909
984
|
|
|
910
985
|
Subscribes to fullscreen errors.
|
|
@@ -913,11 +988,11 @@ Subscribes to fullscreen errors.
|
|
|
913
988
|
|
|
914
989
|
```ts
|
|
915
990
|
const unsubscribe = Native.fullscreen.onError((payload) => {
|
|
916
|
-
console.log(payload.isActive);
|
|
991
|
+
console.log(payload.isActive); // boolean
|
|
917
992
|
console.log(payload.element); // Element
|
|
918
993
|
console.log(payload.nativeEvent); // Event
|
|
919
994
|
});
|
|
920
|
-
|
|
995
|
+
|
|
921
996
|
unsubscribe();
|
|
922
997
|
```
|
|
923
998
|
|
|
@@ -1268,13 +1343,13 @@ try {
|
|
|
1268
1343
|
switch (result) {
|
|
1269
1344
|
AppOpenState.Intent:
|
|
1270
1345
|
console.log('Opened via Android intent.'); break;
|
|
1271
|
-
|
|
1346
|
+
AppOpenState.Universal:
|
|
1272
1347
|
console.log('Opened via Universal Link.'); break;
|
|
1273
|
-
|
|
1348
|
+
AppOpenState.Scheme:
|
|
1274
1349
|
console.log('Opened via custom scheme.'); break;
|
|
1275
|
-
|
|
1350
|
+
AppOpenState.Fallback:
|
|
1276
1351
|
console.log('Opened via fallback URL.'); break;
|
|
1277
|
-
|
|
1352
|
+
AppOpenState.Store:
|
|
1278
1353
|
console.log('Redirected to App Store.'); break;
|
|
1279
1354
|
}
|
|
1280
1355
|
} catch (e) {
|
|
@@ -1625,12 +1700,24 @@ Promise<Contact[]>
|
|
|
1625
1700
|
|
|
1626
1701
|
```ts
|
|
1627
1702
|
interface Contact {
|
|
1628
|
-
name?: string;
|
|
1629
|
-
email?: string;
|
|
1630
|
-
tel?: string;
|
|
1631
|
-
address?:
|
|
1703
|
+
name?: string[];
|
|
1704
|
+
email?: string[];
|
|
1705
|
+
tel?: string[];
|
|
1706
|
+
address?: ContactAddress[];
|
|
1632
1707
|
icon?: Blob[];
|
|
1633
1708
|
}
|
|
1709
|
+
|
|
1710
|
+
interface ContactAddress {
|
|
1711
|
+
country?: string;
|
|
1712
|
+
region?: string;
|
|
1713
|
+
city?: string;
|
|
1714
|
+
dependentLocality?: string;
|
|
1715
|
+
postalCode?: string;
|
|
1716
|
+
sortingCode?: string;
|
|
1717
|
+
organization?: string;
|
|
1718
|
+
recipient?: string;
|
|
1719
|
+
addressLine?: string[];
|
|
1720
|
+
}
|
|
1634
1721
|
```
|
|
1635
1722
|
|
|
1636
1723
|
**Throws**
|
|
@@ -1885,7 +1972,7 @@ enum PermissionState {
|
|
|
1885
1972
|
|
|
1886
1973
|
## pip
|
|
1887
1974
|
|
|
1888
|
-
[`supported`](#pip-supported) · [`element`](#pip-element) · [`isActive`](#pip-
|
|
1975
|
+
[`supported`](#pip-supported) · [`element`](#pip-element) · [`isActive`](#pip-isactive) · [`request`](#pip-request) · [`exit`](#pip-exit) · [`toggle`](#pip-toggle) · [`onChange`](#pip-onchange) · [`onError`](#pip-onerror)
|
|
1889
1976
|
|
|
1890
1977
|
<h3 id="pip-supported"><code>pip.supported</code></h3>
|
|
1891
1978
|
|
|
@@ -1934,7 +2021,7 @@ Returns the video element currently in Picture-in-Picture, or null if not active
|
|
|
1934
2021
|
|
|
1935
2022
|
```ts
|
|
1936
2023
|
const el = Native.pip.element;
|
|
1937
|
-
|
|
2024
|
+
|
|
1938
2025
|
if (el !== null) {
|
|
1939
2026
|
console.log(el.src); // currently PiP video source
|
|
1940
2027
|
}
|
|
@@ -1954,7 +2041,7 @@ HTMLVideoElement | null
|
|
|
1954
2041
|
|
|
1955
2042
|
---
|
|
1956
2043
|
|
|
1957
|
-
<h3 id="pip-
|
|
2044
|
+
<h3 id="pip-isactive"><code>pip.isActive</code></h3>
|
|
1958
2045
|
|
|
1959
2046
|
**Signature**
|
|
1960
2047
|
|
|
@@ -1967,7 +2054,7 @@ Returns whether Picture-in-Picture is currently active.
|
|
|
1967
2054
|
**Example**
|
|
1968
2055
|
|
|
1969
2056
|
```ts
|
|
1970
|
-
console.log(Native.pip.isActive); //
|
|
2057
|
+
console.log(Native.pip.isActive); // boolean
|
|
1971
2058
|
```
|
|
1972
2059
|
|
|
1973
2060
|
**Returns**
|
|
@@ -2017,7 +2104,7 @@ flowchart TD
|
|
|
2017
2104
|
```ts
|
|
2018
2105
|
// Default: first video element
|
|
2019
2106
|
await Native.pip.request();
|
|
2020
|
-
|
|
2107
|
+
|
|
2021
2108
|
// Specific video element
|
|
2022
2109
|
await Native.pip.request(document.querySelector('video#player'));
|
|
2023
2110
|
```
|
|
@@ -2099,12 +2186,60 @@ throw new NotSupportedError // failed to exit PiP
|
|
|
2099
2186
|
|
|
2100
2187
|
---
|
|
2101
2188
|
|
|
2189
|
+
<h3 id="pip-toggle"><code>pip.toggle</code></h3>
|
|
2190
|
+
|
|
2191
|
+
**Signature**
|
|
2192
|
+
|
|
2193
|
+
```ts
|
|
2194
|
+
toggle(target?: HTMLVideoElement): Promise<void>
|
|
2195
|
+
```
|
|
2196
|
+
|
|
2197
|
+
Toggles Picture-in-Picture for a video element.
|
|
2198
|
+
|
|
2199
|
+
**Example**
|
|
2200
|
+
|
|
2201
|
+
```ts
|
|
2202
|
+
// Default: first video element
|
|
2203
|
+
await Native.pip.toggle();
|
|
2204
|
+
|
|
2205
|
+
// Specific video element
|
|
2206
|
+
await Native.pip.toggle(document.querySelector('video#player'));
|
|
2207
|
+
```
|
|
2208
|
+
|
|
2209
|
+
**Returns**
|
|
2210
|
+
|
|
2211
|
+
```ts
|
|
2212
|
+
Promise<void>
|
|
2213
|
+
```
|
|
2214
|
+
|
|
2215
|
+
|
|
2216
|
+
**Throws**
|
|
2217
|
+
|
|
2218
|
+
```ts
|
|
2219
|
+
throw new NotSupportedError // target is not a video element
|
|
2220
|
+
```
|
|
2221
|
+
```ts
|
|
2222
|
+
throw new NotSupportedError // PiP disabled on this element (disablePictureInPicture)
|
|
2223
|
+
```
|
|
2224
|
+
```ts
|
|
2225
|
+
throw new NotSupportedError // requestPictureInPicture and webkitSetPresentationMode both unavailable
|
|
2226
|
+
```
|
|
2227
|
+
```ts
|
|
2228
|
+
throw new NotSupportedError // failed to exit PiP
|
|
2229
|
+
```
|
|
2230
|
+
```ts
|
|
2231
|
+
throw new InvalidStateError // PiP transition already in progress
|
|
2232
|
+
```
|
|
2233
|
+
|
|
2234
|
+
---
|
|
2235
|
+
|
|
2102
2236
|
<h3 id="pip-onchange"><code>pip.onChange</code></h3>
|
|
2103
2237
|
|
|
2104
2238
|
**Signature**
|
|
2105
2239
|
|
|
2106
2240
|
```ts
|
|
2107
2241
|
onChange(listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2242
|
+
onChange(target: HTMLVideoElement, listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2108
2243
|
```
|
|
2109
2244
|
|
|
2110
2245
|
Subscribes to Picture-in-Picture state changes.
|
|
@@ -2113,11 +2248,11 @@ Subscribes to Picture-in-Picture state changes.
|
|
|
2113
2248
|
|
|
2114
2249
|
```ts
|
|
2115
2250
|
const unsubscribe = Native.pip.onChange((payload) => {
|
|
2116
|
-
console.log(payload.isActive);
|
|
2251
|
+
console.log(payload.isActive); // boolean
|
|
2117
2252
|
console.log(payload.element); // HTMLVideoElement
|
|
2118
2253
|
console.log(payload.nativeEvent); // Event
|
|
2119
2254
|
});
|
|
2120
|
-
|
|
2255
|
+
|
|
2121
2256
|
unsubscribe();
|
|
2122
2257
|
```
|
|
2123
2258
|
|
|
@@ -2141,6 +2276,7 @@ unsubscribe();
|
|
|
2141
2276
|
|
|
2142
2277
|
```ts
|
|
2143
2278
|
onError(listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2279
|
+
onError(target: HTMLVideoElement, listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2144
2280
|
```
|
|
2145
2281
|
|
|
2146
2282
|
Subscribes to Picture-in-Picture errors.
|
|
@@ -2149,7 +2285,7 @@ Subscribes to Picture-in-Picture errors.
|
|
|
2149
2285
|
|
|
2150
2286
|
```ts
|
|
2151
2287
|
const unsubscribe = Native.pip.onError((payload) => {
|
|
2152
|
-
console.log(payload.isActive);
|
|
2288
|
+
console.log(payload.isActive); // boolean
|
|
2153
2289
|
console.log(payload.element); // HTMLVideoElement
|
|
2154
2290
|
console.log(payload.nativeEvent); // Event
|
|
2155
2291
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -109,19 +109,27 @@ declare const ENV_PRESETS: {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
type EnvironmentPresetKey = keyof typeof ENV_PRESETS;
|
|
112
|
-
type
|
|
112
|
+
type EnvironmentPresetAttribute<K extends EnvironmentPresetKey> = keyof typeof ENV_PRESETS[K];
|
|
113
113
|
type EnvironmentPresetValues<K extends EnvironmentPresetKey> = {
|
|
114
|
-
[P in
|
|
114
|
+
[P in EnvironmentPresetAttribute<K>]: number;
|
|
115
|
+
};
|
|
116
|
+
declare interface Environment {
|
|
117
|
+
safeAreaInset: EnvironmentObserver<'safe-area-inset'>;
|
|
118
|
+
safeAreaMaxInset: EnvironmentObserver<'safe-area-max-inset'>;
|
|
119
|
+
keyboardInset: EnvironmentObserver<'keyboard-inset'>;
|
|
120
|
+
titlebarArea: EnvironmentObserver<'titlebar-area'>;
|
|
121
|
+
viewportSegment: EnvironmentObserver<'viewport-segment'>;
|
|
122
|
+
}
|
|
123
|
+
declare interface SegmentsObserver {
|
|
124
|
+
get value(): EnvironmentPresetValues<'viewport-segment'>[];
|
|
125
|
+
onChange(listener: (value: EnvironmentPresetValues<'viewport-segment'>[]) => void, options?: AddEventListenerOptions): () => void;
|
|
126
|
+
useCssVariable(prefix: string): () => void;
|
|
127
|
+
}
|
|
128
|
+
declare type EnvironmentObserver<K extends EnvironmentPresetKey> = K extends 'viewport-segment' ? SegmentsObserver : {
|
|
129
|
+
get value(): EnvironmentPresetValues<K>;
|
|
130
|
+
onChange(listener: (value: EnvironmentPresetValues<K>) => void, options?: AddEventListenerOptions): () => void;
|
|
131
|
+
useCssVariable(prefix: string): () => void;
|
|
115
132
|
};
|
|
116
|
-
declare interface DimensionInstance {
|
|
117
|
-
get value(): Dimensions;
|
|
118
|
-
environment: Environment;
|
|
119
|
-
onChange(listener: (dimension: Dimensions) => void, options?: AddEventListenerOptions): () => void;
|
|
120
|
-
Constants: {
|
|
121
|
-
Orientation: typeof Orientation;
|
|
122
|
-
};
|
|
123
|
-
Errors: {};
|
|
124
|
-
}
|
|
125
133
|
declare interface Dimensions {
|
|
126
134
|
outerWidth: number;
|
|
127
135
|
outerHeight: number;
|
|
@@ -130,18 +138,31 @@ declare interface Dimensions {
|
|
|
130
138
|
scale: number;
|
|
131
139
|
orientation: Orientation;
|
|
132
140
|
}
|
|
133
|
-
declare interface
|
|
134
|
-
get value():
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
titlebarArea: EnvironmentPreset<'titlebar-area'>;
|
|
142
|
-
viewportSegment: EnvironmentPreset<'viewport-segment'>;
|
|
141
|
+
declare interface DimensionInstance {
|
|
142
|
+
get value(): Dimensions;
|
|
143
|
+
environment: Environment;
|
|
144
|
+
onChange(listener: (dimension: Dimensions) => void, options?: AddEventListenerOptions): () => void;
|
|
145
|
+
Constants: {
|
|
146
|
+
Orientation: typeof Orientation;
|
|
147
|
+
};
|
|
148
|
+
Errors: {};
|
|
143
149
|
}
|
|
144
150
|
|
|
151
|
+
declare global {
|
|
152
|
+
interface DOMRectReadOnly {
|
|
153
|
+
readonly x: number;
|
|
154
|
+
readonly y: number;
|
|
155
|
+
readonly width: number;
|
|
156
|
+
readonly height: number;
|
|
157
|
+
readonly top: number;
|
|
158
|
+
readonly right: number;
|
|
159
|
+
readonly bottom: number;
|
|
160
|
+
readonly left: number;
|
|
161
|
+
}
|
|
162
|
+
interface VisualViewport {
|
|
163
|
+
readonly segments?: DOMRectReadOnly[];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
145
166
|
declare const Dimension: DimensionInstance;
|
|
146
167
|
|
|
147
168
|
declare const InvalidStateError: ErrorConstructor;
|