react-native-unistyles 3.6.0 → 3.7.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 (142) hide show
  1. package/README.md +4 -9
  2. package/android/build.gradle +42 -0
  3. package/android/src/legacy/java/com/unistyles/NativePlatform+extraWindows.kt +16 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +5 -11
  5. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  6. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +82 -39
  7. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +73 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +2 -13
  9. package/android/src/rn86/java/com/unistyles/NativePlatform+extraWindows.kt +28 -0
  10. package/cxx/common/PerformanceTracing.h +85 -0
  11. package/cxx/converters/BackgroundLayerConverter.cpp +523 -0
  12. package/cxx/converters/BackgroundLayerConverter.h +14 -0
  13. package/cxx/converters/FontVariationSettingsConverter.cpp +104 -0
  14. package/cxx/converters/FontVariationSettingsConverter.h +17 -0
  15. package/cxx/core/UnistyleWrapper.h +16 -1
  16. package/cxx/hybridObjects/HybridShadowRegistry.cpp +8 -0
  17. package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -0
  18. package/cxx/hybridObjects/HybridStyleSheet.h +1 -0
  19. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +10 -30
  20. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  21. package/cxx/parser/Parser.cpp +75 -10
  22. package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +74 -0
  23. package/cxx/shadowTree/ShadowTreeManager.cpp +3 -0
  24. package/lib/commonjs/components/NamedTheme.js +4 -4
  25. package/lib/commonjs/components/NamedTheme.js.map +1 -1
  26. package/lib/commonjs/components/ScopedThemeContext.js +3 -1
  27. package/lib/commonjs/components/ScopedThemeContext.js.map +1 -1
  28. package/lib/commonjs/core/createUnistylesImageBackground.js +6 -2
  29. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  30. package/lib/commonjs/core/withUnistyles/withUnistyles.js +10 -7
  31. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  32. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +22 -3
  33. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  34. package/lib/commonjs/mocks.js +27 -3
  35. package/lib/commonjs/mocks.js.map +1 -1
  36. package/lib/commonjs/specs/ShadowRegistry/index.js +13 -3
  37. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  38. package/lib/commonjs/specs/ShadowRegistry/tracing.js +26 -0
  39. package/lib/commonjs/specs/ShadowRegistry/tracing.js.map +1 -0
  40. package/lib/commonjs/utils.js +52 -1
  41. package/lib/commonjs/utils.js.map +1 -1
  42. package/lib/commonjs/web/convert/index.js +19 -1
  43. package/lib/commonjs/web/convert/index.js.map +1 -1
  44. package/lib/commonjs/web/convert/module.d.ts +3 -0
  45. package/lib/commonjs/web/convert/object/backgroundLayers.js +30 -0
  46. package/lib/commonjs/web/convert/object/backgroundLayers.js.map +1 -0
  47. package/lib/commonjs/web/convert/object/fontVariationSettings.js +12 -0
  48. package/lib/commonjs/web/convert/object/fontVariationSettings.js.map +1 -0
  49. package/lib/commonjs/web/convert/object/index.js +22 -0
  50. package/lib/commonjs/web/convert/object/index.js.map +1 -1
  51. package/lib/commonjs/web/convert/utils.js +7 -1
  52. package/lib/commonjs/web/convert/utils.js.map +1 -1
  53. package/lib/commonjs/web/registry.js +6 -4
  54. package/lib/commonjs/web/registry.js.map +1 -1
  55. package/lib/commonjs/web/runtime.js +9 -6
  56. package/lib/commonjs/web/runtime.js.map +1 -1
  57. package/lib/commonjs/web/utils/unistyle.js +1 -3
  58. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  59. package/lib/module/components/NamedTheme.js +4 -4
  60. package/lib/module/components/NamedTheme.js.map +1 -1
  61. package/lib/module/components/ScopedThemeContext.js +3 -1
  62. package/lib/module/components/ScopedThemeContext.js.map +1 -1
  63. package/lib/module/core/createUnistylesImageBackground.js +6 -2
  64. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  65. package/lib/module/core/withUnistyles/withUnistyles.js +9 -6
  66. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  67. package/lib/module/core/withUnistyles/withUnistyles.native.js +24 -5
  68. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  69. package/lib/module/mocks.js +27 -3
  70. package/lib/module/mocks.js.map +1 -1
  71. package/lib/module/specs/ShadowRegistry/index.js +13 -3
  72. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  73. package/lib/module/specs/ShadowRegistry/tracing.js +21 -0
  74. package/lib/module/specs/ShadowRegistry/tracing.js.map +1 -0
  75. package/lib/module/utils.js +50 -0
  76. package/lib/module/utils.js.map +1 -1
  77. package/lib/module/web/convert/index.js +22 -3
  78. package/lib/module/web/convert/index.js.map +1 -1
  79. package/lib/module/web/convert/module.d.ts +3 -0
  80. package/lib/module/web/convert/object/backgroundLayers.js +25 -0
  81. package/lib/module/web/convert/object/backgroundLayers.js.map +1 -0
  82. package/lib/module/web/convert/object/fontVariationSettings.js +7 -0
  83. package/lib/module/web/convert/object/fontVariationSettings.js.map +1 -0
  84. package/lib/module/web/convert/object/index.js +2 -0
  85. package/lib/module/web/convert/object/index.js.map +1 -1
  86. package/lib/module/web/convert/utils.js +4 -0
  87. package/lib/module/web/convert/utils.js.map +1 -1
  88. package/lib/module/web/registry.js +6 -4
  89. package/lib/module/web/registry.js.map +1 -1
  90. package/lib/module/web/runtime.js +9 -6
  91. package/lib/module/web/runtime.js.map +1 -1
  92. package/lib/module/web/utils/unistyle.js +2 -4
  93. package/lib/module/web/utils/unistyle.js.map +1 -1
  94. package/lib/typescript/src/components/ScopedThemeContext.d.ts +2 -1
  95. package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -1
  96. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  97. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +6 -3
  98. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  99. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +7 -4
  100. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  101. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  102. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts +2 -0
  103. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts.map +1 -0
  104. package/lib/typescript/src/utils.d.ts +1 -0
  105. package/lib/typescript/src/utils.d.ts.map +1 -1
  106. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  107. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts +4 -0
  108. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts.map +1 -0
  109. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts +4 -0
  110. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts.map +1 -0
  111. package/lib/typescript/src/web/convert/object/index.d.ts +2 -0
  112. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -1
  113. package/lib/typescript/src/web/convert/utils.d.ts +2 -0
  114. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  115. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  116. package/lib/typescript/src/web/runtime.d.ts +1 -0
  117. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  118. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  119. package/metro/babel-transformer.js +79 -17
  120. package/package.json +26 -26
  121. package/plugin/index.js +79 -17
  122. package/src/components/NamedTheme.tsx +5 -5
  123. package/src/components/ScopedThemeContext.ts +6 -2
  124. package/src/core/createUnistylesImageBackground.tsx +6 -2
  125. package/src/core/withUnistyles/withUnistyles.native.tsx +28 -6
  126. package/src/core/withUnistyles/withUnistyles.tsx +6 -6
  127. package/src/mocks.ts +14 -5
  128. package/src/specs/ShadowRegistry/index.ts +14 -3
  129. package/src/specs/ShadowRegistry/tracing.ts +23 -0
  130. package/src/utils.ts +51 -0
  131. package/src/web/convert/index.ts +39 -3
  132. package/src/web/convert/object/backgroundLayers.ts +33 -0
  133. package/src/web/convert/object/fontVariationSettings.ts +7 -0
  134. package/src/web/convert/object/index.ts +2 -0
  135. package/src/web/convert/utils.ts +11 -0
  136. package/src/web/registry.ts +7 -8
  137. package/src/web/runtime.ts +7 -7
  138. package/src/web/utils/unistyle.ts +2 -4
  139. package/lib/commonjs/web/convert/module.d.js +0 -2
  140. package/lib/commonjs/web/convert/module.d.js.map +0 -1
  141. package/lib/module/web/convert/module.d.js +0 -2
  142. package/lib/module/web/convert/module.d.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/specs/ShadowRegistry/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,OAAO,KAAK,EAAE,uBAAuB,IAAI,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAM/D,UAAU,cAAe,SAAQ,2BAA2B;IAExD,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAAA;IAC9E,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAEjC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAA;IACtD,MAAM,CAAC,IAAI,EAAE,U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AC,QAAQ,CAAC,GAAG,IAAI,CAAA;IACtD,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC/B,KAAK,IAAI,IAAI,CAAA;IACb,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,cAAc,IAAI,MAAM,GAAG,SAAS,CAAA;IACpC,MAAM,IAAI,YAAY,CAAA;IACtB,4BAA4B,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1C,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;CACpD;AAsKD,KAAK,cAAc,GACb,KAAK,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,8BAA8B,GAC9B,mBAAmB,CAAA;AAEzB,eAAO,MAAM,uBAAuB,EAA2B,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const traceSection: <T>(name: string, fn: () => T) => T;
2
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../../../src/specs/ShadowRegistry/tracing.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,MAAM,MAAM,EAAE,IAAI,MAAM,CAAC,KAAG,CAY3D,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export declare const isDefined: <T>(value: T) => value is NonNullable<T>;
2
+ export declare const isAnimatedStyleHandle: (value: unknown) => boolean;
2
3
  export declare const deepMergeObjects: <T extends Record<PropertyKey, any>>(...sources: Array<T>) => T;
3
4
  export declare const copyComponentProperties: (Component: any, UnistylesComponent: any) => any;
4
5
  export declare const isUnistylesMq: (mq: string) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ut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ot":"","sources":["../../../../../src/web/convert/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AASlD,eAAO,MAAM,gBAAgB,GAAI,OAAO,eAAe,EAAE,SAAS,gBAAgB,wBAqEjF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAoClD,eAAO,MAAM,gBAAgB,GAAI,OAAO,eAAe,EAAE,SAAS,gBAAgB,wBA8EjF,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const getBackgroundLayers: (key: string, layers: Array<unknown>) => {
2
+ [x: string]: string;
3
+ };
4
+ //# sourceMappingURL=backgroundLayers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backgroundLayers.d.ts","sourceRoot":"","sources":["../../../../../../src/web/convert/object/backgroundLayers.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,QAAQ,KAAK,CAAC,OAAO,CAAC;;CAErE,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const getFontVariationSettings: (fontVariationSettings: Record<string, number>) => {
2
+ fontVariationSettings: string;
3
+ };
4
+ //# sourceMappingURL=fontVariationSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fontVariationSettings.d.ts","sourceRoot":"","sources":["../../../../../../src/web/convert/object/fontVariationSettings.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,wBAAwB,GAAI,uBAAuB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;CAKpF,CAAA"}
@@ -1,4 +1,6 @@
1
1
  export * from './transform';
2
2
  export * from './boxShadow';
3
3
  export * from './filter';
4
+ export * from './backgroundLayers';
5
+ export * from './fontVariationSettings';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/web/convert/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/web/convert/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA"}
@@ -6,6 +6,8 @@ export declare const isTextShadow: (key: string) => boolean;
6
6
  export declare const isShadow: (key: string) => boolean;
7
7
  export declare const isFilter: (key: string, value: any) => value is Array<Filters>;
8
8
  export declare const isBoxShadow: (key: string, value: any) => value is Array<BoxShadowValue>;
9
+ export declare const isBackgroundLayer: (key: string, value: any) => value is Array<unknown>;
10
+ export declare const isFontVariationSettings: (key: string, value: any) => value is Record<string, number>;
9
11
  export declare const normalizeNumericValue: (value: number | string) => string | number;
10
12
  export declare const normalizeColor: (color: string, opacity?: number) => string;
11
13
  export declare const extractShadowValue: <TKey extends AllShadowKeys>(key: TKey, breakpoint: string, styles: any) => AllShadow[TKey];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAOlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAqB,KAAK,OAAO,EAAsB,MAAM,SAAS,CAAA;AAEjH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,OA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,CAAC,aAAa,CAAsC;IACpE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAC5G,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;gBAEF,QAAQ,EAAE,iBAAiB;IAI/C,qBAAqB,GAAI,YAAY,yBAAyB,CAAC,UAAU,CAAC,EAAE,kBAAkB,cAAc,gBAgC3G;IAED,2BAA2B,GACvB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,KAAK,UAAU,EACpF,cAAc,KAAK,CAAC,kBAAkB,CAAC,UAoB1C;IAED,OAAO,GAAI,KAAK,WAAW,EAAE,MAAM,MAAM,UAKxC;IAED,MAAM,GAAI,KAAK,WAAW,EAAE,MAAM,MAAM,sBAwBvC;IAED,GAAG,GAAI,OAAO,eAAe,EAAE,WAAW,OAAO;;;MAYhD;IAED,WAAW,GAAI,MAAM,MAAM,EAAE,OAAO,eAAe,UAElD;IAED,KAAK,aAQJ;CACJ"}
@@ -37,6 +37,7 @@ export declare class UnistylesRuntime {
37
37
  get hasAdaptiveThemes(): boolean;
38
38
  get navigationBar(): import("../specs/NavigtionBar").UnistylesNavigationBar;
39
39
  get miniRuntime(): UnistylesMiniRuntime;
40
+ getMiniRuntime: (themeName?: AppThemeName) => UnistylesMiniRuntime;
40
41
  setTheme: (themeName: AppThemeName) => void;
41
42
  setAdaptiveThemes: (isEnabled: boolean) => void;
42
43
  setRootViewBackgroundColor: (color: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGhD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,WAAW,E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kB,GAAI,QAAQ,eAAe,OAazD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,gBAAgB,KAAK,CAAC,MAAM,CAAC,WAqCzE,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,OAAO,GAAG,yBAUrD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,EAAE,MAAM,MAAM,KAAG,OAUvD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,KAAG,OAkB7C,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,CAiB9E,CAAA;AAED,eAAO,MAAM,yBAAyB,GAAI,CAAC,EACvC,SAAS,gBAAgB,EACzB,QAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,oBAAoB,EAAE,CAAC,CAAC,CAAC,kBAgBzD,CAAA"}
@@ -364,6 +364,47 @@ function getReturnStatementsFromBody(node, results = []) {
364
364
  }
365
365
  return results;
366
366
  }
367
+ function countReturnStatements(node) {
368
+ if (t4.isFunction(node) || t4.isClass(node)) {
369
+ return 0;
370
+ }
371
+ if (t4.isReturnStatement(node)) {
372
+ return 1;
373
+ }
374
+ return (t4.VISITOR_KEYS[node.type] ?? []).reduce((count, key) => {
375
+ const child = node[key];
376
+ const children = (Array.isArray(child) ? child : [child]).filter(
377
+ (childNode) => t4.isNode(childNode)
378
+ );
379
+ return count + children.reduce((childCount, childNode) => childCount + countReturnStatements(childNode), 0);
380
+ }, 0);
381
+ }
382
+ function collectReturnedObjects(node, targets, unsupported) {
383
+ if (t4.isObjectExpression(node)) {
384
+ targets.push(node);
385
+ return;
386
+ }
387
+ if (t4.isConditionalExpression(node)) {
388
+ collectReturnedObjects(node.consequent, targets, unsupported);
389
+ collectReturnedObjects(node.alternate, targets, unsupported);
390
+ return;
391
+ }
392
+ if (t4.isLogicalExpression(node)) {
393
+ if (node.operator !== "&&") {
394
+ collectReturnedObjects(node.left, targets, unsupported);
395
+ }
396
+ collectReturnedObjects(node.right, targets, unsupported);
397
+ return;
398
+ }
399
+ if (t4.isTSAsExpression(node) || t4.isTSSatisfiesExpression(node) || t4.isParenthesizedExpression(node)) {
400
+ collectReturnedObjects(node.expression, targets, unsupported);
401
+ return;
402
+ }
403
+ if (t4.isNullLiteral(node) || t4.isBooleanLiteral(node) || t4.isIdentifier(node) && node.name === "undefined") {
404
+ return;
405
+ }
406
+ unsupported.push(node);
407
+ }
367
408
  function isUnistylesStyleSheet(path3, state) {
368
409
  const { callee } = path3.node;
369
410
  if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
@@ -678,42 +719,63 @@ function getStylesDependenciesFromFunction(funcPath) {
678
719
  }, {});
679
720
  }
680
721
  function addDependencies(state, styleName, unistyle, detectedDependencies) {
681
- const debugMessage = (deps) => {
722
+ const debugMessage = (deps, unsupportedReason) => {
682
723
  if (state.opts.debug) {
683
724
  const mappedDeps = deps.map(
684
725
  (dep) => Object.keys(UnistyleDependency).find(
685
726
  (key) => UnistyleDependency[key] === dep
686
727
  )
687
728
  ).join(", ");
688
- console.log(
689
- `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}: [${mappedDeps}]`
690
- );
729
+ const style = `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}`;
730
+ if (unsupportedReason) {
731
+ console.warn(
732
+ `Unistyles \u{1F984}: ${style}: detected [${mappedDeps}], but ${unsupportedReason}. Return an object literal, or a ternary/logical expression of object literals.`
733
+ );
734
+ return;
735
+ }
736
+ console.log(`${style}: [${mappedDeps}]`);
691
737
  }
692
738
  };
693
739
  const styleDependencies = detectedDependencies.map(toUnistylesDependency);
694
740
  if (styleDependencies.length > 0) {
695
741
  const uniqueDependencies = Array.from(new Set(styleDependencies));
696
- debugMessage(uniqueDependencies);
697
- let targets = [];
742
+ const targets = [];
743
+ const unsupported = [];
744
+ let unsupportedReturns = 0;
698
745
  if (t4.isArrowFunctionExpression(unistyle.value) || t4.isFunctionExpression(unistyle.value)) {
699
- if (t4.isObjectExpression(unistyle.value.body)) {
700
- targets.push(unistyle.value.body);
701
- }
702
746
  if (t4.isBlockStatement(unistyle.value.body)) {
703
- targets = getReturnStatementsFromBody(unistyle.value.body).map((node) => {
747
+ const returnStatements = getReturnStatementsFromBody(unistyle.value.body);
748
+ unsupportedReturns = countReturnStatements(unistyle.value.body) - returnStatements.length;
749
+ returnStatements.forEach((node) => {
704
750
  if (t4.isIdentifier(node.argument)) {
705
751
  node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
706
752
  }
707
- return node.argument;
708
- }).filter((node) => t4.isObjectExpression(node));
753
+ if (node.argument) {
754
+ collectReturnedObjects(node.argument, targets, unsupported);
755
+ }
756
+ });
757
+ } else {
758
+ collectReturnedObjects(unistyle.value.body, targets, unsupported);
709
759
  }
710
- }
711
- if (t4.isObjectExpression(unistyle.value)) {
712
- targets.push(unistyle.value);
713
- }
714
- if (t4.isMemberExpression(unistyle.value)) {
760
+ } else if (t4.isMemberExpression(unistyle.value)) {
715
761
  unistyle.value = t4.objectExpression([t4.spreadElement(unistyle.value)]);
716
762
  targets.push(unistyle.value);
763
+ } else {
764
+ collectReturnedObjects(unistyle.value, targets, unsupported);
765
+ }
766
+ if (unsupported.length > 0 || unsupportedReturns > 0) {
767
+ const reasons = unsupported.map((node) => `${node.type}${node.loc ? ` (line ${node.loc.start.line})` : ""}`).concat(
768
+ unsupportedReturns > 0 ? `${unsupportedReturns} return statement(s) inside switch, loop or try blocks` : []
769
+ );
770
+ const consequence = targets.length > 0 ? "the style may not update when these dependencies change, eg. when one of these values is returned first" : "the style won't update when these dependencies change";
771
+ debugMessage(uniqueDependencies, `they can't be attached to: ${reasons.join(", ")}, so ${consequence}`);
772
+ } else if (targets.length === 0) {
773
+ debugMessage(
774
+ uniqueDependencies,
775
+ "no returned object was found to attach them to, so the style won't update when these dependencies change"
776
+ );
777
+ } else {
778
+ debugMessage(uniqueDependencies);
717
779
  }
718
780
  if (targets.length > 0) {
719
781
  targets.forEach((target) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin ./metro ./src/__tests__",
@@ -26,22 +26,22 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "types": "./lib/typescript/src/index.d.ts",
29
- "import": "./lib/module/index.js",
30
29
  "browser": "./lib/module/index.js",
31
30
  "react-native": "./src/index.ts",
31
+ "import": "./lib/module/index.js",
32
32
  "default": "./lib/commonjs/index.js"
33
33
  },
34
34
  "./mocks": {
35
35
  "types": "./lib/typescript/src/mocks.d.ts",
36
- "import": "./lib/module/mocks.js",
37
36
  "browser": "./lib/module/mocks.js",
38
37
  "react-native": "./src/mocks.ts",
38
+ "import": "./lib/module/mocks.js",
39
39
  "default": "./lib/commonjs/mocks.js"
40
40
  },
41
41
  "./components/native/*": {
42
- "import": "./lib/module/components/native/*",
43
42
  "browser": "./lib/module/components/native/*",
44
43
  "react-native": "./src/components/native/*",
44
+ "import": "./lib/module/components/native/*",
45
45
  "default": "./lib/commonjs/components/native/*"
46
46
  },
47
47
  "./plugin": {
@@ -61,30 +61,30 @@
61
61
  "./package.json": "./package.json",
62
62
  "./server": {
63
63
  "types": "./lib/typescript/src/server/index.d.ts",
64
- "import": "./lib/module/server/index.js",
65
64
  "browser": "./lib/module/server/index.js",
66
65
  "react-native": "./src/server/index.ts",
66
+ "import": "./lib/module/server/index.js",
67
67
  "default": "./lib/commonjs/server/index.js"
68
68
  },
69
69
  "./web": {
70
70
  "types": "./lib/typescript/src/web-only/index.d.ts",
71
- "import": "./lib/module/web-only/index.js",
72
71
  "browser": "./lib/module/web-only/index.js",
73
72
  "react-native": "./src/web-only/index.ts",
73
+ "import": "./lib/module/web-only/index.js",
74
74
  "default": "./lib/commonjs/web-only/index.js"
75
75
  },
76
76
  "./reanimated": {
77
77
  "types": "./lib/typescript/src/reanimated/index.d.ts",
78
- "import": "./lib/module/reanimated/index.js",
79
78
  "browser": "./lib/module/reanimated/index.js",
80
79
  "react-native": "./src/reanimated/index.ts",
80
+ "import": "./lib/module/reanimated/index.js",
81
81
  "default": "./lib/commonjs/reanimated/index.js"
82
82
  },
83
83
  "./diagnostics": {
84
84
  "types": "./lib/typescript/src/diagnostics/index.d.ts",
85
- "import": "./lib/module/diagnostics/index.js",
86
85
  "browser": "./lib/module/diagnostics/index.js",
87
86
  "react-native": "./src/diagnostics/index.ts",
87
+ "import": "./lib/module/diagnostics/index.js",
88
88
  "default": "./lib/commonjs/diagnostics/index.js"
89
89
  }
90
90
  },
@@ -154,33 +154,33 @@
154
154
  "@babel/types": "7.29.8"
155
155
  },
156
156
  "devDependencies": {
157
- "@callstack/repack": "5.4.0",
158
- "@commitlint/config-conventional": "21.2.3",
159
- "@react-native/normalize-colors": "0.87.1",
160
- "@rspack/core": "2.2.7",
157
+ "@callstack/repack": "5.4.2",
158
+ "@commitlint/config-conventional": "21.2.4",
159
+ "@react-native/normalize-colors": "0.88.0",
160
+ "@rspack/core": "2.2.9",
161
161
  "@types/jest": "30.0.0",
162
- "@types/react": "19.2.18",
162
+ "@types/react": "19.3.0",
163
163
  "babel-plugin-tester": "12.0.0",
164
- "commitlint": "21.2.3",
165
- "concurrently": "10.0.5",
164
+ "commitlint": "21.2.4",
165
+ "concurrently": "10.0.6",
166
166
  "dpdm": "4.3.0",
167
167
  "esbuild": "0.28.2",
168
168
  "jest": "30.5.2",
169
169
  "@babel/core": "7.29.7",
170
170
  "@babel/plugin-syntax-jsx": "7.29.7",
171
- "@babel/runtime": "7.29.7",
172
- "@react-native/babel-preset": "0.87.1",
173
- "@react-native/jest-preset": "0.87.1",
174
- "@react-native/metro-babel-transformer": "0.87.1",
171
+ "@babel/runtime": "7.29.10",
172
+ "@react-native/babel-preset": "0.88.0",
173
+ "@react-native/jest-preset": "0.88.0",
174
+ "@react-native/metro-babel-transformer": "0.88.0",
175
175
  "nitrogen": "0.37.1",
176
- "oxfmt": "0.70.0",
177
- "oxlint": "1.85.0",
178
- "react": "19.2.3",
179
- "react-native": "0.87.1",
180
- "react-native-builder-bob": "0.43.1",
176
+ "oxfmt": "0.74.0",
177
+ "oxlint": "1.89.0",
178
+ "react": "19.3.0",
179
+ "react-native": "0.88.0",
180
+ "react-native-builder-bob": "0.43.2",
181
181
  "react-native-nitro-modules": "0.37.1",
182
- "react-native-reanimated": "4.7.0",
183
- "react-native-web": "0.21.3",
182
+ "react-native-reanimated": "4.7.1",
183
+ "react-native-web": "0.21.4",
184
184
  "typescript": "6.0.3"
185
185
  },
186
186
  "peerDependencies": {
package/plugin/index.js CHANGED
@@ -355,6 +355,47 @@ function getReturnStatementsFromBody(node, results = []) {
355
355
  }
356
356
  return results;
357
357
  }
358
+ function countReturnStatements(node) {
359
+ if (t4.isFunction(node) || t4.isClass(node)) {
360
+ return 0;
361
+ }
362
+ if (t4.isReturnStatement(node)) {
363
+ return 1;
364
+ }
365
+ return (t4.VISITOR_KEYS[node.type] ?? []).reduce((count, key) => {
366
+ const child = node[key];
367
+ const children = (Array.isArray(child) ? child : [child]).filter(
368
+ (childNode) => t4.isNode(childNode)
369
+ );
370
+ return count + children.reduce((childCount, childNode) => childCount + countReturnStatements(childNode), 0);
371
+ }, 0);
372
+ }
373
+ function collectReturnedObjects(node, targets, unsupported) {
374
+ if (t4.isObjectExpression(node)) {
375
+ targets.push(node);
376
+ return;
377
+ }
378
+ if (t4.isConditionalExpression(node)) {
379
+ collectReturnedObjects(node.consequent, targets, unsupported);
380
+ collectReturnedObjects(node.alternate, targets, unsupported);
381
+ return;
382
+ }
383
+ if (t4.isLogicalExpression(node)) {
384
+ if (node.operator !== "&&") {
385
+ collectReturnedObjects(node.left, targets, unsupported);
386
+ }
387
+ collectReturnedObjects(node.right, targets, unsupported);
388
+ return;
389
+ }
390
+ if (t4.isTSAsExpression(node) || t4.isTSSatisfiesExpression(node) || t4.isParenthesizedExpression(node)) {
391
+ collectReturnedObjects(node.expression, targets, unsupported);
392
+ return;
393
+ }
394
+ if (t4.isNullLiteral(node) || t4.isBooleanLiteral(node) || t4.isIdentifier(node) && node.name === "undefined") {
395
+ return;
396
+ }
397
+ unsupported.push(node);
398
+ }
358
399
  function isUnistylesStyleSheet(path2, state) {
359
400
  const { callee } = path2.node;
360
401
  if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
@@ -669,42 +710,63 @@ function getStylesDependenciesFromFunction(funcPath) {
669
710
  }, {});
670
711
  }
671
712
  function addDependencies(state, styleName, unistyle, detectedDependencies) {
672
- const debugMessage = (deps) => {
713
+ const debugMessage = (deps, unsupportedReason) => {
673
714
  if (state.opts.debug) {
674
715
  const mappedDeps = deps.map(
675
716
  (dep) => Object.keys(UnistyleDependency).find(
676
717
  (key) => UnistyleDependency[key] === dep
677
718
  )
678
719
  ).join(", ");
679
- console.log(
680
- `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}: [${mappedDeps}]`
681
- );
720
+ const style = `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}`;
721
+ if (unsupportedReason) {
722
+ console.warn(
723
+ `Unistyles \u{1F984}: ${style}: detected [${mappedDeps}], but ${unsupportedReason}. Return an object literal, or a ternary/logical expression of object literals.`
724
+ );
725
+ return;
726
+ }
727
+ console.log(`${style}: [${mappedDeps}]`);
682
728
  }
683
729
  };
684
730
  const styleDependencies = detectedDependencies.map(toUnistylesDependency);
685
731
  if (styleDependencies.length > 0) {
686
732
  const uniqueDependencies = Array.from(new Set(styleDependencies));
687
- debugMessage(uniqueDependencies);
688
- let targets = [];
733
+ const targets = [];
734
+ const unsupported = [];
735
+ let unsupportedReturns = 0;
689
736
  if (t4.isArrowFunctionExpression(unistyle.value) || t4.isFunctionExpression(unistyle.value)) {
690
- if (t4.isObjectExpression(unistyle.value.body)) {
691
- targets.push(unistyle.value.body);
692
- }
693
737
  if (t4.isBlockStatement(unistyle.value.body)) {
694
- targets = getReturnStatementsFromBody(unistyle.value.body).map((node) => {
738
+ const returnStatements = getReturnStatementsFromBody(unistyle.value.body);
739
+ unsupportedReturns = countReturnStatements(unistyle.value.body) - returnStatements.length;
740
+ returnStatements.forEach((node) => {
695
741
  if (t4.isIdentifier(node.argument)) {
696
742
  node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
697
743
  }
698
- return node.argument;
699
- }).filter((node) => t4.isObjectExpression(node));
744
+ if (node.argument) {
745
+ collectReturnedObjects(node.argument, targets, unsupported);
746
+ }
747
+ });
748
+ } else {
749
+ collectReturnedObjects(unistyle.value.body, targets, unsupported);
700
750
  }
701
- }
702
- if (t4.isObjectExpression(unistyle.value)) {
703
- targets.push(unistyle.value);
704
- }
705
- if (t4.isMemberExpression(unistyle.value)) {
751
+ } else if (t4.isMemberExpression(unistyle.value)) {
706
752
  unistyle.value = t4.objectExpression([t4.spreadElement(unistyle.value)]);
707
753
  targets.push(unistyle.value);
754
+ } else {
755
+ collectReturnedObjects(unistyle.value, targets, unsupported);
756
+ }
757
+ if (unsupported.length > 0 || unsupportedReturns > 0) {
758
+ const reasons = unsupported.map((node) => `${node.type}${node.loc ? ` (line ${node.loc.start.line})` : ""}`).concat(
759
+ unsupportedReturns > 0 ? `${unsupportedReturns} return statement(s) inside switch, loop or try blocks` : []
760
+ );
761
+ const consequence = targets.length > 0 ? "the style may not update when these dependencies change, eg. when one of these values is returned first" : "the style won't update when these dependencies change";
762
+ debugMessage(uniqueDependencies, `they can't be attached to: ${reasons.join(", ")}, so ${consequence}`);
763
+ } else if (targets.length === 0) {
764
+ debugMessage(
765
+ uniqueDependencies,
766
+ "no returned object was found to attach them to, so the style won't update when these dependencies change"
767
+ );
768
+ } else {
769
+ debugMessage(uniqueDependencies);
708
770
  }
709
771
  if (targets.length > 0) {
710
772
  targets.forEach((target) => {
@@ -17,6 +17,11 @@ interface NamedThemeProps extends PropsWithChildren {
17
17
  export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, children, previousScopedTheme }) => {
18
18
  const scope = useMemo(() => ({ name }), [name])
19
19
 
20
+ useLayoutEffect(() => {
21
+ // this will affect only scoped styles as other styles are not yet mounted
22
+ UnistylesShadowRegistry.flush()
23
+ })
24
+
20
25
  const mappedChildren = [
21
26
  <ApplyScopedTheme key="apply" name={name} />,
22
27
  <ScopedThemeContext.Provider key="scope" value={scope}>
@@ -25,10 +30,5 @@ export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, chi
25
30
  <ApplyScopedTheme key="dispose" name={previousScopedTheme as keyof UnistylesThemes | undefined} />,
26
31
  ]
27
32
 
28
- useLayoutEffect(() => {
29
- // this will affect only scoped styles as other styles are not yet mounted
30
- UnistylesShadowRegistry.flush()
31
- })
32
-
33
33
  return <React.Fragment>{mappedChildren}</React.Fragment>
34
34
  }
@@ -1,4 +1,4 @@
1
- import { createContext } from 'react'
1
+ import { type Context, createContext } from 'react'
2
2
 
3
3
  import type { UnistylesThemes } from '../global'
4
4
 
@@ -6,4 +6,8 @@ export type Scope = {
6
6
  name: keyof UnistylesThemes | undefined
7
7
  }
8
8
 
9
- export const ScopedThemeContext = createContext<Scope | null>(null)
9
+ // React Server Components load a React build without createContext (or useContext). The Next.js App Router
10
+ // setup imports Unistyles from the root layout, a server component, and nothing can read this context there.
11
+ export const ScopedThemeContext = (
12
+ typeof createContext === 'function' ? createContext<Scope | null>(null) : null
13
+ ) as Context<Scope | null>
@@ -10,7 +10,11 @@ import { passForwardedRef } from './passForwardRef'
10
10
  import { maybeWarnAboutMultipleUnistyles } from './warn'
11
11
 
12
12
  export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
13
- const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
13
+ const UnistylesImageBackground = ({
14
+ ref,
15
+ ...props
16
+ }: ImageBackgroundProps & { ref?: React.ForwardedRef<ImageBackground> }) => {
17
+ const forwardedRef: React.ForwardedRef<ImageBackground> = ref ?? null
14
18
  const scope = useContext(ScopedThemeContext)
15
19
 
16
20
  // @ts-expect-error we don't know the type of the component
@@ -49,7 +53,7 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
49
53
  imageRef={hasUnistyles(props.imageStyle) ? linkImageRef : props.imageRef}
50
54
  />
51
55
  )
52
- })
56
+ }
53
57
 
54
58
  return copyComponentProperties(Component, UnistylesImageBackground)
55
59
  }