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