native-fn 1.2.1 → 1.2.2
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 +143 -31
- package/dist/native.cjs +1 -1
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +1 -1
- package/dist/native.umd.js +1 -1
- package/dist/native.umd.min.js +1 -1
- 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();
|
|
@@ -653,7 +655,7 @@ unsubscribe();
|
|
|
653
655
|
|
|
654
656
|
## fullscreen
|
|
655
657
|
|
|
656
|
-
[`supported`](#fullscreen-supported) · [`element`](#fullscreen-element) · [`isActive`](#fullscreen-
|
|
658
|
+
[`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
659
|
|
|
658
660
|
<h3 id="fullscreen-supported"><code>fullscreen.supported</code></h3>
|
|
659
661
|
|
|
@@ -702,7 +704,7 @@ Returns the element currently displayed in fullscreen, or null if not in fullscr
|
|
|
702
704
|
|
|
703
705
|
```ts
|
|
704
706
|
const el = Native.fullscreen.element;
|
|
705
|
-
|
|
707
|
+
|
|
706
708
|
if (el !== null) {
|
|
707
709
|
console.log(el.tagName); // e.g. 'VIDEO', 'DIV'
|
|
708
710
|
}
|
|
@@ -722,7 +724,7 @@ Element | null
|
|
|
722
724
|
|
|
723
725
|
---
|
|
724
726
|
|
|
725
|
-
<h3 id="fullscreen-
|
|
727
|
+
<h3 id="fullscreen-isactive"><code>fullscreen.isActive</code></h3>
|
|
726
728
|
|
|
727
729
|
**Signature**
|
|
728
730
|
|
|
@@ -735,7 +737,7 @@ Returns whether fullscreen is currently active.
|
|
|
735
737
|
**Example**
|
|
736
738
|
|
|
737
739
|
```ts
|
|
738
|
-
console.log(Native.fullscreen.isActive); //
|
|
740
|
+
console.log(Native.fullscreen.isActive); // boolean
|
|
739
741
|
```
|
|
740
742
|
|
|
741
743
|
**Returns**
|
|
@@ -783,10 +785,10 @@ flowchart TD
|
|
|
783
785
|
```ts
|
|
784
786
|
// Default: documentElement on desktop, first video on iOS
|
|
785
787
|
await Native.fullscreen.request();
|
|
786
|
-
|
|
788
|
+
|
|
787
789
|
// Specific element
|
|
788
790
|
await Native.fullscreen.request(document.getElementById('player'));
|
|
789
|
-
|
|
791
|
+
|
|
790
792
|
// With options
|
|
791
793
|
await Native.fullscreen.request(element, { navigationUI: 'hide' });
|
|
792
794
|
```
|
|
@@ -863,12 +865,60 @@ throw new NotSupportedError // failed to exit fullscreen
|
|
|
863
865
|
|
|
864
866
|
---
|
|
865
867
|
|
|
868
|
+
<h3 id="fullscreen-toggle"><code>fullscreen.toggle</code></h3>
|
|
869
|
+
|
|
870
|
+
**Signature**
|
|
871
|
+
|
|
872
|
+
```ts
|
|
873
|
+
toggle(target?: Element, options?: FullscreenOptions): Promise<void>
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
Toggles fullscreen for an element.
|
|
877
|
+
|
|
878
|
+
**Example**
|
|
879
|
+
|
|
880
|
+
```ts
|
|
881
|
+
// Default: documentElement on desktop, first video on iOS
|
|
882
|
+
await Native.fullscreen.toggle();
|
|
883
|
+
|
|
884
|
+
// Specific element
|
|
885
|
+
await Native.fullscreen.toggle(document.getElementById('player'));
|
|
886
|
+
|
|
887
|
+
// With options
|
|
888
|
+
await Native.fullscreen.toggle(element, { navigationUI: 'hide' });
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
**Returns**
|
|
892
|
+
|
|
893
|
+
```ts
|
|
894
|
+
Promise<void>
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
**Throws**
|
|
899
|
+
|
|
900
|
+
```ts
|
|
901
|
+
throw new NotSupportedError // element does not support fullscreen
|
|
902
|
+
```
|
|
903
|
+
```ts
|
|
904
|
+
throw new NotSupportedError // iOS video lacks webkitEnterFullscreen
|
|
905
|
+
```
|
|
906
|
+
```ts
|
|
907
|
+
throw new NotSupportedError // failed to exit fullscreen
|
|
908
|
+
```
|
|
909
|
+
```ts
|
|
910
|
+
throw new InvalidStateError // iOS video not yet played
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
866
915
|
<h3 id="fullscreen-onchange"><code>fullscreen.onChange</code></h3>
|
|
867
916
|
|
|
868
917
|
**Signature**
|
|
869
918
|
|
|
870
919
|
```ts
|
|
871
920
|
onChange(listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
921
|
+
onChange(target: Element, listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
872
922
|
```
|
|
873
923
|
|
|
874
924
|
Subscribes to fullscreen state changes.
|
|
@@ -877,11 +927,11 @@ Subscribes to fullscreen state changes.
|
|
|
877
927
|
|
|
878
928
|
```ts
|
|
879
929
|
const unsubscribe = Native.fullscreen.onChange((payload) => {
|
|
880
|
-
console.log(payload.isActive);
|
|
930
|
+
console.log(payload.isActive); // boolean
|
|
881
931
|
console.log(payload.element); // Element
|
|
882
932
|
console.log(payload.nativeEvent); // Event
|
|
883
933
|
});
|
|
884
|
-
|
|
934
|
+
|
|
885
935
|
unsubscribe();
|
|
886
936
|
```
|
|
887
937
|
|
|
@@ -905,6 +955,7 @@ unsubscribe();
|
|
|
905
955
|
|
|
906
956
|
```ts
|
|
907
957
|
onError(listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
958
|
+
onError(target: Element, listener: (payload: FullscreenEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
908
959
|
```
|
|
909
960
|
|
|
910
961
|
Subscribes to fullscreen errors.
|
|
@@ -913,11 +964,11 @@ Subscribes to fullscreen errors.
|
|
|
913
964
|
|
|
914
965
|
```ts
|
|
915
966
|
const unsubscribe = Native.fullscreen.onError((payload) => {
|
|
916
|
-
console.log(payload.isActive);
|
|
967
|
+
console.log(payload.isActive); // boolean
|
|
917
968
|
console.log(payload.element); // Element
|
|
918
969
|
console.log(payload.nativeEvent); // Event
|
|
919
970
|
});
|
|
920
|
-
|
|
971
|
+
|
|
921
972
|
unsubscribe();
|
|
922
973
|
```
|
|
923
974
|
|
|
@@ -1268,13 +1319,13 @@ try {
|
|
|
1268
1319
|
switch (result) {
|
|
1269
1320
|
AppOpenState.Intent:
|
|
1270
1321
|
console.log('Opened via Android intent.'); break;
|
|
1271
|
-
|
|
1322
|
+
AppOpenState.Universal:
|
|
1272
1323
|
console.log('Opened via Universal Link.'); break;
|
|
1273
|
-
|
|
1324
|
+
AppOpenState.Scheme:
|
|
1274
1325
|
console.log('Opened via custom scheme.'); break;
|
|
1275
|
-
|
|
1326
|
+
AppOpenState.Fallback:
|
|
1276
1327
|
console.log('Opened via fallback URL.'); break;
|
|
1277
|
-
|
|
1328
|
+
AppOpenState.Store:
|
|
1278
1329
|
console.log('Redirected to App Store.'); break;
|
|
1279
1330
|
}
|
|
1280
1331
|
} catch (e) {
|
|
@@ -1625,12 +1676,24 @@ Promise<Contact[]>
|
|
|
1625
1676
|
|
|
1626
1677
|
```ts
|
|
1627
1678
|
interface Contact {
|
|
1628
|
-
name?: string;
|
|
1629
|
-
email?: string;
|
|
1630
|
-
tel?: string;
|
|
1631
|
-
address?:
|
|
1679
|
+
name?: string[];
|
|
1680
|
+
email?: string[];
|
|
1681
|
+
tel?: string[];
|
|
1682
|
+
address?: ContactAddress[];
|
|
1632
1683
|
icon?: Blob[];
|
|
1633
1684
|
}
|
|
1685
|
+
|
|
1686
|
+
interface ContactAddress {
|
|
1687
|
+
country?: string;
|
|
1688
|
+
region?: string;
|
|
1689
|
+
city?: string;
|
|
1690
|
+
dependentLocality?: string;
|
|
1691
|
+
postalCode?: string;
|
|
1692
|
+
sortingCode?: string;
|
|
1693
|
+
organization?: string;
|
|
1694
|
+
recipient?: string;
|
|
1695
|
+
addressLine?: string[];
|
|
1696
|
+
}
|
|
1634
1697
|
```
|
|
1635
1698
|
|
|
1636
1699
|
**Throws**
|
|
@@ -1885,7 +1948,7 @@ enum PermissionState {
|
|
|
1885
1948
|
|
|
1886
1949
|
## pip
|
|
1887
1950
|
|
|
1888
|
-
[`supported`](#pip-supported) · [`element`](#pip-element) · [`isActive`](#pip-
|
|
1951
|
+
[`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
1952
|
|
|
1890
1953
|
<h3 id="pip-supported"><code>pip.supported</code></h3>
|
|
1891
1954
|
|
|
@@ -1934,7 +1997,7 @@ Returns the video element currently in Picture-in-Picture, or null if not active
|
|
|
1934
1997
|
|
|
1935
1998
|
```ts
|
|
1936
1999
|
const el = Native.pip.element;
|
|
1937
|
-
|
|
2000
|
+
|
|
1938
2001
|
if (el !== null) {
|
|
1939
2002
|
console.log(el.src); // currently PiP video source
|
|
1940
2003
|
}
|
|
@@ -1954,7 +2017,7 @@ HTMLVideoElement | null
|
|
|
1954
2017
|
|
|
1955
2018
|
---
|
|
1956
2019
|
|
|
1957
|
-
<h3 id="pip-
|
|
2020
|
+
<h3 id="pip-isactive"><code>pip.isActive</code></h3>
|
|
1958
2021
|
|
|
1959
2022
|
**Signature**
|
|
1960
2023
|
|
|
@@ -1967,7 +2030,7 @@ Returns whether Picture-in-Picture is currently active.
|
|
|
1967
2030
|
**Example**
|
|
1968
2031
|
|
|
1969
2032
|
```ts
|
|
1970
|
-
console.log(Native.pip.isActive); //
|
|
2033
|
+
console.log(Native.pip.isActive); // boolean
|
|
1971
2034
|
```
|
|
1972
2035
|
|
|
1973
2036
|
**Returns**
|
|
@@ -2017,7 +2080,7 @@ flowchart TD
|
|
|
2017
2080
|
```ts
|
|
2018
2081
|
// Default: first video element
|
|
2019
2082
|
await Native.pip.request();
|
|
2020
|
-
|
|
2083
|
+
|
|
2021
2084
|
// Specific video element
|
|
2022
2085
|
await Native.pip.request(document.querySelector('video#player'));
|
|
2023
2086
|
```
|
|
@@ -2099,12 +2162,60 @@ throw new NotSupportedError // failed to exit PiP
|
|
|
2099
2162
|
|
|
2100
2163
|
---
|
|
2101
2164
|
|
|
2165
|
+
<h3 id="pip-toggle"><code>pip.toggle</code></h3>
|
|
2166
|
+
|
|
2167
|
+
**Signature**
|
|
2168
|
+
|
|
2169
|
+
```ts
|
|
2170
|
+
toggle(target?: HTMLVideoElement): Promise<void>
|
|
2171
|
+
```
|
|
2172
|
+
|
|
2173
|
+
Toggles Picture-in-Picture for a video element.
|
|
2174
|
+
|
|
2175
|
+
**Example**
|
|
2176
|
+
|
|
2177
|
+
```ts
|
|
2178
|
+
// Default: first video element
|
|
2179
|
+
await Native.pip.toggle();
|
|
2180
|
+
|
|
2181
|
+
// Specific video element
|
|
2182
|
+
await Native.pip.toggle(document.querySelector('video#player'));
|
|
2183
|
+
```
|
|
2184
|
+
|
|
2185
|
+
**Returns**
|
|
2186
|
+
|
|
2187
|
+
```ts
|
|
2188
|
+
Promise<void>
|
|
2189
|
+
```
|
|
2190
|
+
|
|
2191
|
+
|
|
2192
|
+
**Throws**
|
|
2193
|
+
|
|
2194
|
+
```ts
|
|
2195
|
+
throw new NotSupportedError // target is not a video element
|
|
2196
|
+
```
|
|
2197
|
+
```ts
|
|
2198
|
+
throw new NotSupportedError // PiP disabled on this element (disablePictureInPicture)
|
|
2199
|
+
```
|
|
2200
|
+
```ts
|
|
2201
|
+
throw new NotSupportedError // requestPictureInPicture and webkitSetPresentationMode both unavailable
|
|
2202
|
+
```
|
|
2203
|
+
```ts
|
|
2204
|
+
throw new NotSupportedError // failed to exit PiP
|
|
2205
|
+
```
|
|
2206
|
+
```ts
|
|
2207
|
+
throw new InvalidStateError // PiP transition already in progress
|
|
2208
|
+
```
|
|
2209
|
+
|
|
2210
|
+
---
|
|
2211
|
+
|
|
2102
2212
|
<h3 id="pip-onchange"><code>pip.onChange</code></h3>
|
|
2103
2213
|
|
|
2104
2214
|
**Signature**
|
|
2105
2215
|
|
|
2106
2216
|
```ts
|
|
2107
2217
|
onChange(listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2218
|
+
onChange(target: HTMLVideoElement, listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2108
2219
|
```
|
|
2109
2220
|
|
|
2110
2221
|
Subscribes to Picture-in-Picture state changes.
|
|
@@ -2113,11 +2224,11 @@ Subscribes to Picture-in-Picture state changes.
|
|
|
2113
2224
|
|
|
2114
2225
|
```ts
|
|
2115
2226
|
const unsubscribe = Native.pip.onChange((payload) => {
|
|
2116
|
-
console.log(payload.isActive);
|
|
2227
|
+
console.log(payload.isActive); // boolean
|
|
2117
2228
|
console.log(payload.element); // HTMLVideoElement
|
|
2118
2229
|
console.log(payload.nativeEvent); // Event
|
|
2119
2230
|
});
|
|
2120
|
-
|
|
2231
|
+
|
|
2121
2232
|
unsubscribe();
|
|
2122
2233
|
```
|
|
2123
2234
|
|
|
@@ -2141,6 +2252,7 @@ unsubscribe();
|
|
|
2141
2252
|
|
|
2142
2253
|
```ts
|
|
2143
2254
|
onError(listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2255
|
+
onError(target: HTMLVideoElement, listener: (payload: PipEventPayload) => void, options?: AddEventListenerOptions): () => void
|
|
2144
2256
|
```
|
|
2145
2257
|
|
|
2146
2258
|
Subscribes to Picture-in-Picture errors.
|
|
@@ -2149,7 +2261,7 @@ Subscribes to Picture-in-Picture errors.
|
|
|
2149
2261
|
|
|
2150
2262
|
```ts
|
|
2151
2263
|
const unsubscribe = Native.pip.onError((payload) => {
|
|
2152
|
-
console.log(payload.isActive);
|
|
2264
|
+
console.log(payload.isActive); // boolean
|
|
2153
2265
|
console.log(payload.element); // HTMLVideoElement
|
|
2154
2266
|
console.log(payload.nativeEvent); // Event
|
|
2155
2267
|
});
|