@tamagui/react-native-media-driver 1.116.1 → 1.116.3
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/createMedia.js +24 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/matchMedia.js +21 -0
- package/dist/cjs/matchQuery.js +127 -0
- package/dist/cjs/mediaQueryList.js +64 -0
- package/package.json +3 -3
- package/dist/cjs/matchMedia.native.cjs +0 -27
- package/dist/cjs/matchMedia.native.cjs.map +0 -6
- /package/dist/cjs/{createMedia.cjs.map → createMedia.js.map} +0 -0
- /package/dist/cjs/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/{matchMedia.cjs.map → matchMedia.js.map} +0 -0
- /package/dist/cjs/{matchQuery.cjs.map → matchQuery.js.map} +0 -0
- /package/dist/cjs/{mediaQueryList.cjs.map → mediaQueryList.js.map} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var createMedia_exports = {};
|
|
16
|
+
__export(createMedia_exports, {
|
|
17
|
+
createMedia: () => createMedia
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(createMedia_exports);
|
|
20
|
+
var import_web = require("@tamagui/web"), import_matchMedia = require("./matchMedia");
|
|
21
|
+
function createMedia(media) {
|
|
22
|
+
return (0, import_web.setupMatchMedia)(import_matchMedia.matchMedia), media;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=createMedia.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
return to;
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
+
var src_exports = {};
|
|
13
|
+
module.exports = __toCommonJS(src_exports);
|
|
14
|
+
__reExport(src_exports, require("./createMedia"), module.exports);
|
|
15
|
+
__reExport(src_exports, require("./matchMedia"), module.exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var matchMedia_exports = {};
|
|
16
|
+
__export(matchMedia_exports, {
|
|
17
|
+
matchMedia: () => matchMedia
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(matchMedia_exports);
|
|
20
|
+
const matchMedia = globalThis.matchMedia;
|
|
21
|
+
//# sourceMappingURL=matchMedia.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var matchQuery_exports = {};
|
|
16
|
+
__export(matchQuery_exports, {
|
|
17
|
+
matchQuery: () => matchQuery,
|
|
18
|
+
parseQuery: () => parseQuery
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(matchQuery_exports);
|
|
21
|
+
const RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i, RE_MQ_EXPRESSION = /\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/, RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/, RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/, RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
|
|
22
|
+
function matchQuery(mediaQuery, values) {
|
|
23
|
+
return parseQuery(mediaQuery).some((query) => {
|
|
24
|
+
if (!query) return;
|
|
25
|
+
const inverse = query.inverse, typeMatch = query.type === "all" || values.type === query.type;
|
|
26
|
+
if (typeMatch && inverse || !(typeMatch || inverse))
|
|
27
|
+
return !1;
|
|
28
|
+
const expressionsMatch = query.expressions.every((expression) => {
|
|
29
|
+
const feature = expression.feature, modifier = expression.modifier;
|
|
30
|
+
let expValue = expression.value, value = values[feature];
|
|
31
|
+
if (!value)
|
|
32
|
+
return !1;
|
|
33
|
+
switch (feature) {
|
|
34
|
+
case "orientation":
|
|
35
|
+
case "scan":
|
|
36
|
+
return value.toLowerCase() === expValue.toLowerCase();
|
|
37
|
+
case "width":
|
|
38
|
+
case "height":
|
|
39
|
+
case "device-width":
|
|
40
|
+
case "device-height":
|
|
41
|
+
expValue = toPx(expValue), value = toPx(value);
|
|
42
|
+
break;
|
|
43
|
+
case "resolution":
|
|
44
|
+
expValue = toDpi(expValue), value = toDpi(value);
|
|
45
|
+
break;
|
|
46
|
+
case "aspect-ratio":
|
|
47
|
+
case "device-aspect-ratio":
|
|
48
|
+
case /* Deprecated */
|
|
49
|
+
"device-pixel-ratio":
|
|
50
|
+
expValue = toDecimal(expValue), value = toDecimal(value);
|
|
51
|
+
break;
|
|
52
|
+
case "grid":
|
|
53
|
+
case "color":
|
|
54
|
+
case "color-index":
|
|
55
|
+
case "monochrome":
|
|
56
|
+
expValue = parseInt(expValue, 10) || 1, value = parseInt(value, 10) || 0;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
switch (modifier) {
|
|
60
|
+
case "min":
|
|
61
|
+
return value >= expValue;
|
|
62
|
+
case "max":
|
|
63
|
+
return value <= expValue;
|
|
64
|
+
default:
|
|
65
|
+
return value === expValue;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function parseQuery(mediaQuery) {
|
|
72
|
+
return mediaQuery.split(",").map(function(query) {
|
|
73
|
+
query = query.trim();
|
|
74
|
+
const captures = query.match(RE_MEDIA_QUERY);
|
|
75
|
+
if (!captures) return null;
|
|
76
|
+
const modifier = captures[1], type = captures[2], expressions = (captures[3] || "").match(/\([^\)]+\)/g) || [];
|
|
77
|
+
return {
|
|
78
|
+
inverse: !!modifier && modifier.toLowerCase() === "not",
|
|
79
|
+
type: type ? type.toLowerCase() : "all",
|
|
80
|
+
expressions: expressions.map(function(expression) {
|
|
81
|
+
var captures2 = expression.match(RE_MQ_EXPRESSION), feature = captures2[1].toLowerCase().match(RE_MQ_FEATURE);
|
|
82
|
+
return {
|
|
83
|
+
modifier: feature[1],
|
|
84
|
+
feature: feature[2],
|
|
85
|
+
value: captures2[2]
|
|
86
|
+
};
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function toDecimal(ratio) {
|
|
92
|
+
var decimal = Number(ratio), numbers;
|
|
93
|
+
return decimal || (numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/), decimal = numbers[1] / numbers[2]), decimal;
|
|
94
|
+
}
|
|
95
|
+
function toDpi(resolution) {
|
|
96
|
+
const value = parseFloat(resolution);
|
|
97
|
+
switch (String(resolution).match(RE_RESOLUTION_UNIT)?.[1]) {
|
|
98
|
+
case "dpcm":
|
|
99
|
+
return value / 2.54;
|
|
100
|
+
case "dppx":
|
|
101
|
+
return value * 96;
|
|
102
|
+
default:
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function toPx(length) {
|
|
107
|
+
const value = parseFloat(length);
|
|
108
|
+
switch (String(length).match(RE_LENGTH_UNIT)?.[1]) {
|
|
109
|
+
case "em":
|
|
110
|
+
return value * 16;
|
|
111
|
+
case "rem":
|
|
112
|
+
return value * 16;
|
|
113
|
+
case "cm":
|
|
114
|
+
return value * 96 / 2.54;
|
|
115
|
+
case "mm":
|
|
116
|
+
return value * 96 / 2.54 / 10;
|
|
117
|
+
case "in":
|
|
118
|
+
return value * 96;
|
|
119
|
+
case "pt":
|
|
120
|
+
return value * 72;
|
|
121
|
+
case "pc":
|
|
122
|
+
return value * 72 / 12;
|
|
123
|
+
default:
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=matchQuery.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var mediaQueryList_exports = {};
|
|
16
|
+
__export(mediaQueryList_exports, {
|
|
17
|
+
NativeMediaQueryList: () => NativeMediaQueryList
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(mediaQueryList_exports);
|
|
20
|
+
var import_react_native = require("react-native-web"), import_matchQuery = require("./matchQuery");
|
|
21
|
+
class NativeMediaQueryList {
|
|
22
|
+
constructor(query) {
|
|
23
|
+
this.query = query;
|
|
24
|
+
this.notify(), import_react_native.Dimensions.addEventListener("change", () => {
|
|
25
|
+
this.notify();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
listeners = [];
|
|
29
|
+
get orientation() {
|
|
30
|
+
const windowDimensions = import_react_native.Dimensions.get("window");
|
|
31
|
+
return windowDimensions.height > windowDimensions.width ? "portrait" : "landscape";
|
|
32
|
+
}
|
|
33
|
+
notify() {
|
|
34
|
+
this.listeners.forEach((listener) => {
|
|
35
|
+
listener(this.orientation);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
addListener(listener) {
|
|
39
|
+
this.listeners.push(listener);
|
|
40
|
+
}
|
|
41
|
+
removeListener(listener) {
|
|
42
|
+
const index = this.listeners.indexOf(listener);
|
|
43
|
+
index !== -1 && this.listeners.splice(index, 1);
|
|
44
|
+
}
|
|
45
|
+
match(query, { width, height }) {
|
|
46
|
+
return (0, import_matchQuery.matchQuery)(query, {
|
|
47
|
+
type: "screen",
|
|
48
|
+
orientation: height > width ? "portrait" : "landscape",
|
|
49
|
+
"device-width": width,
|
|
50
|
+
"device-height": height
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
get matches() {
|
|
54
|
+
const windowDimensions = import_react_native.Dimensions.get("window");
|
|
55
|
+
return (0, import_matchQuery.matchQuery)(this.query, {
|
|
56
|
+
type: "screen",
|
|
57
|
+
orientation: this.orientation,
|
|
58
|
+
...windowDimensions,
|
|
59
|
+
"device-width": windowDimensions.width,
|
|
60
|
+
"device-height": windowDimensions.height
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=mediaQueryList.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/react-native-media-driver",
|
|
3
|
-
"version": "1.116.
|
|
3
|
+
"version": "1.116.3",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": true,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tamagui/web": "1.116.
|
|
27
|
+
"@tamagui/web": "1.116.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tamagui/build": "1.116.
|
|
30
|
+
"@tamagui/build": "1.116.3",
|
|
31
31
|
"react-native": "0.74.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: !0
|
|
9
|
-
});
|
|
10
|
-
},
|
|
11
|
-
__copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
-
get: () => from[key],
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value: !0
|
|
20
|
-
}), mod);
|
|
21
|
-
var matchMedia_native_exports = {};
|
|
22
|
-
__export(matchMedia_native_exports, {
|
|
23
|
-
matchMedia: () => matchMedia
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(matchMedia_native_exports);
|
|
26
|
-
var import_mediaQueryList = require("./mediaQueryList.cjs");
|
|
27
|
-
const matchMedia = query => new import_mediaQueryList.NativeMediaQueryList(query);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|