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

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 (36) hide show
  1. package/lib/commonjs/reanimated/index.js +13 -0
  2. package/lib/commonjs/reanimated/index.js.map +1 -0
  3. package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
  4. package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
  5. package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
  6. package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
  7. package/lib/commonjs/web-only/getWebProps.js +19 -0
  8. package/lib/commonjs/web-only/getWebProps.js.map +1 -0
  9. package/lib/commonjs/web-only/index.js +13 -0
  10. package/lib/commonjs/web-only/index.js.map +1 -0
  11. package/lib/module/reanimated/index.js +4 -0
  12. package/lib/module/reanimated/index.js.map +1 -0
  13. package/lib/module/reanimated/useAnimatedTheme.js +17 -0
  14. package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
  15. package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
  16. package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
  17. package/lib/module/web-only/getWebProps.js +14 -0
  18. package/lib/module/web-only/getWebProps.js.map +1 -0
  19. package/lib/module/web-only/index.js +4 -0
  20. package/lib/module/web-only/index.js.map +1 -0
  21. package/lib/typescript/src/reanimated/index.d.ts +2 -0
  22. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  23. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +2 -0
  24. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
  25. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +2 -0
  26. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
  27. package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
  28. package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
  29. package/lib/typescript/src/web-only/index.d.ts +2 -0
  30. package/lib/typescript/src/web-only/index.d.ts.map +1 -0
  31. package/package.json +24 -3
  32. package/src/reanimated/index.ts +1 -0
  33. package/src/reanimated/useAnimatedTheme.native.ts +21 -0
  34. package/src/reanimated/useAnimatedTheme.ts +19 -0
  35. package/src/web-only/getWebProps.ts +18 -0
  36. package/src/web-only/index.ts +2 -0
@@ -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,EAAiBC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAEzE,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,EAAiBC,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;EAEzE,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":[]}
@@ -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,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAE/D,SAASC,QAAQ,QAAQ,iBAAiB;AAE1C,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAGL,cAAc,CAAiBE,gBAAgB,CAACI,QAAQ,CAAC,CAAC,CAAC;EAEzEP,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,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAQ,UAAU;AAG3E,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,KAAK,GAAGL,cAAc,CAAiBG,gBAAgB,CAACG,QAAQ,CAAC,CAAC,CAAC;EAEzEP,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":[]}
@@ -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,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,2 @@
1
+ export declare const useAnimatedTheme: () => import("react-native-reanimated").SharedValue<never>;
2
+ //# sourceMappingURL=useAnimatedTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnimatedTheme.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/useAnimatedTheme.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,4DAY5B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const useAnimatedTheme: () => import("react-native-reanimated").SharedValue<never>;
2
+ //# 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":"AAKA,eAAO,MAAM,gBAAgB,4DAe5B,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-20250513",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin",
@@ -51,8 +51,22 @@
51
51
  "types": "./lib/typescript/src/server/index.d.ts",
52
52
  "import": "./lib/module/server/index.js",
53
53
  "browser": "./lib/module/server/index.js",
54
- "react-native": "./src/server.ts",
54
+ "react-native": "./src/server/index.ts",
55
55
  "default": "./lib/commonjs/server/index.js"
56
+ },
57
+ "./web": {
58
+ "types": "./lib/typescript/src/web-only/index.d.ts",
59
+ "import": "./lib/module/web-only/index.js",
60
+ "browser": "./lib/module/web-only/index.js",
61
+ "react-native": "./src/web-only/index.ts",
62
+ "default": "./lib/commonjs/web-only/index.js"
63
+ },
64
+ "./reanimated": {
65
+ "types": "./lib/typescript/src/reanimated/index.d.ts",
66
+ "import": "./lib/module/reanimated/index.js",
67
+ "browser": "./lib/module/reanimated/index.js",
68
+ "react-native": "./src/reanimated/index.ts",
69
+ "default": "./lib/commonjs/reanimated/index.js"
56
70
  }
57
71
  },
58
72
  "files": [
@@ -124,6 +138,7 @@
124
138
  "react-native": "0.77.1",
125
139
  "react-native-builder-bob": "0.37.0",
126
140
  "react-native-nitro-modules": "0.25.2",
141
+ "react-native-reanimated": "3.17.5",
127
142
  "react-native-web": "0.19.13",
128
143
  "react-test-renderer": "18.3.1",
129
144
  "release-it": "17.11.0",
@@ -134,7 +149,13 @@
134
149
  "react": "*",
135
150
  "react-native": ">=0.76.0",
136
151
  "react-native-edge-to-edge": "*",
137
- "react-native-nitro-modules": "*"
152
+ "react-native-nitro-modules": "*",
153
+ "react-native-reanimated": "*"
154
+ },
155
+ "peerDependenciesMeta": {
156
+ "react-native-reanimated": {
157
+ "optional": true
158
+ }
138
159
  },
139
160
  "workspaces": [
140
161
  "example",
@@ -0,0 +1 @@
1
+ export { useAnimatedTheme } from './useAnimatedTheme'
@@ -0,0 +1,21 @@
1
+ import { useEffect } from 'react'
2
+ import { 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<UnistylesTheme>(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
21
+ }
@@ -0,0 +1,19 @@
1
+ import { useEffect } from 'react'
2
+ import { 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<UnistylesTheme>(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
19
+ }
@@ -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'