react-native-unistyles 3.0.0-nightly-20250512 → 3.0.0-nightly-20250520

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 (53) hide show
  1. package/README.md +2 -2
  2. package/lib/commonjs/reanimated/index.js +13 -0
  3. package/lib/commonjs/reanimated/index.js.map +1 -0
  4. package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
  5. package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
  6. package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
  7. package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
  8. package/lib/commonjs/web/css/core.js +6 -1
  9. package/lib/commonjs/web/css/core.js.map +1 -1
  10. package/lib/commonjs/web-only/getWebProps.js +19 -0
  11. package/lib/commonjs/web-only/getWebProps.js.map +1 -0
  12. package/lib/commonjs/web-only/index.js +13 -0
  13. package/lib/commonjs/web-only/index.js.map +1 -0
  14. package/lib/module/reanimated/index.js +4 -0
  15. package/lib/module/reanimated/index.js.map +1 -0
  16. package/lib/module/reanimated/useAnimatedTheme.js +17 -0
  17. package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
  18. package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
  19. package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
  20. package/lib/module/web/css/core.js +6 -1
  21. package/lib/module/web/css/core.js.map +1 -1
  22. package/lib/module/web-only/getWebProps.js +14 -0
  23. package/lib/module/web-only/getWebProps.js.map +1 -0
  24. package/lib/module/web-only/index.js +4 -0
  25. package/lib/module/web-only/index.js.map +1 -0
  26. package/lib/typescript/plugin/src/consts.d.ts +17 -0
  27. package/lib/typescript/plugin/src/consts.d.ts.map +1 -0
  28. package/lib/typescript/repack-plugin/src/index.d.ts +18 -0
  29. package/lib/typescript/repack-plugin/src/index.d.ts.map +1 -0
  30. package/lib/typescript/repack-plugin/src/loader.d.ts +9 -0
  31. package/lib/typescript/repack-plugin/src/loader.d.ts.map +1 -0
  32. package/lib/typescript/src/reanimated/index.d.ts +2 -0
  33. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  34. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
  35. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
  36. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
  37. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
  38. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  39. package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
  40. package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
  41. package/lib/typescript/src/web-only/index.d.ts +2 -0
  42. package/lib/typescript/src/web-only/index.d.ts.map +1 -0
  43. package/package.json +39 -4
  44. package/reanimated/package.json +6 -0
  45. package/repack-plugin/index.d.ts +19 -0
  46. package/repack-plugin/index.js +152 -0
  47. package/src/reanimated/index.ts +1 -0
  48. package/src/reanimated/useAnimatedTheme.native.ts +21 -0
  49. package/src/reanimated/useAnimatedTheme.ts +19 -0
  50. package/src/web/css/core.ts +9 -1
  51. package/src/web-only/getWebProps.ts +18 -0
  52. package/src/web-only/index.ts +2 -0
  53. package/web/package.json +6 -0
package/README.md CHANGED
@@ -28,8 +28,8 @@ yarn add react-native-edge-to-edge react-native-nitro-modules@0.25.2
28
28
 
29
29
  | react-native-unistyles | react-native-nitro-modules |
30
30
  |------------------------|----------------------------|
31
- | 3.0.0-nightly-20250508 | 0.25.2 |
32
- | 3.0.0-rc.3 | 0.25.2 |
31
+ | 3.0.0-nightly-20250513 | 0.25.2 |
32
+ | 3.0.0-rc.4 | 0.25.2 |
33
33
 
34
34
  Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
35
35
 
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useAnimatedTheme", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _useAnimatedTheme.useAnimatedTheme;
10
+ }
11
+ });
12
+ var _useAnimatedTheme = require("./useAnimatedTheme");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_useAnimatedTheme","require"],"sourceRoot":"../../../src","sources":["reanimated/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAnimatedTheme = void 0;
7
+ var _react = require("react");
8
+ var _reactNativeReanimated = require("react-native-reanimated");
9
+ var _specs = require("../specs");
10
+ var _services = require("../web/services");
11
+ const useAnimatedTheme = () => {
12
+ const theme = (0, _reactNativeReanimated.useSharedValue)(_specs.UnistylesRuntime.getTheme());
13
+ (0, _react.useEffect)(() => {
14
+ const dispose = _services.services.listener.addListeners([_specs.UnistyleDependency.Theme], () => theme.set(_specs.UnistylesRuntime.getTheme()));
15
+ return () => {
16
+ dispose();
17
+ };
18
+ }, []);
19
+ return theme;
20
+ };
21
+ exports.useAnimatedTheme = useAnimatedTheme;
22
+ //# sourceMappingURL=useAnimatedTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","_specs","_services","useAnimatedTheme","theme","useSharedValue","UnistylesRuntime","getTheme","useEffect","dispose","services","listener","addListeners","UnistyleDependency","Theme","set","exports"],"sourceRoot":"../../../src","sources":["reanimated/useAnimatedTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAG,IAAAC,qCAAc,EAACC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAEzD,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,OAAO,GAAGC,kBAAQ,CAACC,QAAQ,CAACC,YAAY,CAAC,CAACC,yBAAkB,CAACC,KAAK,CAAC,EAAE,MAAMV,KAAK,CAACW,GAAG,CAACT,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExH,OAAO,MAAM;MACTE,OAAO,CAAC,CAAC;IACb,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,KAAK;AAChB,CAAC;AAAAY,OAAA,CAAAb,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAnimatedTheme = void 0;
7
+ var _react = require("react");
8
+ var _reactNativeReanimated = require("react-native-reanimated");
9
+ var _specs = require("../specs");
10
+ const useAnimatedTheme = () => {
11
+ const theme = (0, _reactNativeReanimated.useSharedValue)(_specs.UnistylesRuntime.getTheme());
12
+ (0, _react.useEffect)(() => {
13
+ // @ts-ignore this is hidden from TS
14
+ const dispose = _specs.StyleSheet.addChangeListener(changedDependencies => {
15
+ if (changedDependencies.includes(_specs.UnistyleDependency.Theme)) {
16
+ theme.set(_specs.UnistylesRuntime.getTheme());
17
+ }
18
+ });
19
+ return () => dispose();
20
+ }, []);
21
+ return theme;
22
+ };
23
+ exports.useAnimatedTheme = useAnimatedTheme;
24
+ //# sourceMappingURL=useAnimatedTheme.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","_specs","useAnimatedTheme","theme","useSharedValue","UnistylesRuntime","getTheme","useEffect","dispose","StyleSheet","addChangeListener","changedDependencies","includes","UnistyleDependency","Theme","set","exports"],"sourceRoot":"../../../src","sources":["reanimated/useAnimatedTheme.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGO,MAAMG,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAG,IAAAC,qCAAc,EAACC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAEzD,IAAAC,gBAAS,EAAC,MAAM;IACZ;IACA,MAAMC,OAAO,GAAGC,iBAAU,CAACC,iBAAiB,CAACC,mBAAmB,IAAI;MAChE,IAAIA,mBAAmB,CAACC,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,EAAE;QACxDX,KAAK,CAACY,GAAG,CAACV,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;MAC1C;IACJ,CAAC,CAAC;IAEF,OAAO,MAAME,OAAO,CAAC,CAAC;EAC1B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOL,KAAK;AAChB,CAAC;AAAAa,OAAA,CAAAd,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -32,8 +32,13 @@ const convertToCSS = (hash, value, state) => {
32
32
  return;
33
33
  }
34
34
  if (typeof styleValue === 'object') {
35
- const allBreakpoints = Object.keys(value);
36
35
  Object.entries(styleValue).forEach(([breakpointStyleKey, breakpointStyleValue]) => {
36
+ const allBreakpoints = Object.entries(value).filter(([_, value]) => {
37
+ if (typeof value !== 'object' || value === null) {
38
+ return false;
39
+ }
40
+ return breakpointStyleKey in value;
41
+ }).map(([key]) => key);
37
42
  const mediaQuery = (0, _utils.getMediaQuery)(styleKey, allBreakpoints);
38
43
  state.set({
39
44
  mediaQuery,
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","convertToCSS","hash","value","state","Object","entries","forEach","styleKey","styleValue","pseudoClassName","replace","pseudoStyleKey","pseudoStyleValue","allBreakpoints","keys","breakpointStyleKey","breakpointStyleValue","mediaQuery","getMediaQuery","set","className","propertyKey","exports"],"sourceRoot":"../../../../src","sources":["web/css/core.ts"],"mappings":";;;;;;AAAA,IA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,CAACG,UAAU,CAAC,CAACF,OAAO,CAAC,CAAC,CAACS,kBAAkB,EAAEC,oBAAoB,CAAC,KAAK;QAC/E,MAAMC,UAAU,GAAG,IAAAC,oBAAa,EAACX,QAAQ,EAAEM,cAAc,CAAC;QAE1DV,KAAK,CAACgB,GAAG,CAAC;UACNF,UAAU;UACVG,SAAS,EAAEnB,IAAI;UACfoB,WAAW,EAAEN,kBAAkB;UAC/Bb,KAAK,EAAEc;QACX,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ;IAEAb,KAAK,CAACgB,GAAG,CAAC;MACNC,SAAS,EAAEnB,IAAI;MACfoB,WAAW,EAAEd,QAAQ;MACrBL,KAAK,EAAEM;IACX,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAAc,OAAA,CAAAtB,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"names":["_utils","require","convertToCSS","hash","value","state","Object","entries","forEach","styleKey","styleValue","pseudoClassName","replace","pseudoStyleKey","pseudoStyleValue","allBreakpoints","keys","breakpointStyleKey","breakpointStyleValue","mediaQuery","getMediaQuery","set","className","propertyKey","filter","_","map","key","exports"],"sourceRoot":"../../../../src","sources":["web/css/core.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAA0B,EAAEC,KAAe,KAAK;EACvFC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,UAAU,CAAC,KAAK;IACtD,IAAID,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;MACrB,MAAME,eAAe,GAAGF,QAAQ,CAACG,OAAO,CAAC,GAAG,EAAE,GAAGT,IAAI,GAAG,CAAC;MAEzDG,MAAM,CAACC,OAAO,CAACG,UAAU,CAAC,CAACF,OAAO,CAAC,CAAC,CAACK,cAAc,EAAEC,gBAAgB,CAAC,KAAK;QACv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AG,CAAC;UACNF,UAAU;UACVG,SAAS,EAAEnB,IAAI;UACfoB,WAAW,EAAEN,kBAAkB;UAC/Bb,KAAK,EAAEc;QACX,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ;IAEAb,KAAK,CAACgB,GAAG,CAAC;MACNC,SAAS,EAAEnB,IAAI;MACfoB,WAAW,EAAEd,QAAQ;MACrBL,KAAK,EAAEM;IACX,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAAAkB,OAAA,CAAA1B,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getWebProps = void 0;
7
+ var _core = require("../core");
8
+ var _createUnistylesRef = require("../web/utils/createUnistylesRef");
9
+ const getWebProps = style => {
10
+ const styles = (0, _core.getClassName)(style);
11
+ const ref = (0, _createUnistylesRef.createUnistylesRef)(styles);
12
+ const [generatedStyles] = styles ?? [];
13
+ return {
14
+ className: [generatedStyles?.hash, generatedStyles?.injectedClassName].filter(Boolean).join(' '),
15
+ ref
16
+ };
17
+ };
18
+ exports.getWebProps = getWebProps;
19
+ //# sourceMappingURL=getWebProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_core","require","_createUnistylesRef","getWebProps","style","styles","getClassName","ref","createUnistylesRef","generatedStyles","className","hash","injectedClassName","filter","Boolean","join","exports"],"sourceRoot":"../../../src","sources":["web-only/getWebProps.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AAEO,MAAME,WAAW,GAAOC,KAAyB,IAAK;EACzD,MAAMC,MAAM,GAAG,IAAAC,kBAAY,EAACF,KAAwB,CAAC;EACrD,MAAMG,GAAG,GAAG,IAAAC,sCAAkB,EAAIH,MAAM,CAAC;EACzC,MAAM,CAACI,eAAe,CAAC,GAAGJ,MAAM,IAAI,EAAE;EAEtC,OAAO;IACHK,SAAS,EAAE,CACPD,eAAe,EAAEE,IAAI,EACrBF,eAAe,EAAEG,iBAAiB,CACrC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;IAC3BR;EACJ,CAAC;AACL,CAAC;AAAAS,OAAA,CAAAb,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "getWebProps", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _getWebProps.getWebProps;
10
+ }
11
+ });
12
+ var _getWebProps = require("./getWebProps");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_getWebProps","require"],"sourceRoot":"../../../src","sources":["web-only/index.ts"],"mappings":";;;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { useAnimatedTheme } from './useAnimatedTheme';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAnimatedTheme"],"sourceRoot":"../../../src","sources":["reanimated/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ import { useEffect } from 'react';
4
+ import { useSharedValue } from 'react-native-reanimated';
5
+ import { UnistyleDependency, UnistylesRuntime } from '../specs';
6
+ import { services } from '../web/services';
7
+ export const useAnimatedTheme = () => {
8
+ const theme = useSharedValue(UnistylesRuntime.getTheme());
9
+ useEffect(() => {
10
+ const dispose = services.listener.addListeners([UnistyleDependency.Theme], () => theme.set(UnistylesRuntime.getTheme()));
11
+ return () => {
12
+ dispose();
13
+ };
14
+ }, []);
15
+ return theme;
16
+ };
17
+ //# sourceMappingURL=useAnimatedTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useSharedValue","UnistyleDependency","UnistylesRuntime","services","useAnimatedTheme","theme","getTheme","dispose","listener","addListeners","Theme","set"],"sourceRoot":"../../../src","sources":["reanimated/useAnimatedTheme.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAA2BC,cAAc,QAAQ,yBAAyB;AAC1E,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAE/D,SAASC,QAAQ,QAAQ,iBAAiB;AAE1C,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAGL,cAAc,CAACE,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;EAEzDP,SAAS,CAAC,MAAM;IACZ,MAAMQ,OAAO,GAAGJ,QAAQ,CAACK,QAAQ,CAACC,YAAY,CAAC,CAACR,kBAAkB,CAACS,KAAK,CAAC,EAAE,MAAML,KAAK,CAACM,GAAG,CAACT,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExH,OAAO,MAAM;MACTC,OAAO,CAAC,CAAC;IACb,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import { useEffect } from 'react';
4
+ import { useSharedValue } from 'react-native-reanimated';
5
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
6
+ export const useAnimatedTheme = () => {
7
+ const theme = useSharedValue(UnistylesRuntime.getTheme());
8
+ useEffect(() => {
9
+ // @ts-ignore this is hidden from TS
10
+ const dispose = StyleSheet.addChangeListener(changedDependencies => {
11
+ if (changedDependencies.includes(UnistyleDependency.Theme)) {
12
+ theme.set(UnistylesRuntime.getTheme());
13
+ }
14
+ });
15
+ return () => dispose();
16
+ }, []);
17
+ return theme;
18
+ };
19
+ //# sourceMappingURL=useAnimatedTheme.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useSharedValue","StyleSheet","UnistyleDependency","UnistylesRuntime","useAnimatedTheme","theme","getTheme","dispose","addChangeListener","changedDependencies","includes","Theme","set"],"sourceRoot":"../../../src","sources":["reanimated/useAnimatedTheme.native.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAA2BC,cAAc,QAAQ,yBAAyB;AAC1E,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAG3E,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAGL,cAAc,CAACG,gBAAgB,CAACG,QAAQ,CAAC,CAAC,CAAC;EAEzDP,SAAS,CAAC,MAAM;IACZ;IACA,MAAMQ,OAAO,GAAGN,UAAU,CAACO,iBAAiB,CAACC,mBAAmB,IAAI;MAChE,IAAIA,mBAAmB,CAACC,QAAQ,CAACR,kBAAkB,CAACS,KAAK,CAAC,EAAE;QACxDN,KAAK,CAACO,GAAG,CAACT,gBAAgB,CAACG,QAAQ,CAAC,CAAC,CAAC;MAC1C;IACJ,CAAC,CAAC;IAEF,OAAO,MAAMC,OAAO,CAAC,CAAC;EAC1B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -28,8 +28,13 @@ export const convertToCSS = (hash, value, state) => {
28
28
  return;
29
29
  }
30
30
  if (typeof styleValue === 'object') {
31
- const allBreakpoints = Object.keys(value);
32
31
  Object.entries(styleValue).forEach(([breakpointStyleKey, breakpointStyleValue]) => {
32
+ const allBreakpoints = Object.entries(value).filter(([_, value]) => {
33
+ if (typeof value !== 'object' || value === null) {
34
+ return false;
35
+ }
36
+ return breakpointStyleKey in value;
37
+ }).map(([key]) => key);
33
38
  const mediaQuery = getMediaQuery(styleKey, allBreakpoints);
34
39
  state.set({
35
40
  mediaQuery,
@@ -1 +1 @@
1
- {"version":3,"names":["getMediaQuery","convertToCSS","hash","value","state","Object","entries","forEach","styleKey","styleValue","pseudoClassName","replace","pseudoStyleKey","pseudoStyleValue","allBreakpoints","keys","breakpointStyleKey","breakpointStyleValue","mediaQuery","set","className","propertyKey"],"sourceRoot":"../../../../src","sources":["web/css/core.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,UAAU;AAGxC,OAAO,MAAMC,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAA0B,EAAEC,KAAe,KAAK;EACvFC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,UAAU,CAAC,KAAK;IACtD,IAAID,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;MACrB,MAAME,eAAe,GAAGF,QAAQ,CAACG,OAAO,CAAC,GAAG,EAAE,GAAGT,IAAI,GAAG,CAAC;MAEzDG,MAAM,CAACC,OAAO,CAACG,UAAU,CAAC,CAACF,OAAO,CAAC,CAAC,CAACK,cAAc,EAAEC,gBAAgB,CAAC,KAAK;QACvE,IAAI,OAAOA,gBAAgB,KAAK,QAAQ,IAAIA,gBAAgB,KAAK,IAAI,EAAE;UACnE,MAAMC,cAAc,GAAGT,MAAM,CAACU,IAAI,CAACN,UAAU,CAAC;UAC9CJ,MAAM,CAACC,OAAO,CAACO,gBAAgB,CAAC,CAACN,OAAO,CAAC,CAAC,CAACS,kBAAkB,EAAEC,oBAAoB,CAAC,KAAK;YACrF,MAAMC,UAAU,GAAGlB,aAAa,CAACY,cAAc,EAAEE,cAAc,CAAC;YAEhEV,KAAK,CAACe,GAAG,CAAC;cACND,UAAU;cACVE,SAAS,EAAEV,eAAe;cAC1BW,WAAW,EAAEL,kBAAkB;cAC/Bb,KAAK,EAAEc;YACX,CAAC,CAAC;UACN,CAAC,CAAC;UAEF;QACJ;QAEAb,KAAK,CAACe,GAAG,CAAC;UACNC,SAAS,EAAEV,eAAe;UAC1BW,WAAW,EAAET,cAAc;UAC3BT,KAAK,EAAEU;QACX,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ;IAEA,IAAI,OAAOJ,UAAU,KAAK,QAAQ,EAAE;MAChC,MAAMK,cAAc,GAAGT,MAAM,CAACU,IAAI,CAACZ,KAAK,CAAC;MACzCE,MAAM,CAACC,OAAO,CAACG,UAAU,CAAC,CAACF,OAAO,CAAC,CAAC,CAACS,kBAAkB,EAAEC,oBAAoB,CAAC,KAAK;QAC/E,MAAMC,UAAU,GAAGlB,aAAa,CAACQ,QAAQ,EAAEM,cAAc,CAAC;QAE1DV,KAAK,CAACe,GAAG,CAAC;UACND,UAAU;UACVE,SAAS,EAAElB,IAAI;UACfmB,WAAW,EAAEL,kBAAkB;UAC/Bb,KAAK,EAAEc;QACX,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ;IAEAb,KAAK,CAACe,GAAG,CAAC;MACNC,SAAS,EAAElB,IAAI;MACfmB,WAAW,EAAEb,QAAQ;MACrBL,KAAK,EAAEM;IACX,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getMediaQuery","convertToCSS","hash","value","state","Object","entries","forEach","styleKey","styleValue","pseudoClassName","replace","pseudoStyleKey","pseudoStyleValue","allBreakpoints","keys","breakpointStyleKey","breakpointStyleValue","mediaQuery","set","className","propertyKey","filter","_","map","key"],"sourceRoot":"../../../../src","sources":["web/css/core.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,UAAU;AAGxC,OAAO,MAAMC,YAAY,GAAGA,CAACC,IAAY,EAAEC,KAA0B,EAAEC,KAAe,KAAK;EACvFC,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,QAAQ,EAAEC,UAAU,CAAC,KAAK;IACtD,IAAID,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;MACrB,MAAME,eAAe,GAAGF,QAAQ,CAACG,OAAO,CAAC,GAAG,EAAE,GAAGT,IAAI,GAAG,CAAC;MAEzDG,MAAM,CAACC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UAAU,GAAGlB,aAAa,CAACQ,QAAQ,EAAEM,cAAc,CAAC;QAE1DV,KAAK,CAACe,GAAG,CAAC;UACND,UAAU;UACVE,SAAS,EAAElB,IAAI;UACfmB,WAAW,EAAEL,kBAAkB;UAC/Bb,KAAK,EAAEc;QACX,CAAC,CAAC;MACN,CAAC,CAAC;MAEF;IACJ;IAEAb,KAAK,CAACe,GAAG,CAAC;MACNC,SAAS,EAAElB,IAAI;MACfmB,WAAW,EAAEb,QAAQ;MACrBL,KAAK,EAAEM;IACX,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ import { getClassName } from '../core';
4
+ import { createUnistylesRef } from '../web/utils/createUnistylesRef';
5
+ export const getWebProps = style => {
6
+ const styles = getClassName(style);
7
+ const ref = createUnistylesRef(styles);
8
+ const [generatedStyles] = styles ?? [];
9
+ return {
10
+ className: [generatedStyles?.hash, generatedStyles?.injectedClassName].filter(Boolean).join(' '),
11
+ ref
12
+ };
13
+ };
14
+ //# sourceMappingURL=getWebProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getClassName","createUnistylesRef","getWebProps","style","styles","ref","generatedStyles","className","hash","injectedClassName","filter","Boolean","join"],"sourceRoot":"../../../src","sources":["web-only/getWebProps.ts"],"mappings":";;AACA,SAASA,YAAY,QAAQ,SAAS;AAEtC,SAASC,kBAAkB,QAAQ,iCAAiC;AAEpE,OAAO,MAAMC,WAAW,GAAOC,KAAyB,IAAK;EACzD,MAAMC,MAAM,GAAGJ,YAAY,CAACG,KAAwB,CAAC;EACrD,MAAME,GAAG,GAAGJ,kBAAkB,CAAIG,MAAM,CAAC;EACzC,MAAM,CAACE,eAAe,CAAC,GAAGF,MAAM,IAAI,EAAE;EAEtC,OAAO;IACHG,SAAS,EAAE,CACPD,eAAe,EAAEE,IAAI,EACrBF,eAAe,EAAEG,iBAAiB,CACrC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;IAC3BP;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { getWebProps } from './getWebProps';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getWebProps"],"sourceRoot":"../../../src","sources":["web-only/index.ts"],"mappings":";;AACA,SAASA,WAAW,QAAQ,eAAe","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type { RemapConfig } from '../index';
2
+ export declare const REACT_NATIVE_COMPONENT_NAMES: string[];
3
+ /**
4
+ * auto replace RN imports to Unistyles imports under these paths
5
+ * our implementation simply borrows 'ref' to register it in ShadowRegistry
6
+ * so we won't affect anyone's implementation
7
+ */
8
+ export declare const REPLACE_WITH_UNISTYLES_PATHS: string[];
9
+ /**
10
+ * this is more powerful API as it allows to convert unmatched imports to Unistyles
11
+ */
12
+ export declare const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS: Array<RemapConfig>;
13
+ /**
14
+ * this list will additionally detect React Native direct imports
15
+ */
16
+ export declare const NATIVE_COMPONENTS_PATHS: Pick<RemapConfig, 'imports'>;
17
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../plugin/src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,eAAO,MAAM,4BAA4B,UAoBxC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,UAMxC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mCAAmC,EAAE,KAAK,CAAC,WAAW,CAAM,CAAA;AAEzE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAchE,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { getModulePaths } from '@callstack/repack';
2
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
3
+ import type { UnistylesPluginOptions } from 'react-native-unistyles/plugin';
4
+ import { unistylesLoader } from './loader';
5
+ export declare const BASE_REPACK_EXCLUDE_PATHS: RegExp[];
6
+ type RuleExcludePaths = ReturnType<typeof getModulePaths>;
7
+ interface ConstructorParams {
8
+ ruleExcludePaths?: RuleExcludePaths;
9
+ unistylesPluginOptions?: UnistylesPluginOptions;
10
+ }
11
+ export declare class RepackUnistylePlugin implements RspackPluginInstance {
12
+ private ruleExcludePaths;
13
+ private unistylesPluginOptions;
14
+ constructor({ ruleExcludePaths, unistylesPluginOptions }?: ConstructorParams);
15
+ apply(compiler: Compiler): void;
16
+ }
17
+ export default unistylesLoader;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../repack-plugin/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,yBAAyB,UAcpC,CAAA;AAEF,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;AAEzD,UAAU,iBAAiB;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;CAClD;AAwBD,qBAAa,oBAAqB,YAAW,oBAAoB;IAC7D,OAAO,CAAC,gBAAgB,CAAA;IACxB,OAAO,CAAC,sBAAsB,CAAA;gBAElB,EAAE,gBAA4C,EAAE,sBAAsB,EAAE,GAAE,iBAAsB;IAK5G,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAG3B;AAED,eAAe,eAAe,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { LoaderContext } from '@rspack/core';
2
+ import type { UnistylesPluginOptions } from '../../plugin';
3
+ interface UnistylesLoaderOptions {
4
+ babelPlugins?: string[];
5
+ unistylesPluginOptions?: UnistylesPluginOptions;
6
+ }
7
+ export declare function unistylesLoader(this: LoaderContext<UnistylesLoaderOptions>, source: string): void;
8
+ export {};
9
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../repack-plugin/src/loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAK1D,UAAU,sBAAsB;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;CAClD;AAMD,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,MAAM,QAuC1F"}
@@ -0,0 +1,2 @@
1
+ export { useAnimatedTheme } from './useAnimatedTheme';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { type SharedValue } from 'react-native-reanimated';
2
+ import type { UnistylesTheme } from '../types';
3
+ export declare const useAnimatedTheme: () => SharedValue<UnistylesTheme>;
4
+ //# sourceMappingURL=useAnimatedTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedTheme.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/useAnimatedTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,yBAAyB,CAAA;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,eAAO,MAAM,gBAAgB,QAWT,WAAW,CAAC,cAAc,CAC7C,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { type SharedValue } from 'react-native-reanimated';
2
+ import type { UnistylesTheme } from '../types';
3
+ export declare const useAnimatedTheme: () => SharedValue<UnistylesTheme>;
4
+ //# sourceMappingURL=useAnimatedTheme.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedTheme.native.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/useAnimatedTheme.native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,yBAAyB,CAAA;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,gBAAgB,QAcT,WAAW,CAAC,cAAc,CAC7C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/web/css/core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,QAAQ,SAsDrF,CAAA"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/web/css/core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,QAAQ,SA8DrF,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { StyleProp } from 'react-native';
2
+ import type { RNStyle } from '../types';
3
+ export declare const getWebProps: <T>(style: StyleProp<RNStyle>) => {
4
+ className: string;
5
+ ref: ((ref: import("../types").Nullable<T>) => void) | undefined;
6
+ };
7
+ //# sourceMappingURL=getWebProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWebProps.d.ts","sourceRoot":"","sources":["../../../../src/web-only/getWebProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAA;AAGxD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,CAAC,OAAO,CAAC;;;CAYvD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getWebProps } from './getWebProps';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web-only/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-nightly-20250512",
3
+ "version": "3.0.0-nightly-20250520",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin",
@@ -9,10 +9,11 @@
9
9
  "lint": "biome lint",
10
10
  "check": "biome check --write",
11
11
  "check:ci": "biome check",
12
- "prepare": "husky && bob build && yarn plugin:build",
12
+ "prepare": "husky && bob build && yarn plugin:build && yarn repack:plugin:build",
13
13
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn check' 'yarn test' 'yarn circular:check'",
14
14
  "release": "release-it",
15
15
  "plugin:build": "node plugin/esbuild.js",
16
+ "repack:plugin:build": "node repack-plugin/esbuild.js",
16
17
  "circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 src/**/*.ts",
17
18
  "components:build": "node build-components.js"
18
19
  },
@@ -46,13 +47,32 @@
46
47
  "types": "./plugin/index.d.ts",
47
48
  "default": "./plugin/index.js"
48
49
  },
50
+ "./repack-plugin": {
51
+ "import": "./repack-plugin/index.js",
52
+ "types": "./repack-plugin/index.d.ts",
53
+ "default": "./repack-plugin/index.js"
54
+ },
49
55
  "./package.json": "./package.json",
50
56
  "./server": {
51
57
  "types": "./lib/typescript/src/server/index.d.ts",
52
58
  "import": "./lib/module/server/index.js",
53
59
  "browser": "./lib/module/server/index.js",
54
- "react-native": "./src/server.ts",
60
+ "react-native": "./src/server/index.ts",
55
61
  "default": "./lib/commonjs/server/index.js"
62
+ },
63
+ "./web": {
64
+ "types": "./lib/typescript/src/web-only/index.d.ts",
65
+ "import": "./lib/module/web-only/index.js",
66
+ "browser": "./lib/module/web-only/index.js",
67
+ "react-native": "./src/web-only/index.ts",
68
+ "default": "./lib/commonjs/web-only/index.js"
69
+ },
70
+ "./reanimated": {
71
+ "types": "./lib/typescript/src/reanimated/index.d.ts",
72
+ "import": "./lib/module/reanimated/index.js",
73
+ "browser": "./lib/module/reanimated/index.js",
74
+ "react-native": "./src/reanimated/index.ts",
75
+ "default": "./lib/commonjs/reanimated/index.js"
56
76
  }
57
77
  },
58
78
  "files": [
@@ -66,8 +86,14 @@
66
86
  "web",
67
87
  "components",
68
88
  "server",
89
+ "web-only",
90
+ "reanimated",
69
91
  "react-native.config.js",
70
92
  "Unistyles.podspec",
93
+ "repack-plugin",
94
+ "!repack-plugin/__tests__",
95
+ "!repack-plugin/src",
96
+ "!repack-plugin/esbuild.js",
71
97
  "!plugin/__tests__",
72
98
  "!plugin/src",
73
99
  "!plugin/esbuild.js",
@@ -106,9 +132,11 @@
106
132
  "@babel/preset-typescript": "7.26.0",
107
133
  "@babel/types": "7.26.9",
108
134
  "@biomejs/biome": "1.9.4",
135
+ "@callstack/repack": "5.1.0",
109
136
  "@commitlint/config-conventional": "19.7.1",
110
137
  "@react-native/normalize-colors": "0.78.0",
111
138
  "@release-it/conventional-changelog": "8.0.2",
139
+ "@rspack/core": "1.3.10",
112
140
  "@types/jest": "29.5.14",
113
141
  "@types/react": "19.0.10",
114
142
  "babel-plugin-tester": "11.0.4",
@@ -124,6 +152,7 @@
124
152
  "react-native": "0.77.1",
125
153
  "react-native-builder-bob": "0.37.0",
126
154
  "react-native-nitro-modules": "0.25.2",
155
+ "react-native-reanimated": "3.17.5",
127
156
  "react-native-web": "0.19.13",
128
157
  "react-test-renderer": "18.3.1",
129
158
  "release-it": "17.11.0",
@@ -134,7 +163,13 @@
134
163
  "react": "*",
135
164
  "react-native": ">=0.76.0",
136
165
  "react-native-edge-to-edge": "*",
137
- "react-native-nitro-modules": "*"
166
+ "react-native-nitro-modules": "*",
167
+ "react-native-reanimated": "*"
168
+ },
169
+ "peerDependenciesMeta": {
170
+ "react-native-reanimated": {
171
+ "optional": true
172
+ }
138
173
  },
139
174
  "workspaces": [
140
175
  "example",
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/reanimated/index",
3
+ "module": "../lib/module/reanimated/index",
4
+ "react-native": "../src/reanimated/index",
5
+ "types": "../lib/typescript/src/reanimated/index"
6
+ }
@@ -0,0 +1,19 @@
1
+ import type {Compiler,LoaderContext,RspackPluginInstance } from '@rspack/core'
2
+ import type { UnistylesPluginOptions } from 'react-native-unistyles/plugin'
3
+
4
+ export declare const BASE_REPACK_EXCLUDE_PATHS: Array<RegExp>
5
+ interface ConstructorParams {
6
+ ruleExcludePaths?: Array<RegExp>
7
+ unistylesPluginOptions?: UnistylesPluginOptions
8
+ }
9
+
10
+ export declare class RepackUnistylePlugin implements RspackPluginInstance {
11
+ private ruleExcludePaths
12
+ private unistylesPluginOptions
13
+ constructor({ ruleExcludePaths, unistylesPluginOptions }?: ConstructorParams)
14
+ apply(compiler: Compiler): void
15
+ }
16
+
17
+ declare function unistylesLoader(this: LoaderContext<UnistylesLoaderOptions>, source: string): void;
18
+
19
+ export default unistylesLoader
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // repack-plugin/src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ BASE_REPACK_EXCLUDE_PATHS: () => BASE_REPACK_EXCLUDE_PATHS,
24
+ RepackUnistylePlugin: () => RepackUnistylePlugin,
25
+ default: () => index_default
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_repack = require("@callstack/repack");
29
+
30
+ // repack-plugin/src/loader.ts
31
+ var import_core = require("@babel/core");
32
+
33
+ // plugin/src/consts.ts
34
+ var REACT_NATIVE_COMPONENT_NAMES = [
35
+ "ActivityIndicator",
36
+ "View",
37
+ "Text",
38
+ "Image",
39
+ "ImageBackground",
40
+ "KeyboardAvoidingView",
41
+ "Pressable",
42
+ "ScrollView",
43
+ "FlatList",
44
+ "SectionList",
45
+ "Switch",
46
+ "TextInput",
47
+ "RefreshControl",
48
+ "TouchableHighlight",
49
+ "TouchableOpacity",
50
+ "VirtualizedList",
51
+ "Animated"
52
+ // Modal - there is no exposed native handle
53
+ // TouchableWithoutFeedback - can't accept a ref
54
+ ];
55
+ var REPLACE_WITH_UNISTYLES_PATHS = [
56
+ "react-native-reanimated/src/component",
57
+ "react-native-reanimated/lib/module/component",
58
+ "react-native-gesture-handler/lib/module/components",
59
+ "react-native-gesture-handler/lib/commonjs/components",
60
+ "react-native-gesture-handler/src/components"
61
+ ];
62
+
63
+ // repack-plugin/src/loader.ts
64
+ var importName = "react-native-unistyles";
65
+ var UNISTYLES_REGEX = new RegExp(
66
+ [...REACT_NATIVE_COMPONENT_NAMES, ...REPLACE_WITH_UNISTYLES_PATHS, importName].join("|")
67
+ );
68
+ function unistylesLoader(source) {
69
+ this.cacheable();
70
+ const callback = this.async();
71
+ const options = this.getOptions();
72
+ if (!UNISTYLES_REGEX.test(source)) {
73
+ callback(null, source);
74
+ return;
75
+ }
76
+ const unistylesOptions = options.unistylesPluginOptions;
77
+ const unistylesPlugin = unistylesOptions ? ["react-native-unistyles/plugin", unistylesOptions] : "react-native-unistyles/plugin";
78
+ const babelPlugins = options.babelPlugins ?? [];
79
+ (0, import_core.transform)(
80
+ source,
81
+ {
82
+ filename: this.resourcePath,
83
+ babelrc: false,
84
+ configFile: false,
85
+ compact: false,
86
+ comments: true,
87
+ plugins: [...babelPlugins, unistylesPlugin]
88
+ },
89
+ (err, result) => {
90
+ if (err) {
91
+ callback(err);
92
+ return;
93
+ }
94
+ callback(null, result.code, result.map);
95
+ return;
96
+ }
97
+ );
98
+ }
99
+
100
+ // repack-plugin/src/index.ts
101
+ var BASE_REPACK_EXCLUDE_PATHS = (0, import_repack.getModulePaths)([
102
+ "react",
103
+ "react-native",
104
+ "@react-native",
105
+ "react-native-macos",
106
+ "react-native-windows",
107
+ "react-native-tvos",
108
+ "@callstack/react-native-visionos",
109
+ "@module-federation",
110
+ "react-native-unistyles",
111
+ "whatwg-fetch",
112
+ "@callstack",
113
+ "react-native-nitro-modules",
114
+ "@callstack/repack"
115
+ ]);
116
+ var getUnistyleModuleRules = (excludePathLoader, unistylesPluginOptions) => {
117
+ const createRule = (test, babelPlugins) => ({
118
+ test,
119
+ use: {
120
+ loader: "react-native-unistyles/repack-plugin",
121
+ options: {
122
+ babelPlugins,
123
+ unistylesPluginOptions
124
+ }
125
+ }
126
+ });
127
+ return {
128
+ exclude: excludePathLoader,
129
+ oneOf: [
130
+ createRule(/\.[cm]?ts$/, [["@babel/plugin-syntax-typescript", { isTSX: false, allowNamespaces: true }]]),
131
+ createRule(/\.[cm]?tsx$/, [["@babel/plugin-syntax-typescript", { isTSX: true, allowNamespaces: true }]]),
132
+ createRule(/\.[cm]?jsx?$/, ["babel-plugin-syntax-hermes-parser"])
133
+ ]
134
+ };
135
+ };
136
+ var RepackUnistylePlugin = class {
137
+ ruleExcludePaths;
138
+ unistylesPluginOptions;
139
+ constructor({ ruleExcludePaths = BASE_REPACK_EXCLUDE_PATHS, unistylesPluginOptions } = {}) {
140
+ this.ruleExcludePaths = ruleExcludePaths;
141
+ this.unistylesPluginOptions = unistylesPluginOptions;
142
+ }
143
+ apply(compiler) {
144
+ compiler.options.module.rules.push(getUnistyleModuleRules(this.ruleExcludePaths, this.unistylesPluginOptions));
145
+ }
146
+ };
147
+ var index_default = unistylesLoader;
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ BASE_REPACK_EXCLUDE_PATHS,
151
+ RepackUnistylePlugin
152
+ });
@@ -0,0 +1 @@
1
+ export { useAnimatedTheme } from './useAnimatedTheme'
@@ -0,0 +1,21 @@
1
+ import { useEffect } from 'react'
2
+ import { type SharedValue, useSharedValue } from 'react-native-reanimated'
3
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
4
+ import type { UnistylesTheme } from '../types'
5
+
6
+ export const useAnimatedTheme = () => {
7
+ const theme = useSharedValue(UnistylesRuntime.getTheme())
8
+
9
+ useEffect(() => {
10
+ // @ts-ignore this is hidden from TS
11
+ const dispose = StyleSheet.addChangeListener(changedDependencies => {
12
+ if (changedDependencies.includes(UnistyleDependency.Theme)) {
13
+ theme.set(UnistylesRuntime.getTheme())
14
+ }
15
+ })
16
+
17
+ return () => dispose()
18
+ }, [])
19
+
20
+ return theme as SharedValue<UnistylesTheme>
21
+ }
@@ -0,0 +1,19 @@
1
+ import { useEffect } from 'react'
2
+ import { type SharedValue, useSharedValue } from 'react-native-reanimated'
3
+ import { UnistyleDependency, UnistylesRuntime } from '../specs'
4
+ import type { UnistylesTheme } from '../types'
5
+ import { services } from '../web/services'
6
+
7
+ export const useAnimatedTheme = () => {
8
+ const theme = useSharedValue(UnistylesRuntime.getTheme())
9
+
10
+ useEffect(() => {
11
+ const dispose = services.listener.addListeners([UnistyleDependency.Theme], () => theme.set(UnistylesRuntime.getTheme()))
12
+
13
+ return () => {
14
+ dispose()
15
+ }
16
+ }, [])
17
+
18
+ return theme as SharedValue<UnistylesTheme>
19
+ }
@@ -34,8 +34,16 @@ export const convertToCSS = (hash: string, value: Record<string, any>, state: CS
34
34
  }
35
35
 
36
36
  if (typeof styleValue === 'object') {
37
- const allBreakpoints = Object.keys(value)
38
37
  Object.entries(styleValue).forEach(([breakpointStyleKey, breakpointStyleValue]) => {
38
+ const allBreakpoints = Object.entries(value)
39
+ .filter(([_, value]) => {
40
+ if (typeof value !== 'object' || value === null) {
41
+ return false
42
+ }
43
+
44
+ return breakpointStyleKey in value
45
+ })
46
+ .map(([key]) => key)
39
47
  const mediaQuery = getMediaQuery(styleKey, allBreakpoints)
40
48
 
41
49
  state.set({
@@ -0,0 +1,18 @@
1
+ import type { StyleProp } from 'react-native'
2
+ import { getClassName } from '../core'
3
+ import type { RNStyle, UnistylesValues } from '../types'
4
+ import { createUnistylesRef } from '../web/utils/createUnistylesRef'
5
+
6
+ export const getWebProps = <T>(style: StyleProp<RNStyle>) => {
7
+ const styles = getClassName(style as UnistylesValues)
8
+ const ref = createUnistylesRef<T>(styles)
9
+ const [generatedStyles] = styles ?? []
10
+
11
+ return {
12
+ className: [
13
+ generatedStyles?.hash,
14
+ generatedStyles?.injectedClassName,
15
+ ].filter(Boolean).join(' '),
16
+ ref
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+
2
+ export { getWebProps } from './getWebProps'
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/web-only/index",
3
+ "module": "../lib/module/web-only/index",
4
+ "react-native": "../src/web-only/index",
5
+ "types": "../lib/typescript/src/web-only/index"
6
+ }