@react-x11/components 0.12.0 → 0.13.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/dist/html/controls.d.ts +12 -3
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js +15 -55
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/cascade.d.ts +134 -20
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +519 -122
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/parse.d.ts +29 -2
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +277 -9
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +14 -0
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +2 -3
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.d.ts +11 -1
- package/dist/html/css/ua.d.ts.map +1 -1
- package/dist/html/css/ua.js +59 -7
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/dom.d.ts.map +1 -1
- package/dist/html/dom.js +3 -1
- package/dist/html/dom.js.map +1 -1
- package/dist/html/fonts.d.ts +25 -1
- package/dist/html/fonts.d.ts.map +1 -1
- package/dist/html/fonts.js +99 -6
- package/dist/html/fonts.js.map +1 -1
- package/dist/html/form.d.ts +200 -0
- package/dist/html/form.d.ts.map +1 -0
- package/dist/html/form.js +801 -0
- package/dist/html/form.js.map +1 -0
- package/dist/html/index.d.ts +12 -0
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +30 -301
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +5 -1
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +31 -1
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +52 -8
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/flex.js +4 -1
- package/dist/html/layout/flex.js.map +1 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +10 -0
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/node.d.ts +87 -15
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +510 -152
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +22 -1
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +290 -20
- package/dist/html/paint.js.map +1 -1
- package/dist/html/widgets.d.ts +29 -0
- package/dist/html/widgets.d.ts.map +1 -0
- package/dist/html/widgets.js +620 -0
- package/dist/html/widgets.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/html/controls.ts +29 -49
- package/src/html/css/cascade.ts +591 -140
- package/src/html/css/parse.ts +324 -9
- package/src/html/css/style.ts +24 -3
- package/src/html/css/ua.ts +62 -8
- package/src/html/dom.ts +3 -1
- package/src/html/fonts.ts +116 -6
- package/src/html/form.ts +962 -0
- package/src/html/index.ts +49 -338
- package/src/html/layout/block.ts +3 -0
- package/src/html/layout/boxes.ts +78 -11
- package/src/html/layout/flex.ts +4 -1
- package/src/html/layout/inline.ts +10 -0
- package/src/html/node.ts +498 -135
- package/src/html/paint.ts +330 -29
- package/src/html/widgets.ts +735 -0
- package/src/index.ts +1 -0
package/dist/html/css/parse.js
CHANGED
|
@@ -123,6 +123,13 @@ base = null) {
|
|
|
123
123
|
breakpoints.add(c.min);
|
|
124
124
|
if (c.max !== undefined)
|
|
125
125
|
breakpoints.add(c.max + MAX_EDGE);
|
|
126
|
+
if (c.minHeight !== undefined || c.maxHeight !== undefined) {
|
|
127
|
+
sheet.readsHeight = true;
|
|
128
|
+
}
|
|
129
|
+
if (c.minAspect !== undefined || c.maxAspect !== undefined) {
|
|
130
|
+
sheet.readsHeight = true;
|
|
131
|
+
sheet.readsWidth = true;
|
|
132
|
+
}
|
|
126
133
|
}
|
|
127
134
|
// A nested `@media` intersects with the one above it; pushing a
|
|
128
135
|
// level rather than merging keeps "all of these blocks hold" exact
|
|
@@ -226,6 +233,13 @@ base = null) {
|
|
|
226
233
|
breakpoints.add(c.min);
|
|
227
234
|
if (c.max !== undefined)
|
|
228
235
|
breakpoints.add(c.max + MAX_EDGE);
|
|
236
|
+
if (c.minHeight !== undefined || c.maxHeight !== undefined) {
|
|
237
|
+
sheet.readsHeight = true;
|
|
238
|
+
}
|
|
239
|
+
if (c.minAspect !== undefined || c.maxAspect !== undefined) {
|
|
240
|
+
sheet.readsHeight = true;
|
|
241
|
+
sheet.readsWidth = true;
|
|
242
|
+
}
|
|
229
243
|
}
|
|
230
244
|
styleRule(selectors, item.block, media ? [...media, conditions] : [conditions], layer, path, depth + 1);
|
|
231
245
|
}
|
|
@@ -1252,18 +1266,32 @@ function readAtRule(text, at) {
|
|
|
1252
1266
|
* at: a sixty-fourth of a pixel past it, where the widths a display scale
|
|
1253
1267
|
* divides a device width into (`640.5` at 2x) fall on the right side. */
|
|
1254
1268
|
const MAX_EDGE = 1 / 64;
|
|
1269
|
+
/**
|
|
1270
|
+
* The media features that are the viewport's width and its height here.
|
|
1271
|
+
* `device-width` and `device-height` are the Web-exposed screen area's
|
|
1272
|
+
* (Media Queries 4, appendix A), which a user agent may answer with the
|
|
1273
|
+
* viewport's (CSSOM View 2.3), and a document drawn into an element has no
|
|
1274
|
+
* screen of its own to answer with. Deprecated, and still what a page from
|
|
1275
|
+
* before `width` asks with: DuckDuckGo Lite's phone sheet is
|
|
1276
|
+
* `(max-device-width: 700px)`, and a query that went unread held, so a
|
|
1277
|
+
* desktop window got the phone's 12px dropdowns.
|
|
1278
|
+
*/
|
|
1279
|
+
const VIEWPORT_SIDES = {
|
|
1280
|
+
width: new Set(['width', 'device-width']),
|
|
1281
|
+
height: new Set(['height', 'device-height']),
|
|
1282
|
+
};
|
|
1255
1283
|
/**
|
|
1256
1284
|
* A width range in Media Queries 4's syntax — `(width >= 48rem)`, `(60rem >
|
|
1257
1285
|
* width)`, `(40rem <= width < 60rem)` — as the widths it holds between, or
|
|
1258
1286
|
* null for a term that is not one. A strict bound is a sixty-fourth of a
|
|
1259
1287
|
* pixel inside the value, where a viewport's width never lands.
|
|
1260
1288
|
*/
|
|
1261
|
-
function widthRange(term) {
|
|
1289
|
+
function widthRange(term, feature = 'width') {
|
|
1262
1290
|
const inner = /^\(\s*(.*?)\s*\)$/.exec(term)?.[1];
|
|
1263
1291
|
if (!inner || !/[<>=]/.test(inner))
|
|
1264
1292
|
return null;
|
|
1265
1293
|
const parts = inner.split(/\s*(<=|>=|<|>|=)\s*/);
|
|
1266
|
-
const isWidth = (part) => part.toLowerCase()
|
|
1294
|
+
const isWidth = (part) => VIEWPORT_SIDES[feature].has(part.toLowerCase());
|
|
1267
1295
|
const out = {};
|
|
1268
1296
|
// `width OP value`, with the operator read from the width's side
|
|
1269
1297
|
const bound = (op, value) => {
|
|
@@ -1660,8 +1688,15 @@ export function parseMediaQuery(prelude) {
|
|
|
1660
1688
|
const condition = {};
|
|
1661
1689
|
let pass = true;
|
|
1662
1690
|
let sawWidth = false;
|
|
1691
|
+
let sawHeight = false;
|
|
1692
|
+
let sawResolution = false;
|
|
1693
|
+
let sawAspect = false;
|
|
1663
1694
|
const negated = /^\s*not\b/i.test(group);
|
|
1664
|
-
|
|
1695
|
+
// `and` needs white space after it, where a `(` would make it a
|
|
1696
|
+
// function, and none after the `)` it follows: DuckDuckGo writes
|
|
1697
|
+
// `(max-device-width: 701px)and (orientation: landscape)`, which read
|
|
1698
|
+
// as one term that was no feature, and held
|
|
1699
|
+
for (const part of group.split(/(?:\s+|(?<=\)))and\s+/i)) {
|
|
1665
1700
|
const term = part
|
|
1666
1701
|
.trim()
|
|
1667
1702
|
.replace(/^not\s+/i, '')
|
|
@@ -1681,19 +1716,53 @@ export function parseMediaQuery(prelude) {
|
|
|
1681
1716
|
sawWidth = true;
|
|
1682
1717
|
continue;
|
|
1683
1718
|
}
|
|
1719
|
+
const heights = widthRange(term, 'height');
|
|
1720
|
+
if (heights) {
|
|
1721
|
+
if (heights.min !== undefined) {
|
|
1722
|
+
condition.minHeight = Math.max(condition.minHeight ?? 0, heights.min);
|
|
1723
|
+
}
|
|
1724
|
+
if (heights.max !== undefined) {
|
|
1725
|
+
condition.maxHeight = Math.min(condition.maxHeight ?? Infinity, heights.max);
|
|
1726
|
+
}
|
|
1727
|
+
sawHeight = true;
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1684
1730
|
const feature = mediaFeature(term);
|
|
1685
1731
|
if (feature) {
|
|
1686
1732
|
const key = feature[1].toLowerCase();
|
|
1687
1733
|
const len = parseLength(feature[2], ZERO_UNITS);
|
|
1688
1734
|
const px = typeof len === 'number' ? len : null;
|
|
1689
|
-
if (key === 'min-width'
|
|
1735
|
+
if ((key === 'min-width' || key === 'min-device-width') &&
|
|
1736
|
+
px !== null) {
|
|
1690
1737
|
condition.min = Math.max(condition.min ?? 0, px);
|
|
1691
1738
|
sawWidth = true;
|
|
1692
1739
|
}
|
|
1693
|
-
else if (key === 'max-width'
|
|
1740
|
+
else if ((key === 'max-width' || key === 'max-device-width') &&
|
|
1741
|
+
px !== null) {
|
|
1694
1742
|
condition.max = Math.min(condition.max ?? Infinity, px);
|
|
1695
1743
|
sawWidth = true;
|
|
1696
1744
|
}
|
|
1745
|
+
else if (px === null &&
|
|
1746
|
+
/^(?:min-|max-)?(?:device-)?(?:width|height)$/.test(key)) {
|
|
1747
|
+
// a size that is no length is a query that does not parse, which
|
|
1748
|
+
// Media Queries 4 (3.2) makes `not all`: `(min-width:0\0)`, the
|
|
1749
|
+
// hack that kept a block for Internet Explorer 9 and 10, held
|
|
1750
|
+
// here as a query that asked nothing, and its rules applied
|
|
1751
|
+
pass = false;
|
|
1752
|
+
}
|
|
1753
|
+
else if ((key === 'min-height' || key === 'min-device-height') &&
|
|
1754
|
+
px !== null) {
|
|
1755
|
+
// the viewport's height, answered live as its width is: a
|
|
1756
|
+
// design that sets its heading's size by the window's height
|
|
1757
|
+
// took the tallest step's at every height
|
|
1758
|
+
condition.minHeight = Math.max(condition.minHeight ?? 0, px);
|
|
1759
|
+
sawHeight = true;
|
|
1760
|
+
}
|
|
1761
|
+
else if ((key === 'max-height' || key === 'max-device-height') &&
|
|
1762
|
+
px !== null) {
|
|
1763
|
+
condition.maxHeight = Math.min(condition.maxHeight ?? Infinity, px);
|
|
1764
|
+
sawHeight = true;
|
|
1765
|
+
}
|
|
1697
1766
|
else if (key === 'prefers-color-scheme') {
|
|
1698
1767
|
// Answered live, from the palette in force: a document dropped
|
|
1699
1768
|
// into a dark application takes its dark branch, and follows the
|
|
@@ -1716,7 +1785,67 @@ export function parseMediaQuery(prelude) {
|
|
|
1716
1785
|
pass = false;
|
|
1717
1786
|
}
|
|
1718
1787
|
else if (key === 'orientation') {
|
|
1719
|
-
|
|
1788
|
+
// the viewport's, as its aspect ratio: portrait where its height
|
|
1789
|
+
// is at least its width (Media Queries 4, 4.5)
|
|
1790
|
+
const orientation = feature[2].trim().toLowerCase();
|
|
1791
|
+
if (orientation === 'portrait') {
|
|
1792
|
+
condition.maxAspect = Math.min(condition.maxAspect ?? Infinity, 1);
|
|
1793
|
+
sawAspect = true;
|
|
1794
|
+
}
|
|
1795
|
+
else if (orientation === 'landscape') {
|
|
1796
|
+
condition.minAspect = Math.max(condition.minAspect ?? 0, 1 + ASPECT_EDGE);
|
|
1797
|
+
sawAspect = true;
|
|
1798
|
+
}
|
|
1799
|
+
else
|
|
1800
|
+
pass = false;
|
|
1801
|
+
}
|
|
1802
|
+
else if (ASPECT_FEATURES.test(key)) {
|
|
1803
|
+
const ratio = ratioOf(feature[2]);
|
|
1804
|
+
if (ratio === null)
|
|
1805
|
+
pass = false;
|
|
1806
|
+
else {
|
|
1807
|
+
if (!key.startsWith('max-')) {
|
|
1808
|
+
condition.minAspect = Math.max(condition.minAspect ?? 0, ratio);
|
|
1809
|
+
}
|
|
1810
|
+
if (!key.startsWith('min-')) {
|
|
1811
|
+
condition.maxAspect = Math.min(condition.maxAspect ?? Infinity, ratio);
|
|
1812
|
+
}
|
|
1813
|
+
sawAspect = true;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
else if (RESOLUTION_FEATURES.has(key)) {
|
|
1817
|
+
const dppx = resolutionOf(feature[2], key.startsWith('-webkit-'));
|
|
1818
|
+
if (dppx === null)
|
|
1819
|
+
pass = false;
|
|
1820
|
+
else {
|
|
1821
|
+
if (!key.includes('max-')) {
|
|
1822
|
+
condition.minResolution = Math.max(condition.minResolution ?? 0, dppx);
|
|
1823
|
+
}
|
|
1824
|
+
if (!key.includes('min-')) {
|
|
1825
|
+
condition.maxResolution = Math.min(condition.maxResolution ?? Infinity, dppx);
|
|
1826
|
+
}
|
|
1827
|
+
sawResolution = true;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
else if (desktopFeature(key, feature[2]) !== true) {
|
|
1831
|
+
// any other feature as a desktop screen with a mouse answers
|
|
1832
|
+
// it, and one nothing knows is false (Media Queries 4, 3.2):
|
|
1833
|
+
// Firefox's and Opera's resolution features, which a design lists
|
|
1834
|
+
// beside WebKit's, held here, and a page at one dot to the pixel
|
|
1835
|
+
// took the rules it keeps for two
|
|
1836
|
+
pass = false;
|
|
1837
|
+
}
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
const flag = /^\(\s*(-?[a-z][a-z0-9-]*)\s*\)$/i.exec(term);
|
|
1841
|
+
if (flag) {
|
|
1842
|
+
// a feature in the boolean context, `(hover)`: true where its value
|
|
1843
|
+
// is anything but zero or none
|
|
1844
|
+
const key = flag[1].toLowerCase();
|
|
1845
|
+
if (!BOOLEAN_TRUE.has(key) &&
|
|
1846
|
+
!RESOLUTION_FEATURES.has(key) &&
|
|
1847
|
+
desktopFeature(key, null) !== true) {
|
|
1848
|
+
pass = false;
|
|
1720
1849
|
}
|
|
1721
1850
|
continue;
|
|
1722
1851
|
}
|
|
@@ -1734,11 +1863,20 @@ export function parseMediaQuery(prelude) {
|
|
|
1734
1863
|
// `not` over a scheme is the other scheme. `not` over a width range
|
|
1735
1864
|
// is not expressible as one range; the honest reduction is to decide
|
|
1736
1865
|
// it statically rather than invert it wrongly.
|
|
1737
|
-
if (!sawWidth &&
|
|
1866
|
+
if (!sawWidth &&
|
|
1867
|
+
!sawHeight &&
|
|
1868
|
+
!sawResolution &&
|
|
1869
|
+
!sawAspect &&
|
|
1870
|
+
pass &&
|
|
1871
|
+
condition.scheme) {
|
|
1738
1872
|
out.push({ scheme: condition.scheme === 'dark' ? 'light' : 'dark' });
|
|
1739
1873
|
continue;
|
|
1740
1874
|
}
|
|
1741
|
-
out.push({
|
|
1875
|
+
out.push({
|
|
1876
|
+
staticPass: !sawWidth && !sawHeight && !sawResolution && !sawAspect && pass
|
|
1877
|
+
? false
|
|
1878
|
+
: !pass,
|
|
1879
|
+
});
|
|
1742
1880
|
continue;
|
|
1743
1881
|
}
|
|
1744
1882
|
if (!pass) {
|
|
@@ -1746,6 +1884,9 @@ export function parseMediaQuery(prelude) {
|
|
|
1746
1884
|
continue;
|
|
1747
1885
|
}
|
|
1748
1886
|
if (!sawWidth &&
|
|
1887
|
+
!sawHeight &&
|
|
1888
|
+
!sawResolution &&
|
|
1889
|
+
!sawAspect &&
|
|
1749
1890
|
condition.scheme === undefined &&
|
|
1750
1891
|
condition.min === undefined &&
|
|
1751
1892
|
condition.max === undefined) {
|
|
@@ -1847,6 +1988,122 @@ export function supportsCondition(prelude) {
|
|
|
1847
1988
|
* first `)` found no feature there — the term was passed over as though it
|
|
1848
1989
|
* said nothing, and every narrow-screen rule held at every width.
|
|
1849
1990
|
*/
|
|
1991
|
+
/** `aspect-ratio` and the device's, bare or `min-`/`max-`. */
|
|
1992
|
+
const ASPECT_FEATURES = /^(?:min-|max-)?(?:device-)?aspect-ratio$/;
|
|
1993
|
+
/** How far past square a landscape viewport is: any width over the height. */
|
|
1994
|
+
const ASPECT_EDGE = 1e-9;
|
|
1995
|
+
/** A ratio, `16/9` or `16 / 9` or `1.5`, as a number; null for anything
|
|
1996
|
+
* else, or a ratio of nothing. */
|
|
1997
|
+
function ratioOf(value) {
|
|
1998
|
+
const m = /^\s*(\d*\.?\d+)\s*(?:\/\s*(\d*\.?\d+)\s*)?$/.exec(value);
|
|
1999
|
+
if (!m)
|
|
2000
|
+
return null;
|
|
2001
|
+
const ratio = Number(m[1]) / (m[2] === undefined ? 1 : Number(m[2]));
|
|
2002
|
+
return Number.isFinite(ratio) && ratio > 0 ? ratio : null;
|
|
2003
|
+
}
|
|
2004
|
+
/** The resolution features, the standard's and WebKit's, which Chrome
|
|
2005
|
+
* answers; `min--moz-device-pixel-ratio` and `-o-min-device-pixel-ratio`
|
|
2006
|
+
* are no feature of its, and none of this. */
|
|
2007
|
+
const RESOLUTION_FEATURES = new Set([
|
|
2008
|
+
'resolution',
|
|
2009
|
+
'min-resolution',
|
|
2010
|
+
'max-resolution',
|
|
2011
|
+
'-webkit-device-pixel-ratio',
|
|
2012
|
+
'-webkit-min-device-pixel-ratio',
|
|
2013
|
+
'-webkit-max-device-pixel-ratio',
|
|
2014
|
+
]);
|
|
2015
|
+
/** A resolution in dots per CSS pixel: `2dppx`, `2x`, `192dpi`, `75.6dpcm`,
|
|
2016
|
+
* or WebKit's device pixel ratio, a number. Null for anything else. */
|
|
2017
|
+
function resolutionOf(value, ratio) {
|
|
2018
|
+
const m = /^\s*(\d*\.?\d+(?:e[+-]?\d+)?)\s*(dppx|x|dpi|dpcm)?\s*$/i.exec(value);
|
|
2019
|
+
if (!m)
|
|
2020
|
+
return null;
|
|
2021
|
+
const n = Number(m[1]);
|
|
2022
|
+
const unit = (m[2] ?? '').toLowerCase();
|
|
2023
|
+
if (ratio)
|
|
2024
|
+
return unit ? null : n;
|
|
2025
|
+
if (unit === 'dppx' || unit === 'x')
|
|
2026
|
+
return n;
|
|
2027
|
+
if (unit === 'dpi')
|
|
2028
|
+
return n / 96;
|
|
2029
|
+
if (unit === 'dpcm')
|
|
2030
|
+
return (n * 2.54) / 96;
|
|
2031
|
+
return null;
|
|
2032
|
+
}
|
|
2033
|
+
/** The features true in the boolean context whatever the viewport: a
|
|
2034
|
+
* size, a scheme, an orientation, there is always one. */
|
|
2035
|
+
const BOOLEAN_TRUE = new Set([
|
|
2036
|
+
'width',
|
|
2037
|
+
'height',
|
|
2038
|
+
'device-width',
|
|
2039
|
+
'device-height',
|
|
2040
|
+
'aspect-ratio',
|
|
2041
|
+
'orientation',
|
|
2042
|
+
'prefers-color-scheme',
|
|
2043
|
+
]);
|
|
2044
|
+
/**
|
|
2045
|
+
* A media feature as a desktop screen driven by a mouse answers it — the
|
|
2046
|
+
* device `<Html>` draws on — for the features that do not depend on the
|
|
2047
|
+
* viewport: true, false, or null for a feature nothing knows, which is
|
|
2048
|
+
* false (Media Queries 4, 3.2). `value` is null in the boolean context.
|
|
2049
|
+
* The colour is eight bits a component on no palette and no grid; scripts
|
|
2050
|
+
* never run here, so `scripting` is `none`.
|
|
2051
|
+
*/
|
|
2052
|
+
function desktopFeature(key, value) {
|
|
2053
|
+
const v = value?.trim().toLowerCase() ?? null;
|
|
2054
|
+
const numeric = (feature, has) => {
|
|
2055
|
+
const bare = key.replace(/^(min|max)-/, '');
|
|
2056
|
+
if (bare !== feature)
|
|
2057
|
+
return null;
|
|
2058
|
+
if (v === null)
|
|
2059
|
+
return key === feature ? has !== 0 : null;
|
|
2060
|
+
const n = Number(v);
|
|
2061
|
+
if (!Number.isFinite(n))
|
|
2062
|
+
return false;
|
|
2063
|
+
if (key.startsWith('min-'))
|
|
2064
|
+
return has >= n;
|
|
2065
|
+
if (key.startsWith('max-'))
|
|
2066
|
+
return has <= n;
|
|
2067
|
+
return has === n;
|
|
2068
|
+
};
|
|
2069
|
+
const keyword = (answers, bool) => v === null ? bool : (answers[v] ?? false);
|
|
2070
|
+
switch (key) {
|
|
2071
|
+
case 'hover':
|
|
2072
|
+
case 'any-hover':
|
|
2073
|
+
return keyword({ hover: true, none: false }, true);
|
|
2074
|
+
case 'pointer':
|
|
2075
|
+
case 'any-pointer':
|
|
2076
|
+
return keyword({ fine: true, coarse: false, none: false }, true);
|
|
2077
|
+
case 'update':
|
|
2078
|
+
return keyword({ fast: true, slow: false, none: false }, true);
|
|
2079
|
+
case 'overflow-block':
|
|
2080
|
+
case 'overflow-inline':
|
|
2081
|
+
return keyword({ scroll: true }, true);
|
|
2082
|
+
case 'scan':
|
|
2083
|
+
return false;
|
|
2084
|
+
case 'color-gamut':
|
|
2085
|
+
return keyword({ srgb: true }, true);
|
|
2086
|
+
case 'dynamic-range':
|
|
2087
|
+
case 'video-dynamic-range':
|
|
2088
|
+
return keyword({ standard: true }, true);
|
|
2089
|
+
case 'prefers-contrast':
|
|
2090
|
+
case 'prefers-reduced-transparency':
|
|
2091
|
+
case 'prefers-reduced-data':
|
|
2092
|
+
return keyword({ 'no-preference': true }, false);
|
|
2093
|
+
case 'forced-colors':
|
|
2094
|
+
return keyword({ none: true }, false);
|
|
2095
|
+
case 'scripting':
|
|
2096
|
+
return keyword({ none: true }, false);
|
|
2097
|
+
case 'display-mode':
|
|
2098
|
+
return keyword({ browser: true }, true);
|
|
2099
|
+
case '-webkit-transform-3d':
|
|
2100
|
+
return v === null || v === '1';
|
|
2101
|
+
}
|
|
2102
|
+
return (numeric('color', 8) ??
|
|
2103
|
+
numeric('monochrome', 0) ??
|
|
2104
|
+
numeric('color-index', 0) ??
|
|
2105
|
+
numeric('grid', 0));
|
|
2106
|
+
}
|
|
1850
2107
|
function mediaFeature(term) {
|
|
1851
2108
|
const m = /^\(\s*([a-z-]+)\s*:([\s\S]*)\)$/i.exec(term);
|
|
1852
2109
|
if (!m)
|
|
@@ -1867,7 +2124,12 @@ function mediaFeature(term) {
|
|
|
1867
2124
|
const ZERO_UNITS = { em: 16, rem: 16, vw: 0, vh: 0, scale: 1 };
|
|
1868
2125
|
/** Whether a rule's `@media` blocks all hold at this viewport width, under
|
|
1869
2126
|
* this colour scheme. */
|
|
1870
|
-
export function mediaMatches(media, width, scheme = 'light'
|
|
2127
|
+
export function mediaMatches(media, width, scheme = 'light',
|
|
2128
|
+
/** The viewport's height in CSS pixels; a test of it holds at no height
|
|
2129
|
+
* where none is given. */
|
|
2130
|
+
height = NaN,
|
|
2131
|
+
/** The display's scale, device pixels to the CSS pixel. */
|
|
2132
|
+
resolution = 1) {
|
|
1871
2133
|
if (!media)
|
|
1872
2134
|
return true;
|
|
1873
2135
|
for (const block of media) {
|
|
@@ -1880,6 +2142,12 @@ export function mediaMatches(media, width, scheme = 'light') {
|
|
|
1880
2142
|
}
|
|
1881
2143
|
if ((c.min === undefined || width >= c.min) &&
|
|
1882
2144
|
(c.max === undefined || width <= c.max) &&
|
|
2145
|
+
(c.minHeight === undefined || height >= c.minHeight) &&
|
|
2146
|
+
(c.maxHeight === undefined || height <= c.maxHeight) &&
|
|
2147
|
+
(c.minResolution === undefined || resolution >= c.minResolution) &&
|
|
2148
|
+
(c.minAspect === undefined || width >= c.minAspect * height) &&
|
|
2149
|
+
(c.maxAspect === undefined || width <= c.maxAspect * height) &&
|
|
2150
|
+
(c.maxResolution === undefined || resolution <= c.maxResolution) &&
|
|
1883
2151
|
(c.scheme === undefined || c.scheme === scheme)) {
|
|
1884
2152
|
any = true;
|
|
1885
2153
|
}
|