css-prefers-color-scheme 6.0.2 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +278 -45
- package/dist/browser-global.js +1 -99
- package/dist/browser-global.js.map +1 -1
- package/dist/browser.cjs +1 -92
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.mjs +1 -92
- package/dist/browser.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +1 -1
- package/package.json +101 -79
- package/browser.js +0 -100
- package/browser.min.js +0 -100
- package/dist/cli.cjs +0 -3
package/dist/browser.cjs
CHANGED
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var colorIndexRegExp = /((?:not )?all and )?(\(color-index: *(22|48|70)\))/i;
|
|
3
|
-
var prefersColorSchemeRegExp = /prefers-color-scheme:/i;
|
|
4
|
-
|
|
5
|
-
var prefersColorSchemeInit = function prefersColorSchemeInit(initialColorScheme) {
|
|
6
|
-
var mediaQueryString = '(prefers-color-scheme: dark)';
|
|
7
|
-
var mediaQueryList = window.matchMedia && matchMedia(mediaQueryString);
|
|
8
|
-
var hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;
|
|
9
|
-
|
|
10
|
-
var mediaQueryListener = function mediaQueryListener() {
|
|
11
|
-
set(mediaQueryList.matches ? 'dark' : 'light');
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var removeListener = function removeListener() {
|
|
15
|
-
if (mediaQueryList) {
|
|
16
|
-
mediaQueryList.removeListener(mediaQueryListener);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var set = function set(colorScheme) {
|
|
21
|
-
if (colorScheme !== currentColorScheme) {
|
|
22
|
-
currentColorScheme = colorScheme;
|
|
23
|
-
|
|
24
|
-
if (typeof result.onChange === 'function') {
|
|
25
|
-
result.onChange();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[].forEach.call(document.styleSheets || [], function (styleSheet) {
|
|
30
|
-
// cssRules is a live list. Converting to an Array first.
|
|
31
|
-
var rules = [];
|
|
32
|
-
[].forEach.call(styleSheet.cssRules || [], function (cssRule) {
|
|
33
|
-
rules.push(cssRule);
|
|
34
|
-
});
|
|
35
|
-
rules.forEach(function (cssRule) {
|
|
36
|
-
var colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);
|
|
37
|
-
|
|
38
|
-
if (colorSchemeMatch) {
|
|
39
|
-
var index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);
|
|
40
|
-
cssRule.parentStyleSheet.deleteRule(index);
|
|
41
|
-
} else {
|
|
42
|
-
var colorIndexMatch = (Object(cssRule.media).mediaText || '').match(colorIndexRegExp);
|
|
43
|
-
|
|
44
|
-
if (colorIndexMatch) {
|
|
45
|
-
// Old style which has poor browser support and can't handle complex media queries.
|
|
46
|
-
cssRule.media.mediaText = ((/^dark$/i.test(colorScheme) ? colorIndexMatch[3] === '48' : /^light$/i.test(colorScheme) ? colorIndexMatch[3] === '70' : colorIndexMatch[3] === '22') ? 'not all and ' : '') + cssRule.media.mediaText.replace(colorIndexRegExp, '$2');
|
|
47
|
-
} else {
|
|
48
|
-
// New style which supports complex media queries.
|
|
49
|
-
var colorDepthMatch = (Object(cssRule.media).mediaText || '').match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);
|
|
50
|
-
|
|
51
|
-
if (colorDepthMatch && colorDepthMatch.length > 1) {
|
|
52
|
-
if (/^dark$/i.test(colorScheme) && (colorDepthMatch[1] === '48842621' || colorDepthMatch[1] === '22511989')) {
|
|
53
|
-
// No preference or preferred is dark and rule is dark.
|
|
54
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
55
|
-
} else if (/^light$/i.test(colorScheme) && (colorDepthMatch[1] === '70318723' || colorDepthMatch[1] === '22511989')) {
|
|
56
|
-
// No preference or preferred is light and rule is light.
|
|
57
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
58
|
-
} else {
|
|
59
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i, "(color: " + colorDepthMatch[1] + ")");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var result = Object.defineProperty({
|
|
69
|
-
hasNativeSupport: hasNativeSupport,
|
|
70
|
-
removeListener: removeListener
|
|
71
|
-
}, 'scheme', {
|
|
72
|
-
get: function get() {
|
|
73
|
-
return currentColorScheme;
|
|
74
|
-
},
|
|
75
|
-
set: set
|
|
76
|
-
}); // initialize the color scheme using the provided value, the system value, or light
|
|
77
|
-
|
|
78
|
-
var currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');
|
|
79
|
-
set(currentColorScheme); // listen for system changes
|
|
80
|
-
|
|
81
|
-
if (mediaQueryList) {
|
|
82
|
-
if ('addEventListener' in mediaQueryList) {
|
|
83
|
-
mediaQueryList.addEventListener('change', mediaQueryListener);
|
|
84
|
-
} else {
|
|
85
|
-
mediaQueryList.addListener(mediaQueryListener);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
module.exports = prefersColorSchemeInit;
|
|
1
|
+
var e=/prefers-color-scheme:/i;module.exports=function(t,a){a||(a={}),a={debug:!!a.debug||!1};var r="(prefers-color-scheme: dark)",i="matchMedia"in window&&window.matchMedia(r),c=i&&i.media===r,o=function(){n(i&&i.matches?"dark":"light")},n=function(t){"dark"!==t&&"light"!==t&&(t=c&&i.matches?"dark":"light"),t!==l&&(l=t,"function"==typeof d.onChange&&d.onChange()),[].forEach.call(document.styleSheets||[],(function(r){try{var i=[];[].forEach.call(r.cssRules||[],(function(e){i.push(e)})),i.forEach((function(a){if(e.test(Object(a.media).mediaText)){var r=[].indexOf.call(a.parentStyleSheet.cssRules,a);a.parentStyleSheet.deleteRule(r)}else{var i=(Object(a.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723) *\)/i);i&&i.length>1&&("dark"===t&&"48842621"===i[1]?a.media.mediaText=a.media.mediaText.replace(/\( *color: *(?:48842621) *\)/i,"(max-color: "+i[1]+")"):"light"===t&&"70318723"===i[1]?a.media.mediaText=a.media.mediaText.replace(/\( *color: *(?:70318723) *\)/i,"(max-color: "+i[1]+")"):a.media.mediaText=a.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723) *\)/i,"(color: "+i[1]+")"))}}))}catch(e){a.debug&&console.error(e)}}))},d=Object.defineProperty({hasNativeSupport:c,removeListener:function(){i&&i.removeListener(o)}},"scheme",{get:function(){return l},set:n}),l=t||(i&&i.matches?"dark":"light");return n(l),i&&("addEventListener"in i?i.addEventListener("change",o):i.addListener(o)),d};
|
|
93
2
|
//# sourceMappingURL=browser.cjs.map
|
package/dist/browser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.cjs","sources":["../src/browser.js"],"sourcesContent":["/* global document,window
|
|
1
|
+
{"version":3,"file":"browser.cjs","sources":["../src/browser.js"],"sourcesContent":["/* global document,window */\nconst prefersColorSchemeRegExp = /prefers-color-scheme:/i;\n\nconst prefersColorSchemeInit = (initialColorScheme, options) => {\n\t// OPTIONS\n\t{\n\t\tif (!options) {\n\t\t\toptions = {};\n\t\t}\n\n\t\toptions = {\n\t\t\tdebug: (!!options.debug) || false,\n\t\t};\n\t}\n\n\tconst mediaQueryString = '(prefers-color-scheme: dark)';\n\tconst mediaQueryList = ('matchMedia' in window) && window.matchMedia(mediaQueryString);\n\tconst hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;\n\tconst mediaQueryListener = () => {\n\t\tset((mediaQueryList && mediaQueryList.matches) ? 'dark' : 'light');\n\t};\n\tconst removeListener = () => {\n\t\tif (mediaQueryList) {\n\t\t\tmediaQueryList.removeListener(mediaQueryListener);\n\t\t}\n\t};\n\tconst set = (colorScheme) => {\n\t\tif (colorScheme !== 'dark' && colorScheme !== 'light') {\n\t\t\tif (hasNativeSupport) {\n\t\t\t\tcolorScheme = mediaQueryList.matches ? 'dark' : 'light';\n\t\t\t} else {\n\t\t\t\tcolorScheme = 'light';\n\t\t\t}\n\t\t}\n\n\t\tif (colorScheme !== currentColorScheme) {\n\t\t\tcurrentColorScheme = colorScheme;\n\n\t\t\tif (typeof result.onChange === 'function') {\n\t\t\t\tresult.onChange();\n\t\t\t}\n\t\t}\n\n\t\t[].forEach.call(document.styleSheets || [], styleSheet => {\n\t\t\ttry {\n\t\t\t\t// cssRules is a live list. Converting to an Array first.\n\t\t\t\tconst rules = [];\n\t\t\t\t[].forEach.call(styleSheet.cssRules || [], cssRule => {\n\t\t\t\t\trules.push(cssRule);\n\t\t\t\t});\n\n\t\t\t\trules.forEach(cssRule => {\n\t\t\t\t\tconst colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);\n\n\t\t\t\t\tif (colorSchemeMatch) {\n\t\t\t\t\t\tconst index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);\n\t\t\t\t\t\tcssRule.parentStyleSheet.deleteRule(index);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// New style which supports complex media queries.\n\t\t\t\t\t\tconst colorDepthMatch = (Object(cssRule.media).mediaText || '').match(/\\( *(?:color|max-color): *(48842621|70318723) *\\)/i);\n\t\t\t\t\t\tif (colorDepthMatch && colorDepthMatch.length > 1) {\n\t\t\t\t\t\t\tif (colorScheme === 'dark' && (colorDepthMatch[1] === '48842621')) {\n\t\t\t\t\t\t\t\t// preferred is dark and rule is dark.\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *color: *(?:48842621) *\\)/i, `(max-color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t} else if (colorScheme === 'light' && (colorDepthMatch[1] === '70318723')) {\n\t\t\t\t\t\t\t\t// preferred is light and rule is light.\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *color: *(?:70318723) *\\)/i, `(max-color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *max-color: *(?:48842621|70318723) *\\)/i, `(color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\tconst result = Object.defineProperty(\n\t\t{ hasNativeSupport, removeListener },\n\t\t'scheme',\n\t\t{ get: () => currentColorScheme, set },\n\t);\n\n\t// initialize the color scheme using the provided value, the system value, or light\n\tlet currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');\n\n\tset(currentColorScheme);\n\n\t// listen for system changes\n\tif (mediaQueryList) {\n\t\tif ('addEventListener' in mediaQueryList) {\n\t\t\tmediaQueryList.addEventListener('change', mediaQueryListener);\n\t\t} else {\n\t\t\tmediaQueryList.addListener(mediaQueryListener);\n\t\t}\n\t}\n\n\treturn result;\n};\n\nexport default prefersColorSchemeInit;\n"],"names":["prefersColorSchemeRegExp","initialColorScheme","options","debug","mediaQueryString","mediaQueryList","window","matchMedia","hasNativeSupport","media","mediaQueryListener","set","matches","colorScheme","currentColorScheme","result","onChange","forEach","call","document","styleSheets","styleSheet","rules","cssRules","cssRule","push","test","Object","mediaText","index","indexOf","parentStyleSheet","deleteRule","colorDepthMatch","match","length","replace","e","console","error","defineProperty","removeListener","get","addEventListener","addListener"],"mappings":"AACA,IAAMA,EAA2B,wCAEF,SAACC,EAAoBC,GAG7CA,IACJA,EAAU,CAAA,GAGXA,EAAU,CACTC,QAAUD,EAAQC,QAAU,GAI9B,IAAMC,EAAmB,+BACnBC,EAAkB,eAAgBC,QAAWA,OAAOC,WAAWH,GAC/DI,EAAmBH,GAAkBA,EAAeI,QAAUL,EAC9DM,EAAqB,WAC1BC,EAAKN,GAAkBA,EAAeO,QAAW,OAAS,UAOrDD,EAAM,SAACE,GACQ,SAAhBA,GAA0C,UAAhBA,IAE5BA,EADGL,GACWH,EAAeO,QAAU,OAEzB,SAIZC,IAAgBC,IACnBA,EAAqBD,EAEU,mBAApBE,EAAOC,UACjBD,EAAOC,YAIT,GAAGC,QAAQC,KAAKC,SAASC,aAAe,IAAI,SAAAC,GAC3C,IAEC,IAAMC,EAAQ,GACd,GAAGL,QAAQC,KAAKG,EAAWE,UAAY,IAAI,SAAAC,GAC1CF,EAAMG,KAAKD,MAGZF,EAAML,SAAQ,SAAAO,GAGb,GAFyBxB,EAAyB0B,KAAKC,OAAOH,EAAQf,OAAOmB,WAEvD,CACrB,IAAMC,EAAQ,GAAGC,QAAQZ,KAAKM,EAAQO,iBAAiBR,SAAUC,GACjEA,EAAQO,iBAAiBC,WAAWH,EACpC,KAAM,CAEN,IAAMI,GAAmBN,OAAOH,EAAQf,OAAOmB,WAAa,IAAIM,MAAM,sDAClED,GAAmBA,EAAgBE,OAAS,IAC3B,SAAhBtB,GAAkD,aAAvBoB,EAAgB,GAE9CT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,gCAAhC,eAAgFH,EAAgB,GAA1H,KAC0B,UAAhBpB,GAAmD,aAAvBoB,EAAgB,GAEtDT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,gCAAhC,eAAgFH,EAAgB,GAA1H,KAEAT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,6CAAhC,WAAyFH,EAAgB,GAAnI,KAGF,IAMF,CAJC,MAAOI,GACJnC,EAAQC,OACXmC,QAAQC,MAAMF,EAEf,MAGGtB,EAASY,OAAOa,eACrB,CAAEhC,iBAAAA,EAAkBiC,eA5DE,WAClBpC,GACHA,EAAeoC,eAAe/B,KA2D/B,SACA,CAAEgC,IAAK,WAAA,OAAM5B,CAAb,EAAiCH,IAAAA,IAI9BG,EAAqBb,IAAuBI,GAAkBA,EAAeO,QAAU,OAAS,SAapG,OAXAD,EAAIG,GAGAT,IACC,qBAAsBA,EACzBA,EAAesC,iBAAiB,SAAUjC,GAE1CL,EAAeuC,YAAYlC,IAItBK,CACP"}
|
package/dist/browser.mjs
CHANGED
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var colorIndexRegExp = /((?:not )?all and )?(\(color-index: *(22|48|70)\))/i;
|
|
3
|
-
var prefersColorSchemeRegExp = /prefers-color-scheme:/i;
|
|
4
|
-
|
|
5
|
-
var prefersColorSchemeInit = function prefersColorSchemeInit(initialColorScheme) {
|
|
6
|
-
var mediaQueryString = '(prefers-color-scheme: dark)';
|
|
7
|
-
var mediaQueryList = window.matchMedia && matchMedia(mediaQueryString);
|
|
8
|
-
var hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;
|
|
9
|
-
|
|
10
|
-
var mediaQueryListener = function mediaQueryListener() {
|
|
11
|
-
set(mediaQueryList.matches ? 'dark' : 'light');
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var removeListener = function removeListener() {
|
|
15
|
-
if (mediaQueryList) {
|
|
16
|
-
mediaQueryList.removeListener(mediaQueryListener);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var set = function set(colorScheme) {
|
|
21
|
-
if (colorScheme !== currentColorScheme) {
|
|
22
|
-
currentColorScheme = colorScheme;
|
|
23
|
-
|
|
24
|
-
if (typeof result.onChange === 'function') {
|
|
25
|
-
result.onChange();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[].forEach.call(document.styleSheets || [], function (styleSheet) {
|
|
30
|
-
// cssRules is a live list. Converting to an Array first.
|
|
31
|
-
var rules = [];
|
|
32
|
-
[].forEach.call(styleSheet.cssRules || [], function (cssRule) {
|
|
33
|
-
rules.push(cssRule);
|
|
34
|
-
});
|
|
35
|
-
rules.forEach(function (cssRule) {
|
|
36
|
-
var colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);
|
|
37
|
-
|
|
38
|
-
if (colorSchemeMatch) {
|
|
39
|
-
var index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);
|
|
40
|
-
cssRule.parentStyleSheet.deleteRule(index);
|
|
41
|
-
} else {
|
|
42
|
-
var colorIndexMatch = (Object(cssRule.media).mediaText || '').match(colorIndexRegExp);
|
|
43
|
-
|
|
44
|
-
if (colorIndexMatch) {
|
|
45
|
-
// Old style which has poor browser support and can't handle complex media queries.
|
|
46
|
-
cssRule.media.mediaText = ((/^dark$/i.test(colorScheme) ? colorIndexMatch[3] === '48' : /^light$/i.test(colorScheme) ? colorIndexMatch[3] === '70' : colorIndexMatch[3] === '22') ? 'not all and ' : '') + cssRule.media.mediaText.replace(colorIndexRegExp, '$2');
|
|
47
|
-
} else {
|
|
48
|
-
// New style which supports complex media queries.
|
|
49
|
-
var colorDepthMatch = (Object(cssRule.media).mediaText || '').match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);
|
|
50
|
-
|
|
51
|
-
if (colorDepthMatch && colorDepthMatch.length > 1) {
|
|
52
|
-
if (/^dark$/i.test(colorScheme) && (colorDepthMatch[1] === '48842621' || colorDepthMatch[1] === '22511989')) {
|
|
53
|
-
// No preference or preferred is dark and rule is dark.
|
|
54
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
55
|
-
} else if (/^light$/i.test(colorScheme) && (colorDepthMatch[1] === '70318723' || colorDepthMatch[1] === '22511989')) {
|
|
56
|
-
// No preference or preferred is light and rule is light.
|
|
57
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
58
|
-
} else {
|
|
59
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i, "(color: " + colorDepthMatch[1] + ")");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var result = Object.defineProperty({
|
|
69
|
-
hasNativeSupport: hasNativeSupport,
|
|
70
|
-
removeListener: removeListener
|
|
71
|
-
}, 'scheme', {
|
|
72
|
-
get: function get() {
|
|
73
|
-
return currentColorScheme;
|
|
74
|
-
},
|
|
75
|
-
set: set
|
|
76
|
-
}); // initialize the color scheme using the provided value, the system value, or light
|
|
77
|
-
|
|
78
|
-
var currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');
|
|
79
|
-
set(currentColorScheme); // listen for system changes
|
|
80
|
-
|
|
81
|
-
if (mediaQueryList) {
|
|
82
|
-
if ('addEventListener' in mediaQueryList) {
|
|
83
|
-
mediaQueryList.addEventListener('change', mediaQueryListener);
|
|
84
|
-
} else {
|
|
85
|
-
mediaQueryList.addListener(mediaQueryListener);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { prefersColorSchemeInit as default };
|
|
1
|
+
var e=/prefers-color-scheme:/i,t=function(t,a){a||(a={}),a={debug:!!a.debug||!1};var r="(prefers-color-scheme: dark)",i="matchMedia"in window&&window.matchMedia(r),c=i&&i.media===r,o=function(){n(i&&i.matches?"dark":"light")},n=function(t){"dark"!==t&&"light"!==t&&(t=c&&i.matches?"dark":"light"),t!==l&&(l=t,"function"==typeof d.onChange&&d.onChange()),[].forEach.call(document.styleSheets||[],(function(r){try{var i=[];[].forEach.call(r.cssRules||[],(function(e){i.push(e)})),i.forEach((function(a){if(e.test(Object(a.media).mediaText)){var r=[].indexOf.call(a.parentStyleSheet.cssRules,a);a.parentStyleSheet.deleteRule(r)}else{var i=(Object(a.media).mediaText||"").match(/\( *(?:color|max-color): *(48842621|70318723) *\)/i);i&&i.length>1&&("dark"===t&&"48842621"===i[1]?a.media.mediaText=a.media.mediaText.replace(/\( *color: *(?:48842621) *\)/i,"(max-color: "+i[1]+")"):"light"===t&&"70318723"===i[1]?a.media.mediaText=a.media.mediaText.replace(/\( *color: *(?:70318723) *\)/i,"(max-color: "+i[1]+")"):a.media.mediaText=a.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723) *\)/i,"(color: "+i[1]+")"))}}))}catch(e){a.debug&&console.error(e)}}))},d=Object.defineProperty({hasNativeSupport:c,removeListener:function(){i&&i.removeListener(o)}},"scheme",{get:function(){return l},set:n}),l=t||(i&&i.matches?"dark":"light");return n(l),i&&("addEventListener"in i?i.addEventListener("change",o):i.addListener(o)),d};export{t as default};
|
|
93
2
|
//# sourceMappingURL=browser.mjs.map
|
package/dist/browser.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.mjs","sources":["../src/browser.js"],"sourcesContent":["/* global document,window
|
|
1
|
+
{"version":3,"file":"browser.mjs","sources":["../src/browser.js"],"sourcesContent":["/* global document,window */\nconst prefersColorSchemeRegExp = /prefers-color-scheme:/i;\n\nconst prefersColorSchemeInit = (initialColorScheme, options) => {\n\t// OPTIONS\n\t{\n\t\tif (!options) {\n\t\t\toptions = {};\n\t\t}\n\n\t\toptions = {\n\t\t\tdebug: (!!options.debug) || false,\n\t\t};\n\t}\n\n\tconst mediaQueryString = '(prefers-color-scheme: dark)';\n\tconst mediaQueryList = ('matchMedia' in window) && window.matchMedia(mediaQueryString);\n\tconst hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;\n\tconst mediaQueryListener = () => {\n\t\tset((mediaQueryList && mediaQueryList.matches) ? 'dark' : 'light');\n\t};\n\tconst removeListener = () => {\n\t\tif (mediaQueryList) {\n\t\t\tmediaQueryList.removeListener(mediaQueryListener);\n\t\t}\n\t};\n\tconst set = (colorScheme) => {\n\t\tif (colorScheme !== 'dark' && colorScheme !== 'light') {\n\t\t\tif (hasNativeSupport) {\n\t\t\t\tcolorScheme = mediaQueryList.matches ? 'dark' : 'light';\n\t\t\t} else {\n\t\t\t\tcolorScheme = 'light';\n\t\t\t}\n\t\t}\n\n\t\tif (colorScheme !== currentColorScheme) {\n\t\t\tcurrentColorScheme = colorScheme;\n\n\t\t\tif (typeof result.onChange === 'function') {\n\t\t\t\tresult.onChange();\n\t\t\t}\n\t\t}\n\n\t\t[].forEach.call(document.styleSheets || [], styleSheet => {\n\t\t\ttry {\n\t\t\t\t// cssRules is a live list. Converting to an Array first.\n\t\t\t\tconst rules = [];\n\t\t\t\t[].forEach.call(styleSheet.cssRules || [], cssRule => {\n\t\t\t\t\trules.push(cssRule);\n\t\t\t\t});\n\n\t\t\t\trules.forEach(cssRule => {\n\t\t\t\t\tconst colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);\n\n\t\t\t\t\tif (colorSchemeMatch) {\n\t\t\t\t\t\tconst index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);\n\t\t\t\t\t\tcssRule.parentStyleSheet.deleteRule(index);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// New style which supports complex media queries.\n\t\t\t\t\t\tconst colorDepthMatch = (Object(cssRule.media).mediaText || '').match(/\\( *(?:color|max-color): *(48842621|70318723) *\\)/i);\n\t\t\t\t\t\tif (colorDepthMatch && colorDepthMatch.length > 1) {\n\t\t\t\t\t\t\tif (colorScheme === 'dark' && (colorDepthMatch[1] === '48842621')) {\n\t\t\t\t\t\t\t\t// preferred is dark and rule is dark.\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *color: *(?:48842621) *\\)/i, `(max-color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t} else if (colorScheme === 'light' && (colorDepthMatch[1] === '70318723')) {\n\t\t\t\t\t\t\t\t// preferred is light and rule is light.\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *color: *(?:70318723) *\\)/i, `(max-color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcssRule.media.mediaText = cssRule.media.mediaText.replace(/\\( *max-color: *(?:48842621|70318723) *\\)/i, `(color: ${colorDepthMatch[1]})`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\tconst result = Object.defineProperty(\n\t\t{ hasNativeSupport, removeListener },\n\t\t'scheme',\n\t\t{ get: () => currentColorScheme, set },\n\t);\n\n\t// initialize the color scheme using the provided value, the system value, or light\n\tlet currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');\n\n\tset(currentColorScheme);\n\n\t// listen for system changes\n\tif (mediaQueryList) {\n\t\tif ('addEventListener' in mediaQueryList) {\n\t\t\tmediaQueryList.addEventListener('change', mediaQueryListener);\n\t\t} else {\n\t\t\tmediaQueryList.addListener(mediaQueryListener);\n\t\t}\n\t}\n\n\treturn result;\n};\n\nexport default prefersColorSchemeInit;\n"],"names":["prefersColorSchemeRegExp","prefersColorSchemeInit","initialColorScheme","options","debug","mediaQueryString","mediaQueryList","window","matchMedia","hasNativeSupport","media","mediaQueryListener","set","matches","colorScheme","currentColorScheme","result","onChange","forEach","call","document","styleSheets","styleSheet","rules","cssRules","cssRule","push","test","Object","mediaText","index","indexOf","parentStyleSheet","deleteRule","colorDepthMatch","match","length","replace","e","console","error","defineProperty","removeListener","get","addEventListener","addListener"],"mappings":"AACA,IAAMA,EAA2B,yBAE3BC,EAAyB,SAACC,EAAoBC,GAG7CA,IACJA,EAAU,CAAA,GAGXA,EAAU,CACTC,QAAUD,EAAQC,QAAU,GAI9B,IAAMC,EAAmB,+BACnBC,EAAkB,eAAgBC,QAAWA,OAAOC,WAAWH,GAC/DI,EAAmBH,GAAkBA,EAAeI,QAAUL,EAC9DM,EAAqB,WAC1BC,EAAKN,GAAkBA,EAAeO,QAAW,OAAS,UAOrDD,EAAM,SAACE,GACQ,SAAhBA,GAA0C,UAAhBA,IAE5BA,EADGL,GACWH,EAAeO,QAAU,OAEzB,SAIZC,IAAgBC,IACnBA,EAAqBD,EAEU,mBAApBE,EAAOC,UACjBD,EAAOC,YAIT,GAAGC,QAAQC,KAAKC,SAASC,aAAe,IAAI,SAAAC,GAC3C,IAEC,IAAMC,EAAQ,GACd,GAAGL,QAAQC,KAAKG,EAAWE,UAAY,IAAI,SAAAC,GAC1CF,EAAMG,KAAKD,MAGZF,EAAML,SAAQ,SAAAO,GAGb,GAFyBzB,EAAyB2B,KAAKC,OAAOH,EAAQf,OAAOmB,WAEvD,CACrB,IAAMC,EAAQ,GAAGC,QAAQZ,KAAKM,EAAQO,iBAAiBR,SAAUC,GACjEA,EAAQO,iBAAiBC,WAAWH,EACpC,KAAM,CAEN,IAAMI,GAAmBN,OAAOH,EAAQf,OAAOmB,WAAa,IAAIM,MAAM,sDAClED,GAAmBA,EAAgBE,OAAS,IAC3B,SAAhBtB,GAAkD,aAAvBoB,EAAgB,GAE9CT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,gCAAhC,eAAgFH,EAAgB,GAA1H,KAC0B,UAAhBpB,GAAmD,aAAvBoB,EAAgB,GAEtDT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,gCAAhC,eAAgFH,EAAgB,GAA1H,KAEAT,EAAQf,MAAMmB,UAAYJ,EAAQf,MAAMmB,UAAUQ,QAAQ,6CAAhC,WAAyFH,EAAgB,GAAnI,KAGF,IAMF,CAJC,MAAOI,GACJnC,EAAQC,OACXmC,QAAQC,MAAMF,EAEf,MAGGtB,EAASY,OAAOa,eACrB,CAAEhC,iBAAAA,EAAkBiC,eA5DE,WAClBpC,GACHA,EAAeoC,eAAe/B,KA2D/B,SACA,CAAEgC,IAAK,WAAA,OAAM5B,CAAb,EAAiCH,IAAAA,IAI9BG,EAAqBb,IAAuBI,GAAkBA,EAAeO,QAAU,OAAS,SAapG,OAXAD,EAAIG,GAGAT,IACC,qBAAsBA,EACzBA,EAAesC,iBAAiB,SAAUjC,GAE1CL,EAAeuC,YAAYlC,IAItBK,CACP"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e
|
|
1
|
+
"use strict";const e=/\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)/gi,s={dark:"48842621",light:"70318723"},r=(e,r)=>`(color: ${s[r.toLowerCase()]})`,o=s=>{const o=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-prefers-color-scheme",AtRule:s=>{if("media"!==s.name.toLowerCase())return;const{params:t}=s,c=t.replace(e,r);t!==c&&(s.cloneBefore({params:c}),o.preserve||s.remove())}}};o.postcss=!0,module.exports=o;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e
|
|
1
|
+
const e=/\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)/gi,s={dark:"48842621",light:"70318723"},r=(e,r)=>`(color: ${s[r.toLowerCase()]})`,o=s=>{const o=Object.assign({preserve:!0},s);return{postcssPlugin:"postcss-prefers-color-scheme",AtRule:s=>{if("media"!==s.name.toLowerCase())return;const{params:t}=s,a=t.replace(e,r);t!==a&&(s.cloneBefore({params:a}),o.preserve||s.remove())}}};o.postcss=!0;export{o as default};
|
package/package.json
CHANGED
|
@@ -1,81 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
2
|
+
"name": "css-prefers-color-scheme",
|
|
3
|
+
"description": "Use light and dark color schemes in all browsers",
|
|
4
|
+
"version": "7.0.1",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Antonio Laguna",
|
|
8
|
+
"email": "antonio@laguna.es",
|
|
9
|
+
"url": "https://antonio.laguna.es"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Romain Menke",
|
|
13
|
+
"email": "romainmenke@gmail.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Jonathan Neal",
|
|
17
|
+
"email": "jonathantneal@hotmail.com"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"license": "CC0-1.0",
|
|
21
|
+
"funding": {
|
|
22
|
+
"type": "opencollective",
|
|
23
|
+
"url": "https://opencollective.com/csstools"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": "^12 || ^14 || >=16"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.cjs",
|
|
29
|
+
"module": "dist/index.mjs",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/index.mjs",
|
|
34
|
+
"require": "./dist/index.cjs",
|
|
35
|
+
"default": "./dist/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./browser": {
|
|
38
|
+
"import": "./dist/browser.mjs",
|
|
39
|
+
"require": "./dist/browser.cjs",
|
|
40
|
+
"default": "./dist/browser.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./browser-global": {
|
|
43
|
+
"default": "./dist/browser-global.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"CHANGELOG.md",
|
|
48
|
+
"LICENSE.md",
|
|
49
|
+
"README.md",
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"postcss": "^8.2"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"puppeteer": "^16.0.0"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "rollup -c ../../rollup/default.js",
|
|
60
|
+
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
|
|
61
|
+
"docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
|
|
62
|
+
"lint": "npm run lint:eslint && npm run lint:package-json",
|
|
63
|
+
"lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
|
|
64
|
+
"lint:package-json": "node ../../.github/bin/format-package-json.mjs",
|
|
65
|
+
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
66
|
+
"test": "node .tape.mjs && npm run test:exports",
|
|
67
|
+
"test:browser": "node ./test/_browser.mjs",
|
|
68
|
+
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
69
|
+
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme#readme",
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "https://github.com/csstools/postcss-plugins.git",
|
|
75
|
+
"directory": "plugins/css-prefers-color-scheme"
|
|
76
|
+
},
|
|
77
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
78
|
+
"keywords": [
|
|
79
|
+
"color",
|
|
80
|
+
"css",
|
|
81
|
+
"dark",
|
|
82
|
+
"interface",
|
|
83
|
+
"light",
|
|
84
|
+
"media",
|
|
85
|
+
"mode",
|
|
86
|
+
"no-preference",
|
|
87
|
+
"postcss",
|
|
88
|
+
"postcss-plugin",
|
|
89
|
+
"prefers",
|
|
90
|
+
"queries",
|
|
91
|
+
"query",
|
|
92
|
+
"scheme"
|
|
93
|
+
],
|
|
94
|
+
"csstools": {
|
|
95
|
+
"cssdbId": "prefers-color-scheme-query",
|
|
96
|
+
"exportName": "prefersColorScheme",
|
|
97
|
+
"humanReadableName": "Prefers Color Scheme",
|
|
98
|
+
"specUrl": "https://www.w3.org/TR/mediaqueries-5/#prefers-color-scheme"
|
|
99
|
+
},
|
|
100
|
+
"volta": {
|
|
101
|
+
"extends": "../../package.json"
|
|
102
|
+
}
|
|
81
103
|
}
|
package/browser.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
(function () {
|
|
2
|
-
|
|
3
|
-
/* global document,window,matchMedia */
|
|
4
|
-
var colorIndexRegExp = /((?:not )?all and )?(\(color-index: *(22|48|70)\))/i;
|
|
5
|
-
var prefersColorSchemeRegExp = /prefers-color-scheme:/i;
|
|
6
|
-
|
|
7
|
-
var prefersColorSchemeInit = function prefersColorSchemeInit(initialColorScheme) {
|
|
8
|
-
var mediaQueryString = '(prefers-color-scheme: dark)';
|
|
9
|
-
var mediaQueryList = window.matchMedia && matchMedia(mediaQueryString);
|
|
10
|
-
var hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;
|
|
11
|
-
|
|
12
|
-
var mediaQueryListener = function mediaQueryListener() {
|
|
13
|
-
set(mediaQueryList.matches ? 'dark' : 'light');
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var removeListener = function removeListener() {
|
|
17
|
-
if (mediaQueryList) {
|
|
18
|
-
mediaQueryList.removeListener(mediaQueryListener);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var set = function set(colorScheme) {
|
|
23
|
-
if (colorScheme !== currentColorScheme) {
|
|
24
|
-
currentColorScheme = colorScheme;
|
|
25
|
-
|
|
26
|
-
if (typeof result.onChange === 'function') {
|
|
27
|
-
result.onChange();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
[].forEach.call(document.styleSheets || [], function (styleSheet) {
|
|
32
|
-
// cssRules is a live list. Converting to an Array first.
|
|
33
|
-
var rules = [];
|
|
34
|
-
[].forEach.call(styleSheet.cssRules || [], function (cssRule) {
|
|
35
|
-
rules.push(cssRule);
|
|
36
|
-
});
|
|
37
|
-
rules.forEach(function (cssRule) {
|
|
38
|
-
var colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);
|
|
39
|
-
|
|
40
|
-
if (colorSchemeMatch) {
|
|
41
|
-
var index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);
|
|
42
|
-
cssRule.parentStyleSheet.deleteRule(index);
|
|
43
|
-
} else {
|
|
44
|
-
var colorIndexMatch = (Object(cssRule.media).mediaText || '').match(colorIndexRegExp);
|
|
45
|
-
|
|
46
|
-
if (colorIndexMatch) {
|
|
47
|
-
// Old style which has poor browser support and can't handle complex media queries.
|
|
48
|
-
cssRule.media.mediaText = ((/^dark$/i.test(colorScheme) ? colorIndexMatch[3] === '48' : /^light$/i.test(colorScheme) ? colorIndexMatch[3] === '70' : colorIndexMatch[3] === '22') ? 'not all and ' : '') + cssRule.media.mediaText.replace(colorIndexRegExp, '$2');
|
|
49
|
-
} else {
|
|
50
|
-
// New style which supports complex media queries.
|
|
51
|
-
var colorDepthMatch = (Object(cssRule.media).mediaText || '').match(/\( *(?:color|max-color): *(48842621|70318723|22511989) *\)/i);
|
|
52
|
-
|
|
53
|
-
if (colorDepthMatch && colorDepthMatch.length > 1) {
|
|
54
|
-
if (/^dark$/i.test(colorScheme) && (colorDepthMatch[1] === '48842621' || colorDepthMatch[1] === '22511989')) {
|
|
55
|
-
// No preference or preferred is dark and rule is dark.
|
|
56
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|70318723) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
57
|
-
} else if (/^light$/i.test(colorScheme) && (colorDepthMatch[1] === '70318723' || colorDepthMatch[1] === '22511989')) {
|
|
58
|
-
// No preference or preferred is light and rule is light.
|
|
59
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *color: *(?:48842621|22511989) *\)/i, "(max-color: " + colorDepthMatch[1] + ")");
|
|
60
|
-
} else {
|
|
61
|
-
cssRule.media.mediaText = cssRule.media.mediaText.replace(/\( *max-color: *(?:48842621|70318723|22511989) *\)/i, "(color: " + colorDepthMatch[1] + ")");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
var result = Object.defineProperty({
|
|
71
|
-
hasNativeSupport: hasNativeSupport,
|
|
72
|
-
removeListener: removeListener
|
|
73
|
-
}, 'scheme', {
|
|
74
|
-
get: function get() {
|
|
75
|
-
return currentColorScheme;
|
|
76
|
-
},
|
|
77
|
-
set: set
|
|
78
|
-
}); // initialize the color scheme using the provided value, the system value, or light
|
|
79
|
-
|
|
80
|
-
var currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');
|
|
81
|
-
set(currentColorScheme); // listen for system changes
|
|
82
|
-
|
|
83
|
-
if (mediaQueryList) {
|
|
84
|
-
if ('addEventListener' in mediaQueryList) {
|
|
85
|
-
mediaQueryList.addEventListener('change', mediaQueryListener);
|
|
86
|
-
} else {
|
|
87
|
-
mediaQueryList.addListener(mediaQueryListener);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return result;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/* global self */
|
|
95
|
-
self.prefersColorSchemeInit = prefersColorSchemeInit; // Legacy : there used to be a rollup config that exposed this function under a different name.
|
|
96
|
-
|
|
97
|
-
self.initPrefersColorScheme = prefersColorSchemeInit;
|
|
98
|
-
|
|
99
|
-
})();
|
|
100
|
-
//# sourceMappingURL=browser-global.js.map
|