native-fn 1.2.2 → 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 +32 -8
- 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/dist/native.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = "1.
|
|
3
|
+
var version = "1.3.0";
|
|
4
4
|
var packageJSON = {
|
|
5
5
|
version: version};
|
|
6
6
|
|
|
@@ -27,11 +27,11 @@ var Appearances;
|
|
|
27
27
|
Appearances["Light"] = "light";
|
|
28
28
|
Appearances["Dark"] = "dark";
|
|
29
29
|
})(Appearances || (Appearances = {}));
|
|
30
|
-
var
|
|
30
|
+
var PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST;
|
|
31
31
|
if (typeof globalThis.matchMedia !== 'undefined')
|
|
32
|
-
|
|
32
|
+
PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST = globalThis.matchMedia('(prefers-color-scheme: dark)');
|
|
33
33
|
else
|
|
34
|
-
|
|
34
|
+
PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
|
|
35
35
|
var CONTEXT = globalThis.document.createElement('canvas').getContext('2d', { willReadFrequently: true });
|
|
36
36
|
var SVG_PIXEL_DATA_URL = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxIiBoZWlnaHQ9IjEiPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik0wIDBoMXYxSDB6Ii8+PC9zdmc+';
|
|
37
37
|
|
|
@@ -124,11 +124,11 @@ var Browsers;
|
|
|
124
124
|
Browsers["IE"] = "IE";
|
|
125
125
|
Browsers["SamsungInternet"] = "SamsungInternet";
|
|
126
126
|
})(Browsers || (Browsers = {}));
|
|
127
|
-
var USER_AGENT
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
var USER_AGENT;
|
|
128
|
+
if (typeof globalThis.navigator.userAgent !== 'undefined')
|
|
129
|
+
USER_AGENT = globalThis.navigator.userAgent;
|
|
130
|
+
else
|
|
131
|
+
USER_AGENT = '';
|
|
132
132
|
var HIGH_ENTROPY_BRAND_NAME_MAP = {
|
|
133
133
|
'Google Chrome': 'Chrome',
|
|
134
134
|
'Microsoft Edge': 'Edge',
|
|
@@ -829,6 +829,8 @@ function createSubscriptionManager(attach, detach) {
|
|
|
829
829
|
},
|
|
830
830
|
subscribe: function (listener, options) {
|
|
831
831
|
if (options === void 0) { options = {}; }
|
|
832
|
+
if (typeof options.signal !== 'undefined' && options.signal.aborted)
|
|
833
|
+
return function () { };
|
|
832
834
|
var entry = { fn: listener, once: false };
|
|
833
835
|
if (typeof options.once !== 'undefined')
|
|
834
836
|
entry.once = options.once;
|
|
@@ -847,12 +849,8 @@ function createSubscriptionManager(attach, detach) {
|
|
|
847
849
|
EventListener.remove(entry.signal, { type: 'abort', callback: cleanup });
|
|
848
850
|
removeEntry(entry);
|
|
849
851
|
};
|
|
850
|
-
if (typeof entry.signal !== 'undefined')
|
|
851
|
-
|
|
852
|
-
removeEntry(entry);
|
|
853
|
-
else
|
|
854
|
-
EventListener.add(entry.signal, { type: 'abort', callback: cleanup });
|
|
855
|
-
}
|
|
852
|
+
if (typeof entry.signal !== 'undefined')
|
|
853
|
+
EventListener.add(entry.signal, { type: 'abort', callback: cleanup });
|
|
856
854
|
return function unsubscribe() {
|
|
857
855
|
removeEntry(entry);
|
|
858
856
|
};
|
|
@@ -886,9 +884,9 @@ function getAppearanceFromEngine() {
|
|
|
886
884
|
return Appearances.Light;
|
|
887
885
|
}
|
|
888
886
|
function getAppearanceFromMediaQuery() {
|
|
889
|
-
if (
|
|
887
|
+
if (PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST.media === 'not all')
|
|
890
888
|
return Appearances.Unknown;
|
|
891
|
-
if (
|
|
889
|
+
if (PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST.matches)
|
|
892
890
|
return Appearances.Dark;
|
|
893
891
|
return Appearances.Light;
|
|
894
892
|
}
|
|
@@ -916,13 +914,13 @@ function stopPolling() {
|
|
|
916
914
|
}
|
|
917
915
|
function attachOnChange$5() {
|
|
918
916
|
appearanceRef = getAppearanceFromMediaQuery();
|
|
919
|
-
EventListener.add(
|
|
917
|
+
EventListener.add(PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST, { type: 'change', callback: onMediaChange });
|
|
920
918
|
if (Platform.browser.name === Browsers.SamsungInternet)
|
|
921
919
|
startPolling();
|
|
922
920
|
}
|
|
923
921
|
function detachOnChange$5() {
|
|
924
922
|
appearanceRef = null;
|
|
925
|
-
EventListener.remove(
|
|
923
|
+
EventListener.remove(PREFERS_COLOR_SCHEME_MEDIA_QUERY_LIST, { type: 'change', callback: onMediaChange });
|
|
926
924
|
if (Platform.browser.name === Browsers.SamsungInternet)
|
|
927
925
|
stopPolling();
|
|
928
926
|
}
|
|
@@ -1390,19 +1388,16 @@ var ENV_PRESETS = {
|
|
|
1390
1388
|
left: 'viewport-segment-left',
|
|
1391
1389
|
},
|
|
1392
1390
|
};
|
|
1393
|
-
var
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
orientation: Orientation.Unknown,
|
|
1400
|
-
};
|
|
1401
|
-
var MEDIA_QUERY_LIST;
|
|
1391
|
+
var ORIENTATION_MEDIA_QUERY_LIST;
|
|
1392
|
+
if (typeof globalThis.matchMedia !== 'undefined')
|
|
1393
|
+
ORIENTATION_MEDIA_QUERY_LIST = globalThis.matchMedia('(orientation: portrait)');
|
|
1394
|
+
else
|
|
1395
|
+
ORIENTATION_MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
|
|
1396
|
+
var DEVICE_POSTURE_MEDIA_QUERY_LIST;
|
|
1402
1397
|
if (typeof globalThis.matchMedia !== 'undefined')
|
|
1403
|
-
|
|
1398
|
+
DEVICE_POSTURE_MEDIA_QUERY_LIST = globalThis.matchMedia('(device-posture: folded)');
|
|
1404
1399
|
else
|
|
1405
|
-
|
|
1400
|
+
DEVICE_POSTURE_MEDIA_QUERY_LIST = FALLBACK_MEDIA_QUERY_LIST;
|
|
1406
1401
|
|
|
1407
1402
|
function keys(object) {
|
|
1408
1403
|
var keys = [];
|
|
@@ -1424,15 +1419,306 @@ function defer(task) {
|
|
|
1424
1419
|
globalThis.setTimeout(task, 0);
|
|
1425
1420
|
}
|
|
1426
1421
|
|
|
1422
|
+
var MAX_SEGMENTS_PER_AXIS = 4;
|
|
1427
1423
|
function noop() {
|
|
1428
1424
|
}
|
|
1425
|
+
function getSupportedEnvironment() {
|
|
1426
|
+
if (typeof globalThis.CSS !== 'undefined' && typeof globalThis.CSS.supports === 'function') {
|
|
1427
|
+
if (globalThis.CSS.supports('x: env(x)'))
|
|
1428
|
+
return 'env';
|
|
1429
|
+
if (globalThis.CSS.supports('x: constant(x)'))
|
|
1430
|
+
return 'constant';
|
|
1431
|
+
}
|
|
1432
|
+
return undefined;
|
|
1433
|
+
}
|
|
1434
|
+
function getSegmentGrid() {
|
|
1435
|
+
if (typeof globalThis.matchMedia !== 'function')
|
|
1436
|
+
return { rows: 1, cols: 1 };
|
|
1437
|
+
var cols = 1;
|
|
1438
|
+
var rows = 1;
|
|
1439
|
+
for (var i = MAX_SEGMENTS_PER_AXIS; i >= 2; i--) {
|
|
1440
|
+
if (globalThis.matchMedia('(horizontal-viewport-segments: ' + i + ')').matches) {
|
|
1441
|
+
cols = i;
|
|
1442
|
+
break;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
for (var i = MAX_SEGMENTS_PER_AXIS; i >= 2; i--) {
|
|
1446
|
+
if (globalThis.matchMedia('(vertical-viewport-segments: ' + i + ')').matches) {
|
|
1447
|
+
rows = i;
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
return { rows: rows, cols: cols };
|
|
1452
|
+
}
|
|
1453
|
+
function buildSegmentMediaQueryLists() {
|
|
1454
|
+
if (typeof globalThis.matchMedia !== 'function')
|
|
1455
|
+
return [];
|
|
1456
|
+
var mediaQueryLists = [];
|
|
1457
|
+
for (var i = 2; i <= MAX_SEGMENTS_PER_AXIS; i++) {
|
|
1458
|
+
mediaQueryLists.push(globalThis.matchMedia('(horizontal-viewport-segments: ' + i + ')'));
|
|
1459
|
+
mediaQueryLists.push(globalThis.matchMedia('(vertical-viewport-segments: ' + i + ')'));
|
|
1460
|
+
}
|
|
1461
|
+
return mediaQueryLists;
|
|
1462
|
+
}
|
|
1463
|
+
function createViewportSegmentObserver() {
|
|
1464
|
+
var viewport = globalThis.viewport;
|
|
1465
|
+
var visualViewport = globalThis.visualViewport;
|
|
1466
|
+
var devicePosture = globalThis.navigator.devicePosture;
|
|
1467
|
+
var hasSegmentsAPI = typeof viewport !== 'undefined';
|
|
1468
|
+
var hasLegacySegmentsAPI = !hasSegmentsAPI && typeof visualViewport !== 'undefined' && visualViewport !== null && typeof visualViewport.segments !== 'undefined';
|
|
1469
|
+
var hasDevicePosture = typeof devicePosture !== 'undefined';
|
|
1470
|
+
var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
|
|
1471
|
+
var support = getSupportedEnvironment();
|
|
1472
|
+
var cachedDiv = null;
|
|
1473
|
+
var segmentMediaQueryLists = [];
|
|
1474
|
+
var previousSegments = null;
|
|
1475
|
+
function attachCSSFallbackListeners() {
|
|
1476
|
+
EventListener.add(globalThis, { type: 'resize', callback: onSegmentChange });
|
|
1477
|
+
segmentMediaQueryLists = buildSegmentMediaQueryLists();
|
|
1478
|
+
for (var i = 0; i < segmentMediaQueryLists.length; i++)
|
|
1479
|
+
EventListener.add(segmentMediaQueryLists[i], { type: 'change', callback: onSegmentChange });
|
|
1480
|
+
if (DEVICE_POSTURE_MEDIA_QUERY_LIST.media !== 'not all')
|
|
1481
|
+
EventListener.add(DEVICE_POSTURE_MEDIA_QUERY_LIST, { type: 'change', callback: onSegmentChange });
|
|
1482
|
+
}
|
|
1483
|
+
function detachCSSFallbackListeners() {
|
|
1484
|
+
EventListener.remove(globalThis, { type: 'resize', callback: onSegmentChange });
|
|
1485
|
+
for (var i = 0; i < segmentMediaQueryLists.length; i++)
|
|
1486
|
+
EventListener.remove(segmentMediaQueryLists[i], { type: 'change', callback: onSegmentChange });
|
|
1487
|
+
segmentMediaQueryLists = [];
|
|
1488
|
+
if (DEVICE_POSTURE_MEDIA_QUERY_LIST.media !== 'not all')
|
|
1489
|
+
EventListener.remove(DEVICE_POSTURE_MEDIA_QUERY_LIST, { type: 'change', callback: onSegmentChange });
|
|
1490
|
+
}
|
|
1491
|
+
function attachOnChange() {
|
|
1492
|
+
if (hasSegmentsAPI) {
|
|
1493
|
+
if (hasDevicePosture) {
|
|
1494
|
+
EventListener.add(devicePosture, { type: 'change', callback: onSegmentChange });
|
|
1495
|
+
EventListener.add(globalThis, { type: 'resize', callback: onSegmentChange });
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
attachCSSFallbackListeners();
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
else if (hasLegacySegmentsAPI) {
|
|
1502
|
+
EventListener.add(visualViewport, { type: 'resize', callback: onSegmentChange, options: { passive: true } });
|
|
1503
|
+
if (hasSegmentsAPI)
|
|
1504
|
+
EventListener.add(devicePosture, { type: 'change', callback: onSegmentChange });
|
|
1505
|
+
}
|
|
1506
|
+
else {
|
|
1507
|
+
getOrCreateCachedDiv();
|
|
1508
|
+
attachCSSFallbackListeners();
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
function detachOnChange() {
|
|
1512
|
+
if (hasSegmentsAPI) {
|
|
1513
|
+
if (hasDevicePosture) {
|
|
1514
|
+
EventListener.remove(devicePosture, { type: 'change', callback: onSegmentChange });
|
|
1515
|
+
EventListener.remove(globalThis, { type: 'resize', callback: onSegmentChange });
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
detachCSSFallbackListeners();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
else if (hasLegacySegmentsAPI) {
|
|
1522
|
+
EventListener.remove(visualViewport, { type: 'resize', callback: onSegmentChange, options: { passive: true } });
|
|
1523
|
+
if (hasSegmentsAPI)
|
|
1524
|
+
EventListener.remove(devicePosture, { type: 'change', callback: onSegmentChange });
|
|
1525
|
+
}
|
|
1526
|
+
else {
|
|
1527
|
+
detachCSSFallbackListeners();
|
|
1528
|
+
releaseDiv();
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
function segmentsEqual(segments1, segments2) {
|
|
1532
|
+
if (segments1.length !== segments2.length)
|
|
1533
|
+
return false;
|
|
1534
|
+
for (var i = 0; i < segments1.length; i++) {
|
|
1535
|
+
var segment1 = segments1[i];
|
|
1536
|
+
var segment2 = segments2[i];
|
|
1537
|
+
if (segment1.width !== segment2.width || segment1.height !== segment2.height || segment1.top !== segment2.top || segment1.left !== segment2.left || segment1.bottom !== segment2.bottom || segment1.right !== segment2.right)
|
|
1538
|
+
return false;
|
|
1539
|
+
}
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
function onSegmentChange() {
|
|
1543
|
+
var next = getValue();
|
|
1544
|
+
if (previousSegments !== null && segmentsEqual(previousSegments, next))
|
|
1545
|
+
return;
|
|
1546
|
+
previousSegments = next;
|
|
1547
|
+
onChangeSubscriptionManager.emit(next);
|
|
1548
|
+
}
|
|
1549
|
+
function buildDiv() {
|
|
1550
|
+
var div = createHiddenElement('div');
|
|
1551
|
+
div.setAttribute('data-viewport-segment-observer', '');
|
|
1552
|
+
div.style.setProperty('position', 'fixed', 'important');
|
|
1553
|
+
div.style.setProperty('top', '0', 'important');
|
|
1554
|
+
div.style.setProperty('left', '0', 'important');
|
|
1555
|
+
div.style.setProperty('visibility', 'hidden', 'important');
|
|
1556
|
+
div.style.setProperty('pointer-events', 'none', 'important');
|
|
1557
|
+
div.style.setProperty('z-index', '-1', 'important');
|
|
1558
|
+
div.style.setProperty('box-sizing', 'content-box', 'important');
|
|
1559
|
+
div.style.setProperty('padding', '0', 'important');
|
|
1560
|
+
div.style.setProperty('margin', '0', 'important');
|
|
1561
|
+
div.style.setProperty('border', '0', 'important');
|
|
1562
|
+
div.style.setProperty('width', '0', 'important');
|
|
1563
|
+
div.style.setProperty('height', '0', 'important');
|
|
1564
|
+
div.style.setProperty('min-width', '0', 'important');
|
|
1565
|
+
div.style.setProperty('min-height', '0', 'important');
|
|
1566
|
+
div.style.setProperty('max-width', 'none', 'important');
|
|
1567
|
+
div.style.setProperty('max-height', 'none', 'important');
|
|
1568
|
+
div.style.setProperty('transition', 'none', 'important');
|
|
1569
|
+
div.style.setProperty('animation', 'none', 'important');
|
|
1570
|
+
div.style.setProperty('display', 'block', 'important');
|
|
1571
|
+
div.style.setProperty('float', 'none', 'important');
|
|
1572
|
+
div.style.setProperty('transform', 'none', 'important');
|
|
1573
|
+
return div;
|
|
1574
|
+
}
|
|
1575
|
+
function getOrCreateCachedDiv() {
|
|
1576
|
+
if (cachedDiv !== null)
|
|
1577
|
+
return cachedDiv;
|
|
1578
|
+
cachedDiv = buildDiv();
|
|
1579
|
+
globalThis.document.body.appendChild(cachedDiv);
|
|
1580
|
+
return cachedDiv;
|
|
1581
|
+
}
|
|
1582
|
+
function releaseDiv() {
|
|
1583
|
+
if (cachedDiv !== null) {
|
|
1584
|
+
if (cachedDiv.parentNode !== null)
|
|
1585
|
+
cachedDiv.parentNode.removeChild(cachedDiv);
|
|
1586
|
+
cachedDiv = null;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
function readFromSegmentsAPI() {
|
|
1590
|
+
var segments;
|
|
1591
|
+
if (hasSegmentsAPI)
|
|
1592
|
+
segments = viewport.segments;
|
|
1593
|
+
else
|
|
1594
|
+
segments = visualViewport.segments;
|
|
1595
|
+
if (segments === null || typeof segments === 'undefined')
|
|
1596
|
+
return [];
|
|
1597
|
+
var results = [];
|
|
1598
|
+
for (var i = 0; i < segments.length; i++) {
|
|
1599
|
+
var segment = segments[i];
|
|
1600
|
+
results.push({
|
|
1601
|
+
width: segment.width,
|
|
1602
|
+
height: segment.height,
|
|
1603
|
+
top: segment.top,
|
|
1604
|
+
left: segment.left,
|
|
1605
|
+
bottom: segment.bottom,
|
|
1606
|
+
right: segment.right,
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
return results;
|
|
1610
|
+
}
|
|
1611
|
+
function buildFullViewportSegment() {
|
|
1612
|
+
var width = globalThis.innerWidth;
|
|
1613
|
+
var height = globalThis.innerHeight;
|
|
1614
|
+
return {
|
|
1615
|
+
width: width,
|
|
1616
|
+
height: height,
|
|
1617
|
+
top: 0,
|
|
1618
|
+
left: 0,
|
|
1619
|
+
bottom: height,
|
|
1620
|
+
right: width,
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
function readFromCSSEnv(div) {
|
|
1624
|
+
var grid = getSegmentGrid();
|
|
1625
|
+
if (grid.rows === 1 && grid.cols === 1)
|
|
1626
|
+
return [buildFullViewportSegment()];
|
|
1627
|
+
if (typeof support === 'undefined' || typeof div.style.setProperty === 'undefined')
|
|
1628
|
+
return [buildFullViewportSegment()];
|
|
1629
|
+
var results = [];
|
|
1630
|
+
for (var row = 0; row < grid.rows; row++) {
|
|
1631
|
+
for (var col = 0; col < grid.cols; col++) {
|
|
1632
|
+
div.style.setProperty('width', support + '(viewport-segment-width ' + row + ' ' + col + ', -1px)', 'important');
|
|
1633
|
+
div.style.setProperty('height', support + '(viewport-segment-height ' + row + ' ' + col + ', -1px)', 'important');
|
|
1634
|
+
div.style.setProperty('margin-top', support + '(viewport-segment-top ' + row + ' ' + col + ', -1px)', 'important');
|
|
1635
|
+
div.style.setProperty('margin-left', support + '(viewport-segment-left ' + row + ' ' + col + ', -1px)', 'important');
|
|
1636
|
+
div.style.setProperty('margin-bottom', support + '(viewport-segment-bottom ' + row + ' ' + col + ', -1px)', 'important');
|
|
1637
|
+
div.style.setProperty('margin-right', support + '(viewport-segment-right ' + row + ' ' + col + ', -1px)', 'important');
|
|
1638
|
+
var computed = globalThis.getComputedStyle(div);
|
|
1639
|
+
var top_1 = globalThis.parseFloat(computed.marginTop);
|
|
1640
|
+
if (top_1 < 0)
|
|
1641
|
+
continue;
|
|
1642
|
+
var left = globalThis.parseFloat(computed.marginLeft);
|
|
1643
|
+
var bottom = globalThis.parseFloat(computed.marginBottom);
|
|
1644
|
+
var right = globalThis.parseFloat(computed.marginRight);
|
|
1645
|
+
var width = globalThis.parseFloat(computed.width);
|
|
1646
|
+
var height = globalThis.parseFloat(computed.height);
|
|
1647
|
+
results.push({
|
|
1648
|
+
width: width,
|
|
1649
|
+
height: height,
|
|
1650
|
+
top: top_1,
|
|
1651
|
+
left: left,
|
|
1652
|
+
bottom: bottom,
|
|
1653
|
+
right: right,
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
return results;
|
|
1658
|
+
}
|
|
1659
|
+
function getValue() {
|
|
1660
|
+
if (hasSegmentsAPI || hasLegacySegmentsAPI)
|
|
1661
|
+
return readFromSegmentsAPI();
|
|
1662
|
+
if (cachedDiv !== null)
|
|
1663
|
+
return readFromCSSEnv(cachedDiv);
|
|
1664
|
+
var div = buildDiv();
|
|
1665
|
+
globalThis.document.body.appendChild(div);
|
|
1666
|
+
var results = readFromCSSEnv(div);
|
|
1667
|
+
globalThis.document.body.removeChild(div);
|
|
1668
|
+
return results;
|
|
1669
|
+
}
|
|
1670
|
+
function useCssVariable(prefix) {
|
|
1671
|
+
if (typeof globalThis.document === 'undefined')
|
|
1672
|
+
return noop;
|
|
1673
|
+
var attributes = keys(ENV_PRESETS['viewport-segment']);
|
|
1674
|
+
var element = globalThis.document.documentElement;
|
|
1675
|
+
var lastCount = 0;
|
|
1676
|
+
function applySegments(segments) {
|
|
1677
|
+
for (var i = segments.length; i < lastCount; i++) {
|
|
1678
|
+
for (var j = 0; j < attributes.length; j++) {
|
|
1679
|
+
element.style.removeProperty("--".concat(prefix, "-").concat(i, "-").concat(attributes[j]));
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
lastCount = segments.length;
|
|
1683
|
+
for (var i = 0; i < segments.length; i++) {
|
|
1684
|
+
var segment = segments[i];
|
|
1685
|
+
for (var j = 0; j < attributes.length; j++) {
|
|
1686
|
+
var attribute = attributes[j];
|
|
1687
|
+
element.style.setProperty("--".concat(prefix, "-").concat(i, "-").concat(attribute), segment[attribute] + 'px');
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
applySegments(getValue());
|
|
1692
|
+
var unsubscribe = onChangeSubscriptionManager.subscribe(function (segments) {
|
|
1693
|
+
applySegments(segments);
|
|
1694
|
+
});
|
|
1695
|
+
return function () {
|
|
1696
|
+
unsubscribe();
|
|
1697
|
+
for (var i = 0; i < lastCount; i++)
|
|
1698
|
+
for (var j = 0; j < attributes.length; j++)
|
|
1699
|
+
element.style.removeProperty("--".concat(prefix, "-").concat(i, "-").concat(attributes[j]));
|
|
1700
|
+
lastCount = 0;
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
return {
|
|
1704
|
+
get value() {
|
|
1705
|
+
return getValue();
|
|
1706
|
+
},
|
|
1707
|
+
onChange: onChangeSubscriptionManager.subscribe,
|
|
1708
|
+
useCssVariable: useCssVariable,
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1429
1711
|
function createVirtualKeyboardObserver() {
|
|
1430
1712
|
var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
|
|
1713
|
+
var previousOverlaysContent = false;
|
|
1431
1714
|
function attachOnChange() {
|
|
1715
|
+
previousOverlaysContent = globalThis.navigator.virtualKeyboard.overlaysContent;
|
|
1716
|
+
globalThis.navigator.virtualKeyboard.overlaysContent = true;
|
|
1432
1717
|
EventListener.add(globalThis.navigator.virtualKeyboard, { type: 'geometrychange', callback: onGeometryChange, options: { passive: true } });
|
|
1433
1718
|
}
|
|
1434
1719
|
function detachOnChange() {
|
|
1435
1720
|
EventListener.remove(globalThis.navigator.virtualKeyboard, { type: 'geometrychange', callback: onGeometryChange, options: { passive: true } });
|
|
1721
|
+
globalThis.navigator.virtualKeyboard.overlaysContent = previousOverlaysContent;
|
|
1436
1722
|
}
|
|
1437
1723
|
function onGeometryChange() {
|
|
1438
1724
|
onChangeSubscriptionManager.emit(getValue());
|
|
@@ -1443,16 +1729,16 @@ function createVirtualKeyboardObserver() {
|
|
|
1443
1729
|
var top = rect.y;
|
|
1444
1730
|
var width = rect.width;
|
|
1445
1731
|
var height = rect.height;
|
|
1446
|
-
var right
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
var bottom
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1732
|
+
var right;
|
|
1733
|
+
if (width === 0)
|
|
1734
|
+
right = 0;
|
|
1735
|
+
else
|
|
1736
|
+
right = Math.max(0, globalThis.innerWidth - (left + width));
|
|
1737
|
+
var bottom;
|
|
1738
|
+
if (height === 0)
|
|
1739
|
+
bottom = 0;
|
|
1740
|
+
else
|
|
1741
|
+
bottom = Math.max(0, globalThis.innerHeight - (top + height));
|
|
1456
1742
|
return {
|
|
1457
1743
|
top: top,
|
|
1458
1744
|
right: right,
|
|
@@ -1462,17 +1748,43 @@ function createVirtualKeyboardObserver() {
|
|
|
1462
1748
|
height: height,
|
|
1463
1749
|
};
|
|
1464
1750
|
}
|
|
1751
|
+
function useCssVariable(prefix) {
|
|
1752
|
+
if (typeof globalThis.document === 'undefined')
|
|
1753
|
+
return noop;
|
|
1754
|
+
var attributes = keys(ENV_PRESETS['keyboard-inset']);
|
|
1755
|
+
var element = globalThis.document.documentElement;
|
|
1756
|
+
function applyValues(values) {
|
|
1757
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
1758
|
+
var attribute = attributes[i];
|
|
1759
|
+
element.style.setProperty("--".concat(prefix, "-").concat(attribute), values[attribute] + 'px');
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
applyValues(getValue());
|
|
1763
|
+
var unsubscribe = onChangeSubscriptionManager.subscribe(function (values) {
|
|
1764
|
+
applyValues(values);
|
|
1765
|
+
});
|
|
1766
|
+
return function () {
|
|
1767
|
+
unsubscribe();
|
|
1768
|
+
for (var i = 0; i < attributes.length; i++)
|
|
1769
|
+
element.style.removeProperty("--".concat(prefix, "-").concat(attributes[i]));
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1465
1772
|
return {
|
|
1466
|
-
get
|
|
1773
|
+
get value() {
|
|
1774
|
+
return getValue();
|
|
1775
|
+
},
|
|
1467
1776
|
onChange: onChangeSubscriptionManager.subscribe,
|
|
1777
|
+
useCssVariable: useCssVariable,
|
|
1468
1778
|
};
|
|
1469
1779
|
}
|
|
1470
|
-
function
|
|
1780
|
+
function createEnvironmentObserver(preset) {
|
|
1471
1781
|
if (preset === 'keyboard-inset' && typeof globalThis.navigator.virtualKeyboard !== 'undefined')
|
|
1472
1782
|
return createVirtualKeyboardObserver();
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
var
|
|
1783
|
+
if (preset === 'viewport-segment')
|
|
1784
|
+
return createViewportSegmentObserver();
|
|
1785
|
+
var environmentMap = ENV_PRESETS[preset];
|
|
1786
|
+
var attributes = keys(environmentMap);
|
|
1787
|
+
var support = getSupportedEnvironment();
|
|
1476
1788
|
var parentReadyCallbacks = [];
|
|
1477
1789
|
var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
|
|
1478
1790
|
var elementComputedStyle = {};
|
|
@@ -1489,15 +1801,6 @@ function createEnvObserver(preset) {
|
|
|
1489
1801
|
function detachOnChange() {
|
|
1490
1802
|
removeDetector();
|
|
1491
1803
|
}
|
|
1492
|
-
function getSupportedEnv() {
|
|
1493
|
-
if (typeof globalThis.CSS !== 'undefined' && typeof globalThis.CSS.supports === 'function') {
|
|
1494
|
-
if (globalThis.CSS.supports('x: env(x)'))
|
|
1495
|
-
return 'env';
|
|
1496
|
-
if (globalThis.CSS.supports('x: constant(x)'))
|
|
1497
|
-
return 'constant';
|
|
1498
|
-
}
|
|
1499
|
-
return undefined;
|
|
1500
|
-
}
|
|
1501
1804
|
function isSameValues(a, b) {
|
|
1502
1805
|
for (var i = 0; i < attributes.length; i++) {
|
|
1503
1806
|
var key = attributes[i];
|
|
@@ -1537,7 +1840,7 @@ function createEnvObserver(preset) {
|
|
|
1537
1840
|
parentReadyCallbacks[i]();
|
|
1538
1841
|
}
|
|
1539
1842
|
function addChild(parent, attribute) {
|
|
1540
|
-
var envVar =
|
|
1843
|
+
var envVar = environmentMap[attribute];
|
|
1541
1844
|
var p1 = globalThis.document.createElement('div');
|
|
1542
1845
|
var p2 = globalThis.document.createElement('div');
|
|
1543
1846
|
var c1 = globalThis.document.createElement('div');
|
|
@@ -1600,9 +1903,8 @@ function createEnvObserver(preset) {
|
|
|
1600
1903
|
}
|
|
1601
1904
|
function init() {
|
|
1602
1905
|
if (typeof support === 'undefined') {
|
|
1603
|
-
for (var i = 0; i < attributes.length; i++)
|
|
1906
|
+
for (var i = 0; i < attributes.length; i++)
|
|
1604
1907
|
elementComputedStyle[attributes[i]] = 0;
|
|
1605
|
-
}
|
|
1606
1908
|
return;
|
|
1607
1909
|
}
|
|
1608
1910
|
elementComputedStyle = {};
|
|
@@ -1646,8 +1948,28 @@ function createEnvObserver(preset) {
|
|
|
1646
1948
|
}
|
|
1647
1949
|
return result;
|
|
1648
1950
|
}
|
|
1951
|
+
function useCssVariable(prefix) {
|
|
1952
|
+
if (typeof support === 'undefined' || typeof globalThis.document === 'undefined')
|
|
1953
|
+
return noop;
|
|
1954
|
+
var element = globalThis.document.documentElement;
|
|
1955
|
+
function applyValues(values) {
|
|
1956
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
1957
|
+
var attribute = attributes[i];
|
|
1958
|
+
element.style.setProperty("--".concat(prefix, "-").concat(String(attribute)), values[attribute] + 'px');
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
var unsubscribe = onChangeSubscriptionManager.subscribe(function (values) {
|
|
1962
|
+
applyValues(values);
|
|
1963
|
+
});
|
|
1964
|
+
applyValues(readValues());
|
|
1965
|
+
return function () {
|
|
1966
|
+
unsubscribe();
|
|
1967
|
+
for (var i = 0; i < attributes.length; i++)
|
|
1968
|
+
element.style.removeProperty("--".concat(prefix, "-").concat(String(attributes[i])));
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1649
1971
|
return {
|
|
1650
|
-
get
|
|
1972
|
+
get value() {
|
|
1651
1973
|
if (parentDiv !== null)
|
|
1652
1974
|
return readValues();
|
|
1653
1975
|
init();
|
|
@@ -1660,15 +1982,16 @@ function createEnvObserver(preset) {
|
|
|
1660
1982
|
if (typeof support === 'undefined')
|
|
1661
1983
|
return noop;
|
|
1662
1984
|
return onChangeSubscriptionManager.subscribe(callback, options);
|
|
1663
|
-
}
|
|
1985
|
+
},
|
|
1986
|
+
useCssVariable: useCssVariable
|
|
1664
1987
|
};
|
|
1665
1988
|
}
|
|
1666
1989
|
|
|
1667
|
-
var safeAreaInsetObserver =
|
|
1668
|
-
var safeAreaMaxInsetObserver =
|
|
1669
|
-
var keyboardInsetObserver =
|
|
1670
|
-
var titlebarAreaObserver =
|
|
1671
|
-
var viewportSegmentObserver =
|
|
1990
|
+
var safeAreaInsetObserver = createEnvironmentObserver('safe-area-inset');
|
|
1991
|
+
var safeAreaMaxInsetObserver = createEnvironmentObserver('safe-area-max-inset');
|
|
1992
|
+
var keyboardInsetObserver = createEnvironmentObserver('keyboard-inset');
|
|
1993
|
+
var titlebarAreaObserver = createEnvironmentObserver('titlebar-area');
|
|
1994
|
+
var viewportSegmentObserver = createEnvironmentObserver('viewport-segment');
|
|
1672
1995
|
var onChangeSubscriptionManager$4 = createSubscriptionManager(attachOnChange$4, detachOnChange$4);
|
|
1673
1996
|
var dimensionRef = null;
|
|
1674
1997
|
var Dimension = {
|
|
@@ -1703,9 +2026,9 @@ function getOrientation() {
|
|
|
1703
2026
|
return Orientation.Landscape;
|
|
1704
2027
|
}
|
|
1705
2028
|
}
|
|
1706
|
-
if (
|
|
2029
|
+
if (ORIENTATION_MEDIA_QUERY_LIST.media === 'not all')
|
|
1707
2030
|
return Orientation.Unknown;
|
|
1708
|
-
else if (
|
|
2031
|
+
else if (ORIENTATION_MEDIA_QUERY_LIST.matches)
|
|
1709
2032
|
return Orientation.Portrait;
|
|
1710
2033
|
else
|
|
1711
2034
|
return Orientation.Landscape;
|
|
@@ -1717,50 +2040,29 @@ function getScale() {
|
|
|
1717
2040
|
}
|
|
1718
2041
|
function getEnvironment() {
|
|
1719
2042
|
return {
|
|
1720
|
-
safeAreaInset:
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
},
|
|
1726
|
-
safeAreaMaxInset: {
|
|
1727
|
-
get value() {
|
|
1728
|
-
return safeAreaMaxInsetObserver.get();
|
|
1729
|
-
},
|
|
1730
|
-
onChange: safeAreaMaxInsetObserver.onChange,
|
|
1731
|
-
},
|
|
1732
|
-
keyboardInset: {
|
|
1733
|
-
get value() {
|
|
1734
|
-
return keyboardInsetObserver.get();
|
|
1735
|
-
},
|
|
1736
|
-
onChange: keyboardInsetObserver.onChange,
|
|
1737
|
-
},
|
|
1738
|
-
titlebarArea: {
|
|
1739
|
-
get value() {
|
|
1740
|
-
return titlebarAreaObserver.get();
|
|
1741
|
-
},
|
|
1742
|
-
onChange: titlebarAreaObserver.onChange,
|
|
1743
|
-
},
|
|
1744
|
-
viewportSegment: {
|
|
1745
|
-
get value() {
|
|
1746
|
-
return viewportSegmentObserver.get();
|
|
1747
|
-
},
|
|
1748
|
-
onChange: viewportSegmentObserver.onChange,
|
|
1749
|
-
},
|
|
2043
|
+
safeAreaInset: safeAreaInsetObserver,
|
|
2044
|
+
safeAreaMaxInset: safeAreaMaxInsetObserver,
|
|
2045
|
+
keyboardInset: keyboardInsetObserver,
|
|
2046
|
+
titlebarArea: titlebarAreaObserver,
|
|
2047
|
+
viewportSegment: viewportSegmentObserver,
|
|
1750
2048
|
};
|
|
1751
2049
|
}
|
|
1752
2050
|
function getDimension() {
|
|
2051
|
+
var dimensions = {
|
|
2052
|
+
innerWidth: 0,
|
|
2053
|
+
innerHeight: 0,
|
|
2054
|
+
outerWidth: 0,
|
|
2055
|
+
outerHeight: 0,
|
|
2056
|
+
scale: getScale(),
|
|
2057
|
+
orientation: getOrientation(),
|
|
2058
|
+
};
|
|
1753
2059
|
if (typeof globalThis.innerWidth !== 'undefined') {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
outerHeight: globalThis.outerHeight,
|
|
1759
|
-
scale: getScale(),
|
|
1760
|
-
orientation: getOrientation(),
|
|
1761
|
-
};
|
|
2060
|
+
dimensions.innerWidth = globalThis.innerWidth;
|
|
2061
|
+
dimensions.innerHeight = globalThis.innerHeight;
|
|
2062
|
+
dimensions.outerWidth = globalThis.outerWidth;
|
|
2063
|
+
dimensions.outerHeight = globalThis.outerHeight;
|
|
1762
2064
|
}
|
|
1763
|
-
return
|
|
2065
|
+
return dimensions;
|
|
1764
2066
|
}
|
|
1765
2067
|
function attachOnChange$4() {
|
|
1766
2068
|
dimensionRef = getDimension();
|
|
@@ -1769,8 +2071,8 @@ function attachOnChange$4() {
|
|
|
1769
2071
|
EventListener.add(globalThis.screen.orientation, { type: 'change', callback: onResize });
|
|
1770
2072
|
else if (typeof globalThis.orientation !== 'undefined')
|
|
1771
2073
|
EventListener.add(globalThis, { type: 'orientationChange', callback: onResize });
|
|
1772
|
-
else if (
|
|
1773
|
-
EventListener.add(
|
|
2074
|
+
else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
|
|
2075
|
+
EventListener.add(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
|
|
1774
2076
|
}
|
|
1775
2077
|
function detachOnChange$4() {
|
|
1776
2078
|
dimensionRef = null;
|
|
@@ -1779,8 +2081,8 @@ function detachOnChange$4() {
|
|
|
1779
2081
|
EventListener.remove(globalThis.screen.orientation, { type: 'change', callback: onResize });
|
|
1780
2082
|
else if (typeof globalThis.orientation !== 'undefined')
|
|
1781
2083
|
EventListener.remove(globalThis, { type: 'orientationChange', callback: onResize });
|
|
1782
|
-
else if (
|
|
1783
|
-
EventListener.remove(
|
|
2084
|
+
else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
|
|
2085
|
+
EventListener.remove(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onResize });
|
|
1784
2086
|
}
|
|
1785
2087
|
function onResize() {
|
|
1786
2088
|
var dimension = getDimension();
|
|
@@ -2714,7 +3016,7 @@ function getTopmostWindow() {
|
|
|
2714
3016
|
}
|
|
2715
3017
|
|
|
2716
3018
|
function dispatchClickEvent(element, view) {
|
|
2717
|
-
if (view === void 0) { view =
|
|
3019
|
+
if (view === void 0) { view = globalThis; }
|
|
2718
3020
|
var fake;
|
|
2719
3021
|
try {
|
|
2720
3022
|
fake = new MouseEvent('click', {
|