react-native-unistyles 3.0.0-alpha.20 → 3.0.0-alpha.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/cxx/common/Constants.h +1 -0
  2. package/cxx/core/UnistyleWrapper.h +21 -41
  3. package/cxx/hybridObjects/HybridStyleSheet.cpp +1 -1
  4. package/cxx/hybridObjects/HybridStyleSheet.h +1 -1
  5. package/lib/commonjs/web/convert/boxShadow.js +13 -13
  6. package/lib/commonjs/web/convert/boxShadow.js.map +1 -1
  7. package/lib/commonjs/web/convert/index.js +9 -11
  8. package/lib/commonjs/web/convert/index.js.map +1 -1
  9. package/lib/commonjs/web/convert/pseudo.js.map +1 -0
  10. package/lib/commonjs/web/convert/style.js +11 -7
  11. package/lib/commonjs/web/convert/style.js.map +1 -1
  12. package/lib/commonjs/web/convert/textShadow.js +12 -12
  13. package/lib/commonjs/web/convert/textShadow.js.map +1 -1
  14. package/lib/commonjs/web/convert/transform.js +5 -5
  15. package/lib/commonjs/web/convert/transform.js.map +1 -1
  16. package/lib/commonjs/web/{listener/listener.js → listener.js} +2 -2
  17. package/lib/commonjs/web/listener.js.map +1 -0
  18. package/lib/commonjs/web/mq.js.map +1 -1
  19. package/lib/commonjs/web/registry.js +159 -21
  20. package/lib/commonjs/web/registry.js.map +1 -1
  21. package/lib/commonjs/web/shadowRegistry.js +50 -48
  22. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  23. package/lib/commonjs/web/state.js +8 -16
  24. package/lib/commonjs/web/state.js.map +1 -1
  25. package/lib/commonjs/web/{utils.js → utils/common.js} +9 -47
  26. package/lib/commonjs/web/utils/common.js.map +1 -0
  27. package/lib/commonjs/web/utils/index.js +28 -0
  28. package/lib/commonjs/web/utils/index.js.map +1 -0
  29. package/lib/commonjs/web/utils/unistyle.js +82 -0
  30. package/lib/commonjs/web/utils/unistyle.js.map +1 -0
  31. package/lib/module/web/convert/boxShadow.js +13 -13
  32. package/lib/module/web/convert/boxShadow.js.map +1 -1
  33. package/lib/module/web/convert/index.js +7 -9
  34. package/lib/module/web/convert/index.js.map +1 -1
  35. package/lib/module/web/convert/pseudo.js.map +1 -0
  36. package/lib/module/web/convert/style.js +11 -7
  37. package/lib/module/web/convert/style.js.map +1 -1
  38. package/lib/module/web/convert/textShadow.js +12 -12
  39. package/lib/module/web/convert/textShadow.js.map +1 -1
  40. package/lib/module/web/convert/transform.js +5 -5
  41. package/lib/module/web/convert/transform.js.map +1 -1
  42. package/lib/module/web/{listener/listener.js → listener.js} +2 -2
  43. package/lib/module/web/listener.js.map +1 -0
  44. package/lib/module/web/mq.js.map +1 -1
  45. package/lib/module/web/registry.js +160 -22
  46. package/lib/module/web/registry.js.map +1 -1
  47. package/lib/module/web/shadowRegistry.js +51 -49
  48. package/lib/module/web/shadowRegistry.js.map +1 -1
  49. package/lib/module/web/state.js +8 -16
  50. package/lib/module/web/state.js.map +1 -1
  51. package/lib/module/web/{utils.js → utils/common.js} +7 -39
  52. package/lib/module/web/utils/common.js.map +1 -0
  53. package/lib/module/web/utils/index.js +5 -0
  54. package/lib/module/web/utils/index.js.map +1 -0
  55. package/lib/module/web/utils/unistyle.js +69 -0
  56. package/lib/module/web/utils/unistyle.js.map +1 -0
  57. package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts +3 -0
  58. package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts.map +1 -0
  59. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts +3 -0
  60. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts.map +1 -0
  61. package/lib/typescript/expo-example/app/(tabs)/index.d.ts +3 -0
  62. package/lib/typescript/expo-example/app/(tabs)/index.d.ts.map +1 -0
  63. package/lib/typescript/expo-example/app/+html.d.ts +4 -0
  64. package/lib/typescript/expo-example/app/+html.d.ts.map +1 -0
  65. package/lib/typescript/expo-example/app/+not-found.d.ts +3 -0
  66. package/lib/typescript/expo-example/app/+not-found.d.ts.map +1 -0
  67. package/lib/typescript/expo-example/app/_layout.d.ts +3 -0
  68. package/lib/typescript/expo-example/app/_layout.d.ts.map +1 -0
  69. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
  70. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  71. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  72. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  73. package/lib/typescript/src/web/convert/boxShadow.d.ts +7 -2
  74. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -1
  75. package/lib/typescript/src/web/convert/index.d.ts +1 -2
  76. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  77. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
  78. package/lib/typescript/src/web/convert/style.d.ts +1 -2
  79. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  80. package/lib/typescript/src/web/convert/textShadow.d.ts +7 -2
  81. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -1
  82. package/lib/typescript/src/web/convert/transform.d.ts +1 -2
  83. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -1
  84. package/lib/typescript/src/web/{listener/listener.d.ts → listener.d.ts} +1 -1
  85. package/lib/typescript/src/web/listener.d.ts.map +1 -0
  86. package/lib/typescript/src/web/mq.d.ts +6 -2
  87. package/lib/typescript/src/web/mq.d.ts.map +1 -1
  88. package/lib/typescript/src/web/registry.d.ts +21 -8
  89. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  90. package/lib/typescript/src/web/shadowRegistry.d.ts +3 -4
  91. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  92. package/lib/typescript/src/web/state.d.ts +2 -2
  93. package/lib/typescript/src/web/state.d.ts.map +1 -1
  94. package/lib/typescript/src/web/{utils.d.ts → utils/common.d.ts} +2 -20
  95. package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
  96. package/lib/typescript/src/web/utils/index.d.ts +3 -0
  97. package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
  98. package/lib/typescript/src/web/utils/unistyle.d.ts +20 -0
  99. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
  100. package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
  101. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +8 -8
  102. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +22 -22
  103. package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
  104. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +2 -2
  106. package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +2 -2
  107. package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
  108. package/nitrogen/generated/ios/Unistyles+autolinking.rb +5 -3
  109. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
  110. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +32 -32
  111. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -29
  112. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +0 -12
  113. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +134 -110
  114. package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
  115. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  116. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  117. package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
  118. package/package.json +4 -15
  119. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
  120. package/src/types/stylesheet.ts +1 -1
  121. package/src/web/convert/boxShadow.ts +14 -15
  122. package/src/web/convert/index.ts +6 -13
  123. package/src/web/convert/style.ts +61 -10
  124. package/src/web/convert/textShadow.ts +13 -14
  125. package/src/web/convert/transform.ts +7 -8
  126. package/src/web/{listener/listener.ts → listener.ts} +2 -2
  127. package/src/web/mq.ts +1 -3
  128. package/src/web/registry.ts +202 -23
  129. package/src/web/shadowRegistry.ts +49 -49
  130. package/src/web/state.ts +13 -23
  131. package/src/web/{utils.ts → utils/common.ts} +6 -68
  132. package/src/web/utils/index.ts +2 -0
  133. package/src/web/utils/unistyle.ts +104 -0
  134. package/lib/commonjs/web/convert/breakpoint.js +0 -25
  135. package/lib/commonjs/web/convert/breakpoint.js.map +0 -1
  136. package/lib/commonjs/web/createUnistylesComponent.js +0 -61
  137. package/lib/commonjs/web/createUnistylesComponent.js.map +0 -1
  138. package/lib/commonjs/web/listener/index.js +0 -20
  139. package/lib/commonjs/web/listener/index.js.map +0 -1
  140. package/lib/commonjs/web/listener/listenToDependencies.js +0 -38
  141. package/lib/commonjs/web/listener/listenToDependencies.js.map +0 -1
  142. package/lib/commonjs/web/listener/listener.js.map +0 -1
  143. package/lib/commonjs/web/pseudo.js.map +0 -1
  144. package/lib/commonjs/web/utils.js.map +0 -1
  145. package/lib/module/web/convert/breakpoint.js +0 -20
  146. package/lib/module/web/convert/breakpoint.js.map +0 -1
  147. package/lib/module/web/createUnistylesComponent.js +0 -54
  148. package/lib/module/web/createUnistylesComponent.js.map +0 -1
  149. package/lib/module/web/listener/index.js +0 -5
  150. package/lib/module/web/listener/index.js.map +0 -1
  151. package/lib/module/web/listener/listenToDependencies.js +0 -33
  152. package/lib/module/web/listener/listenToDependencies.js.map +0 -1
  153. package/lib/module/web/listener/listener.js.map +0 -1
  154. package/lib/module/web/pseudo.js.map +0 -1
  155. package/lib/module/web/utils.js.map +0 -1
  156. package/lib/typescript/src/web/convert/breakpoint.d.ts +0 -3
  157. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +0 -1
  158. package/lib/typescript/src/web/createUnistylesComponent.d.ts +0 -3
  159. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +0 -1
  160. package/lib/typescript/src/web/listener/index.d.ts +0 -3
  161. package/lib/typescript/src/web/listener/index.d.ts.map +0 -1
  162. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +0 -12
  163. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +0 -1
  164. package/lib/typescript/src/web/listener/listener.d.ts.map +0 -1
  165. package/lib/typescript/src/web/pseudo.d.ts.map +0 -1
  166. package/lib/typescript/src/web/utils.d.ts.map +0 -1
  167. package/src/web/convert/breakpoint.ts +0 -21
  168. package/src/web/createUnistylesComponent.tsx +0 -54
  169. package/src/web/listener/index.ts +0 -2
  170. package/src/web/listener/listenToDependencies.ts +0 -45
  171. /package/lib/commonjs/web/{pseudo.js → convert/pseudo.js} +0 -0
  172. /package/lib/module/web/{pseudo.js → convert/pseudo.js} +0 -0
  173. /package/lib/typescript/src/web/{pseudo.d.ts → convert/pseudo.d.ts} +0 -0
  174. /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesOnLoad.kt} +0 -0
  175. /package/src/web/{pseudo.ts → convert/pseudo.ts} +0 -0
@@ -1,3 +1,8 @@
1
- import type { NestedCSSProperties } from 'typestyle/lib/types';
2
- export declare const getTextShadowStyle: (styles: Record<string, any>) => NestedCSSProperties;
1
+ export declare const getTextShadowStyle: (styles: Record<string, any>) => {
2
+ [x: string]: {
3
+ textShadow: string;
4
+ };
5
+ } | {
6
+ textShadow: string;
7
+ };
3
8
  //# sourceMappingURL=textShadow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"textShadow.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/textShadow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAiB9D,eAAO,MAAM,kBAAkB,WAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,mBAkDhE,CAAA"}
1
+ {"version":3,"file":"textShadow.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/textShadow.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,kBAAkB,WAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;CAoD7D,CAAA"}
@@ -1,5 +1,4 @@
1
- import type { NestedCSSProperties } from 'typestyle/lib/types';
2
1
  type Transforms = Array<Record<string, any>>;
3
- export declare const getTransformStyle: (transforms: Transforms) => NestedCSSProperties;
2
+ export declare const getTransformStyle: (transforms: Transforms) => Record<string, any>;
4
3
  export {};
5
4
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK9D,KAAK,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAmC5C,eAAO,MAAM,iBAAiB,eAAgB,UAAU,KAAG,mBA+C1D,CAAA"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/transform.ts"],"names":[],"mappings":"AAGA,KAAK,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAmC5C,eAAO,MAAM,iBAAiB,eAAgB,UAAU,wBAiDvD,CAAA"}
@@ -1,4 +1,4 @@
1
- import { UnistyleDependency } from '../../specs/NativePlatform';
1
+ import { UnistyleDependency } from '../specs/NativePlatform';
2
2
  declare class UnistylesListenerBuilder {
3
3
  private isInitialized;
4
4
  private listeners;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,cAAM,wBAAwB;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IAErH,UAAU,eAAgB,kBAAkB,UAE3C;IAED,aAAa,aAUZ;IAED,YAAY,iBAAkB,KAAK,CAAC,kBAAkB,CAAC,YAAY,YAAY,gBAM9E;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
@@ -1,4 +1,8 @@
1
- import type { MediaQuery } from 'typestyle/lib/types';
2
- export declare const parseMq: (mq: string) => MediaQuery;
1
+ export declare const parseMq: (mq: string) => {
2
+ minWidth: number | undefined;
3
+ maxWidth: number | undefined;
4
+ minHeight: number | undefined;
5
+ maxHeight: number | undefined;
6
+ };
3
7
  export declare const isUnistylesMq: (mq: string) => boolean;
4
8
  //# sourceMappingURL=mq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/web/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAMrD,eAAO,MAAM,OAAO,OAAQ,MAAM,KAAG,UAUpC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA"}
1
+ {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/web/mq.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,OAAQ,MAAM;;;;;CAUjC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA"}
@@ -1,14 +1,27 @@
1
- import { TypeStyle } from 'typestyle';
2
- import type { UnistylesValues } from '../types';
1
+ import type { UnistylesTheme, UnistylesValues } from '../types';
3
2
  import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet';
3
+ import type { UnistyleDependency } from '../specs/NativePlatform';
4
+ import type { UnistylesMiniRuntime } from '../specs';
5
+ type AddProps = {
6
+ value: UnistylesValues;
7
+ stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
8
+ key: string;
9
+ args: Array<any>;
10
+ variants: Record<string, any>;
11
+ };
4
12
  declare class UnistylesRegistryBuilder {
5
- private stylesheets;
13
+ #private;
14
+ private readonly stylesheets;
15
+ private readonly stylesCounter;
16
+ private readonly disposeListenersMap;
17
+ private readonly dependenciesMap;
18
+ private get styleTag();
6
19
  getComputedStylesheet: (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => StyleSheet;
7
- createStyles: (stylesheet: UnistylesValues, key: string) => {
8
- className: string;
9
- unistyles: TypeStyle;
10
- };
11
- updateStyles: (unistyles: TypeStyle, stylesheet: UnistylesValues, className: string) => void;
20
+ addDependenciesToStylesheet: (stylesheet: (theme: UnistylesTheme, miniRuntime: UnistylesMiniRuntime) => StyleSheet, dependencies: Array<UnistyleDependency>) => void;
21
+ add: ({ key, value, stylesheet, args, variants }: AddProps) => string;
22
+ private applyStyles;
23
+ private applyRule;
24
+ remove: (value: UnistylesValues) => void;
12
25
  }
13
26
  export declare const UnistylesRegistry: UnistylesRegistryBuilder;
14
27
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,cAAM,wBAAwB;IAC1B,OAAO,CAAC,WAAW,CAA+D;IAElF,qBAAqB,eAAgB,yBAAyB,CAAC,UAAU,CAAC,gBAwBzE;IAED,YAAY,eAAgB,eAAe,OAAO,MAAM;;;MAYvD;IAED,YAAY,cAAe,SAAS,cAAc,eAAe,aAAa,MAAM,UAKnF;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAGpD,KAAK,QAAQ,GAAG;IACZ,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA;AAWD,cAAM,wBAAwB;;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+D;IAC3F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAExE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAE5G,OAAO,KAAK,QAAQ,GAcnB;IAED,qBAAqB,eAAgB,yBAAyB,CAAC,UAAU,CAAC,gBAkBzE;IAED,2BAA2B,eAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,KAAK,UAAU,gBAAgB,KAAK,CAAC,kBAAkB,CAAC,UAe3J;IAED,GAAG,+CAAgD,QAAQ,YAoC1D;IAED,OAAO,CAAC,WAAW,CAwElB;IAED,OAAO,CAAC,SAAS,CAmBhB;IAED,MAAM,UAAW,eAAe,UAe/B;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
@@ -6,11 +6,10 @@ declare class UnistylesShadowRegistryBuilder {
6
6
  equals: () => boolean;
7
7
  toString: () => string;
8
8
  dispose: () => void;
9
- private readonly webUnistylesMap;
10
- private readonly disposeMap;
11
- private readonly stylesMap;
9
+ private resultsMap;
10
+ private classNamesMap;
12
11
  add: (ref: any, _style?: Style | Array<Style>, _variants?: Record<string, any>, _args?: Array<any>) => void;
13
- remove: (ref: HTMLElement, style: Style) => void;
12
+ remove: () => void;
14
13
  }
15
14
  export declare const UnistylesShadowRegistry: UnistylesShadowRegistryBuilder;
16
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAQ/C,KAAK,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,CAAA;AAEzE,cAAM,8BAA8B;IAEhC,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsD;IACtF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmE;IAC9F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2D;IAErF,GAAG,QAAS,GAAG,WAAW,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,UAuFlG;IAED,MAAM,QAAS,WAAW,SAAS,KAAK,UAQvC;CACJ;AAED,eAAO,MAAM,uBAAuB,gCAAuC,CAAA"}
1
+ {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAK/C,KAAK,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,CAAA;AAEzE,cAAM,8BAA8B;IAEhC,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,UAAU,CAA0D;IAC5E,OAAO,CAAC,aAAa,CAAwD;IAE7E,GAAG,QAAS,GAAG,WAAW,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,UAmGlG;IAED,MAAM,aAAW;CACpB;AAED,eAAO,MAAM,uBAAuB,gCAAuC,CAAA"}
@@ -3,10 +3,10 @@ import type { UnistylesConfig } from '../specs/StyleSheet';
3
3
  import type { AppBreakpoint, AppThemeName } from '../specs/types';
4
4
  import type { UnistylesBreakpoints } from '../global';
5
5
  declare class UnistylesStateBuilder {
6
- private readonly isSSR;
7
6
  themes: Map<string, UnistylesTheme>;
8
7
  themeName?: AppThemeName;
9
- breakpoint?: AppBreakpoint;
8
+ private matchingBreakpoints;
9
+ get breakpoint(): AppBreakpoint | undefined;
10
10
  breakpoints?: UnistylesBreakpoints;
11
11
  hasAdaptiveThemes: boolean;
12
12
  init: (config: UnistylesConfig) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAMtE,cAAM,qBAAqB;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAEnC,MAAM,8BAAoC;IAC1C,SAAS,CAAC,EAAE,YAAY,CAAA;IAExB,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;IAEzB,IAAI,WAAY,eAAe,UAU9B;IAED,OAAO,CAAC,UAAU,CAIjB;IAED,OAAO,CAAC,YAAY,CAyBnB;IAED,OAAO,CAAC,eAAe,CAmCtB;CACJ;AAED,eAAO,MAAM,cAAc,uBAA8B,CAAA"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAMtE,cAAM,qBAAqB;IACvB,MAAM,8BAAoC;IAC1C,SAAS,CAAC,EAAE,YAAY,CAAA;IAExB,OAAO,CAAC,mBAAmB,CAA6B;IAExD,IAAI,UAAU,IAKkB,aAAa,GAAG,SAAS,CACxD;IAED,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;IAEzB,IAAI,WAAY,eAAe,UAU9B;IAED,OAAO,CAAC,UAAU,CAIjB;IAED,OAAO,CAAC,YAAY,CAyBnB;IAED,OAAO,CAAC,eAAe,CAkBtB;CACJ;AAED,eAAO,MAAM,cAAc,uBAA8B,CAAA"}
@@ -1,9 +1,5 @@
1
- import { ColorScheme, type AppThemeName } from '../specs/types';
2
- import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../types/stylesheet';
3
1
  export declare const reduceObject: <TObj extends Record<string, any>, TReducer>(obj: TObj, reducer: (value: TObj[keyof TObj], key: keyof TObj) => TReducer) => { [K in keyof TObj]: TReducer; };
4
2
  export declare const keyInObject: <T extends Record<string, any>>(obj: T, key: PropertyKey) => key is keyof T;
5
- export declare const schemeToTheme: (scheme: ColorScheme) => AppThemeName;
6
- export declare const hexToRGBA: (hex: string, opacity: number) => string;
7
3
  export declare const isServer: () => boolean;
8
4
  /**
9
5
  * Deeply merges properties of passed object
@@ -11,25 +7,11 @@ export declare const isServer: () => boolean;
11
7
  export declare const deepMergeObjects: <T extends Record<PropertyKey, any>>(...sources: Array<T>) => T;
12
8
  export declare const warn: (message: string) => void;
13
9
  export declare const equal: <T>(a: T, b: T) => boolean;
14
- type UnistyleSecrets = {
15
- __uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
16
- __uni__key: string;
17
- __uni__refs: Set<HTMLElement>;
18
- __uni__variants: Record<string, any>;
19
- __uni__args?: Array<any>;
20
- };
21
- export declare const assignSecrets: <T>(object: T, secrets: UnistyleSecrets) => T;
22
- export declare const extractSecrets: (object: any) => UnistyleSecrets[];
23
- export declare const getStyles: (values: UnistylesValues) => {};
10
+ export declare const generateHash: (value: any) => string;
24
11
  export declare const createDoubleMap: <TKey, TSecondKey, TValue>() => {
25
12
  get: (key: TKey, secondKey: TSecondKey) => TValue | undefined;
26
13
  set: (key: TKey, secondKey: TSecondKey, value: TValue) => void;
27
14
  delete: (key: TKey, secondKey: TSecondKey) => void;
28
15
  forEach: (callback: (key: TKey, secondKey: TSecondKey, value: TValue) => void) => void;
29
16
  };
30
- export declare const extractHiddenProperties: (object: any) => {
31
- [k: string]: any;
32
- };
33
- export declare const isInDocument: (element: HTMLElement) => boolean;
34
- export {};
35
- //# sourceMappingURL=utils.d.ts.map
17
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,OAC9D,IAAI,WACA,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,IAAI,KAAK,QAAQ,KACmD,GAAG,CAAe,IAAV,MAAM,IAAI,GAAG,QAAQ,GAAE,CAAA;AAErJ,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,WAAW,KAAG,GAAG,IAAI,MAAM,CAAe,CAAA;AAElH,eAAO,MAAM,QAAQ,eAAsC,CAAA;AAE3D;;EAEE;AACF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,MAqBxF,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAA2D,CAAA;AAE/F,eAAO,MAAM,KAAK,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAqBlC,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,GAAG,WAQtC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,EAAE,UAAU,EAAE,MAAM;eAIrC,IAAI,aAAa,UAAU;eAS3B,IAAI,aAAa,UAAU,SAAS,MAAM;kBAMvC,IAAI,aAAa,UAAU;wBASrB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;CAQpF,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './common';
2
+ export * from './unistyle';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { UnistyleDependency } from '../../specs/NativePlatform';
2
+ import { ColorScheme, type AppThemeName } from '../../specs/types';
3
+ import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet';
4
+ export declare const schemeToTheme: (scheme: ColorScheme) => AppThemeName;
5
+ export declare const hexToRGBA: (hex: string, opacity: number) => string;
6
+ export type UnistyleSecrets = {
7
+ __uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
8
+ __uni__key: string;
9
+ __uni__refs: Set<HTMLElement>;
10
+ __uni__variants: Record<string, any>;
11
+ __uni__args?: Array<any>;
12
+ };
13
+ export declare const assignSecrets: <T>(object: T, secrets: UnistyleSecrets) => T;
14
+ export declare const extractSecrets: (object: any) => UnistyleSecrets[];
15
+ export declare const getStyles: (values: UnistylesValues) => {};
16
+ export declare const isInDocument: (element: HTMLElement) => boolean;
17
+ export declare const extractMediaQueryValue: (query: string) => number | undefined;
18
+ export declare const getMediaQuery: (query: string) => string;
19
+ export declare const extractUnistyleDependencies: (value: any) => UnistyleDependency[];
20
+ //# sourceMappingURL=unistyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,KAAG,YAQnD,CAAA;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,WAAW,MAAM,WAM5B,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAUnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAIrD,CAAA"}
@@ -53,7 +53,7 @@ namespace margelo::nitro::unistyles {
53
53
  return clazz->getStaticFieldValue(fieldUNSPECIFIED);
54
54
  default:
55
55
  std::string stringValue = std::to_string(static_cast<int>(value));
56
- throw std::runtime_error("Invalid enum value (" + stringValue + "!");
56
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
57
57
  }
58
58
  }
59
59
  };
@@ -30,16 +30,16 @@ namespace margelo::nitro::unistyles {
30
30
  }
31
31
 
32
32
  public:
33
- void call(const jni::alias_ref<jni::JArrayClass<JUnistyleDependency>>& dependencies) {
33
+ void call(jni::alias_ref<jni::JArrayClass<JUnistyleDependency>> dependencies) {
34
34
  return _func([&]() {
35
- size_t size = dependencies->size();
36
- std::vector<UnistyleDependency> vector;
37
- vector.reserve(size);
38
- for (size_t i = 0; i < size; i++) {
39
- auto element = dependencies->getElement(i);
40
- vector.push_back(element->toCpp());
35
+ size_t __size = dependencies->size();
36
+ std::vector<UnistyleDependency> __vector;
37
+ __vector.reserve(__size);
38
+ for (size_t __i = 0; __i < __size; __i++) {
39
+ auto __element = dependencies->getElement(__i);
40
+ __vector.push_back(__element->toCpp());
41
41
  }
42
- return vector;
42
+ return __vector;
43
43
  }());
44
44
  }
45
45
 
@@ -60,53 +60,53 @@ namespace margelo::nitro::unistyles {
60
60
  // Methods
61
61
  Insets JHybridNativePlatformSpec::getInsets() {
62
62
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JInsets>()>("getInsets");
63
- auto result = method(_javaPart);
64
- return result->toCpp();
63
+ auto __result = method(_javaPart);
64
+ return __result->toCpp();
65
65
  }
66
66
  ColorScheme JHybridNativePlatformSpec::getColorScheme() {
67
67
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JColorScheme>()>("getColorScheme");
68
- auto result = method(_javaPart);
69
- return result->toCpp();
68
+ auto __result = method(_javaPart);
69
+ return __result->toCpp();
70
70
  }
71
71
  double JHybridNativePlatformSpec::getFontScale() {
72
72
  static const auto method = _javaPart->getClass()->getMethod<double()>("getFontScale");
73
- auto result = method(_javaPart);
74
- return result;
73
+ auto __result = method(_javaPart);
74
+ return __result;
75
75
  }
76
76
  double JHybridNativePlatformSpec::getPixelRatio() {
77
77
  static const auto method = _javaPart->getClass()->getMethod<double()>("getPixelRatio");
78
- auto result = method(_javaPart);
79
- return result;
78
+ auto __result = method(_javaPart);
79
+ return __result;
80
80
  }
81
81
  Orientation JHybridNativePlatformSpec::getOrientation() {
82
82
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JOrientation>()>("getOrientation");
83
- auto result = method(_javaPart);
84
- return result->toCpp();
83
+ auto __result = method(_javaPart);
84
+ return __result->toCpp();
85
85
  }
86
86
  std::string JHybridNativePlatformSpec::getContentSizeCategory() {
87
87
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<jni::JString>()>("getContentSizeCategory");
88
- auto result = method(_javaPart);
89
- return result->toStdString();
88
+ auto __result = method(_javaPart);
89
+ return __result->toStdString();
90
90
  }
91
91
  Dimensions JHybridNativePlatformSpec::getScreenDimensions() {
92
92
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JDimensions>()>("getScreenDimensions");
93
- auto result = method(_javaPart);
94
- return result->toCpp();
93
+ auto __result = method(_javaPart);
94
+ return __result->toCpp();
95
95
  }
96
96
  Dimensions JHybridNativePlatformSpec::getStatusBarDimensions() {
97
97
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JDimensions>()>("getStatusBarDimensions");
98
- auto result = method(_javaPart);
99
- return result->toCpp();
98
+ auto __result = method(_javaPart);
99
+ return __result->toCpp();
100
100
  }
101
101
  Dimensions JHybridNativePlatformSpec::getNavigationBarDimensions() {
102
102
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JDimensions>()>("getNavigationBarDimensions");
103
- auto result = method(_javaPart);
104
- return result->toCpp();
103
+ auto __result = method(_javaPart);
104
+ return __result->toCpp();
105
105
  }
106
106
  bool JHybridNativePlatformSpec::getPrefersRtlDirection() {
107
107
  static const auto method = _javaPart->getClass()->getMethod<jboolean()>("getPrefersRtlDirection");
108
- auto result = method(_javaPart);
109
- return result;
108
+ auto __result = method(_javaPart);
109
+ return __result;
110
110
  }
111
111
  void JHybridNativePlatformSpec::setRootViewBackgroundColor(double color) {
112
112
  static const auto method = _javaPart->getClass()->getMethod<void(double /* color */)>("setRootViewBackgroundColor");
@@ -134,8 +134,8 @@ namespace margelo::nitro::unistyles {
134
134
  }
135
135
  UnistylesNativeMiniRuntime JHybridNativePlatformSpec::getMiniRuntime() {
136
136
  static const auto method = _javaPart->getClass()->getMethod<jni::local_ref<JUnistylesNativeMiniRuntime>()>("getMiniRuntime");
137
- auto result = method(_javaPart);
138
- return result->toCpp();
137
+ auto __result = method(_javaPart);
138
+ return __result->toCpp();
139
139
  }
140
140
  void JHybridNativePlatformSpec::registerPlatformListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& callback) {
141
141
  static const auto method = _javaPart->getClass()->getMethod<void(jni::alias_ref<JFunc_void_std__vector_UnistyleDependency_::javaobject> /* callback */)>("registerPlatformListener");
@@ -50,7 +50,7 @@ namespace margelo::nitro::unistyles {
50
50
  return clazz->getStaticFieldValue(fieldLANDSCAPE);
51
51
  default:
52
52
  std::string stringValue = std::to_string(static_cast<int>(value));
53
- throw std::runtime_error("Invalid enum value (" + stringValue + "!");
53
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
54
54
  }
55
55
  }
56
56
  };
@@ -86,7 +86,7 @@ namespace margelo::nitro::unistyles {
86
86
  return clazz->getStaticFieldValue(fieldNAVIGATIONBAR);
87
87
  default:
88
88
  std::string stringValue = std::to_string(static_cast<int>(value));
89
- throw std::runtime_error("Invalid enum value (" + stringValue + "!");
89
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
90
90
  }
91
91
  }
92
92
  };
@@ -116,8 +116,8 @@ abstract class HybridNativePlatformSpec: HybridObject() {
116
116
  @DoNotStrip
117
117
  @Keep
118
118
  private fun registerPlatformListener(callback: Func_void_std__vector_UnistyleDependency_): Unit {
119
- val result = registerPlatformListener(callback.toLambda())
120
- return result
119
+ val __result = registerPlatformListener(callback.toLambda())
120
+ return __result
121
121
  }
122
122
 
123
123
  private external fun initHybrid(): HybridData
@@ -1,11 +1,11 @@
1
1
  ///
2
- /// UnistylesOnLoad.cpp
2
+ /// unistylesOnLoad.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2024 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
- #include "UnistylesOnLoad.hpp"
8
+ #include "unistylesOnLoad.hpp"
9
9
 
10
10
  #include <jni.h>
11
11
  #include <fbjni/fbjni.h>
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// UnistylesOnLoad.hpp
2
+ /// unistylesOnLoad.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2024 Marc Rousavy @ Margelo
@@ -24,7 +24,7 @@ def add_nitrogen_files(spec)
24
24
 
25
25
  spec.dependency "NitroModules"
26
26
 
27
- current_source_files = spec.attributes_hash['source_files'] || []
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
28
  spec.source_files = current_source_files + [
29
29
  # Generated cross-platform specs
30
30
  "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
@@ -32,7 +32,7 @@ def add_nitrogen_files(spec)
32
32
  "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
33
  ]
34
34
 
35
- current_public_header_files = spec.attributes_hash['public_header_files'] || []
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
36
  spec.public_header_files = current_public_header_files + [
37
37
  # Generated specs
38
38
  "nitrogen/generated/shared/**/*.{h,hpp}",
@@ -40,7 +40,7 @@ def add_nitrogen_files(spec)
40
40
  "nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp"
41
41
  ]
42
42
 
43
- current_private_header_files = spec.attributes_hash['private_header_files'] || []
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
44
  spec.private_header_files = current_private_header_files + [
45
45
  # iOS specific specs
46
46
  "nitrogen/generated/ios/c++/**/*.{h,hpp}",
@@ -52,5 +52,7 @@ def add_nitrogen_files(spec)
52
52
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
53
53
  # Enables C++ <-> Swift interop (by default it's only C)
54
54
  "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
55
+ # Enables stricter modular headers
56
+ "DEFINES_MODULE" => "YES",
55
57
  })
56
58
  end
@@ -6,3 +6,28 @@
6
6
  ///
7
7
 
8
8
  #include "Unistyles-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridNativePlatformSpecSwift.hpp"
12
+ #include "Unistyles-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/HybridContext.hpp>
14
+
15
+ namespace margelo::nitro::unistyles::bridge::swift {
16
+
17
+ // pragma MARK: std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>
18
+ std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec> create_std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_(void* _Nonnull swiftUnsafePointer) {
19
+ Unistyles::HybridNativePlatformSpecCxx swiftPart = Unistyles::HybridNativePlatformSpecCxxUnsafe::fromUnsafe(swiftUnsafePointer);
20
+ return HybridContext::getOrCreate<margelo::nitro::unistyles::HybridNativePlatformSpecSwift>(swiftPart);
21
+ }
22
+ void* _Nonnull get_std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_(std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_ cppType) {
23
+ std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::unistyles::HybridNativePlatformSpecSwift>(cppType);
24
+ #ifdef NITRO_DEBUG
25
+ if (swiftWrapper == nullptr) [[unlikely]] {
26
+ throw std::runtime_error("Class \"HybridNativePlatformSpec\" is not implemented in Swift!");
27
+ }
28
+ #endif
29
+ Unistyles::HybridNativePlatformSpecCxx swiftPart = swiftWrapper->getSwiftPart();
30
+ return Unistyles::HybridNativePlatformSpecCxxUnsafe::toUnsafe(swiftPart);
31
+ }
32
+
33
+ } // namespace margelo::nitro::unistyles::bridge::swift
@@ -7,29 +7,28 @@
7
7
 
8
8
  #pragma once
9
9
 
10
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
10
16
  // Forward declarations of C++ defined types
17
+ // Forward declaration of `HybridNativePlatformSpec` to properly resolve imports.
18
+ namespace margelo::nitro::unistyles { class HybridNativePlatformSpec; }
11
19
  // Forward declaration of `UnistyleDependency` to properly resolve imports.
12
20
  namespace margelo::nitro::unistyles { enum class UnistyleDependency; }
13
21
 
22
+ // Forward declarations of Swift defined types
23
+ // Forward declaration of `HybridNativePlatformSpecCxx` to properly resolve imports.
24
+ namespace Unistyles { class HybridNativePlatformSpecCxx; }
25
+
14
26
  // Include C++ defined types
15
- #if __has_include("UnistyleDependency.hpp")
16
- #include "UnistyleDependency.hpp"
17
- #endif
18
- #if __has_include(<functional>)
19
- #include <functional>
20
- #endif
21
- #if __has_include(<memory>)
22
- #include <memory>
23
- #endif
24
- #if __has_include(<optional>)
25
- #include <optional>
26
- #endif
27
- #if __has_include(<string>)
28
- #include <string>
29
- #endif
30
- #if __has_include(<vector>)
31
- #include <vector>
32
- #endif
27
+ #include "HybridNativePlatformSpec.hpp"
28
+ #include "UnistyleDependency.hpp"
29
+ #include <functional>
30
+ #include <memory>
31
+ #include <vector>
33
32
 
34
33
  /**
35
34
  * Contains specialized versions of C++ templated types so they can be accessed from Swift,
@@ -37,6 +36,7 @@ namespace margelo::nitro::unistyles { enum class UnistyleDependency; }
37
36
  */
38
37
  namespace margelo::nitro::unistyles::bridge::swift {
39
38
 
39
+ // pragma MARK: std::vector<UnistyleDependency>
40
40
  /**
41
41
  * Specialized version of `std::vector<UnistyleDependency>`.
42
42
  */
@@ -47,6 +47,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
47
47
  return vector;
48
48
  }
49
49
 
50
+ // pragma MARK: std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>
50
51
  /**
51
52
  * Specialized version of `std::function<void(const std::vector<UnistyleDependency>&)>`.
52
53
  */
@@ -54,18 +55,17 @@ namespace margelo::nitro::unistyles::bridge::swift {
54
55
  /**
55
56
  * Wrapper class for a `std::function<void(const std::vector<UnistyleDependency>& / * dependencies * /)>`, this can be used from Swift.
56
57
  */
57
- class Func_void_std__vector_UnistyleDependency__Wrapper {
58
+ class Func_void_std__vector_UnistyleDependency__Wrapper final {
58
59
  public:
59
- explicit Func_void_std__vector_UnistyleDependency__Wrapper(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& func): function(func) {}
60
- explicit Func_void_std__vector_UnistyleDependency__Wrapper(std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>&& func): function(std::move(func)) {}
61
-
62
- void call(std::vector<UnistyleDependency> dependencies) const {
63
- function(dependencies);
60
+ explicit Func_void_std__vector_UnistyleDependency__Wrapper(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& func): _function(func) {}
61
+ explicit Func_void_std__vector_UnistyleDependency__Wrapper(std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>&& func): _function(std::move(func)) {}
62
+ inline void call(std::vector<UnistyleDependency> dependencies) const {
63
+ _function(dependencies);
64
64
  }
65
-
66
- std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)> function;
65
+ private:
66
+ std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)> _function;
67
67
  };
68
- inline Func_void_std__vector_UnistyleDependency_ create_Func_void_std__vector_UnistyleDependency_(void* closureHolder, void(*call)(void* /* closureHolder */, std::vector<UnistyleDependency>), void(*destroy)(void*)) {
68
+ inline Func_void_std__vector_UnistyleDependency_ create_Func_void_std__vector_UnistyleDependency_(void* _Nonnull closureHolder, void(* _Nonnull call)(void* _Nonnull /* closureHolder */, std::vector<UnistyleDependency>), void(* _Nonnull destroy)(void* _Nonnull)) {
69
69
  std::shared_ptr<void> sharedClosureHolder(closureHolder, destroy);
70
70
  return Func_void_std__vector_UnistyleDependency_([sharedClosureHolder, call](const std::vector<UnistyleDependency>& dependencies) -> void {
71
71
  call(sharedClosureHolder.get(), dependencies);
@@ -75,12 +75,12 @@ namespace margelo::nitro::unistyles::bridge::swift {
75
75
  return std::make_shared<Func_void_std__vector_UnistyleDependency__Wrapper>(value);
76
76
  }
77
77
 
78
+ // pragma MARK: std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>
78
79
  /**
79
- * Specialized version of `std::optional<std::string>`.
80
+ * Specialized version of `std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>`.
80
81
  */
81
- using std__optional_std__string_ = std::optional<std::string>;
82
- inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) {
83
- return std::optional<std::string>(value);
84
- }
82
+ using std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_ = std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>;
83
+ std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec> create_std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_(void* _Nonnull swiftUnsafePointer);
84
+ void* _Nonnull get_std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_(std__shared_ptr_margelo__nitro__unistyles__HybridNativePlatformSpec_ cppType);
85
85
 
86
86
  } // namespace margelo::nitro::unistyles::bridge::swift