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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "1.2.
|
|
1
|
+
var version = "1.2.1";
|
|
2
2
|
var packageJSON = {
|
|
3
3
|
version: version};
|
|
4
4
|
|
|
@@ -687,10 +687,15 @@ function parseFromHighEntropyValues() {
|
|
|
687
687
|
parsedFromHighEntropyValuesEngine.version = brandVersion;
|
|
688
688
|
}
|
|
689
689
|
if (typeof platformVersion === 'string') {
|
|
690
|
-
if (getParsedCache().os.name === OS.Windows)
|
|
691
|
-
|
|
692
|
-
|
|
690
|
+
if (getParsedCache().os.name === OS.Windows) {
|
|
691
|
+
if (parseInt(platformVersion.split('.')[0], 10) >= 13)
|
|
692
|
+
parsedFromHighEntropyValuesOS.version = '11';
|
|
693
|
+
else
|
|
694
|
+
parsedFromHighEntropyValuesOS.version = '10';
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
693
697
|
parsedFromHighEntropyValuesOS.version = platformVersion;
|
|
698
|
+
}
|
|
694
699
|
}
|
|
695
700
|
if (typeof platform === 'string') {
|
|
696
701
|
if (/android/i.test(platform))
|
|
@@ -1867,7 +1872,8 @@ var NotSupportedError = createCustomError('NotSupportedError');
|
|
|
1867
1872
|
|
|
1868
1873
|
var InvalidStateError = createCustomError('InvalidStateError');
|
|
1869
1874
|
|
|
1870
|
-
var
|
|
1875
|
+
var videoElement$1 = null;
|
|
1876
|
+
var lastFallbackVideoElement$1 = null;
|
|
1871
1877
|
var eventsBridged$1 = false;
|
|
1872
1878
|
var FS_BRIDGE_KEY = (function () {
|
|
1873
1879
|
if (typeof Symbol === 'function') {
|
|
@@ -1913,24 +1919,33 @@ var onChangeSubscriptionManager$3 = createSubscriptionManager(attachOnChange$3,
|
|
|
1913
1919
|
var onErrorSubscriptionManager$1 = createSubscriptionManager(attachOnError$1, detachOnError$1);
|
|
1914
1920
|
var Fullscreen = {
|
|
1915
1921
|
get supported() {
|
|
1916
|
-
return
|
|
1922
|
+
return getSupported$1();
|
|
1917
1923
|
},
|
|
1918
1924
|
get element() {
|
|
1919
1925
|
return getElement$1();
|
|
1920
1926
|
},
|
|
1921
|
-
get
|
|
1922
|
-
return
|
|
1927
|
+
get isActive() {
|
|
1928
|
+
return getIsActive$1();
|
|
1923
1929
|
},
|
|
1924
1930
|
request: request$3,
|
|
1925
1931
|
exit: exit$1,
|
|
1926
|
-
|
|
1927
|
-
|
|
1932
|
+
toggle: toggle$1,
|
|
1933
|
+
onChange: onChange$1,
|
|
1934
|
+
onError: onError$1,
|
|
1928
1935
|
Constants: {},
|
|
1929
1936
|
Errors: {
|
|
1930
1937
|
NotSupportedError: NotSupportedError,
|
|
1931
1938
|
InvalidStateError: InvalidStateError,
|
|
1932
1939
|
},
|
|
1933
1940
|
};
|
|
1941
|
+
function getHTMLVideoElement$1() {
|
|
1942
|
+
var selected = globalThis.document.querySelector('video');
|
|
1943
|
+
if (selected !== null)
|
|
1944
|
+
return selected;
|
|
1945
|
+
if (videoElement$1 === null)
|
|
1946
|
+
return videoElement$1 = globalThis.document.createElement('video');
|
|
1947
|
+
return videoElement$1;
|
|
1948
|
+
}
|
|
1934
1949
|
function hasStandardApi$1() {
|
|
1935
1950
|
return api !== null;
|
|
1936
1951
|
}
|
|
@@ -1953,27 +1968,24 @@ function detectApi() {
|
|
|
1953
1968
|
function getDefaultTarget$1() {
|
|
1954
1969
|
if (Platform.os.name === OS.iOS) {
|
|
1955
1970
|
var video = globalThis.document.querySelector('video');
|
|
1956
|
-
|
|
1971
|
+
if (video !== null)
|
|
1972
|
+
return video;
|
|
1973
|
+
return undefined;
|
|
1957
1974
|
}
|
|
1958
1975
|
return globalThis.document.documentElement;
|
|
1959
1976
|
}
|
|
1960
|
-
function
|
|
1977
|
+
function getSupported$1() {
|
|
1961
1978
|
if (api !== null)
|
|
1962
1979
|
return globalThis.document[api.enabled] === true;
|
|
1963
1980
|
if (Platform.os.name !== OS.iOS)
|
|
1964
1981
|
return false;
|
|
1965
|
-
var video;
|
|
1966
|
-
var selected = globalThis.document.querySelector('video');
|
|
1967
|
-
if (selected !== null)
|
|
1968
|
-
video = selected;
|
|
1969
|
-
else
|
|
1970
|
-
video = globalThis.document.createElement('video');
|
|
1982
|
+
var video = getHTMLVideoElement$1();
|
|
1971
1983
|
return video.webkitSupportsFullscreen === true || typeof video.webkitEnterFullscreen === 'function';
|
|
1972
1984
|
}
|
|
1973
1985
|
function getElement$1() {
|
|
1974
1986
|
if (api === null) {
|
|
1975
|
-
if (
|
|
1976
|
-
return
|
|
1987
|
+
if (lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true)
|
|
1988
|
+
return lastFallbackVideoElement$1;
|
|
1977
1989
|
return null;
|
|
1978
1990
|
}
|
|
1979
1991
|
var currentElement = globalThis.document[api.element];
|
|
@@ -1981,43 +1993,43 @@ function getElement$1() {
|
|
|
1981
1993
|
return currentElement;
|
|
1982
1994
|
return null;
|
|
1983
1995
|
}
|
|
1984
|
-
function
|
|
1996
|
+
function getIsActive$1() {
|
|
1985
1997
|
return getElement$1() !== null;
|
|
1986
1998
|
}
|
|
1987
|
-
function createEventPayload(nativeEvent, element,
|
|
1999
|
+
function createEventPayload(nativeEvent, element, isActive) {
|
|
1988
2000
|
return {
|
|
1989
2001
|
nativeEvent: nativeEvent,
|
|
1990
2002
|
element: element,
|
|
1991
|
-
|
|
2003
|
+
isActive: isActive,
|
|
1992
2004
|
};
|
|
1993
2005
|
}
|
|
1994
|
-
function emitChange$1(nativeEvent, element,
|
|
1995
|
-
onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element,
|
|
2006
|
+
function emitChange$1(nativeEvent, element, isActive) {
|
|
2007
|
+
onChangeSubscriptionManager$3.emit(createEventPayload(nativeEvent, element, isActive));
|
|
1996
2008
|
}
|
|
1997
|
-
function emitError$1(nativeEvent, element,
|
|
1998
|
-
onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element,
|
|
2009
|
+
function emitError$1(nativeEvent, element, isActive) {
|
|
2010
|
+
onErrorSubscriptionManager$1.emit(createEventPayload(nativeEvent, element, isActive));
|
|
1999
2011
|
}
|
|
2000
2012
|
function onFullscreenChange(event) {
|
|
2001
2013
|
var target = event.target;
|
|
2002
2014
|
if (target instanceof globalThis.Element)
|
|
2003
|
-
emitChange$1(event, target,
|
|
2015
|
+
emitChange$1(event, target, getIsActive$1());
|
|
2004
2016
|
if (target instanceof globalThis.Document)
|
|
2005
|
-
emitChange$1(event, globalThis.document.documentElement,
|
|
2017
|
+
emitChange$1(event, globalThis.document.documentElement, getIsActive$1());
|
|
2006
2018
|
}
|
|
2007
2019
|
function onFullscreenError(event) {
|
|
2008
2020
|
var target = event.target;
|
|
2009
2021
|
if (target instanceof globalThis.Element)
|
|
2010
|
-
emitError$1(event, target,
|
|
2022
|
+
emitError$1(event, target, getIsActive$1());
|
|
2011
2023
|
if (target instanceof globalThis.Document)
|
|
2012
|
-
emitError$1(event, globalThis.document.documentElement,
|
|
2024
|
+
emitError$1(event, globalThis.document.documentElement, getIsActive$1());
|
|
2013
2025
|
}
|
|
2014
2026
|
function onIOSBeginFullscreen(event) {
|
|
2015
|
-
|
|
2027
|
+
lastFallbackVideoElement$1 = this;
|
|
2016
2028
|
emitChange$1(event, this, true);
|
|
2017
2029
|
}
|
|
2018
2030
|
function onIOSEndFullscreen(event) {
|
|
2019
|
-
if (
|
|
2020
|
-
|
|
2031
|
+
if (lastFallbackVideoElement$1 === this)
|
|
2032
|
+
lastFallbackVideoElement$1 = null;
|
|
2021
2033
|
emitChange$1(event, this, false);
|
|
2022
2034
|
}
|
|
2023
2035
|
function bridgeSingleVideoNode$1(video) {
|
|
@@ -2044,13 +2056,13 @@ function bridgeEvents$1() {
|
|
|
2044
2056
|
if (typeof globalThis.MutationObserver === 'undefined')
|
|
2045
2057
|
return;
|
|
2046
2058
|
var observer = new globalThis.MutationObserver(function (records) {
|
|
2047
|
-
if (
|
|
2059
|
+
if (lastFallbackVideoElement$1 !== null) {
|
|
2048
2060
|
var removed = false;
|
|
2049
2061
|
for (var i = 0; i < records.length; i++) {
|
|
2050
2062
|
var removedNodes = records[i].removedNodes;
|
|
2051
2063
|
for (var j = 0; j < removedNodes.length; j++) {
|
|
2052
2064
|
var node = removedNodes[j];
|
|
2053
|
-
if (node ===
|
|
2065
|
+
if (node === lastFallbackVideoElement$1 || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement$1))) {
|
|
2054
2066
|
removed = true;
|
|
2055
2067
|
break;
|
|
2056
2068
|
}
|
|
@@ -2058,8 +2070,8 @@ function bridgeEvents$1() {
|
|
|
2058
2070
|
if (removed)
|
|
2059
2071
|
break;
|
|
2060
2072
|
}
|
|
2061
|
-
if (removed && !globalThis.document.contains(
|
|
2062
|
-
|
|
2073
|
+
if (removed && !globalThis.document.contains(lastFallbackVideoElement$1))
|
|
2074
|
+
lastFallbackVideoElement$1 = null;
|
|
2063
2075
|
}
|
|
2064
2076
|
for (var i = 0; i < records.length; i++) {
|
|
2065
2077
|
var addedNodes = records[i].addedNodes;
|
|
@@ -2112,8 +2124,10 @@ function request$3(target, options) {
|
|
|
2112
2124
|
target = getDefaultTarget$1();
|
|
2113
2125
|
if (typeof target === 'undefined')
|
|
2114
2126
|
return reject(new NotSupportedError('Failed to enter fullscreen mode.'));
|
|
2127
|
+
if (getIsActive$1() && getElement$1() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
|
|
2128
|
+
return reject(new NotSupportedError('There is already a Fullscreen element in this document.'));
|
|
2115
2129
|
var tagName = target.tagName.toLowerCase();
|
|
2116
|
-
var isIOSFullscreenActive =
|
|
2130
|
+
var isIOSFullscreenActive = lastFallbackVideoElement$1 !== null && lastFallbackVideoElement$1.webkitDisplayingFullscreen === true;
|
|
2117
2131
|
if (api !== null) {
|
|
2118
2132
|
var method = target[api.request];
|
|
2119
2133
|
if (typeof method === 'function' && !isIOSFullscreenActive) {
|
|
@@ -2127,7 +2141,7 @@ function request$3(target, options) {
|
|
|
2127
2141
|
return reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
|
|
2128
2142
|
fallbackToIOSVideo();
|
|
2129
2143
|
}
|
|
2130
|
-
catch (
|
|
2144
|
+
catch (e) {
|
|
2131
2145
|
reject(new NotSupportedError('The "' + tagName + '" element does not support fullscreen requests.'));
|
|
2132
2146
|
}
|
|
2133
2147
|
});
|
|
@@ -2146,7 +2160,8 @@ function request$3(target, options) {
|
|
|
2146
2160
|
video_1.play()
|
|
2147
2161
|
.then(function () {
|
|
2148
2162
|
try {
|
|
2149
|
-
video_1.webkitEnterFullscreen
|
|
2163
|
+
if (video_1.webkitSupportsFullscreen && typeof video_1.webkitEnterFullscreen === 'function')
|
|
2164
|
+
video_1.webkitEnterFullscreen();
|
|
2150
2165
|
}
|
|
2151
2166
|
catch (e) {
|
|
2152
2167
|
return reject(new InvalidStateError('The object is in an invalid state.'));
|
|
@@ -2161,7 +2176,7 @@ function request$3(target, options) {
|
|
|
2161
2176
|
return reject(new InvalidStateError('The object is in an invalid state.'));
|
|
2162
2177
|
}
|
|
2163
2178
|
}
|
|
2164
|
-
|
|
2179
|
+
lastFallbackVideoElement$1 = video_1;
|
|
2165
2180
|
return resolve();
|
|
2166
2181
|
}
|
|
2167
2182
|
}
|
|
@@ -2179,16 +2194,7 @@ function exit$1() {
|
|
|
2179
2194
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
2180
2195
|
result
|
|
2181
2196
|
.then(resolve)
|
|
2182
|
-
.catch(
|
|
2183
|
-
try {
|
|
2184
|
-
if (Platform.os.name !== OS.iOS)
|
|
2185
|
-
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2186
|
-
fallbackToIOSVideo();
|
|
2187
|
-
}
|
|
2188
|
-
catch (_e) {
|
|
2189
|
-
reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2190
|
-
}
|
|
2191
|
-
});
|
|
2197
|
+
.catch(resolve);
|
|
2192
2198
|
return;
|
|
2193
2199
|
}
|
|
2194
2200
|
return resolve();
|
|
@@ -2199,12 +2205,12 @@ function exit$1() {
|
|
|
2199
2205
|
reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2200
2206
|
return;
|
|
2201
2207
|
}
|
|
2202
|
-
var target =
|
|
2208
|
+
var target = lastFallbackVideoElement$1;
|
|
2203
2209
|
if (target !== null && typeof target.webkitExitFullscreen === 'function' && target.webkitDisplayingFullscreen === true) {
|
|
2204
2210
|
target.webkitExitFullscreen();
|
|
2205
2211
|
if (target.webkitDisplayingFullscreen)
|
|
2206
2212
|
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2207
|
-
|
|
2213
|
+
lastFallbackVideoElement$1 = null;
|
|
2208
2214
|
return resolve();
|
|
2209
2215
|
}
|
|
2210
2216
|
var videos = globalThis.document.querySelectorAll('video');
|
|
@@ -2214,7 +2220,7 @@ function exit$1() {
|
|
|
2214
2220
|
video.webkitExitFullscreen();
|
|
2215
2221
|
if (video.webkitDisplayingFullscreen)
|
|
2216
2222
|
return reject(new NotSupportedError('Failed to exit fullscreen mode.'));
|
|
2217
|
-
|
|
2223
|
+
lastFallbackVideoElement$1 = null;
|
|
2218
2224
|
return resolve();
|
|
2219
2225
|
}
|
|
2220
2226
|
}
|
|
@@ -2225,6 +2231,39 @@ function exit$1() {
|
|
|
2225
2231
|
fallbackToIOSVideo();
|
|
2226
2232
|
});
|
|
2227
2233
|
}
|
|
2234
|
+
function toggle$1(target, options) {
|
|
2235
|
+
var current = getElement$1();
|
|
2236
|
+
if (typeof target !== 'undefined') {
|
|
2237
|
+
if (current === target)
|
|
2238
|
+
return this.exit();
|
|
2239
|
+
return this.request(target, options);
|
|
2240
|
+
}
|
|
2241
|
+
if (current !== null)
|
|
2242
|
+
return this.exit();
|
|
2243
|
+
return this.request(undefined, options);
|
|
2244
|
+
}
|
|
2245
|
+
function onChange$1(targetOrListener, listenerOrOptions, options) {
|
|
2246
|
+
if (typeof targetOrListener === 'function')
|
|
2247
|
+
return onChangeSubscriptionManager$3.subscribe(targetOrListener, listenerOrOptions);
|
|
2248
|
+
var target = targetOrListener;
|
|
2249
|
+
var listener = listenerOrOptions;
|
|
2250
|
+
function wrappedListener(payload) {
|
|
2251
|
+
if (payload.element === target)
|
|
2252
|
+
listener(payload);
|
|
2253
|
+
}
|
|
2254
|
+
return onChangeSubscriptionManager$3.subscribe(wrappedListener, options);
|
|
2255
|
+
}
|
|
2256
|
+
function onError$1(targetOrListener, listenerOrOptions, options) {
|
|
2257
|
+
if (typeof targetOrListener === 'function')
|
|
2258
|
+
return onErrorSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
|
|
2259
|
+
var target = targetOrListener;
|
|
2260
|
+
var listener = listenerOrOptions;
|
|
2261
|
+
function wrappedListener(payload) {
|
|
2262
|
+
if (payload.element === target)
|
|
2263
|
+
listener(payload);
|
|
2264
|
+
}
|
|
2265
|
+
return onErrorSubscriptionManager$1.subscribe(wrappedListener, options);
|
|
2266
|
+
}
|
|
2228
2267
|
bridgeEvents$1();
|
|
2229
2268
|
|
|
2230
2269
|
var PermissionType;
|
|
@@ -4032,7 +4071,8 @@ function stop() {
|
|
|
4032
4071
|
|
|
4033
4072
|
var PIP_PRESENTATION_MODE = 'picture-in-picture';
|
|
4034
4073
|
var INLINE_PRESENTATION_MODE = 'inline';
|
|
4035
|
-
var
|
|
4074
|
+
var videoElement = null;
|
|
4075
|
+
var lastFallbackVideoElement = null;
|
|
4036
4076
|
var eventsBridged = false;
|
|
4037
4077
|
var PIP_BRIDGE_KEY = (function () {
|
|
4038
4078
|
if (typeof Symbol === 'function') {
|
|
@@ -4047,43 +4087,57 @@ var onChangeSubscriptionManager$1 = createSubscriptionManager(attachOnChange$1,
|
|
|
4047
4087
|
var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
|
|
4048
4088
|
var Pip = {
|
|
4049
4089
|
get supported() {
|
|
4050
|
-
return
|
|
4090
|
+
return getSupported();
|
|
4051
4091
|
},
|
|
4052
4092
|
get element() {
|
|
4053
4093
|
return getElement();
|
|
4054
4094
|
},
|
|
4055
|
-
get
|
|
4056
|
-
return
|
|
4095
|
+
get isActive() {
|
|
4096
|
+
return getIsActive();
|
|
4057
4097
|
},
|
|
4058
4098
|
request: request,
|
|
4059
4099
|
exit: exit,
|
|
4060
|
-
|
|
4061
|
-
|
|
4100
|
+
toggle: toggle,
|
|
4101
|
+
onChange: onChange,
|
|
4102
|
+
onError: onError,
|
|
4062
4103
|
Constants: {},
|
|
4063
4104
|
Errors: {
|
|
4064
4105
|
NotSupportedError: NotSupportedError,
|
|
4065
4106
|
InvalidStateError: InvalidStateError,
|
|
4066
4107
|
},
|
|
4067
4108
|
};
|
|
4109
|
+
function getHTMLVideoElement() {
|
|
4110
|
+
var selected = globalThis.document.querySelector('video');
|
|
4111
|
+
if (selected !== null)
|
|
4112
|
+
return selected;
|
|
4113
|
+
if (videoElement === null)
|
|
4114
|
+
return videoElement = globalThis.document.createElement('video');
|
|
4115
|
+
return videoElement;
|
|
4116
|
+
}
|
|
4068
4117
|
function hasStandardApi() {
|
|
4069
4118
|
return typeof globalThis.document.pictureInPictureEnabled !== 'undefined';
|
|
4070
4119
|
}
|
|
4120
|
+
function hasWebkitApi() {
|
|
4121
|
+
return typeof getHTMLVideoElement().webkitSetPresentationMode === 'function';
|
|
4122
|
+
}
|
|
4071
4123
|
function getDefaultTarget() {
|
|
4072
4124
|
var video = globalThis.document.querySelector('video');
|
|
4073
|
-
|
|
4125
|
+
if (video !== null)
|
|
4126
|
+
return video;
|
|
4127
|
+
return undefined;
|
|
4074
4128
|
}
|
|
4075
|
-
function createPipEventPayload(nativeEvent, element,
|
|
4129
|
+
function createPipEventPayload(nativeEvent, element, isActive) {
|
|
4076
4130
|
return {
|
|
4077
4131
|
nativeEvent: nativeEvent,
|
|
4078
4132
|
element: element,
|
|
4079
|
-
|
|
4133
|
+
isActive: isActive
|
|
4080
4134
|
};
|
|
4081
4135
|
}
|
|
4082
|
-
function emitChange(nativeEvent, element,
|
|
4083
|
-
onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element,
|
|
4136
|
+
function emitChange(nativeEvent, element, isActive) {
|
|
4137
|
+
onChangeSubscriptionManager$1.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
4084
4138
|
}
|
|
4085
|
-
function emitError(nativeEvent, element,
|
|
4086
|
-
onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element,
|
|
4139
|
+
function emitError(nativeEvent, element, isActive) {
|
|
4140
|
+
onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
4087
4141
|
}
|
|
4088
4142
|
function onEnterPictureInPicture(event) {
|
|
4089
4143
|
var target = event.target;
|
|
@@ -4098,16 +4152,16 @@ function onLeavePictureInPicture(event) {
|
|
|
4098
4152
|
function onPictureInPictureError(event) {
|
|
4099
4153
|
var target = event.target;
|
|
4100
4154
|
if (target instanceof globalThis.HTMLVideoElement)
|
|
4101
|
-
emitError(event, target,
|
|
4155
|
+
emitError(event, target, getIsActive());
|
|
4102
4156
|
}
|
|
4103
4157
|
function onWebkitPresentationModeChanged(event) {
|
|
4104
4158
|
if (this.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
4105
|
-
|
|
4159
|
+
lastFallbackVideoElement = this;
|
|
4106
4160
|
emitChange(event, this, true);
|
|
4107
4161
|
return;
|
|
4108
4162
|
}
|
|
4109
|
-
if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE &&
|
|
4110
|
-
|
|
4163
|
+
if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastFallbackVideoElement === this) {
|
|
4164
|
+
lastFallbackVideoElement = null;
|
|
4111
4165
|
emitChange(event, this, false);
|
|
4112
4166
|
}
|
|
4113
4167
|
}
|
|
@@ -4128,19 +4182,19 @@ function bridgeEvents() {
|
|
|
4128
4182
|
if (eventsBridged)
|
|
4129
4183
|
return;
|
|
4130
4184
|
eventsBridged = true;
|
|
4131
|
-
if (hasStandardApi())
|
|
4185
|
+
if (hasStandardApi() && !hasWebkitApi())
|
|
4132
4186
|
return;
|
|
4133
4187
|
bridgeWebkitVideoEvents();
|
|
4134
4188
|
if (typeof globalThis.MutationObserver === 'undefined')
|
|
4135
4189
|
return;
|
|
4136
4190
|
var observer = new globalThis.MutationObserver(function (records) {
|
|
4137
|
-
if (
|
|
4191
|
+
if (lastFallbackVideoElement !== null) {
|
|
4138
4192
|
var removed = false;
|
|
4139
4193
|
for (var i = 0; i < records.length; i++) {
|
|
4140
4194
|
var removedNodes = records[i].removedNodes;
|
|
4141
4195
|
for (var j = 0; j < removedNodes.length; j++) {
|
|
4142
4196
|
var node = removedNodes[j];
|
|
4143
|
-
if (node ===
|
|
4197
|
+
if (node === lastFallbackVideoElement || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement))) {
|
|
4144
4198
|
removed = true;
|
|
4145
4199
|
break;
|
|
4146
4200
|
}
|
|
@@ -4148,8 +4202,8 @@ function bridgeEvents() {
|
|
|
4148
4202
|
if (removed)
|
|
4149
4203
|
break;
|
|
4150
4204
|
}
|
|
4151
|
-
if (removed && !globalThis.document.contains(
|
|
4152
|
-
|
|
4205
|
+
if (removed && !globalThis.document.contains(lastFallbackVideoElement))
|
|
4206
|
+
lastFallbackVideoElement = null;
|
|
4153
4207
|
}
|
|
4154
4208
|
for (var i = 0; i < records.length; i++) {
|
|
4155
4209
|
var addedNodes = records[i].addedNodes;
|
|
@@ -4196,26 +4250,21 @@ function attachOnError() {
|
|
|
4196
4250
|
function detachOnError() {
|
|
4197
4251
|
EventListener.remove(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
|
|
4198
4252
|
}
|
|
4199
|
-
function
|
|
4253
|
+
function getSupported() {
|
|
4200
4254
|
if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
|
|
4201
4255
|
return globalThis.document.pictureInPictureEnabled;
|
|
4202
|
-
var video;
|
|
4203
|
-
var selected = globalThis.document.querySelector('video');
|
|
4204
|
-
if (selected !== null)
|
|
4205
|
-
video = selected;
|
|
4206
|
-
else
|
|
4207
|
-
video = globalThis.document.createElement('video');
|
|
4256
|
+
var video = getHTMLVideoElement();
|
|
4208
4257
|
return typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE);
|
|
4209
4258
|
}
|
|
4210
4259
|
function getElement() {
|
|
4211
4260
|
var currentElement = globalThis.document.pictureInPictureElement;
|
|
4212
4261
|
if (currentElement !== null && typeof currentElement !== 'undefined')
|
|
4213
4262
|
return currentElement;
|
|
4214
|
-
if (
|
|
4215
|
-
return
|
|
4263
|
+
if (lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE)
|
|
4264
|
+
return lastFallbackVideoElement;
|
|
4216
4265
|
return null;
|
|
4217
4266
|
}
|
|
4218
|
-
function
|
|
4267
|
+
function getIsActive() {
|
|
4219
4268
|
return getElement() !== null;
|
|
4220
4269
|
}
|
|
4221
4270
|
function request(target) {
|
|
@@ -4224,12 +4273,14 @@ function request(target) {
|
|
|
4224
4273
|
target = getDefaultTarget();
|
|
4225
4274
|
if (typeof target === 'undefined')
|
|
4226
4275
|
return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
|
|
4276
|
+
if (getIsActive() && getElement() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
|
|
4277
|
+
return reject(new NotSupportedError('There is already a Picture-in-Picture element in this document.'));
|
|
4227
4278
|
var tagName = target.tagName.toLowerCase();
|
|
4228
4279
|
if (tagName !== 'video')
|
|
4229
4280
|
return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
4230
4281
|
var method = target.requestPictureInPicture;
|
|
4231
|
-
var isWebkitPipActive =
|
|
4232
|
-
if (typeof method === 'function' && !isWebkitPipActive) {
|
|
4282
|
+
var isWebkitPipActive = lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE;
|
|
4283
|
+
if (typeof method === 'function' && !hasWebkitApi() && !isWebkitPipActive) {
|
|
4233
4284
|
var result = method.call(target);
|
|
4234
4285
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
4235
4286
|
result
|
|
@@ -4250,12 +4301,8 @@ function request(target) {
|
|
|
4250
4301
|
if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
|
|
4251
4302
|
if (target.disablePictureInPicture)
|
|
4252
4303
|
return reject(new NotSupportedError('Picture-in-Picture is disabled on this element.'));
|
|
4253
|
-
|
|
4254
|
-
bridgeSingleVideoNode(target);
|
|
4304
|
+
bridgeSingleVideoNode(target);
|
|
4255
4305
|
target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
|
|
4256
|
-
if (target.webkitPresentationMode !== PIP_PRESENTATION_MODE)
|
|
4257
|
-
return reject(new InvalidStateError('Picture-in-Picture transition is already in progress.'));
|
|
4258
|
-
lastPipVideo = target;
|
|
4259
4306
|
return resolve();
|
|
4260
4307
|
}
|
|
4261
4308
|
reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
@@ -4266,7 +4313,7 @@ function request(target) {
|
|
|
4266
4313
|
function exit() {
|
|
4267
4314
|
return new Promise(function (resolve, reject) {
|
|
4268
4315
|
var method = globalThis.document.exitPictureInPicture;
|
|
4269
|
-
if (typeof method === 'function') {
|
|
4316
|
+
if (typeof method === 'function' && !hasWebkitApi()) {
|
|
4270
4317
|
var result = method.call(globalThis.document);
|
|
4271
4318
|
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
4272
4319
|
result
|
|
@@ -4284,9 +4331,8 @@ function exit() {
|
|
|
4284
4331
|
return resolve();
|
|
4285
4332
|
}
|
|
4286
4333
|
function fallbackToWebkit() {
|
|
4287
|
-
if (
|
|
4288
|
-
|
|
4289
|
-
lastPipVideo = null;
|
|
4334
|
+
if (lastFallbackVideoElement !== null && typeof lastFallbackVideoElement.webkitSetPresentationMode === 'function') {
|
|
4335
|
+
lastFallbackVideoElement.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
4290
4336
|
return resolve();
|
|
4291
4337
|
}
|
|
4292
4338
|
var videos = globalThis.document.querySelectorAll('video');
|
|
@@ -4294,17 +4340,49 @@ function exit() {
|
|
|
4294
4340
|
var video = videos[i];
|
|
4295
4341
|
if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
4296
4342
|
video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
4297
|
-
lastPipVideo = null;
|
|
4298
4343
|
return resolve();
|
|
4299
4344
|
}
|
|
4300
4345
|
}
|
|
4301
|
-
|
|
4302
|
-
return resolve();
|
|
4303
|
-
reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
|
|
4346
|
+
return resolve();
|
|
4304
4347
|
}
|
|
4305
4348
|
fallbackToWebkit();
|
|
4306
4349
|
});
|
|
4307
4350
|
}
|
|
4351
|
+
function toggle(target) {
|
|
4352
|
+
var current = getElement();
|
|
4353
|
+
if (typeof target !== 'undefined') {
|
|
4354
|
+
if (current === target)
|
|
4355
|
+
return this.exit();
|
|
4356
|
+
else
|
|
4357
|
+
return this.request(target);
|
|
4358
|
+
}
|
|
4359
|
+
if (current !== null)
|
|
4360
|
+
return this.exit();
|
|
4361
|
+
else
|
|
4362
|
+
return this.request(target);
|
|
4363
|
+
}
|
|
4364
|
+
function onChange(targetOrListener, listenerOrOptions, options) {
|
|
4365
|
+
if (typeof targetOrListener === 'function')
|
|
4366
|
+
return onChangeSubscriptionManager$1.subscribe(targetOrListener, listenerOrOptions);
|
|
4367
|
+
var target = targetOrListener;
|
|
4368
|
+
var listener = listenerOrOptions;
|
|
4369
|
+
function wrappedListener(payload) {
|
|
4370
|
+
if (payload.element === target)
|
|
4371
|
+
listener(payload);
|
|
4372
|
+
}
|
|
4373
|
+
return onChangeSubscriptionManager$1.subscribe(wrappedListener, options);
|
|
4374
|
+
}
|
|
4375
|
+
function onError(targetOrListener, listenerOrOptions, options) {
|
|
4376
|
+
if (typeof targetOrListener === 'function')
|
|
4377
|
+
return onErrorSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
|
|
4378
|
+
var target = targetOrListener;
|
|
4379
|
+
var listener = listenerOrOptions;
|
|
4380
|
+
function wrappedListener(payload) {
|
|
4381
|
+
if (payload.element === target)
|
|
4382
|
+
listener(payload);
|
|
4383
|
+
}
|
|
4384
|
+
return onErrorSubscriptionManager.subscribe(wrappedListener, options);
|
|
4385
|
+
}
|
|
4308
4386
|
bridgeEvents();
|
|
4309
4387
|
|
|
4310
4388
|
var Badge = {
|