@tamagui/react-native-media-driver 2.7.6 → 3.0.0-beta.637.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/dist/cjs/index.cjs +10 -12
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -11
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/matchMedia.cjs +15 -18
- package/dist/cjs/matchMedia.native.cjs +30 -0
- package/dist/cjs/matchMedia.native.js +17 -19
- package/dist/cjs/matchMedia.native.js.map +1 -1
- package/dist/cjs/matchQuery.cjs +115 -132
- package/dist/cjs/matchQuery.native.cjs +145 -0
- package/dist/cjs/matchQuery.native.js +117 -133
- package/dist/cjs/matchQuery.native.js.map +1 -1
- package/dist/cjs/mediaQueryList.cjs +102 -66
- package/dist/cjs/mediaQueryList.native.cjs +180 -0
- package/dist/cjs/mediaQueryList.native.js +158 -110
- package/dist/cjs/mediaQueryList.native.js.map +1 -1
- package/dist/esm/index.js +1 -3
- package/dist/esm/index.mjs +1 -3
- package/dist/esm/index.native.js +1 -3
- package/dist/esm/matchMedia.mjs +1 -0
- package/dist/esm/matchMedia.mjs.map +1 -1
- package/dist/esm/matchMedia.native.js +4 -2
- package/dist/esm/matchMedia.native.js.map +1 -1
- package/dist/esm/matchQuery.mjs +100 -115
- package/dist/esm/matchQuery.mjs.map +1 -1
- package/dist/esm/matchQuery.native.js +102 -117
- package/dist/esm/matchQuery.native.js.map +1 -1
- package/dist/esm/mediaQueryList.mjs +90 -49
- package/dist/esm/mediaQueryList.mjs.map +1 -1
- package/dist/esm/mediaQueryList.native.js +146 -94
- package/dist/esm/mediaQueryList.native.js.map +1 -1
- package/package.json +7 -4
- package/src/index.ts +0 -1
- package/src/mediaQueryList.ts +58 -3
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +2 -2
- package/types/mediaQueryList.d.ts +2 -2
- package/types/mediaQueryList.d.ts.map +2 -2
- package/dist/cjs/createMedia.cjs +0 -33
- package/dist/cjs/createMedia.native.js +0 -36
- package/dist/cjs/createMedia.native.js.map +0 -1
- package/dist/esm/createMedia.mjs +0 -8
- package/dist/esm/createMedia.mjs.map +0 -1
- package/dist/esm/createMedia.native.js +0 -8
- package/dist/esm/createMedia.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/src/createMedia.ts +0 -19
- package/types/createMedia.d.ts +0 -10
- package/types/createMedia.d.ts.map +0 -11
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
15
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
17
|
var index_exports = {};
|
|
19
18
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./
|
|
21
|
-
__reExport(index_exports, require("./matchMedia.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./matchMedia.cjs"), module.exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./matchMedia.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
var index_exports = {};
|
|
21
20
|
module.exports = __toCommonJS(index_exports);
|
|
22
|
-
__reExport(index_exports, require("./createMedia.native.js"), module.exports);
|
|
23
21
|
__reExport(index_exports, require("./matchMedia.native.js"), module.exports);
|
|
22
|
+
|
|
24
23
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./matchMedia\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,wBAAc,GAAG,OAAO,OAAO"}
|
package/dist/cjs/matchMedia.cjs
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var matchMedia_exports = {};
|
|
24
|
-
__export(matchMedia_exports, {
|
|
25
|
-
matchMedia: () => matchMedia
|
|
26
|
-
});
|
|
23
|
+
__export(matchMedia_exports, { matchMedia: () => matchMedia });
|
|
27
24
|
module.exports = __toCommonJS(matchMedia_exports);
|
|
28
|
-
const matchMedia = globalThis["matchMedia"];
|
|
25
|
+
const matchMedia = globalThis["matchMedia"];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var matchMedia_native_exports = {};
|
|
25
|
+
__export(matchMedia_native_exports, { matchMedia: () => matchMedia });
|
|
26
|
+
module.exports = __toCommonJS(matchMedia_native_exports);
|
|
27
|
+
var import_mediaQueryList = require("./mediaQueryList.native.js");
|
|
28
|
+
var matchMedia = function(query) {
|
|
29
|
+
return new import_mediaQueryList.NativeMediaQueryList(query);
|
|
30
|
+
};
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var matchMedia_native_exports = {};
|
|
26
|
-
__export(matchMedia_native_exports, {
|
|
27
|
-
matchMedia: () => matchMedia
|
|
28
|
-
});
|
|
25
|
+
__export(matchMedia_native_exports, { matchMedia: () => matchMedia });
|
|
29
26
|
module.exports = __toCommonJS(matchMedia_native_exports);
|
|
30
27
|
var import_mediaQueryList = require("./mediaQueryList.native.js");
|
|
31
|
-
var matchMedia = function
|
|
32
|
-
|
|
28
|
+
var matchMedia = function(query) {
|
|
29
|
+
return new import_mediaQueryList.NativeMediaQueryList(query);
|
|
33
30
|
};
|
|
31
|
+
|
|
34
32
|
//# sourceMappingURL=matchMedia.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"matchMedia.native.js","names":[],"sources":["cjs/matchMedia.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar matchMedia_native_exports = {};\n__export(matchMedia_native_exports, {\n matchMedia: () => matchMedia\n});\nmodule.exports = __toCommonJS(matchMedia_native_exports);\nvar import_mediaQueryList = require(\"./mediaQueryList\");\nvar matchMedia = function(query) {\n return new import_mediaQueryList.NativeMediaQueryList(query);\n};\n//# sourceMappingURL=matchMedia.native.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,4BAA4B,CAAC;AACjC,SAAS,2BAA2B,EAClC,kBAAkB,WACpB,CAAC;AACD,OAAO,UAAU,aAAa,yBAAyB;AACvD,IAAI,wBAAwB,QAAQ,4BAAkB;AACtD,IAAI,aAAa,SAAS,OAAO;CAC/B,OAAO,IAAI,sBAAsB,qBAAqB,KAAK;AAC7D"}
|
package/dist/cjs/matchQuery.cjs
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var matchQuery_exports = {};
|
|
24
23
|
__export(matchQuery_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
matchQuery: () => matchQuery,
|
|
25
|
+
parseQuery: () => parseQuery
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(matchQuery_exports);
|
|
29
28
|
const RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s()]+)(?:\s*and)?\s*)?(.+)?/i;
|
|
@@ -32,127 +31,111 @@ const RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/;
|
|
|
32
31
|
const RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/;
|
|
33
32
|
const RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
|
|
34
33
|
function matchQuery(mediaQuery, values) {
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return value === expValue;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
90
|
-
});
|
|
34
|
+
return parseQuery(mediaQuery).some((query) => {
|
|
35
|
+
if (!query) return;
|
|
36
|
+
const inverse = query.inverse;
|
|
37
|
+
const typeMatch = query.type === "all" || values.type === query.type;
|
|
38
|
+
if (typeMatch && inverse || !(typeMatch || inverse)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const expressionsMatch = query.expressions.every((expression) => {
|
|
42
|
+
const feature = expression.feature;
|
|
43
|
+
const modifier = expression.modifier;
|
|
44
|
+
let expValue = expression.value;
|
|
45
|
+
let value = values[feature];
|
|
46
|
+
if (!value) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
switch (feature) {
|
|
50
|
+
case "orientation":
|
|
51
|
+
case "scan": return value.toLowerCase() === expValue.toLowerCase();
|
|
52
|
+
case "width":
|
|
53
|
+
case "height":
|
|
54
|
+
case "device-width":
|
|
55
|
+
case "device-height":
|
|
56
|
+
expValue = toPx(expValue);
|
|
57
|
+
value = toPx(value);
|
|
58
|
+
break;
|
|
59
|
+
case "resolution":
|
|
60
|
+
expValue = toDpi(expValue);
|
|
61
|
+
value = toDpi(value);
|
|
62
|
+
break;
|
|
63
|
+
case "aspect-ratio":
|
|
64
|
+
case "device-aspect-ratio":
|
|
65
|
+
case "device-pixel-ratio":
|
|
66
|
+
expValue = toDecimal(expValue);
|
|
67
|
+
value = toDecimal(value);
|
|
68
|
+
break;
|
|
69
|
+
case "grid":
|
|
70
|
+
case "color":
|
|
71
|
+
case "color-index":
|
|
72
|
+
case "monochrome":
|
|
73
|
+
expValue = Number.parseInt(expValue, 10) || 1;
|
|
74
|
+
value = Number.parseInt(value, 10) || 0;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
switch (modifier) {
|
|
78
|
+
case "min": return value >= expValue;
|
|
79
|
+
case "max": return value <= expValue;
|
|
80
|
+
default: return value === expValue;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
84
|
+
});
|
|
91
85
|
}
|
|
92
86
|
function parseQuery(mediaQuery) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
return mediaQuery.split(",").map((query) => {
|
|
88
|
+
query = query.trim();
|
|
89
|
+
const captures = query.match(RE_MEDIA_QUERY);
|
|
90
|
+
if (!captures) return null;
|
|
91
|
+
const modifier = captures[1];
|
|
92
|
+
const type = captures[2];
|
|
93
|
+
const expressionsCapture = captures[3] || "";
|
|
94
|
+
const expressions = expressionsCapture.match(/\([^)]+\)/g) || [];
|
|
95
|
+
return {
|
|
96
|
+
inverse: !!modifier && modifier.toLowerCase() === "not",
|
|
97
|
+
type: type ? type.toLowerCase() : "all",
|
|
98
|
+
expressions: expressions.map((expression) => {
|
|
99
|
+
const captures2 = expression.match(RE_MQ_EXPRESSION);
|
|
100
|
+
const feature = captures2[1].toLowerCase().match(RE_MQ_FEATURE);
|
|
101
|
+
return {
|
|
102
|
+
modifier: feature[1],
|
|
103
|
+
feature: feature[2],
|
|
104
|
+
value: captures2[2]
|
|
105
|
+
};
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
});
|
|
115
109
|
}
|
|
116
110
|
function toDecimal(ratio) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
111
|
+
let decimal = Number(ratio);
|
|
112
|
+
let numbers;
|
|
113
|
+
if (!decimal) {
|
|
114
|
+
numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
|
|
115
|
+
decimal = numbers[1] / numbers[2];
|
|
116
|
+
}
|
|
117
|
+
return decimal;
|
|
124
118
|
}
|
|
125
119
|
function toDpi(resolution) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
default:
|
|
134
|
-
return value;
|
|
135
|
-
}
|
|
120
|
+
const value = Number.parseFloat(resolution);
|
|
121
|
+
const units = String(resolution).match(RE_RESOLUTION_UNIT)?.[1];
|
|
122
|
+
switch (units) {
|
|
123
|
+
case "dpcm": return value / 2.54;
|
|
124
|
+
case "dppx": return value * 96;
|
|
125
|
+
default: return value;
|
|
126
|
+
}
|
|
136
127
|
}
|
|
137
128
|
function toPx(length) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
case "pt":
|
|
152
|
-
return value * 72;
|
|
153
|
-
case "pc":
|
|
154
|
-
return value * 72 / 12;
|
|
155
|
-
default:
|
|
156
|
-
return value;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
129
|
+
const value = Number.parseFloat(length);
|
|
130
|
+
const units = String(length).match(RE_LENGTH_UNIT)?.[1];
|
|
131
|
+
switch (units) {
|
|
132
|
+
case "em": return value * 16;
|
|
133
|
+
case "rem": return value * 16;
|
|
134
|
+
case "cm": return value * 96 / 2.54;
|
|
135
|
+
case "mm": return value * 96 / 2.54 / 10;
|
|
136
|
+
case "in": return value * 96;
|
|
137
|
+
case "pt": return value * 72;
|
|
138
|
+
case "pc": return value * 72 / 12;
|
|
139
|
+
default: return value;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var matchQuery_exports = {};
|
|
25
|
+
__export(matchQuery_exports, {
|
|
26
|
+
matchQuery: () => matchQuery,
|
|
27
|
+
parseQuery: () => parseQuery
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(matchQuery_exports);
|
|
30
|
+
var RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s()]+)(?:\s*and)?\s*)?(.+)?/i;
|
|
31
|
+
var RE_MQ_EXPRESSION = /\(\s*([^\s:)]+)\s*(?::\s*([^\s)]+))?\s*\)/;
|
|
32
|
+
var RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/;
|
|
33
|
+
var RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/;
|
|
34
|
+
var RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
|
|
35
|
+
function matchQuery(mediaQuery, values) {
|
|
36
|
+
return parseQuery(mediaQuery).some(function(query) {
|
|
37
|
+
if (!query) return;
|
|
38
|
+
var inverse = query.inverse;
|
|
39
|
+
var typeMatch = query.type === "all" || values.type === query.type;
|
|
40
|
+
if (typeMatch && inverse || !(typeMatch || inverse)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
var expressionsMatch = query.expressions.every(function(expression) {
|
|
44
|
+
var feature = expression.feature;
|
|
45
|
+
var modifier = expression.modifier;
|
|
46
|
+
var expValue = expression.value;
|
|
47
|
+
var value = values[feature];
|
|
48
|
+
if (!value) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
switch (feature) {
|
|
52
|
+
case "orientation":
|
|
53
|
+
case "scan": return value.toLowerCase() === expValue.toLowerCase();
|
|
54
|
+
case "width":
|
|
55
|
+
case "height":
|
|
56
|
+
case "device-width":
|
|
57
|
+
case "device-height":
|
|
58
|
+
expValue = toPx(expValue);
|
|
59
|
+
value = toPx(value);
|
|
60
|
+
break;
|
|
61
|
+
case "resolution":
|
|
62
|
+
expValue = toDpi(expValue);
|
|
63
|
+
value = toDpi(value);
|
|
64
|
+
break;
|
|
65
|
+
case "aspect-ratio":
|
|
66
|
+
case "device-aspect-ratio":
|
|
67
|
+
case "device-pixel-ratio":
|
|
68
|
+
expValue = toDecimal(expValue);
|
|
69
|
+
value = toDecimal(value);
|
|
70
|
+
break;
|
|
71
|
+
case "grid":
|
|
72
|
+
case "color":
|
|
73
|
+
case "color-index":
|
|
74
|
+
case "monochrome":
|
|
75
|
+
expValue = Number.parseInt(expValue, 10) || 1;
|
|
76
|
+
value = Number.parseInt(value, 10) || 0;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
switch (modifier) {
|
|
80
|
+
case "min": return value >= expValue;
|
|
81
|
+
case "max": return value <= expValue;
|
|
82
|
+
default: return value === expValue;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function parseQuery(mediaQuery) {
|
|
89
|
+
return mediaQuery.split(",").map(function(query) {
|
|
90
|
+
query = query.trim();
|
|
91
|
+
var captures = query.match(RE_MEDIA_QUERY);
|
|
92
|
+
if (!captures) return null;
|
|
93
|
+
var modifier = captures[1];
|
|
94
|
+
var type = captures[2];
|
|
95
|
+
var expressionsCapture = captures[3] || "";
|
|
96
|
+
var expressions = expressionsCapture.match(/\([^)]+\)/g) || [];
|
|
97
|
+
return {
|
|
98
|
+
inverse: !!modifier && modifier.toLowerCase() === "not",
|
|
99
|
+
type: type ? type.toLowerCase() : "all",
|
|
100
|
+
expressions: expressions.map(function(expression) {
|
|
101
|
+
var captures2 = expression.match(RE_MQ_EXPRESSION);
|
|
102
|
+
var feature = captures2[1].toLowerCase().match(RE_MQ_FEATURE);
|
|
103
|
+
return {
|
|
104
|
+
modifier: feature[1],
|
|
105
|
+
feature: feature[2],
|
|
106
|
+
value: captures2[2]
|
|
107
|
+
};
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function toDecimal(ratio) {
|
|
113
|
+
var decimal = Number(ratio);
|
|
114
|
+
var numbers;
|
|
115
|
+
if (!decimal) {
|
|
116
|
+
numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
|
|
117
|
+
decimal = numbers[1] / numbers[2];
|
|
118
|
+
}
|
|
119
|
+
return decimal;
|
|
120
|
+
}
|
|
121
|
+
function toDpi(resolution) {
|
|
122
|
+
var _String_match;
|
|
123
|
+
var value = Number.parseFloat(resolution);
|
|
124
|
+
var units = (_String_match = String(resolution).match(RE_RESOLUTION_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];
|
|
125
|
+
switch (units) {
|
|
126
|
+
case "dpcm": return value / 2.54;
|
|
127
|
+
case "dppx": return value * 96;
|
|
128
|
+
default: return value;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function toPx(length) {
|
|
132
|
+
var _String_match;
|
|
133
|
+
var value = Number.parseFloat(length);
|
|
134
|
+
var units = (_String_match = String(length).match(RE_LENGTH_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];
|
|
135
|
+
switch (units) {
|
|
136
|
+
case "em": return value * 16;
|
|
137
|
+
case "rem": return value * 16;
|
|
138
|
+
case "cm": return value * 96 / 2.54;
|
|
139
|
+
case "mm": return value * 96 / 2.54 / 10;
|
|
140
|
+
case "in": return value * 96;
|
|
141
|
+
case "pt": return value * 72;
|
|
142
|
+
case "pc": return value * 72 / 12;
|
|
143
|
+
default: return value;
|
|
144
|
+
}
|
|
145
|
+
}
|