@niibase/uniwind 1.6.1 → 1.6.3

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 (150) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/common/common/utils.js +15 -0
  3. package/dist/common/components/native/ActivityIndicator.js +2 -1
  4. package/dist/common/components/native/Button.js +2 -2
  5. package/dist/common/components/native/FlatList.js +2 -1
  6. package/dist/common/components/native/Image.js +2 -1
  7. package/dist/common/components/native/ImageBackground.js +2 -1
  8. package/dist/common/components/native/InputAccessoryView.js +2 -1
  9. package/dist/common/components/native/Modal.js +2 -1
  10. package/dist/common/components/native/RefreshControl.js +5 -4
  11. package/dist/common/components/native/ScrollView.js +2 -1
  12. package/dist/common/components/native/SectionList.js +2 -1
  13. package/dist/common/components/native/Switch.js +5 -4
  14. package/dist/common/components/native/Text.js +2 -1
  15. package/dist/common/components/native/TextInput.js +6 -5
  16. package/dist/common/components/native/TouchableHighlight.js +2 -1
  17. package/dist/common/components/native/VirtualizedList.js +2 -1
  18. package/dist/common/components/native/useAccentColor.js +19 -0
  19. package/dist/common/components/react-native-gesture-handler/native/FlatList.js +2 -1
  20. package/dist/common/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
  21. package/dist/common/components/react-native-gesture-handler/native/Text.js +2 -1
  22. package/dist/common/components/react-native-gesture-handler/native/TextInput.js +5 -4
  23. package/dist/common/components/web/ActivityIndicator.js +2 -2
  24. package/dist/common/components/web/Button.js +2 -2
  25. package/dist/common/components/web/Image.js +2 -1
  26. package/dist/common/components/web/ImageBackground.js +2 -2
  27. package/dist/common/components/web/Switch.js +4 -4
  28. package/dist/common/components/web/TextInput.js +2 -2
  29. package/dist/common/components/web/TouchableHighlight.js +2 -2
  30. package/dist/common/components/web/useUniwindAccent.js +20 -0
  31. package/dist/common/core/config/config.common.js +4 -7
  32. package/dist/common/core/config/config.js +42 -23
  33. package/dist/common/core/config/config.native.js +1 -3
  34. package/dist/common/core/web/cssListener.js +1 -1
  35. package/dist/common/hoc/withUniwind.js +7 -0
  36. package/dist/common/hoc/withUniwind.native.js +7 -0
  37. package/dist/common/hooks/index.js +0 -11
  38. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +2 -7
  39. package/dist/metro/index.cjs +11 -5
  40. package/dist/metro/index.mjs +12 -6
  41. package/dist/metro/metro-transformer.cjs +14 -14
  42. package/dist/metro/metro-transformer.mjs +8 -8
  43. package/dist/module/common/utils.d.ts +2 -0
  44. package/dist/module/common/utils.js +7 -0
  45. package/dist/module/components/native/ActivityIndicator.js +2 -1
  46. package/dist/module/components/native/Button.js +2 -2
  47. package/dist/module/components/native/FlatList.js +2 -1
  48. package/dist/module/components/native/Image.js +2 -1
  49. package/dist/module/components/native/ImageBackground.js +2 -1
  50. package/dist/module/components/native/InputAccessoryView.js +2 -1
  51. package/dist/module/components/native/Modal.js +2 -1
  52. package/dist/module/components/native/RefreshControl.js +5 -4
  53. package/dist/module/components/native/ScrollView.js +2 -1
  54. package/dist/module/components/native/SectionList.js +2 -1
  55. package/dist/module/components/native/Switch.js +5 -4
  56. package/dist/module/components/native/Text.js +2 -1
  57. package/dist/module/components/native/TextInput.js +6 -5
  58. package/dist/module/components/native/TouchableHighlight.js +2 -1
  59. package/dist/module/components/native/VirtualizedList.js +2 -1
  60. package/dist/module/components/native/useAccentColor.d.ts +2 -0
  61. package/dist/module/components/native/useAccentColor.js +14 -0
  62. package/dist/module/components/react-native-gesture-handler/native/FlatList.js +2 -1
  63. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
  64. package/dist/module/components/react-native-gesture-handler/native/Text.js +2 -1
  65. package/dist/module/components/react-native-gesture-handler/native/TextInput.js +5 -4
  66. package/dist/module/components/web/ActivityIndicator.js +1 -1
  67. package/dist/module/components/web/Button.js +1 -1
  68. package/dist/module/components/web/Image.js +2 -1
  69. package/dist/module/components/web/ImageBackground.js +1 -1
  70. package/dist/module/components/web/Switch.js +1 -1
  71. package/dist/module/components/web/TextInput.js +1 -1
  72. package/dist/module/components/web/TouchableHighlight.js +1 -1
  73. package/dist/module/components/web/useUniwindAccent.js +15 -0
  74. package/dist/module/core/config/config.common.d.ts +1 -1
  75. package/dist/module/core/config/config.common.js +3 -4
  76. package/dist/module/core/config/config.d.ts +4 -4
  77. package/dist/module/core/config/config.js +44 -25
  78. package/dist/module/core/config/config.native.js +1 -3
  79. package/dist/module/core/web/cssListener.js +1 -1
  80. package/dist/module/hoc/withUniwind.js +9 -0
  81. package/dist/module/hoc/withUniwind.native.js +9 -0
  82. package/dist/module/hooks/index.d.ts +0 -1
  83. package/dist/module/hooks/index.js +0 -1
  84. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +1 -6
  85. package/dist/shared/{uniwind.C-rHhHOg.mjs → uniwind.BGiqYvxb.mjs} +1 -1
  86. package/dist/shared/{uniwind.nl8746mK.cjs → uniwind.Cv73KtI-.cjs} +0 -2
  87. package/dist/shared/{uniwind.F-0-Rr--.mjs → uniwind.PtWWxxnh.mjs} +1 -2
  88. package/dist/shared/{uniwind.BZyFsest.cjs → uniwind.r2i22V6d.cjs} +1 -1
  89. package/dist/vite/index.cjs +2 -2
  90. package/dist/vite/index.mjs +2 -2
  91. package/package.json +3 -3
  92. package/src/common/utils.ts +9 -0
  93. package/src/components/native/ActivityIndicator.tsx +2 -1
  94. package/src/components/native/Button.tsx +2 -2
  95. package/src/components/native/FlatList.tsx +2 -1
  96. package/src/components/native/Image.tsx +2 -1
  97. package/src/components/native/ImageBackground.tsx +2 -1
  98. package/src/components/native/InputAccessoryView.tsx +2 -1
  99. package/src/components/native/Modal.tsx +2 -1
  100. package/src/components/native/RefreshControl.tsx +5 -4
  101. package/src/components/native/ScrollView.tsx +2 -1
  102. package/src/components/native/SectionList.tsx +2 -1
  103. package/src/components/native/Switch.tsx +5 -4
  104. package/src/components/native/Text.tsx +2 -1
  105. package/src/components/native/TextInput.tsx +6 -5
  106. package/src/components/native/TouchableHighlight.tsx +2 -1
  107. package/src/components/native/VirtualizedList.tsx +2 -1
  108. package/src/components/native/useAccentColor.ts +19 -0
  109. package/src/components/react-native-gesture-handler/native/FlatList.tsx +2 -1
  110. package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +5 -4
  111. package/src/components/react-native-gesture-handler/native/Text.tsx +2 -1
  112. package/src/components/react-native-gesture-handler/native/TextInput.tsx +5 -4
  113. package/src/components/web/ActivityIndicator.tsx +1 -1
  114. package/src/components/web/Button.tsx +1 -1
  115. package/src/components/web/Image.tsx +2 -1
  116. package/src/components/web/ImageBackground.tsx +1 -1
  117. package/src/components/web/Switch.tsx +1 -1
  118. package/src/components/web/TextInput.tsx +1 -1
  119. package/src/components/web/TouchableHighlight.tsx +1 -1
  120. package/src/components/web/useUniwindAccent.ts +21 -0
  121. package/src/core/config/config.common.ts +4 -7
  122. package/src/core/config/config.native.ts +1 -3
  123. package/src/core/config/config.ts +61 -29
  124. package/src/core/logger.ts +0 -2
  125. package/src/core/native/parsers/transforms.ts +0 -1
  126. package/src/core/native/store.ts +0 -1
  127. package/src/core/web/cssListener.ts +2 -3
  128. package/src/hoc/withUniwind.native.tsx +11 -1
  129. package/src/hoc/withUniwind.tsx +11 -0
  130. package/src/hooks/index.ts +0 -1
  131. package/src/hooks/useCSSVariable/useCSSVariable.ts +1 -8
  132. package/src/metro/addMetaToStylesTemplate.ts +3 -3
  133. package/src/metro/logger.ts +0 -2
  134. package/src/metro/metro-css-patches.ts +1 -2
  135. package/src/metro/metro-transformer.ts +3 -3
  136. package/src/metro/processor/css.ts +3 -2
  137. package/src/metro/processor/functions.ts +0 -1
  138. package/src/metro/processor/rn.ts +2 -1
  139. package/src/metro/resolvers.ts +12 -13
  140. package/src/metro/utils/common.ts +0 -3
  141. package/src/metro/utils/serialize.ts +0 -1
  142. package/src/types.ts +0 -1
  143. package/dist/common/components/native/TextInput.android.js +0 -52
  144. package/dist/common/hooks/useUniwindAccent.js +0 -13
  145. package/dist/module/components/native/TextInput.android.d.ts +0 -3
  146. package/dist/module/components/native/TextInput.android.js +0 -49
  147. package/dist/module/hooks/useUniwindAccent.js +0 -6
  148. package/src/components/native/TextInput.android.tsx +0 -51
  149. package/src/hooks/useUniwindAccent.ts +0 -10
  150. /package/dist/module/{hooks → components/web}/useUniwindAccent.d.ts +0 -0
@@ -4,50 +4,69 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Uniwind = void 0;
7
+ var _utils = require("../../common/utils");
7
8
  var _types = require("../../types");
8
9
  var _listener = require("../listener");
9
10
  var _logger = require("../logger");
11
+ var _web = require("../web");
10
12
  var _config = require("./config.common");
11
13
  class UniwindConfigBuilder extends _config.UniwindConfigBuilder {
12
- runtimeCSSVariables = /* @__PURE__ */new Map();
14
+ cssRules;
13
15
  constructor() {
14
16
  super();
15
17
  }
16
18
  updateCSSVariables(theme, variables) {
19
+ if (typeof document === "undefined") {
20
+ return;
21
+ }
22
+ const uniwindRules = this.getUniwindDynamicCSSRules();
17
23
  Object.entries(variables).forEach(([varName, varValue]) => {
18
24
  if (!varName.startsWith("--") && __DEV__) {
19
25
  _logger.Logger.error(`CSS variable name must start with "--", instead got: ${varName}`);
20
- return;
21
- }
22
- const runtimeCSSVariables = this.runtimeCSSVariables.get(theme) ?? {};
23
- runtimeCSSVariables[varName] = varValue;
24
- this.runtimeCSSVariables.set(theme, runtimeCSSVariables);
25
- if (theme === this.currentTheme) {
26
- this.applyCSSVariable(varName, varValue);
27
26
  }
27
+ const existingRules = Object.fromEntries(uniwindRules.map(rule => [rule.theme, (0, _web.getWebVariable)(varName, {
28
+ scopedTheme: rule.theme
29
+ })]));
30
+ uniwindRules.forEach(rule => {
31
+ if (rule.theme === theme) {
32
+ rule.style.setProperty(varName, typeof varValue === "number" ? `${varValue}px` : varValue);
33
+ return;
34
+ }
35
+ rule.style.setProperty(varName, existingRules[rule.theme] ?? null);
36
+ });
28
37
  });
29
- if (theme === this.currentTheme) {
30
- _listener.UniwindListener.notify([_types.StyleDependency.Variables]);
31
- }
38
+ _listener.UniwindListener.notify([_types.StyleDependency.Variables]);
32
39
  }
33
- onThemeChange() {
34
- if (typeof document === "undefined") {
40
+ __reinit(generateStyleSheetCallback, themes) {
41
+ const oldThemes = this.themes;
42
+ super.__reinit(generateStyleSheetCallback, themes);
43
+ if ((0, _utils.arrayEquals)(themes, oldThemes)) {
35
44
  return;
36
45
  }
37
- document.documentElement.removeAttribute("style");
38
- const runtimeCSSVariables = this.runtimeCSSVariables.get(this.currentTheme);
39
- if (!runtimeCSSVariables) {
40
- return;
46
+ this.cssRules = void 0;
47
+ if (typeof document !== "undefined") {
48
+ document.querySelector("#uniwind-dynamic-styles")?.remove();
41
49
  }
42
- Object.entries(runtimeCSSVariables).forEach(([varName, varValue]) => {
43
- this.applyCSSVariable(varName, varValue);
44
- });
45
50
  }
46
- applyCSSVariable(varName, varValue) {
51
+ getUniwindDynamicCSSRules() {
52
+ if (this.cssRules) {
53
+ return this.cssRules;
54
+ }
47
55
  if (typeof document === "undefined") {
48
- return;
56
+ return [];
49
57
  }
50
- document.documentElement.style.setProperty(varName, typeof varValue === "number" ? `${varValue}px` : varValue);
58
+ const styleElement = document.createElement("style");
59
+ styleElement.innerText = this.themes.reduce((acc, theme) => {
60
+ return `${acc}.${theme}{}`;
61
+ }, "");
62
+ styleElement.setAttribute("id", "uniwind-dynamic-styles");
63
+ document.head.appendChild(styleElement);
64
+ const cssRules = Array.from(styleElement.sheet?.cssRules ?? []).filter(rule => "selectorText" in rule && "style" in rule).map(rule => ({
65
+ style: rule.style,
66
+ theme: rule.selectorText.replace(".", "")
67
+ }));
68
+ this.cssRules = cssRules;
69
+ return cssRules;
51
70
  }
52
71
  }
53
72
  const Uniwind = exports.Uniwind = new UniwindConfigBuilder();
@@ -37,9 +37,7 @@ class UniwindConfigBuilder extends _config.UniwindConfigBuilder {
37
37
  get: getValue
38
38
  });
39
39
  });
40
- if (theme === this.currentTheme) {
41
- _listener.UniwindListener.notify([_types.StyleDependency.Variables]);
42
- }
40
+ _listener.UniwindListener.notify([_types.StyleDependency.Variables]);
43
41
  }
44
42
  updateInsets(insets) {
45
43
  _native.UniwindStore.runtime.insets.bottom = insets.bottom ?? 0;
@@ -54,7 +54,7 @@ class CSSListenerBuilder {
54
54
  listeners?.add(listener);
55
55
  disposables.push(() => listeners?.delete(listener));
56
56
  });
57
- const disposeThemeListener = _listener.UniwindListener.subscribe(listener, [_types.StyleDependency.Theme]);
57
+ const disposeThemeListener = _listener.UniwindListener.subscribe(listener, [_types.StyleDependency.Theme, _types.StyleDependency.Variables]);
58
58
  return () => {
59
59
  disposables.forEach(disposable => disposable());
60
60
  disposeThemeListener();
@@ -6,10 +6,13 @@ 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 _utils = require("../common/utils");
9
10
  var _generateDataSet = require("../components/web/generateDataSet");
10
11
  var _context = require("../core/context");
12
+ var _logger = require("../core/logger");
11
13
  var _web = require("../core/web");
12
14
  var _withUniwindUtils = require("./withUniwindUtils");
15
+ let warnedOnce = false;
13
16
  const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
14
17
  exports.withUniwind = withUniwind;
15
18
  const withAutoUniwind = Component2 => props => {
@@ -25,6 +28,10 @@ const withAutoUniwind = Component2 => props => {
25
28
  }
26
29
  const className = propValue;
27
30
  const color = (0, _web.getWebStyles)(className, props, uniwindContext).accentColor;
31
+ if (__DEV__ && !warnedOnce && (0, _utils.isDefined)(className) && className.trim() !== "" && color === void 0) {
32
+ warnedOnce = true;
33
+ _logger.Logger.warn(`className '${className}' was provided to extract accentColor but no color was found. Make sure the className includes a color utility (e.g., 'accent-red-500', 'accent-blue-600'). See https://docs.uniwind.dev/class-names#the-accent-prefix`);
34
+ }
28
35
  acc.generatedProps[colorProp] = color !== void 0 ? (0, _web.formatColor)(color) : void 0;
29
36
  acc.classNames += `${className} `;
30
37
  return acc;
@@ -6,10 +6,13 @@ 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 _utils = require("../common/utils");
9
10
  var _context = require("../core/context");
10
11
  var _listener = require("../core/listener");
12
+ var _logger = require("../core/logger");
11
13
  var _native = require("../core/native");
12
14
  var _withUniwindUtils = require("./withUniwindUtils");
15
+ let warnedOnce = false;
13
16
  const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
14
17
  exports.withUniwind = withUniwind;
15
18
  const withAutoUniwind = Component2 => props => {
@@ -27,6 +30,10 @@ const withAutoUniwind = Component2 => props => {
27
30
  styles,
28
31
  dependencies: dependencies2
29
32
  } = _native.UniwindStore.getStyles(propValue, props, void 0, uniwindContext);
33
+ if (__DEV__ && !warnedOnce && (0, _utils.isDefined)(propValue) && propValue.trim() !== "" && styles.accentColor === void 0) {
34
+ warnedOnce = true;
35
+ _logger.Logger.warn(`className '${propValue}' was provided to extract accentColor but no color was found. Make sure the className includes a color utility (e.g., 'accent-red-500', 'accent-blue-600'). See https://docs.uniwind.dev/class-names#the-accent-prefix`);
36
+ }
30
37
  acc.dependencies.push(...dependencies2);
31
38
  acc.generatedProps[colorProp] = styles.accentColor;
32
39
  return acc;
@@ -35,15 +35,4 @@ Object.keys(_useUniwind).forEach(function (key) {
35
35
  return _useUniwind[key];
36
36
  }
37
37
  });
38
- });
39
- var _useUniwindAccent = require("./useUniwindAccent");
40
- Object.keys(_useUniwindAccent).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _useUniwindAccent[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _useUniwindAccent[key];
47
- }
48
- });
49
38
  });
@@ -5,18 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useCSSVariable = void 0;
7
7
  var _react = require("react");
8
+ var _utils = require("../../common/utils");
8
9
  var _context = require("../../core/context");
9
10
  var _listener = require("../../core/listener");
10
11
  var _logger = require("../../core/logger");
11
12
  var _types = require("../../types");
12
13
  var _getVariableValue = require("./getVariableValue");
13
14
  const getValue = (name, uniwindContext) => Array.isArray(name) ? name.map(name2 => (0, _getVariableValue.getVariableValue)(name2, uniwindContext)) : (0, _getVariableValue.getVariableValue)(name, uniwindContext);
14
- const arrayEquals = (a, b) => {
15
- if (a.length !== b.length) {
16
- return false;
17
- }
18
- return a.every((value, index) => value === b[index]);
19
- };
20
15
  let warned = false;
21
16
  const logDevError = name => {
22
17
  warned = true;
@@ -28,7 +23,7 @@ const useCSSVariable = name => {
28
23
  const nameRef = (0, _react.useRef)(name);
29
24
  (0, _react.useLayoutEffect)(() => {
30
25
  if (Array.isArray(name) && Array.isArray(nameRef.current)) {
31
- if (arrayEquals(name, nameRef.current)) {
26
+ if ((0, _utils.arrayEquals)(name, nameRef.current)) {
32
27
  return;
33
28
  }
34
29
  setValue(getValue(name, uniwindContext));
@@ -5,7 +5,7 @@ const FileStoreBase = require('metro-cache/private/stores/FileStore');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
7
  const node_path = require('node:path');
8
- const common = require('../shared/uniwind.nl8746mK.cjs');
8
+ const common = require('../shared/uniwind.Cv73KtI-.cjs');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
11
 
@@ -78,8 +78,11 @@ const nativeResolver = (extraComponents) => ({
78
78
  }) => {
79
79
  const resolution = resolver(context, moduleName, platform);
80
80
  if (cachedInternalBasePath === null) {
81
- const componentsResolution = resolver(context, `${common.name}/components`, platform);
82
- cachedInternalBasePath = componentsResolution.type === "sourceFile" ? node_path.join(node_path.dirname(componentsResolution.filePath), "../..") : "";
81
+ try {
82
+ cachedInternalBasePath = node_path.dirname(require.resolve(`${common.name}/package.json`));
83
+ } catch {
84
+ cachedInternalBasePath = "";
85
+ }
83
86
  }
84
87
  const isInternal = cachedInternalBasePath !== "" && context.originModulePath.startsWith(cachedInternalBasePath);
85
88
  const isFromNodeModules = context.originModulePath.includes(`${node_path.sep}node_modules${node_path.sep}`);
@@ -115,8 +118,11 @@ const webResolver = (extraComponents) => ({
115
118
  }) => {
116
119
  const resolution = resolver(context, moduleName, platform);
117
120
  if (cachedInternalBasePath === null) {
118
- const componentsResolution = resolver(context, `${common.name}/components`, platform);
119
- cachedInternalBasePath = componentsResolution.type === "sourceFile" ? node_path.join(node_path.dirname(componentsResolution.filePath), "../../../..") : "";
121
+ try {
122
+ cachedInternalBasePath = node_path.dirname(require.resolve(`${common.name}/package.json`));
123
+ } catch {
124
+ cachedInternalBasePath = "";
125
+ }
120
126
  }
121
127
  if (cachedInternalBasePath !== "" && context.originModulePath.startsWith(cachedInternalBasePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${node_path.sep}react-native-web${node_path.sep}`)) {
122
128
  return resolution;
@@ -2,8 +2,8 @@ import { P as Platform } from '../shared/uniwind.JSWK3vHl.mjs';
2
2
  import FileStoreBase from 'metro-cache/private/stores/FileStore';
3
3
  import os from 'os';
4
4
  import path from 'path';
5
- import { join, dirname, sep, basename } from 'node:path';
6
- import { n as name, u as uniq } from '../shared/uniwind.F-0-Rr--.mjs';
5
+ import { dirname, sep, basename } from 'node:path';
6
+ import { n as name, u as uniq } from '../shared/uniwind.PtWWxxnh.mjs';
7
7
 
8
8
  class FileStore extends FileStoreBase {
9
9
  async set(key, value) {
@@ -70,8 +70,11 @@ const nativeResolver = (extraComponents) => ({
70
70
  }) => {
71
71
  const resolution = resolver(context, moduleName, platform);
72
72
  if (cachedInternalBasePath === null) {
73
- const componentsResolution = resolver(context, `${name}/components`, platform);
74
- cachedInternalBasePath = componentsResolution.type === "sourceFile" ? join(dirname(componentsResolution.filePath), "../..") : "";
73
+ try {
74
+ cachedInternalBasePath = dirname(require.resolve(`${name}/package.json`));
75
+ } catch {
76
+ cachedInternalBasePath = "";
77
+ }
75
78
  }
76
79
  const isInternal = cachedInternalBasePath !== "" && context.originModulePath.startsWith(cachedInternalBasePath);
77
80
  const isFromNodeModules = context.originModulePath.includes(`${sep}node_modules${sep}`);
@@ -107,8 +110,11 @@ const webResolver = (extraComponents) => ({
107
110
  }) => {
108
111
  const resolution = resolver(context, moduleName, platform);
109
112
  if (cachedInternalBasePath === null) {
110
- const componentsResolution = resolver(context, `${name}/components`, platform);
111
- cachedInternalBasePath = componentsResolution.type === "sourceFile" ? join(dirname(componentsResolution.filePath), "../../../..") : "";
113
+ try {
114
+ cachedInternalBasePath = dirname(require.resolve(`${name}/package.json`));
115
+ } catch {
116
+ cachedInternalBasePath = "";
117
+ }
112
118
  }
113
119
  if (cachedInternalBasePath !== "" && context.originModulePath.startsWith(cachedInternalBasePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${sep}react-native-web${sep}`)) {
114
120
  return resolution;
@@ -2,12 +2,12 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const common = require('../shared/uniwind.nl8746mK.cjs');
5
+ const common = require('../shared/uniwind.Cv73KtI-.cjs');
6
6
  const consts = require('../shared/uniwind.B5q8hBGv.cjs');
7
7
  const node = require('@tailwindcss/node');
8
8
  const oxide = require('@tailwindcss/oxide');
9
9
  const lightningcss = require('lightningcss');
10
- const stringifyThemes = require('../shared/uniwind.BZyFsest.cjs');
10
+ const stringifyThemes = require('../shared/uniwind.r2i22V6d.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; }
@@ -114,6 +114,8 @@ const serializeJSObject = (obj, serializer) => {
114
114
  return serializedObject;
115
115
  };
116
116
 
117
+ const isDefined = (value) => value !== void 0 && value !== null;
118
+
117
119
  var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
118
120
  StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
119
121
  StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
@@ -156,8 +158,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
156
158
  minWidth,
157
159
  maxWidth,
158
160
  colorScheme,
159
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
160
- important,
161
+ important: _,
161
162
  importantProperties,
162
163
  active,
163
164
  focus,
@@ -236,7 +237,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
236
237
  ].filter(Boolean).length
237
238
  };
238
239
  });
239
- const filteredStyles = styles.filter(common.isDefined);
240
+ const filteredStyles = styles.filter(isDefined);
240
241
  if (filteredStyles.length === 0) {
241
242
  return null;
242
243
  }
@@ -244,7 +245,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
244
245
  className,
245
246
  filteredStyles
246
247
  ];
247
- }).filter(common.isDefined);
248
+ }).filter(isDefined);
248
249
  const stylesheets = Object.fromEntries(stylesheetsEntries);
249
250
  return stylesheets;
250
251
  };
@@ -543,7 +544,7 @@ class CSS {
543
544
  this.processValue(filter.value.yOffset),
544
545
  this.processValue(filter.value.blur),
545
546
  this.processValue(filter.value.color)
546
- ].filter(common.isDefined);
547
+ ].filter(isDefined);
547
548
  return `drop-shadow(${parts.join(" ")})`;
548
549
  }
549
550
  const value = this.processValue(filter.value);
@@ -776,7 +777,7 @@ class CSS {
776
777
  return [
777
778
  this.Processor.Color.processColor(declarationValue.color),
778
779
  declarationValue.position ? this.processValue(declarationValue.position) : null
779
- ].filter(common.isDefined).join(" ");
780
+ ].filter(isDefined).join(" ");
780
781
  case "side":
781
782
  return declarationValue.side;
782
783
  case "absolute":
@@ -911,7 +912,7 @@ class CSS {
911
912
  this.processValue(declarationValue.blur),
912
913
  this.processValue(declarationValue.spread),
913
914
  this.processValue(declarationValue.color)
914
- ].filter(common.isDefined).join(" ");
915
+ ].filter(isDefined).join(" ");
915
916
  }
916
917
  if ("blockStart" in declarationValue) {
917
918
  const startValue = this.processValue(declarationValue.blockStart);
@@ -959,7 +960,6 @@ class CSS {
959
960
  this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
960
961
  return void 0;
961
962
  }
962
- // eslint-disable-next-line @typescript-eslint/member-ordering
963
963
  static TRANSFORM_TYPES = /* @__PURE__ */ new Set([
964
964
  "translate",
965
965
  "translateX",
@@ -1504,7 +1504,7 @@ class RN {
1504
1504
  typeof value === "string" ? common.addMissingSpaces(value) : value
1505
1505
  );
1506
1506
  const joinedStyles = this.joinStyles(rn);
1507
- return Object.entries(joinedStyles).filter(([, value2]) => common.isDefined(value2));
1507
+ return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2));
1508
1508
  }
1509
1509
  transformProperty(property, value) {
1510
1510
  if (property in cssToRNMap) {
@@ -2072,7 +2072,7 @@ try {
2072
2072
  worker = require("metro-transform-worker");
2073
2073
  }
2074
2074
  const transform = async (config, projectRoot, filePath, data, options) => {
2075
- const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(process.cwd(), filePath);
2075
+ const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(projectRoot, filePath);
2076
2076
  if (filePath.endsWith("/components/web/metro-injected.js")) {
2077
2077
  const cssPath2 = path__default.join(process.cwd(), config.uniwind.cssEntryFile);
2078
2078
  const injectedThemesCode2 = await injectThemes({
@@ -2109,7 +2109,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2109
2109
  themes: config.uniwind.themes,
2110
2110
  dtsPath: config.uniwind.dtsFile
2111
2111
  });
2112
- const css = fs__default.readFileSync(filePath, "utf-8");
2112
+ const css = fs__default.readFileSync(cssPath, "utf-8");
2113
2113
  const platform = getPlatform();
2114
2114
  const virtualCode = await compileVirtual({
2115
2115
  css,
@@ -2122,7 +2122,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2122
2122
  const isWeb = platform === consts.Platform.Web;
2123
2123
  data = Buffer.from(
2124
2124
  isWeb ? virtualCode : [
2125
- `import { Uniwind } from '${common.name}';`,
2125
+ `const { Uniwind } = require('${common.name}');`,
2126
2126
  `Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`
2127
2127
  ].join(""),
2128
2128
  "utf-8"
@@ -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.F-0-Rr--.mjs';
3
+ import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, d as deepEqual, c as shouldBeSerialized, e as removeKeys, n as name } from '../shared/uniwind.PtWWxxnh.mjs';
4
4
  import { P as Platform, U as UNIWIND_PLATFORM_VARIABLES, a as UNIWIND_THEME_VARIABLES } from '../shared/uniwind.JSWK3vHl.mjs';
5
5
  import { compile } from '@tailwindcss/node';
6
6
  import { Scanner } from '@tailwindcss/oxide';
7
7
  import { transform as transform$1 } from 'lightningcss';
8
- import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.C-rHhHOg.mjs';
8
+ import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.BGiqYvxb.mjs';
9
9
  import { converter, parse, formatHex, formatHex8 } from 'culori';
10
10
 
11
11
  const parseStringValue = (value) => {
@@ -107,6 +107,8 @@ const serializeJSObject = (obj, serializer) => {
107
107
  return serializedObject;
108
108
  };
109
109
 
110
+ const isDefined = (value) => value !== void 0 && value !== null;
111
+
110
112
  var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
111
113
  StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
112
114
  StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
@@ -149,8 +151,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
149
151
  minWidth,
150
152
  maxWidth,
151
153
  colorScheme,
152
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
153
- important,
154
+ important: _,
154
155
  importantProperties,
155
156
  active,
156
157
  focus,
@@ -952,7 +953,6 @@ class CSS {
952
953
  this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
953
954
  return void 0;
954
955
  }
955
- // eslint-disable-next-line @typescript-eslint/member-ordering
956
956
  static TRANSFORM_TYPES = /* @__PURE__ */ new Set([
957
957
  "translate",
958
958
  "translateX",
@@ -2065,7 +2065,7 @@ try {
2065
2065
  worker = require("metro-transform-worker");
2066
2066
  }
2067
2067
  const transform = async (config, projectRoot, filePath, data, options) => {
2068
- const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(process.cwd(), filePath);
2068
+ const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(projectRoot, filePath);
2069
2069
  if (filePath.endsWith("/components/web/metro-injected.js")) {
2070
2070
  const cssPath2 = path.join(process.cwd(), config.uniwind.cssEntryFile);
2071
2071
  const injectedThemesCode2 = await injectThemes({
@@ -2102,7 +2102,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2102
2102
  themes: config.uniwind.themes,
2103
2103
  dtsPath: config.uniwind.dtsFile
2104
2104
  });
2105
- const css = fs.readFileSync(filePath, "utf-8");
2105
+ const css = fs.readFileSync(cssPath, "utf-8");
2106
2106
  const platform = getPlatform();
2107
2107
  const virtualCode = await compileVirtual({
2108
2108
  css,
@@ -2115,7 +2115,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2115
2115
  const isWeb = platform === Platform.Web;
2116
2116
  data = Buffer.from(
2117
2117
  isWeb ? virtualCode : [
2118
- `import { Uniwind } from '${name}';`,
2118
+ `const { Uniwind } = require('${name}');`,
2119
2119
  `Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`
2120
2120
  ].join(""),
2121
2121
  "utf-8"
@@ -0,0 +1,2 @@
1
+ export declare const isDefined: <T>(value: T) => value is NonNullable<T>;
2
+ export declare const arrayEquals: <T>(a: Array<T>, b: Array<T>) => boolean;
@@ -0,0 +1,7 @@
1
+ export const isDefined = (value) => value !== void 0 && value !== null;
2
+ export const arrayEquals = (a, b) => {
3
+ if (a.length !== b.length) {
4
+ return false;
5
+ }
6
+ return a.every((value, index) => value === b[index]);
7
+ };
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ActivityIndicator as RNActivityIndicator } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const ActivityIndicator = copyComponentProperties(RNActivityIndicator, (props) => {
6
7
  const { Component, style } = useStyle(RNActivityIndicator, props.className, props, { isPressed: Boolean(props.animating) });
7
- const color = useStyle(props.colorClassName, props).accentColor;
8
+ const color = useAccentColor(props.colorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Button as RNButton } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
- import { useStyle } from "./useStyle.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
5
5
  export const Button = copyComponentProperties(RNButton, (props) => {
6
- const color = useStyle(props.colorClassName, props).accentColor;
6
+ const color = useAccentColor(props.colorClassName, props);
7
7
  return /* @__PURE__ */ jsx(
8
8
  RNButton,
9
9
  {
@@ -1,6 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { FlatList as RNFlatList } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const FlatList = copyComponentProperties(RNFlatList, (props) => {
6
7
  const { Component, style } = useStyle(RNFlatList, props.className, props);
@@ -8,7 +9,7 @@ export const FlatList = copyComponentProperties(RNFlatList, (props) => {
8
9
  const styleContentContainer = useStyle(props.contentContainerClassName, props);
9
10
  const styleListFooterComponent = useStyle(props.ListFooterComponentClassName, props);
10
11
  const styleListHeaderComponent = useStyle(props.ListHeaderComponentClassName, props);
11
- const endFillColor = useStyle(props.endFillColorClassName, props).accentColor;
12
+ const endFillColor = useAccentColor(props.endFillColorClassName, props);
12
13
  const hasSingleColumn = !("numColumns" in props) || props.numColumns === 1;
13
14
  return /* @__PURE__ */ jsx(
14
15
  Component,
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Image as RNImage } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const Image = copyComponentProperties(RNImage, (props) => {
6
7
  const { Component, style } = useStyle(RNImage, props.className, props);
7
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
8
+ const tintColor = useAccentColor(props.tintColorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,11 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ImageBackground as RNImageBackground } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const ImageBackground = copyComponentProperties(RNImageBackground, (props) => {
6
7
  const { Component, style } = useStyle(RNImageBackground, props.className, props);
7
8
  const imageStyle = useStyle(props.imageClassName, props);
8
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
9
+ const tintColor = useAccentColor(props.tintColorClassName, props);
9
10
  return /* @__PURE__ */ jsx(
10
11
  Component,
11
12
  {
@@ -1,12 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { InputAccessoryView as RNInputAccessoryView } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const InputAccessoryView = copyComponentProperties(
6
7
  RNInputAccessoryView,
7
8
  (props) => {
8
9
  const { Component, style } = useStyle(RNInputAccessoryView, props.className, props);
9
- const backgroundColor = useStyle(props.backgroundColorClassName, props).accentColor;
10
+ const backgroundColor = useAccentColor(props.backgroundColorClassName, props);
10
11
  return /* @__PURE__ */ jsx(
11
12
  Component,
12
13
  {
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Modal as RNModal } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const Modal = copyComponentProperties(RNModal, (props) => {
6
7
  const { Component, style } = useStyle(RNModal, props.className, props);
7
- const backdropColor = useStyle(props.backdropColorClassName, props).accentColor;
8
+ const backdropColor = useAccentColor(props.backdropColorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,15 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { RefreshControl as RNRefreshControl } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const RefreshControl = copyComponentProperties(RNRefreshControl, (props) => {
6
7
  const { Component, style } = useStyle(RNRefreshControl, props.className, props, {
7
8
  isPressed: Boolean(props.refreshing)
8
9
  });
9
- const color = useStyle(props.colorsClassName, props).accentColor;
10
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
11
- const titleColor = useStyle(props.titleColorClassName, props).accentColor;
12
- const progressBackgroundColor = useStyle(props.progressBackgroundColorClassName, props).accentColor;
10
+ const color = useAccentColor(props.colorsClassName, props);
11
+ const tintColor = useAccentColor(props.tintColorClassName, props);
12
+ const titleColor = useAccentColor(props.titleColorClassName, props);
13
+ const progressBackgroundColor = useAccentColor(props.progressBackgroundColorClassName, props);
13
14
  return /* @__PURE__ */ jsx(
14
15
  Component,
15
16
  {
@@ -1,11 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ScrollView as RNScrollView } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const ScrollView = copyComponentProperties(RNScrollView, (props) => {
6
7
  const { Component, style } = useStyle(RNScrollView, props.className, props);
7
8
  const contentContainerStyle = useStyle(props.contentContainerClassName, props);
8
- const endFillColor = useStyle(props.endFillColorClassName, props).accentColor;
9
+ const endFillColor = useAccentColor(props.endFillColorClassName, props);
9
10
  return /* @__PURE__ */ jsx(
10
11
  Component,
11
12
  {