react-native-unistyles 3.0.0-rc.5 → 3.0.0

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 (120) hide show
  1. package/README.md +7 -7
  2. package/Unistyles.podspec +12 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -1
  5. package/android/src/main/cxx/NativeUnistylesModule.h +4 -0
  6. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +1 -0
  7. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +21 -9
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +7 -0
  9. package/cxx/core/UnistylesRegistry.cpp +7 -0
  10. package/cxx/core/UnistylesRegistry.h +2 -1
  11. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +9 -2
  12. package/get_rn_version.rb +28 -0
  13. package/ios/UnistylesModuleOnLoad.mm +5 -0
  14. package/lib/commonjs/components/AdaptiveTheme.js +1 -1
  15. package/lib/commonjs/components/AdaptiveTheme.js.map +1 -1
  16. package/lib/commonjs/components/NamedTheme.js +1 -1
  17. package/lib/commonjs/components/NamedTheme.js.map +1 -1
  18. package/lib/commonjs/components/ScopedTheme.js +23 -18
  19. package/lib/commonjs/components/ScopedTheme.js.map +1 -1
  20. package/lib/commonjs/core/createUnistylesElement.js +2 -2
  21. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  22. package/lib/commonjs/core/useProxifiedUnistyles/listener.js +1 -1
  23. package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
  24. package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +2 -1
  25. package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -1
  26. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +14 -2
  27. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  28. package/lib/commonjs/core/withUnistyles/withUnistyles.js +9 -3
  29. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  30. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +9 -3
  31. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  32. package/lib/commonjs/mocks.js +21 -0
  33. package/lib/commonjs/mocks.js.map +1 -1
  34. package/lib/commonjs/specs/UnistylesRuntime/index.js +0 -1
  35. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  36. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
  37. package/lib/commonjs/web/convert/pseudo.js +13 -3
  38. package/lib/commonjs/web/convert/pseudo.js.map +1 -1
  39. package/lib/commonjs/web/convert/utils.js +1 -0
  40. package/lib/commonjs/web/convert/utils.js.map +1 -1
  41. package/lib/commonjs/web/css/core.js +3 -1
  42. package/lib/commonjs/web/css/core.js.map +1 -1
  43. package/lib/commonjs/web/listener.js +2 -2
  44. package/lib/commonjs/web/listener.js.map +1 -1
  45. package/lib/commonjs/web/runtime.js +11 -1
  46. package/lib/commonjs/web/runtime.js.map +1 -1
  47. package/lib/module/components/AdaptiveTheme.js +1 -1
  48. package/lib/module/components/AdaptiveTheme.js.map +1 -1
  49. package/lib/module/components/NamedTheme.js +1 -1
  50. package/lib/module/components/NamedTheme.js.map +1 -1
  51. package/lib/module/components/ScopedTheme.js +23 -18
  52. package/lib/module/components/ScopedTheme.js.map +1 -1
  53. package/lib/module/core/createUnistylesElement.js +2 -2
  54. package/lib/module/core/createUnistylesElement.js.map +1 -1
  55. package/lib/module/core/useProxifiedUnistyles/listener.js +1 -1
  56. package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
  57. package/lib/module/core/useProxifiedUnistyles/listener.native.js +2 -1
  58. package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -1
  59. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +14 -2
  60. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  61. package/lib/module/core/withUnistyles/withUnistyles.js +9 -3
  62. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  63. package/lib/module/core/withUnistyles/withUnistyles.native.js +9 -3
  64. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  65. package/lib/module/mocks.js +21 -0
  66. package/lib/module/mocks.js.map +1 -1
  67. package/lib/module/specs/UnistylesRuntime/index.js +0 -1
  68. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  69. package/lib/module/web/convert/object/boxShadow.js.map +1 -1
  70. package/lib/module/web/convert/pseudo.js +10 -2
  71. package/lib/module/web/convert/pseudo.js.map +1 -1
  72. package/lib/module/web/convert/utils.js +1 -0
  73. package/lib/module/web/convert/utils.js.map +1 -1
  74. package/lib/module/web/css/core.js +3 -1
  75. package/lib/module/web/css/core.js.map +1 -1
  76. package/lib/module/web/listener.js +2 -2
  77. package/lib/module/web/listener.js.map +1 -1
  78. package/lib/module/web/runtime.js +11 -1
  79. package/lib/module/web/runtime.js.map +1 -1
  80. package/lib/typescript/src/components/NamedTheme.d.ts +1 -1
  81. package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -1
  82. package/lib/typescript/src/components/ScopedTheme.d.ts +9 -3
  83. package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
  84. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  85. package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
  86. package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts +1 -1
  87. package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -1
  88. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  89. package/lib/typescript/src/core/withUnistyles/types.d.ts +3 -1
  90. package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -1
  91. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  92. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  93. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  94. package/lib/typescript/src/web/convert/pseudo.d.ts +6 -3
  95. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
  96. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  97. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  98. package/lib/typescript/src/web/listener.d.ts +4 -2
  99. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  100. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  101. package/package.json +2 -1
  102. package/src/components/AdaptiveTheme.tsx +1 -1
  103. package/src/components/NamedTheme.tsx +2 -2
  104. package/src/components/ScopedTheme.tsx +39 -32
  105. package/src/core/createUnistylesElement.tsx +5 -3
  106. package/src/core/useProxifiedUnistyles/listener.native.ts +3 -1
  107. package/src/core/useProxifiedUnistyles/listener.ts +1 -1
  108. package/src/core/useProxifiedUnistyles/types.ts +1 -1
  109. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +19 -2
  110. package/src/core/withUnistyles/types.ts +1 -1
  111. package/src/core/withUnistyles/withUnistyles.native.tsx +9 -3
  112. package/src/core/withUnistyles/withUnistyles.tsx +11 -8
  113. package/src/mocks.ts +23 -0
  114. package/src/specs/UnistylesRuntime/index.ts +0 -1
  115. package/src/web/convert/object/boxShadow.ts +2 -2
  116. package/src/web/convert/pseudo.ts +23 -52
  117. package/src/web/convert/utils.ts +2 -1
  118. package/src/web/css/core.ts +3 -1
  119. package/src/web/listener.ts +8 -6
  120. package/src/web/runtime.ts +14 -1
@@ -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":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAqB,KAAK,OAAO,EAAsB,MAAM,SAAS,CAAA;AAEjH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,OAAO,GAAG,KAAG,KAAK,IAAI,KAAK,CAAC,eAAe,CAAgD,CAAA;AAEpI,eAAO,MAAM,YAAY,GAAI,KA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AAI,KAAK,MAAM,EAAE,OAAO,GAAG,KAAG,KAAK,IAAI,KAAK,CAAC,cAAc,CAAgD,CAAA;AAEnI,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,GAAG,MAAM,oBAA8D,CAAA;AAE1H,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,gBAAW,WAyBxD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,IAAI,SAAS,aAAa,EAAE,KAAK,IAAI,EAAE,YAAY,MAAM,EAAE,QAAQ,GAAG,KAAG,SAAS,CAAC,IAAI,CAazH,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"}
@@ -1,5 +1,6 @@
1
1
  import { UnistyleDependency } from '../specs/NativePlatform';
2
2
  import type { UnistylesServices } from './types';
3
+ type Listener = (dependency: UnistyleDependency) => void;
3
4
  export declare class UnistylesListener {
4
5
  private services;
5
6
  private isInitialized;
@@ -8,7 +9,8 @@ export declare class UnistylesListener {
8
9
  constructor(services: UnistylesServices);
9
10
  emitChange: (dependency: UnistyleDependency) => void;
10
11
  initListeners: () => void;
11
- addListeners: (dependencies: Array<UnistyleDependency>, listener: VoidFunction) => () => void;
12
- addStylesheetListeners: (dependencies: Array<UnistyleDependency>, listener: VoidFunction) => () => void;
12
+ addListeners: (dependencies: Array<UnistyleDependency>, listener: Listener) => () => void;
13
+ addStylesheetListeners: (dependencies: Array<UnistyleDependency>, listener: Listener) => () => void;
13
14
  }
15
+ export {};
14
16
  //# sourceMappingURL=listener.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,qBAAa,iBAAiB;IAKd,OAAO,CAAC,QAAQ;IAJ5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IACrH,OAAO,CAAC,mBAAmB,CAAoG;gBAE3G,QAAQ,EAAE,iBAAiB;IAE/C,UAAU,GAAI,YAAY,kBAAkB,UAG3C;IAED,aAAa,aAkCZ;IAED,YAAY,GAAI,cAAc,KAAK,CAAC,kBAAkB,CAAC,EAAE,UAAU,YAAY,gBAM9E;IAED,sBAAsB,GAAI,cAAc,KAAK,CAAC,kBAAkB,CAAC,EAAE,UAAU,YAAY,gBAMxF;CACJ"}
1
+ {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,KAAK,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,IAAI,CAAA;AAExD,qBAAa,iBAAiB;IAKd,OAAO,CAAC,QAAQ;IAJ5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAgG;IACjH,OAAO,CAAC,mBAAmB,CAAgG;gBAEvG,QAAQ,EAAE,iBAAiB;I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;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,GAAI,WAAW,YAAY,UAmBlC;IAED,iBAAiB,GAAI,WAAW,OAAO,UAiBtC;IAED,0BAA0B,GAAI,OAAO,MAAM,UAM1C;IAED,gBAAgB,aAAW;IAE3B,WAAW,GAAI,WAAW,YAAY,EAAE,SAAS,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAsBpF;IAED,QAAQ,GAAI,qBAA0B,EAAE,iBAAe,WActD;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-rc.5",
3
+ "version": "3.0.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin",
@@ -91,6 +91,7 @@
91
91
  "react-native.config.js",
92
92
  "Unistyles.podspec",
93
93
  "repack-plugin",
94
+ "get_rn_version.rb",
94
95
  "!repack-plugin/__tests__",
95
96
  "!repack-plugin/src",
96
97
  "!repack-plugin/esbuild.js",
@@ -14,7 +14,7 @@ export const AdaptiveTheme: React.FunctionComponent<AdaptiveThemeProps> = ({
14
14
  previousScopedTheme
15
15
  }) => {
16
16
  const { rt } = useUnistyles()
17
- const name = (rt.themeName === 'dark' ? 'light' : 'dark') as keyof UnistylesThemes
17
+ const name = (rt.colorScheme === 'dark' ? 'light' : 'dark') as keyof UnistylesThemes
18
18
  const mappedChildren = [
19
19
  <ApplyScopedTheme key={name} name={name} />,
20
20
  children,
@@ -5,7 +5,7 @@ import { UnistylesShadowRegistry } from '../specs'
5
5
  import { ApplyScopedTheme } from './ApplyScopedTheme'
6
6
 
7
7
  interface NamedThemeProps extends PropsWithChildren {
8
- name: keyof UnistylesThemes,
8
+ name: keyof UnistylesThemes | undefined,
9
9
  previousScopedTheme?: string
10
10
  }
11
11
 
@@ -15,7 +15,7 @@ export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({
15
15
  previousScopedTheme
16
16
  }) => {
17
17
  const mappedChildren = [
18
- <ApplyScopedTheme key={name} name={name} />,
18
+ <ApplyScopedTheme key='apply' name={name} />,
19
19
  children,
20
20
  <ApplyScopedTheme key='dispose' name={previousScopedTheme as keyof UnistylesThemes | undefined} />
21
21
  ]
@@ -6,47 +6,54 @@ import { NamedTheme } from './NamedTheme'
6
6
 
7
7
  type ThemeProps = {
8
8
  name: keyof UnistylesThemes,
9
- invertedAdaptive?: boolean
9
+ invertedAdaptive?: never
10
+ reset?: never
10
11
  } | {
11
- name?: undefined,
12
- invertedAdaptive: true
12
+ name?: never,
13
+ invertedAdaptive: boolean,
14
+ reset?: never
15
+ } | {
16
+ name?: never,
17
+ invertedAdaptive?: never,
18
+ reset: boolean
13
19
  }
14
20
 
15
21
  export const ScopedTheme: React.FunctionComponent<React.PropsWithChildren<ThemeProps>> = ({
16
22
  name,
17
23
  children,
18
- invertedAdaptive
24
+ invertedAdaptive,
25
+ reset
19
26
  }) => {
20
27
  const hasAdaptiveThemes = UnistylesRuntime.hasAdaptiveThemes
21
28
  const isAdaptiveTheme = invertedAdaptive && hasAdaptiveThemes
22
-
23
- if (invertedAdaptive && !hasAdaptiveThemes) {
24
- return children
25
- }
26
-
27
- if (!invertedAdaptive && !name) {
28
- if (__DEV__) {
29
- console.error('ScopedTheme: name or invertedAdaptive must be provided')
30
- }
31
-
32
- return null
33
- }
34
-
35
29
  const previousScopedTheme = UnistylesShadowRegistry.getScopedTheme()
36
30
 
37
- return isAdaptiveTheme
38
- ? (
39
- <AdaptiveTheme previousScopedTheme={previousScopedTheme}>
40
- {children}
41
- </AdaptiveTheme>
42
- )
43
- : (
44
- <NamedTheme
45
- name={name as keyof UnistylesThemes}
46
- previousScopedTheme={previousScopedTheme}
47
- >
48
- {children}
49
- </NamedTheme>
50
- )
51
-
31
+ switch (true) {
32
+ case name !== undefined:
33
+ return (
34
+ <NamedTheme
35
+ name={name as keyof UnistylesThemes}
36
+ previousScopedTheme={previousScopedTheme}
37
+ >
38
+ {children}
39
+ </NamedTheme>
40
+ )
41
+ case isAdaptiveTheme:
42
+ return (
43
+ <AdaptiveTheme previousScopedTheme={previousScopedTheme}>
44
+ {children}
45
+ </AdaptiveTheme>
46
+ )
47
+ case reset:
48
+ return (
49
+ <NamedTheme
50
+ name={undefined}
51
+ previousScopedTheme={previousScopedTheme}
52
+ >
53
+ {children}
54
+ </NamedTheme>
55
+ )
56
+ default:
57
+ return children
58
+ }
52
59
  }
@@ -7,14 +7,16 @@ import { createUnistylesRef } from '../web/utils/createUnistylesRef'
7
7
  import { getClassName } from './getClassname'
8
8
  import { maybeWarnAboutMultipleUnistyles } from './warn'
9
9
 
10
- const STYLE_PROPS = ['style', 'contentContainerStyle', 'columnWrapperStyle'] as const
10
+ const STYLE_PROPS = ['contentContainerStyle', 'columnWrapperStyle'] as const
11
+
12
+ type StyleProp = typeof STYLE_PROPS[number] | 'style'
11
13
 
12
14
  type ComponentProps = {
13
- [K in typeof STYLE_PROPS[number]]?: UnistylesValues
15
+ [K in StyleProp]?: UnistylesValues
14
16
  }
15
17
 
16
18
  const buildUnistylesProps = (Component: any, props: ComponentProps, forwardedRef: React.ForwardedRef<unknown>) => {
17
- const componentStyleProps = STYLE_PROPS.filter(styleProp => styleProp in props)
19
+ const componentStyleProps = ['style' as const, ...STYLE_PROPS.filter(styleProp => styleProp in props)]
18
20
  const classNames = Object.fromEntries(componentStyleProps.map(styleProp => [styleProp, getClassName(props[styleProp])]))
19
21
  const refs = componentStyleProps.map(styleProp => {
20
22
  return createUnistylesRef(
@@ -10,7 +10,9 @@ export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerP
10
10
  }
11
11
 
12
12
  if (changedDependencies.some((dependency: UnistyleDependency) => dependencies.includes(dependency))) {
13
- updateRuntime()
13
+ const hasThemeNameChange = changedDependencies.includes(UnistyleDependency.ThemeName)
14
+
15
+ updateRuntime(hasThemeNameChange)
14
16
  }
15
17
  })
16
18
 
@@ -4,7 +4,7 @@ import type { ListenerProps } from './types'
4
4
 
5
5
  export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
6
6
  const disposeTheme = unistyles.services.listener.addListeners(dependencies.filter(dependency => dependency === UnistyleDependency.Theme), updateTheme)
7
- const disposeRuntime = unistyles.services.listener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), updateRuntime)
7
+ const disposeRuntime = unistyles.services.listener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), dependency => updateRuntime(dependency === UnistyleDependency.ThemeName))
8
8
 
9
9
  return () => {
10
10
  disposeTheme()
@@ -2,6 +2,6 @@ import type { UnistyleDependency } from '../../specs'
2
2
 
3
3
  export type ListenerProps = {
4
4
  updateTheme: VoidFunction,
5
- updateRuntime: VoidFunction,
5
+ updateRuntime(themeNameChange: boolean): void,
6
6
  dependencies: Array<UnistyleDependency>
7
7
  }
@@ -28,7 +28,7 @@ const RTDependencyMap = {
28
28
  } satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
29
29
 
30
30
  export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
31
- const scopedTheme = forcedTheme ?? UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
31
+ const [scopedTheme, setScopedTheme] = useState(forcedTheme ?? UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme)
32
32
  const [dependencies] = useState(() => new Set<number>())
33
33
  const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
34
34
  const [_, runtimeChanged] = useReducer(() => ({}), {})
@@ -45,7 +45,13 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
45
45
 
46
46
  setTheme(UnistylesRuntime.getTheme(scopedTheme))
47
47
  },
48
- updateRuntime: () => runtimeChanged()
48
+ updateRuntime: (hasThemeNameChange: boolean) => {
49
+ if (hasThemeNameChange && scopedTheme) {
50
+ return
51
+ }
52
+
53
+ runtimeChanged()
54
+ }
49
55
  })
50
56
  }
51
57
 
@@ -55,6 +61,13 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
55
61
  return () => disposeRef.current?.()
56
62
  }, [dependencies.size])
57
63
 
64
+
65
+ const maybeNewScopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
66
+
67
+ if (scopedTheme && maybeNewScopedTheme && scopedTheme !== maybeNewScopedTheme) {
68
+ setScopedTheme(maybeNewScopedTheme)
69
+ }
70
+
58
71
  const proxifiedTheme = new Proxy(theme, {
59
72
  get: (target, prop) => {
60
73
  dependencies.add(UnistyleDependency.Theme)
@@ -84,6 +97,10 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
84
97
  dependencies.add(RTDependencyMap[prop as keyof typeof RTDependencyMap])
85
98
  }
86
99
 
100
+ if (prop === 'themeName' && scopedTheme) {
101
+ return scopedTheme
102
+ }
103
+
87
104
  return target[prop as keyof typeof target]
88
105
  }
89
106
  })
@@ -4,4 +4,4 @@ import type { UnistylesTheme } from '../../types';
4
4
  export const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
5
5
 
6
6
  export type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
7
- export type Mappings<T = {}> = (theme: UnistylesTheme, rt: UnistylesMiniRuntime) => Omit<Partial<T>, SupportedStyleProps>
7
+ export type Mappings<T = {}> = (theme: UnistylesTheme, rt: UnistylesMiniRuntime) => Omit<Partial<T>, SupportedStyleProps> & { key?: string }
@@ -75,8 +75,8 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
75
75
  addDependencies(Array.from(new Set([...styleSecrets.dependencies, ...contentContainerStyleSecrets.dependencies])))
76
76
  }, [narrowedProps.style, narrowedProps.contentContainerStyle])
77
77
 
78
- const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
79
- const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
78
+ const { key: mappingsKey, ...mappingsProps } = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
79
+ const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
80
80
 
81
81
  const styleSecrets = getSecrets(narrowedProps.style)
82
82
  const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
@@ -91,6 +91,12 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
91
91
  } : {},
92
92
  } as any
93
93
 
94
- return <NativeComponent {...finalProps as TProps} ref={ref} />
94
+ return (
95
+ <NativeComponent
96
+ key={uniPropsKey || mappingsKey}
97
+ {...finalProps as TProps}
98
+ ref={ref}
99
+ />
100
+ )
95
101
  })
96
102
  }
@@ -27,16 +27,15 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
27
27
  const contentContainerStyleClassNames = getClassName(narrowedProps.contentContainerStyle)
28
28
  const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
29
29
 
30
- const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
31
- const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
32
-
30
+ const { key: mappingsKey, ...mappingsProps } = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
31
+ const { key: uniPropsKey, ...unistyleProps } = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
33
32
 
34
33
  const emptyStyles = narrowedProps.style
35
34
  ? Object.fromEntries(
36
- Object.entries(Object.getOwnPropertyDescriptors(narrowedProps.style))
37
- .filter(([key]) => !key.startsWith("unistyles") && !key.startsWith("_"))
38
- .map(([key]) => [key, undefined])
39
- )
35
+ Object.entries(Object.getOwnPropertyDescriptors(narrowedProps.style))
36
+ .filter(([key]) => !key.startsWith("unistyles") && !key.startsWith("_"))
37
+ .map(([key]) => [key, undefined])
38
+ )
40
39
  : undefined
41
40
 
42
41
  const combinedProps = {
@@ -63,7 +62,11 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
63
62
  className={classNames?.hash}
64
63
  style={{ display: 'contents' }}
65
64
  >
66
- <NativeComponent {...combinedProps} ref={ref} />
65
+ <NativeComponent
66
+ key={uniPropsKey || mappingsKey}
67
+ {...combinedProps}
68
+ ref={ref}
69
+ />
67
70
  </div>
68
71
  )
69
72
  })
package/src/mocks.ts CHANGED
@@ -217,4 +217,27 @@ jest.mock('react-native-unistyles', () => {
217
217
  }
218
218
  })
219
219
 
220
+ jest.mock('react-native-unistyles/reanimated', () => {
221
+ const unistyles = require('react-native-unistyles')
222
+ const mockedSharedValue = (value: any) => ({
223
+ value
224
+ })
220
225
 
226
+ return {
227
+ useAnimatedTheme: () => {
228
+ const theme = unistyles.useUnistyles().theme
229
+ const sharedTheme = mockedSharedValue(theme)
230
+
231
+ return sharedTheme
232
+ },
233
+ useAnimatedVariantColor: () => {
234
+ const fromValue = mockedSharedValue('#000000')
235
+ const toValue = mockedSharedValue('#FFFFFF')
236
+
237
+ return {
238
+ fromValue,
239
+ toValue
240
+ }
241
+ },
242
+ }
243
+ })
@@ -44,7 +44,6 @@ const HybridUnistylesRuntime = NitroModules
44
44
 
45
45
  HybridUnistylesRuntime.statusBar = HybridUnistylesRuntime.createHybridStatusBar()
46
46
  HybridUnistylesRuntime.navigationBar = HybridUnistylesRuntime.createHybridNavigationBar()
47
- HybridUnistylesRuntime._setRootViewBackgroundColor = HybridUnistylesRuntime.setRootViewBackgroundColor
48
47
 
49
48
  HybridUnistylesRuntime.setRootViewBackgroundColor = (color?: string) => {
50
49
  const parsedColor = processColor(color) ?? 0
@@ -25,7 +25,7 @@ export const getBoxShadow = (boxShadow: Array<BoxShadowValue>) => {
25
25
  const boxShadowStyle = Object.fromEntries(boxShadow.map(shadow => {
26
26
  const [key] = Object.keys(shadow)
27
27
  return [key, shadow[key as keyof BoxShadowValue]]
28
- }))
28
+ })) as BoxShadowValue
29
29
 
30
30
  return {
31
31
  boxShadow: createBoxShadowValue(boxShadowStyle)
@@ -42,7 +42,7 @@ export const getBoxShadow = (boxShadow: Array<BoxShadowValue>) => {
42
42
  }
43
43
 
44
44
  return [key, value]
45
- }))
45
+ })) as BoxShadowValue
46
46
 
47
47
  return {
48
48
  [breakpoint]: {
@@ -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)
@@ -1,5 +1,6 @@
1
1
  // based on react-native-web normalizer
2
2
  // https://github.com/necolas/react-native-web
3
+ /// <reference path="module.d.ts" />
3
4
  import normalizeColors from '@react-native/normalize-colors'
4
5
  import type { BoxShadowValue } from 'react-native'
5
6
  import type { TransformStyles } from '../../types/core'
@@ -30,7 +31,7 @@ export const normalizeColor = (color: string, opacity = 1) => {
30
31
  return color
31
32
  }
32
33
 
33
- const hex = integer.toString(16).padStart(8, '0')
34
+ const hex = integer.toString(16).padStart(8, '0') as string
34
35
 
35
36
  if (hex.length === 8) {
36
37
  const [r = 0, g = 0, b = 0, a = 1] = hex
@@ -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) {
@@ -1,16 +1,18 @@
1
1
  import { UnistyleDependency } from '../specs/NativePlatform'
2
2
  import type { UnistylesServices } from './types'
3
3
 
4
+ type Listener = (dependency: UnistyleDependency) => void
5
+
4
6
  export class UnistylesListener {
5
7
  private isInitialized = false
6
- private listeners = Array.from({ length: Object.keys(UnistyleDependency).length / 2 }, () => new Set<VoidFunction>())
7
- private stylesheetListeners = Array.from({ length: Object.keys(UnistyleDependency).length / 2 }, () => new Set<VoidFunction>())
8
+ private listeners = Array.from({ length: Object.keys(UnistyleDependency).length / 2 }, () => new Set<Listener>())
9
+ private stylesheetListeners = Array.from({ length: Object.keys(UnistyleDependency).length / 2 }, () => new Set<Listener>())
8
10
 
9
11
  constructor(private services: UnistylesServices) {}
10
12
 
11
13
  emitChange = (dependency: UnistyleDependency) => {
12
- this.stylesheetListeners[dependency]?.forEach(listener => listener())
13
- this.listeners[dependency]?.forEach(listener => listener())
14
+ this.stylesheetListeners[dependency]?.forEach(listener => listener(dependency))
15
+ this.listeners[dependency]?.forEach(listener => listener(dependency))
14
16
  }
15
17
 
16
18
  initListeners = () => {
@@ -49,7 +51,7 @@ export class UnistylesListener {
49
51
  window.addEventListener('resize', () => this.emitChange(UnistyleDependency.Dimensions))
50
52
  }
51
53
 
52
- addListeners = (dependencies: Array<UnistyleDependency>, listener: VoidFunction) => {
54
+ addListeners = (dependencies: Array<UnistyleDependency>, listener: Listener) => {
53
55
  dependencies.forEach(dependency => this.listeners[dependency]?.add(listener))
54
56
 
55
57
  return () => {
@@ -57,7 +59,7 @@ export class UnistylesListener {
57
59
  }
58
60
  }
59
61
 
60
- addStylesheetListeners = (dependencies: Array<UnistyleDependency>, listener: VoidFunction) => {
62
+ addStylesheetListeners = (dependencies: Array<UnistyleDependency>, listener: Listener) => {
61
63
  dependencies.forEach(dependency => this.stylesheetListeners[dependency]?.add(listener))
62
64
 
63
65
  return () => {