@tamagui/react-native-media-driver 2.7.7 → 3.0.0-beta.1093.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 +9 -12
- package/dist/cjs/index.native.cjs +20 -0
- package/dist/cjs/index.native.js +9 -11
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/matchMedia.cjs +14 -18
- package/dist/cjs/matchMedia.native.cjs +29 -0
- package/dist/cjs/matchMedia.native.js +16 -19
- package/dist/cjs/matchMedia.native.js.map +1 -1
- package/dist/cjs/matchQuery.cjs +114 -132
- package/dist/cjs/matchQuery.native.cjs +144 -0
- package/dist/cjs/matchQuery.native.js +116 -133
- package/dist/cjs/matchQuery.native.js.map +1 -1
- package/dist/cjs/mediaQueryList.native.cjs +179 -0
- package/dist/cjs/mediaQueryList.native.js +159 -112
- 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.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/matchMedia.native.ts +1 -1
- package/src/mediaQueryList.native.ts +115 -0
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +2 -2
- package/types/matchMedia.native.d.ts.map +1 -1
- package/types/{mediaQueryList.d.ts → mediaQueryList.native.d.ts} +3 -3
- package/types/mediaQueryList.native.d.ts.map +11 -0
- 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/cjs/mediaQueryList.cjs +0 -78
- 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/dist/esm/mediaQueryList.mjs +0 -53
- package/dist/esm/mediaQueryList.mjs.map +0 -1
- package/src/createMedia.ts +0 -19
- package/src/mediaQueryList.ts +0 -60
- package/types/createMedia.d.ts +0 -10
- package/types/createMedia.d.ts.map +0 -11
- package/types/mediaQueryList.d.ts.map +0 -11
|
@@ -4,131 +4,116 @@ var RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/;
|
|
|
4
4
|
var RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/;
|
|
5
5
|
var RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
|
|
6
6
|
function matchQuery(mediaQuery, values) {
|
|
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
|
-
return value === expValue;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
62
|
-
});
|
|
7
|
+
return parseQuery(mediaQuery).some(function(query) {
|
|
8
|
+
if (!query) return;
|
|
9
|
+
var inverse = query.inverse;
|
|
10
|
+
var typeMatch = query.type === "all" || values.type === query.type;
|
|
11
|
+
if (typeMatch && inverse || !(typeMatch || inverse)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
var expressionsMatch = query.expressions.every(function(expression) {
|
|
15
|
+
var feature = expression.feature;
|
|
16
|
+
var modifier = expression.modifier;
|
|
17
|
+
var expValue = expression.value;
|
|
18
|
+
var value = values[feature];
|
|
19
|
+
if (!value) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
switch (feature) {
|
|
23
|
+
case "orientation":
|
|
24
|
+
case "scan": return value.toLowerCase() === expValue.toLowerCase();
|
|
25
|
+
case "width":
|
|
26
|
+
case "height":
|
|
27
|
+
case "device-width":
|
|
28
|
+
case "device-height":
|
|
29
|
+
expValue = toPx(expValue);
|
|
30
|
+
value = toPx(value);
|
|
31
|
+
break;
|
|
32
|
+
case "resolution":
|
|
33
|
+
expValue = toDpi(expValue);
|
|
34
|
+
value = toDpi(value);
|
|
35
|
+
break;
|
|
36
|
+
case "aspect-ratio":
|
|
37
|
+
case "device-aspect-ratio":
|
|
38
|
+
case "device-pixel-ratio":
|
|
39
|
+
expValue = toDecimal(expValue);
|
|
40
|
+
value = toDecimal(value);
|
|
41
|
+
break;
|
|
42
|
+
case "grid":
|
|
43
|
+
case "color":
|
|
44
|
+
case "color-index":
|
|
45
|
+
case "monochrome":
|
|
46
|
+
expValue = Number.parseInt(expValue, 10) || 1;
|
|
47
|
+
value = Number.parseInt(value, 10) || 0;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
switch (modifier) {
|
|
51
|
+
case "min": return value >= expValue;
|
|
52
|
+
case "max": return value <= expValue;
|
|
53
|
+
default: return value === expValue;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return expressionsMatch && !inverse || !expressionsMatch && inverse;
|
|
57
|
+
});
|
|
63
58
|
}
|
|
64
59
|
function parseQuery(mediaQuery) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
60
|
+
return mediaQuery.split(",").map(function(query) {
|
|
61
|
+
query = query.trim();
|
|
62
|
+
var captures = query.match(RE_MEDIA_QUERY);
|
|
63
|
+
if (!captures) return null;
|
|
64
|
+
var modifier = captures[1];
|
|
65
|
+
var type = captures[2];
|
|
66
|
+
var expressionsCapture = captures[3] || "";
|
|
67
|
+
var expressions = expressionsCapture.match(/\([^)]+\)/g) || [];
|
|
68
|
+
return {
|
|
69
|
+
inverse: !!modifier && modifier.toLowerCase() === "not",
|
|
70
|
+
type: type ? type.toLowerCase() : "all",
|
|
71
|
+
expressions: expressions.map(function(expression) {
|
|
72
|
+
var captures2 = expression.match(RE_MQ_EXPRESSION);
|
|
73
|
+
var feature = captures2[1].toLowerCase().match(RE_MQ_FEATURE);
|
|
74
|
+
return {
|
|
75
|
+
modifier: feature[1],
|
|
76
|
+
feature: feature[2],
|
|
77
|
+
value: captures2[2]
|
|
78
|
+
};
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
});
|
|
87
82
|
}
|
|
88
83
|
function toDecimal(ratio) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
var decimal = Number(ratio);
|
|
85
|
+
var numbers;
|
|
86
|
+
if (!decimal) {
|
|
87
|
+
numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
|
|
88
|
+
decimal = numbers[1] / numbers[2];
|
|
89
|
+
}
|
|
90
|
+
return decimal;
|
|
96
91
|
}
|
|
97
92
|
function toDpi(resolution) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
default:
|
|
107
|
-
return value;
|
|
108
|
-
}
|
|
93
|
+
var _String_match;
|
|
94
|
+
var value = Number.parseFloat(resolution);
|
|
95
|
+
var units = (_String_match = String(resolution).match(RE_RESOLUTION_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];
|
|
96
|
+
switch (units) {
|
|
97
|
+
case "dpcm": return value / 2.54;
|
|
98
|
+
case "dppx": return value * 96;
|
|
99
|
+
default: return value;
|
|
100
|
+
}
|
|
109
101
|
}
|
|
110
102
|
function toPx(length) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return value * 96;
|
|
125
|
-
case "pt":
|
|
126
|
-
return value * 72;
|
|
127
|
-
case "pc":
|
|
128
|
-
return value * 72 / 12;
|
|
129
|
-
default:
|
|
130
|
-
return value;
|
|
131
|
-
}
|
|
103
|
+
var _String_match;
|
|
104
|
+
var value = Number.parseFloat(length);
|
|
105
|
+
var units = (_String_match = String(length).match(RE_LENGTH_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];
|
|
106
|
+
switch (units) {
|
|
107
|
+
case "em": return value * 16;
|
|
108
|
+
case "rem": return value * 16;
|
|
109
|
+
case "cm": return value * 96 / 2.54;
|
|
110
|
+
case "mm": return value * 96 / 2.54 / 10;
|
|
111
|
+
case "in": return value * 96;
|
|
112
|
+
case "pt": return value * 72;
|
|
113
|
+
case "pc": return value * 72 / 12;
|
|
114
|
+
default: return value;
|
|
115
|
+
}
|
|
132
116
|
}
|
|
117
|
+
|
|
133
118
|
export { matchQuery, parseQuery };
|
|
134
119
|
//# sourceMappingURL=matchQuery.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"matchQuery.native.js","names":[],"sources":["esm/matchQuery.native.js"],"sourcesContent":["var RE_MEDIA_QUERY = /(?:(only|not)?\\s*([^\\s()]+)(?:\\s*and)?\\s*)?(.+)?/i;\nvar RE_MQ_EXPRESSION = /\\(\\s*([^\\s:)]+)\\s*(?::\\s*([^\\s)]+))?\\s*\\)/;\nvar RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/;\nvar RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/;\nvar RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;\nfunction matchQuery(mediaQuery, values) {\n return parseQuery(mediaQuery).some(function(query) {\n if (!query) return;\n var inverse = query.inverse;\n var typeMatch = query.type === \"all\" || values.type === query.type;\n if (typeMatch && inverse || !(typeMatch || inverse)) {\n return false;\n }\n var expressionsMatch = query.expressions.every(function(expression) {\n var feature = expression.feature;\n var modifier = expression.modifier;\n var expValue = expression.value;\n var value = values[feature];\n if (!value) {\n return false;\n }\n switch (feature) {\n case \"orientation\":\n case \"scan\":\n return value.toLowerCase() === expValue.toLowerCase();\n case \"width\":\n case \"height\":\n case \"device-width\":\n case \"device-height\":\n expValue = toPx(expValue);\n value = toPx(value);\n break;\n case \"resolution\":\n expValue = toDpi(expValue);\n value = toDpi(value);\n break;\n case \"aspect-ratio\":\n case \"device-aspect-ratio\":\n case /* Deprecated */\n \"device-pixel-ratio\":\n expValue = toDecimal(expValue);\n value = toDecimal(value);\n break;\n case \"grid\":\n case \"color\":\n case \"color-index\":\n case \"monochrome\":\n expValue = Number.parseInt(expValue, 10) || 1;\n value = Number.parseInt(value, 10) || 0;\n break;\n }\n switch (modifier) {\n case \"min\":\n return value >= expValue;\n case \"max\":\n return value <= expValue;\n default:\n return value === expValue;\n }\n });\n return expressionsMatch && !inverse || !expressionsMatch && inverse;\n });\n}\nfunction parseQuery(mediaQuery) {\n return mediaQuery.split(\",\").map(function(query) {\n query = query.trim();\n var captures = query.match(RE_MEDIA_QUERY);\n if (!captures) return null;\n var modifier = captures[1];\n var type = captures[2];\n var expressionsCapture = captures[3] || \"\";\n var expressions = expressionsCapture.match(/\\([^)]+\\)/g) || [];\n return {\n inverse: !!modifier && modifier.toLowerCase() === \"not\",\n type: type ? type.toLowerCase() : \"all\",\n expressions: expressions.map(function(expression) {\n var captures2 = expression.match(RE_MQ_EXPRESSION);\n var feature = captures2[1].toLowerCase().match(RE_MQ_FEATURE);\n return {\n modifier: feature[1],\n feature: feature[2],\n value: captures2[2]\n };\n })\n };\n });\n}\nfunction toDecimal(ratio) {\n var decimal = Number(ratio);\n var numbers;\n if (!decimal) {\n numbers = ratio.match(/^(\\d+)\\s*\\/\\s*(\\d+)$/);\n decimal = numbers[1] / numbers[2];\n }\n return decimal;\n}\nfunction toDpi(resolution) {\n var _String_match;\n var value = Number.parseFloat(resolution);\n var units = (_String_match = String(resolution).match(RE_RESOLUTION_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];\n switch (units) {\n case \"dpcm\":\n return value / 2.54;\n case \"dppx\":\n return value * 96;\n default:\n return value;\n }\n}\nfunction toPx(length) {\n var _String_match;\n var value = Number.parseFloat(length);\n var units = (_String_match = String(length).match(RE_LENGTH_UNIT)) === null || _String_match === void 0 ? void 0 : _String_match[1];\n switch (units) {\n case \"em\":\n return value * 16;\n case \"rem\":\n return value * 16;\n case \"cm\":\n return value * 96 / 2.54;\n case \"mm\":\n return value * 96 / 2.54 / 10;\n case \"in\":\n return value * 96;\n case \"pt\":\n return value * 72;\n case \"pc\":\n return value * 72 / 12;\n default:\n return value;\n }\n}\nexport {\n matchQuery,\n parseQuery\n};\n//# sourceMappingURL=matchQuery.js.map\n"],"mappings":";AAAA,IAAI,iBAAiB;AACrB,IAAI,mBAAmB;AACvB,IAAI,gBAAgB;AACpB,IAAI,iBAAiB;AACrB,IAAI,qBAAqB;AACzB,SAAS,WAAW,YAAY,QAAQ;CACtC,OAAO,WAAW,UAAU,CAAC,CAAC,KAAK,SAAS,OAAO;EACjD,IAAI,CAAC,OAAO;EACZ,IAAI,UAAU,MAAM;EACpB,IAAI,YAAY,MAAM,SAAS,SAAS,OAAO,SAAS,MAAM;EAC9D,IAAI,aAAa,WAAW,EAAE,aAAa,UAAU;GACnD,OAAO;EACT;EACA,IAAI,mBAAmB,MAAM,YAAY,MAAM,SAAS,YAAY;GAClE,IAAI,UAAU,WAAW;GACzB,IAAI,WAAW,WAAW;GAC1B,IAAI,WAAW,WAAW;GAC1B,IAAI,QAAQ,OAAO;GACnB,IAAI,CAAC,OAAO;IACV,OAAO;GACT;GACA,QAAQ,SAAR;IACE,KAAK;IACL,KAAK,QACH,OAAO,MAAM,YAAY,MAAM,SAAS,YAAY;IACtD,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;KACH,WAAW,KAAK,QAAQ;KACxB,QAAQ,KAAK,KAAK;KAClB;IACF,KAAK;KACH,WAAW,MAAM,QAAQ;KACzB,QAAQ,MAAM,KAAK;KACnB;IACF,KAAK;IACL,KAAK;IACL,KACA;KACE,WAAW,UAAU,QAAQ;KAC7B,QAAQ,UAAU,KAAK;KACvB;IACF,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;KACH,WAAW,OAAO,SAAS,UAAU,EAAE,KAAK;KAC5C,QAAQ,OAAO,SAAS,OAAO,EAAE,KAAK;KACtC;GACJ;GACA,QAAQ,UAAR;IACE,KAAK,OACH,OAAO,SAAS;IAClB,KAAK,OACH,OAAO,SAAS;IAClB,SACE,OAAO,UAA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pB,IAAI;CACJ,IAAI,QAAQ,OAAO,WAAW,MAAM;CACpC,IAAI,SAAS,gBAAgB,OAAO,MAAM,CAAC,CAAC,MAAM,cAAc,OAAO,QAAQ,kBAAkB,KAAK,IAAI,KAAK,IAAI,cAAc;CACjI,QAAQ,OAAR;EACE,KAAK,MACH,OAAO,QAAQ;EACjB,KAAK,OACH,OAAO,QAAQ;EACjB,KAAK,MACH,OAAO,QAAQ,KAAK;EACtB,KAAK,MACH,OAAO,QAAQ,KAAK,OAAO;EAC7B,KAAK,MACH,OAAO,QAAQ;EACjB,KAAK,MACH,OAAO,QAAQ;EACjB,KAAK,MACH,OAAO,QAAQ,KAAK;EACtB,SACE,OAAO;CACX;AACF"}
|
|
@@ -1,106 +1,158 @@
|
|
|
1
|
-
import { Dimensions } from "react-native";
|
|
1
|
+
import { AccessibilityInfo, Dimensions } from "react-native";
|
|
2
2
|
import { matchQuery } from "./matchQuery.native.js";
|
|
3
|
+
|
|
3
4
|
function _class_call_check(instance, Constructor) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (!(instance instanceof Constructor)) {
|
|
6
|
+
throw new TypeError("Cannot call a class as a function");
|
|
7
|
+
}
|
|
7
8
|
}
|
|
8
9
|
function _defineProperties(target, props) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
for (var i = 0; i < props.length; i++) {
|
|
11
|
+
var descriptor = props[i];
|
|
12
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
13
|
+
descriptor.configurable = true;
|
|
14
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
15
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
16
|
+
}
|
|
16
17
|
}
|
|
17
18
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
20
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
21
|
+
return Constructor;
|
|
21
22
|
}
|
|
22
23
|
function _define_property(obj, key, value) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
var REDUCED_MOTION_RE = /\(\s*prefers-reduced-motion\s*:\s*([a-z-]+)\s*\)/i;
|
|
37
|
+
var reducedMotionEnabled = false;
|
|
38
|
+
var reducedMotionInitialized = false;
|
|
39
|
+
var reducedMotionListeners = /* @__PURE__ */ new Set();
|
|
40
|
+
function ensureReducedMotionSubscription() {
|
|
41
|
+
var _AccessibilityInfo_isReduceMotionEnabled, _AccessibilityInfo_addEventListener;
|
|
42
|
+
if (reducedMotionInitialized) return;
|
|
43
|
+
reducedMotionInitialized = true;
|
|
44
|
+
(_AccessibilityInfo_isReduceMotionEnabled = AccessibilityInfo.isReduceMotionEnabled) === null || _AccessibilityInfo_isReduceMotionEnabled === void 0 ? void 0 : _AccessibilityInfo_isReduceMotionEnabled.call(AccessibilityInfo).then(function(value) {
|
|
45
|
+
if (value !== reducedMotionEnabled) {
|
|
46
|
+
reducedMotionEnabled = value;
|
|
47
|
+
reducedMotionListeners.forEach(function(cb) {
|
|
48
|
+
return cb();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}).catch(function() {});
|
|
52
|
+
(_AccessibilityInfo_addEventListener = AccessibilityInfo.addEventListener) === null || _AccessibilityInfo_addEventListener === void 0 ? void 0 : _AccessibilityInfo_addEventListener.call(AccessibilityInfo, "reduceMotionChanged", function(value) {
|
|
53
|
+
if (value === reducedMotionEnabled) return;
|
|
54
|
+
reducedMotionEnabled = value;
|
|
55
|
+
reducedMotionListeners.forEach(function(cb) {
|
|
56
|
+
return cb();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
34
59
|
}
|
|
35
|
-
var NativeMediaQueryList = /* @__PURE__ */
|
|
36
|
-
|
|
60
|
+
var NativeMediaQueryList = /* @__PURE__ */ (function() {
|
|
61
|
+
"use strict";
|
|
62
|
+
function NativeMediaQueryList2(query) {
|
|
63
|
+
var _this = this;
|
|
64
|
+
_class_call_check(this, NativeMediaQueryList2);
|
|
65
|
+
_define_property(this, "query", void 0);
|
|
66
|
+
_define_property(this, "listeners", void 0);
|
|
67
|
+
_define_property(this, "reducedMotionExpected", void 0);
|
|
68
|
+
this.query = query;
|
|
69
|
+
this.listeners = [];
|
|
70
|
+
this.reducedMotionExpected = null;
|
|
71
|
+
var reducedMotionMatch = query.match(REDUCED_MOTION_RE);
|
|
72
|
+
if (reducedMotionMatch) {
|
|
73
|
+
this.reducedMotionExpected = reducedMotionMatch[1];
|
|
74
|
+
ensureReducedMotionSubscription();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.notify();
|
|
78
|
+
Dimensions.addEventListener("change", function() {
|
|
79
|
+
_this.notify();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
_create_class(NativeMediaQueryList2, [
|
|
83
|
+
{
|
|
84
|
+
key: "orientation",
|
|
85
|
+
get: function get() {
|
|
86
|
+
var windowDimensions = Dimensions.get("window");
|
|
87
|
+
return windowDimensions.height > windowDimensions.width ? "portrait" : "landscape";
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: "notify",
|
|
92
|
+
value: function notify() {
|
|
93
|
+
this.listeners.forEach(function(listener) {
|
|
94
|
+
listener();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: "addListener",
|
|
100
|
+
value: function addListener(listener) {
|
|
101
|
+
if (this.reducedMotionExpected) {
|
|
102
|
+
reducedMotionListeners.add(listener);
|
|
103
|
+
this.listeners.push(listener);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.listeners.push(listener);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
key: "removeListener",
|
|
111
|
+
value: function removeListener(listener) {
|
|
112
|
+
if (this.reducedMotionExpected) {
|
|
113
|
+
reducedMotionListeners.delete(listener);
|
|
114
|
+
}
|
|
115
|
+
var index = this.listeners.indexOf(listener);
|
|
116
|
+
if (index !== -1) this.listeners.splice(index, 1);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: "match",
|
|
121
|
+
value: function match(query, param) {
|
|
122
|
+
var { width, height } = param;
|
|
123
|
+
var reducedMotionMatch = query.match(REDUCED_MOTION_RE);
|
|
124
|
+
if (reducedMotionMatch) {
|
|
125
|
+
var expected = reducedMotionMatch[1];
|
|
126
|
+
return expected === "reduce" ? reducedMotionEnabled : !reducedMotionEnabled;
|
|
127
|
+
}
|
|
128
|
+
return matchQuery(query, {
|
|
129
|
+
type: "screen",
|
|
130
|
+
orientation: height > width ? "portrait" : "landscape",
|
|
131
|
+
"device-width": width,
|
|
132
|
+
"device-height": height
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: "matches",
|
|
138
|
+
get: function get() {
|
|
139
|
+
if (this.reducedMotionExpected) {
|
|
140
|
+
return this.reducedMotionExpected === "reduce" ? reducedMotionEnabled : !reducedMotionEnabled;
|
|
141
|
+
}
|
|
142
|
+
var windowDimensions = Dimensions.get("window");
|
|
143
|
+
var matches = matchQuery(this.query, {
|
|
144
|
+
type: "screen",
|
|
145
|
+
orientation: this.orientation,
|
|
146
|
+
...windowDimensions,
|
|
147
|
+
"device-width": windowDimensions.width,
|
|
148
|
+
"device-height": windowDimensions.height
|
|
149
|
+
});
|
|
150
|
+
return matches;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
]);
|
|
154
|
+
return NativeMediaQueryList2;
|
|
155
|
+
})();
|
|
37
156
|
|
|
38
|
-
function NativeMediaQueryList2(query) {
|
|
39
|
-
var _this = this;
|
|
40
|
-
_class_call_check(this, NativeMediaQueryList2);
|
|
41
|
-
_define_property(this, "query", void 0);
|
|
42
|
-
_define_property(this, "listeners", void 0);
|
|
43
|
-
this.query = query;
|
|
44
|
-
this.listeners = [];
|
|
45
|
-
this.notify();
|
|
46
|
-
Dimensions.addEventListener("change", function () {
|
|
47
|
-
_this.notify();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
_create_class(NativeMediaQueryList2, [{
|
|
51
|
-
key: "orientation",
|
|
52
|
-
get: function get() {
|
|
53
|
-
var windowDimensions = Dimensions.get("window");
|
|
54
|
-
return windowDimensions.height > windowDimensions.width ? "portrait" : "landscape";
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "notify",
|
|
58
|
-
value: function notify() {
|
|
59
|
-
var _this = this;
|
|
60
|
-
this.listeners.forEach(function (listener) {
|
|
61
|
-
listener(_this.orientation);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "addListener",
|
|
66
|
-
value: function addListener(listener) {
|
|
67
|
-
this.listeners.push(listener);
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "removeListener",
|
|
71
|
-
value: function removeListener(listener) {
|
|
72
|
-
var index = this.listeners.indexOf(listener);
|
|
73
|
-
if (index !== -1) this.listeners.splice(index, 1);
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "match",
|
|
77
|
-
value: function match(query, param) {
|
|
78
|
-
var {
|
|
79
|
-
width,
|
|
80
|
-
height
|
|
81
|
-
} = param;
|
|
82
|
-
return matchQuery(query, {
|
|
83
|
-
type: "screen",
|
|
84
|
-
orientation: height > width ? "portrait" : "landscape",
|
|
85
|
-
"device-width": width,
|
|
86
|
-
"device-height": height
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "matches",
|
|
91
|
-
get: function get() {
|
|
92
|
-
var windowDimensions = Dimensions.get("window");
|
|
93
|
-
var matches = matchQuery(this.query, {
|
|
94
|
-
type: "screen",
|
|
95
|
-
orientation: this.orientation,
|
|
96
|
-
...windowDimensions,
|
|
97
|
-
"device-width": windowDimensions.width,
|
|
98
|
-
"device-height": windowDimensions.height
|
|
99
|
-
});
|
|
100
|
-
return matches;
|
|
101
|
-
}
|
|
102
|
-
}]);
|
|
103
|
-
return NativeMediaQueryList2;
|
|
104
|
-
}();
|
|
105
157
|
export { NativeMediaQueryList };
|
|
106
158
|
//# sourceMappingURL=mediaQueryList.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mediaQueryList.native.js","names":[],"sources":["esm/mediaQueryList.native.js"],"sourcesContent":["import { AccessibilityInfo, Dimensions } from \"react-native\";\nimport { matchQuery } from \"./matchQuery\";\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\nfunction _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nvar REDUCED_MOTION_RE = /\\(\\s*prefers-reduced-motion\\s*:\\s*([a-z-]+)\\s*\\)/i;\nvar reducedMotionEnabled = false;\nvar reducedMotionInitialized = false;\nvar reducedMotionListeners = /* @__PURE__ */ new Set();\nfunction ensureReducedMotionSubscription() {\n var _AccessibilityInfo_isReduceMotionEnabled, _AccessibilityInfo_addEventListener;\n if (reducedMotionInitialized) return;\n reducedMotionInitialized = true;\n (_AccessibilityInfo_isReduceMotionEnabled = AccessibilityInfo.isReduceMotionEnabled) === null || _AccessibilityInfo_isReduceMotionEnabled === void 0 ? void 0 : _AccessibilityInfo_isReduceMotionEnabled.call(AccessibilityInfo).then(function(value) {\n if (value !== reducedMotionEnabled) {\n reducedMotionEnabled = value;\n reducedMotionListeners.forEach(function(cb) {\n return cb();\n });\n }\n }).catch(function() {\n });\n (_AccessibilityInfo_addEventListener = AccessibilityInfo.addEventListener) === null || _AccessibilityInfo_addEventListener === void 0 ? void 0 : _AccessibilityInfo_addEventListener.call(AccessibilityInfo, \"reduceMotionChanged\", function(value) {\n if (value === reducedMotionEnabled) return;\n reducedMotionEnabled = value;\n reducedMotionListeners.forEach(function(cb) {\n return cb();\n });\n });\n}\nvar NativeMediaQueryList = /* @__PURE__ */ (function() {\n \"use strict\";\n function NativeMediaQueryList2(query) {\n var _this = this;\n _class_call_check(this, NativeMediaQueryList2);\n _define_property(this, \"query\", void 0);\n _define_property(this, \"listeners\", void 0);\n _define_property(this, \"reducedMotionExpected\", void 0);\n this.query = query;\n this.listeners = [];\n this.reducedMotionExpected = null;\n var reducedMotionMatch = query.match(REDUCED_MOTION_RE);\n if (reducedMotionMatch) {\n this.reducedMotionExpected = reducedMotionMatch[1];\n ensureReducedMotionSubscription();\n return;\n }\n this.notify();\n Dimensions.addEventListener(\"change\", function() {\n _this.notify();\n });\n }\n _create_class(NativeMediaQueryList2, [\n {\n key: \"orientation\",\n get: function get() {\n var windowDimensions = Dimensions.get(\"window\");\n return windowDimensions.height > windowDimensions.width ? \"portrait\" : \"landscape\";\n }\n },\n {\n key: \"notify\",\n value: function notify() {\n this.listeners.forEach(function(listener) {\n listener();\n });\n }\n },\n {\n key: \"addListener\",\n value: function addListener(listener) {\n if (this.reducedMotionExpected) {\n reducedMotionListeners.add(listener);\n this.listeners.push(listener);\n return;\n }\n this.listeners.push(listener);\n }\n },\n {\n key: \"removeListener\",\n value: function removeListener(listener) {\n if (this.reducedMotionExpected) {\n reducedMotionListeners.delete(listener);\n }\n var index = this.listeners.indexOf(listener);\n if (index !== -1) this.listeners.splice(index, 1);\n }\n },\n {\n key: \"match\",\n value: function match(query, param) {\n var { width, height } = param;\n var reducedMotionMatch = query.match(REDUCED_MOTION_RE);\n if (reducedMotionMatch) {\n var expected = reducedMotionMatch[1];\n return expected === \"reduce\" ? reducedMotionEnabled : !reducedMotionEnabled;\n }\n return matchQuery(query, {\n type: \"screen\",\n orientation: height > width ? \"portrait\" : \"landscape\",\n \"device-width\": width,\n \"device-height\": height\n });\n }\n },\n {\n key: \"matches\",\n get: function get() {\n if (this.reducedMotionExpected) {\n return this.reducedMotionExpected === \"reduce\" ? reducedMotionEnabled : !reducedMotionEnabled;\n }\n var windowDimensions = Dimensions.get(\"window\");\n var matches = matchQuery(this.query, {\n type: \"screen\",\n orientation: this.orientation,\n ...windowDimensions,\n \"device-width\": windowDimensions.width,\n \"device-height\": windowDimensions.height\n });\n return matches;\n }\n }\n ]);\n return NativeMediaQueryList2;\n})();\nexport {\n NativeMediaQueryList\n};\n//# sourceMappingURL=mediaQueryList.native.js.map\n"],"mappings":";;;;AAEA,SAAS,kBAAkB,UAAU,aAAa;CAChD,IAAI,EAAE,oBAAoB,cAAc;EACtC,MAAM,IAAI,UAAU,mCAAmC;CACzD;AACF;AACA,SAAS,kBAAkB,QAAQ,OAAO;CACxC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,IAAI,aAAa,MAAM;EACvB,WAAW,aAAa,WAAW,cAAc;EACjD,WAAW,eA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B;KAClC,OAAO,aAAa,WAAW,uBAAuB,CAAC;IACzD;IACA,OAAO,WAAW,OAAO;KACvB,MAAM;KACN,aAAa,SAAS,QAAQ,aAAa;KAC3C,gBAAgB;KAChB,iBAAiB;IACnB,CAAC;GACH;EACF;EACA;GACE,KAAK;GACL,KAAK,SAAS,MAAM;IAClB,IAAI,KAAK,uBAAuB;KAC9B,OAAO,KAAK,0BAA0B,WAAW,uBAAuB,CAAC;IAC3E;IACA,IAAI,mBAAmB,WAAW,IAAI,QAAQ;IAC9C,IAAI,UAAU,WAAW,KAAK,OAAO;KACnC,MAAM;KACN,aAAa,KAAK;KAClB,GAAG;KACH,gBAAgB,iBAAiB;KACjC,iBAAiB,iBAAiB;IACpC,CAAC;IACD,OAAO;GACT;EACF;CACF,CAAC;CACD,OAAO;AACT,EAAC,CAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/react-native-media-driver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1093.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -35,11 +35,14 @@
|
|
|
35
35
|
"clean:build": "tamagui-build clean:build"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tamagui/web": "
|
|
38
|
+
"@tamagui/web": "3.0.0-beta.1093.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tamagui/build": "
|
|
42
|
-
"react-native": "0.
|
|
41
|
+
"@tamagui/build": "3.0.0-beta.1093.1",
|
|
42
|
+
"react-native": "0.86.2"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react-native-web": "*"
|
|
43
46
|
},
|
|
44
47
|
"repository": {
|
|
45
48
|
"type": "git",
|
package/src/index.ts
CHANGED
package/src/matchMedia.native.ts
CHANGED