@niibase/uniwind 1.1.2 → 1.1.4

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 (30) hide show
  1. package/dist/common/core/config/config.common.js +9 -0
  2. package/dist/common/core/index.js +9 -13
  3. package/dist/metro/index.cjs +4 -9
  4. package/dist/metro/index.mjs +1 -6
  5. package/dist/module/core/config/config.common.d.ts +5 -0
  6. package/dist/module/core/config/config.common.js +6 -0
  7. package/dist/module/core/index.d.ts +1 -9
  8. package/dist/module/core/index.js +1 -12
  9. package/package.json +1 -3
  10. package/src/core/config/config.common.ts +10 -0
  11. package/src/core/index.ts +1 -0
  12. package/src/metro/resolvers.ts +1 -7
  13. package/types.d.ts +0 -6
  14. package/dist/common/components/native/react-native-svg.js +0 -16
  15. package/dist/common/components/react-native-svg/index.js +0 -14
  16. package/dist/common/components/react-native-svg/native/Svg.js +0 -18
  17. package/dist/common/components/react-native-svg/web/Svg.js +0 -17
  18. package/dist/module/components/native/react-native-svg.d.ts +0 -1
  19. package/dist/module/components/native/react-native-svg.js +0 -1
  20. package/dist/module/components/react-native-svg/index.d.ts +0 -1
  21. package/dist/module/components/react-native-svg/index.js +0 -10
  22. package/dist/module/components/react-native-svg/native/Svg.d.ts +0 -3
  23. package/dist/module/components/react-native-svg/native/Svg.js +0 -15
  24. package/dist/module/components/react-native-svg/web/Svg.d.ts +0 -3
  25. package/dist/module/components/react-native-svg/web/Svg.js +0 -14
  26. package/src/components/native/react-native-svg.tsx +0 -1
  27. package/src/components/react-native-svg/index.ts +0 -12
  28. package/src/components/react-native-svg/native/Svg.tsx +0 -16
  29. package/src/components/react-native-svg/web/Svg.tsx +0 -14
  30. package/src/core/index.tsx +0 -18
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.UniwindConfigBuilder = exports.Uniwind = void 0;
7
+ var _react = require("react");
7
8
  var _reactNative = require("react-native");
9
+ var _withUniwind = require("../../hoc/withUniwind");
8
10
  var _types = require("../../types");
9
11
  var _listener = require("../listener");
10
12
  const SYSTEM_THEME = "system";
@@ -32,6 +34,13 @@ class UniwindConfigBuilder {
32
34
  get colorScheme() {
33
35
  return _reactNative.Appearance.getColorScheme() ?? _types.ColorScheme.Light;
34
36
  }
37
+ Wrapper({
38
+ as,
39
+ ...props
40
+ }) {
41
+ const StyledComponent = (0, _react.useMemo)(() => (0, _withUniwind.withUniwind)(as), [as]);
42
+ return (0, _react.createElement)(StyledComponent, props);
43
+ }
35
44
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
36
45
  setTheme(theme) {
37
46
  const prevTheme = this.#currentTheme;
@@ -3,18 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Uniwind = void 0;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var _react = require("react");
9
- var _hoc = require("../hoc");
10
6
  var _config = require("./config");
11
- const Box = ({
12
- as,
13
- ...props
14
- }) => {
15
- const StyledComponent = (0, _react.useMemo)(() => (0, _hoc.withUniwind)(as), [as]);
16
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(StyledComponent, {
17
- ...props
7
+ Object.keys(_config).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _config[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _config[key];
14
+ }
18
15
  });
19
- };
20
- const Uniwind = exports.Uniwind = Object.assign(Box, _config.Uniwind);
16
+ });
@@ -46,9 +46,7 @@ const patchMetroGraphToSupportUncachedModules = () => {
46
46
 
47
47
  const thisModuleDist = node_path.resolve(__dirname, "../../dist");
48
48
  const thisModuleSrc = node_path.resolve(__dirname, "../../src");
49
- const nodeModulesPath = node_path.resolve(__dirname, "../../../");
50
49
  const isFromThisModule = (filename) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc);
51
- const name = node_path.basename(nodeModulesPath) === "node_modules" ? node_path.basename(node_path.resolve(__dirname, "../../")) : common.name;
52
50
  const SUPPORTED_COMPONENTS = [
53
51
  "ActivityIndicator",
54
52
  "Button",
@@ -88,19 +86,16 @@ const nativeResolver = (extraComponents) => ({
88
86
  return resolution;
89
87
  }
90
88
  if (moduleName === "react-native") {
91
- return resolver(context, `${name}/components`, platform);
89
+ return resolver(context, `${common.name}/components`, platform);
92
90
  }
93
91
  if (moduleName === "react-native-gesture-handler") {
94
- return resolver(context, `${name}/components/react-native-gesture-handler`, platform);
95
- }
96
- if (moduleName === "react-native-svg") {
97
- return resolver(context, `${name}/components/react-native-svg`, platform);
92
+ return resolver(context, `${common.name}/components/react-native-gesture-handler`, platform);
98
93
  }
99
94
  if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
100
95
  const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
101
96
  const module = filename.split(".").at(0);
102
97
  if (module !== void 0 && SUPPORTED_COMPONENTS.includes(module)) {
103
- return resolver(context, `${name}/components/${module}`, platform);
98
+ return resolver(context, `${common.name}/components/${module}`, platform);
104
99
  }
105
100
  }
106
101
  if (moduleName in extraComponents) {
@@ -129,7 +124,7 @@ const webResolver = (extraComponents) => ({
129
124
  if (!isIndex || module === void 0 || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${node_path.sep}index.js`)) {
130
125
  return resolution;
131
126
  }
132
- return resolver(context, `${name}/components/${module}`, platform);
127
+ return resolver(context, `${common.name}/components/${module}`, platform);
133
128
  };
134
129
 
135
130
  const withUniwindConfig = (config, uniwindConfig) => {
@@ -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 { sep, basename, resolve } from 'node:path';
5
- import { n as name$1, u as uniq } from '../shared/uniwind.DhluOugg.mjs';
5
+ import { n as name, u as uniq } from '../shared/uniwind.DhluOugg.mjs';
6
6
  import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
7
7
 
8
8
  class FileStore extends FileStoreBase {
@@ -38,9 +38,7 @@ const patchMetroGraphToSupportUncachedModules = () => {
38
38
 
39
39
  const thisModuleDist = resolve(__dirname, "../../dist");
40
40
  const thisModuleSrc = resolve(__dirname, "../../src");
41
- const nodeModulesPath = resolve(__dirname, "../../../");
42
41
  const isFromThisModule = (filename) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc);
43
- const name = basename(nodeModulesPath) === "node_modules" ? basename(resolve(__dirname, "../../")) : name$1;
44
42
  const SUPPORTED_COMPONENTS = [
45
43
  "ActivityIndicator",
46
44
  "Button",
@@ -85,9 +83,6 @@ const nativeResolver = (extraComponents) => ({
85
83
  if (moduleName === "react-native-gesture-handler") {
86
84
  return resolver(context, `${name}/components/react-native-gesture-handler`, platform);
87
85
  }
88
- if (moduleName === "react-native-svg") {
89
- return resolver(context, `${name}/components/react-native-svg`, platform);
90
- }
91
86
  if (resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)) {
92
87
  const filename = basename(resolution.filePath.split(sep).at(-1) ?? "");
93
88
  const module = filename.split(".").at(0);
@@ -1,4 +1,6 @@
1
+ import { ComponentPropsWithRef, ElementType } from 'react';
1
2
  import { Insets } from 'react-native';
3
+ import { ApplyUniwind } from '../../hoc/types';
2
4
  import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
3
5
  declare const SYSTEM_THEME: "system";
4
6
  export declare class UniwindConfigBuilder {
@@ -8,6 +10,9 @@ export declare class UniwindConfigBuilder {
8
10
  get hasAdaptiveThemes(): boolean;
9
11
  get currentTheme(): ThemeName;
10
12
  private get colorScheme();
13
+ Wrapper<T extends ElementType>({ as, ...props }: {
14
+ as: T;
15
+ } & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
11
16
  setTheme(theme: ThemeName | typeof SYSTEM_THEME): void;
12
17
  updateCSSVariables(theme: ThemeName, variables: CSSVariables): void;
13
18
  updateInsets(insets: Insets): void;
@@ -1,4 +1,6 @@
1
+ import { createElement, useMemo } from "react";
1
2
  import { Appearance, Platform } from "react-native";
3
+ import { withUniwind } from "../../hoc/withUniwind.js";
2
4
  import { ColorScheme, StyleDependency } from "../../types.js";
3
5
  import { UniwindListener } from "../listener.js";
4
6
  const SYSTEM_THEME = "system";
@@ -26,6 +28,10 @@ export class UniwindConfigBuilder {
26
28
  get colorScheme() {
27
29
  return Appearance.getColorScheme() ?? ColorScheme.Light;
28
30
  }
31
+ Wrapper({ as, ...props }) {
32
+ const StyledComponent = useMemo(() => withUniwind(as), [as]);
33
+ return createElement(StyledComponent, props);
34
+ }
29
35
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
30
36
  setTheme(theme) {
31
37
  const prevTheme = this.#currentTheme;
@@ -1,9 +1 @@
1
- import { ComponentPropsWithRef, ElementType } from 'react';
2
- import { ApplyUniwind } from '../hoc/types';
3
- import { Uniwind as UniwindConfig } from './config';
4
- type BoxProps<T extends ElementType> = {
5
- as: T;
6
- } & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>;
7
- declare const Box: <T extends ElementType>({ as, ...props }: BoxProps<T>) => import("react").JSX.Element;
8
- export declare const Uniwind: typeof UniwindConfig & typeof Box;
9
- export {};
1
+ export * from './config';
@@ -1,12 +1 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { withUniwind } from "../hoc/index.js";
4
- import { Uniwind as UniwindConfig } from "./config/index.js";
5
- const Box = ({ as, ...props }) => {
6
- const StyledComponent = useMemo(() => withUniwind(as), [as]);
7
- return /* @__PURE__ */ jsx(StyledComponent, { ...props });
8
- };
9
- export const Uniwind = Object.assign(
10
- Box,
11
- UniwindConfig
12
- );
1
+ export * from "./config/index.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@niibase/uniwind",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "description": "The fastest Tailwind bindings for React Native",
6
6
  "homepage": "https://uniwind.dev",
7
7
  "author": "Unistack",
@@ -87,7 +87,6 @@
87
87
  "react": ">=19.0.0",
88
88
  "react-native": ">=0.81.0",
89
89
  "react-native-gesture-handler": ">=2.28.0",
90
- "react-native-svg": ">=15.15.1",
91
90
  "tailwindcss": ">=4"
92
91
  },
93
92
  "devDependencies": {
@@ -102,7 +101,6 @@
102
101
  "jest": "30.2.0",
103
102
  "react-native-gesture-handler": "2.28.0",
104
103
  "react-native-safe-area-context": "5.6.0",
105
- "react-native-svg": "15.15.1",
106
104
  "react-test-renderer": "19.1.0",
107
105
  "@react-native/babel-preset": "0.83.0",
108
106
  "@testing-library/jest-native": "5.4.3",
@@ -1,4 +1,7 @@
1
+ import { ComponentPropsWithRef, createElement, ElementType, useMemo } from 'react'
1
2
  import { Appearance, Insets, Platform } from 'react-native'
3
+ import { ApplyUniwind } from '../../hoc/types'
4
+ import { withUniwind } from '../../hoc/withUniwind'
2
5
  import { ColorScheme, StyleDependency } from '../../types'
3
6
  import { UniwindListener } from '../listener'
4
7
  import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
@@ -35,6 +38,13 @@ export class UniwindConfigBuilder {
35
38
  return Appearance.getColorScheme() ?? ColorScheme.Light
36
39
  }
37
40
 
41
+ Wrapper<T extends ElementType>({ as, ...props }: {
42
+ as: T
43
+ } & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>) {
44
+ const StyledComponent = useMemo(() => withUniwind(as as any), [as])
45
+ return createElement(StyledComponent, props)
46
+ }
47
+
38
48
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
39
49
  setTheme(theme: ThemeName | typeof SYSTEM_THEME) {
40
50
  const prevTheme = this.#currentTheme
@@ -0,0 +1 @@
1
+ export * from './config'
@@ -1,6 +1,6 @@
1
1
  import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
2
2
  import { basename, resolve, sep } from 'node:path'
3
- import { name as packageName } from '../../package.json'
3
+ import { name } from '../../package.json'
4
4
 
5
5
  type ResolverConfig = {
6
6
  platform: string | null
@@ -11,10 +11,8 @@ type ResolverConfig = {
11
11
 
12
12
  const thisModuleDist = resolve(__dirname, '../../dist')
13
13
  const thisModuleSrc = resolve(__dirname, '../../src')
14
- const nodeModulesPath = resolve(__dirname, '../../../')
15
14
 
16
15
  const isFromThisModule = (filename: string) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc)
17
- const name = basename(nodeModulesPath) === 'node_modules' ? basename(resolve(__dirname, '../../')) : packageName
18
16
 
19
17
  const SUPPORTED_COMPONENTS = [
20
18
  'ActivityIndicator',
@@ -66,10 +64,6 @@ export const nativeResolver = (extraComponents: Record<string, string>) =>
66
64
  return resolver(context, `${name}/components/react-native-gesture-handler`, platform)
67
65
  }
68
66
 
69
- if (moduleName === 'react-native-svg') {
70
- return resolver(context, `${name}/components/react-native-svg`, platform)
71
- }
72
-
73
67
  if (
74
68
  resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)
75
69
  ) {
package/types.d.ts CHANGED
@@ -139,9 +139,3 @@ declare module 'react-native-gesture-handler' {
139
139
  className?: string
140
140
  }
141
141
  }
142
-
143
- declare module 'react-native-svg' {
144
- interface SvgProps {
145
- className?: string
146
- }
147
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _reactNativeSvg = require("../react-native-svg");
7
- Object.keys(_reactNativeSvg).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _reactNativeSvg[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _reactNativeSvg[key];
14
- }
15
- });
16
- });
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- var Svg = _interopRequireWildcard(require("react-native-svg"));
4
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
5
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
6
- module.exports = {
7
- ...Svg,
8
- get Svg() {
9
- return require("./native/Svg").Svg;
10
- },
11
- get default() {
12
- return require("./native/Svg").default;
13
- }
14
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = exports.Svg = void 0;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var _reactNativeSvg = require("react-native-svg");
9
- var _useStyle = require("../../native/useStyle");
10
- var _utils = require("../../utils");
11
- const Svg = exports.Svg = (0, _utils.copyComponentProperties)(_reactNativeSvg.Svg, props => {
12
- const style = (0, _useStyle.useStyle)(props.className);
13
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
14
- ...props,
15
- style: [style, props.style]
16
- });
17
- });
18
- module.exports = Svg;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- module.exports = exports.Svg = void 0;
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var _reactNativeSvg = require("react-native-svg");
9
- var _utils = require("../../utils");
10
- var _rnw = require("../../web/rnw");
11
- const Svg = exports.Svg = (0, _utils.copyComponentProperties)(_reactNativeSvg.Svg, props => {
12
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
13
- ...props,
14
- style: [(0, _rnw.toRNWClassName)(props.className), props.style]
15
- });
16
- });
17
- module.exports = Svg;
@@ -1 +0,0 @@
1
- export * from '../react-native-svg';
@@ -1 +0,0 @@
1
- export * from "../react-native-svg/index.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import * as Svg from "react-native-svg";
2
- module.exports = {
3
- ...Svg,
4
- get Svg() {
5
- return require("./native/Svg").Svg;
6
- },
7
- get default() {
8
- return require("./native/Svg").default;
9
- }
10
- };
@@ -1,3 +0,0 @@
1
- import { Svg as RNSvg } from 'react-native-svg';
2
- export declare const Svg: typeof RNSvg;
3
- export default Svg;
@@ -1,15 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Svg as RNSvg } from "react-native-svg";
3
- import { useStyle } from "../../native/useStyle.js";
4
- import { copyComponentProperties } from "../../utils.js";
5
- export const Svg = copyComponentProperties(RNSvg, (props) => {
6
- const style = useStyle(props.className);
7
- return /* @__PURE__ */ jsx(
8
- RNSvg,
9
- {
10
- ...props,
11
- style: [style, props.style]
12
- }
13
- );
14
- });
15
- export default Svg;
@@ -1,3 +0,0 @@
1
- import { Svg as RNSvg } from 'react-native-svg';
2
- export declare const Svg: typeof RNSvg;
3
- export default Svg;
@@ -1,14 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Svg as RNSvg } from "react-native-svg";
3
- import { copyComponentProperties } from "../../utils.js";
4
- import { toRNWClassName } from "../../web/rnw.js";
5
- export const Svg = copyComponentProperties(RNSvg, (props) => {
6
- return /* @__PURE__ */ jsx(
7
- RNSvg,
8
- {
9
- ...props,
10
- style: [toRNWClassName(props.className), props.style]
11
- }
12
- );
13
- });
14
- export default Svg;
@@ -1 +0,0 @@
1
- export * from '../react-native-svg'
@@ -1,12 +0,0 @@
1
- // Re-export everything from react-native-svg
2
- import * as Svg from 'react-native-svg'
3
-
4
- module.exports = {
5
- ...Svg,
6
- get Svg() {
7
- return require('./native/Svg').Svg
8
- },
9
- get default() {
10
- return require('./native/Svg').default
11
- },
12
- }
@@ -1,16 +0,0 @@
1
- import { Svg as RNSvg, SvgProps } from 'react-native-svg'
2
- import { useStyle } from '../../native/useStyle'
3
- import { copyComponentProperties } from '../../utils'
4
-
5
- export const Svg = copyComponentProperties(RNSvg, (props: SvgProps) => {
6
- const style = useStyle(props.className)
7
-
8
- return (
9
- <RNSvg
10
- {...props}
11
- style={[style, props.style]}
12
- />
13
- )
14
- })
15
-
16
- export default Svg
@@ -1,14 +0,0 @@
1
- import { Svg as RNSvg, SvgProps } from 'react-native-svg'
2
- import { copyComponentProperties } from '../../utils'
3
- import { toRNWClassName } from '../../web/rnw'
4
-
5
- export const Svg = copyComponentProperties(RNSvg, (props: SvgProps) => {
6
- return (
7
- <RNSvg
8
- {...props}
9
- style={[toRNWClassName(props.className), props.style]}
10
- />
11
- )
12
- })
13
-
14
- export default Svg
@@ -1,18 +0,0 @@
1
- import { ComponentPropsWithRef, ElementType, useMemo } from 'react'
2
- import { withUniwind } from '../hoc'
3
- import { ApplyUniwind } from '../hoc/types'
4
- import { Uniwind as UniwindConfig } from './config'
5
-
6
- type BoxProps<T extends ElementType> = {
7
- as: T
8
- } & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>
9
-
10
- const Box = <T extends ElementType>({ as, ...props }: BoxProps<T>) => {
11
- const StyledComponent = useMemo(() => withUniwind(as as any), [as])
12
- return <StyledComponent {...props} />
13
- }
14
-
15
- export const Uniwind = Object.assign(
16
- Box,
17
- UniwindConfig,
18
- ) as typeof UniwindConfig & typeof Box