@niibase/uniwind 1.1.11 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/common/components/ScopedTheme/ScopedTheme.js +28 -0
  2. package/dist/common/components/ScopedTheme/ScopedTheme.native.js +22 -0
  3. package/dist/common/components/ScopedTheme/index.js +16 -0
  4. package/dist/common/components/native/TextInput.android.js +52 -0
  5. package/dist/common/components/native/useStyle.js +4 -7
  6. package/dist/common/core/config/config.native.js +4 -14
  7. package/dist/common/core/context.js +13 -0
  8. package/dist/common/core/native/runtime.js +11 -1
  9. package/dist/common/core/native/store.js +36 -36
  10. package/dist/common/core/web/getWebStyles.js +26 -6
  11. package/dist/common/{css/processFunctions.js → css-visitor/function-visitor.js} +20 -8
  12. package/dist/common/css-visitor/index.js +16 -0
  13. package/dist/common/css-visitor/rule-visitor.js +122 -0
  14. package/dist/common/css-visitor/visitor.js +23 -0
  15. package/dist/common/hoc/withUniwind.js +5 -2
  16. package/dist/common/hoc/withUniwind.native.js +7 -4
  17. package/dist/common/hooks/useCSSVariable/getVariableValue.js +1 -12
  18. package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +1 -1
  19. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +8 -6
  20. package/dist/common/hooks/useResolveClassNames.js +4 -2
  21. package/dist/common/hooks/useResolveClassNames.native.js +4 -2
  22. package/dist/common/hooks/useUniwind.js +8 -3
  23. package/dist/common/index.js +19 -0
  24. package/dist/common/vite/vite.js +2 -4
  25. package/dist/metro/index.cjs +1 -1
  26. package/dist/metro/index.mjs +1 -1
  27. package/dist/metro/metro-transformer.cjs +33 -17
  28. package/dist/metro/metro-transformer.mjs +33 -17
  29. package/dist/module/components/ScopedTheme/ScopedTheme.d.ts +7 -0
  30. package/dist/module/components/ScopedTheme/ScopedTheme.js +7 -0
  31. package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +7 -0
  32. package/dist/module/components/ScopedTheme/ScopedTheme.native.js +7 -0
  33. package/dist/module/components/ScopedTheme/index.d.ts +1 -0
  34. package/dist/module/components/ScopedTheme/index.js +1 -0
  35. package/dist/module/components/native/TextInput.android.d.ts +3 -0
  36. package/dist/module/components/native/TextInput.android.js +49 -0
  37. package/dist/module/components/native/useStyle.js +4 -7
  38. package/dist/module/core/config/config.native.js +4 -14
  39. package/dist/module/core/context.d.ts +7 -0
  40. package/dist/module/core/context.js +6 -0
  41. package/dist/module/core/native/runtime.js +5 -2
  42. package/dist/module/core/native/store.d.ts +4 -6
  43. package/dist/module/core/native/store.js +36 -36
  44. package/dist/module/core/types.d.ts +4 -0
  45. package/dist/module/core/web/getWebStyles.d.ts +3 -2
  46. package/dist/module/core/web/getWebStyles.js +23 -4
  47. package/dist/module/css-visitor/function-visitor.d.ts +8 -0
  48. package/dist/module/{css/processFunctions.js → css-visitor/function-visitor.js} +12 -7
  49. package/dist/module/css-visitor/index.d.ts +1 -0
  50. package/dist/module/css-visitor/index.js +1 -0
  51. package/dist/module/css-visitor/rule-visitor.d.ts +26 -0
  52. package/dist/module/css-visitor/rule-visitor.js +111 -0
  53. package/dist/module/css-visitor/visitor.d.ts +8 -0
  54. package/dist/module/css-visitor/visitor.js +16 -0
  55. package/dist/module/hoc/withUniwind.js +5 -2
  56. package/dist/module/hoc/withUniwind.native.js +7 -4
  57. package/dist/module/hooks/useCSSVariable/getVariableValue.d.ts +1 -1
  58. package/dist/module/hooks/useCSSVariable/getVariableValue.js +2 -12
  59. package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +2 -1
  60. package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +2 -2
  61. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +8 -6
  62. package/dist/module/hooks/useResolveClassNames.js +6 -3
  63. package/dist/module/hooks/useResolveClassNames.native.js +6 -3
  64. package/dist/module/hooks/useUniwind.d.ts +1 -2
  65. package/dist/module/hooks/useUniwind.js +8 -3
  66. package/dist/module/index.d.ts +1 -0
  67. package/dist/module/index.js +1 -0
  68. package/dist/module/vite/vite.js +2 -4
  69. package/dist/shared/{uniwind.xtsPxiWD.mjs → uniwind.B_j3NcHy.mjs} +141 -9
  70. package/dist/shared/{uniwind.BJE4mTIG.cjs → uniwind.D7C2Zt-r.cjs} +141 -9
  71. package/dist/shared/{uniwind.BxeutNHQ.mjs → uniwind.F-0-Rr--.mjs} +1 -0
  72. package/dist/shared/{uniwind.thpLtIq6.cjs → uniwind.nl8746mK.cjs} +1 -0
  73. package/dist/vite/index.cjs +3 -5
  74. package/dist/vite/index.mjs +3 -5
  75. package/package.json +4 -3
  76. package/readme.md +4 -12
  77. package/src/components/ScopedTheme/ScopedTheme.native.tsx +17 -0
  78. package/src/components/ScopedTheme/ScopedTheme.tsx +19 -0
  79. package/src/components/ScopedTheme/index.ts +1 -0
  80. package/src/components/native/TextInput.android.tsx +51 -0
  81. package/src/components/native/useStyle.ts +4 -12
  82. package/src/core/config/config.native.ts +4 -16
  83. package/src/core/context.ts +10 -0
  84. package/src/core/native/runtime.ts +5 -1
  85. package/src/core/native/store.ts +56 -43
  86. package/src/core/types.ts +5 -0
  87. package/src/core/web/getWebStyles.ts +31 -5
  88. package/src/{css/processFunctions.ts → css-visitor/function-visitor.ts} +19 -9
  89. package/src/css-visitor/index.ts +1 -0
  90. package/src/css-visitor/rule-visitor.ts +155 -0
  91. package/src/css-visitor/visitor.ts +20 -0
  92. package/src/hoc/withUniwind.native.tsx +7 -4
  93. package/src/hoc/withUniwind.tsx +7 -2
  94. package/src/hooks/useCSSVariable/getVariableValue.native.ts +4 -2
  95. package/src/hooks/useCSSVariable/getVariableValue.ts +2 -18
  96. package/src/hooks/useCSSVariable/useCSSVariable.ts +11 -8
  97. package/src/hooks/useResolveClassNames.native.ts +6 -3
  98. package/src/hooks/useResolveClassNames.ts +6 -3
  99. package/src/hooks/useUniwind.ts +9 -3
  100. package/src/index.ts +1 -0
  101. package/src/metro/compileVirtual.ts +7 -2
  102. package/src/metro/processor/functions.ts +12 -0
  103. package/src/metro/processor/rn.ts +15 -0
  104. package/src/metro/utils/common.ts +1 -0
  105. package/src/metro/utils/serialize.ts +7 -1
  106. package/src/vite/vite.ts +2 -4
  107. package/dist/module/css/processFunctions.d.ts +0 -2
  108. package/src/metro/polyfillWeb.ts +0 -14
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.withUniwind = void 0;
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _react = require("react");
9
+ var _context = require("../core/context");
9
10
  var _listener = require("../core/listener");
10
11
  var _native = require("../core/native");
11
12
  var _withUniwindUtils = require("./withUniwindUtils");
12
13
  const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
13
14
  exports.withUniwind = withUniwind;
14
15
  const withAutoUniwind = Component2 => props => {
16
+ const uniwindContext = (0, _context.useUniwindContext)();
15
17
  const {
16
18
  dependencies,
17
19
  generatedProps
@@ -24,7 +26,7 @@ const withAutoUniwind = Component2 => props => {
24
26
  const {
25
27
  styles,
26
28
  dependencies: dependencies2
27
- } = _native.UniwindStore.getStyles(propValue);
29
+ } = _native.UniwindStore.getStyles(propValue, void 0, void 0, uniwindContext);
28
30
  acc.dependencies.push(...dependencies2);
29
31
  acc.generatedProps[colorProp] = styles.accentColor;
30
32
  return acc;
@@ -34,7 +36,7 @@ const withAutoUniwind = Component2 => props => {
34
36
  const {
35
37
  styles,
36
38
  dependencies: dependencies2
37
- } = _native.UniwindStore.getStyles(propValue);
39
+ } = _native.UniwindStore.getStyles(propValue, void 0, void 0, uniwindContext);
38
40
  acc.dependencies.push(...dependencies2);
39
41
  acc.generatedProps[styleProp] ??= [];
40
42
  acc.generatedProps[styleProp][0] = styles;
@@ -65,6 +67,7 @@ const withAutoUniwind = Component2 => props => {
65
67
  });
66
68
  };
67
69
  const withManualUniwind = (Component2, options) => props => {
70
+ const uniwindContext = (0, _context.useUniwindContext)();
68
71
  const {
69
72
  generatedProps,
70
73
  dependencies
@@ -80,7 +83,7 @@ const withManualUniwind = (Component2, options) => props => {
80
83
  const {
81
84
  styles: styles2,
82
85
  dependencies: dependencies3
83
- } = _native.UniwindStore.getStyles(className);
86
+ } = _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext);
84
87
  acc.generatedProps[propName] = styles2[option.styleProperty];
85
88
  acc.dependencies.push(...dependencies3);
86
89
  return acc;
@@ -88,7 +91,7 @@ const withManualUniwind = (Component2, options) => props => {
88
91
  const {
89
92
  styles,
90
93
  dependencies: dependencies2
91
- } = _native.UniwindStore.getStyles(className);
94
+ } = _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext);
92
95
  acc.dependencies.push(...dependencies2);
93
96
  if (!(0, _withUniwindUtils.isStyleProperty)(propName)) {
94
97
  acc.generatedProps[propName] = styles;
@@ -5,15 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getVariableValue = void 0;
7
7
  var _web = require("../../core/web");
8
- const documentStyles = typeof document !== "undefined" ? window.getComputedStyle(document.documentElement) : null;
9
- const getVariableValue = name => {
10
- if (!documentStyles) {
11
- return void 0;
12
- }
13
- const value = documentStyles.getPropertyValue(name).trim();
14
- if (value === "") {
15
- return void 0;
16
- }
17
- return (0, _web.parseCSSValue)(value);
18
- };
19
- exports.getVariableValue = getVariableValue;
8
+ const getVariableValue = exports.getVariableValue = _web.getWebVariable;
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getVariableValue = void 0;
7
7
  var _native = require("../../core/native");
8
- const getVariableValue = name => _native.UniwindStore.vars[name];
8
+ const getVariableValue = (name, uniwindContext) => _native.UniwindStore.vars[uniwindContext.scopedTheme ?? _native.UniwindRuntime.currentThemeName]?.[name];
9
9
  exports.getVariableValue = getVariableValue;
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useCSSVariable = void 0;
7
7
  var _react = require("react");
8
+ var _context = require("../../core/context");
8
9
  var _listener = require("../../core/listener");
9
10
  var _logger = require("../../core/logger");
10
11
  var _types = require("../../types");
11
12
  var _getVariableValue = require("./getVariableValue");
12
- const getValue = name => Array.isArray(name) ? name.map(_getVariableValue.getVariableValue) : (0, _getVariableValue.getVariableValue)(name);
13
+ const getValue = (name, uniwindContext) => Array.isArray(name) ? name.map(name2 => (0, _getVariableValue.getVariableValue)(name2, uniwindContext)) : (0, _getVariableValue.getVariableValue)(name, uniwindContext);
13
14
  const arrayEquals = (a, b) => {
14
15
  if (a.length !== b.length) {
15
16
  return false;
@@ -22,27 +23,28 @@ const logDevError = name => {
22
23
  _logger.Logger.warn(`We couldn't find your variable ${name}. Make sure it's used at least once in your className, or define it in a static theme as described in the docs: https://docs.uniwind.dev/api/use-css-variable`);
23
24
  };
24
25
  const useCSSVariable = name => {
25
- const [value, setValue] = (0, _react.useState)(getValue(name));
26
+ const uniwindContext = (0, _context.useUniwindContext)();
27
+ const [value, setValue] = (0, _react.useState)(getValue(name, uniwindContext));
26
28
  const nameRef = (0, _react.useRef)(name);
27
29
  (0, _react.useLayoutEffect)(() => {
28
30
  if (Array.isArray(name) && Array.isArray(nameRef.current)) {
29
31
  if (arrayEquals(name, nameRef.current)) {
30
32
  return;
31
33
  }
32
- setValue(getValue(name));
34
+ setValue(getValue(name, uniwindContext));
33
35
  nameRef.current = name;
34
36
  return;
35
37
  }
36
38
  if (name !== nameRef.current) {
37
- setValue(getValue(name));
39
+ setValue(getValue(name, uniwindContext));
38
40
  nameRef.current = name;
39
41
  }
40
42
  }, [name]);
41
43
  (0, _react.useLayoutEffect)(() => {
42
- const updateValue = () => setValue(getValue(nameRef.current));
44
+ const updateValue = () => setValue(getValue(nameRef.current, uniwindContext));
43
45
  const dispose = _listener.UniwindListener.subscribe(updateValue, [_types.StyleDependency.Theme, _types.StyleDependency.Variables]);
44
46
  return dispose;
45
- }, []);
47
+ }, [uniwindContext]);
46
48
  if (Array.isArray(value)) {
47
49
  value.forEach((val, index) => {
48
50
  if (val === void 0 && __DEV__ && !warned) {
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useResolveClassNames = void 0;
7
7
  var _react = require("react");
8
+ var _context = require("../core/context");
8
9
  var _web = require("../core/web");
9
10
  const emptyState = {};
10
11
  const useResolveClassNames = className => {
11
- const [styles, recreate] = (0, _react.useReducer)(() => className !== "" ? (0, _web.getWebStyles)(className) : emptyState, className !== "" ? (0, _web.getWebStyles)(className) : emptyState);
12
+ const uniwindContext = (0, _context.useUniwindContext)();
13
+ const [styles, recreate] = (0, _react.useReducer)(() => className !== "" ? (0, _web.getWebStyles)(className, uniwindContext) : emptyState, void 0, () => className !== "" ? (0, _web.getWebStyles)(className, uniwindContext) : emptyState);
12
14
  (0, _react.useLayoutEffect)(() => {
13
15
  if (className === "") {
14
16
  return;
@@ -16,7 +18,7 @@ const useResolveClassNames = className => {
16
18
  recreate();
17
19
  const dispose = _web.CSSListener.subscribeToClassName(className, recreate);
18
20
  return dispose;
19
- }, [className]);
21
+ }, [className, uniwindContext]);
20
22
  return styles;
21
23
  };
22
24
  exports.useResolveClassNames = useResolveClassNames;
@@ -5,15 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useResolveClassNames = void 0;
7
7
  var _react = require("react");
8
+ var _context = require("../core/context");
8
9
  var _listener = require("../core/listener");
9
10
  var _native = require("../core/native");
10
11
  const useResolveClassNames = className => {
11
- const [uniwindState, recreate] = (0, _react.useReducer)(() => _native.UniwindStore.getStyles(className), _native.UniwindStore.getStyles(className));
12
+ const uniwindContext = (0, _context.useUniwindContext)();
13
+ const [uniwindState, recreate] = (0, _react.useReducer)(() => _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext), void 0, () => _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext));
12
14
  (0, _react.useLayoutEffect)(() => {
13
15
  if (className !== "") {
14
16
  recreate();
15
17
  }
16
- }, [className]);
18
+ }, [className, uniwindContext]);
17
19
  (0, _react.useLayoutEffect)(() => {
18
20
  if (uniwindState.dependencies.length > 0) {
19
21
  const dispose = _listener.UniwindListener.subscribe(recreate, uniwindState.dependencies);
@@ -6,12 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useUniwind = void 0;
7
7
  var _react = require("react");
8
8
  var _core = require("../core");
9
+ var _context = require("../core/context");
9
10
  var _listener = require("../core/listener");
10
11
  var _types = require("../types");
11
12
  const useUniwind = () => {
13
+ const uniwindContext = (0, _context.useUniwindContext)();
12
14
  const [theme, setTheme] = (0, _react.useState)(_core.Uniwind.currentTheme);
13
15
  const [hasAdaptiveThemes, setHasAdaptiveThemes] = (0, _react.useState)(_core.Uniwind.hasAdaptiveThemes);
14
16
  (0, _react.useLayoutEffect)(() => {
17
+ if (uniwindContext.scopedTheme !== null) {
18
+ return;
19
+ }
15
20
  const dispose = _listener.UniwindListener.subscribe(() => {
16
21
  setTheme(_core.Uniwind.currentTheme);
17
22
  setHasAdaptiveThemes(_core.Uniwind.hasAdaptiveThemes);
@@ -19,10 +24,10 @@ const useUniwind = () => {
19
24
  return () => {
20
25
  dispose();
21
26
  };
22
- }, []);
27
+ }, [uniwindContext]);
23
28
  return {
24
- theme,
25
- hasAdaptiveThemes
29
+ theme: uniwindContext.scopedTheme ?? theme,
30
+ hasAdaptiveThemes: uniwindContext.scopedTheme !== null ? false : hasAdaptiveThemes
26
31
  };
27
32
  };
28
33
  exports.useUniwind = useUniwind;
@@ -3,6 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ Uniwind: true,
8
+ withUniwind: true,
9
+ useCSSVariable: true,
10
+ useResolveClassNames: true,
11
+ useUniwind: true
12
+ };
6
13
  Object.defineProperty(exports, "Uniwind", {
7
14
  enumerable: true,
8
15
  get: function () {
@@ -33,6 +40,18 @@ Object.defineProperty(exports, "withUniwind", {
33
40
  return _hoc.withUniwind;
34
41
  }
35
42
  });
43
+ var _ScopedTheme = require("./components/ScopedTheme");
44
+ Object.keys(_ScopedTheme).forEach(function (key) {
45
+ if (key === "default" || key === "__esModule") return;
46
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
+ if (key in exports && exports[key] === _ScopedTheme[key]) return;
48
+ Object.defineProperty(exports, key, {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _ScopedTheme[key];
52
+ }
53
+ });
54
+ });
36
55
  var _core = require("./core");
37
56
  var _hoc = require("./hoc");
38
57
  var _hooks = require("./hooks");
@@ -8,7 +8,7 @@ var _node = require("@tailwindcss/node");
8
8
  var _path = _interopRequireDefault(require("path"));
9
9
  var _package = require("../../package.json");
10
10
  var _css = require("../css");
11
- var _processFunctions = require("../css/processFunctions");
11
+ var _cssVisitor = require("../css-visitor");
12
12
  var _utils = require("../metro/utils");
13
13
  var _buildDtsFile = require("../utils/buildDtsFile");
14
14
  var _stringifyThemes = require("../utils/stringifyThemes");
@@ -37,9 +37,7 @@ const uniwind = ({
37
37
  css: {
38
38
  transformer: "lightningcss",
39
39
  lightningcss: {
40
- visitor: {
41
- Function: _processFunctions.processFunctions
42
- }
40
+ visitor: new _cssVisitor.UniwindCSSVisitor(themes)
43
41
  }
44
42
  },
45
43
  optimizeDeps: {
@@ -4,7 +4,7 @@ const FileStoreBase = require('metro-cache/private/stores/FileStore');
4
4
  const os = require('os');
5
5
  const path = require('path');
6
6
  const node_path = require('node:path');
7
- const common = require('../shared/uniwind.thpLtIq6.cjs');
7
+ const common = require('../shared/uniwind.nl8746mK.cjs');
8
8
  const types = require('../shared/uniwind.BZIuaszw.cjs');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -2,7 +2,7 @@ import FileStoreBase from 'metro-cache/private/stores/FileStore';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
4
  import { join, dirname, sep, basename } from 'node:path';
5
- import { n as name, u as uniq } from '../shared/uniwind.BxeutNHQ.mjs';
5
+ import { n as name, u as uniq } from '../shared/uniwind.F-0-Rr--.mjs';
6
6
  import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
7
7
 
8
8
  class FileStore extends FileStoreBase {
@@ -2,12 +2,12 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const common = require('../shared/uniwind.thpLtIq6.cjs');
5
+ const common = require('../shared/uniwind.nl8746mK.cjs');
6
6
  const node = require('@tailwindcss/node');
7
7
  const oxide = require('@tailwindcss/oxide');
8
- const types = require('../shared/uniwind.BZIuaszw.cjs');
9
- const stringifyThemes = require('../shared/uniwind.BJE4mTIG.cjs');
10
8
  const lightningcss = require('lightningcss');
9
+ const types = require('../shared/uniwind.BZIuaszw.cjs');
10
+ const stringifyThemes = require('../shared/uniwind.D7C2Zt-r.cjs');
11
11
  const culori = require('culori');
12
12
 
13
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -34,9 +34,13 @@ const parseStringValue = (value) => {
34
34
  return token;
35
35
  }
36
36
  const endsWithComma = token.endsWith(",");
37
+ const expr = endsWithComma ? token.slice(0, -1) : token;
38
+ if (!common.isValidJSValue(expr)) {
39
+ return token;
40
+ }
37
41
  return [
38
42
  "${",
39
- endsWithComma ? token.slice(0, -1) : token,
43
+ expr,
40
44
  "}",
41
45
  endsWithComma ? "," : ""
42
46
  ].join("");
@@ -238,17 +242,6 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
238
242
  return stylesheets;
239
243
  };
240
244
 
241
- const polyfillWeb = (css) => {
242
- const result = lightningcss.transform({
243
- code: Buffer.from(css),
244
- filename: "uniwind.css",
245
- visitor: {
246
- Function: stringifyThemes.processFunctions
247
- }
248
- });
249
- return result.code.toString();
250
- };
251
-
252
245
  const transforms = [
253
246
  "translateX",
254
247
  "translateY",
@@ -1125,10 +1118,19 @@ class Functions {
1125
1118
  if (fn.name === "hairlineWidth") {
1126
1119
  return "rt.hairlineWidth";
1127
1120
  }
1121
+ if (fn.name === "platformSelect") {
1122
+ return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
1123
+ }
1128
1124
  if (fn.name === "pixelRatio") {
1125
+ if (fn.arguments.length === 0) {
1126
+ return "rt.pixelRatio(1)";
1127
+ }
1129
1128
  return `rt.pixelRatio(${this.Processor.CSS.processValue(fn.arguments)})`;
1130
1129
  }
1131
1130
  if (fn.name === "fontScale") {
1131
+ if (fn.arguments.length === 0) {
1132
+ return "rt.fontScale(1)";
1133
+ }
1132
1134
  return `rt.fontScale(${this.Processor.CSS.processValue(fn.arguments)})`;
1133
1135
  }
1134
1136
  if (fn.name === "drop-shadow") {
@@ -1426,6 +1428,7 @@ const cssToRNMap = {
1426
1428
  })
1427
1429
  };
1428
1430
  const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
1431
+ const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
1429
1432
  class RN {
1430
1433
  constructor(Processor) {
1431
1434
  this.Processor = Processor;
@@ -1435,7 +1438,7 @@ class RN {
1435
1438
  common.toCamelCase,
1436
1439
  (x) => {
1437
1440
  if (x.includes("padding") || x.includes("margin")) {
1438
- return x.replace("Inline", "Horizontal").replace("Block", "Vertical");
1441
+ return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
1439
1442
  }
1440
1443
  return x;
1441
1444
  }
@@ -1531,6 +1534,15 @@ class RN {
1531
1534
  };
1532
1535
  }
1533
1536
  }
1537
+ if (BORDER_COLOR_KEYS.every((key) => keys.includes(key))) {
1538
+ const borderColor = styles.borderTopColor;
1539
+ if (BORDER_COLOR_KEYS.every((key) => styles[key] === borderColor)) {
1540
+ return {
1541
+ ...common.removeKeys(styles, BORDER_COLOR_KEYS),
1542
+ borderColor
1543
+ };
1544
+ }
1545
+ }
1534
1546
  return styles;
1535
1547
  }
1536
1548
  }
@@ -1942,7 +1954,11 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
1942
1954
  });
1943
1955
  const tailwindCSS = compiler.build(candidates ?? scanner.scan());
1944
1956
  if (platform === types.Platform.Web) {
1945
- return polyfillWeb(tailwindCSS);
1957
+ return lightningcss.transform({
1958
+ code: Buffer.from(tailwindCSS),
1959
+ filename: "uniwind.css",
1960
+ visitor: new stringifyThemes.UniwindCSSVisitor(themes)
1961
+ }).code.toString();
1946
1962
  }
1947
1963
  const Processor = new ProcessorBuilder(themes, polyfills);
1948
1964
  stringifyThemes.Logger.debug = debug === true;
@@ -1,11 +1,11 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, c as isDefined, d as deepEqual, e as shouldBeSerialized, f as removeKeys, n as name } from '../shared/uniwind.BxeutNHQ.mjs';
3
+ import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, c as isDefined, d as deepEqual, e as shouldBeSerialized, f as removeKeys, n as name } from '../shared/uniwind.F-0-Rr--.mjs';
4
4
  import { compile } from '@tailwindcss/node';
5
5
  import { Scanner } from '@tailwindcss/oxide';
6
- import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
7
- import { L as Logger, p as processFunctions, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.xtsPxiWD.mjs';
8
6
  import { transform as transform$1 } from 'lightningcss';
7
+ import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
8
+ import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.B_j3NcHy.mjs';
9
9
  import { converter, parse, formatHex, formatHex8 } from 'culori';
10
10
 
11
11
  const parseStringValue = (value) => {
@@ -27,9 +27,13 @@ const parseStringValue = (value) => {
27
27
  return token;
28
28
  }
29
29
  const endsWithComma = token.endsWith(",");
30
+ const expr = endsWithComma ? token.slice(0, -1) : token;
31
+ if (!isValidJSValue(expr)) {
32
+ return token;
33
+ }
30
34
  return [
31
35
  "${",
32
- endsWithComma ? token.slice(0, -1) : token,
36
+ expr,
33
37
  "}",
34
38
  endsWithComma ? "," : ""
35
39
  ].join("");
@@ -231,17 +235,6 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
231
235
  return stylesheets;
232
236
  };
233
237
 
234
- const polyfillWeb = (css) => {
235
- const result = transform$1({
236
- code: Buffer.from(css),
237
- filename: "uniwind.css",
238
- visitor: {
239
- Function: processFunctions
240
- }
241
- });
242
- return result.code.toString();
243
- };
244
-
245
238
  const transforms = [
246
239
  "translateX",
247
240
  "translateY",
@@ -1118,10 +1111,19 @@ class Functions {
1118
1111
  if (fn.name === "hairlineWidth") {
1119
1112
  return "rt.hairlineWidth";
1120
1113
  }
1114
+ if (fn.name === "platformSelect") {
1115
+ return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
1116
+ }
1121
1117
  if (fn.name === "pixelRatio") {
1118
+ if (fn.arguments.length === 0) {
1119
+ return "rt.pixelRatio(1)";
1120
+ }
1122
1121
  return `rt.pixelRatio(${this.Processor.CSS.processValue(fn.arguments)})`;
1123
1122
  }
1124
1123
  if (fn.name === "fontScale") {
1124
+ if (fn.arguments.length === 0) {
1125
+ return "rt.fontScale(1)";
1126
+ }
1125
1127
  return `rt.fontScale(${this.Processor.CSS.processValue(fn.arguments)})`;
1126
1128
  }
1127
1129
  if (fn.name === "drop-shadow") {
@@ -1419,6 +1421,7 @@ const cssToRNMap = {
1419
1421
  })
1420
1422
  };
1421
1423
  const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
1424
+ const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
1422
1425
  class RN {
1423
1426
  constructor(Processor) {
1424
1427
  this.Processor = Processor;
@@ -1428,7 +1431,7 @@ class RN {
1428
1431
  toCamelCase,
1429
1432
  (x) => {
1430
1433
  if (x.includes("padding") || x.includes("margin")) {
1431
- return x.replace("Inline", "Horizontal").replace("Block", "Vertical");
1434
+ return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
1432
1435
  }
1433
1436
  return x;
1434
1437
  }
@@ -1524,6 +1527,15 @@ class RN {
1524
1527
  };
1525
1528
  }
1526
1529
  }
1530
+ if (BORDER_COLOR_KEYS.every((key) => keys.includes(key))) {
1531
+ const borderColor = styles.borderTopColor;
1532
+ if (BORDER_COLOR_KEYS.every((key) => styles[key] === borderColor)) {
1533
+ return {
1534
+ ...removeKeys(styles, BORDER_COLOR_KEYS),
1535
+ borderColor
1536
+ };
1537
+ }
1538
+ }
1527
1539
  return styles;
1528
1540
  }
1529
1541
  }
@@ -1935,7 +1947,11 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
1935
1947
  });
1936
1948
  const tailwindCSS = compiler.build(candidates ?? scanner.scan());
1937
1949
  if (platform === Platform.Web) {
1938
- return polyfillWeb(tailwindCSS);
1950
+ return transform$1({
1951
+ code: Buffer.from(tailwindCSS),
1952
+ filename: "uniwind.css",
1953
+ visitor: new UniwindCSSVisitor(themes)
1954
+ }).code.toString();
1939
1955
  }
1940
1956
  const Processor = new ProcessorBuilder(themes, polyfills);
1941
1957
  Logger.debug = debug === true;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { ThemeName } from '../../core/types';
3
+ type ScopedThemeProps = {
4
+ theme: ThemeName;
5
+ };
6
+ export declare const ScopedTheme: React.FC<React.PropsWithChildren<ScopedThemeProps>>;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { UniwindContext } from "../../core/context.js";
4
+ export const ScopedTheme = ({ theme, children }) => {
5
+ const value = useMemo(() => ({ scopedTheme: theme }), [theme]);
6
+ return /* @__PURE__ */ jsx(UniwindContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { className: theme, style: { display: "contents" }, children }) });
7
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { ThemeName } from '../../core/types';
3
+ type ScopedThemeProps = {
4
+ theme: ThemeName;
5
+ };
6
+ export declare const ScopedTheme: React.FC<React.PropsWithChildren<ScopedThemeProps>>;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { UniwindContext } from "../../core/context.js";
4
+ export const ScopedTheme = ({ theme, children }) => {
5
+ const value = useMemo(() => ({ scopedTheme: theme }), [theme]);
6
+ return /* @__PURE__ */ jsx(UniwindContext.Provider, { value, children });
7
+ };
@@ -0,0 +1 @@
1
+ export * from './ScopedTheme';
@@ -0,0 +1 @@
1
+ export * from "./ScopedTheme.js";
@@ -0,0 +1,3 @@
1
+ import { TextInput as RNTextInput } from 'react-native';
2
+ export declare const TextInput: typeof RNTextInput;
3
+ export default TextInput;
@@ -0,0 +1,49 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { TextInput as RNTextInput } from "react-native";
4
+ import { copyComponentProperties } from "../utils.js";
5
+ import { useStyle } from "./useStyle.js";
6
+ export const TextInput = copyComponentProperties(RNTextInput, (props) => {
7
+ const [isFocused, setIsFocused] = useState(false);
8
+ const [isPressed, setIsPressed] = useState(false);
9
+ const state = {
10
+ isDisabled: props.editable === false,
11
+ isFocused,
12
+ isPressed
13
+ };
14
+ const style = useStyle(props.className, props, state);
15
+ const cursorColor = useStyle(props.cursorColorClassName, props, state).accentColor;
16
+ const selectionColor = useStyle(props.selectionColorClassName, props, state).accentColor;
17
+ const placeholderTextColor = useStyle(props.placeholderTextColorClassName, props, state).accentColor;
18
+ const selectionHandleColor = useStyle(props.selectionHandleColorClassName, props, state).accentColor;
19
+ const underlineColorAndroid = useStyle(props.underlineColorAndroidClassName, props, state).accentColor;
20
+ return /* @__PURE__ */ jsx(
21
+ RNTextInput,
22
+ {
23
+ ...props,
24
+ style: [style, props.style],
25
+ cursorColor: props.cursorColor ?? cursorColor,
26
+ selectionColor: props.selectionColor ?? selectionColor,
27
+ placeholderTextColor: props.placeholderTextColor ?? placeholderTextColor,
28
+ selectionHandleColor: props.selectionHandleColor ?? selectionHandleColor,
29
+ underlineColorAndroid: props.underlineColorAndroid ?? underlineColorAndroid,
30
+ onFocus: (event) => {
31
+ setIsFocused(true);
32
+ props.onFocus?.(event);
33
+ },
34
+ onBlur: (event) => {
35
+ setIsFocused(false);
36
+ props.onBlur?.(event);
37
+ },
38
+ onPressIn: (event) => {
39
+ setIsPressed(true);
40
+ props.onPressIn?.(event);
41
+ },
42
+ onPressOut: (event) => {
43
+ setIsPressed(false);
44
+ props.onPressOut?.(event);
45
+ }
46
+ }
47
+ );
48
+ });
49
+ export default TextInput;
@@ -1,27 +1,24 @@
1
1
  import { useLayoutEffect, useReducer } from "react";
2
2
  import { createAnimatedComponent } from "react-native-reanimated";
3
+ import { useUniwindContext } from "../../core/context.js";
3
4
  import { UniwindListener } from "../../core/listener.js";
4
5
  import { UniwindStore } from "../../core/native/index.js";
5
6
  import { weakFamily } from "../../core/weak-map.js";
6
- const emptyState = {
7
- styles: {},
8
- component: void 0,
9
- dependencies: []
10
- };
11
7
  export function useStyle(componentOrClassName, classNameOrComponentProps, componentPropsOrState, state) {
12
8
  "use no memo";
9
+ const uniwindContext = useUniwindContext();
13
10
  const [_, rerender] = useReducer(() => ({}), {});
14
11
  const isComponentOverload = typeof componentOrClassName !== "string" && componentOrClassName !== void 0;
15
12
  const className = isComponentOverload ? classNameOrComponentProps : componentOrClassName;
16
13
  const componentProps = isComponentOverload ? componentPropsOrState : classNameOrComponentProps;
17
14
  const actualState = isComponentOverload ? state : componentPropsOrState;
18
- const styleState = className ? UniwindStore.getStyles(className, componentProps, actualState) : emptyState;
15
+ const styleState = UniwindStore.getStyles(className, componentProps, actualState, uniwindContext);
19
16
  useLayoutEffect(() => {
20
17
  if (__DEV__ || styleState.dependencies.length > 0) {
21
18
  const dispose = UniwindListener.subscribe(rerender, styleState.dependencies);
22
19
  return dispose;
23
20
  }
24
- }, [styleState.dependencies]);
21
+ }, [styleState.dependencySum]);
25
22
  if (!isComponentOverload) {
26
23
  return styleState.styles;
27
24
  }