react-native-unistyles 2.0.0-alpha.7 → 2.0.0-alpha.9
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/UnistylesRuntime.cpp +24 -31
- package/cxx/UnistylesRuntime.h +11 -12
- package/ios/UnistylesModule.mm +20 -20
- package/lib/commonjs/{types/cxx.js → common.js} +6 -6
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/{UnistyleRegistry.js → core/UnistyleRegistry.js} +1 -8
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/{Unistyles.js → core/Unistyles.js} +2 -7
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/{UnistylesRuntime.js → core/UnistylesRuntime.js} +6 -6
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +10 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/{useInitialTheme.js → hooks/useInitialTheme.js} +6 -2
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +54 -0
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
- package/lib/commonjs/index.js +10 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
- package/lib/commonjs/types/index.js +4 -4
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/mq.js +6 -0
- package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/commonjs/types/unistyles.js.map +1 -0
- package/lib/commonjs/useStyles.js +7 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +18 -20
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +10 -38
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +67 -53
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +86 -0
- package/lib/commonjs/utils/mqParser.js.map +1 -0
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/{types/cxx.js → common.js} +8 -6
- package/lib/module/common.js.map +1 -0
- package/lib/module/{UnistyleRegistry.js → core/UnistyleRegistry.js} +1 -8
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/{Unistyles.js → core/Unistyles.js} +1 -6
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/{UnistylesRuntime.js → core/UnistylesRuntime.js} +2 -2
- package/lib/module/core/UnistylesRuntime.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useInitialTheme.js +10 -0
- package/lib/module/hooks/useInitialTheme.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +47 -0
- package/lib/module/hooks/useUnistyles.js.map +1 -0
- package/lib/module/index.js +11 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/mq.js +2 -0
- package/lib/module/types/mq.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/useStyles.js +6 -3
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +14 -16
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +2 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +65 -51
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js +79 -0
- package/lib/module/utils/mqParser.js.map +1 -0
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +17 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/{UnistyleRegistry.d.ts → core/UnistyleRegistry.d.ts} +2 -3
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/{Unistyles.d.ts → core/Unistyles.d.ts} +0 -3
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/{UnistylesRuntime.d.ts → core/UnistylesRuntime.d.ts} +6 -6
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +2 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -12
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +5 -9
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +3 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +9 -4
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +5 -4
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mq.d.ts +3 -0
- package/lib/typescript/src/types/mq.d.ts.map +1 -0
- package/lib/typescript/src/types/{cxx.d.ts → unistyles.d.ts} +4 -23
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +8 -6
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -2
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -9
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +3 -0
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +19 -0
- package/src/{UnistyleRegistry.ts → core/UnistyleRegistry.ts} +3 -12
- package/src/{Unistyles.ts → core/Unistyles.ts} +2 -9
- package/src/{UnistylesRuntime.ts → core/UnistylesRuntime.ts} +4 -4
- package/src/core/index.ts +1 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useInitialTheme.ts +11 -0
- package/src/hooks/useUnistyles.ts +55 -0
- package/src/index.ts +17 -20
- package/src/types/breakpoints.ts +6 -11
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +10 -4
- package/src/types/index.ts +5 -9
- package/src/types/mq.ts +3 -0
- package/src/types/{cxx.ts → unistyles.ts} +4 -28
- package/src/useStyles.ts +15 -8
- package/src/utils/breakpoints.ts +13 -12
- package/src/utils/index.ts +2 -9
- package/src/utils/mq.ts +75 -46
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/styles.ts +2 -2
- package/lib/commonjs/UnistyleRegistry.js.map +0 -1
- package/lib/commonjs/Unistyles.js.map +0 -1
- package/lib/commonjs/UnistylesEngine.js +0 -26
- package/lib/commonjs/UnistylesEngine.js.map +0 -1
- package/lib/commonjs/UnistylesModule.js.map +0 -1
- package/lib/commonjs/UnistylesRuntime.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.js +0 -10
- package/lib/commonjs/hooks/useDimensions.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.web.js +0 -34
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/cxx.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/useInitialTheme.js.map +0 -1
- package/lib/commonjs/useUnistyles.js +0 -51
- package/lib/commonjs/useUnistyles.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.js +0 -98
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/module/UnistyleRegistry.js.map +0 -1
- package/lib/module/Unistyles.js.map +0 -1
- package/lib/module/UnistylesEngine.js +0 -19
- package/lib/module/UnistylesEngine.js.map +0 -1
- package/lib/module/UnistylesModule.js.map +0 -1
- package/lib/module/UnistylesRuntime.js.map +0 -1
- package/lib/module/hooks/useDimensions.js +0 -3
- package/lib/module/hooks/useDimensions.js.map +0 -1
- package/lib/module/hooks/useDimensions.web.js +0 -27
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/cxx.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/useInitialTheme.js +0 -6
- package/lib/module/useInitialTheme.js.map +0 -1
- package/lib/module/useUnistyles.js +0 -44
- package/lib/module/useUnistyles.js.map +0 -1
- package/lib/module/utils/mediaQueries.js +0 -85
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +0 -1
- package/lib/typescript/src/Unistyles.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesEngine.d.ts +0 -11
- package/lib/typescript/src/UnistylesEngine.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesModule.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
- package/lib/typescript/src/types/cxx.d.ts.map +0 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +0 -10
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/useInitialTheme.d.ts +0 -3
- package/lib/typescript/src/useInitialTheme.d.ts.map +0 -1
- package/lib/typescript/src/useUnistyles.d.ts +0 -10
- package/lib/typescript/src/useUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -11
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/src/UnistylesEngine.ts +0 -24
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -34
- package/src/types/mediaQueries.ts +0 -15
- package/src/useInitialTheme.ts +0 -7
- package/src/useUnistyles.ts +0 -61
- package/src/utils/mediaQueries.ts +0 -152
- /package/lib/commonjs/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/module/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/typescript/src/{UnistylesModule.d.ts → core/UnistylesModule.d.ts} +0 -0
- /package/src/{UnistylesModule.ts → core/UnistylesModule.ts} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/unistyles.ts"],"mappings":""}
|
@@ -7,13 +7,16 @@ exports.useStyles = void 0;
|
|
7
7
|
var _react = require("react");
|
8
8
|
var _reactNative = require("react-native");
|
9
9
|
var _utils = require("./utils");
|
10
|
-
var
|
10
|
+
var _hooks = require("./hooks");
|
11
11
|
const useStyles = stylesheet => {
|
12
12
|
const {
|
13
13
|
theme,
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
layout
|
15
|
+
} = (0, _hooks.useUnistyles)();
|
16
|
+
const {
|
17
|
+
screenSize,
|
18
|
+
breakpoint
|
19
|
+
} = layout;
|
17
20
|
if (!stylesheet) {
|
18
21
|
return {
|
19
22
|
theme,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","theme","layout","useUnistyles","screenSize","breakpoint","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AASO,MAAMI,SAAS,GAAsCC,UAAyD,IAA2B;EAC5I,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACxC,MAAM;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAEzC,IAAI,CAACF,UAAU,EAAE;IACb,OAAO;MACHC,KAAK;MACLI,UAAU;MACVC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOR,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;EAEtC,MAAMS,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,CAAC,CACrBK,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,MAAMG,KAAK,GAAGD,KAA8B;IAE5C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAG,sBAAe,EAACF,KAAK,EAAEX,UAAU,EAAED,UAAU;MACxD,CAAC;IACL;IAEA,OAAOe,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGP,GAAG;MACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAKJ,KAAK,EAAEZ,UAAU,EAAED,UAAU;IACvD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACC,UAAU,EAAED,UAAU,EAAEG,YAAY,CAAC,CAA8B;EAEtF,OAAO;IACHN,KAAK;IACLI,UAAU;IACVC,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAvB,SAAA,GAAAA,SAAA"}
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.sortAndValidateBreakpoints = exports.getValueForBreakpoint = exports.getBreakpointFromScreenWidth = void 0;
|
7
|
-
var
|
7
|
+
var _core = require("../core");
|
8
8
|
var _common = require("./common");
|
9
|
-
var
|
9
|
+
var _common2 = require("../common");
|
10
|
+
var _mqParser = require("./mqParser");
|
10
11
|
const sortAndValidateBreakpoints = breakpoints => {
|
11
12
|
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
12
13
|
const [, value1] = breakpoint1;
|
@@ -40,25 +41,22 @@ const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
|
40
41
|
exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
|
41
42
|
const getValueForBreakpoint = value => {
|
42
43
|
// the highest priority is for custom media queries
|
43
|
-
const
|
44
|
-
|
45
|
-
return _Unistyles.unistyles.engine.isMediaQuery(key);
|
46
|
-
});
|
47
|
-
// const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize) as keyof typeof value
|
48
|
-
const customMediaQueryKey = _Unistyles.unistyles.engine.didMatchMediaQuery(customMediaQueries);
|
49
|
-
if (customMediaQueryKey && customMediaQueryKey in value) {
|
44
|
+
const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
|
45
|
+
if (customMediaQueryKey) {
|
50
46
|
return value[customMediaQueryKey];
|
51
47
|
}
|
52
48
|
|
53
49
|
// at this point user didn't use custom media queries (:w, :h)
|
54
50
|
// check if user defined any breakpoints
|
55
|
-
const hasBreakpoints =
|
51
|
+
const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
|
56
52
|
|
57
|
-
// if not then we can
|
53
|
+
// if not then we can fall back to horizontal and portrait (mobile only)
|
58
54
|
if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
|
59
|
-
return value[
|
55
|
+
return value[_core.unistyles.runtime.orientation === _common2.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
|
60
56
|
}
|
61
|
-
|
57
|
+
|
58
|
+
// let's get the current breakpoint
|
59
|
+
const breakpoint = _core.unistyles.runtime.breakpoint;
|
62
60
|
if (!breakpoint) {
|
63
61
|
return undefined;
|
64
62
|
}
|
@@ -72,16 +70,16 @@ const getValueForBreakpoint = value => {
|
|
72
70
|
}
|
73
71
|
|
74
72
|
// there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
|
75
|
-
const breakpointPairs =
|
76
|
-
const currentBreakpoint = breakpointPairs.findIndex(
|
77
|
-
let [key] =
|
73
|
+
const breakpointPairs = _core.unistyles.runtime.sortedBreakpoints;
|
74
|
+
const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
|
75
|
+
let [key] = _ref2;
|
78
76
|
return key === breakpoint;
|
79
77
|
});
|
80
|
-
const availableBreakpoints = breakpointPairs.filter((
|
81
|
-
let [key] =
|
78
|
+
const availableBreakpoints = breakpointPairs.filter((_ref3, index) => {
|
79
|
+
let [key] = _ref3;
|
82
80
|
return index < currentBreakpoint && key && key in value;
|
83
|
-
}).map(
|
84
|
-
let [key] =
|
81
|
+
}).map(_ref4 => {
|
82
|
+
let [key] = _ref4;
|
85
83
|
return key;
|
86
84
|
});
|
87
85
|
return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_core","require","_common","_common2","_mqParser","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","customMediaQueryKey","getKeyForUnistylesMediaQuery","unistyles","runtime","screen","hasBreakpoints","isMobile","Orientation","Landscape","Portrait","orientation","ScreenOrientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref2","availableBreakpoints","filter","_ref3","map","_ref4"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAA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AoB,CAACA,oBAAoB,CAACnC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnG6B,SAAS;AACnB,CAAC;AAAA1B,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
|
@@ -6,30 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
var _exportNames = {
|
7
7
|
normalizeStyles: true,
|
8
8
|
mq: true,
|
9
|
+
MQSymbol: true,
|
10
|
+
getKeyForUnistylesMediaQuery: true,
|
9
11
|
getBreakpointFromScreenWidth: true,
|
10
12
|
sortAndValidateBreakpoints: true,
|
11
13
|
getValueForBreakpoint: true,
|
12
14
|
proxifyFunction: true,
|
13
15
|
parseStyle: true,
|
14
16
|
isServer: true,
|
15
|
-
Orientation: true
|
16
|
-
extractValues: true,
|
17
|
-
getKeyForCustomMediaQuery: true,
|
18
|
-
isMediaQuery: true,
|
19
|
-
isWithinTheHeight: true,
|
20
|
-
isWithinTheWidth: true,
|
21
|
-
isWithinTheWidthAndHeight: true
|
17
|
+
Orientation: true
|
22
18
|
};
|
23
|
-
Object.defineProperty(exports, "
|
19
|
+
Object.defineProperty(exports, "MQSymbol", {
|
24
20
|
enumerable: true,
|
25
21
|
get: function () {
|
26
|
-
return
|
22
|
+
return _mq.MQSymbol;
|
27
23
|
}
|
28
24
|
});
|
29
|
-
Object.defineProperty(exports, "
|
25
|
+
Object.defineProperty(exports, "Orientation", {
|
30
26
|
enumerable: true,
|
31
27
|
get: function () {
|
32
|
-
return
|
28
|
+
return _common.Orientation;
|
33
29
|
}
|
34
30
|
});
|
35
31
|
Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
@@ -38,10 +34,10 @@ Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
|
38
34
|
return _breakpoints.getBreakpointFromScreenWidth;
|
39
35
|
}
|
40
36
|
});
|
41
|
-
Object.defineProperty(exports, "
|
37
|
+
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
42
38
|
enumerable: true,
|
43
39
|
get: function () {
|
44
|
-
return
|
40
|
+
return _mqParser.getKeyForUnistylesMediaQuery;
|
45
41
|
}
|
46
42
|
});
|
47
43
|
Object.defineProperty(exports, "getValueForBreakpoint", {
|
@@ -50,36 +46,12 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
50
46
|
return _breakpoints.getValueForBreakpoint;
|
51
47
|
}
|
52
48
|
});
|
53
|
-
Object.defineProperty(exports, "isMediaQuery", {
|
54
|
-
enumerable: true,
|
55
|
-
get: function () {
|
56
|
-
return _mediaQueries.isMediaQuery;
|
57
|
-
}
|
58
|
-
});
|
59
49
|
Object.defineProperty(exports, "isServer", {
|
60
50
|
enumerable: true,
|
61
51
|
get: function () {
|
62
52
|
return _common.isServer;
|
63
53
|
}
|
64
54
|
});
|
65
|
-
Object.defineProperty(exports, "isWithinTheHeight", {
|
66
|
-
enumerable: true,
|
67
|
-
get: function () {
|
68
|
-
return _mediaQueries.isWithinTheHeight;
|
69
|
-
}
|
70
|
-
});
|
71
|
-
Object.defineProperty(exports, "isWithinTheWidth", {
|
72
|
-
enumerable: true,
|
73
|
-
get: function () {
|
74
|
-
return _mediaQueries.isWithinTheWidth;
|
75
|
-
}
|
76
|
-
});
|
77
|
-
Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
78
|
-
enumerable: true,
|
79
|
-
get: function () {
|
80
|
-
return _mediaQueries.isWithinTheWidthAndHeight;
|
81
|
-
}
|
82
|
-
});
|
83
55
|
Object.defineProperty(exports, "mq", {
|
84
56
|
enumerable: true,
|
85
57
|
get: function () {
|
@@ -124,8 +96,8 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
124
96
|
});
|
125
97
|
});
|
126
98
|
var _mq = require("./mq");
|
99
|
+
var _mqParser = require("./mqParser");
|
127
100
|
var _breakpoints = require("./breakpoints");
|
128
101
|
var _styles = require("./styles");
|
129
102
|
var _common = require("./common");
|
130
|
-
var _mediaQueries = require("./mediaQueries");
|
131
103
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_breakpoints","_styles","_common"
|
1
|
+
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_mqParser","_breakpoints","_styles","_common"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AACA,IAAAgB,YAAA,GAAAhB,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA"}
|
package/lib/commonjs/utils/mq.js
CHANGED
@@ -3,73 +3,87 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.mq = void 0;
|
7
|
-
var
|
8
|
-
const MQSymbol = Symbol('unistyles-mq');
|
6
|
+
exports.mq = exports.MQSymbol = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const MQSymbol = exports.MQSymbol = Symbol('unistyles-mq');
|
9
9
|
var MQProp = /*#__PURE__*/function (MQProp) {
|
10
10
|
MQProp["toString"] = "toString";
|
11
11
|
MQProp["width"] = "width";
|
12
12
|
MQProp["height"] = "height";
|
13
|
+
MQProp["shortW"] = "w";
|
14
|
+
MQProp["shortH"] = "h";
|
13
15
|
return MQProp;
|
14
16
|
}(MQProp || {});
|
15
17
|
const getMQValue = value => {
|
16
18
|
if (typeof value === 'number') {
|
17
19
|
return value;
|
18
20
|
}
|
19
|
-
|
21
|
+
if (value === null) {
|
22
|
+
return 0;
|
23
|
+
}
|
24
|
+
return _core.unistyles.registry.breakpoints[value] ?? 0;
|
20
25
|
};
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
38
|
-
}
|
39
|
-
return Reflect.get(target, prop, receiver);
|
26
|
+
const widthHandler = function () {
|
27
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
28
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
29
|
+
return new Proxy({}, {
|
30
|
+
get: (target, prop, receiver) => {
|
31
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
32
|
+
return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
33
|
+
}
|
34
|
+
if (prop === MQProp.width || prop === MQProp.shortW) {
|
35
|
+
return function () {
|
36
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
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)}]`;
|
40
42
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
return Reflect.get(target, prop, receiver);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
};
|
47
|
+
}
|
48
|
+
return Reflect.get(target, prop, receiver);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
};
|
52
|
+
const heightHandler = function () {
|
53
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
54
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
55
|
+
return new Proxy({}, {
|
56
|
+
get: (target, prop, receiver) => {
|
57
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
58
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
45
59
|
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
55
|
-
}
|
56
|
-
if (prop === MQProp.height) {
|
57
|
-
return function () {
|
58
|
-
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
59
|
-
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
60
|
-
return new Proxy({}, {
|
61
|
-
get: (target, prop, receiver) => {
|
62
|
-
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
63
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
64
|
-
}
|
65
|
-
return Reflect.get(target, prop, receiver);
|
60
|
+
if (prop === MQProp.height || prop === MQProp.shortH) {
|
61
|
+
return function () {
|
62
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
63
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
64
|
+
return new Proxy({}, {
|
65
|
+
get: (target, prop, receiver) => {
|
66
|
+
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
67
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
66
68
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
return Reflect.get(target, prop, receiver);
|
70
|
+
}
|
71
|
+
});
|
72
|
+
};
|
71
73
|
}
|
72
|
-
|
73
|
-
|
74
|
+
return Reflect.get(target, prop, receiver);
|
75
|
+
}
|
76
|
+
});
|
74
77
|
};
|
78
|
+
const mq = exports.mq = new Proxy({}, {
|
79
|
+
get: (target, prop, receiver) => {
|
80
|
+
if (prop === MQProp.shortW || prop === MQProp.width) {
|
81
|
+
return heightHandler;
|
82
|
+
}
|
83
|
+
if (prop === MQProp.shortH || prop === MQProp.height) {
|
84
|
+
return widthHandler;
|
85
|
+
}
|
86
|
+
return Reflect.get(target, prop, receiver);
|
87
|
+
}
|
88
|
+
});
|
75
89
|
//# sourceMappingURL=mq.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_core","require","MQSymbol","exports","Symbol","MQProp","getMQValue","value","unistyles","registry","breakpoints","widthHandler","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","shortW","wMin","wMax","Reflect","heightHandler","height","shortH","mq"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAAC,OAAA,CAAA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pB,YAAY;IACvB;IAEA,OAAOkB,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;EAC9C;AACJ,CAAC,CAAC"}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getKeyForUnistylesMediaQuery = void 0;
|
7
|
+
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
|
+
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
|
+
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
10
|
+
const parseMq = mq => {
|
11
|
+
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
|
12
|
+
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
|
13
|
+
return {
|
14
|
+
width: width ? {
|
15
|
+
from: Number(fromW),
|
16
|
+
to: Number(toW)
|
17
|
+
} : undefined,
|
18
|
+
height: height ? {
|
19
|
+
from: Number(fromH),
|
20
|
+
to: Number(toH)
|
21
|
+
} : undefined
|
22
|
+
};
|
23
|
+
};
|
24
|
+
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
25
|
+
const isValidMq = parsedMq => {
|
26
|
+
const {
|
27
|
+
width,
|
28
|
+
height
|
29
|
+
} = parsedMq;
|
30
|
+
if (width && height) {
|
31
|
+
return width.from <= width.to && height.from <= height.to;
|
32
|
+
}
|
33
|
+
if (width) {
|
34
|
+
return width.from <= width.to;
|
35
|
+
}
|
36
|
+
if (height) {
|
37
|
+
return height.from <= height.to;
|
38
|
+
}
|
39
|
+
return false;
|
40
|
+
};
|
41
|
+
const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
42
|
+
const {
|
43
|
+
width,
|
44
|
+
height
|
45
|
+
} = parsedMq;
|
46
|
+
if (width && height) {
|
47
|
+
return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
|
48
|
+
}
|
49
|
+
if (width) {
|
50
|
+
return isWithinTheWidth(width, screenSize.width);
|
51
|
+
}
|
52
|
+
if (height) {
|
53
|
+
return isWithinTheHeight(height, screenSize.height);
|
54
|
+
}
|
55
|
+
return false;
|
56
|
+
};
|
57
|
+
const isWithinTheWidth = (width, screenWidth) => {
|
58
|
+
const {
|
59
|
+
from,
|
60
|
+
to
|
61
|
+
} = width;
|
62
|
+
return screenWidth >= from && screenWidth <= to;
|
63
|
+
};
|
64
|
+
const isWithinTheHeight = (height, screenHeight) => {
|
65
|
+
const {
|
66
|
+
from,
|
67
|
+
to
|
68
|
+
} = height;
|
69
|
+
return screenHeight >= from && screenHeight <= to;
|
70
|
+
};
|
71
|
+
const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
|
72
|
+
const mq = mediaQueries.find(_ref => {
|
73
|
+
let [key] = _ref;
|
74
|
+
if (!isUnistylesMq(key)) {
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
const parsedMq = parseMq(key);
|
78
|
+
if (!isValidMq(parsedMq)) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
return isWithinTheWidthAndHeight(parsedMq, screenSize);
|
82
|
+
});
|
83
|
+
return mq?.at(0);
|
84
|
+
};
|
85
|
+
exports.getKeyForUnistylesMediaQuery = getKeyForUnistylesMediaQuery;
|
86
|
+
//# sourceMappingURL=mqParser.js.map
|
@@ -0,0 +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","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EAAE,CAAC;AAEjE,MAAMc,SAAS,GAAIC,QAA2B,IAAK;EAC/C,MAAM;IAAEd,KAAK;IAAEI;EAAO,CAAC,GAAGU,QAAQ;EAElC,IAAId,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOJ,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE,IAAIL,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACK,EAAE;EAC7D;EAEA,IAAIT,KAAK,EAAE;IACP,OAAOA,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE;EACjC;EAEA,IAAIL,MAAM,EAAE;IACR,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AAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAC,OAAA,CAAAN,4BAAA,GAAAA,4BAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,KACX,IAAIC,KAAK,CAACH,EAAE,EAAE;EACzBI,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEN,UAAU,EAAEC,UAAU;AAC/E,CAAC,CAAC;AAAAO,OAAA,CAAAV,eAAA,GAAAA,eAAA;AAEK,MAAMW,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iB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akpoint","screenSize","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,KACX,IAAIC,KAAK,CAACH,EAAE,EAAE;EACzBI,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEN,UAAU,EAAEC,UAAU;AAC/E,CAAC,CAAC;AAAAO,OAAA,CAAAV,eAAA,GAAAA,eAAA;AAEK,MAAMW,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAA2B,EAC3Bf,UAA+C,EAC/CC,UAAsB,KAClB;EACJ,MAAMe,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,IAAI,CAAC,CAAC,CAGzC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAEZ,KAAK,CAAC,GAAAW,IAAA;IACd,MAAME,mBAAmB,GAAGD,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIC,mBAAmB,EAAE;MACrB,OAAO,CACHD,GAAG,EACHf,UAAU,CAACG,KAAK,EAA0BV,UAAU,EAAEC,UAAU,CAAC,CACpE;IACL;IAEA,MAAMuB,WAAW,GAAGF,GAAG,KAAK,WAAW;IAEvC,IAAIE,WAAW,IAAIC,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,EAAE;MACrC,OAAO,CACHY,GAAG,EACHZ,KAAK,CAACU,GAAG,CAACV,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEV,UAAU,EAAEC,UAAU,CAAC,CAAC,CAChE;IACL;IAEA,MAAM0B,iBAAiB,GAAG,OAAOjB,KAAK,KAAK,UAAU;IACrD,MAAMkB,YAAY,GAAG,OAAOlB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIiB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACN,GAAG,EAAEZ,KAAK,CAAC;IACvB;IAEA,OAAO,CACHY,GAAG,EACH,IAAAO,kCAAqB,EAACnB,KAAqF,CAAC,CAC/G;EACL,CAAC,CACL,CAAC;EAEL,OAAOoB,aAAK,GACN,IAAAC,gCAAe,EAACb,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAV,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
@@ -1,8 +1,3 @@
|
|
1
|
-
export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
2
|
-
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
3
|
-
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
4
|
-
return ScreenOrientation;
|
5
|
-
}({});
|
6
1
|
export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
|
7
2
|
CxxUnistylesEventTypes["Theme"] = "theme";
|
8
3
|
CxxUnistylesEventTypes["Layout"] = "layout";
|
@@ -17,4 +12,11 @@ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
|
17
12
|
UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
|
18
13
|
return UnistylesError;
|
19
14
|
}({});
|
20
|
-
|
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
|
+
//# sourceMappingURL=common.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CxxUnistylesEventTypes","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAKlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AAS1B;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
|
@@ -15,6 +15,7 @@ export class UnistyleRegistry {
|
|
15
15
|
return this;
|
16
16
|
};
|
17
17
|
addBreakpoints = breakpoints => {
|
18
|
+
this.breakpoints = breakpoints;
|
18
19
|
this.unistylesBridge.useBreakpoints(breakpoints);
|
19
20
|
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
20
21
|
return this;
|
@@ -26,13 +27,5 @@ export class UnistyleRegistry {
|
|
26
27
|
}
|
27
28
|
return this;
|
28
29
|
};
|
29
|
-
dangerouslyUnregister = () => {
|
30
|
-
this.config = {};
|
31
|
-
this.themeNames = [];
|
32
|
-
this.themes = {};
|
33
|
-
this.breakpoints = {};
|
34
|
-
this.sortedBreakpointPairs = [];
|
35
|
-
this.unistylesBridge.unregister();
|
36
|
-
};
|
37
30
|
}
|
38
31
|
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;AACL"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { UnistylesModule } from './UnistylesModule';
|
2
2
|
import { UnistylesRuntime } from './UnistylesRuntime';
|
3
|
-
import { UnistylesBuiltInEngine } from './UnistylesEngine';
|
4
3
|
import { UnistyleRegistry } from './UnistyleRegistry';
|
5
|
-
import { UnistylesError } from '
|
4
|
+
import { UnistylesError } from '../common';
|
6
5
|
class Unistyles {
|
7
6
|
constructor() {
|
8
7
|
const isInstalled = UnistylesModule?.install() ?? false;
|
@@ -14,7 +13,6 @@ class Unistyles {
|
|
14
13
|
this._bridge = global.__UNISTYLES__;
|
15
14
|
this._registry = new UnistyleRegistry(this._bridge);
|
16
15
|
this._runtime = new UnistylesRuntime(this._bridge, this._registry);
|
17
|
-
this._engine = new UnistylesBuiltInEngine(this._registry, this._runtime);
|
18
16
|
}
|
19
17
|
get registry() {
|
20
18
|
return this._registry;
|
@@ -22,9 +20,6 @@ class Unistyles {
|
|
22
20
|
get runtime() {
|
23
21
|
return this._runtime;
|
24
22
|
}
|
25
|
-
get engine() {
|
26
|
-
return this._engine;
|
27
|
-
}
|
28
23
|
}
|
29
24
|
export const unistyles = new Unistyles();
|
30
25
|
//# sourceMappingURL=Unistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","registry","runtime","unistyles"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGN,eAAe,EAAEO,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACL,cAAc,CAACM,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIX,gBAAgB,CAAC,IAAI,CAACQ,OAAO,CAAC;IACnD,IAAI,CAACI,QAAQ,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;EACtE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACF,SAAS;EACzB;EAEA,IAAWG,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACF,QAAQ;EACxB;AACJ;AAEA,OAAO,MAAMG,SAAS,GAAG,IAAIb,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ScreenOrientation, UnistylesError } from '
|
1
|
+
import { ScreenOrientation, UnistylesError } from '../common';
|
2
2
|
export class UnistylesRuntime {
|
3
3
|
constructor(unistylesBridge, registry) {
|
4
4
|
this.unistylesBridge = unistylesBridge;
|
@@ -36,7 +36,7 @@ export class UnistylesRuntime {
|
|
36
36
|
return ScreenOrientation.Portrait;
|
37
37
|
}
|
38
38
|
setTheme = name => {
|
39
|
-
if (
|
39
|
+
if (this.hasTheme(name)) {
|
40
40
|
this.unistylesBridge.useTheme(name);
|
41
41
|
return true;
|
42
42
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,QAAQ,CAACI,qBAAqB;EAC9C;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACN,eAAe,CAACM,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACP,eAAe,CAACO,UAAU;EAC1C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACT,eAAe,CAACU,WAAW;MACvCC,MAAM,EA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