@niibase/uniwind 1.1.2 → 1.1.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.
- package/dist/common/core/config/config.common.js +9 -0
- package/dist/common/core/index.js +9 -13
- package/dist/metro/index.cjs +5 -7
- package/dist/metro/index.mjs +1 -3
- package/dist/module/core/config/config.common.d.ts +5 -0
- package/dist/module/core/config/config.common.js +6 -0
- package/dist/module/core/index.d.ts +1 -9
- package/dist/module/core/index.js +1 -12
- package/package.json +1 -1
- package/src/core/config/config.common.ts +10 -0
- package/src/core/index.ts +1 -0
- package/src/metro/resolvers.ts +1 -3
- 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
});
|
package/dist/metro/index.cjs
CHANGED
|
@@ -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,19 @@ 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);
|
|
92
|
+
return resolver(context, `${common.name}/components/react-native-gesture-handler`, platform);
|
|
95
93
|
}
|
|
96
94
|
if (moduleName === "react-native-svg") {
|
|
97
|
-
return resolver(context, `${name}/components/react-native-svg`, platform);
|
|
95
|
+
return resolver(context, `${common.name}/components/react-native-svg`, platform);
|
|
98
96
|
}
|
|
99
97
|
if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
|
|
100
98
|
const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
|
|
101
99
|
const module = filename.split(".").at(0);
|
|
102
100
|
if (module !== void 0 && SUPPORTED_COMPONENTS.includes(module)) {
|
|
103
|
-
return resolver(context, `${name}/components/${module}`, platform);
|
|
101
|
+
return resolver(context, `${common.name}/components/${module}`, platform);
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
if (moduleName in extraComponents) {
|
|
@@ -129,7 +127,7 @@ const webResolver = (extraComponents) => ({
|
|
|
129
127
|
if (!isIndex || module === void 0 || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${node_path.sep}index.js`)) {
|
|
130
128
|
return resolution;
|
|
131
129
|
}
|
|
132
|
-
return resolver(context, `${name}/components/${module}`, platform);
|
|
130
|
+
return resolver(context, `${common.name}/components/${module}`, platform);
|
|
133
131
|
};
|
|
134
132
|
|
|
135
133
|
const withUniwindConfig = (config, uniwindConfig) => {
|
package/dist/metro/index.mjs
CHANGED
|
@@ -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
|
|
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",
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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,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'
|
package/src/metro/resolvers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
|
|
2
2
|
import { basename, resolve, sep } from 'node:path'
|
|
3
|
-
import { name
|
|
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',
|
package/src/core/index.tsx
DELETED
|
@@ -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
|