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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/lib/commonjs/core/UnistyleRegistry.js +15 -25
  2. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  3. package/lib/commonjs/core/UnistylesModule.js +187 -2
  4. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  5. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  6. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  7. package/lib/commonjs/hooks/useCSS.js +36 -1
  8. package/lib/commonjs/hooks/useCSS.js.map +1 -1
  9. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  10. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  11. package/lib/commonjs/normalizer/normalizer.js +1 -2
  12. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  13. package/lib/commonjs/useStyles.js +1 -2
  14. package/lib/commonjs/useStyles.js.map +1 -1
  15. package/lib/commonjs/utils/breakpoints.js +2 -11
  16. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  17. package/lib/commonjs/utils/cssMediaQuery.js +3 -9
  18. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
  19. package/lib/commonjs/utils/mq.js +12 -36
  20. package/lib/commonjs/utils/mq.js.map +1 -1
  21. package/lib/commonjs/utils/mqParser.js +1 -2
  22. package/lib/commonjs/utils/mqParser.js.map +1 -1
  23. package/lib/commonjs/utils/styles.js +34 -39
  24. package/lib/commonjs/utils/styles.js.map +1 -1
  25. package/lib/module/core/UnistyleRegistry.js +15 -25
  26. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  27. package/lib/module/core/UnistylesModule.js +186 -2
  28. package/lib/module/core/UnistylesModule.js.map +1 -1
  29. package/lib/module/core/UnistylesModule.native.js +3 -0
  30. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  31. package/lib/module/hooks/useCSS.js +36 -1
  32. package/lib/module/hooks/useCSS.js.map +1 -1
  33. package/lib/module/hooks/useCSS.native.js +2 -0
  34. package/lib/module/hooks/useCSS.native.js.map +1 -0
  35. package/lib/module/normalizer/normalizer.js +1 -2
  36. package/lib/module/normalizer/normalizer.js.map +1 -1
  37. package/lib/module/useStyles.js +1 -2
  38. package/lib/module/useStyles.js.map +1 -1
  39. package/lib/module/utils/breakpoints.js +2 -11
  40. package/lib/module/utils/breakpoints.js.map +1 -1
  41. package/lib/module/utils/cssMediaQuery.js +3 -9
  42. package/lib/module/utils/cssMediaQuery.js.map +1 -1
  43. package/lib/module/utils/mq.js +12 -36
  44. package/lib/module/utils/mq.js.map +1 -1
  45. package/lib/module/utils/mqParser.js +1 -2
  46. package/lib/module/utils/mqParser.js.map +1 -1
  47. package/lib/module/utils/styles.js +34 -39
  48. package/lib/module/utils/styles.js.map +1 -1
  49. package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
  50. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  51. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  52. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  53. package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
  54. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
  55. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  56. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  57. package/package.json +6 -8
  58. package/src/core/UnistylesModule.native.ts +7 -0
  59. package/src/core/UnistylesModule.ts +224 -4
  60. package/src/hooks/useCSS.native.ts +3 -0
  61. package/src/hooks/useCSS.ts +49 -1
  62. package/lib/commonjs/core/UnistylesModule.web.js +0 -199
  63. package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
  64. package/lib/commonjs/hooks/useCSS.web.js +0 -46
  65. package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
  66. package/lib/module/core/UnistylesModule.web.js +0 -192
  67. package/lib/module/core/UnistylesModule.web.js.map +0 -1
  68. package/lib/module/hooks/useCSS.web.js +0 -39
  69. package/lib/module/hooks/useCSS.web.js.map +0 -1
  70. package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
  71. package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
  72. package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
  73. package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
  74. package/src/core/UnistylesModule.web.ts +0 -227
  75. package/src/hooks/useCSS.web.ts +0 -51
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeColor","isUnistylesMq","isValidMq","parseMq","generateReactNativeWebId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","_ref","value","reduce","acc","_ref2","prop","objectKeys","keys","mediaQueries","key","breakpoints","length","className","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","_ref3","result","from","normalizePropName","normalizeWebValue","_ref4","breakpoint","undefined","replace","toLowerCase"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAgC,YAAY;AAEtF,SAASC,wBAAwB,QAAQ,cAAc;AAGvD,OAAO,MAAMC,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAACC,IAAA;IAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;IAAA,OAAK,OAAOC,KAAK,KAAK,QAAQ;EAAA,EAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,EAAAC,KAAA,KAAoB;IAAA,IAAlB,CAACC,IAAI,EAAEJ,KAAK,CAAC,GAAAG,KAAA;IACvB,MAAME,UAAU,GAAGT,MAAM,CAACU,IAAI,CAACN,KAAK,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ACd,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,YAAY;IACjB,KAAK,YAAY;IACjB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,WAAW;IAChB,KAAK,qBAAqB;IAC1B,KAAK,YAAY;IACjB,KAAK,eAAe;IACpB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,WAAW;MACZ,OAAOA,KAAK;;IAEhB;IACA;IACA,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,gBAAgB;IACrB,KAAK,iBAAiB;IACtB,KAAK,aAAa;IAClB,KAAK,cAAc;IACnB,KAAK,eAAe;IACpB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB,KAAK,iBAAiB;IACtB,KAAK,YAAY;IACjB,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,iBAAiB;MAClB,OAAO,EAAE;;IAEb;IACA,KAAK,kBAAkB;IACvB,KAAK,gBAAgB;IACrB,KAAK,gBAAgB;IACrB,KAAK,uBAAuB;IAC5B,KAAK,yBAAyB;IAC9B,KAAK,aAAa;IAClB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,sBAAsB;IAC3B,KAAK,kBAAkB;IACvB,KAAK,OAAO;IACZ,KAAK,KAAK;IACV,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB;MACI,OAAO,EAAE;EACjB;AACJ,CAAC"}
1
+ {"version":3,"names":["normalizeColor","isUnistylesMq","isValidMq","parseMq","generateReactNativeWebId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","value","reduce","acc","prop","objectKeys","keys","mediaQueries","key","breakpoints","length","className","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","result","from","normalizePropName","normalizeWebValue","breakpoint","undefined","replace","toLowerCase"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAgC,YAAY;AAEtF,SAASC,wBAAwB,QAAQ,cAAc;AAGvD,OAAO,MAAMC,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,CAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,IAAI,EAAEH,KAAK,CAAC,KAAK;IAC5B,MAAMI,UAAU,GAAGP,MAAM,CAACQ,IAAI,CAACL,KAAK,CAAC;IACrC,MAAMM,YAAY,GAAGF,UAAU,CAACL,MAAM,CAACQ,GAAG,IAAIlB,aAAa,CAACkB,GAAG,CAAC,CAAC;IACjE,MAAMC,WAAW,GAAGJ,UAAU,CAACL,MAAM,CAACQ,GAAG,IAAIZ,OAAO,CAACa,WAAW,CAACD,GAAG,CAAqC,CAAC;IAE1G,IAAID,YAAY,CAACG,MAAM,KAAK,CAAC,IAAID,WAAW,CAACC,MAAM,KAAK,CAAC,EAAE;MACvD,OAAOP,GAAG;IACd;IAEA,MAAMQ,SAAS,GAAGlB,wBAAwB,CAACW,IAAI,EAAE,IAAI,CAAC;IACtD,MAAMQ,iBAAiB,GAAGC,oBAAoB,CAACT,IAAI,EAAEH,KAAK,EAA6BL,OAAO,EAAEe,SAAS,CAAC;IAC1G,MAAMG,kBAAkB,GAAGC,qBAAqB,CAACX,IAAI,EAAEH,KAAK,EAA6BU,SAAS,CAAC;IAEnG,OAAO;MACH,GAAGR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AAK,aAAa;IAClB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,sBAAsB;IAC3B,KAAK,kBAAkB;IACvB,KAAK,OAAO;IACZ,KAAK,KAAK;IACV,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB;MACI,OAAO,EAAE;EACjB;AACJ,CAAC"}
@@ -15,42 +15,18 @@ const getMQValue = value => {
15
15
  */
16
16
  export const mq = {
17
17
  only: {
18
- width: function () {
19
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
20
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
21
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
22
- },
23
- height: function () {
24
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
25
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
26
- return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
27
- }
28
- },
29
- width: function () {
30
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
31
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
32
- return {
33
- and: {
34
- height: function () {
35
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
36
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
37
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
38
- }
39
- }
40
- };
18
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
19
+ height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
41
20
  },
42
- height: function () {
43
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
44
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
45
- return {
46
- and: {
47
- width: function () {
48
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
49
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
50
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
51
- }
52
- }
53
- };
54
- }
21
+ width: (wMin = 0, wMax = Infinity) => ({
22
+ and: {
23
+ height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
24
+ }
25
+ }),
26
+ height: (hMin = 0, hMax = Infinity) => ({
27
+ and: {
28
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
29
+ }
30
+ })
55
31
  };
56
32
  //# sourceMappingURL=mq.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","getMQValue","value","registry","breakpoints","mq","only","width","wMin","arguments","length","undefined","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AAEA,SAASA,SAAS,QAAQ,SAAS;AAqBnC,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOF,SAAS,CAACG,QAAQ,CAACC,WAAW,CAACF,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMG,EAAa,GAAG;EACzBC,I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MX,UAAU,CAACc,IAAI,CAAE,KAAId,UAAU,CAACe,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA,CAAC;EACFF,MAAM,EAAE,SAAAA,CAAA;IAAA,IAACC,IAAuB,GAAAN,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEO,IAAa,GAAAP,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;IAAA,OAAM;MAChEI,GAAG,EAAE;QACDV,KAAK,EAAE,SAAAA,CAAA;UAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;UAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;UAAA,OACvD,MAAKZ,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACW,IAAI,CAAE,OAAMX,UAAU,CAACc,IAAI,CAAE,KAAId,UAAU,CAACe,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA;AACL,CAAC"}
1
+ {"version":3,"names":["unistyles","getMQValue","value","registry","breakpoints","mq","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AAEA,SAASA,SAAS,QAAQ,SAAS;AAqBnC,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOF,SAAS,CAACG,QAAQ,CAACC,WAAW,CAACF,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMG,EAAa,GAAG;EACzBC,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAO,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,GAAwB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAO,MAAKT,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;EACpH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACxD,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,OAAMR,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;IACjG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACvD,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,OAAMR,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;IACjG;EACJ,CAAC;AACL,CAAC"}
@@ -63,8 +63,7 @@ const isWithinTheHeight = (height, screenHeight) => {
63
63
  return screenHeight >= from && screenHeight <= to;
64
64
  };
65
65
  export const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
66
- const mq = mediaQueries.find(_ref => {
67
- let [key] = _ref;
66
+ const mq = mediaQueries.find(([key]) => {
68
67
  if (!isUnistylesMq(key)) {
69
68
  return false;
70
69
  }
@@ -1 +1 @@
1
- {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":"AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,OAAO,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,OAAO,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EAAE,CAAC;AAExE,OAAO,MAAMc,SAAS,GAAIC,QAA2B,IAAK;EACtD,MAAM;IAAEd,KAAK;IAAEI;EAAO,CAAC,GAAGU,QAAQ;EAElC,IAAId,KA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AAY,IAAIX,EAAE;AACrD,CAAC;AAED,OAAO,MAAMY,4BAA4B,GAAGA,CAACC,YAAsC,EAAEN,UAAsB,KAAuB;EAC9H,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC"}
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":"AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,OAAO,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC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B,UAAU,CAAChB,KAAK,CAAC;EACpD;EAEA,IAAII,MAAM,EAAE;IACR,OAAOc,iBAAiB,CAACd,MAAM,EAAEY,UAAU,CAACZ,MAAM,CAAC;EACvD;EAEA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMa,gBAAgB,GAAGA,CAACjB,KAAiC,EAAEmB,WAAmB,KAAc;EAC1F,MAAM;IAAEZ,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOmB,WAAW,IAAIZ,IAAI,IAAIY,WAAW,IAAIV,EAAE;AACnD,CAAC;AAED,MAAMS,iBAAiB,GAAGA,CAACd,MAAmC,EAAEgB,YAAoB,KAAc;EAC9F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAED,OAAO,MAAMY,4BAA4B,GAAGA,CAACC,YAAsC,EAAEN,UAAsB,KAAuB;EAC9H,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK;IACpC,IAAI,CAACb,aAAa,CAACa,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMV,QAAQ,GAAGhB,OAAO,CAAC0B,GAAa,CAAC;IAEvC,IAAI,CAACX,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE0B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -10,50 +10,45 @@ export const isPlatformColor = value => {
10
10
  }
11
11
  return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
12
12
  };
13
- export const parseStyle = function (style) {
14
- let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
- let parseMediaQueries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
16
- return Object.entries(style || {}).reduce((acc, _ref) => {
17
- let [key, value] = _ref;
18
- // nested objects
19
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
20
- acc[key] = parseStyle(value, variant);
21
- return acc;
22
- }
13
+ export const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
14
+ // nested objects
15
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
16
+ acc[key] = parseStyle(value, variant);
17
+ return acc;
18
+ }
23
19
 
24
- // transforms
25
- if (key === 'transform' && Array.isArray(value)) {
26
- acc[key] = value.map(value => parseStyle(value, variant));
27
- return acc;
28
- }
20
+ // transforms
21
+ if (key === 'transform' && Array.isArray(value)) {
22
+ acc[key] = value.map(value => parseStyle(value, variant));
23
+ return acc;
24
+ }
29
25
 
30
- // values or platform colors
31
- if (typeof value !== 'object' || isPlatformColor(value)) {
32
- acc[key] = value;
33
- return acc;
34
- }
35
- if (key === 'variants') {
36
- return {
26
+ // values or platform colors
27
+ if (typeof value !== 'object' || isPlatformColor(value)) {
28
+ acc[key] = value;
29
+ return acc;
30
+ }
31
+ if (key === 'variants') {
32
+ return {
33
+ ...acc,
34
+ ...Object.keys(value).reduce((acc, key) => ({
37
35
  ...acc,
38
- ...Object.keys(value).reduce((acc, key) => ({
39
- ...acc,
40
- // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
41
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
42
- }), {})
43
- };
44
- }
36
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
37
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
38
+ }), {})
39
+ };
40
+ }
45
41
 
46
- // don't parse media queries and breakpoints
47
- if (!parseMediaQueries) {
48
- return {
49
- ...acc,
50
- [key]: value
51
- };
52
- }
42
+ // don't parse media queries and breakpoints
43
+ if (!parseMediaQueries) {
53
44
  return {
54
45
  ...acc,
55
- [key]: getValueForBreakpoint(value)
46
+ [key]: value
56
47
  };
57
- }, {});
58
- };
48
+ }
49
+ return {
50
+ ...acc,
51
+ [key]: getValueForBreakpoint(value)
52
+ };
53
+ }, {});
59
54
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAG,SAAAA,CACtBK,KAAQ;EAAA,IACRX,OAAyC,GAAAY,SAAA,CAAAC,MAAA,QAAAD,SAA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I,CAAC,CAAC;QAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;;IAEA;IACA,IAAI,CAACV,iBAAiB,EAAE;MACpB,OAAO;QACH,GAAGI,GAAG;QACN,CAACrB,GAAG,GAAGU;MACX,CAAC;IACL;IAEA,OAAO;MACH,GAAGW,GAAG;MACN,CAACrB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA"}
1
+ {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAGA,CACtB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MACH,GAAGI,GAAG;MACN,CAAClB,GAAG,GAAGU;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGQ,GAAG;IACN,CAAClB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC"}
@@ -1,6 +1,19 @@
1
- type UnistylesNativeModule = {
1
+ export declare class UnistylesBridgeWeb {
2
+ #private;
3
+ constructor();
2
4
  install(): boolean;
3
- };
4
- export declare const UnistylesModule: UnistylesNativeModule;
5
- export {};
5
+ private useTheme;
6
+ private useBreakpoints;
7
+ private useAdaptiveThemes;
8
+ private addPlugin;
9
+ private removePlugin;
10
+ private getTheme;
11
+ private setupListeners;
12
+ private getBreakpointFromScreenWidth;
13
+ private getPreferredColorScheme;
14
+ private emitPluginChange;
15
+ private emitThemeChange;
16
+ private emitLayoutChange;
17
+ }
18
+ export declare const UnistylesModule: UnistylesBridgeWeb;
6
19
  //# sourceMappingURL=UnistylesModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IACzB,OAAO,IAAI,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,uBAAoD,CAAA"}
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"}
@@ -0,0 +1,6 @@
1
+ type UnistylesNativeModule = {
2
+ install(): boolean;
3
+ };
4
+ export declare const UnistylesModule: UnistylesNativeModule;
5
+ export {};
6
+ //# sourceMappingURL=UnistylesModule.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnistylesModule.native.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.native.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IACzB,OAAO,IAAI,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,uBAAoD,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { ReactNativeStyleSheet } from '../types';
2
- export declare const useCSS: <T>(_stylesheet: ReactNativeStyleSheet<T>) => void;
2
+ export declare const useCSS: <T>(stylesheet: ReactNativeStyleSheet<T>) => void;
3
3
  //# sourceMappingURL=useCSS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCSS.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,MAAM,gDAA+C,IAAU,CAAA"}
1
+ {"version":3,"file":"useCSS.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGrD,eAAO,MAAM,MAAM,mDA6ClB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ReactNativeStyleSheet } from '../types';
2
+ export declare const useCSS: <T>(_stylesheet: ReactNativeStyleSheet<T>) => void;
3
+ //# sourceMappingURL=useCSS.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCSS.native.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,MAAM,gDAA+C,IAAU,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -56,17 +56,17 @@
56
56
  "@release-it/conventional-changelog": "8.0.1",
57
57
  "@testing-library/react-hooks": "8.0.1",
58
58
  "@types/jest": "29.5.11",
59
- "@types/react": "18.2.43",
59
+ "@types/react": "18.2.45",
60
60
  "@typescript-eslint/eslint-plugin": "6.14.0",
61
61
  "@typescript-eslint/eslint-plugin-tslint": "6.14.0",
62
62
  "@typescript-eslint/parser": "6.14.0",
63
63
  "commitlint": "18.4.3",
64
64
  "concurrently": "8.2.2",
65
- "eslint": "8.55.0",
65
+ "eslint": "8.56.0",
66
66
  "eslint-config-codemask": "1.1.7",
67
67
  "eslint-plugin-functional": "6.0.0",
68
- "eslint-plugin-import": "2.29.0",
69
- "eslint-plugin-jsdoc": "46.9.0",
68
+ "eslint-plugin-import": "2.29.1",
69
+ "eslint-plugin-jsdoc": "46.9.1",
70
70
  "eslint-plugin-jsx-a11y": "6.8.0",
71
71
  "eslint-plugin-nested-if": "1.0.0",
72
72
  "eslint-plugin-no-else": "0.2.2",
@@ -136,9 +136,7 @@
136
136
  },
137
137
  "plugins": {
138
138
  "@release-it/conventional-changelog": {
139
- "preset": {
140
- "name": "conventionalcommits"
141
- }
139
+ "preset": "angular"
142
140
  }
143
141
  }
144
142
  },
@@ -0,0 +1,7 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ type UnistylesNativeModule = {
4
+ install(): boolean
5
+ }
6
+
7
+ export const UnistylesModule = NativeModules?.Unistyles as UnistylesNativeModule
@@ -1,7 +1,227 @@
1
- import { NativeModules } from 'react-native'
1
+ import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
3
+ import type { ColorSchemeName } from '../types'
4
+ import { normalizeWebStylesPlugin } from '../plugins'
5
+ import { isServer } from '../common'
2
6
 
3
- type UnistylesNativeModule = {
4
- install(): boolean
7
+ export class UnistylesBridgeWeb {
8
+ #timerRef?: ReturnType<typeof setTimeout> = undefined
9
+ #hasAdaptiveThemes: boolean = false
10
+ #supportsAutomaticColorScheme = false
11
+ #screenWidth = isServer ? undefined : window.innerWidth
12
+ #screenHeight = isServer ? undefined : window.innerHeight
13
+ #themes: Array<keyof UnistylesThemes> = []
14
+ #breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
15
+ #colorScheme: ColorSchemeName = this.getPreferredColorScheme()
16
+ #themeName: keyof UnistylesThemes = '' as keyof UnistylesThemes
17
+ #enabledPlugins: Array<string> = [normalizeWebStylesPlugin.name]
18
+ #unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
19
+ #sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, number]> = []
20
+ #breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
21
+
22
+ constructor() {
23
+ if (!isServer) {
24
+ this.setupListeners()
25
+ this.#screenWidth = window.innerWidth
26
+ this.#screenHeight = window.innerHeight
27
+ }
28
+ }
29
+
30
+ public install() {
31
+ // @ts-ignore
32
+ // eslint-disable-next-line no-undef
33
+ globalThis.__UNISTYLES__ = new Proxy({}, {
34
+ get: (_target, prop) => {
35
+ switch (prop) {
36
+ case 'themeName':
37
+ return this.getTheme()
38
+ case 'screenWidth':
39
+ return this.#screenWidth
40
+ case 'screenHeight':
41
+ return this.#screenHeight
42
+ case 'breakpoint':
43
+ return this.#breakpoint || undefined
44
+ case 'breakpoints':
45
+ return this.#breakpoints
46
+ case 'hasAdaptiveThemes':
47
+ return this.#hasAdaptiveThemes
48
+ case 'sortedBreakpointPairs':
49
+ return this.#sortedBreakpointPairs
50
+ case 'enabledPlugins':
51
+ return this.#enabledPlugins
52
+ case 'colorScheme':
53
+ return this.#colorScheme
54
+ case 'useTheme':
55
+ return (themeName: keyof UnistylesThemes) => this.useTheme(themeName)
56
+ case 'useBreakpoints':
57
+ return (breakpoints: UnistylesBreakpoints) => this.useBreakpoints(breakpoints)
58
+ case 'useAdaptiveThemes':
59
+ return (enable: boolean) => this.useAdaptiveThemes(enable)
60
+ case 'addPlugin':
61
+ return (pluginName: string, notify: boolean) => this.addPlugin(pluginName, notify)
62
+ case 'removePlugin':
63
+ return (pluginName: string) => this.removePlugin(pluginName)
64
+ default:
65
+ return Reflect.get(this, prop)
66
+ }
67
+ },
68
+ set: (target, prop, newValue, receiver) => {
69
+ switch (prop) {
70
+ case 'themes': {
71
+ this.#themes = newValue
72
+ this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark')
73
+
74
+ return true
75
+ }
76
+ case 'themeName': {
77
+ this.#themeName = newValue as keyof UnistylesThemes
78
+ this.emitThemeChange()
79
+
80
+ return true
81
+ }
82
+ default:
83
+ return Reflect.set(target, prop, newValue, receiver)
84
+ }
85
+ }
86
+ })
87
+
88
+ return true
89
+ }
90
+
91
+ private useTheme(themeName: keyof UnistylesThemes) {
92
+ this.#themeName = themeName
93
+ this.emitThemeChange()
94
+ }
95
+
96
+ private useBreakpoints(breakpoints: UnistylesBreakpoints) {
97
+ this.#breakpoints = breakpoints
98
+ this.#sortedBreakpointPairs = Object
99
+ .entries(breakpoints)
100
+ .sort(([, a], [, b]) => (a ?? 0) - (b ?? 0)) as Array<[keyof UnistylesBreakpoints, number]>
101
+
102
+ if (!isServer) {
103
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth as number)
104
+ }
105
+ }
106
+
107
+ private useAdaptiveThemes(enable: boolean) {
108
+ this.#hasAdaptiveThemes = enable
109
+
110
+ if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
111
+ return
112
+ }
113
+
114
+ if (this.#themeName !== this.#colorScheme) {
115
+ this.#themeName = this.#colorScheme as keyof UnistylesThemes
116
+ this.emitThemeChange()
117
+ }
118
+ }
119
+
120
+ private addPlugin(pluginName: string, notify: boolean) {
121
+ this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins)
122
+
123
+ if (notify) {
124
+ this.emitPluginChange()
125
+ }
126
+ }
127
+
128
+ private removePlugin(pluginName: string) {
129
+ this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName)
130
+ this.emitPluginChange()
131
+ }
132
+
133
+ private getTheme(): keyof UnistylesThemes {
134
+
135
+ if (this.#themes.length === 1) {
136
+ return this.#themes.at(0) as keyof UnistylesThemes
137
+ }
138
+
139
+ return this.#themeName
140
+ }
141
+
142
+ private setupListeners() {
143
+ window.addEventListener('resize', () => {
144
+ clearTimeout(this.#timerRef)
145
+
146
+ this.#timerRef = setTimeout(() => {
147
+ this.#screenWidth = window.innerWidth
148
+ this.#screenHeight = window.innerHeight
149
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth)
150
+
151
+ this.emitLayoutChange()
152
+ }, 100)
153
+ })
154
+
155
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
156
+ this.#colorScheme = event.matches
157
+ ? 'dark'
158
+ : 'light'
159
+
160
+ if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
161
+ return
162
+ }
163
+
164
+ if (this.#colorScheme !== this.#themeName) {
165
+ this.#themeName = this.#colorScheme as keyof UnistylesThemes
166
+ this.emitThemeChange()
167
+ }
168
+ })
169
+ }
170
+
171
+ private getBreakpointFromScreenWidth(width: number): keyof UnistylesBreakpoints {
172
+ const breakpoint = this.#sortedBreakpointPairs
173
+ .find(([, value], index, otherBreakpoints) => {
174
+ const minVal = value
175
+ const maxVal = otherBreakpoints[index + 1]?.[1]
176
+
177
+ if (!maxVal) {
178
+ return true
179
+ }
180
+
181
+ return width >= minVal && width < maxVal
182
+ })
183
+
184
+ return breakpoint?.at(0) as keyof UnistylesBreakpoints
185
+ }
186
+
187
+ private getPreferredColorScheme() {
188
+ if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
189
+ return 'dark'
190
+ }
191
+
192
+ return 'light'
193
+ }
194
+
195
+ private emitPluginChange() {
196
+ this.#unistylesEvents.emit('__unistylesOnChange', {
197
+ type: 'plugin'
198
+ })
199
+ }
200
+
201
+ private emitThemeChange() {
202
+ this.#unistylesEvents.emit('__unistylesOnChange', {
203
+ type: 'theme',
204
+ payload: {
205
+ themeName: this.#themeName
206
+ }
207
+ })
208
+ }
209
+
210
+ private emitLayoutChange() {
211
+ this.#unistylesEvents.emit('__unistylesOnChange', {
212
+ type: 'layout',
213
+ payload: {
214
+ breakpoint: this.#breakpoint,
215
+ orientation: (this.#screenWidth as number) > (this.#screenHeight as number)
216
+ ? 'landscape'
217
+ : 'portrait',
218
+ screen: {
219
+ width: this.#screenWidth,
220
+ height: this.#screenHeight
221
+ }
222
+ }
223
+ })
224
+ }
5
225
  }
6
226
 
7
- export const UnistylesModule = NativeModules?.Unistyles as UnistylesNativeModule
227
+ export const UnistylesModule = new UnistylesBridgeWeb()
@@ -0,0 +1,3 @@
1
+ import type { ReactNativeStyleSheet } from '../types'
2
+
3
+ export const useCSS = <T>(_stylesheet: ReactNativeStyleSheet<T>): void => {}
@@ -1,3 +1,51 @@
1
+ import { useInsertionEffect, useRef } from 'react'
2
+ import { unistyles } from '../core'
1
3
  import type { ReactNativeStyleSheet } from '../types'
4
+ import { generateReactNativeWebId } from '../utils'
2
5
 
3
- export const useCSS = <T>(_stylesheet: ReactNativeStyleSheet<T>): void => {}
6
+ export const useCSS = <T>(stylesheet: ReactNativeStyleSheet<T>) => {
7
+ const insertedIds = useRef<Array<string>>([])
8
+
9
+ useInsertionEffect(() => {
10
+ if (!unistyles.registry.config.experimentalCSSMediaQueries) {
11
+ return
12
+ }
13
+
14
+ Object
15
+ .entries(stylesheet)
16
+ .forEach(([_key, value]) => {
17
+ Object.entries(value!)
18
+ .forEach(([prop, val]) => {
19
+ if (!val.toString().includes('@media')) {
20
+ return
21
+ }
22
+
23
+ const id = generateReactNativeWebId(prop, '""')
24
+
25
+ if (insertedIds.current.includes(id)) {
26
+ return
27
+ }
28
+
29
+ const style = document.createElement('style')
30
+
31
+ style.id = id
32
+ style.innerHTML = val
33
+
34
+ document.head.appendChild(style)
35
+ insertedIds.current = [...insertedIds.current, id]
36
+ })
37
+ })
38
+
39
+ return () => {
40
+ insertedIds.current.forEach(id => {
41
+ const style = document.getElementById(id)
42
+
43
+ if (style) {
44
+ style.remove()
45
+ }
46
+ })
47
+
48
+ insertedIds.current = []
49
+ }
50
+ }, [stylesheet])
51
+ }