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