react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/ios/UnistylesModule.h +10 -0
- package/ios/UnistylesModule.mm +108 -0
- package/ios/UnistylesRuntime.h +30 -0
- package/ios/UnistylesRuntime.mm +191 -0
- package/lib/commonjs/UnistyleRegistry.js +37 -0
- package/lib/commonjs/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/Unistyles.js +36 -0
- package/lib/commonjs/Unistyles.js.map +1 -0
- package/lib/commonjs/UnistylesEngine.js +22 -0
- package/lib/commonjs/UnistylesEngine.js.map +1 -0
- package/lib/commonjs/UnistylesModule.js +9 -0
- package/lib/commonjs/UnistylesModule.js.map +1 -0
- package/lib/commonjs/UnistylesRuntime.js +52 -0
- package/lib/commonjs/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js +14 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -0
- package/lib/commonjs/global.js +2 -0
- package/lib/commonjs/global.js.map +1 -0
- package/lib/commonjs/hooks/useDimensions.web.js +3 -2
- package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
- package/lib/commonjs/index.js +33 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/cxx.js +23 -0
- package/lib/commonjs/types/cxx.js.map +1 -0
- package/lib/commonjs/types/index.js +26 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/normalizer.js +6 -0
- package/lib/commonjs/types/normalizer.js.map +1 -0
- package/lib/commonjs/useInitialTheme.js +13 -0
- package/lib/commonjs/useInitialTheme.js.map +1 -0
- package/lib/commonjs/useStyles.js +48 -0
- package/lib/commonjs/useStyles.js.map +1 -0
- package/lib/commonjs/useUnistyles.js +59 -0
- package/lib/commonjs/useUnistyles.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +4 -2
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/common.js +3 -3
- package/lib/commonjs/utils/common.js.map +1 -1
- package/lib/commonjs/utils/index.js +34 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/module.d.js +2 -0
- package/lib/commonjs/utils/module.d.js.map +1 -0
- package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
- package/lib/commonjs/utils/normalizer.js +89 -0
- package/lib/commonjs/utils/normalizer.js.map +1 -0
- package/lib/commonjs/utils/styles.js +7 -7
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/UnistyleRegistry.js +30 -0
- package/lib/module/UnistyleRegistry.js.map +1 -0
- package/lib/module/Unistyles.js +30 -0
- package/lib/module/Unistyles.js.map +1 -0
- package/lib/module/UnistylesEngine.js +15 -0
- package/lib/module/UnistylesEngine.js.map +1 -0
- package/lib/module/UnistylesModule.js +3 -0
- package/lib/module/UnistylesModule.js.map +1 -0
- package/lib/module/UnistylesRuntime.js +45 -0
- package/lib/module/UnistylesRuntime.js.map +1 -0
- package/lib/module/createStyleSheet.js +7 -0
- package/lib/module/createStyleSheet.js.map +1 -0
- package/lib/module/global.js +2 -0
- package/lib/module/global.js.map +1 -0
- package/lib/module/hooks/useDimensions.web.js +3 -2
- package/lib/module/hooks/useDimensions.web.js.map +1 -1
- package/lib/module/index.js +18 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/cxx.js +17 -0
- package/lib/module/types/cxx.js.map +1 -0
- package/lib/module/types/index.js +2 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/normalizer.js +2 -0
- package/lib/module/types/normalizer.js.map +1 -0
- package/lib/module/useInitialTheme.js +6 -0
- package/lib/module/useInitialTheme.js.map +1 -0
- package/lib/module/useStyles.js +42 -0
- package/lib/module/useStyles.js.map +1 -0
- package/lib/module/useUnistyles.js +52 -0
- package/lib/module/useUnistyles.js.map +1 -0
- package/lib/module/utils/breakpoints.js +4 -3
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/common.js +2 -1
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/module.d.js +2 -0
- package/lib/module/utils/module.d.js.map +1 -0
- package/lib/module/utils/normalizeStyles.web.js +13 -13
- package/lib/module/utils/normalizeStyles.web.js.map +1 -1
- package/lib/module/utils/normalizer.js +79 -0
- package/lib/module/utils/normalizer.js.map +1 -0
- package/lib/module/utils/styles.js +7 -8
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/examples/expo/src/App.d.ts +3 -0
- package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +3 -0
- package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts +2 -0
- package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/index.d.ts +2 -0
- package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
- package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts +16 -0
- package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts +40 -0
- package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
- package/lib/typescript/src/UnistyleRegistry.d.ts +15 -0
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/Unistyles.d.ts +16 -0
- package/lib/typescript/src/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesEngine.d.ts +8 -0
- package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesModule.d.ts +6 -0
- package/lib/typescript/src/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/UnistylesRuntime.d.ts +56 -0
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts +6 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
- package/lib/typescript/src/global.d.ts +5 -0
- package/lib/typescript/src/global.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +14 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +6 -7
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +4 -4
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/cxx.d.ts +50 -0
- package/lib/typescript/src/types/cxx.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +4 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/normalizer.d.ts +20 -0
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +46 -0
- package/lib/typescript/src/useStyles.d.ts.map +1 -0
- package/lib/typescript/src/useUnistyles.d.ts +45 -0
- package/lib/typescript/src/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +5 -4
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/common.d.ts +2 -1
- package/lib/typescript/src/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizer.d.ts +11 -0
- package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +4 -3
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +13 -3
- package/react-native-unistyles.podspec +21 -0
- package/src/UnistyleRegistry.ts +39 -0
- package/src/Unistyles.ts +41 -0
- package/src/UnistylesEngine.ts +15 -0
- package/src/UnistylesModule.ts +7 -0
- package/src/UnistylesRuntime.ts +58 -0
- package/src/createStyleSheet.ts +12 -0
- package/src/global.ts +2 -0
- package/src/hooks/useDimensions.web.ts +3 -2
- package/src/index.ts +30 -2
- package/src/types/breakpoints.ts +9 -11
- package/src/types/core.ts +6 -6
- package/src/types/cxx.ts +61 -0
- package/src/types/index.ts +4 -3
- package/src/types/normalizer.ts +29 -0
- package/src/useInitialTheme.ts +7 -0
- package/src/useStyles.ts +49 -0
- package/src/useUnistyles.ts +67 -0
- package/src/utils/breakpoints.ts +16 -14
- package/src/utils/common.ts +2 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/module.d.ts +3 -0
- package/src/utils/normalizeStyles.web.ts +21 -42
- package/src/utils/normalizer.ts +99 -0
- package/src/utils/styles.ts +17 -19
- package/lib/commonjs/UnistylesTheme.js +0 -21
- package/lib/commonjs/UnistylesTheme.js.map +0 -1
- package/lib/commonjs/createUnistyles.js +0 -57
- package/lib/commonjs/createUnistyles.js.map +0 -1
- package/lib/module/UnistylesTheme.js +0 -12
- package/lib/module/UnistylesTheme.js.map +0 -1
- package/lib/module/createUnistyles.js +0 -50
- package/lib/module/createUnistyles.js.map +0 -1
- package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
- package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
- package/lib/typescript/src/createUnistyles.d.ts +0 -10
- package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
- package/src/UnistylesTheme.tsx +0 -17
- package/src/__tests__/createUnistyles.spec.tsx +0 -192
- package/src/createUnistyles.ts +0 -70
@@ -0,0 +1,30 @@
|
|
1
|
+
export class UnistyleRegistry {
|
2
|
+
isClosed = false;
|
3
|
+
themes = {};
|
4
|
+
breakpoints = {};
|
5
|
+
sortedBreakpointPairs = [];
|
6
|
+
config = {};
|
7
|
+
constructor(unistylesBridge) {
|
8
|
+
this.unistylesBridge = unistylesBridge;
|
9
|
+
}
|
10
|
+
addThemes = themes => {
|
11
|
+
this.themes = themes;
|
12
|
+
return this;
|
13
|
+
};
|
14
|
+
addBreakpoints = breakpoints => {
|
15
|
+
this.unistylesBridge.useBreakpoints(breakpoints);
|
16
|
+
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
17
|
+
return this;
|
18
|
+
};
|
19
|
+
addConfig = config => {
|
20
|
+
this.config = config;
|
21
|
+
if (config.featureFlags && config.featureFlags.length > 0) {
|
22
|
+
this.unistylesBridge.useFeatureFlags(config.featureFlags);
|
23
|
+
}
|
24
|
+
if (config.colorScheme) {
|
25
|
+
this.unistylesBridge.useColorScheme(config.colorScheme);
|
26
|
+
}
|
27
|
+
return this;
|
28
|
+
};
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=UnistyleRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistyleRegistry","isClosed","themes","breakpoints","sortedBreakpointPairs","config","constructor","unistylesBridge","addThemes","addBreakpoints","useBreakpoints","addConfig","featureFlags","length","useFeatureFlags","colorScheme","useColorScheme"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,QAAQ,GAAG,KAAK;EAChBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EACjHC,MAAM,GAAoB,CAAC,CAAC;EAEnCC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,OAAO,IAAI;EACf,CAAC;EAEMO,cAAc,GAAIN,WAAiC,IAAK;IAC3D,IAAI,CAACI,eAAe,CAACG,cAAc,CAACP,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACG,eAAe,CAACH,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMO,SAAS,GAAIN,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACO,YAAY,IAAIP,MAAM,CAACO,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;MACvD,IAAI,CAACN,eAAe,CAACO,eAAe,CAACT,MAAM,CAACO,YAAY,CAAC;IAC7D;IAEA,IAAIP,MAAM,CAACU,WAAW,EAAE;MACpB,IAAI,CAACR,eAAe,CAACS,cAAc,CAACX,MAAM,CAACU,WAAW,CAAC;IAC3D;IAEA,OAAO,IAAI;EACf,CAAC;AACL"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { UnistylesModule } from './UnistylesModule';
|
2
|
+
import { UnistylesRuntime } from './UnistylesRuntime';
|
3
|
+
import { UnistylesEngine } from './UnistylesEngine';
|
4
|
+
import { UnistyleRegistry } from './UnistyleRegistry';
|
5
|
+
import { UnistylesError } from './types';
|
6
|
+
class Unistyles {
|
7
|
+
constructor() {
|
8
|
+
const isInstalled = UnistylesModule?.install() ?? false;
|
9
|
+
if (!isInstalled) {
|
10
|
+
throw new Error(UnistylesError.RuntimeUnavailable);
|
11
|
+
}
|
12
|
+
|
13
|
+
// @ts-ignore
|
14
|
+
this._bridge = global.__UNISTYLES__;
|
15
|
+
this._registry = new UnistyleRegistry(this._bridge);
|
16
|
+
this._runtime = new UnistylesRuntime(this._bridge, this._registry);
|
17
|
+
this._engine = new UnistylesEngine(this._registry, this._runtime);
|
18
|
+
}
|
19
|
+
get registry() {
|
20
|
+
return this._registry;
|
21
|
+
}
|
22
|
+
get runtime() {
|
23
|
+
return this._runtime;
|
24
|
+
}
|
25
|
+
get engine() {
|
26
|
+
return this._engine;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
export const unistyles = new Unistyles();
|
30
|
+
//# sourceMappingURL=Unistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistylesEngine","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","_engine","registry","runtime","engine","unistyles"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,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,IAAId,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACE,OAAO,GAAG,IAAId,eAAe,CAAC,IAAI,CAACY,SAAS,EAAE,IAAI,CAACC,QAAQ,CAAC;EACrE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACH,SAAS;EACzB;EAEA,IAAWI,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;EAEA,IAAWI,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,OAAO;EACvB;AACJ;AAEA,OAAO,MAAMI,SAAS,GAAG,IAAIf,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// todo implement engine
|
2
|
+
export class UnistylesEngine {
|
3
|
+
// @ts-ignore
|
4
|
+
constructor(registry, runtime) {
|
5
|
+
this.registry = registry;
|
6
|
+
this.runtime = runtime;
|
7
|
+
this.registry = registry;
|
8
|
+
this.runtime = runtime;
|
9
|
+
}
|
10
|
+
|
11
|
+
// UnistylesEngine.parseStyleSheet
|
12
|
+
// UnistylesEngine.parseStyle
|
13
|
+
// UnistylesEngine.proxify
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=UnistylesEngine.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesEngine","constructor","registry","runtime"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":"AAGA;AACA,OAAO,MAAMA,eAAe,CAAC;EACzB;EACAC,WAAWA,CAASC,QAA0B,EAAUC,OAAyB,EAAE;IAAA,KAA/DD,QAA0B,GAA1BA,QAA0B;IAAA,KAAUC,OAAyB,GAAzBA,OAAyB;IAC7E,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;;EAEA;EACA;EACA;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../src","sources":["UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { UnistylesError } from './types';
|
2
|
+
export class UnistylesRuntime {
|
3
|
+
constructor(unistylesBridge, registry) {
|
4
|
+
this.unistylesBridge = unistylesBridge;
|
5
|
+
this.registry = registry;
|
6
|
+
}
|
7
|
+
get colorScheme() {
|
8
|
+
return this.unistylesBridge.colorScheme;
|
9
|
+
}
|
10
|
+
get breakpoints() {
|
11
|
+
return this.registry.breakpoints;
|
12
|
+
}
|
13
|
+
get sortedBreakpoints() {
|
14
|
+
return this.registry.sortedBreakpointPairs;
|
15
|
+
}
|
16
|
+
get config() {
|
17
|
+
return this.registry.config;
|
18
|
+
}
|
19
|
+
get theme() {
|
20
|
+
return this.unistylesBridge.theme;
|
21
|
+
}
|
22
|
+
get currentBreakpoint() {
|
23
|
+
return this.unistylesBridge.breakpoint;
|
24
|
+
}
|
25
|
+
setColorScheme = scheme => {
|
26
|
+
if (scheme !== this.colorScheme) {
|
27
|
+
this.unistylesBridge.useColorScheme(scheme);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
setTheme = name => {
|
31
|
+
if (name !== this.theme && this.hasTheme(name)) {
|
32
|
+
this.unistylesBridge.useTheme(name);
|
33
|
+
return true;
|
34
|
+
}
|
35
|
+
return false;
|
36
|
+
};
|
37
|
+
hasTheme = name => name in this.registry.themes;
|
38
|
+
getTheme = forName => {
|
39
|
+
if (!this.hasTheme(forName)) {
|
40
|
+
throw new Error(UnistylesError.ThemeNotFound);
|
41
|
+
}
|
42
|
+
return this.registry.themes[forName];
|
43
|
+
};
|
44
|
+
}
|
45
|
+
//# sourceMappingURL=UnistylesRuntime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","breakpoints","sortedBreakpoints","sortedBreakpointPairs","config","theme","currentBreakpoint","breakpoint","setColorScheme","scheme","useColorScheme","setTheme","name","hasTheme","useTheme","themes","getTheme","forName","Error","ThemeNotFound"],"sourceRoot":"../../src","sources":["UnistylesRuntime.ts"],"mappings":"AAEA,SAA+BA,cAAc,QAAQ,SAAS;AAG9D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,e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AQ,CAACgB,MAAM,CAACE,OAAO,CAAC;EACxC,CAAC;AACL"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createStyleSheet","styles"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAKA,OAAO,MAAMA,gBAAgB,GAAuCC,MAA+E,IAAY;EAC3J,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
2
|
+
import { isServer } from '../utils';
|
2
3
|
export const useDimensions = () => {
|
3
4
|
const timerRef = useRef();
|
4
5
|
const [screenSize, setScreenSize] = useState({
|
5
|
-
width: window.innerWidth,
|
6
|
-
height: window.innerHeight
|
6
|
+
width: isServer ? 0 : window.innerWidth,
|
7
|
+
height: isServer ? 0 : window.innerHeight
|
7
8
|
});
|
8
9
|
useEffect(() => {
|
9
10
|
const handleResize = () => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","isServer","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,SAASC,QAAQ,QAAQ,UAAU;AAEnC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGJ,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACK,UAAU,EAAEC,aAAa,CAAC,GAAGL,QAAQ,CAAa;IACrDM,KAAK,EAAEL,QAAQ,GAAG,CAAC,GAAGM,MAAM,CAACC,UAAU;IACvCC,MAAM,EAAER,QAAQ,GAAG,CAAC,GAAGM,MAAM,CAACG;EAClC,CAAC,CAAC;EAEFZ,SAAS,CAAC,MAAM;IACZ,MAAMa,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
|
package/lib/module/index.js
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { unistyles } from './Unistyles';
|
2
|
+
import { UnistylesColorScheme } from './types';
|
3
|
+
export { useInitialTheme } from './useInitialTheme';
|
4
|
+
export { useStyles } from './useStyles';
|
5
|
+
export { createStyleSheet } from './createStyleSheet';
|
6
|
+
const {
|
7
|
+
addThemes,
|
8
|
+
addBreakpoints,
|
9
|
+
addConfig
|
10
|
+
} = unistyles.registry;
|
11
|
+
const UnistylesRuntime = unistyles.runtime;
|
12
|
+
const UnistylesRegistry = {
|
13
|
+
addThemes,
|
14
|
+
addBreakpoints,
|
15
|
+
addConfig
|
16
|
+
};
|
17
|
+
export { UnistylesRuntime, UnistylesRegistry };
|
18
|
+
export { UnistylesColorScheme };
|
3
19
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["unistyles","UnistylesColorScheme","useInitialTheme","useStyles","createStyleSheet","addThemes","addBreakpoints","addConfig","registry","UnistylesRuntime","runtime","UnistylesRegistry"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC,SAASC,oBAAoB,QAAQ,SAAS;AAE9C,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAM;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGP,SAAS,CAACQ,QAAQ;AACpE,MAAMC,gBAAgB,GAAGT,SAAS,CAACU,OAAO;AAC1C,MAAMC,iBAAiB,GAAG;EACtBN,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAED,SACIE,gBAAgB,EAChBE,iBAAiB;AAGrB,SACIV,oBAAoB"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export let UnistylesColorScheme = /*#__PURE__*/function (UnistylesColorScheme) {
|
2
|
+
UnistylesColorScheme["System"] = "system";
|
3
|
+
UnistylesColorScheme["Manual"] = "manual";
|
4
|
+
return UnistylesColorScheme;
|
5
|
+
}({});
|
6
|
+
export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
|
7
|
+
CxxUnistylesEventTypes["Theme"] = "theme";
|
8
|
+
CxxUnistylesEventTypes["Size"] = "size";
|
9
|
+
CxxUnistylesEventTypes["Breakpoint"] = "breakpoint";
|
10
|
+
return CxxUnistylesEventTypes;
|
11
|
+
}({});
|
12
|
+
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
13
|
+
UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
|
14
|
+
UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
|
15
|
+
return UnistylesError;
|
16
|
+
}({});
|
17
|
+
//# sourceMappingURL=cxx.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistylesColorScheme","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":"AAGA,WAAYA,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAwBhC,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AA8BlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/normalizer.ts"],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useRef","unistyles","useInitialTheme","forName","runtime","setTheme"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,SAAS,QAAQ,aAAa;AAGvC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,MAAM,CAACC,SAAS,CAACG,OAAO,CAACC,QAAQ,CAACF,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { useMemo } from 'react';
|
2
|
+
import { StyleSheet } from 'react-native';
|
3
|
+
import { parseStyle, proxifyFunction } from './utils';
|
4
|
+
import { useUnistyles } from './useUnistyles';
|
5
|
+
|
6
|
+
// todo types
|
7
|
+
|
8
|
+
export const useStyles = stylesheet => {
|
9
|
+
const {
|
10
|
+
theme,
|
11
|
+
breakpoint,
|
12
|
+
screenSize
|
13
|
+
} = useUnistyles();
|
14
|
+
if (!stylesheet) {
|
15
|
+
return {
|
16
|
+
theme,
|
17
|
+
breakpoint,
|
18
|
+
styles: {}
|
19
|
+
};
|
20
|
+
}
|
21
|
+
const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
|
22
|
+
const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
|
23
|
+
let [key, value] = _ref;
|
24
|
+
const style = value;
|
25
|
+
if (typeof value === 'function') {
|
26
|
+
return {
|
27
|
+
...acc,
|
28
|
+
[key]: proxifyFunction(value, breakpoint, screenSize)
|
29
|
+
};
|
30
|
+
}
|
31
|
+
return StyleSheet.create({
|
32
|
+
...acc,
|
33
|
+
[key]: parseStyle(style, breakpoint, screenSize)
|
34
|
+
});
|
35
|
+
}, {}), [breakpoint, screenSize, parsedStyles]);
|
36
|
+
return {
|
37
|
+
theme,
|
38
|
+
breakpoint,
|
39
|
+
styles: dynamicStyleSheet
|
40
|
+
};
|
41
|
+
};
|
42
|
+
//# sourceMappingURL=useStyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useStyles","stylesheet","theme","breakpoint","screenSize","styles","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"A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E;EACZ,CAAC;AACL,CAAC"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
2
|
+
import { useEffect, useState } from 'react';
|
3
|
+
import { CxxUnistylesEventTypes } from './types';
|
4
|
+
import { unistyles } from './Unistyles';
|
5
|
+
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
|
6
|
+
export const useUnistyles = () => {
|
7
|
+
const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.theme));
|
8
|
+
const [breakpoint, setBreakpoint] = useState(unistyles.runtime.currentBreakpoint);
|
9
|
+
const [screenSize, setScreenSize] = useState({
|
10
|
+
width: 0,
|
11
|
+
height: 0
|
12
|
+
});
|
13
|
+
useEffect(() => {
|
14
|
+
const subscription = unistylesEvents.addListener('onChange', event => {
|
15
|
+
switch (event.type) {
|
16
|
+
case CxxUnistylesEventTypes.Theme:
|
17
|
+
{
|
18
|
+
const themeEvent = event;
|
19
|
+
setTheme(unistyles.runtime.getTheme(themeEvent.payload.currentTheme));
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
case CxxUnistylesEventTypes.Size:
|
23
|
+
{
|
24
|
+
const sizeEvent = event;
|
25
|
+
setScreenSize({
|
26
|
+
width: sizeEvent.payload.width,
|
27
|
+
height: sizeEvent.payload.height
|
28
|
+
});
|
29
|
+
// todo
|
30
|
+
// setBreakpoint(unistyles.runtime.currentBreakpoint)
|
31
|
+
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
case CxxUnistylesEventTypes.Breakpoint:
|
35
|
+
{
|
36
|
+
const breakpointEvent = event;
|
37
|
+
setBreakpoint(breakpointEvent.payload.currentBreakpoint);
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
default:
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
});
|
44
|
+
return subscription.remove;
|
45
|
+
}, []);
|
46
|
+
return {
|
47
|
+
theme,
|
48
|
+
breakpoint,
|
49
|
+
screenSize
|
50
|
+
};
|
51
|
+
};
|
52
|
+
//# sourceMappingURL=useUnistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","CxxUnistylesEventTypes","unistyles","unistylesEvents","Unistyles","useUnistyles","theme","setTheme","runtime","getTheme","breakpoint","setBreakpoint","currentBreakpoint","screenSize","setScreenSize","width","height","subscription","addListener","event","type","Theme","themeEvent","payload","currentTheme","Size","sizeEvent","Breakpoint","breakpointEvent","remove"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAO3C,SAASC,sBAAsB,QAAQ,SAAS;AAChD,SAASC,SAAS,QAAQ,aAAa;AAEvC,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGP,QAAQ,CAACE,SAAS,CAACM,OAAO,CAACC,QAAQ,CAACP,SAAS,CAACM,OAAO,CAACF,KAAK,CAAC,CAAC;EACvF,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGX,QAAQ,CAACE,SAAS,CAACM,OAAO,CAACI,iBAAiB,CAAC;EACjF,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGd,QAAQ,CAAC;IACzCe,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC,CAAC;EAEFjB,SAAS,CAAC,MAAM;IACZ,MAAMkB,YAAY,GAAGd,eAAe,CAACe,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKnB,sBAAsB,CAACoB,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGH,KAA+B;YAElDZ,QAAQ,CAACL,SAAS,CAACM,OAAO,CAACC,QAAQ,CAACa,UAAU,CAACC,OAAO,CAACC,YAAY,CAAC,CAAC;YAErE;UACJ;QACA,KAAKvB,sBAAsB,CAACwB,IAAI;UAAE;YAC9B,MAAMC,SAAS,GAAGP,KAA8B;YAEhDL,aAAa,CAAC;cACVC,KAAK,EAAEW,SAAS,CAACH,OAAO,CAACR,KAAK;cAC9BC,MAAM,EAAEU,SAAS,CAACH,OAAO,CAACP;YAC9B,CAAC,CAAC;YACF;YACA;;YAEA;UACJ;QACA,KAAKf,sBAAsB,CAAC0B,UAAU;UAAE;YACpC,MAAMC,eAAe,GAAGT,KAAoC;YAE5DR,aAAa,CAACiB,eAAe,CAACL,OAAO,CAACX,iBAAiB,CAAC;YAExD;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOK,YAAY,CAACY,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHvB,KAAK;IACLI,UAAU;IACVG;EACJ,CAAC;AACL,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import { unistyles } from '../Unistyles';
|
1
2
|
import { throwError } from './common';
|
2
3
|
import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries';
|
3
|
-
|
4
4
|
/**
|
5
5
|
* Sorts the breakpoints object based on its numeric values in ascending order and validates them.
|
6
6
|
*
|
@@ -90,7 +90,7 @@ export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
|
90
90
|
*
|
91
91
|
* getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
|
92
92
|
*/
|
93
|
-
export const getValueForBreakpoint = (value, breakpoint, screenSize
|
93
|
+
export const getValueForBreakpoint = (value, breakpoint, screenSize) => {
|
94
94
|
// the highest priority is for custom media queries
|
95
95
|
const customMediaQueries = Object.entries(value).filter(_ref2 => {
|
96
96
|
let [key] = _ref2;
|
@@ -102,7 +102,7 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointP
|
|
102
102
|
}
|
103
103
|
|
104
104
|
// if no custom media query, or didn't match, proceed with defined breakpoints
|
105
|
-
const unifiedKey = breakpoint
|
105
|
+
const unifiedKey = breakpoint?.toLowerCase();
|
106
106
|
const directBreakpoint = value[unifiedKey];
|
107
107
|
|
108
108
|
// if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
|
@@ -111,6 +111,7 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointP
|
|
111
111
|
}
|
112
112
|
|
113
113
|
// there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
|
114
|
+
const breakpointPairs = unistyles.runtime.sortedBreakpoints;
|
114
115
|
const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
|
115
116
|
let [key] = _ref3;
|
116
117
|
return key === unifiedKey;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","
|
1
|
+
{"version":3,"names":["unistyles","throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","runtime","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,Q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CAACtB,GAAG,CAAC,GAAAsB,KAAA;IAAA,OAAKtB,GAAG,KAAKe,UAAU;EAAA,EAAC;EAE7C,MAAMQ,oBAAoB,GAAGL,eAAe,CACvCN,MAAM,CAAC,CAAAY,KAAA,EAAQrB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAAwB,KAAA;IAAA,OAAYrB,KAAK,GAAGiB,iBAAiB,IAAIpB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EoB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC1B,GAAG,CAAC,GAAA0B,KAAA;IAAA,OAAK1B,GAAG;EAAA,EAAC;EAExB,OAAOkB,eAAe,CAACxB,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACkB,oBAAoB,CAACA,oBAAoB,CAAC7B,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGiC,SAAS;AACnB,CAAC"}
|
@@ -5,5 +5,6 @@ export const throwError = message => {
|
|
5
5
|
export const warn = message => {
|
6
6
|
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
7
7
|
};
|
8
|
-
export const isWeb =
|
8
|
+
export const isWeb = Platform.OS === 'web';
|
9
|
+
export const isServer = typeof window === 'undefined';
|
9
10
|
//# sourceMappingURL=common.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,
|
1
|
+
{"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS","isServer","window"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,GAAGN,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW"}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles';
|
2
|
+
export * from './normalizer';
|
2
3
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
3
4
|
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { isServer } from './common';
|
4
6
|
export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
|
5
7
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
|
1
|
+
{"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,QAAQ,UAAU;AACnC,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { warn } from './common';
|
2
|
-
|
3
|
-
const normalizeBoxShadow =
|
2
|
+
import { preprocessor } from './normalizer';
|
3
|
+
const normalizeBoxShadow = style => {
|
4
4
|
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
5
|
-
if (!requiredBoxShadowProperties.every(prop => prop in
|
5
|
+
if (!requiredBoxShadowProperties.every(prop => prop in style)) {
|
6
6
|
warn(`can't apply box shadow as you miss at least one of these properties: ${requiredBoxShadowProperties.join(', ')}`);
|
7
7
|
return {
|
8
8
|
shadowColor: undefined,
|
@@ -12,16 +12,16 @@ const normalizeBoxShadow = styles => {
|
|
12
12
|
};
|
13
13
|
}
|
14
14
|
return {
|
15
|
-
boxShadow: preprocessor.createBoxShadowValue(
|
15
|
+
boxShadow: preprocessor.createBoxShadowValue(style),
|
16
16
|
shadowColor: undefined,
|
17
17
|
shadowOffset: undefined,
|
18
18
|
shadowOpacity: undefined,
|
19
19
|
shadowRadius: undefined
|
20
20
|
};
|
21
21
|
};
|
22
|
-
const normalizeTextShadow =
|
22
|
+
const normalizeTextShadow = style => {
|
23
23
|
const requiredTextShadowProperties = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
|
24
|
-
if (!requiredTextShadowProperties.every(prop => prop in
|
24
|
+
if (!requiredTextShadowProperties.every(prop => prop in style)) {
|
25
25
|
warn(`can't apply text shadow as you miss at least one of these properties: ${requiredTextShadowProperties.join(', ')}`);
|
26
26
|
return {
|
27
27
|
textShadowColor: undefined,
|
@@ -30,20 +30,20 @@ const normalizeTextShadow = styles => {
|
|
30
30
|
};
|
31
31
|
}
|
32
32
|
return {
|
33
|
-
textShadow: preprocessor.createTextShadowValue(
|
33
|
+
textShadow: preprocessor.createTextShadowValue(style),
|
34
34
|
textShadowColor: undefined,
|
35
35
|
textShadowOffset: undefined,
|
36
36
|
textShadowRadius: undefined
|
37
37
|
};
|
38
38
|
};
|
39
|
-
export const normalizeStyles =
|
40
|
-
const normalizedTransform = 'transform' in
|
41
|
-
transform: preprocessor.createTransformValue(
|
39
|
+
export const normalizeStyles = style => {
|
40
|
+
const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
|
41
|
+
transform: preprocessor.createTransformValue(style.transform)
|
42
42
|
} : {};
|
43
|
-
const normalizedBoxShadow = 'shadowColor' in
|
44
|
-
const normalizedTextShadow = 'textShadowColor' in
|
43
|
+
const normalizedBoxShadow = 'shadowColor' in style || 'shadowOffset' in style || 'shadowOpacity' in style || 'shadowRadius' in style ? normalizeBoxShadow(style) : {};
|
44
|
+
const normalizedTextShadow = 'textShadowColor' in style || 'textShadowOffset' in style || 'textShadowRadius' in style ? normalizeTextShadow(style) : {};
|
45
45
|
return {
|
46
|
-
...
|
46
|
+
...style,
|
47
47
|
...normalizedTransform,
|
48
48
|
...normalizedBoxShadow,
|
49
49
|
...normalizedTextShadow
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["warn","preprocessor","
|
1
|
+
{"version":3,"names":["warn","preprocessor","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,YAAY,QAAQ,cAAc;AAG3C,MAAMC,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3DH,IAAI,CAAE,wEAAuEI,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEZ,YAAY,CAACa,oBAAoB,CAACX,KAAK,CAAC;IACnDK,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMM,mBAAmB,GAA0BZ,KAAQ,IAA2B;EAClF,MAAMa,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACX,KAAK,CAACC,IAAI,IAAIA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