react-native-unistyles 2.0.0-beta.3 → 2.0.0-beta.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,14 +6,10 @@ add_library(unistyles
6
6
  SHARED
7
7
  ../cxx/UnistylesRuntime.cpp
8
8
  ./src/main/cxx/cpp-adapter.cpp
9
- ../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp
10
9
  )
11
10
 
12
11
  include_directories(
13
12
  ../cxx
14
- ../node_modules/react-native/React
15
- ../node_modules/react-native/React/Base
16
- ../node_modules/react-native/ReactCommon/jsi
17
13
  )
18
14
 
19
15
  set_target_properties(unistyles PROPERTIES
@@ -23,6 +19,9 @@ set_target_properties(unistyles PROPERTIES
23
19
  POSITION_INDEPENDENT_CODE ON
24
20
  )
25
21
 
22
+ find_package(ReactAndroid REQUIRED CONFIG)
23
+
26
24
  target_link_libraries(unistyles
25
+ ReactAndroid::jsi
27
26
  android
28
27
  )
@@ -15,12 +15,28 @@ buildscript {
15
15
  apply plugin: 'com.android.library'
16
16
  apply plugin: 'org.jetbrains.kotlin.android'
17
17
 
18
+ def resolveBuildType() {
19
+ Gradle gradle = getGradle()
20
+ String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
21
+
22
+ return tskReqStr.contains('Release') ? 'release' : 'debug'
23
+ }
24
+
18
25
  android {
19
26
  compileSdkVersion safeExtGet('compileSdkVersion', 33)
20
27
  namespace "com.unistyles"
21
28
 
22
29
  defaultConfig {
23
30
  minSdkVersion safeExtGet('minSdkVersion', 21)
31
+ externalNativeBuild {
32
+ cmake {
33
+ arguments "-DANDROID_STL=c++_shared"
34
+ }
35
+ }
36
+ }
37
+
38
+ buildFeatures {
39
+ prefab true
24
40
  }
25
41
 
26
42
  externalNativeBuild {
@@ -28,6 +44,16 @@ android {
28
44
  path "CMakeLists.txt"
29
45
  }
30
46
  }
47
+
48
+ packagingOptions {
49
+ doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
50
+ excludes = [
51
+ "META-INF",
52
+ "META-INF/**",
53
+ "**/libjsi.so",
54
+ "**/libc++_shared.so"
55
+ ]
56
+ }
31
57
  }
32
58
 
33
59
  repositories {
@@ -16,7 +16,8 @@ class Unistyles {
16
16
  }
17
17
 
18
18
  // @ts-ignore
19
- this._bridge = (_common.isWeb ? window : global).__UNISTYLES__;
19
+ // eslint-disable-next-line no-undef
20
+ this._bridge = (_common.isWeb ? globalThis : global).__UNISTYLES__;
20
21
  this._registry = new _UnistyleRegistry.UnistyleRegistry(this._bridge);
21
22
  this._runtime = new _UnistylesRuntime.UnistylesRuntime(this._bridge, this._registry);
22
23
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistyleRegistry","_common","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","isWeb","window","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","registry","runtime","unistyles","exports"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAMI,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAG,CAACC,aAAK,GAAGC,MAAM,GAAGC,MAAM,EAAEC,aAAgC;IACzE,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,CAAC;IACnD,IAAI,CAACO,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACR,OAAO,EAAE,IAAI,CAACK,SAAS,CAAC;EACtE;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACJ,SAAS;EACzB;EAEA,IAAWK,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;AACJ;AAEO,MAAMI,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAInB,SAAS,CAAC,CAAC"}
1
+ {"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistyleRegistry","_common","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","isWeb","globalThis","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","registry","runtime","unistyles","exports"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAMI,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA;IACA,IAAI,CAACC,OAAO,GAAG,CAACC,aAAK,GAAGC,UAAU,GAAGC,MAAM,EAAEC,aAAgC;IAC7E,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,CAAC;IACnD,IAAI,CAACO,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACR,OAAO,EAAE,IAAI,CAACK,SAAS,CAAC;EACtE;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACJ,SAAS;EACzB;EAEA,IAAWK,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;AACJ;AAEO,MAAMI,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAInB,SAAS,CAAC,CAAC"}
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.UnistylesModule = exports.UnistylesBridgeWeb = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  var _plugins = require("../plugins");
9
+ var _common = require("../common");
9
10
  class UnistylesBridgeWeb {
10
11
  #timerRef = undefined;
11
12
  #hasAdaptiveThemes = false;
12
13
  #supportsAutomaticColorScheme = false;
13
- #screenWidth = window.innerWidth;
14
- #screenHeight = window.innerHeight;
14
+ #screenWidth = _common.isServer ? undefined : window.innerWidth;
15
+ #screenHeight = _common.isServer ? undefined : window.innerHeight;
15
16
  #themes = [];
16
17
  #breakpoints = {};
17
18
  #colorScheme = this.getPreferredColorScheme();
@@ -21,11 +22,16 @@ class UnistylesBridgeWeb {
21
22
  #sortedBreakpointPairs = [];
22
23
  #breakpoint = '';
23
24
  constructor() {
24
- this.setupListeners();
25
+ if (!_common.isServer) {
26
+ this.setupListeners();
27
+ this.#screenWidth = window.innerWidth;
28
+ this.#screenHeight = window.innerHeight;
29
+ }
25
30
  }
26
31
  install() {
27
32
  // @ts-ignore
28
- window.__UNISTYLES__ = new Proxy({}, {
33
+ // eslint-disable-next-line no-undef
34
+ globalThis.__UNISTYLES__ = new Proxy({}, {
29
35
  get: (_target, prop) => {
30
36
  switch (prop) {
31
37
  case 'themeName':
@@ -92,7 +98,9 @@ class UnistylesBridgeWeb {
92
98
  let [, b] = _ref2;
93
99
  return (a ?? 0) - (b ?? 0);
94
100
  });
95
- this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
101
+ if (!_common.isServer) {
102
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
103
+ }
96
104
  }
97
105
  useAdaptiveThemes(enable) {
98
106
  this.#hasAdaptiveThemes = enable;
@@ -154,7 +162,7 @@ class UnistylesBridgeWeb {
154
162
  return breakpoint?.at(0);
155
163
  }
156
164
  getPreferredColorScheme() {
157
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
165
+ if (!_common.isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
158
166
  return 'dark';
159
167
  }
160
168
  return 'light';
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_plugins","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAWC,MAAM,CAACC,UAAU;EACxC,CAACC,YAAY,GAAWF,MAAM,CAACG,WAAW;EAC1C,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,u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,MAAM,EAAE,IAAI,CAAC,CAACzE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC0E,OAAA,CAAAlF,kBAAA,GAAAA,kBAAA;AAEM,MAAMmF,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,IAAInF,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"names":["_reactNative","require","_plugins","_common","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","isServer","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGC,gBAAQ,GAAGJ,SAAS,GAAGK,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGH,gBAAQ,GAAGJ,SAAS,GAAGK,MAAM,CAACG,WAAW;EACzD,CAACC,MAAM,GAAiC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CAAC2D,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLxD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5ByD,WAAW,EAAG,IAAI,CAAC,CAAC5E,WAAW,GAAe,IAAI,CAAC,CAACI,YAAuB,GACrE,WAAW,GACX,UAAU;QAChByE,MAAM,EAAE;UACJZ,KAAK,EAAE,IAAI,CAAC,CAACjE,WAAW;UACxB8E,MAAM,EAAE,IAAI,CAAC,CAAC1E;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC2E,OAAA,CAAApF,kBAAA,GAAAA,kBAAA;AAEM,MAAMqF,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,IAAIrF,kBAAkB,CAAC,CAAC"}
@@ -45,7 +45,8 @@ const parseStyle = function (style) {
45
45
  ...acc,
46
46
  ...Object.keys(value).reduce((acc, key) => ({
47
47
  ...acc,
48
- ...parseStyle(value[key][variant[key] || 'default'] ?? {})
48
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
49
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
49
50
  }), {})
50
51
  };
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EA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EAAE;MAC7Ca,GAAG,CAACzB,GAAG,CAAC,GAAGY,KAAK,CAACiB,GAAG,CAACjB,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEV,OAAO,CAAC,CAAC;MAEzD,OAAOuB,GAAG;IACd;;IAEA;IACA,IAAI,OAAOb,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;MACrDa,GAAG,CAACzB,GAAG,CAAY,GAAGY,KAAK;MAE3B,OAAOa,GAAG;IACd;IAEA,IAAIzB,GAAG,KAAK,UAAU,EAAE;MACpB,OAAO;QACH,GAAGyB,GAAG;QACN,GAAIH,MAAM,CACLQ,IAAI,CAAClB,KAAK,CAAC,CACXY,MAAM,CAAC,CAACC,GAAG,EAAEzB,GAAG,MAAM;UACnB,GAAGyB,GAAG;UACN,GAAGhB,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;;IAEA;IACA,IAAI,CAACqB,iBAAiB,EAAE;MACpB,OAAO;QACH,GAAGI,GAAG;QACN,CAACzB,GAAG,GAAGY;MACX,CAAC;IACL;IAEA,OAAO;MACH,GAAGa,GAAG;MACN,CAACzB,GAAG,GAAG,IAAA+B,kCAAqB,EAACnB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,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10
  }
11
11
 
12
12
  // @ts-ignore
13
- this._bridge = (isWeb ? window : global).__UNISTYLES__;
13
+ // eslint-disable-next-line no-undef
14
+ this._bridge = (isWeb ? globalThis : global).__UNISTYLES__;
14
15
  this._registry = new UnistyleRegistry(this._bridge);
15
16
  this._runtime = new UnistylesRuntime(this._bridge, this._registry);
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isWeb","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","window","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,EAAEC,KAAK,QAAQ,WAAW;AAEjD,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACN,cAAc,CAACO,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAG,CAACP,KAAK,GAAGQ,MAAM,GAAGC,MAAM,EAAEC,aAAgC;IACzE,IAAI,CAACC,SAAS,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIf,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACI,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,IAAId,SAAS,CAAC,CAAC"}
1
+ {"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistyleRegistry","UnistylesError","isWeb","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","globalThis","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,EAAEC,KAAK,QAAQ,WAAW;AAEjD,MAAMC,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACN,cAAc,CAACO,kBAAkB,CAAC;IACtD;;IAEA;IACA;IACA,IAAI,CAACC,OAAO,GAAG,CAACP,KAAK,GAAGQ,UAAU,GAAGC,MAAM,EAAEC,aAAgC;IAC7E,IAAI,CAACC,SAAS,GAAG,IAAIb,gBAAgB,CAAC,IAAI,CAACS,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIf,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACI,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,IAAId,SAAS,CAAC,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native';
2
2
  import { normalizeWebStylesPlugin } from '../plugins';
3
+ import { isServer } from '../common';
3
4
  export class UnistylesBridgeWeb {
4
5
  #timerRef = undefined;
5
6
  #hasAdaptiveThemes = false;
6
7
  #supportsAutomaticColorScheme = false;
7
- #screenWidth = window.innerWidth;
8
- #screenHeight = window.innerHeight;
8
+ #screenWidth = isServer ? undefined : window.innerWidth;
9
+ #screenHeight = isServer ? undefined : window.innerHeight;
9
10
  #themes = [];
10
11
  #breakpoints = {};
11
12
  #colorScheme = this.getPreferredColorScheme();
@@ -15,11 +16,16 @@ export class UnistylesBridgeWeb {
15
16
  #sortedBreakpointPairs = [];
16
17
  #breakpoint = '';
17
18
  constructor() {
18
- this.setupListeners();
19
+ if (!isServer) {
20
+ this.setupListeners();
21
+ this.#screenWidth = window.innerWidth;
22
+ this.#screenHeight = window.innerHeight;
23
+ }
19
24
  }
20
25
  install() {
21
26
  // @ts-ignore
22
- window.__UNISTYLES__ = new Proxy({}, {
27
+ // eslint-disable-next-line no-undef
28
+ globalThis.__UNISTYLES__ = new Proxy({}, {
23
29
  get: (_target, prop) => {
24
30
  switch (prop) {
25
31
  case 'themeName':
@@ -86,7 +92,9 @@ export class UnistylesBridgeWeb {
86
92
  let [, b] = _ref2;
87
93
  return (a ?? 0) - (b ?? 0);
88
94
  });
89
- this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
95
+ if (!isServer) {
96
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
97
+ }
90
98
  }
91
99
  useAdaptiveThemes(enable) {
92
100
  this.#hasAdaptiveThemes = enable;
@@ -148,7 +156,7 @@ export class UnistylesBridgeWeb {
148
156
  return breakpoint?.at(0);
149
157
  }
150
158
  getPreferredColorScheme() {
151
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
159
+ if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
152
160
  return 'dark';
153
161
  }
154
162
  return 'light';
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAWC,MAAM,CAACC,UAAU;EACxC,CAACC,YAAY,GAAWF,MAAM,CAACG,WAAW;EAC1C,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,CAACC,cAAc,GAAkB,CAAChB,wBAAwB,CAACiB,IAAI,CAAC;EAChE,CAACC,eAAe,GAAG,IAAIpB,kBAAkB,CAACC,aAAa,CAACoB,SAAS,CAAC;EAClE,CAACC,qBAAqB,GAAgD,EAAE;EACxE,CAACC,UAAU,GAA+B,EAAE;EAE5CC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACC,cAAc,CAAC,CAAC;EAC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AU,EAAEqC,EAAE,CAAC,CAAC,CAAC;EAC5B;EAEQ5C,uBAAuBA,CAAA,EAAG;IAC9B,IAAIP,MAAM,CAACwD,UAAU,IAAIxD,MAAM,CAACwD,UAAU,CAAC,8BAA8B,CAAC,CAACE,OAAO,EAAE;MAChF,OAAO,MAAM;IACjB;IAEA,OAAO,OAAO;EAClB;EAEQV,gBAAgBA,CAAA,EAAG;IACvB,IAAI,CAAC,CAACrC,eAAe,CAACwD,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;EAEQ9B,eAAeA,CAAA,EAAG;IACtB,IAAI,CAAC,CAAC3B,eAAe,CAACwD,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,OAAO;MACbC,OAAO,EAAE;QACL7D,SAAS,EAAE,IAAI,CAAC,CAACA;MACrB;IACJ,CAAC,CAAC;EACN;EAEQ+C,gBAAgBA,CAAA,EAAG;IACvB,IAAI,CAAC,CAAC5C,eAAe,CAACwD,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLvD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5BwD,WAAW,EAAE,IAAI,CAAC,CAACvE,WAAW,GAAG,IAAI,CAAC,CAACG,YAAY,GAC7C,WAAW,GACX,UAAU;QAChBqE,MAAM,EAAE;UACJZ,KAAK,EAAE,IAAI,CAAC,CAAC5D,WAAW;UACxByE,MAAM,EAAE,IAAI,CAAC,CAACtE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMuE,eAAe,GAAG,IAAI/E,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,QAAQ,QAAQ,WAAW;AAEpC,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGN,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGT,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACG,WAAW;EACzD,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,CAACC,cAAc,GAAkB,CAACjB,wBAAwB,CAACkB,IAAI,CAAC;EAChE,CAACC,eAAe,GAAG,IAAIrB,kBAAkB,CAACC,aAAa,CAACqB,SAAS,CAAC;EAClE,CAACC,qBAAqB,GAAgD,EAAE;EACxE,CAACC,UAAU,GAA+B,EAAE;EAE5CC,WAAWA,CAAA,EAAG;IACV,IAAI,CAACtB,Q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O,MAAMwE,eAAe,GAAG,IAAIhF,kBAAkB,CAAC,CAAC"}
@@ -37,7 +37,8 @@ export const parseStyle = function (style) {
37
37
  ...acc,
38
38
  ...Object.keys(value).reduce((acc, key) => ({
39
39
  ...acc,
40
- ...parseStyle(value[key][variant[key] || 'default'] ?? {})
40
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
41
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
41
42
  }), {})
42
43
  };
43
44
  }
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,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AAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;;IAEA;IACA,IAAI,CAACiB,iBAAiB,EAAE;MACpB,OAAO;QACH,GAAGI,GAAG;QACN,CAACrB,GAAG,GAAGU;MACX,CAAC;IACL;IAEA,OAAO;MACH,GAAGW,GAAG;MACN,CAACrB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA"}
1
+ {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,K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N;UACA,GAAGb,UAAU,CAAEE,KAAK,CAAEV,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKU,KAAK,CAAEV,GAAG,CAAC,CAAC2B,OAAO,IAAI,CAAC,CAAC;QAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;;IAEA;IACA,IAAI,CAACV,iBAAiB,EAAE;MACpB,OAAO;QACH,GAAGI,GAAG;QACN,CAACrB,GAAG,GAAGU;MACX,CAAC;IACL;IAEA,OAAO;MACH,GAAGW,GAAG;MACN,CAACrB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Unistyles.d.ts","sourceRoot":"","sources":["../../../../src/core/Unistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,cAAM,SAAS;IACX,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,OAAO,CAAiB;;IAehC,IAAW,QAAQ,qBAElB;IAED,IAAW,OAAO,qBAEjB;CACJ;AAED,eAAO,MAAM,SAAS,WAAkB,CAAA"}
1
+ {"version":3,"file":"Unistyles.d.ts","sourceRoot":"","sources":["../../../../src/core/Unistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAIrD,cAAM,SAAS;IACX,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,OAAO,CAAiB;;IAgBhC,IAAW,QAAQ,qBAElB;IAED,IAAW,OAAO,qBAEjB;CACJ;AAED,eAAO,MAAM,SAAS,WAAkB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesModule.web.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.web.ts"],"names":[],"mappings":"AAKA,qBAAa,kBAAkB;;;IAmBpB,OAAO;IA4Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
1
+ {"version":3,"file":"UnistylesModule.web.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.web.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAuBpB,OAAO;IA6Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAK1D,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,YACF,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAC3C,QAED,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,0CAEV,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,mCAkD9B,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAK1D,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,YACF,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAC3C,QAED,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,0CAEV,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,mCAmD9B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.5",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -17,7 +17,8 @@ class Unistyles {
17
17
  }
18
18
 
19
19
  // @ts-ignore
20
- this._bridge = (isWeb ? window : global).__UNISTYLES__ as UnistylesBridge
20
+ // eslint-disable-next-line no-undef
21
+ this._bridge = (isWeb ? globalThis : global).__UNISTYLES__ as UnistylesBridge
21
22
  this._registry = new UnistyleRegistry(this._bridge)
22
23
  this._runtime = new UnistylesRuntime(this._bridge, this._registry)
23
24
  }
@@ -2,13 +2,14 @@ import { NativeEventEmitter, NativeModules } from 'react-native'
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
3
3
  import type { ColorSchemeName } from '../types'
4
4
  import { normalizeWebStylesPlugin } from '../plugins'
5
+ import { isServer } from '../common'
5
6
 
6
7
  export class UnistylesBridgeWeb {
7
8
  #timerRef?: ReturnType<typeof setTimeout> = undefined
8
9
  #hasAdaptiveThemes: boolean = false
9
10
  #supportsAutomaticColorScheme = false
10
- #screenWidth: number = window.innerWidth
11
- #screenHeight: number = window.innerHeight
11
+ #screenWidth = isServer ? undefined : window.innerWidth
12
+ #screenHeight = isServer ? undefined : window.innerHeight
12
13
  #themes: Array<keyof UnistylesThemes> = []
13
14
  #breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
14
15
  #colorScheme: ColorSchemeName = this.getPreferredColorScheme()
@@ -19,12 +20,17 @@ export class UnistylesBridgeWeb {
19
20
  #breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
20
21
 
21
22
  constructor() {
22
- this.setupListeners()
23
+ if (!isServer) {
24
+ this.setupListeners()
25
+ this.#screenWidth = window.innerWidth
26
+ this.#screenHeight = window.innerHeight
27
+ }
23
28
  }
24
29
 
25
30
  public install() {
26
31
  // @ts-ignore
27
- window.__UNISTYLES__ = new Proxy({}, {
32
+ // eslint-disable-next-line no-undef
33
+ globalThis.__UNISTYLES__ = new Proxy({}, {
28
34
  get: (_target, prop) => {
29
35
  switch (prop) {
30
36
  case 'themeName':
@@ -92,7 +98,10 @@ export class UnistylesBridgeWeb {
92
98
  this.#sortedBreakpointPairs = Object
93
99
  .entries(breakpoints)
94
100
  .sort(([, a], [, b]) => (a ?? 0) - (b ?? 0)) as Array<[keyof UnistylesBreakpoints, number]>
95
- this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth)
101
+
102
+ if (!isServer) {
103
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth as number)
104
+ }
96
105
  }
97
106
 
98
107
  private useAdaptiveThemes(enable: boolean) {
@@ -176,7 +185,7 @@ export class UnistylesBridgeWeb {
176
185
  }
177
186
 
178
187
  private getPreferredColorScheme() {
179
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
188
+ if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
180
189
  return 'dark'
181
190
  }
182
191
 
@@ -203,7 +212,7 @@ export class UnistylesBridgeWeb {
203
212
  type: 'layout',
204
213
  payload: {
205
214
  breakpoint: this.#breakpoint,
206
- orientation: this.#screenWidth > this.#screenHeight
215
+ orientation: (this.#screenWidth as number) > (this.#screenHeight as number)
207
216
  ? 'landscape'
208
217
  : 'portrait',
209
218
  screen: {
@@ -54,7 +54,8 @@ export const parseStyle = <T extends RNStyle>(
54
54
  .keys(value) as Array<keyof typeof value>)
55
55
  .reduce((acc, key) => ({
56
56
  ...acc,
57
- ...parseStyle((value)[key][variant[key as keyof typeof variant] || 'default'] ?? {})
57
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
58
+ ...parseStyle((value)[key][variant[key as keyof typeof variant] || 'default'] ?? (value)[key].default ?? {})
58
59
  }), {})
59
60
  }
60
61
  }