react-native-unistyles 2.0.0-rc.2 → 2.0.0-rc.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +10 -4
  3. package/android/src/main/cxx/cpp-adapter.cpp +26 -2
  4. package/android/src/main/java/com/unistyles/UnistylesModule.kt +29 -3
  5. package/cxx/UnistylesRuntime.cpp +10 -0
  6. package/cxx/UnistylesRuntime.h +10 -2
  7. package/ios/UnistylesHelpers.h +0 -1
  8. package/ios/UnistylesHelpers.mm +0 -15
  9. package/ios/UnistylesModule.h +7 -1
  10. package/ios/UnistylesModule.mm +17 -47
  11. package/ios/platform/Platform_iOS.h +21 -0
  12. package/ios/platform/Platform_iOS.mm +132 -0
  13. package/ios/platform/Platform_macOS.h +20 -0
  14. package/ios/platform/Platform_macOS.mm +83 -0
  15. package/lib/commonjs/common.js +21 -1
  16. package/lib/commonjs/common.js.map +1 -1
  17. package/lib/commonjs/core/UnistylesModule.js +3 -0
  18. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  19. package/lib/commonjs/core/UnistylesRuntime.js +8 -0
  20. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  21. package/lib/commonjs/hooks/useUnistyles.js +8 -1
  22. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  23. package/lib/commonjs/index.js +12 -0
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  26. package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
  27. package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
  28. package/lib/commonjs/useStyles.js +1 -1
  29. package/lib/commonjs/useStyles.js.map +1 -1
  30. package/lib/commonjs/utils/index.js +6 -0
  31. package/lib/commonjs/utils/index.js.map +1 -1
  32. package/lib/module/common.js +20 -0
  33. package/lib/module/common.js.map +1 -1
  34. package/lib/module/core/UnistylesModule.js +3 -0
  35. package/lib/module/core/UnistylesModule.js.map +1 -1
  36. package/lib/module/core/UnistylesRuntime.js +8 -0
  37. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  38. package/lib/module/hooks/useUnistyles.js +8 -1
  39. package/lib/module/hooks/useUnistyles.js.map +1 -1
  40. package/lib/module/index.js +2 -2
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/module/normalizer/normalizer.js.map +1 -1
  43. package/lib/module/normalizer/normalizer.macos.js +2 -0
  44. package/lib/module/normalizer/normalizer.macos.js.map +1 -0
  45. package/lib/module/useStyles.js +1 -1
  46. package/lib/module/useStyles.js.map +1 -1
  47. package/lib/module/utils/index.js +1 -1
  48. package/lib/module/utils/index.js.map +1 -1
  49. package/lib/typescript/src/common.d.ts +19 -1
  50. package/lib/typescript/src/common.d.ts.map +1 -1
  51. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  52. package/lib/typescript/src/core/UnistylesRuntime.d.ts +5 -0
  53. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  54. package/lib/typescript/src/hooks/useUnistyles.d.ts +1 -0
  55. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  56. package/lib/typescript/src/index.d.ts +2 -2
  57. package/lib/typescript/src/index.d.ts.map +1 -1
  58. package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
  59. package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
  60. package/lib/typescript/src/types/unistyles.d.ts +9 -2
  61. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  62. package/lib/typescript/src/utils/index.d.ts +1 -1
  63. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  64. package/package.json +11 -3
  65. package/react-native-unistyles.podspec +2 -2
  66. package/src/common.ts +21 -1
  67. package/src/core/UnistylesModule.ts +3 -0
  68. package/src/core/UnistylesRuntime.ts +8 -0
  69. package/src/hooks/useUnistyles.ts +9 -2
  70. package/src/index.ts +3 -1
  71. package/src/normalizer/normalizer.macos.ts +1 -0
  72. package/src/normalizer/normalizer.ts +1 -1
  73. package/src/types/unistyles.ts +10 -2
  74. package/src/useStyles.ts +1 -1
  75. package/src/utils/index.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAqB,CAAA;AAC1C,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAqB,CAAA;AAC1C,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,sBAAsB;IAC9B,oBAAoB,aAAa;IACjC,eAAe,YAAY;IAC3B,UAAU,WAAW;IACrB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,UAAU,WAAW;IACrB,WAAW,gBAAgB;CAC9B;AAED,oBAAY,0BAA0B;IAClC,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,IAAI,SAAS;CAChB;AAED,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,eAAe,oBAAoB;CACtC;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAuBpB,OAAO;IA6Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
1
+ {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAwBpB,OAAO;IA+Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
@@ -23,6 +23,11 @@ export declare class UnistylesRuntime {
23
23
  * @returns - The current theme name
24
24
  */
25
25
  get themeName(): never;
26
+ /**
27
+ * Get the current content size category
28
+ * @returns - The current content size category
29
+ */
30
+ get contentSizeCategory(): import("../common").IOSContentSizeCategory | import("../common").AndroidContentSizeCategory;
26
31
  /**
27
32
  * Get the current breakpoint based on device size
28
33
  * @returns - The current breakpoint
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
1
+ {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
@@ -9,5 +9,6 @@ export declare const useUnistyles: () => {
9
9
  height: number;
10
10
  };
11
11
  };
12
+ contentSizeCategory: import("../common").IOSContentSizeCategory | import("../common").AndroidContentSizeCategory;
12
13
  };
13
14
  //# sourceMappingURL=useUnistyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;CAgDxB,CAAA"}
1
+ {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;;CAuDxB,CAAA"}
@@ -2,7 +2,7 @@ import { mq } from './utils';
2
2
  import { useInitialTheme } from './hooks';
3
3
  import type { UnistylesPlugin } from './types';
4
4
  import type { UnistylesThemes, UnistylesBreakpoints } from './global';
5
- import { ScreenOrientation } from './common';
5
+ import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common';
6
6
  import { useStyles } from './useStyles';
7
7
  import { createStyleSheet } from './createStyleSheet';
8
8
  /**
@@ -72,6 +72,6 @@ declare const UnistylesRegistry: {
72
72
  };
73
73
  };
74
74
  declare const UnistylesRuntime: import("./core").UnistylesRuntime;
75
- export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
75
+ export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesRegistry, UnistylesRuntime };
76
76
  export type { UnistylesThemes, UnistylesBreakpoints, UnistylesPlugin };
77
77
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eA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,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=normalizer.macos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.macos.d.ts","sourceRoot":"","sources":["../../../../src/normalizer/normalizer.macos.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { UnistylesEventType, ScreenOrientation } from '../common';
1
+ import { UnistylesEventType, ScreenOrientation, IOSContentSizeCategory, AndroidContentSizeCategory } from '../common';
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
3
3
  import type { ScreenSize } from './core';
4
4
  import type { UnistylesPlugin } from './plugin';
@@ -17,6 +17,7 @@ export type UnistylesBridge = {
17
17
  themeName: keyof UnistylesThemes;
18
18
  breakpoint: keyof UnistylesBreakpoints;
19
19
  colorScheme: ColorSchemeName;
20
+ contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
20
21
  sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
21
22
  themes: Array<keyof UnistylesThemes>;
22
23
  useBreakpoints(breakpoints: UnistylesBreakpoints): void;
@@ -42,5 +43,11 @@ export type UnistylesMobileLayoutEvent = {
42
43
  export type UnistylesPluginEvent = {
43
44
  type: UnistylesEventType.Plugin;
44
45
  };
45
- export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent;
46
+ export type UnistylesDynamicTypeSizeEvent = {
47
+ type: UnistylesEventType.DynamicTypeSize;
48
+ payload: {
49
+ contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
50
+ };
51
+ };
52
+ export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent;
46
53
  //# sourceMappingURL=unistyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACjC,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAE1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAG7G,MAAM,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAC;IACrC,cAAc,CAAC,WAAW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CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IACxC,IAAI,EAAE,kBAAkB,CAAC,eAAe,CAAC;IACzC,OAAO,EAAE;QACL,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAA;KAC3E,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,6BAA6B,CAAA"}
@@ -2,7 +2,7 @@ export { mq } from './mq';
2
2
  export type { UnistylesParsedMq } from './mqParser';
3
3
  export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
4
4
  export { getValueForBreakpoint } from './breakpoints';
5
- export { proxifyFunction, parseStyle } from './styles';
5
+ export { proxifyFunction, parseStyle, isPlatformColor } from './styles';
6
6
  export { withPlugins } from './withPlugins';
7
7
  export { generateReactNativeWebId } from './generateId';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.4",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -37,7 +37,10 @@
37
37
  "keywords": [
38
38
  "react-native",
39
39
  "ios",
40
- "android"
40
+ "android",
41
+ "react-native-macos",
42
+ "react-native-web",
43
+ "expo"
41
44
  ],
42
45
  "repository": "https://github.com/jpudysz/react-native-unistyles",
43
46
  "author": "Jacek Pudysz <jacekpudysz@gmail.com> (https://github.com/jpudysz)",
@@ -88,15 +91,20 @@
88
91
  "@react-native/normalize-colors": "*",
89
92
  "react": "*",
90
93
  "react-native": "*",
94
+ "react-native-macos": "*",
91
95
  "react-native-web": "*"
92
96
  },
93
97
  "peerDependenciesMeta": {
98
+ "react-native-macos": {
99
+ "optional": true
100
+ },
94
101
  "react-native-web": {
95
102
  "optional": true
96
103
  }
97
104
  },
98
105
  "workspaces": [
99
106
  "examples/expo",
107
+ "examples/macos",
100
108
  "docs"
101
109
  ],
102
110
  "packageManager": "yarn@3.6.1",
@@ -107,7 +115,7 @@
107
115
  "preset": "react-native",
108
116
  "modulePathIgnorePatterns": [
109
117
  "<rootDir>/examples/expo/node_modules",
110
- "<rootDir>/examples/ssr/node_modules",
118
+ "<rootDir>/examples/macos/node_modules",
111
119
  "<rootDir>/docs/node_modules",
112
120
  "<rootDir>/lib/"
113
121
  ],
@@ -10,11 +10,11 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => min_ios_version_supported }
13
+ s.platforms = { :ios => min_ios_version_supported, :osx => "10.14" }
14
14
  s.source = { :git => package["repository"], :tag => "#{s.version}" }
15
15
 
16
16
  s.source_files = [
17
- "ios/*.{h,mm}",
17
+ "ios/**/*.{h,mm}",
18
18
  "cxx/*.{h,cpp}"
19
19
  ]
20
20
 
package/src/common.ts CHANGED
@@ -15,10 +15,30 @@ export const ScreenOrientation = {
15
15
  Portrait: 'portrait'
16
16
  } as const
17
17
 
18
+ export enum IOSContentSizeCategory {
19
+ ExtraExtraExtraLarge = 'xxxLarge',
20
+ ExtraExtraLarge = 'xxLarge',
21
+ ExtraLarge = 'xLarge',
22
+ Large = 'Large',
23
+ Medium = 'Medium',
24
+ Small = 'Small',
25
+ ExtraSmall = 'xSmall',
26
+ Unspecified = 'unspecified'
27
+ }
28
+
29
+ export enum AndroidContentSizeCategory {
30
+ Small = 'Small',
31
+ Default = 'Default',
32
+ Large = 'Large',
33
+ ExtraLarge = 'ExtraLarge',
34
+ Huge = 'Huge'
35
+ }
36
+
18
37
  export enum UnistylesEventType {
19
38
  Theme = 'theme',
20
39
  Layout = 'layout',
21
- Plugin = 'plugin'
40
+ Plugin = 'plugin',
41
+ DynamicTypeSize = 'dynamicTypeSize'
22
42
  }
23
43
 
24
44
  export enum UnistylesError {
@@ -18,6 +18,7 @@ export class UnistylesBridgeWeb {
18
18
  #unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
19
19
  #sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, number]> = []
20
20
  #breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
21
+ #contentSizeCategory: string = 'unspecified'
21
22
 
22
23
  constructor() {
23
24
  if (!isServer) {
@@ -39,6 +40,8 @@ export class UnistylesBridgeWeb {
39
40
  return this.#screenWidth
40
41
  case 'screenHeight':
41
42
  return this.#screenHeight
43
+ case 'contentSizeCategory':
44
+ return this.#contentSizeCategory
42
45
  case 'breakpoint':
43
46
  return this.#breakpoint || undefined
44
47
  case 'breakpoints':
@@ -33,6 +33,14 @@ export class UnistylesRuntime {
33
33
  return this.unistylesBridge.themeName
34
34
  }
35
35
 
36
+ /**
37
+ * Get the current content size category
38
+ * @returns - The current content size category
39
+ */
40
+ public get contentSizeCategory() {
41
+ return this.unistylesBridge.contentSizeCategory
42
+ }
43
+
36
44
  /**
37
45
  * Get the current breakpoint based on device size
38
46
  * @returns - The current breakpoint
@@ -2,13 +2,14 @@ import { NativeEventEmitter, NativeModules } from 'react-native'
2
2
  import { useEffect, useState } from 'react'
3
3
  import { unistyles } from '../core'
4
4
  import { UnistylesEventType } from '../common'
5
- import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
5
+ import type { UnistylesDynamicTypeSizeEvent, UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
6
6
 
7
7
  const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
8
8
 
9
9
  export const useUnistyles = () => {
10
10
  const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins)
11
11
  const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName))
12
+ const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory)
12
13
  const [layout, setLayout] = useState({
13
14
  breakpoint: unistyles.runtime.breakpoint,
14
15
  orientation: unistyles.runtime.orientation,
@@ -40,6 +41,11 @@ export const useUnistyles = () => {
40
41
  case UnistylesEventType.Plugin: {
41
42
  return setPlugins(unistyles.runtime.enabledPlugins)
42
43
  }
44
+ case UnistylesEventType.DynamicTypeSize: {
45
+ const dynamicTypeSizeEvent = event as UnistylesDynamicTypeSizeEvent
46
+
47
+ return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory)
48
+ }
43
49
  default:
44
50
  return
45
51
  }
@@ -52,6 +58,7 @@ export const useUnistyles = () => {
52
58
  return {
53
59
  plugins,
54
60
  theme,
55
- layout
61
+ layout,
62
+ contentSizeCategory
56
63
  }
57
64
  }
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import { mq } from './utils'
3
3
  import { useInitialTheme } from './hooks'
4
4
  import type { UnistylesPlugin } from './types'
5
5
  import type { UnistylesThemes, UnistylesBreakpoints } from './global'
6
- import { ScreenOrientation } from './common'
6
+ import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common'
7
7
  import { useStyles } from './useStyles'
8
8
  import { createStyleSheet } from './createStyleSheet'
9
9
 
@@ -37,6 +37,8 @@ export {
37
37
  useInitialTheme,
38
38
  createStyleSheet,
39
39
  ScreenOrientation,
40
+ AndroidContentSizeCategory,
41
+ IOSContentSizeCategory,
40
42
  UnistylesRegistry,
41
43
  UnistylesRuntime
42
44
  }
@@ -0,0 +1 @@
1
+ // keep it empty for macOS
@@ -38,7 +38,7 @@ export const normalizeColor = (color: string, opacity: number = 1) => {
38
38
 
39
39
  export const normalizeNumericValue = (value: number) => value ? `${value}px` : value
40
40
 
41
- const normalizeTransform = (key: string, value: number | string) => {
41
+ const normalizeTransform = <T>(key: string, value: T) => {
42
42
  if (key.includes('scale')) {
43
43
  return value
44
44
  }
@@ -1,4 +1,4 @@
1
- import { UnistylesEventType, ScreenOrientation } from '../common'
1
+ import { UnistylesEventType, ScreenOrientation, IOSContentSizeCategory, AndroidContentSizeCategory } from '../common'
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from '../global'
3
3
  import type { ScreenSize } from './core'
4
4
  import type { UnistylesPlugin } from './plugin'
@@ -21,6 +21,7 @@ export type UnistylesBridge = {
21
21
  themeName: keyof UnistylesThemes,
22
22
  breakpoint: keyof UnistylesBreakpoints,
23
23
  colorScheme: ColorSchemeName,
24
+ contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
24
25
  sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
25
26
 
26
27
  // setters
@@ -52,4 +53,11 @@ export type UnistylesPluginEvent = {
52
53
  type: UnistylesEventType.Plugin
53
54
  }
54
55
 
55
- export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent
56
+ export type UnistylesDynamicTypeSizeEvent = {
57
+ type: UnistylesEventType.DynamicTypeSize,
58
+ payload: {
59
+ contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory
60
+ }
61
+ }
62
+
63
+ export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent
package/src/useStyles.ts CHANGED
@@ -35,7 +35,7 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
35
35
  if (typeof value === 'function') {
36
36
  return {
37
37
  ...acc,
38
- [key]: proxifyFunction(key, value)
38
+ [key]: proxifyFunction(key, value, variants)
39
39
  }
40
40
  }
41
41
 
@@ -2,6 +2,6 @@ export { mq } from './mq'
2
2
  export type { UnistylesParsedMq } from './mqParser'
3
3
  export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser'
4
4
  export { getValueForBreakpoint } from './breakpoints'
5
- export { proxifyFunction, parseStyle } from './styles'
5
+ export { proxifyFunction, parseStyle, isPlatformColor } from './styles'
6
6
  export { withPlugins } from './withPlugins'
7
7
  export { generateReactNativeWebId } from './generateId'