react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +40 -0
- package/android/src/main/cxx/cpp-adapter.cpp +108 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +55 -2
- package/cxx/UnistylesRuntime.h +15 -9
- package/ios/UnistylesModule.mm +12 -2
- package/lib/commonjs/common.js +30 -16
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +65 -3
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +15 -16
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/createStyleSheet.js +1 -6
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/hooks/index.js +7 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +11 -8
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/index.js +38 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/index.js +32 -0
- package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/stylesheet.js.map +1 -0
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/commonjs/useStyles.js +10 -20
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +13 -59
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -51
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +36 -68
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +4 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +35 -20
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +28 -17
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +65 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +15 -16
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/createStyleSheet.js +1 -6
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +12 -9
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/plugins/normalizer/index.js +3 -0
- package/lib/module/plugins/normalizer/index.js.map +1 -0
- package/lib/module/plugins/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
- package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/module/useStyles.js +12 -22
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +12 -56
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +4 -6
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +35 -67
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js +3 -3
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +35 -20
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +23 -12
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +1 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/createStyleSheet.d.ts +2 -2
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +51 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -12
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +6 -27
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- package/lib/typescript/src/types/stylesheet.d.ts +40 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +16 -11
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +4 -6
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -14
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +14 -2
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +3 -4
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +19 -16
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +30 -14
- package/src/core/UnistyleRegistry.ts +66 -4
- package/src/core/UnistylesRuntime.ts +18 -20
- package/src/core/index.ts +1 -0
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +11 -9
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +3 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/plugins/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
- package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
- package/src/types/breakpoints.ts +57 -25
- package/src/types/core.ts +9 -43
- package/src/types/index.ts +11 -2
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +18 -13
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +18 -25
- package/src/utils/breakpoints.ts +11 -67
- package/src/utils/index.ts +4 -6
- package/src/utils/mq.ts +31 -84
- package/src/utils/mqParser.ts +5 -5
- package/src/utils/styles.ts +44 -50
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/utils/common.js +0 -25
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/types/mq.js +0 -2
- package/lib/module/utils/common.js +0 -17
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -12
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
- package/src/utils/common.ts +0 -20
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -3,86 +3,40 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.getValueForBreakpoint = void 0;
|
7
7
|
var _core = require("../core");
|
8
|
-
var _common = require("
|
9
|
-
var _common2 = require("../common");
|
8
|
+
var _common = require("../common");
|
10
9
|
var _mqParser = require("./mqParser");
|
11
|
-
const sortAndValidateBreakpoints = breakpoints => {
|
12
|
-
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
13
|
-
const [, value1] = breakpoint1;
|
14
|
-
const [, value2] = breakpoint2;
|
15
|
-
return value1 - value2;
|
16
|
-
});
|
17
|
-
const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
|
18
|
-
const breakpointValues = Object.values(sortedBreakpoints);
|
19
|
-
const [firstBreakpoint] = breakpointValues;
|
20
|
-
if (firstBreakpoint !== 0) {
|
21
|
-
(0, _common.throwError)('first breakpoint must start with 0');
|
22
|
-
}
|
23
|
-
if (breakpointValues.length !== new Set(breakpointValues).size) {
|
24
|
-
(0, _common.throwError)('breakpoint values are duplicated');
|
25
|
-
}
|
26
|
-
return sortedBreakpoints;
|
27
|
-
};
|
28
|
-
exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
|
29
|
-
const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
30
|
-
const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
|
31
|
-
let [, value] = _ref;
|
32
|
-
const minVal = value;
|
33
|
-
const maxVal = otherBreakpoints[index + 1]?.[1];
|
34
|
-
if (!maxVal) {
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
return width >= minVal && width < maxVal;
|
38
|
-
});
|
39
|
-
return key;
|
40
|
-
};
|
41
|
-
exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
|
42
10
|
const getValueForBreakpoint = value => {
|
43
|
-
// the highest priority is for custom media queries
|
44
11
|
const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
|
45
12
|
if (customMediaQueryKey) {
|
46
13
|
return value[customMediaQueryKey];
|
47
14
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
|
52
|
-
|
53
|
-
// if not then we can fall back to horizontal and portrait (mobile only)
|
54
|
-
if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
|
55
|
-
return value[_core.unistyles.runtime.orientation === _common2.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
|
15
|
+
const hasBreakpoints = _core.unistyles.registry.sortedBreakpointPairs.length > 0;
|
16
|
+
if (!hasBreakpoints && _common.isMobile && (_common.ScreenOrientation.Landscape in value || _common.ScreenOrientation.Portrait in value)) {
|
17
|
+
return value[_core.unistyles.runtime.orientation];
|
56
18
|
}
|
57
|
-
|
58
|
-
// let's get the current breakpoint
|
59
19
|
const breakpoint = _core.unistyles.runtime.breakpoint;
|
60
20
|
if (!breakpoint) {
|
61
21
|
return undefined;
|
62
22
|
}
|
63
|
-
|
64
|
-
// if user defined breakpoints, then we look for the valid one
|
65
23
|
const directBreakpoint = value[breakpoint];
|
66
|
-
|
67
|
-
// if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
|
68
24
|
if (directBreakpoint || breakpoint in value) {
|
69
25
|
return directBreakpoint;
|
70
26
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
|
75
|
-
let [key] = _ref2;
|
27
|
+
const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
|
28
|
+
const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
|
29
|
+
let [key] = _ref;
|
76
30
|
return key === breakpoint;
|
77
31
|
});
|
78
|
-
const availableBreakpoints = breakpointPairs.filter((
|
32
|
+
const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
|
33
|
+
let [key] = _ref2;
|
34
|
+
return index < currentBreakpointIndex && key in value;
|
35
|
+
}).map(_ref3 => {
|
79
36
|
let [key] = _ref3;
|
80
|
-
return index < currentBreakpoint && key && key in value;
|
81
|
-
}).map(_ref4 => {
|
82
|
-
let [key] = _ref4;
|
83
37
|
return key;
|
84
38
|
});
|
85
|
-
return
|
39
|
+
return value[availableBreakpoints[availableBreakpoints.length - 1]];
|
86
40
|
};
|
87
41
|
exports.getValueForBreakpoint = getValueForBreakpoint;
|
88
42
|
//# sourceMappingURL=breakpoints.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","_common","
|
1
|
+
{"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","_ref","key","availableBreakpoints","filter","_ref2","index","map","_ref3","exports"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAG,IAAAC,sCAA4B,EACpDC,MAAM,CAACC,OAAO,CAACJ,KAAK,CAAC,EACrBK,eAAS,CAACC,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIN,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMO,cAAc,GAAGH,eAAS,CAACI,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAII,gBAAQ,KAAKC,yBAAiB,CAACC,SAAS,IAAId,KAAK,IAAIa,yBAAiB,CAACE,QAAQ,IAAIf,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACK,eAAS,CAACC,OAAO,CAACU,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGZ,eAAS,CAACC,OAAO,CAACW,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGnB,KAAK,CAACiB,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIjB,KAAM,EAAE;IAC3C,OAAOmB,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGf,eAAS,CAACI,QAAQ,CAACC,qBAAqB;EAChE,MAAMW,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKP,UAAU;EAAA,EAAC;EAE7C,MAAMQ,oBAAoB,GAAGL,eAAe,CACvCM,MAAM,CAAC,CAAAC,KAAA,EAAQC,KAAK;IAAA,IAAZ,CAACJ,GAAG,CAAC,GAAAG,KAAA;IAAA,OAAYC,KAAK,GAAGP,sBAAsB,IAAIG,GAAG,IAAIxB,KAAK;EAAA,EAAC,CACxE6B,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOxB,KAAK,CAACyB,oBAAoB,CAACA,oBAAoB,CAACd,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAoB,OAAA,CAAAhC,qBAAA,GAAAA,qBAAA"}
|
@@ -3,37 +3,6 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
var _exportNames = {
|
7
|
-
normalizeStyles: true,
|
8
|
-
mq: true,
|
9
|
-
MQSymbol: true,
|
10
|
-
getKeyForUnistylesMediaQuery: true,
|
11
|
-
getBreakpointFromScreenWidth: true,
|
12
|
-
sortAndValidateBreakpoints: true,
|
13
|
-
getValueForBreakpoint: true,
|
14
|
-
proxifyFunction: true,
|
15
|
-
parseStyle: true,
|
16
|
-
isServer: true,
|
17
|
-
Orientation: true
|
18
|
-
};
|
19
|
-
Object.defineProperty(exports, "MQSymbol", {
|
20
|
-
enumerable: true,
|
21
|
-
get: function () {
|
22
|
-
return _mq.MQSymbol;
|
23
|
-
}
|
24
|
-
});
|
25
|
-
Object.defineProperty(exports, "Orientation", {
|
26
|
-
enumerable: true,
|
27
|
-
get: function () {
|
28
|
-
return _common.Orientation;
|
29
|
-
}
|
30
|
-
});
|
31
|
-
Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
32
|
-
enumerable: true,
|
33
|
-
get: function () {
|
34
|
-
return _breakpoints.getBreakpointFromScreenWidth;
|
35
|
-
}
|
36
|
-
});
|
37
6
|
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
38
7
|
enumerable: true,
|
39
8
|
get: function () {
|
@@ -46,10 +15,16 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
46
15
|
return _breakpoints.getValueForBreakpoint;
|
47
16
|
}
|
48
17
|
});
|
49
|
-
Object.defineProperty(exports, "
|
18
|
+
Object.defineProperty(exports, "isValidMq", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function () {
|
21
|
+
return _mqParser.isValidMq;
|
22
|
+
}
|
23
|
+
});
|
24
|
+
Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
50
25
|
enumerable: true,
|
51
26
|
get: function () {
|
52
|
-
return
|
27
|
+
return _mqParser.isWithinTheWidthAndHeight;
|
53
28
|
}
|
54
29
|
});
|
55
30
|
Object.defineProperty(exports, "mq", {
|
@@ -58,10 +33,10 @@ Object.defineProperty(exports, "mq", {
|
|
58
33
|
return _mq.mq;
|
59
34
|
}
|
60
35
|
});
|
61
|
-
Object.defineProperty(exports, "
|
36
|
+
Object.defineProperty(exports, "parseMq", {
|
62
37
|
enumerable: true,
|
63
38
|
get: function () {
|
64
|
-
return
|
39
|
+
return _mqParser.parseMq;
|
65
40
|
}
|
66
41
|
});
|
67
42
|
Object.defineProperty(exports, "parseStyle", {
|
@@ -76,28 +51,15 @@ Object.defineProperty(exports, "proxifyFunction", {
|
|
76
51
|
return _styles.proxifyFunction;
|
77
52
|
}
|
78
53
|
});
|
79
|
-
Object.defineProperty(exports, "
|
54
|
+
Object.defineProperty(exports, "withPlugins", {
|
80
55
|
enumerable: true,
|
81
56
|
get: function () {
|
82
|
-
return
|
57
|
+
return _withPlugins.withPlugins;
|
83
58
|
}
|
84
59
|
});
|
85
|
-
var _normalizeStyles = require("./normalizeStyles");
|
86
|
-
var _normalizer = require("./normalizer");
|
87
|
-
Object.keys(_normalizer).forEach(function (key) {
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
89
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
90
|
-
if (key in exports && exports[key] === _normalizer[key]) return;
|
91
|
-
Object.defineProperty(exports, key, {
|
92
|
-
enumerable: true,
|
93
|
-
get: function () {
|
94
|
-
return _normalizer[key];
|
95
|
-
}
|
96
|
-
});
|
97
|
-
});
|
98
60
|
var _mq = require("./mq");
|
99
61
|
var _mqParser = require("./mqParser");
|
100
62
|
var _breakpoints = require("./breakpoints");
|
101
63
|
var _styles = require("./styles");
|
102
|
-
var
|
64
|
+
var _withPlugins = require("./withPlugins");
|
103
65
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA"}
|
package/lib/commonjs/utils/mq.js
CHANGED
@@ -3,17 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.mq =
|
6
|
+
exports.mq = void 0;
|
7
7
|
var _core = require("../core");
|
8
|
-
const MQSymbol = exports.MQSymbol = Symbol('unistyles-mq');
|
9
|
-
var MQProp = /*#__PURE__*/function (MQProp) {
|
10
|
-
MQProp["toString"] = "toString";
|
11
|
-
MQProp["width"] = "width";
|
12
|
-
MQProp["height"] = "height";
|
13
|
-
MQProp["shortW"] = "w";
|
14
|
-
MQProp["shortH"] = "h";
|
15
|
-
return MQProp;
|
16
|
-
}(MQProp || {});
|
17
8
|
const getMQValue = value => {
|
18
9
|
if (typeof value === 'number') {
|
19
10
|
return value;
|
@@ -23,67 +14,44 @@ const getMQValue = value => {
|
|
23
14
|
}
|
24
15
|
return _core.unistyles.registry.breakpoints[value] ?? 0;
|
25
16
|
};
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
38
|
-
return new Proxy({}, {
|
39
|
-
get: (target, prop, receiver) => {
|
40
|
-
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
41
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
42
|
-
}
|
43
|
-
return Reflect.get(target, prop, receiver);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
};
|
47
|
-
}
|
48
|
-
return Reflect.get(target, prop, receiver);
|
17
|
+
const mq = exports.mq = {
|
18
|
+
only: {
|
19
|
+
width: function () {
|
20
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
21
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
22
|
+
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
23
|
+
},
|
24
|
+
height: function () {
|
25
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
26
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
27
|
+
return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
49
28
|
}
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
58
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
59
|
-
}
|
60
|
-
if (prop === MQProp.height || prop === MQProp.shortH) {
|
61
|
-
return function () {
|
29
|
+
},
|
30
|
+
width: function () {
|
31
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
32
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
33
|
+
return {
|
34
|
+
and: {
|
35
|
+
height: function () {
|
62
36
|
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
63
37
|
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
64
|
-
return
|
65
|
-
|
66
|
-
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
67
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
68
|
-
}
|
69
|
-
return Reflect.get(target, prop, receiver);
|
70
|
-
}
|
71
|
-
});
|
72
|
-
};
|
38
|
+
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
39
|
+
}
|
73
40
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
41
|
+
};
|
42
|
+
},
|
43
|
+
height: function () {
|
44
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
45
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
46
|
+
return {
|
47
|
+
and: {
|
48
|
+
width: function () {
|
49
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
50
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
51
|
+
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
};
|
87
55
|
}
|
88
|
-
}
|
56
|
+
};
|
89
57
|
//# sourceMappingURL=mq.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","
|
1
|
+
{"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","arguments","length","undefined","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAqBA,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAEM,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;MAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QA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D,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEO,IAAa,GAAAP,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;IAAA,OAAM;MAChEI,GAAG,EAAE;QACDV,KAAK,EAAE,SAAAA,CAAA;UAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;UAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;UAAA,OACvD,MAAKd,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACa,IAAI,CAAE,OAAMb,UAAU,CAACgB,IAAI,CAAE,KAAIhB,UAAU,CAACiB,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA;AACL,CAAC"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getKeyForUnistylesMediaQuery = void 0;
|
6
|
+
exports.parseMq = exports.isWithinTheWidthAndHeight = exports.isValidMq = exports.getKeyForUnistylesMediaQuery = void 0;
|
7
7
|
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
8
|
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
9
|
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
@@ -21,6 +21,7 @@ const parseMq = mq => {
|
|
21
21
|
} : undefined
|
22
22
|
};
|
23
23
|
};
|
24
|
+
exports.parseMq = parseMq;
|
24
25
|
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
25
26
|
const isValidMq = parsedMq => {
|
26
27
|
const {
|
@@ -38,6 +39,7 @@ const isValidMq = parsedMq => {
|
|
38
39
|
}
|
39
40
|
return false;
|
40
41
|
};
|
42
|
+
exports.isValidMq = isValidMq;
|
41
43
|
const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
42
44
|
const {
|
43
45
|
width,
|
@@ -54,6 +56,7 @@ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
|
54
56
|
}
|
55
57
|
return false;
|
56
58
|
};
|
59
|
+
exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
|
57
60
|
const isWithinTheWidth = (width, screenWidth) => {
|
58
61
|
const {
|
59
62
|
from,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"
|
1
|
+
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","exports","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAY7D,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,C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,CAAC;EAEF,OAAOlB,EAAE,EAAE4B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAhB,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
|
7
7
|
var _breakpoints = require("./breakpoints");
|
8
|
-
var
|
9
|
-
var
|
10
|
-
const proxifyFunction = (
|
11
|
-
apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList),
|
8
|
+
var _common = require("../common");
|
9
|
+
var _withPlugins = require("./withPlugins");
|
10
|
+
const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
|
11
|
+
apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
|
12
12
|
});
|
13
13
|
exports.proxifyFunction = proxifyFunction;
|
14
14
|
const isPlatformColor = value => {
|
@@ -18,26 +18,41 @@ const isPlatformColor = value => {
|
|
18
18
|
return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
|
19
19
|
};
|
20
20
|
exports.isPlatformColor = isPlatformColor;
|
21
|
-
const parseStyle = (style
|
22
|
-
|
23
|
-
|
21
|
+
const parseStyle = function (style) {
|
22
|
+
let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
23
|
+
return Object.entries(style || {}).reduce((acc, _ref) => {
|
24
24
|
let [key, value] = _ref;
|
25
|
-
|
26
|
-
if (
|
27
|
-
|
25
|
+
// nested objects
|
26
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
27
|
+
acc[key] = parseStyle(value, variant);
|
28
|
+
return acc;
|
28
29
|
}
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
|
31
|
+
// transforms
|
32
|
+
if (key === 'transform' && Array.isArray(value)) {
|
33
|
+
acc[key] = value.map(value => parseStyle(value, variant));
|
34
|
+
return acc;
|
35
|
+
}
|
36
|
+
|
37
|
+
// values or platform colors
|
38
|
+
if (typeof value !== 'object' || isPlatformColor(value)) {
|
39
|
+
acc[key] = value;
|
40
|
+
return acc;
|
32
41
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
if (key === 'variants') {
|
43
|
+
return {
|
44
|
+
...acc,
|
45
|
+
...Object.keys(value).reduce((acc, key) => ({
|
46
|
+
...acc,
|
47
|
+
...parseStyle(value[key][variant[key] || 'default'] ?? {})
|
48
|
+
}), {})
|
49
|
+
};
|
37
50
|
}
|
38
|
-
return
|
39
|
-
|
40
|
-
|
51
|
+
return {
|
52
|
+
...acc,
|
53
|
+
[key]: (0, _breakpoints.getValueForBreakpoint)(value)
|
54
|
+
};
|
55
|
+
}, {});
|
41
56
|
};
|
42
57
|
exports.parseStyle = parseStyle;
|
43
58
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK,IAAAC,wBAAW,EAACR,GAAG,EAAES,UAAU,CAACJ,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,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AAY,GAAGY,KAAK;MAE3B,OAAOY,GAAG;IACd;IAEA,IAAIxB,GAAG,KAAK,UAAU,EAAE;MACpB,OAAO;QACH,GAAGwB,GAAG;QACN,GAAIH,MAAM,CACLQ,IAAI,CAACjB,KAAK,CAAC,CACXW,MAAM,CAAC,CAACC,GAAG,EAAExB,GAAG,MAAM;UACnB,GAAGwB,GAAG;UACN,GAAGf,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;IAEA,OAAO;MACH,GAAGwB,GAAG;MACN,CAACxB,GAAG,GAAG,IAAA8B,kCAAqB,EAAClB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withPlugins = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const withPlugins = (key, style) => _core.unistyles.registry.plugins.reduce((acc, plugin) => {
|
9
|
+
if (plugin.onParsedStyle) {
|
10
|
+
return plugin.onParsedStyle(key, style, _core.unistyles.runtime);
|
11
|
+
}
|
12
|
+
return acc;
|
13
|
+
}, style);
|
14
|
+
exports.withPlugins = withPlugins;
|
15
|
+
//# sourceMappingURL=withPlugins.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","withPlugins","key","style","unistyles","registry","plugins","reduce","acc","plugin","onParsedStyle","runtime","exports"],"sourceRoot":"../../../src","sources":["utils/withPlugins.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,KACbC,eAAS,CAACC,QAAQ,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACpD,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACR,GAAG,EAAEC,KAAK,EAAEC,eAAS,CAACO,OAAO,CAAC;EAC9D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
|
package/lib/module/common.js
CHANGED
@@ -1,22 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { Platform } from 'react-native';
|
2
|
+
export const warn = message => {
|
3
|
+
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
4
|
+
};
|
5
|
+
export const isWeb = Platform.OS === 'web';
|
6
|
+
export const isIOS = Platform.OS === 'ios';
|
7
|
+
export const isAndroid = Platform.OS === 'android';
|
8
|
+
export const isMobile = isIOS || isAndroid;
|
9
|
+
export const isServer = typeof window === 'undefined';
|
10
|
+
export const ScreenOrientation = {
|
11
|
+
Landscape: 'landscape',
|
12
|
+
Portrait: 'portrait'
|
13
|
+
};
|
14
|
+
export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
15
|
+
UnistylesEventType["Theme"] = "theme";
|
16
|
+
UnistylesEventType["Layout"] = "layout";
|
17
|
+
UnistylesEventType["Plugin"] = "plugin";
|
18
|
+
return UnistylesEventType;
|
5
19
|
}({});
|
6
20
|
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
7
|
-
UnistylesError["RuntimeUnavailable"] = "
|
8
|
-
UnistylesError["ThemeNotFound"] = "
|
9
|
-
UnistylesError["ThemeNotRegistered"] = "
|
10
|
-
UnistylesError["
|
11
|
-
UnistylesError["
|
12
|
-
UnistylesError["
|
21
|
+
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
|
22
|
+
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
|
23
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
|
24
|
+
UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
|
25
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
|
26
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
|
27
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
|
28
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
|
29
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
|
30
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
|
13
31
|
return UnistylesError;
|
14
32
|
}({});
|
15
|
-
|
16
|
-
// todo to string?
|
17
|
-
export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
18
|
-
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
19
|
-
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
20
|
-
return ScreenOrientation;
|
21
|
-
}({});
|
22
33
|
//# sourceMappingURL=common.js.map
|
package/lib/module/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAM9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|