react-native-unistyles 2.0.0-alpha.16 → 2.0.0-alpha.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,15 +25,16 @@ let UnistylesEventType = exports.UnistylesEventType = /*#__PURE__*/function (Uni
25
25
  return UnistylesEventType;
26
26
  }({});
27
27
  let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
28
- UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions.";
29
- UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered.";
30
- UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that is not registered.";
31
- UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register an empty themes object.";
32
- UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register an empty breakpoints object.";
33
- UnistylesError["BreakpointsMustStartFromZero"] = "One breakpoint must start from 0.";
34
- UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix. Use another name.";
35
- UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered.";
36
- UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin.";
28
+ UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
29
+ UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
30
+ UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
31
+ UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
32
+ UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
33
+ UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
34
+ UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
35
+ UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
36
+ UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
37
+ UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
37
38
  return UnistylesError;
38
39
  }({});
39
40
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","warn","message","console","exports","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,QAAQ,GAAAD,OAAA,CAAAC,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAL,OAAA,CAAAK,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAN,OAAA,CAAAM,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,iBAAiB,GAAAT,OAAA,CAAAS,iBAAA,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAAA,IAEEC,kBAAkB,GAAAZ,OAAA,CAAAY,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAA,IAMlBC,cAAc,GAAAb,OAAA,CAAAa,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
1
+ {"version":3,"names":["_reactNative","require","warn","message","console","exports","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,QAAQ,GAAAD,OAAA,CAAAC,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAL,OAAA,CAAAK,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAN,OAAA,CAAAM,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,iBAAiB,GAAAT,OAAA,CAAAS,iBAAA,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAAA,IAEEC,kBAAkB,GAAAZ,OAAA,CAAAY,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAA,IAMlBC,cAAc,GAAAb,OAAA,CAAAa,cAAA,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"}
@@ -21,13 +21,19 @@ class UnistyleRegistry {
21
21
  const keys = Object.keys(themes);
22
22
  this.unistylesBridge.themes = keys;
23
23
  this.themeNames = keys;
24
- return this;
24
+ return {
25
+ addBreakpoints: this.addBreakpoints,
26
+ addConfig: this.addConfig
27
+ };
25
28
  };
26
29
  addBreakpoints = breakpoints => {
27
30
  this.breakpoints = breakpoints;
28
31
  this.unistylesBridge.useBreakpoints(breakpoints);
29
32
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
30
- return this;
33
+ return {
34
+ addThemes: this.addThemes,
35
+ addConfig: this.addConfig
36
+ };
31
37
  };
32
38
  addConfig = config => {
33
39
  this.config = config;
@@ -40,15 +46,22 @@ class UnistyleRegistry {
40
46
  if (config.initialTheme) {
41
47
  this.unistylesBridge.useTheme(config.initialTheme);
42
48
  }
49
+ return {
50
+ addBreakpoints: this.addBreakpoints,
51
+ addThemes: this.addThemes
52
+ };
43
53
  };
44
54
  getTheme = forName => {
45
55
  if (this.themeNames.length === 0) {
46
56
  return {};
47
57
  }
48
- if (!this.hasTheme(forName)) {
58
+ if (this.hasTheme(forName)) {
59
+ return this.themes[forName];
60
+ }
61
+ if (this.unistylesBridge.themeName) {
49
62
  throw new Error(_common.UnistylesError.ThemeNotFound);
50
63
  }
51
- return this.themes[forName];
64
+ throw new Error(_common.UnistylesError.ThemeNotSelected);
52
65
  };
53
66
  addPlugin = (() => {
54
67
  var _this = this;
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","Error","UnistylesError","ThemeNotFound","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BC,aAAK,GACxC,CAACC,iCAAwB,CAAC,GAC1B,EAAE;EACDC,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,GAAIf,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MA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c,CAACW,mBAAmB,CAAC;MACvD;MAEAT,KAAI,CAAC9B,OAAO,GAAG,CAACmB,MAAM,CAAC,CAACqB,MAAM,CAACV,KAAI,CAAC9B,OAAO,CAAC;MAC5C8B,KAAI,CAACtB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACe,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAItB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACe,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIR,KAAK,CAACC,sBAAc,CAACc,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAAC1C,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC2C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKf,MAAM,CAACe,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC1B,eAAe,CAACiC,YAAY,CAACtB,MAAM,CAACe,IAAI,CAAC;EAClD,CAAC;EAEMR,QAAQ,GAAIQ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC9B,MAAM;AAC1E;AAACyC,OAAA,CAAA/C,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,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ACvD,MAAM,IAAIR,KAAK,CAACC,sBAAc,CAACY,mBAAmB,CAAC;MACvD;MAEAT,KAAI,CAAChC,OAAO,GAAG,CAACmB,MAAM,CAAC,CAACuB,MAAM,CAACV,KAAI,CAAChC,OAAO,CAAC;MAC5CgC,KAAI,CAACxB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACiB,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAIxB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACiB,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIT,KAAK,CAACC,sBAAc,CAACe,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAAC5C,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC6C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKjB,MAAM,CAACiB,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC5B,eAAe,CAACmC,YAAY,CAACxB,MAAM,CAACiB,IAAI,CAAC;EAClD,CAAC;EAEMV,QAAQ,GAAIU,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChC,MAAM;AAC1E;AAAC2C,OAAA,CAAAjD,gBAAA,GAAAA,gBAAA"}
@@ -15,16 +15,9 @@ const useStyles = (stylesheet, variantsMap) => {
15
15
  layout,
16
16
  plugins
17
17
  } = (0, _hooks.useUnistyles)();
18
- if (!stylesheet) {
19
- return {
20
- theme,
21
- breakpoint: layout.breakpoint,
22
- styles: {}
23
- };
24
- }
25
18
  const variants = (0, _hooks.useVariants)(variantsMap);
26
19
  const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
27
- const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
20
+ const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
28
21
  let [key, value] = _ref;
29
22
  if (typeof value === 'function') {
30
23
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","breakpoint","styles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","unistyles","registry","runtime","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;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAcO,MAAMK,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EAEjD,IAAI,CAACL,UAAU,EAAE;IACb,OAAO;MACHE,KAAK;MACLI,UAAU,EAAEH,MAAM,CAACG,UAAU;MAC7BC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAACR,WAAW,CAAC;EACzC,MAAMS,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOX,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,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,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAE,sBAAe,EAACF,GAAG,EAAEC,KAAK,EAACE,eAAS,CAACC,QAAQ,CAAClB,OAAO,EAAEiB,eAAS,CAACE,OAAO,EAAEf,QAAQ;MAC7F,CAAC;IACL;IAEA,OAAOgB,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGT,GAAG;MACN,CAACE,GAAG,GAAG,IAAAQ,iBAAU,EACbR,GAAG,EACHC,KAAK,EACLE,eAAS,CAACC,QAAQ,CAAClB,OAAO,EAC1BiB,eAAS,CAACE,OAAO,EACjBf,QACJ;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EACV,CAACL,MAAM,EAAEO,YAAY,EAAEF,QAAQ,EAAEJ,OAAO,CACxC,CAA8B;EAE9B,OAAO;IACHF,KAAK;IACLI,UAAU,EAAEH,MAAM,CAACG,UAAU;IAC7BC,MAAM,EAAEK;EACZ,CAAC;AACL,CAAC;AAAAe,OAAA,CAAA5B,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","unistyles","registry","runtime","StyleSheet","create","parseStyle","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAcO,MAAMK,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAA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EventType = /*#__PURE__*/function (UnistylesEventType) {
18
18
  return UnistylesEventType;
19
19
  }({});
20
20
  export let UnistylesError = /*#__PURE__*/function (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.";
23
- UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that is not registered.";
24
- UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register an empty themes object.";
25
- UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register an empty breakpoints object.";
26
- UnistylesError["BreakpointsMustStartFromZero"] = "One breakpoint must start from 0.";
27
- UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix. Use another name.";
28
- UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered.";
29
- UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin.";
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";
30
31
  return UnistylesError;
31
32
  }({});
32
33
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","warn","message","console","isMobile","OS","isWeb","isIOS","isAndroid","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,QAAQ,GAAGJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIL,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGP,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGR,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,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;EAAA,OAAdA,cAAc;AAAA"}
1
+ {"version":3,"names":["Platform","warn","message","console","isMobile","OS","isWeb","isIOS","isAndroid","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,QAAQ,GAAGJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIL,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGP,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGR,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,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"}
@@ -15,13 +15,19 @@ export class UnistyleRegistry {
15
15
  const keys = Object.keys(themes);
16
16
  this.unistylesBridge.themes = keys;
17
17
  this.themeNames = keys;
18
- return this;
18
+ return {
19
+ addBreakpoints: this.addBreakpoints,
20
+ addConfig: this.addConfig
21
+ };
19
22
  };
20
23
  addBreakpoints = breakpoints => {
21
24
  this.breakpoints = breakpoints;
22
25
  this.unistylesBridge.useBreakpoints(breakpoints);
23
26
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
24
- return this;
27
+ return {
28
+ addThemes: this.addThemes,
29
+ addConfig: this.addConfig
30
+ };
25
31
  };
26
32
  addConfig = config => {
27
33
  this.config = config;
@@ -34,15 +40,22 @@ export class UnistyleRegistry {
34
40
  if (config.initialTheme) {
35
41
  this.unistylesBridge.useTheme(config.initialTheme);
36
42
  }
43
+ return {
44
+ addBreakpoints: this.addBreakpoints,
45
+ addThemes: this.addThemes
46
+ };
37
47
  };
38
48
  getTheme = forName => {
39
49
  if (this.themeNames.length === 0) {
40
50
  return {};
41
51
  }
42
- if (!this.hasTheme(forName)) {
52
+ if (this.hasTheme(forName)) {
53
+ return this.themes[forName];
54
+ }
55
+ if (this.unistylesBridge.themeName) {
43
56
  throw new Error(UnistylesError.ThemeNotFound);
44
57
  }
45
- return this.themes[forName];
58
+ throw new Error(UnistylesError.ThemeNotSelected);
46
59
  };
47
60
  addPlugin = (() => {
48
61
  var _this = this;
@@ -1 +1 @@
1
- {"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","Error","ThemeNotFound","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BL,KAAK,GACxC,CAACE,wBAAwB,CAAC,GAC1B,EAAE;EACDI,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,G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AACzB,eAAe,CAACgC,YAAY,CAACrB,MAAM,CAACc,IAAI,CAAC;EAClD,CAAC;EAEMP,QAAQ,GAAIO,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC7B,MAAM;AAC1E"}
1
+ {"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BL,KAAK,GACxC,CAACE,wBAAwB,CAAC,GAC1B,EAAE;EACDI,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;MACHE,cAAc,EAAE,IAAI,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IAAI,CAAC3B,eAAe,CAACkC,YAAY,CAACvB,MAAM,CAACgB,IAAI,CAAC;EAClD,CAAC;EAEMT,QAAQ,GAAIS,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC/B,MAAM;AAC1E"}
@@ -9,16 +9,9 @@ export const useStyles = (stylesheet, variantsMap) => {
9
9
  layout,
10
10
  plugins
11
11
  } = useUnistyles();
12
- if (!stylesheet) {
13
- return {
14
- theme,
15
- breakpoint: layout.breakpoint,
16
- styles: {}
17
- };
18
- }
19
12
  const variants = useVariants(variantsMap);
20
13
  const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
21
- const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
14
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
22
15
  let [key, value] = _ref;
23
16
  if (typeof value === 'function') {
24
17
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useVariants","unistyles","useStyles","stylesheet","variantsMap","theme","layout","plugins","breakpoint","styles","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","registry","runtime","create"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,QAAQ,SAAS;AACrD,SAASC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAEnD,SAASC,SAAS,QAAQ,QAAQ;AAclC,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,YAAY,CAAC,CAAC;EAEjD,IAAI,CAACI,UAAU,EAAE;IACb,OAAO;MACHE,KAAK;MACLG,UAAU,EAAEF,MAAM,CAACE,UAAU;MAC7BC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,QAAQ,GAAGV,WAAW,CAACI,WAAW,CAAC;EACzC,MAAMO,YAAY,GAAGhB,OAAO,CAAC,MAAM,OAAOQ,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMM,iBAAiB,GAAGjB,OAAO,CAAC,MAAMkB,MAAM,CACzCC,OAAO,CAACH,YAAY,CAAC,CACrBI,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAGpB,eAAe,CAACoB,GAAG,EAAEC,KAAK,EAAClB,SAAS,CAACmB,QAAQ,CAACb,OAAO,EAAEN,SAAS,CAACoB,OAAO,EAAEX,QAAQ;MAC7F,CAAC;IACL;IAEA,OAAOd,UAAU,CAAC0B,MAAM,CAAC;MACrB,GAAGN,GAAG;MACN,CAACE,GAAG,GAAGrB,UAAU,CACbqB,GAAG,EACHC,KAAK,EACLlB,SAAS,CAACmB,QAAQ,CAACb,OAAO,EAC1BN,SAAS,CAACoB,OAAO,EACjBX,QACJ;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EACV,CAACJ,MAAM,EAAEK,YAAY,EAAED,QAAQ,EAAEH,OAAO,CACxC,CAA8B;EAE9B,OAAO;IACHF,KAAK;IACLG,UAAU,EAAEF,MAAM,CAACE,UAAU;IAC7BC,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useVariants","unistyles","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","registry","runtime","create","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,QAAQ,SAAS;AACrD,SAASC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAEnD,SAASC,SAAS,QAAQ,QAAQ;AAclC,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,YAAY,CAAC,CAAC;EACjD,MAAMS,QAAQ,GAAGR,WAAW,CAACI,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGd,OAAO,CAAC,MAAM,OAAOQ,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGf,OAAO,CAAC,MAAMgB,MAAM,CACzCC,OAAO,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BI,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAGlB,eAAe,CAACkB,GAAG,EAAEC,KAAK,EAAChB,SAAS,CAACiB,QAAQ,CAACX,OAAO,EAAEN,SAAS,CAACkB,OAAO,EAAEX,QAAQ;MAC7F,CAAC;IACL;IAEA,OAAOZ,UAAU,CAACwB,MAAM,CAAC;MACrB,GAAGN,GAAG;MACN,CAACE,GAAG,GAAGnB,UAAU,CACbmB,GAAG,EACHC,KAAK,EACLhB,SAAS,CAACiB,QAAQ,CAACX,OAAO,EAC1BN,SAAS,CAACkB,OAAO,EACjBX,QACJ;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACF,MAAM,EAAEG,YAAY,EAAED,QAAQ,EAAED,OAAO,CACpD,CAAC;EAED,OAAO;IACHF,KAAK;IACLgB,UAAU,EAAEf,MAAM,CAACe,UAAU;IAC7BC,MAAM,EAAEZ;EACZ,CAAC;AACL,CAAC"}
@@ -14,14 +14,15 @@ export declare enum UnistylesEventType {
14
14
  Plugin = "plugin"
15
15
  }
16
16
  export declare enum UnistylesError {
17
- RuntimeUnavailable = "Unistyles runtime is not available. Make sure you followed the installation instructions.",
18
- ThemeNotFound = "You are trying to get a theme that is not registered.",
19
- ThemeNotRegistered = "You are trying to set a theme that is not registered.",
20
- ThemesCannotBeEmpty = "You are trying to register an empty themes object.",
21
- BreakpointsCannotBeEmpty = "You are trying to register an empty breakpoints object.",
22
- BreakpointsMustStartFromZero = "One breakpoint must start from 0.",
23
- InvalidPluginName = "Plugin name can't start from reserved prefix. Use another name.",
24
- DuplicatePluginName = "You are trying to register a plugin with a name that is already registered.",
25
- CantRemoveInternalPlugin = "You are trying to remove an internal unistyles plugin."
17
+ RuntimeUnavailable = "Unistyles runtime is not available. Make sure you followed the installation instructions",
18
+ ThemeNotFound = "You are trying to get a theme that is not registered with UnistylesRegistry",
19
+ ThemeNotRegistered = "You are trying to set a theme that was not registered with UnistylesRegistry",
20
+ ThemeNotSelected = "Your themes are registered, but you didn't select the initial theme",
21
+ ThemesCannotBeEmpty = "You are trying to register empty themes object",
22
+ BreakpointsCannotBeEmpty = "You are trying to register empty breakpoints object",
23
+ BreakpointsMustStartFromZero = "You are trying to register breakpoints that don't start from 0",
24
+ InvalidPluginName = "Plugin name can't start from reserved prefix __unistyles",
25
+ DuplicatePluginName = "You are trying to register a plugin with a name that is already registered",
26
+ CantRemoveInternalPlugin = "You are trying to remove an internal unistyles plugin"
26
27
  }
27
28
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,SAAqD,CAAA;AAC1E,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,8FAA8F;IAChH,aAAa,0DAA0D;IACvE,kBAAkB,0DAA0D;IAC5E,mBAAmB,uDAAuD;IAC1E,wBAAwB,4DAA4D;IACpF,4BAA4B,sCAAsC;IAClE,iBAAiB,oEAAqE;IACtF,mBAAmB,gFAAgF;IACnG,wBAAwB,2DAA2D;CACtF"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,SAAqD,CAAA;AAC1E,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
@@ -9,9 +9,45 @@ export declare class UnistyleRegistry {
9
9
  breakpoints: UnistylesBreakpoints;
10
10
  sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
11
11
  constructor(unistylesBridge: UnistylesBridge);
12
- addThemes: (themes: UnistylesThemes) => this;
13
- addBreakpoints: (breakpoints: UnistylesBreakpoints) => this;
14
- addConfig: (config: UnistylesConfig) => void;
12
+ addThemes: (themes: UnistylesThemes) => {
13
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
14
+ addThemes: any;
15
+ addConfig: (config: UnistylesConfig) => {
16
+ addBreakpoints: any;
17
+ addThemes: any;
18
+ };
19
+ };
20
+ addConfig: (config: UnistylesConfig) => {
21
+ addBreakpoints: any;
22
+ addThemes: any;
23
+ };
24
+ };
25
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
26
+ addThemes: (themes: UnistylesThemes) => {
27
+ addBreakpoints: any;
28
+ addConfig: (config: UnistylesConfig) => {
29
+ addBreakpoints: any;
30
+ addThemes: any;
31
+ };
32
+ };
33
+ addConfig: (config: UnistylesConfig) => {
34
+ addBreakpoints: any;
35
+ addThemes: any;
36
+ };
37
+ };
38
+ addConfig: (config: UnistylesConfig) => {
39
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
40
+ addThemes: (themes: UnistylesThemes) => {
41
+ addBreakpoints: any;
42
+ addConfig: any;
43
+ };
44
+ addConfig: any;
45
+ };
46
+ addThemes: (themes: UnistylesThemes) => {
47
+ addBreakpoints: any;
48
+ addConfig: any;
49
+ };
50
+ };
15
51
  getTheme: (forName: keyof UnistylesThemes) => never;
16
52
  addPlugin: (plugin: UnistylesPlugin, notify?: boolean) => void;
17
53
  removePlugin: (plugin: UnistylesPlugin) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAItE,qBAAa,gBAAgB;IAUb,OAAO,CAAC,eAAe;IAT5B,MAAM,EAAE,eAAe,CAAK;IAC5B,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,CAE9B;IACD,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAMzD;IAEM,SAAS,WAAY,eAAe,UAc1C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAUhD;IAEM,SAAS,WAAY,eAAe,WAAU,OAAO,UAW3D;IAEM,YAAY,WAAY,eAAe,UAO7C;IAEM,QAAQ,SAAU,MAAM,eAAe,aAAwB;CACzE"}
1
+ {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAItE,qBAAa,gBAAgB;IAUb,OAAO,CAAC,eAAe;IAT5B,MAAM,EAAE,eAAe,CAAK;IAC5B,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,CAE9B;IACD,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe;sCAcL,oBAAoB;;gCAW9B,eAAe;;;;;4BAAf,eAAe;;;;MAb1C;IAEM,cAAc,gBAAiB,oBAAoB;4BAd9B,eAAe;;gCAyBf,eAAe;;;;;4BAAf,eAAe;;;;MAF1C;IAEM,SAAS,WAAY,eAAe;sCAXL,oBAAoB;gCAd9B,eAAe;;;;;;4BAAf,eAAe;;;;MA4C1C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAchD;IAEM,SAAS,WAAY,eAAe,WAAU,OAAO,UAW3D;IAEM,YAAY,WAAY,eAAe,UAO7C;IAEM,QAAQ,SAAU,MAAM,eAAe,aAAwB;CACzE"}
@@ -6,9 +6,54 @@ import { ScreenOrientation } from './common';
6
6
  import { useStyles } from './useStyles';
7
7
  import { createStyleSheet } from './createStyleSheet';
8
8
  declare const UnistylesRegistry: {
9
- addThemes: (themes: UnistylesThemes) => import("./core/UnistyleRegistry").UnistyleRegistry;
10
- addBreakpoints: (breakpoints: UnistylesBreakpoints) => import("./core/UnistyleRegistry").UnistyleRegistry;
11
- addConfig: (config: import("./types").UnistylesConfig) => void;
9
+ addThemes: (themes: UnistylesThemes) => {
10
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
11
+ addThemes: any;
12
+ addConfig: (config: import("./types").UnistylesConfig) => {
13
+ addBreakpoints: any;
14
+ addThemes: any;
15
+ };
16
+ };
17
+ addConfig: (config: import("./types").UnistylesConfig) => {
18
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
19
+ addThemes: any;
20
+ addConfig: any;
21
+ };
22
+ addThemes: any;
23
+ };
24
+ };
25
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
26
+ addThemes: (themes: UnistylesThemes) => {
27
+ addBreakpoints: any;
28
+ addConfig: (config: import("./types").UnistylesConfig) => {
29
+ addBreakpoints: any;
30
+ addThemes: any;
31
+ };
32
+ };
33
+ addConfig: (config: import("./types").UnistylesConfig) => {
34
+ addBreakpoints: any;
35
+ addThemes: (themes: UnistylesThemes) => {
36
+ addBreakpoints: any;
37
+ addConfig: any;
38
+ };
39
+ };
40
+ };
41
+ addConfig: (config: import("./types").UnistylesConfig) => {
42
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
43
+ addThemes: (themes: UnistylesThemes) => {
44
+ addBreakpoints: any;
45
+ addConfig: any;
46
+ };
47
+ addConfig: any;
48
+ };
49
+ addThemes: (themes: UnistylesThemes) => {
50
+ addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
51
+ addThemes: any;
52
+ addConfig: any;
53
+ };
54
+ addConfig: any;
55
+ };
56
+ };
12
57
  };
13
58
  declare const UnistylesRuntime: import("./core").UnistylesRuntime;
14
59
  export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,gJAgDrB,CAAA"}
1
+ {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,gJAsCrB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-alpha.16",
3
+ "version": "2.0.0-alpha.17",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/src/common.ts CHANGED
@@ -22,13 +22,14 @@ export enum UnistylesEventType {
22
22
  }
23
23
 
24
24
  export enum UnistylesError {
25
- RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions.',
26
- ThemeNotFound = 'You are trying to get a theme that is not registered.',
27
- ThemeNotRegistered = 'You are trying to set a theme that is not registered.',
28
- ThemesCannotBeEmpty = 'You are trying to register an empty themes object.',
29
- BreakpointsCannotBeEmpty = 'You are trying to register an empty breakpoints object.',
30
- BreakpointsMustStartFromZero = 'One breakpoint must start from 0.',
31
- InvalidPluginName = 'Plugin name can\'t start from reserved prefix. Use another name.',
32
- DuplicatePluginName = 'You are trying to register a plugin with a name that is already registered.',
33
- CantRemoveInternalPlugin = 'You are trying to remove an internal unistyles plugin.'
25
+ RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions',
26
+ ThemeNotFound = 'You are trying to get a theme that is not registered with UnistylesRegistry',
27
+ ThemeNotRegistered = 'You are trying to set a theme that was not registered with UnistylesRegistry',
28
+ ThemeNotSelected = 'Your themes are registered, but you didn\'t select the initial theme',
29
+ ThemesCannotBeEmpty = 'You are trying to register empty themes object',
30
+ BreakpointsCannotBeEmpty = 'You are trying to register empty breakpoints object',
31
+ BreakpointsMustStartFromZero = 'You are trying to register breakpoints that don\'t start from 0',
32
+ InvalidPluginName = 'Plugin name can\'t start from reserved prefix __unistyles',
33
+ DuplicatePluginName = 'You are trying to register a plugin with a name that is already registered',
34
+ CantRemoveInternalPlugin = 'You are trying to remove an internal unistyles plugin'
34
35
  }
@@ -23,7 +23,10 @@ export class UnistyleRegistry {
23
23
  this.unistylesBridge.themes = keys
24
24
  this.themeNames = keys
25
25
 
26
- return this
26
+ return {
27
+ addBreakpoints: this.addBreakpoints,
28
+ addConfig: this.addConfig
29
+ }
27
30
  }
28
31
 
29
32
  public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
@@ -31,7 +34,10 @@ export class UnistyleRegistry {
31
34
  this.unistylesBridge.useBreakpoints(breakpoints)
32
35
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs
33
36
 
34
- return this
37
+ return {
38
+ addThemes: this.addThemes,
39
+ addConfig: this.addConfig
40
+ }
35
41
  }
36
42
 
37
43
  public addConfig = (config: UnistylesConfig) => {
@@ -48,6 +54,11 @@ export class UnistyleRegistry {
48
54
  if (config.initialTheme) {
49
55
  this.unistylesBridge.useTheme(config.initialTheme)
50
56
  }
57
+
58
+ return {
59
+ addBreakpoints: this.addBreakpoints,
60
+ addThemes: this.addThemes
61
+ }
51
62
  }
52
63
 
53
64
  public getTheme = (forName: keyof UnistylesThemes) => {
@@ -55,11 +66,15 @@ export class UnistyleRegistry {
55
66
  return {} as UnistylesThemes[keyof UnistylesThemes]
56
67
  }
57
68
 
58
- if (!this.hasTheme(forName)) {
69
+ if (this.hasTheme(forName)) {
70
+ return this.themes[forName]
71
+ }
72
+
73
+ if (this.unistylesBridge.themeName) {
59
74
  throw new Error(UnistylesError.ThemeNotFound)
60
75
  }
61
76
 
62
- return this.themes[forName]
77
+ throw new Error(UnistylesError.ThemeNotSelected)
63
78
  }
64
79
 
65
80
  public addPlugin = (plugin: UnistylesPlugin, notify: boolean = true) => {
package/src/useStyles.ts CHANGED
@@ -22,22 +22,13 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
22
22
  variantsMap?: ExtractVariantNames<typeof stylesheet>
23
23
  ): ParsedStylesheet<ST> => {
24
24
  const { theme, layout, plugins } = useUnistyles()
25
-
26
- if (!stylesheet) {
27
- return {
28
- theme,
29
- breakpoint: layout.breakpoint,
30
- styles: {} as ReactNativeStyleSheet<ST>
31
- }
32
- }
33
-
34
25
  const variants = useVariants(variantsMap)
35
26
  const parsedStyles = useMemo(() => typeof stylesheet === 'function'
36
27
  ? stylesheet(theme)
37
28
  : stylesheet, [theme, stylesheet, layout])
38
29
 
39
30
  const dynamicStyleSheet = useMemo(() => Object
40
- .entries(parsedStyles)
31
+ .entries(parsedStyles || {})
41
32
  .reduce((acc, [key, value]) => {
42
33
  if (typeof value === 'function') {
43
34
  return {
@@ -56,13 +47,12 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
56
47
  variants
57
48
  )
58
49
  })
59
- }, {}),
60
- [layout, parsedStyles, variants, plugins]
61
- ) as ReactNativeStyleSheet<ST>
50
+ }, {}), [layout, parsedStyles, variants, plugins]
51
+ )
62
52
 
63
53
  return {
64
54
  theme,
65
55
  breakpoint: layout.breakpoint,
66
- styles: dynamicStyleSheet
56
+ styles: dynamicStyleSheet as ReactNativeStyleSheet<ST>
67
57
  }
68
58
  }