react-native-unistyles 2.0.0-beta.7 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +22 -35
  2. package/lib/commonjs/core/UnistyleRegistry.js +15 -25
  3. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  4. package/lib/commonjs/core/UnistylesModule.js +187 -2
  5. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  6. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  7. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  8. package/lib/commonjs/core/UnistylesRuntime.js +64 -0
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/createStyleSheet.js +5 -0
  11. package/lib/commonjs/createStyleSheet.js.map +1 -1
  12. package/lib/commonjs/hooks/useCSS.js +36 -1
  13. package/lib/commonjs/hooks/useCSS.js.map +1 -1
  14. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  15. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  16. package/lib/commonjs/index.js +16 -0
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/normalizer/normalizer.js +1 -2
  19. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  20. package/lib/commonjs/useStyles.js +7 -2
  21. package/lib/commonjs/useStyles.js.map +1 -1
  22. package/lib/commonjs/utils/breakpoints.js +2 -11
  23. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  24. package/lib/commonjs/utils/cssMediaQuery.js +3 -9
  25. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
  26. package/lib/commonjs/utils/mq.js +17 -36
  27. package/lib/commonjs/utils/mq.js.map +1 -1
  28. package/lib/commonjs/utils/mqParser.js +1 -2
  29. package/lib/commonjs/utils/mqParser.js.map +1 -1
  30. package/lib/commonjs/utils/styles.js +34 -39
  31. package/lib/commonjs/utils/styles.js.map +1 -1
  32. package/lib/module/core/UnistyleRegistry.js +15 -25
  33. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  34. package/lib/module/core/UnistylesModule.js +186 -2
  35. package/lib/module/core/UnistylesModule.js.map +1 -1
  36. package/lib/module/core/UnistylesModule.native.js +3 -0
  37. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  38. package/lib/module/core/UnistylesRuntime.js +64 -0
  39. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  40. package/lib/module/createStyleSheet.js +5 -0
  41. package/lib/module/createStyleSheet.js.map +1 -1
  42. package/lib/module/hooks/useCSS.js +36 -1
  43. package/lib/module/hooks/useCSS.js.map +1 -1
  44. package/lib/module/hooks/useCSS.native.js +2 -0
  45. package/lib/module/hooks/useCSS.native.js.map +1 -0
  46. package/lib/module/index.js +17 -0
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/normalizer/normalizer.js +1 -2
  49. package/lib/module/normalizer/normalizer.js.map +1 -1
  50. package/lib/module/useStyles.js +7 -2
  51. package/lib/module/useStyles.js.map +1 -1
  52. package/lib/module/utils/breakpoints.js +2 -11
  53. package/lib/module/utils/breakpoints.js.map +1 -1
  54. package/lib/module/utils/cssMediaQuery.js +3 -9
  55. package/lib/module/utils/cssMediaQuery.js.map +1 -1
  56. package/lib/module/utils/mq.js +17 -36
  57. package/lib/module/utils/mq.js.map +1 -1
  58. package/lib/module/utils/mqParser.js +1 -2
  59. package/lib/module/utils/mqParser.js.map +1 -1
  60. package/lib/module/utils/styles.js +34 -39
  61. package/lib/module/utils/styles.js.map +1 -1
  62. package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
  63. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  64. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  65. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  66. package/lib/typescript/src/core/UnistylesRuntime.d.ts +52 -0
  67. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  68. package/lib/typescript/src/createStyleSheet.d.ts +5 -0
  69. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  70. package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
  71. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
  72. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  73. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  74. package/lib/typescript/src/index.d.ts +16 -0
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/useStyles.d.ts +6 -0
  77. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  78. package/lib/typescript/src/utils/mq.d.ts +4 -0
  79. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  80. package/package.json +14 -16
  81. package/src/core/UnistylesModule.native.ts +7 -0
  82. package/src/core/UnistylesModule.ts +224 -4
  83. package/src/core/UnistylesRuntime.ts +52 -0
  84. package/src/createStyleSheet.ts +5 -0
  85. package/src/hooks/useCSS.native.ts +3 -0
  86. package/src/hooks/useCSS.ts +49 -1
  87. package/src/index.ts +16 -0
  88. package/src/useStyles.ts +6 -0
  89. package/src/utils/mq.ts +4 -0
  90. package/lib/commonjs/core/UnistylesModule.web.js +0 -199
  91. package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
  92. package/lib/commonjs/hooks/useCSS.web.js +0 -46
  93. package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
  94. package/lib/module/core/UnistylesModule.web.js +0 -192
  95. package/lib/module/core/UnistylesModule.web.js.map +0 -1
  96. package/lib/module/hooks/useCSS.web.js +0 -39
  97. package/lib/module/hooks/useCSS.web.js.map +0 -1
  98. package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
  99. package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
  100. package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
  101. package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
  102. package/src/core/UnistylesModule.web.ts +0 -227
  103. package/src/hooks/useCSS.web.ts +0 -51
package/README.md CHANGED
@@ -1,55 +1,42 @@
1
- [<img alt="react-native-unistyles" src="assets/banner.png">](https://codemask.com)
2
-
3
-
4
- <picture>
5
- <source media="(prefers-color-scheme: dark)" srcset="assets/uni-dark.svg">
6
- <img alt="react-native-unistyles" src="assets/uni-light.svg">
7
- </picture>
1
+ [<img alt="react-native-unistyles" src="assets/banner.png">](https://reactnativeunistyles.vercel.app/)
8
2
 
9
3
  ![GitHub package.json version](https://img.shields.io/github/package-json/v/jpudysz/react-native-unistyles?style=for-the-badge)
10
4
  [![npm downloads](https://img.shields.io/npm/dm/react-native-unistyles.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-unistyles)
11
5
  ![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20IOS%20%7C%20SSR%20%7C%20Web-blue.svg?style=for-the-badge)
12
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
13
7
 
8
+ ## [Documentation](https://reactnativeunistyles.vercel.app/)
9
+ - [Start here](https://reactnativeunistyles.vercel.app/start/introduction/)
10
+ - [API](https://reactnativeunistyles.vercel.app/reference/create-stylesheet/)
11
+ - [Show case](https://reactnativeunistyles.vercel.app/show-case/projects/)
12
+ - [Examples](https://reactnativeunistyles.vercel.app/examples/all/)
13
+
14
14
  ## Features
15
- - Blazing fast, adds around ~3ms on top of StyleSheet*
15
+ - 🚀 Shared core with C++ and JSI bindings
16
+ - 🌉 Supports new architecture
17
+ - 🔥 Crazy performance, adds under 0.1 ms to your StyleSheet
16
18
  - 🎳 Share up to 100% of your styles across platforms in monorepo
17
- - 🎯 Doesn't introduce new components
18
- - 🖥️ Supports custom breakpoints and css-like media queries
19
- - 🎨 Access theme in your StyleSheets and components
20
- - 🪄 Supports dynamic functions to access values from JSX
21
- - 🥳 Compatible with Expo, Expo Go, Bare React Native, React Native Web and SSR
19
+ - 🎯 Doesn't introduce new components, everything is packed in one hook
20
+ - ⚛️ No React Context
21
+ - 🖥️ Supports custom breakpoints, css-like media queries and variants
22
+ - 🎨 Register multiple themes and change them with single function call
23
+ - 🥳 Compatible with Expo, Bare React Native, React Native Web and SSR
22
24
  - 🛡️ ~99% Test coverage
25
+ - 🔌 Extend stylesheets with your own plugins
23
26
  - ⚔️ No 3rd party dependencies
24
-
25
- *-based on this [benchmark](https://github.com/efstathiosntonas/react-native-style-libraries-benchmark)
27
+ - and much much more!
26
28
 
27
29
  ## Installation
28
30
 
29
- ```cmd
30
- yarn add react-native-unistyles
31
- ```
32
-
33
- ## [Documentation](https://reactnativeunistyles.vercel.app/)
34
- - [Start here](https://reactnativeunistyles.vercel.app/start/setup/)
35
- - [References](https://reactnativeunistyles.vercel.app/reference/create-stylesheet/)
36
- - [Examples](https://reactnativeunistyles.vercel.app/example/breakpoints/)
37
-
38
- ## Faster, better and simpler - v.2.0 🚀
39
-
40
- There is ongoing work on branch [2.0](https://github.com/jpudysz/react-native-unistyles/tree/2.0).
41
-
42
- ---
43
-
44
- Join early testers and discussion [here](https://github.com/jpudysz/react-native-unistyles/discussions/41).
45
-
46
- ```cmd
31
+ ```shell
32
+ # Unistyles is currently in RC phase
47
33
  yarn add react-native-unistyles@next
48
34
  ```
49
35
 
50
- ## Blog post
36
+ ## Discord
37
+ Looking for help or you want to chat with me?
51
38
 
52
- Read about what drove me to create this library in this blog post [here](https://www.reactnativecrossroads.com/posts/level-up-react-native-styles).
39
+ [Join Discord](https://discord.gg/akGHf27P4C)
53
40
 
54
41
  ## Sponsor my work
55
42
 
@@ -67,35 +67,25 @@ class UnistyleRegistry {
67
67
  }
68
68
  throw new Error(_common.UnistylesError.ThemeNotSelected);
69
69
  };
70
- addPlugin = (() => {
71
- var _this = this;
72
- return function (plugin) {
73
- let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
74
- if (plugin.name.startsWith('__unistyles')) {
75
- throw new Error(_common.UnistylesError.InvalidPluginName);
76
- }
77
- if (_this.plugins.some(_ref => {
78
- let {
79
- name
80
- } = _ref;
81
- return name === plugin.name;
82
- })) {
83
- throw new Error(_common.UnistylesError.DuplicatePluginName);
84
- }
85
- _this.plugins = [plugin].concat(_this.plugins);
86
- _this.unistylesBridge.addPlugin(plugin.name, notify);
87
- };
88
- })();
70
+ addPlugin = (plugin, notify = true) => {
71
+ if (plugin.name.startsWith('__unistyles')) {
72
+ throw new Error(_common.UnistylesError.InvalidPluginName);
73
+ }
74
+ if (this.plugins.some(({
75
+ name
76
+ }) => name === plugin.name)) {
77
+ throw new Error(_common.UnistylesError.DuplicatePluginName);
78
+ }
79
+ this.plugins = [plugin].concat(this.plugins);
80
+ this.unistylesBridge.addPlugin(plugin.name, notify);
81
+ };
89
82
  removePlugin = plugin => {
90
83
  if (plugin.name.startsWith('__unistyles')) {
91
84
  throw new Error(_common.UnistylesError.CantRemoveInternalPlugin);
92
85
  }
93
- this.plugins = this.plugins.filter(_ref2 => {
94
- let {
95
- name
96
- } = _ref2;
97
- return name !== plugin.name;
98
- });
86
+ this.plugins = this.plugins.filter(({
87
+ name
88
+ }) => name !== plugin.name);
99
89
  this.unistylesBridge.removePlugin(plugin.name);
100
90
  };
101
91
  hasTheme = name => name in this.themes;
@@ -1 +1 @@
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","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","_ref2","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IA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,MAAM,IAAIR,KAAK,CAACC,sBAAc,CAACQ,iBAAiB,CAAC;MACrD;MAEA,IAAIL,KAAI,CAACnC,OAAO,CAACyC,IAAI,CAACC,IAAA;QAAA,IAAC;UAAEjB;QAAK,CAAC,GAAAiB,IAAA;QAAA,OAAKjB,IAAI,KAAKP,MAAM,CAACO,IAAI;MAAA,EAAC,EAAE;QACvD,MAAM,IAAIM,KAAK,CAACC,sBAAc,CAACW,mBAAmB,CAAC;MACvD;MAEAR,KAAI,CAACnC,OAAO,GAAG,CAACkB,MAAM,CAAC,CAACM,MAAM,CAACW,KAAI,CAACnC,OAAO,CAAC;MAC5CmC,KAAI,CAAC3B,eAAe,CAACW,SAAS,CAACD,MAAM,CAACO,IAAI,EAAEW,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMQ,YAAY,GAAI1B,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACO,IAAI,CAACc,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIR,KAAK,CAACC,sBAAc,CAACa,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAAC7C,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC8C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEtB;MAAK,CAAC,GAAAsB,KAAA;MAAA,OAAKtB,IAAI,KAAKP,MAAM,CAACO,IAAI;IAAA,EAAC;IACtE,IAAI,CAACjB,eAAe,CAACoC,YAAY,CAAC1B,MAAM,CAACO,IAAI,CAAC;EAClD,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACrB,MAAM;AAC1E;AAAC4C,OAAA,CAAAlD,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","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","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;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACM,cAAc,CAACT,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO;MACHG,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,SAAS,EAAE,I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AAC;EACpD,CAAC;EAEMf,SAAS,GAAGA,CAACD,MAAuB,EAAEiB,MAAe,GAAG,IAAI,KAAK;IACpE,IAAIjB,MAAM,CAACO,IAAI,CAACW,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIL,KAAK,CAACC,sBAAc,CAACK,iBAAiB,CAAC;IACrD;IAEA,IAAI,IAAI,CAACrC,OAAO,CAACsC,IAAI,CAAC,CAAC;MAAEb;IAAK,CAAC,KAAKA,IAAI,KAAKP,MAAM,CAACO,IAAI,CAAC,EAAE;MACvD,MAAM,IAAIM,KAAK,CAACC,sBAAc,CAACO,mBAAmB,CAAC;IACvD;IAEA,IAAI,CAACvC,OAAO,GAAG,CAACkB,MAAM,CAAC,CAACM,MAAM,CAAC,IAAI,CAACxB,OAAO,CAAC;IAC5C,IAAI,CAACQ,eAAe,CAACW,SAAS,CAACD,MAAM,CAACO,IAAI,EAAEU,MAAM,CAAC;EACvD,CAAC;EAEMK,YAAY,GAAItB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACO,IAAI,CAACW,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIL,KAAK,CAACC,sBAAc,CAACS,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACzC,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC0C,MAAM,CAAC,CAAC;MAAEjB;IAAK,CAAC,KAAKA,IAAI,KAAKP,MAAM,CAACO,IAAI,CAAC;IACtE,IAAI,CAACjB,eAAe,CAACgC,YAAY,CAACtB,MAAM,CAACO,IAAI,CAAC;EAClD,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACrB,MAAM;AAC1E;AAACuC,OAAA,CAAA7C,gBAAA,GAAAA,gBAAA"}
@@ -3,7 +3,192 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UnistylesModule = void 0;
6
+ exports.UnistylesModule = exports.UnistylesBridgeWeb = void 0;
7
7
  var _reactNative = require("react-native");
8
- const UnistylesModule = exports.UnistylesModule = _reactNative.NativeModules?.Unistyles;
8
+ var _plugins = require("../plugins");
9
+ var _common = require("../common");
10
+ class UnistylesBridgeWeb {
11
+ #timerRef = undefined;
12
+ #hasAdaptiveThemes = false;
13
+ #supportsAutomaticColorScheme = false;
14
+ #screenWidth = _common.isServer ? undefined : window.innerWidth;
15
+ #screenHeight = _common.isServer ? undefined : window.innerHeight;
16
+ #themes = [];
17
+ #breakpoints = {};
18
+ #colorScheme = this.getPreferredColorScheme();
19
+ #themeName = '';
20
+ #enabledPlugins = [_plugins.normalizeWebStylesPlugin.name];
21
+ #unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
22
+ #sortedBreakpointPairs = [];
23
+ #breakpoint = '';
24
+ constructor() {
25
+ if (!_common.isServer) {
26
+ this.setupListeners();
27
+ this.#screenWidth = window.innerWidth;
28
+ this.#screenHeight = window.innerHeight;
29
+ }
30
+ }
31
+ install() {
32
+ // @ts-ignore
33
+ // eslint-disable-next-line no-undef
34
+ globalThis.__UNISTYLES__ = new Proxy({}, {
35
+ get: (_target, prop) => {
36
+ switch (prop) {
37
+ case 'themeName':
38
+ return this.getTheme();
39
+ case 'screenWidth':
40
+ return this.#screenWidth;
41
+ case 'screenHeight':
42
+ return this.#screenHeight;
43
+ case 'breakpoint':
44
+ return this.#breakpoint || undefined;
45
+ case 'breakpoints':
46
+ return this.#breakpoints;
47
+ case 'hasAdaptiveThemes':
48
+ return this.#hasAdaptiveThemes;
49
+ case 'sortedBreakpointPairs':
50
+ return this.#sortedBreakpointPairs;
51
+ case 'enabledPlugins':
52
+ return this.#enabledPlugins;
53
+ case 'colorScheme':
54
+ return this.#colorScheme;
55
+ case 'useTheme':
56
+ return themeName => this.useTheme(themeName);
57
+ case 'useBreakpoints':
58
+ return breakpoints => this.useBreakpoints(breakpoints);
59
+ case 'useAdaptiveThemes':
60
+ return enable => this.useAdaptiveThemes(enable);
61
+ case 'addPlugin':
62
+ return (pluginName, notify) => this.addPlugin(pluginName, notify);
63
+ case 'removePlugin':
64
+ return pluginName => this.removePlugin(pluginName);
65
+ default:
66
+ return Reflect.get(this, prop);
67
+ }
68
+ },
69
+ set: (target, prop, newValue, receiver) => {
70
+ switch (prop) {
71
+ case 'themes':
72
+ {
73
+ this.#themes = newValue;
74
+ this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
75
+ return true;
76
+ }
77
+ case 'themeName':
78
+ {
79
+ this.#themeName = newValue;
80
+ this.emitThemeChange();
81
+ return true;
82
+ }
83
+ default:
84
+ return Reflect.set(target, prop, newValue, receiver);
85
+ }
86
+ }
87
+ });
88
+ return true;
89
+ }
90
+ useTheme(themeName) {
91
+ this.#themeName = themeName;
92
+ this.emitThemeChange();
93
+ }
94
+ useBreakpoints(breakpoints) {
95
+ this.#breakpoints = breakpoints;
96
+ this.#sortedBreakpointPairs = Object.entries(breakpoints).sort(([, a], [, b]) => (a ?? 0) - (b ?? 0));
97
+ if (!_common.isServer) {
98
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
99
+ }
100
+ }
101
+ useAdaptiveThemes(enable) {
102
+ this.#hasAdaptiveThemes = enable;
103
+ if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
104
+ return;
105
+ }
106
+ if (this.#themeName !== this.#colorScheme) {
107
+ this.#themeName = this.#colorScheme;
108
+ this.emitThemeChange();
109
+ }
110
+ }
111
+ addPlugin(pluginName, notify) {
112
+ this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
113
+ if (notify) {
114
+ this.emitPluginChange();
115
+ }
116
+ }
117
+ removePlugin(pluginName) {
118
+ this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
119
+ this.emitPluginChange();
120
+ }
121
+ getTheme() {
122
+ if (this.#themes.length === 1) {
123
+ return this.#themes.at(0);
124
+ }
125
+ return this.#themeName;
126
+ }
127
+ setupListeners() {
128
+ window.addEventListener('resize', () => {
129
+ clearTimeout(this.#timerRef);
130
+ this.#timerRef = setTimeout(() => {
131
+ this.#screenWidth = window.innerWidth;
132
+ this.#screenHeight = window.innerHeight;
133
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
134
+ this.emitLayoutChange();
135
+ }, 100);
136
+ });
137
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
138
+ this.#colorScheme = event.matches ? 'dark' : 'light';
139
+ if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
140
+ return;
141
+ }
142
+ if (this.#colorScheme !== this.#themeName) {
143
+ this.#themeName = this.#colorScheme;
144
+ this.emitThemeChange();
145
+ }
146
+ });
147
+ }
148
+ getBreakpointFromScreenWidth(width) {
149
+ const breakpoint = this.#sortedBreakpointPairs.find(([, value], index, otherBreakpoints) => {
150
+ const minVal = value;
151
+ const maxVal = otherBreakpoints[index + 1]?.[1];
152
+ if (!maxVal) {
153
+ return true;
154
+ }
155
+ return width >= minVal && width < maxVal;
156
+ });
157
+ return breakpoint?.at(0);
158
+ }
159
+ getPreferredColorScheme() {
160
+ if (!_common.isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
161
+ return 'dark';
162
+ }
163
+ return 'light';
164
+ }
165
+ emitPluginChange() {
166
+ this.#unistylesEvents.emit('__unistylesOnChange', {
167
+ type: 'plugin'
168
+ });
169
+ }
170
+ emitThemeChange() {
171
+ this.#unistylesEvents.emit('__unistylesOnChange', {
172
+ type: 'theme',
173
+ payload: {
174
+ themeName: this.#themeName
175
+ }
176
+ });
177
+ }
178
+ emitLayoutChange() {
179
+ this.#unistylesEvents.emit('__unistylesOnChange', {
180
+ type: 'layout',
181
+ payload: {
182
+ breakpoint: this.#breakpoint,
183
+ orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
184
+ screen: {
185
+ width: this.#screenWidth,
186
+ height: this.#screenHeight
187
+ }
188
+ }
189
+ });
190
+ }
191
+ }
192
+ exports.UnistylesBridgeWeb = UnistylesBridgeWeb;
193
+ const UnistylesModule = exports.UnistylesModule = new UnistylesBridgeWeb();
9
194
  //# sourceMappingURL=UnistylesModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
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","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","height","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.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,gBA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vB,IAAI,CAAC,CAAC7C,eAAe,CAACwD,IAAI,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLrD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5BsD,WAAW,EAAG,IAAI,CAAC,CAACzE,WAAW,GAAe,IAAI,CAAC,CAACI,YAAuB,GACrE,WAAW,GACX,UAAU;QAChBsE,MAAM,EAAE;UACJX,KAAK,EAAE,IAAI,CAAC,CAAC/D,WAAW;UACxB2E,MAAM,EAAE,IAAI,CAAC,CAACvE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACwE,OAAA,CAAAjF,kBAAA,GAAAA,kBAAA;AAEM,MAAMkF,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,IAAIlF,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesModule = void 0;
7
+ var _reactNative = require("react-native");
8
+ const UnistylesModule = exports.UnistylesModule = _reactNative.NativeModules?.Unistyles;
9
+ //# sourceMappingURL=UnistylesModule.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.native.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
@@ -5,35 +5,78 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UnistylesRuntime = void 0;
7
7
  var _common = require("../common");
8
+ /**
9
+ * Utility to interact with the Unistyles during runtime
10
+ */
8
11
  class UnistylesRuntime {
9
12
  constructor(unistylesBridge, unistylesRegistry) {
10
13
  this.unistylesBridge = unistylesBridge;
11
14
  this.unistylesRegistry = unistylesRegistry;
12
15
  }
16
+
17
+ /**
18
+ * Get the current color scheme
19
+ * @returns - The current color scheme
20
+ */
13
21
  get colorScheme() {
14
22
  return this.unistylesBridge.colorScheme;
15
23
  }
24
+
25
+ /**
26
+ * Get info about adaptive themes
27
+ * @returns - boolean indicating if the adaptive themes are enabled
28
+ */
16
29
  get hasAdaptiveThemes() {
17
30
  return this.unistylesBridge.hasAdaptiveThemes;
18
31
  }
32
+
33
+ /**
34
+ * Get the current theme name
35
+ * @returns - The current theme name
36
+ */
19
37
  get themeName() {
20
38
  return this.unistylesBridge.themeName;
21
39
  }
40
+
41
+ /**
42
+ * Get the current breakpoint based on device size
43
+ * @returns - The current breakpoint
44
+ */
22
45
  get breakpoint() {
23
46
  return this.unistylesBridge.breakpoint;
24
47
  }
48
+
49
+ /**
50
+ * Get registered breakpoints with UnitylesRegistry
51
+ * @returns - The registered breakpoints
52
+ */
25
53
  get breakpoints() {
26
54
  return this.unistylesRegistry.breakpoints;
27
55
  }
56
+
57
+ /**
58
+ * Get the names of currently enabled plugins
59
+ * @returns - The names of currently enabled plugins
60
+ */
28
61
  get enabledPlugins() {
29
62
  return this.unistylesBridge.enabledPlugins;
30
63
  }
64
+
65
+ /**
66
+ * Get the screen size
67
+ * @returns - The screen size { width, height }
68
+ */
31
69
  get screen() {
32
70
  return {
33
71
  width: this.unistylesBridge.screenWidth,
34
72
  height: this.unistylesBridge.screenHeight
35
73
  };
36
74
  }
75
+
76
+ /**
77
+ * Get the screen orientation
78
+ * @returns - The screen orientation
79
+ */
37
80
  get orientation() {
38
81
  const {
39
82
  width,
@@ -44,6 +87,12 @@ class UnistylesRuntime {
44
87
  }
45
88
  return _common.ScreenOrientation.Portrait;
46
89
  }
90
+
91
+ /**
92
+ * Switch to a different theme
93
+ * @param name - The name of the theme to switch to
94
+ * @returns - boolean indicating if the theme was switched
95
+ */
47
96
  setTheme = name => {
48
97
  if (name === this.themeName) {
49
98
  return;
@@ -54,12 +103,27 @@ class UnistylesRuntime {
54
103
  }
55
104
  throw new Error(_common.UnistylesError.ThemeNotRegistered);
56
105
  };
106
+
107
+ /**
108
+ * Enable or disable adaptive themes
109
+ * @param enable - boolean indicating if adaptive themes should be enabled
110
+ */
57
111
  setAdaptiveThemes = enable => {
58
112
  this.unistylesBridge.useAdaptiveThemes(enable);
59
113
  };
114
+
115
+ /**
116
+ * Enable a plugin
117
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
118
+ */
60
119
  addPlugin = plugin => {
61
120
  this.unistylesRegistry.addPlugin(plugin);
62
121
  };
122
+
123
+ /**
124
+ * Disable a plugin
125
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
126
+ */
63
127
  removePlugin = plugin => {
64
128
  this.unistylesRegistry.removePlugin(plugin);
65
129
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAA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AAC4B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL;AAACE,OAAA,CAAAhC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;;EAEpG;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAAS;EACzC;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACL,eAAe,CAACK,UAAU;EAC1C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACL,iBAAiB,CAACK,WAAW;EAC7C;;EAEA;AACJ;AACA;AACA;EACI,IAAWC,cAAcA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACP,eAAe,CAACO,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@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createStyleSheet = void 0;
7
+ /**
8
+ * Utility to create a stylesheet with superpowers
9
+ * Compatible with React Native StyleSheet.create
10
+ * @param stylesheet - The stylesheet with superpowers to be used
11
+ */
7
12
  const createStyleSheet = stylesheet => stylesheet;
8
13
  exports.createStyleSheet = createStyleSheet;
9
14
  //# sourceMappingURL=createStyleSheet.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStyleSheet","stylesheet","exports"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU;AAAAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["createStyleSheet","stylesheet","exports"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU;AAAAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
@@ -4,6 +4,41 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useCSS = void 0;
7
- const useCSS = _stylesheet => {};
7
+ var _react = require("react");
8
+ var _core = require("../core");
9
+ var _utils = require("../utils");
10
+ const useCSS = stylesheet => {
11
+ const insertedIds = (0, _react.useRef)([]);
12
+ (0, _react.useInsertionEffect)(() => {
13
+ if (!_core.unistyles.registry.config.experimentalCSSMediaQueries) {
14
+ return;
15
+ }
16
+ Object.entries(stylesheet).forEach(([_key, value]) => {
17
+ Object.entries(value).forEach(([prop, val]) => {
18
+ if (!val.toString().includes('@media')) {
19
+ return;
20
+ }
21
+ const id = (0, _utils.generateReactNativeWebId)(prop, '""');
22
+ if (insertedIds.current.includes(id)) {
23
+ return;
24
+ }
25
+ const style = document.createElement('style');
26
+ style.id = id;
27
+ style.innerHTML = val;
28
+ document.head.appendChild(style);
29
+ insertedIds.current = [...insertedIds.current, id];
30
+ });
31
+ });
32
+ return () => {
33
+ insertedIds.current.forEach(id => {
34
+ const style = document.getElementById(id);
35
+ if (style) {
36
+ style.remove();
37
+ }
38
+ });
39
+ insertedIds.current = [];
40
+ };
41
+ }, [stylesheet]);
42
+ };
8
43
  exports.useCSS = useCSS;
9
44
  //# sourceMappingURL=useCSS.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCSS","_stylesheet","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC;AAAAC,OAAA,CAAAF,MAAA,GAAAA,MAAA"}
1
+ {"version":3,"names":["_react","require","_core","_utils","useCSS","stylesheet","insertedIds","useRef","useInsertionEffect","unistyles","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_key","value","prop","val","toString","includes","id","generateReactNativeWebId","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,MAAM,GAAOC,UAAoC,IAAK;EAC/D,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAgB,EAAE,CAAC;EAE7C,IAAAC,yBAAkB,EAAC,MAAM;IACrB,IAAI,CAACC,eAAS,CAACC,QAAQ,CAACC,MAAM,CAACC,2BAA2B,EAAE;MACxD;IACJ;IAEAC,MAAM,CACDC,OAAO,CAACT,UAAU,CAAC,CACnBU,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;MACxBJ,MAAM,CAACC,OAAO,CAACG,KAAM,CAAC,CACjBF,OAAO,CAAC,CAAC,CAACG,IAAI,EAAEC,GAAG,CAAC,KAAK;QACtB,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;UACpC;QACJ;QAEA,MAAMC,EAAE,GAAG,IAAAC,+BAAwB,EAACL,IAAI,EAAE,IAAI,CAAC;QAE/C,IAAIZ,WAAW,CAACkB,OAAO,CAACH,QAAQ,CAACC,EAAE,CAAC,EAAE;UAClC;QACJ;QAEA,MAAMG,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;QAE7CF,KAAK,CAACH,EAAE,GAAGA,EAAE;QACbG,KAAK,CAACG,SAAS,GAAGT,GAAG;QAErBO,QAAQ,CAACG,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;QAChCnB,WAAW,CAACkB,OAAO,GAAG,CAAC,GAAGlB,WAAW,CAACkB,OAAO,EAAEF,EAAE,CAAC;MACtD,CAAC,CAAC;IACV,CAAC,CAAC;IAEN,OAAO,MAAM;MACThB,WAAW,CAACkB,OAAO,CAACT,OAAO,CAACO,EAAE,IAAI;QAC9B,MAAMG,KAAK,GAAGC,QAAQ,CAACK,cAAc,CAACT,EAAE,CAAC;QAEzC,IAAIG,KAAK,EAAE;UACPA,KAAK,CAACO,MAAM,CAAC,CAAC;QAClB;MACJ,CAAC,CAAC;MAEF1B,WAAW,CAACkB,OAAO,GAAG,EAAE;IAC5B,CAAC;EACL,CAAC,EAAE,CAACnB,UAAU,CAAC,CAAC;AACpB,CAAC;AAAA4B,OAAA,CAAA7B,MAAA,GAAAA,MAAA"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCSS = void 0;
7
+ const useCSS = _stylesheet => {};
8
+ exports.useCSS = useCSS;
9
+ //# sourceMappingURL=useCSS.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCSS","_stylesheet","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC;AAAAC,OAAA,CAAAF,MAAA,GAAAA,MAAA"}
@@ -40,9 +40,25 @@ var _hooks = require("./hooks");
40
40
  var _common = require("./common");
41
41
  var _useStyles = require("./useStyles");
42
42
  var _createStyleSheet = require("./createStyleSheet");
43
+ /**
44
+ * Utility to interact with the Unistyles
45
+ * (should be called only once)
46
+ */
43
47
  const UnistylesRegistry = exports.UnistylesRegistry = {
48
+ /**
49
+ * Register themes to be used in the app
50
+ * @param themes - Key value pair of themes
51
+ */
44
52
  addThemes: _core.unistyles.registry.addThemes,
53
+ /**
54
+ * Register breakpoints to be used in the app
55
+ * @param breakpoints - Key value pair of breakpoints
56
+ */
45
57
  addBreakpoints: _core.unistyles.registry.addBreakpoints,
58
+ /**
59
+ * Register additional config to customize the Unistyles
60
+ * @param config - Key value pair of config
61
+ */
46
62
  addConfig: _core.unistyles.registry.addConfig
47
63
  };
48
64
  const UnistylesRuntime = exports.UnistylesRuntime = _core.unistyles.runtime;
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_utils","_hooks","_common","_useStyles","_createStyleSheet","UnistylesRegistry","exports","addThemes","unistyles","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EACtBE,SAAS,EAAEC,eAAS,CAACC,QAAQ,CAACF,SAAS;EACvCG,cAAc,EAAEF,eAAS,CAACC,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEH,eAAS,CAACC,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAGJ,eAAS,CAACK,OAAO"}
1
+ {"version":3,"names":["_core","require","_utils","_hooks","_common","_useStyles","_createStyleSheet","UnistylesRegistry","exports","addThemes","unistyles","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA;AACA;AACA;AACA;AACA,MAAMM,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EACtB;AACJ;AACA;AACA;EACIE,SAAS,EAAEC,eAAS,CAACC,QAAQ,CAACF,SAAS;EACvC;AACJ;AACA;AACA;EACIG,cAAc,EAAEF,eAAS,CAACC,QAAQ,CAACC,cAAc;EACjD;AACJ;AACA;AACA;EACIC,SAAS,EAAEH,eAAS,CAACC,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAGJ,eAAS,CAACK,OAAO"}
@@ -9,8 +9,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
9
9
  // based on react-native-web normalizer
10
10
  // https://github.com/necolas/react-native-web
11
11
 
12
- const normalizeColor = function (color) {
13
- let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
12
+ const normalizeColor = (color, opacity = 1) => {
14
13
  // If the opacity is 1 there's no need to normalize the color
15
14
  if (opacity === 1) {
16
15
  return color;