react-native-unistyles 3.0.0-nightly-20250609 → 3.0.0-nightly-20250613

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 (97) hide show
  1. package/README.md +3 -5
  2. package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.h +4 -0
  4. package/android/src/main/java/com/unistyles/UnistylesModule.kt +7 -0
  5. package/cxx/core/UnistylesRegistry.cpp +7 -6
  6. package/cxx/core/UnistylesRegistry.h +2 -1
  7. package/ios/UnistylesModuleOnLoad.mm +5 -0
  8. package/lib/commonjs/components/ScopedTheme.js +6 -2
  9. package/lib/commonjs/components/ScopedTheme.js.map +1 -1
  10. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  11. package/lib/commonjs/reanimated/index.js +7 -0
  12. package/lib/commonjs/reanimated/index.js.map +1 -1
  13. package/lib/commonjs/reanimated/variant/index.js +17 -0
  14. package/lib/commonjs/reanimated/variant/index.js.map +1 -0
  15. package/lib/commonjs/reanimated/variant/types.js +2 -0
  16. package/lib/commonjs/reanimated/variant/types.js.map +1 -0
  17. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js +38 -0
  18. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  19. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +66 -0
  20. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  21. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +39 -0
  22. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  23. package/lib/commonjs/web/convert/pseudo.js +13 -3
  24. package/lib/commonjs/web/convert/pseudo.js.map +1 -1
  25. package/lib/commonjs/web/create.js +1 -1
  26. package/lib/commonjs/web/create.js.map +1 -1
  27. package/lib/commonjs/web/css/core.js +3 -1
  28. package/lib/commonjs/web/css/core.js.map +1 -1
  29. package/lib/commonjs/web/shadowRegistry.js +3 -2
  30. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  31. package/lib/commonjs/web/types.js.map +1 -1
  32. package/lib/commonjs/web/utils/unistyle.js +13 -1
  33. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  34. package/lib/module/components/ScopedTheme.js +6 -2
  35. package/lib/module/components/ScopedTheme.js.map +1 -1
  36. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  37. package/lib/module/reanimated/index.js +1 -0
  38. package/lib/module/reanimated/index.js.map +1 -1
  39. package/lib/module/reanimated/variant/index.js +4 -0
  40. package/lib/module/reanimated/variant/index.js.map +1 -0
  41. package/lib/module/reanimated/variant/types.js +2 -0
  42. package/lib/module/reanimated/variant/types.js.map +1 -0
  43. package/lib/module/reanimated/variant/useAnimatedVariantColor.js +33 -0
  44. package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  45. package/lib/module/reanimated/variant/useUpdateVariantColor.js +61 -0
  46. package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  47. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +34 -0
  48. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  49. package/lib/module/web/convert/pseudo.js +10 -2
  50. package/lib/module/web/convert/pseudo.js.map +1 -1
  51. package/lib/module/web/create.js +1 -1
  52. package/lib/module/web/create.js.map +1 -1
  53. package/lib/module/web/css/core.js +3 -1
  54. package/lib/module/web/css/core.js.map +1 -1
  55. package/lib/module/web/shadowRegistry.js +3 -2
  56. package/lib/module/web/shadowRegistry.js.map +1 -1
  57. package/lib/module/web/types.js.map +1 -1
  58. package/lib/module/web/utils/unistyle.js +12 -1
  59. package/lib/module/web/utils/unistyle.js.map +1 -1
  60. package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
  61. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  62. package/lib/typescript/src/reanimated/index.d.ts +1 -0
  63. package/lib/typescript/src/reanimated/index.d.ts.map +1 -1
  64. package/lib/typescript/src/reanimated/variant/index.d.ts +2 -0
  65. package/lib/typescript/src/reanimated/variant/index.d.ts.map +1 -0
  66. package/lib/typescript/src/reanimated/variant/types.d.ts +10 -0
  67. package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -0
  68. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts +3 -0
  69. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -0
  70. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +6 -0
  71. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -0
  72. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +6 -0
  73. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -0
  74. package/lib/typescript/src/web/convert/pseudo.d.ts +6 -3
  75. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
  76. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  77. package/lib/typescript/src/web/shadowRegistry.d.ts +1 -0
  78. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  79. package/lib/typescript/src/web/types.d.ts +4 -1
  80. package/lib/typescript/src/web/types.d.ts.map +1 -1
  81. package/lib/typescript/src/web/utils/unistyle.d.ts +4 -1
  82. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  83. package/package.json +1 -1
  84. package/src/components/ScopedTheme.tsx +7 -2
  85. package/src/core/withUnistyles/withUnistyles.native.tsx +1 -0
  86. package/src/reanimated/index.ts +1 -0
  87. package/src/reanimated/variant/index.ts +1 -0
  88. package/src/reanimated/variant/types.ts +14 -0
  89. package/src/reanimated/variant/useAnimatedVariantColor.ts +38 -0
  90. package/src/reanimated/variant/useUpdateVariantColor.native.ts +38 -0
  91. package/src/reanimated/variant/useUpdateVariantColor.ts +81 -0
  92. package/src/web/convert/pseudo.ts +23 -52
  93. package/src/web/create.ts +1 -1
  94. package/src/web/css/core.ts +3 -1
  95. package/src/web/shadowRegistry.ts +2 -2
  96. package/src/web/types.ts +4 -1
  97. package/src/web/utils/unistyle.ts +18 -2
@@ -1 +1 @@
1
- {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/pseudo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,ssEAiIV,CAAA;AAEV,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,YAAwD,CAAA;AAEjG,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,MAAM,GAAG,GAAG,CAAC,CAAA;AAE3F,MAAM,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"pseudo.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/pseudo.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa,43BAoET,CAAA;AAGV,QAAA,MAAM,cAAc,uYAuBV,CAAA;AAEV,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,MAAM,GAAG,GAAG,CAAC,CAAA;AAE3F,MAAM,MAAM,MAAM,GAAG,kBAAkB,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEzG,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,YAA8D,CAAA;AAE5G,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,YAA+D,CAAA;AAE/G,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,YAAyD,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,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,QAAQ,SA8DrF,CAAA"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/web/css/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,QAAQ,SA+DrF,CAAA"}
@@ -14,6 +14,7 @@ export declare class UnistylesShadowRegistry {
14
14
  addStyles: (unistyles: Array<UnistylesValues>, forChild?: boolean) => UniGeneratedStyle | {
15
15
  injectedClassName: string;
16
16
  hash: string;
17
+ parsedStyles: UnistylesValues;
17
18
  };
18
19
  setScopedTheme: (theme?: UnistylesTheme) => void;
19
20
  getScopedTheme: () => undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAInE,qBAAa,uBAAuB;IAYpB,OAAO,CAAC,QAAQ;IAV5B,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,UAAU,CAAkC;gBAEhC,QAAQ,EAAE,iBAAiB;IAE/C,GAAG,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAM7B;IAED,SAAS,GAAI,WAAW,KAAK,CAAC,eAAe,CAAC,EAAE,WAAW,OAAO;;;MAoEjE;IAED,cAAc,GAAI,QAAQ,cAAc,UAEvC;IAED,cAAc,kBAAyB;IAEvC,MAAM,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAchC;IAED,KAAK,aAAW;CACnB"}
1
+ {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAInE,qBAAa,uBAAuB;IAYpB,OAAO,CAAC,QAAQ;IAV5B,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,UAAU,CAAkC;gBAEhC,QAAQ,EAAE,iBAAiB;IAE/C,GAAG,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAM7B;IAED,SAAS,GAAI,WAAW,KAAK,CAAC,eAAe,CAAC,EAAE,WAAW,OAAO;;;;MAoEjE;IAED,cAAc,GAAI,QAAQ,cAAc,UAEvC;IAED,cAAc,kBAAyB;IAEvC,MAAM,GAAI,KAAK,GAAG,EAAE,OAAO,MAAM,UAchC;IAED,KAAK,aAAW;CACnB"}
@@ -1,3 +1,4 @@
1
+ import type { UnistylesValues } from '../types';
1
2
  import type { UnistylesListener } from './listener';
2
3
  import type { UnistylesRegistry } from './registry';
3
4
  import type { UnistylesRuntime } from './runtime';
@@ -12,5 +13,7 @@ export type UnistylesServices = {
12
13
  };
13
14
  export declare const UNI_GENERATED_KEYS: readonly ["$$css", "hash", "injectedClassName"];
14
15
  export type UniGeneratedKey = typeof UNI_GENERATED_KEYS[number];
15
- export type UniGeneratedStyle = Record<UniGeneratedKey, string>;
16
+ export type UniGeneratedStyle = Record<UniGeneratedKey, string> & {
17
+ parsedStyles?: UnistylesValues;
18
+ };
16
19
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,EAAE,uBAAuB,CAAC;IACxC,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,kBAAkB,iDAAkD,CAAA;AACjF,MAAM,MAAM,eAAe,GAAG,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;AAE/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,EAAE,uBAAuB,CAAC;IACxC,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,kBAAkB,iDAAkD,CAAA;AACjF,MAAM,MAAM,eAAe,GAAG,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;AAE/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG;IAC9D,YAAY,CAAC,EAAE,eAAe,CAAA;CACjC,CAAA"}
@@ -1,13 +1,15 @@
1
+ import type { UnistylesBreakpoints } from '../../global';
1
2
  import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro';
2
3
  import { ColorScheme } from '../../specs/types';
3
4
  import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet';
5
+ import type { UnistylesRuntime } from '../runtime';
4
6
  import { type UniGeneratedStyle } from '../types';
5
7
  export declare const schemeToTheme: (scheme: ColorScheme) => "light" | "dark";
6
8
  export type UnistyleSecrets = {
7
9
  __uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
8
10
  __uni__key: string;
9
11
  __uni__args?: Array<any>;
10
- __uni_variants: Record<string, string | boolean | undefined>;
12
+ __stylesheetVariants: Record<string, string | boolean | undefined>;
11
13
  };
12
14
  export declare const assignSecrets: <T>(object: T, secrets: UnistyleSecrets) => T;
13
15
  export declare const extractSecrets: (object: any) => {
@@ -20,4 +22,5 @@ export declare const checkForProp: (value: any, prop: string) => boolean;
20
22
  export declare const checkForAnimated: (value: any) => boolean;
21
23
  export declare const isGeneratedUnistyle: (value: Record<string, any>) => value is UniGeneratedStyle;
22
24
  export declare const convertTheme: (key: string, value: any, prev?: string) => [string, any];
25
+ export declare const getClosestBreakpointValue: <T>(runtime: UnistylesRuntime, values: Partial<Record<keyof UnistylesBreakpoints, T>>) => T | undefined;
23
26
  //# sourceMappingURL=unistyle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AACzF,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGpG,OAAO,EAA4C,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAG3F,eAAO,MAAM,aAAa,GAAI,QAAQ,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;CAC/D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,eAAe,MAanE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG;;aAYzC,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,eAAe,OAUzD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,gBAAgB,KAAK,CAAC,MAAM,CAAC,WA6BzE,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,OAAO,GAAG,yBAQrD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,EAAE,MAAM,MAAM,KAAG,OAcvD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,KAAG,OAgB7C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,KAAK,IAAI,iBAIzE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,OAAO,GAAG,EAAE,aAAU,KAAG,CAAC,MAAM,EAAE,GAAG,CAU9E,CAAA"}
1
+ {"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AACzF,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAEpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,EAA4C,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAG3F,eAAO,MAAM,aAAa,GAAI,QAAQ,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;CACrE,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,eAAe,MAanE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG;;aAYzC,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,eAAe,OAUzD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,gBAAgB,KAAK,CAAC,MAAM,CAAC,WA6BzE,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,OAAO,GAAG,yBAQrD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,EAAE,MAAM,MAAM,KAAG,OAcvD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,KAAG,OAgB7C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,KAAK,IAAI,iBAIzE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,EAAE,OAAO,GAAG,EAAE,aAAU,KAAG,CAAC,MAAM,EAAE,GAAG,CAU9E,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,EAAE,SAAS,gBAAgB,EAAE,QAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,oBAAoB,EAAE,CAAC,CAAC,CAAC,kBAa7H,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-nightly-20250609",
3
+ "version": "3.0.0-nightly-20250613",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin",
@@ -17,9 +17,14 @@ export const ScopedTheme: React.FunctionComponent<React.PropsWithChildren<ThemeP
17
17
  children,
18
18
  invertedAdaptive
19
19
  }) => {
20
- const isAdaptiveTheme = invertedAdaptive && UnistylesRuntime.hasAdaptiveThemes
20
+ const hasAdaptiveThemes = UnistylesRuntime.hasAdaptiveThemes
21
+ const isAdaptiveTheme = invertedAdaptive && hasAdaptiveThemes
21
22
 
22
- if (!isAdaptiveTheme && !name) {
23
+ if (invertedAdaptive && !hasAdaptiveThemes) {
24
+ return children
25
+ }
26
+
27
+ if (!invertedAdaptive && !name) {
23
28
  if (__DEV__) {
24
29
  console.error('ScopedTheme: name or invertedAdaptive must be provided')
25
30
  }
@@ -26,6 +26,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
26
26
  type PropsWithUnistyles = Partial<TProps> & {
27
27
  uniProps?: Mappings<TProps>
28
28
  }
29
+
29
30
  const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
30
31
  const styles = Array.isArray(styleProps)
31
32
  ? styleProps.flat()
@@ -1 +1,2 @@
1
1
  export { useAnimatedTheme } from './useAnimatedTheme'
2
+ export { useAnimatedVariantColor } from './variant'
@@ -0,0 +1 @@
1
+ export * from './useAnimatedVariantColor'
@@ -0,0 +1,14 @@
1
+ export type ColorKeys<T> = {
2
+ [K in keyof T]: K extends string
3
+ ? K extends `${string}color${string}` | `${string}Color${string}`
4
+ ? K
5
+ : never
6
+ : never
7
+ }[keyof T]
8
+
9
+ export type UseUpdateVariantColorConfig<T extends Record<string, any>> = {
10
+ animateCallback?: (from: string, to: string) => void,
11
+ colorKey: ColorKeys<T>,
12
+ style: T,
13
+ secretKey: string | undefined
14
+ }
@@ -0,0 +1,38 @@
1
+ import { interpolateColor, useDerivedValue, useSharedValue } from 'react-native-reanimated'
2
+ import type { ColorKeys } from './types'
3
+ import { useUpdateVariantColor } from './useUpdateVariantColor'
4
+
5
+ export const useAnimatedVariantColor = <T extends Record<string, any>>(style: T, colorKey: ColorKeys<T>) => {
6
+ const secretKey = Object.keys(style).find(key => key.startsWith('unistyles_'))
7
+ // @ts-ignore this is hidden from TS
8
+ const hasVariants = style[secretKey]?.__stylesheetVariants
9
+
10
+ if (!hasVariants || !colorKey.toLowerCase().includes('color')) {
11
+ throw new Error('useAnimatedVariantColor: Style was not created by Unistyles, does not have variants or has no color property')
12
+ }
13
+
14
+ const { fromValue, toValue } = useUpdateVariantColor({
15
+ animateCallback: (from, to) => animate(from, to),
16
+ colorKey,
17
+ secretKey,
18
+ style,
19
+ })
20
+
21
+ const progress = useSharedValue(1)
22
+ const animate = (from: string, to: string) => {
23
+ 'worklet'
24
+
25
+ fromValue.set(from)
26
+ toValue.set(to)
27
+ }
28
+
29
+ const derivedColor = useDerivedValue(() => {
30
+ return interpolateColor(
31
+ progress.value,
32
+ [0, 1],
33
+ [fromValue.get(), toValue.get()]
34
+ )
35
+ })
36
+
37
+ return derivedColor
38
+ }
@@ -0,0 +1,38 @@
1
+ import { useEffect, useLayoutEffect } from 'react'
2
+ import { useSharedValue } from 'react-native-reanimated'
3
+ import { StyleSheet, UnistyleDependency } from '../../specs'
4
+ import type { UseUpdateVariantColorConfig } from './types'
5
+
6
+ export const useUpdateVariantColor = <T extends Record<string, any>>({
7
+ colorKey,
8
+ style,
9
+ secretKey
10
+ }: UseUpdateVariantColorConfig<T>) => {
11
+ const fromValue = useSharedValue<string>(style[colorKey])
12
+ const toValue = useSharedValue<string>(style[colorKey])
13
+
14
+ useEffect(() => {
15
+ // @ts-ignore this is hidden from TS
16
+ const dispose = StyleSheet.addChangeListener(changedDependencies => {
17
+ if (changedDependencies.includes(UnistyleDependency.Theme) || changedDependencies.includes(UnistyleDependency.Breakpoints)) {
18
+ // @ts-ignore
19
+ const newStyles = style[secretKey]?.uni__getStyles()
20
+
21
+ fromValue.set(toValue.value)
22
+ toValue.set(newStyles[colorKey])
23
+ }
24
+ })
25
+
26
+ return () => dispose()
27
+ }, [style, colorKey])
28
+
29
+ useLayoutEffect(() => {
30
+ fromValue.set(toValue.value)
31
+ toValue.set(style[colorKey])
32
+ }, [style, colorKey])
33
+
34
+ return {
35
+ fromValue,
36
+ toValue
37
+ }
38
+ }
@@ -0,0 +1,81 @@
1
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
2
+ import { runOnUI, useSharedValue } from 'react-native-reanimated'
3
+ import { UnistyleDependency } from '../../specs'
4
+ import type { UnistylesValues } from '../../types'
5
+ import { services } from '../../web/services'
6
+ import { getClosestBreakpointValue } from '../../web/utils'
7
+ import type { UseUpdateVariantColorConfig } from './types'
8
+
9
+ export const useUpdateVariantColor = <T extends Record<string, any>>({
10
+ animateCallback,
11
+ colorKey,
12
+ style
13
+ }: UseUpdateVariantColorConfig<T>) => {
14
+ const [dummyDiv] = useState(() => {
15
+ const div = document.createElement('div')
16
+
17
+ div.style.display = 'none'
18
+ document.body.appendChild(div)
19
+
20
+ return div
21
+ })
22
+ const parsedStyles = useMemo(() => {
23
+ return services.shadowRegistry.addStyles([style]).parsedStyles
24
+ }, [style])
25
+ const getCurrentColor = useCallback(
26
+ () => {
27
+ if (!parsedStyles) {
28
+ return 'rgb(0, 0, 0)'
29
+ }
30
+
31
+ const currentColor = parsedStyles[colorKey as keyof UnistylesValues] as string | Record<string, string>
32
+ const currentColorVar = typeof currentColor === 'string'
33
+ ? currentColor
34
+ : getClosestBreakpointValue<string>(services.runtime, currentColor) ?? 'rgb(0, 0, 0)'
35
+
36
+ if (currentColorVar.startsWith('var(--')) {
37
+ dummyDiv.style.color = currentColorVar
38
+
39
+ return getComputedStyle(dummyDiv).color
40
+ }
41
+
42
+ return currentColorVar
43
+ },
44
+ [style, colorKey]
45
+ )
46
+ const fromValue = useSharedValue<string>(getCurrentColor())
47
+ const toValue = useSharedValue<string>(getCurrentColor())
48
+
49
+ useEffect(() => {
50
+ const dispose = services.listener.addListeners([UnistyleDependency.Theme], () => {
51
+ runOnUI(() => {
52
+ animateCallback?.(toValue.get(), getCurrentColor())
53
+ })()
54
+ })
55
+
56
+ return () => dispose()
57
+ }, [style, colorKey])
58
+
59
+ useLayoutEffect(() => {
60
+ animateCallback?.(toValue.get(), getCurrentColor())
61
+
62
+ const colorStyle = parsedStyles?.[colorKey as keyof UnistylesValues]
63
+
64
+ if (typeof colorStyle !== 'object' || colorStyle === null) {
65
+ return
66
+ }
67
+
68
+ const dispose = services.listener.addListeners([UnistyleDependency.Breakpoints], () => {
69
+ animateCallback?.(toValue.get(), getCurrentColor())
70
+ })
71
+
72
+ return () => dispose()
73
+ }, [style, colorKey])
74
+
75
+ useEffect(() => () => dummyDiv.remove(), [])
76
+
77
+ return {
78
+ fromValue,
79
+ toValue
80
+ }
81
+ }
@@ -1,26 +1,12 @@
1
- export const pseudos = [
2
- '_-moz-broken',
3
- '_-moz-drag-over',
4
- '_-moz-first-node',
5
- '_-moz-handler-blocked',
6
- '_-moz-handler-crashed',
7
- '_-moz-handler-disabled',
8
- '_-moz-last-node',
9
- '_-moz-loading',
10
- '_-moz-locale-dir(ltr)',
11
- '_-moz-locale-dir(rtl)',
12
- '_-moz-only-whitespace',
13
- '_-moz-submit-invalid',
14
- '_-moz-suppressed',
15
- '_-moz-user-disabled',
16
- '_-moz-window-inactive',
1
+ // All non experimental pseudo clasess and elements
2
+
3
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
4
+ const pseudoClasses = [
17
5
  '_active',
18
6
  '_any-link',
19
7
  '_autofill',
20
- '_blank',
21
8
  '_buffering',
22
9
  '_checked',
23
- '_current',
24
10
  '_default',
25
11
  '_defined',
26
12
  '_dir(',
@@ -33,8 +19,8 @@ export const pseudos = [
33
19
  '_focus',
34
20
  '_focus-visible',
35
21
  '_focus-within',
36
- '_fullscreen',
37
22
  '_future',
23
+ '_has-slotted',
38
24
  '_has(',
39
25
  '_host',
40
26
  '_host-context(',
@@ -49,7 +35,6 @@ export const pseudos = [
49
35
  '_last-of-type',
50
36
  '_left',
51
37
  '_link',
52
- '_local-link',
53
38
  '_modal',
54
39
  '_muted',
55
40
  '_not(',
@@ -59,6 +44,7 @@ export const pseudos = [
59
44
  '_nth-of-type(',
60
45
  '_only-child',
61
46
  '_only-of-type',
47
+ '_open',
62
48
  '_optional',
63
49
  '_out-of-range',
64
50
  '_past',
@@ -71,45 +57,27 @@ export const pseudos = [
71
57
  '_read-write',
72
58
  '_required',
73
59
  '_right',
60
+ '_root',
74
61
  '_scope',
75
62
  '_seeking',
76
63
  '_stalled',
77
64
  '_state(',
78
65
  '_target',
79
- '_target-within',
80
66
  '_user-invalid',
81
67
  '_user-valid',
82
68
  '_valid',
83
69
  '_visited',
84
70
  '_volume-locked',
85
- '_where(',
86
- '_-moz-color-swatch',
87
- '_-moz-focus-inner',
88
- '_-moz-list-bullet',
89
- '_-moz-list-number',
90
- '_-moz-meter-bar',
91
- '_-moz-progress-bar',
92
- '_-moz-range-progress',
93
- '_-moz-range-thumb',
94
- '_-moz-range-track',
95
- '_-webkit-inner-spin-button',
96
- '_-webkit-meter-barDeprecated',
97
- '_-webkit-meter-even-less-good-value',
98
- '_-webkit-meter-inner-element',
99
- '_-webkit-meter-optimum-value',
100
- '_-webkit-meter-suboptimum-value',
101
- '_-webkit-progress-bar',
102
- '_-webkit-progress-inner-element',
103
- '_-webkit-progress-value',
104
- '_-webkit-scrollbar',
105
- '_-webkit-search-cancel-button',
106
- '_-webkit-search-results-button',
107
- '_-webkit-slider-runnable-track',
108
- '_-webkit-slider-thumb',
71
+ '_where',
72
+ ] as const
73
+
74
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
75
+ const pseudoElements = [
109
76
  '_after',
110
77
  '_backdrop',
111
78
  '_before',
112
79
  '_cue',
80
+ '_details-content',
113
81
  '_file-selector-button',
114
82
  '_first-letter',
115
83
  '_first-line',
@@ -123,15 +91,18 @@ export const pseudos = [
123
91
  '_spelling-error',
124
92
  '_target-text',
125
93
  '_view-transition',
126
- '_view-transition-group',
127
- '_view-transition-image-pair',
128
- '_view-transition-new',
129
- '_view-transition-old',
94
+ '_view-transition-group(',
95
+ '_view-transition-image-pair(',
96
+ '_view-transition-new(',
97
+ '_view-transition-old(',
130
98
  ] as const
131
99
 
132
- export const isPseudo = (selector: string) => pseudos.some(pseudo => selector.startsWith(pseudo))
133
-
134
100
  type AddDynamicSelector<T extends string> = T extends `${infer U}(` ? `${U}(${string})` : T
135
101
 
136
- export type Pseudo = AddDynamicSelector<typeof pseudos[number]>
102
+ export type Pseudo = AddDynamicSelector<(typeof pseudoClasses)[number] | (typeof pseudoElements)[number]>
103
+
104
+ export const isPseudoClass = (selector: string) => pseudoClasses.some(pseudo => selector.startsWith(pseudo))
105
+
106
+ export const isPseudoElement = (selector: string) => pseudoElements.some(pseudo => selector.startsWith(pseudo))
137
107
 
108
+ export const isPseudo = (selector: string) => isPseudoClass(selector) || isPseudoElement(selector)
package/src/web/create.ts CHANGED
@@ -21,7 +21,7 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
21
21
  __uni__key: key,
22
22
  __uni__stylesheet: stylesheet,
23
23
  __uni__args: args,
24
- __uni_variants: variants
24
+ __stylesheetVariants: variants
25
25
  })
26
26
 
27
27
  const createStyleSheetStyles = (variants?: Variants) => {
@@ -1,10 +1,12 @@
1
+ import { isPseudoClass } from '../convert/pseudo'
1
2
  import { getMediaQuery } from '../utils'
2
3
  import type { CSSState } from './state'
3
4
 
4
5
  export const convertToCSS = (hash: string, value: Record<string, any>, state: CSSState) => {
5
6
  Object.entries(value).forEach(([styleKey, styleValue]) => {
6
7
  if (styleKey[0] === '_') {
7
- const pseudoClassName = styleKey.replace('_', `${hash}:`)
8
+ const isStylePseudoClass = isPseudoClass(styleKey)
9
+ const pseudoClassName = `${hash}${isStylePseudoClass ? ':' : '::'}${styleKey.slice(1)}`
8
10
 
9
11
  Object.entries(styleValue).forEach(([pseudoStyleKey, pseudoStyleValue]) => {
10
12
  if (typeof pseudoStyleValue === 'object' && pseudoStyleValue !== null) {
@@ -49,7 +49,7 @@ export class UnistylesShadowRegistry {
49
49
  return {}
50
50
  }
51
51
 
52
- const { __uni__key, __uni__stylesheet, __uni__args = [], __uni_variants: variants } = secrets
52
+ const { __uni__key, __uni__stylesheet, __uni__args = [], __stylesheetVariants: variants } = secrets
53
53
  const newComputedStylesheet = this.services.registry.getComputedStylesheet(__uni__stylesheet, scopedTheme)
54
54
  const style = newComputedStylesheet[__uni__key] as (UnistylesValues | ((...args: any) => UnistylesValues))
55
55
  const result = typeof style === 'function'
@@ -94,7 +94,7 @@ export class UnistylesShadowRegistry {
94
94
  ? hash.replace(' > *', '')
95
95
  : hash
96
96
 
97
- return { injectedClassName, hash: hashClassname }
97
+ return { injectedClassName, hash: hashClassname, parsedStyles }
98
98
  }
99
99
 
100
100
  setScopedTheme = (theme?: UnistylesTheme) => {
package/src/web/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { UnistylesValues } from '../types'
1
2
  import type { UnistylesListener } from './listener'
2
3
  import type { UnistylesRegistry } from './registry'
3
4
  import type { UnistylesRuntime } from './runtime'
@@ -15,4 +16,6 @@ export type UnistylesServices = {
15
16
  export const UNI_GENERATED_KEYS = ['$$css', 'hash', 'injectedClassName'] as const
16
17
  export type UniGeneratedKey = typeof UNI_GENERATED_KEYS[number]
17
18
 
18
- export type UniGeneratedStyle = Record<UniGeneratedKey, string>
19
+ export type UniGeneratedStyle = Record<UniGeneratedKey, string> & {
20
+ parsedStyles?: UnistylesValues
21
+ }
@@ -3,7 +3,8 @@ import type { UnistylesBreakpoints } from '../../global'
3
3
  import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
4
4
  import { ColorScheme, Orientation } from '../../specs/types'
5
5
  import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
6
- import { isUnistylesMq, parseMq } from '../../utils'
6
+ import { isDefined, isUnistylesMq, parseMq } from '../../utils'
7
+ import type { UnistylesRuntime } from '../runtime'
7
8
  import * as unistyles from '../services'
8
9
  import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
9
10
  import { hyphenate, keyInObject, reduceObject } from './common'
@@ -22,7 +23,7 @@ export type UnistyleSecrets = {
22
23
  __uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>,
23
24
  __uni__key: string,
24
25
  __uni__args?: Array<any>,
25
- __uni_variants: Record<string, string | boolean | undefined>
26
+ __stylesheetVariants: Record<string, string | boolean | undefined>
26
27
  }
27
28
 
28
29
  export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
@@ -158,3 +159,18 @@ export const convertTheme = (key: string, value: any, prev = '-'): [string, any]
158
159
 
159
160
  return [key, value]
160
161
  }
162
+
163
+ export const getClosestBreakpointValue = <T>(runtime: UnistylesRuntime, values: Partial<Record<keyof UnistylesBreakpoints, T>>) => {
164
+ const breakpoints = runtime.breakpoints
165
+ const breakpointValues = Object.entries(values)
166
+ // Filter out non-breakpoint values
167
+ .filter((pair): pair is [keyof UnistylesBreakpoints, T] => pair[0] in breakpoints)
168
+ // Sort in descending order
169
+ .sort(([a], [b]) => (breakpoints[b] ?? 0) - (breakpoints[a] ?? 0))
170
+ // Get breakpoint value with highest priority
171
+ const [_, currentBreakpointValue] = breakpointValues.find(
172
+ ([key]) => isDefined(runtime.breakpoint) && (breakpoints[key] ?? 0) <= (breakpoints[runtime.breakpoint] ?? 0)
173
+ ) ?? []
174
+
175
+ return currentBreakpointValue
176
+ }