native-fn 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/dist/index.d.ts +12 -6
- package/dist/native.cjs +180 -102
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +180 -102
- package/dist/native.umd.js +180 -102
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/appearance/index.cjs +8 -3
- package/dist/plugin/appearance/index.mjs +8 -3
- package/dist/plugin/appearance/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/appearance/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/appearance/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/badge/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/badge/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/battery/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/battery/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/clipboard/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/clipboard/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/dimension/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/dimension/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/fullscreen/index.cjs +93 -54
- package/dist/plugin/fullscreen/index.d.ts +7 -4
- package/dist/plugin/fullscreen/index.mjs +93 -54
- package/dist/plugin/fullscreen/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/fullscreen/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/fullscreen/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/geolocation/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/geolocation/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/notification/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/notification/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/open/index.cjs +8 -3
- package/dist/plugin/open/index.mjs +8 -3
- package/dist/plugin/open/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/open/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/open/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/permission/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/permission/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/pip/index.cjs +448 -47
- package/dist/plugin/pip/index.d.ts +5 -2
- package/dist/plugin/pip/index.mjs +448 -47
- package/dist/plugin/pip/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/pip/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/pip/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/platform/index.cjs +8 -3
- package/dist/plugin/platform/index.mjs +8 -3
- package/dist/plugin/platform/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/platform/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/platform/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/theme/index.cjs +8 -3
- package/dist/plugin/theme/index.mjs +8 -3
- package/dist/plugin/theme/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/theme/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/theme/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/plugin/vibration/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/plugin/vibration/src/types/subscription-manager.d.ts +1 -1
- package/dist/src/plugin/fullscreen/types/fullscreen.d.ts +7 -4
- package/dist/src/plugin/pip/types/pip.d.ts +5 -2
- package/dist/src/types/subscription-manager.d.ts +1 -1
- package/package.json +1 -1
package/dist/native.umd.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Native = factory());
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
|
-
var version = "1.2.
|
|
7
|
+
var version = "1.2.1";
|
|
8
8
|
var packageJSON = {
|
|
9
9
|
version: version};
|
|
10
10
|
|
|
@@ -693,10 +693,15 @@
|
|
|
693
693
|
parsedFromHighEntropyValuesEngine.version = brandVersion;
|
|
694
694
|
}
|
|
695
695
|
if (typeof platformVersion === 'string') {
|
|
696
|
-
if (getParsedCache().os.name === OS.Windows)
|
|
697
|
-
|
|
698
|
-
|
|
696
|
+
if (getParsedCache().os.name === OS.Windows) {
|
|
697
|
+
if (parseInt(platformVersion.split('.')[0], 10) >= 13)
|
|
698
|
+
parsedFromHighEntropyValuesOS.version = '11';
|
|
699
|
+
else
|
|
700
|
+
parsedFromHighEntropyValuesOS.version = '10';
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
699
703
|
parsedFromHighEntropyValuesOS.version = platformVersion;
|
|
704
|
+
}
|
|
700
705
|
}
|
|
701
706
|
if (typeof platform === 'string') {
|
|
702
707
|
if (/android/i.test(platform))
|
|
@@ -1873,7 +1878,8 @@
|
|
|
1873
1878
|
|
|
1874
1879
|
var InvalidStateError = createCustomError('InvalidStateError');
|
|
1875
1880
|
|
|
1876
|
-
var
|
|
1881
|
+
var videoElement$1 = null;
|
|
1882
|
+
var lastFallbackVideoElement$1 = null;
|
|
1877
1883
|
var eventsBridged$1 = false;
|
|
1878
1884
|
var FS_BRIDGE_KEY = (function () {
|
|
1879
1885
|
if (typeof Symbol === 'function') {
|
|
@@ -1919,24 +1925,33 @@
|
|
|
1919
1925
|
var onErrorSubscriptionManager$1 = createSubscriptionManager(attachOnError$1, detachOnError$1);
|
|
1920
1926
|
var Fullscreen = {
|
|
1921
1927
|
get supported() {
|
|
1922
|
-
return
|
|
1928
|
+
return getSupported$1();
|
|
1923
1929
|
},
|
|
1924
1930
|
get element() {
|
|
1925
1931
|
return getElement$1();
|
|
1926
1932
|
},
|
|
1927
|
-
get
|
|
1928
|
-
return
|
|
1933
|
+
get isActive() {
|
|
1934
|
+
return getIsActive$1();
|
|
1929
1935
|
},
|
|
1930
1936
|
request: request$3,
|
|
1931
1937
|
exit: exit$1,
|
|
1932
|
-
|
|
1933
|
-
|
|
1938
|
+
toggle: toggle$1,
|
|
1939
|
+
onChange: onChange$1,
|
|
1940
|
+
onError: onError$1,
|
|
1934
1941
|
Constants: {},
|
|
1935
1942
|
Errors: {
|
|
1936
1943
|
NotSupportedError: NotSupportedError,
|
|
1937
1944
|
InvalidStateError: InvalidStateError,
|
|
1938
1945
|
},
|
|
1939
1946
|
};
|
|
1947
|
+
function getHTMLVideoElement$1() {
|
|
1948
|
+
var selected = globalThis.document.querySelector('video');
|
|
1949
|
+
if (selected !== null)
|
|
1950
|
+
return selected;
|
|
1951
|
+
if (videoElement$1 === null)
|
|
1952
|
+
return videoElement$1 = globalThis.document.createElement('video');
|
|
1953
|
+
return videoElement$1;
|
|
1954
|
+
}
|
|
1940
1955
|
function hasStandardApi$1() {
|
|
1941
1956
|
return api !== null;
|
|
1942
1957
|
}
|
|
@@ -1959,27 +1974,24 @@
|
|
|
1959
1974
|
function getDefaultTarget$1() {
|
|
1960
1975
|
if (Platform.os.name === OS.iOS) {
|
|
1961
1976
|
var video = globalThis.document.querySelector('video');
|
|
1962
|
-
|
|
1977
|
+
if (video !== null)
|
|
1978
|
+
return video;
|
|
1979
|
+
return undefined;
|
|
1963
1980
|
}
|
|
1964
1981
|
return globalThis.document.documentElement;
|
|
1965
1982
|
}
|
|
1966
|
-
function
|
|
1983
|
+
function getSupported$1() {
|
|
1967
1984
|
if (api !== null)
|
|
1968
1985
|
return globalThis.document[api.enabled] === true;
|
|
1969
1986
|
if (Platform.os.name !== OS.iOS)
|
|
1970
1987
|
return false;
|
|
1971
|
-
var video;
|
|
1972
|
-
var selected = globalThis.document.querySelector('video');
|
|
1973
|
-
if (selected !== null)
|
|
1974
|
-
video = selected;
|
|
1975
|
-
else
|
|
1976
|
-
video = globalThis.document.createElement('video');
|
|
1988
|
+
var video = getHTMLVideoElement$1();
|
|
1977
1989
|
return video.webkitSupportsFullscreen === true || typeof video.webkitEnterFullscreen === 'function';
|
|
1978
1990
|
}
|
|
1979
1991
|
function getElement$1() {
|
|
1980
1992
|
if (api === null) {
|
|
1981
|
-
if (
|
|
1982
|
-
return
|
|
1993
|
+
if (lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true)
|
|
1994
|
+
return lastFallbackVideoElement$1;
|
|
1983
1995
|
return null;
|
|
1984
1996
|
}
|
|
1985
1997
|
var currentElement = globalThis.document[api.element];
|
|
@@ -1987,43 +1999,43 @@
|
|
|
1987
1999
|
return currentElement;
|
|
1988
2000
|
return null;
|
|
1989
2001
|
}
|
|
1990
|
-
function
|
|
2002
|
+
function getIsActive$1() {
|
|
1991
2003
|
return getElement$1() !== null;
|
|
1992
2004
|
}
|
|
1993
|
-
function createEventPayload(nativeEvent, element,
|
|
2005
|
+
function createEventPayload(nativeEvent, element, isActive) {
|
|
1994
2006
|
return {
|
|
1995
2007
|
nativeEvent: nativeEvent,
|
|
1996
2008
|
element: element,
|
|
1997
|
-
|
|
2009
|
+
isActive: isActive,
|
|
1998
2010
|
};
|
|
1999
2011
|
}
|
|
2000
|
-
function emitChange$1(nativeEvent, element,
|
|
2001
|
-
onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element,
|
|
2012
|
+
function emitChange$1(nativeEvent, element, isActive) {
|
|
2013
|
+
onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element, isActive));
|
|
2002
2014
|
}
|
|
2003
|
-
function emitError$1(nativeEvent, element,
|
|
2004
|
-
onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element,
|
|
2015
|
+
function emitError$1(nativeEvent, element, isActive) {
|
|
2016
|
+
onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element, isActive));
|
|
2005
2017
|
}
|
|
2006
2018
|
function onFullscreenChange(event) {
|
|
2007
2019
|
var target = event.target;
|
|
2008
2020
|
if (target instanceof globalThis.Element)
|
|
2009
|
-
emitChange$1(event, target,
|
|
2021
|
+
emitChange$1(event, target, getIsActive$1());
|
|
2010
2022
|
if (target instanceof globalThis.Document)
|
|
2011
|
-
emitChange$1(event, globalThis.document.documentElement,
|
|
2023
|
+
emitChange$1(event, globalThis.document.documentElement, getIsActive$1());
|
|
2012
2024
|
}
|
|
2013
2025
|
function onFullscreenError(event) {
|
|
2014
2026
|
var target = event.target;
|
|
2015
2027
|
if (target instanceof globalThis.Element)
|
|
2016
|
-
emitError$1(event, target,
|
|
2028
|
+
emitError$1(event, target, getIsActive$1());
|
|
2017
2029
|
if (target instanceof globalThis.Document)
|
|
2018
|
-
emitError$1(event, globalThis.document.documentElement,
|
|
2030
|
+
emitError$1(event, globalThis.document.documentElement, getIsActive$1());
|
|
2019
2031
|
}
|
|
2020
2032
|
function onIOSBeginFullscreen(event) {
|
|
2021
|
-
|
|
2033
|
+
lastFallbackVideoElement$1 = this;
|
|
2022
2034
|
emitChange$1(event, this, true);
|
|
2023
2035
|
}
|
|
2024
2036
|
function onIOSEndFullscreen(event) {
|
|
2025
|
-
if (
|
|
2026
|
-
|
|
2037
|
+
if (lastFallbackVideoElement$1 === this)
|
|
2038
|
+
lastFallbackVideoElement$1 = null;
|
|
2027
2039
|
emitChange$1(event, this, false);
|
|
2028
2040
|
}
|
|
2029
2041
|
function bridgeSingleVideoNode$1(video) {
|
|
@@ -2050,13 +2062,13 @@
|
|
|
2050
2062
|
if (typeof globalThis.MutationObserver === 'undefined')
|
|
2051
2063
|
return;
|
|
2052
2064
|
var observer = new globalThis.MutationObserver(function (records) {
|
|
2053
|
-
if (
|
|
2065
|
+
if (lastFallbackVideoElement$1 !== null) {
|
|
2054
2066
|
var removed = false;
|
|
2055
2067
|
for (var i = 0; i < records.length; i++) {
|
|
2056
2068
|
var removedNodes = records[i].removedNodes;
|
|
2057
2069
|
for (var j = 0; j < removedNodes.length; j++) {
|
|
2058
2070
|
var node = removedNodes[j];
|
|
2059
|
-
if (node ===
|
|
2071
|
+
if (node === lastFallbackVideoElement$1 || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement$1))) {
|
|
2060
2072
|
removed = true;
|
|
2061
2073
|
break;
|
|
2062
2074
|
}
|
|
@@ -2064,8 +2076,8 @@
|
|
|
2064
2076
|
if (removed)
|
|
2065
2077
|
break;
|
|
2066
2078
|
}
|
|
2067
|
-
if (removed && !globalThis.document.contains(
|
|
2068
|
-
|
|
2079
|
+
if (removed && !globalThis.document.contains(lastFallbackVideoElement$1))
|
|
2080
|
+
lastFallbackVideoElement$1 = null;
|
|
2069
2081
|
}
|
|
2070
2082
|
for (var i = 0; i < records.length; i++) {
|
|
2071
2083
|
var addedNodes = records[i].addedNodes;
|
|
@@ -2118,8 +2130,10 @@
|
|
|
2118
2130
|
target = getDefaultTarget$1();
|
|
2119
2131
|
if (typeof target === 'undefined')
|
|
2120
2132
|
return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
|
|
2133
|
+
if (getIsActive$1() && getElement$1() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
|
|
2134
|
+
return reject(new NotSupportedError('There is already a Fullscreen element in this document.'));
|
|
2121
2135
|
var tagName = target.tagName.toLowerCase();
|
|
2122
|
-
var isIOSFullscreenActive =
|
|
2136
|
+
var isIOSFullscreenActive = lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true;
|
|
2123
2137
|
if (api !== null) {
|
|
2124
2138
|
var method = target[api.request];
|
|
2125
2139
|
if (typeof method === 'function' && !isIOSFullscreenActive) {
|
|
@@ -2133,7 +2147,7 @@
|
|
|
2133
2147
|
return reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
|
|
2134
2148
|
fallbackToIOSVideo();
|
|
2135
2149
|
}
|
|
2136
|
-
catch (
|
|
2150
|
+
catch (e) {
|
|
2137
2151
|
reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
|
|
2138
2152
|
}
|
|
2139
2153
|
});
|
|
@@ -2152,7 +2166,8 @@
|
|
|
2152
2166
|
video_1.play()
|
|
2153
2167
|
.then(function () {
|
|
2154
2168
|
try {
|
|
2155
|
-
video_1.webkitEnterFullscreen
|
|
2169
|
+
if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function')
|
|
2170
|
+
video_1.webkitEnterFullscreen();
|
|
2156
2171
|
}
|
|
2157
2172
|
catch (e) {
|
|
2158
2173
|
return reject(new InvalidStateError('The object is in an invalid state.'));
|
|
@@ -2167,7 +2182,7 @@
|
|
|
2167
2182
|
return reject(new InvalidStateError('The object is in an invalid state.'));
|
|
2168
2183
|
}
|
|
2169
2184
|
}
|
|
2170
|
-
|
|
2185
|
+
lastFallbackVideoElement$1 = video_1;
|
|
2171
2186
|
return resolve();
|
|
2172
2187
|
}
|
|
2173
2188
|
}
|
|
@@ -2185,16 +2200,7 @@
|
|
|
2185
2200
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
2186
2201
|
result
|
|
2187
2202
|
.then(resolve)
|
|
2188
|
-
.catch(
|
|
2189
|
-
try {
|
|
2190
|
-
if (Platform.os.name !== OS.iOS)
|
|
2191
|
-
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2192
|
-
fallbackToIOSVideo();
|
|
2193
|
-
}
|
|
2194
|
-
catch (_e) {
|
|
2195
|
-
reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2203
|
+
.catch(resolve);
|
|
2198
2204
|
return;
|
|
2199
2205
|
}
|
|
2200
2206
|
return resolve();
|
|
@@ -2205,12 +2211,12 @@
|
|
|
2205
2211
|
reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2206
2212
|
return;
|
|
2207
2213
|
}
|
|
2208
|
-
var target =
|
|
2214
|
+
var target = lastFallbackVideoElement$1;
|
|
2209
2215
|
if (target !== null && typeof target.webkitExitFullscreen === 'function' && target.webkitDisplayingFullscreen === true) {
|
|
2210
2216
|
target.webkitExitFullscreen();
|
|
2211
2217
|
if (target.webkitDisplayingFullscreen)
|
|
2212
2218
|
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2213
|
-
|
|
2219
|
+
lastFallbackVideoElement$1 = null;
|
|
2214
2220
|
return resolve();
|
|
2215
2221
|
}
|
|
2216
2222
|
var videos = globalThis.document.querySelectorAll('video');
|
|
@@ -2220,7 +2226,7 @@
|
|
|
2220
2226
|
video.webkitExitFullscreen();
|
|
2221
2227
|
if (video.webkitDisplayingFullscreen)
|
|
2222
2228
|
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2223
|
-
|
|
2229
|
+
lastFallbackVideoElement$1 = null;
|
|
2224
2230
|
return resolve();
|
|
2225
2231
|
}
|
|
2226
2232
|
}
|
|
@@ -2231,6 +2237,39 @@
|
|
|
2231
2237
|
fallbackToIOSVideo();
|
|
2232
2238
|
});
|
|
2233
2239
|
}
|
|
2240
|
+
function toggle$1(target, options) {
|
|
2241
|
+
var current = getElement$1();
|
|
2242
|
+
if (typeof target !== 'undefined') {
|
|
2243
|
+
if (current === target)
|
|
2244
|
+
return this.exit();
|
|
2245
|
+
return this.request(target, options);
|
|
2246
|
+
}
|
|
2247
|
+
if (current !== null)
|
|
2248
|
+
return this.exit();
|
|
2249
|
+
return this.request(undefined, options);
|
|
2250
|
+
}
|
|
2251
|
+
function onChange$1(targetOrListener, listenerOrOptions, options) {
|
|
2252
|
+
if (typeof targetOrListener === 'function')
|
|
2253
|
+
return onChangeSubscriptionManager$3.subscribe(targetOrListener, listenerOrOptions);
|
|
2254
|
+
var target = targetOrListener;
|
|
2255
|
+
var listener = listenerOrOptions;
|
|
2256
|
+
function wrappedListener(payload) {
|
|
2257
|
+
if (payload.element === target)
|
|
2258
|
+
listener(payload);
|
|
2259
|
+
}
|
|
2260
|
+
return onChangeSubscriptionManager$3.subscribe(wrappedListener, options);
|
|
2261
|
+
}
|
|
2262
|
+
function onError$1(targetOrListener, listenerOrOptions, options) {
|
|
2263
|
+
if (typeof targetOrListener === 'function')
|
|
2264
|
+
return onErrorSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
|
|
2265
|
+
var target = targetOrListener;
|
|
2266
|
+
var listener = listenerOrOptions;
|
|
2267
|
+
function wrappedListener(payload) {
|
|
2268
|
+
if (payload.element === target)
|
|
2269
|
+
listener(payload);
|
|
2270
|
+
}
|
|
2271
|
+
return onErrorSubscriptionManager$1.subscribe(wrappedListener, options);
|
|
2272
|
+
}
|
|
2234
2273
|
bridgeEvents$1();
|
|
2235
2274
|
|
|
2236
2275
|
var PermissionType;
|
|
@@ -4038,7 +4077,8 @@
|
|
|
4038
4077
|
|
|
4039
4078
|
var PIP_PRESENTATION_MODE = 'picture-in-picture';
|
|
4040
4079
|
var INLINE_PRESENTATION_MODE = 'inline';
|
|
4041
|
-
var
|
|
4080
|
+
var videoElement = null;
|
|
4081
|
+
var lastFallbackVideoElement = null;
|
|
4042
4082
|
var eventsBridged = false;
|
|
4043
4083
|
var PIP_BRIDGE_KEY = (function () {
|
|
4044
4084
|
if (typeof Symbol === 'function') {
|
|
@@ -4053,43 +4093,57 @@
|
|
|
4053
4093
|
var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
|
|
4054
4094
|
var Pip = {
|
|
4055
4095
|
get supported() {
|
|
4056
|
-
return
|
|
4096
|
+
return getSupported();
|
|
4057
4097
|
},
|
|
4058
4098
|
get element() {
|
|
4059
4099
|
return getElement();
|
|
4060
4100
|
},
|
|
4061
|
-
get
|
|
4062
|
-
return
|
|
4101
|
+
get isActive() {
|
|
4102
|
+
return getIsActive();
|
|
4063
4103
|
},
|
|
4064
4104
|
request: request,
|
|
4065
4105
|
exit: exit,
|
|
4066
|
-
|
|
4067
|
-
|
|
4106
|
+
toggle: toggle,
|
|
4107
|
+
onChange: onChange,
|
|
4108
|
+
onError: onError,
|
|
4068
4109
|
Constants: {},
|
|
4069
4110
|
Errors: {
|
|
4070
4111
|
NotSupportedError: NotSupportedError,
|
|
4071
4112
|
InvalidStateError: InvalidStateError,
|
|
4072
4113
|
},
|
|
4073
4114
|
};
|
|
4115
|
+
function getHTMLVideoElement() {
|
|
4116
|
+
var selected = globalThis.document.querySelector('video');
|
|
4117
|
+
if (selected !== null)
|
|
4118
|
+
return selected;
|
|
4119
|
+
if (videoElement === null)
|
|
4120
|
+
return videoElement = globalThis.document.createElement('video');
|
|
4121
|
+
return videoElement;
|
|
4122
|
+
}
|
|
4074
4123
|
function hasStandardApi() {
|
|
4075
4124
|
return typeof globalThis.document.pictureInPictureEnabled !== 'undefined';
|
|
4076
4125
|
}
|
|
4126
|
+
function hasWebkitApi() {
|
|
4127
|
+
return typeof getHTMLVideoElement().webkitSetPresentationMode === 'function';
|
|
4128
|
+
}
|
|
4077
4129
|
function getDefaultTarget() {
|
|
4078
4130
|
var video = globalThis.document.querySelector('video');
|
|
4079
|
-
|
|
4131
|
+
if (video !== null)
|
|
4132
|
+
return video;
|
|
4133
|
+
return undefined;
|
|
4080
4134
|
}
|
|
4081
|
-
function createPipEventPayload(nativeEvent, element,
|
|
4135
|
+
function createPipEventPayload(nativeEvent, element, isActive) {
|
|
4082
4136
|
return {
|
|
4083
4137
|
nativeEvent: nativeEvent,
|
|
4084
4138
|
element: element,
|
|
4085
|
-
|
|
4139
|
+
isActive: isActive
|
|
4086
4140
|
};
|
|
4087
4141
|
}
|
|
4088
|
-
function emitChange(nativeEvent, element,
|
|
4089
|
-
onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element,
|
|
4142
|
+
function emitChange(nativeEvent, element, isActive) {
|
|
4143
|
+
onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
4090
4144
|
}
|
|
4091
|
-
function emitError(nativeEvent, element,
|
|
4092
|
-
onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element,
|
|
4145
|
+
function emitError(nativeEvent, element, isActive) {
|
|
4146
|
+
onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
4093
4147
|
}
|
|
4094
4148
|
function onEnterPictureInPicture(event) {
|
|
4095
4149
|
var target = event.target;
|
|
@@ -4104,16 +4158,16 @@
|
|
|
4104
4158
|
function onPictureInPictureError(event) {
|
|
4105
4159
|
var target = event.target;
|
|
4106
4160
|
if (target instanceof globalThis.HTMLVideoElement)
|
|
4107
|
-
emitError(event, target,
|
|
4161
|
+
emitError(event, target, getIsActive());
|
|
4108
4162
|
}
|
|
4109
4163
|
function onWebkitPresentationModeChanged(event) {
|
|
4110
4164
|
if (this.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
4111
|
-
|
|
4165
|
+
lastFallbackVideoElement = this;
|
|
4112
4166
|
emitChange(event, this, true);
|
|
4113
4167
|
return;
|
|
4114
4168
|
}
|
|
4115
|
-
if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE &&
|
|
4116
|
-
|
|
4169
|
+
if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastFallbackVideoElement === this) {
|
|
4170
|
+
lastFallbackVideoElement = null;
|
|
4117
4171
|
emitChange(event, this, false);
|
|
4118
4172
|
}
|
|
4119
4173
|
}
|
|
@@ -4134,19 +4188,19 @@
|
|
|
4134
4188
|
if (eventsBridged)
|
|
4135
4189
|
return;
|
|
4136
4190
|
eventsBridged = true;
|
|
4137
|
-
if (hasStandardApi())
|
|
4191
|
+
if (hasStandardApi() && !hasWebkitApi())
|
|
4138
4192
|
return;
|
|
4139
4193
|
bridgeWebkitVideoEvents();
|
|
4140
4194
|
if (typeof globalThis.MutationObserver === 'undefined')
|
|
4141
4195
|
return;
|
|
4142
4196
|
var observer = new globalThis.MutationObserver(function (records) {
|
|
4143
|
-
if (
|
|
4197
|
+
if (lastFallbackVideoElement !== null) {
|
|
4144
4198
|
var removed = false;
|
|
4145
4199
|
for (var i = 0; i < records.length; i++) {
|
|
4146
4200
|
var removedNodes = records[i].removedNodes;
|
|
4147
4201
|
for (var j = 0; j < removedNodes.length; j++) {
|
|
4148
4202
|
var node = removedNodes[j];
|
|
4149
|
-
if (node ===
|
|
4203
|
+
if (node === lastFallbackVideoElement || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement))) {
|
|
4150
4204
|
removed = true;
|
|
4151
4205
|
break;
|
|
4152
4206
|
}
|
|
@@ -4154,8 +4208,8 @@
|
|
|
4154
4208
|
if (removed)
|
|
4155
4209
|
break;
|
|
4156
4210
|
}
|
|
4157
|
-
if (removed && !globalThis.document.contains(
|
|
4158
|
-
|
|
4211
|
+
if (removed && !globalThis.document.contains(lastFallbackVideoElement))
|
|
4212
|
+
lastFallbackVideoElement = null;
|
|
4159
4213
|
}
|
|
4160
4214
|
for (var i = 0; i < records.length; i++) {
|
|
4161
4215
|
var addedNodes = records[i].addedNodes;
|
|
@@ -4202,26 +4256,21 @@
|
|
|
4202
4256
|
function detachOnError() {
|
|
4203
4257
|
EventListener.remove(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
|
|
4204
4258
|
}
|
|
4205
|
-
function
|
|
4259
|
+
function getSupported() {
|
|
4206
4260
|
if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
|
|
4207
4261
|
return globalThis.document.pictureInPictureEnabled;
|
|
4208
|
-
var video;
|
|
4209
|
-
var selected = globalThis.document.querySelector('video');
|
|
4210
|
-
if (selected !== null)
|
|
4211
|
-
video = selected;
|
|
4212
|
-
else
|
|
4213
|
-
video = globalThis.document.createElement('video');
|
|
4262
|
+
var video = getHTMLVideoElement();
|
|
4214
4263
|
return typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE);
|
|
4215
4264
|
}
|
|
4216
4265
|
function getElement() {
|
|
4217
4266
|
var currentElement = globalThis.document.pictureInPictureElement;
|
|
4218
4267
|
if (currentElement !== null && typeof currentElement !== 'undefined')
|
|
4219
4268
|
return currentElement;
|
|
4220
|
-
if (
|
|
4221
|
-
return
|
|
4269
|
+
if (lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE)
|
|
4270
|
+
return lastFallbackVideoElement;
|
|
4222
4271
|
return null;
|
|
4223
4272
|
}
|
|
4224
|
-
function
|
|
4273
|
+
function getIsActive() {
|
|
4225
4274
|
return getElement() !== null;
|
|
4226
4275
|
}
|
|
4227
4276
|
function request(target) {
|
|
@@ -4230,12 +4279,14 @@
|
|
|
4230
4279
|
target = getDefaultTarget();
|
|
4231
4280
|
if (typeof target === 'undefined')
|
|
4232
4281
|
return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
|
|
4282
|
+
if (getIsActive() && getElement() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
|
|
4283
|
+
return reject(new NotSupportedError('There is already a Picture-in-Picture element in this document.'));
|
|
4233
4284
|
var tagName = target.tagName.toLowerCase();
|
|
4234
4285
|
if (tagName !== 'video')
|
|
4235
4286
|
return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
4236
4287
|
var method = target.requestPictureInPicture;
|
|
4237
|
-
var isWebkitPipActive =
|
|
4238
|
-
if (typeof method === 'function' && !isWebkitPipActive) {
|
|
4288
|
+
var isWebkitPipActive = lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE;
|
|
4289
|
+
if (typeof method === 'function' && !hasWebkitApi() && !isWebkitPipActive) {
|
|
4239
4290
|
var result = method.call(target);
|
|
4240
4291
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
4241
4292
|
result
|
|
@@ -4256,12 +4307,8 @@
|
|
|
4256
4307
|
if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
|
|
4257
4308
|
if (target.disablePictureInPicture)
|
|
4258
4309
|
return reject(new NotSupportedError('Picture-in-Picture is disabled on this element.'));
|
|
4259
|
-
|
|
4260
|
-
bridgeSingleVideoNode(target);
|
|
4310
|
+
bridgeSingleVideoNode(target);
|
|
4261
4311
|
target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
|
|
4262
|
-
if (target.webkitPresentationMode !== PIP_PRESENTATION_MODE)
|
|
4263
|
-
return reject(new InvalidStateError('Picture-in-Picture transition is already in progress.'));
|
|
4264
|
-
lastPipVideo = target;
|
|
4265
4312
|
return resolve();
|
|
4266
4313
|
}
|
|
4267
4314
|
reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
@@ -4272,7 +4319,7 @@
|
|
|
4272
4319
|
function exit() {
|
|
4273
4320
|
return new Promise(function (resolve, reject) {
|
|
4274
4321
|
var method = globalThis.document.exitPictureInPicture;
|
|
4275
|
-
if (typeof method === 'function') {
|
|
4322
|
+
if (typeof method === 'function' && !hasWebkitApi()) {
|
|
4276
4323
|
var result = method.call(globalThis.document);
|
|
4277
4324
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
4278
4325
|
result
|
|
@@ -4290,9 +4337,8 @@
|
|
|
4290
4337
|
return resolve();
|
|
4291
4338
|
}
|
|
4292
4339
|
function fallbackToWebkit() {
|
|
4293
|
-
if (
|
|
4294
|
-
|
|
4295
|
-
lastPipVideo = null;
|
|
4340
|
+
if (lastFallbackVideoElement !== null && typeof lastFallbackVideoElement.webkitSetPresentationMode === 'function') {
|
|
4341
|
+
lastFallbackVideoElement.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
4296
4342
|
return resolve();
|
|
4297
4343
|
}
|
|
4298
4344
|
var videos = globalThis.document.querySelectorAll('video');
|
|
@@ -4300,17 +4346,49 @@
|
|
|
4300
4346
|
var video = videos[i];
|
|
4301
4347
|
if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
4302
4348
|
video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
4303
|
-
lastPipVideo = null;
|
|
4304
4349
|
return resolve();
|
|
4305
4350
|
}
|
|
4306
4351
|
}
|
|
4307
|
-
|
|
4308
|
-
return resolve();
|
|
4309
|
-
reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
|
|
4352
|
+
return resolve();
|
|
4310
4353
|
}
|
|
4311
4354
|
fallbackToWebkit();
|
|
4312
4355
|
});
|
|
4313
4356
|
}
|
|
4357
|
+
function toggle(target) {
|
|
4358
|
+
var current = getElement();
|
|
4359
|
+
if (typeof target !== 'undefined') {
|
|
4360
|
+
if (current === target)
|
|
4361
|
+
return this.exit();
|
|
4362
|
+
else
|
|
4363
|
+
return this.request(target);
|
|
4364
|
+
}
|
|
4365
|
+
if (current !== null)
|
|
4366
|
+
return this.exit();
|
|
4367
|
+
else
|
|
4368
|
+
return this.request(target);
|
|
4369
|
+
}
|
|
4370
|
+
function onChange(targetOrListener, listenerOrOptions, options) {
|
|
4371
|
+
if (typeof targetOrListener === 'function')
|
|
4372
|
+
return onChangeSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
|
|
4373
|
+
var target = targetOrListener;
|
|
4374
|
+
var listener = listenerOrOptions;
|
|
4375
|
+
function wrappedListener(payload) {
|
|
4376
|
+
if (payload.element === target)
|
|
4377
|
+
listener(payload);
|
|
4378
|
+
}
|
|
4379
|
+
return onChangeSubscriptionManager$1.subscribe(wrappedListener, options);
|
|
4380
|
+
}
|
|
4381
|
+
function onError(targetOrListener, listenerOrOptions, options) {
|
|
4382
|
+
if (typeof targetOrListener === 'function')
|
|
4383
|
+
return onErrorSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
|
|
4384
|
+
var target = targetOrListener;
|
|
4385
|
+
var listener = listenerOrOptions;
|
|
4386
|
+
function wrappedListener(payload) {
|
|
4387
|
+
if (payload.element === target)
|
|
4388
|
+
listener(payload);
|
|
4389
|
+
}
|
|
4390
|
+
return onErrorSubscriptionManager.subscribe(wrappedListener, options);
|
|
4391
|
+
}
|
|
4314
4392
|
bridgeEvents();
|
|
4315
4393
|
|
|
4316
4394
|
var Badge = {
|