@niibase/uniwind 1.6.2 → 1.6.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.
- package/CHANGELOG.md +45 -0
- package/dist/common/common/utils.js +9 -2
- package/dist/common/components/index.js +0 -3
- package/dist/common/core/config/config.common.js +10 -7
- package/dist/common/core/config/config.js +42 -23
- package/dist/common/core/config/config.native.js +1 -3
- package/dist/common/core/web/cssListener.js +1 -1
- package/dist/common/hooks/useCSSVariable/index.js +7 -11
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +22 -23
- package/dist/metro/index.cjs +10 -4
- package/dist/metro/index.mjs +11 -5
- package/dist/metro/metro-transformer.cjs +15 -4
- package/dist/metro/metro-transformer.mjs +15 -4
- package/dist/module/common/utils.d.ts +1 -0
- package/dist/module/common/utils.js +6 -0
- package/dist/module/components/index.js +0 -3
- package/dist/module/core/config/config.common.d.ts +3 -1
- package/dist/module/core/config/config.common.js +7 -4
- package/dist/module/core/config/config.d.ts +4 -4
- package/dist/module/core/config/config.js +44 -25
- package/dist/module/core/config/config.native.js +1 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/hooks/useCSSVariable/index.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/index.js +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +19 -21
- package/package.json +3 -3
- package/src/common/utils.ts +8 -0
- package/src/components/index.ts +0 -3
- package/src/core/config/config.common.ts +9 -7
- package/src/core/config/config.native.ts +1 -3
- package/src/core/config/config.ts +61 -29
- package/src/core/logger.ts +0 -2
- package/src/core/native/parsers/transforms.ts +0 -1
- package/src/core/native/store.ts +0 -1
- package/src/core/web/cssListener.ts +2 -3
- package/src/hoc/withUniwind.native.tsx +0 -1
- package/src/hooks/useCSSVariable/index.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +27 -31
- package/src/metro/addMetaToStylesTemplate.ts +1 -2
- package/src/metro/logger.ts +0 -2
- package/src/metro/metro-css-patches.ts +1 -2
- package/src/metro/metro-transformer.ts +1 -1
- package/src/metro/processor/css.ts +0 -1
- package/src/metro/processor/functions.ts +0 -1
- package/src/metro/processor/rn.ts +19 -0
- package/src/metro/resolvers.ts +12 -13
- package/src/metro/utils/common.ts +0 -1
- package/src/metro/utils/serialize.ts +0 -1
- package/src/types.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
## What's Changed in 1.6.4
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
* getCSSVariable function to get css variable outside of react (#521) by @Brentlok
|
|
8
|
+
* parse inline-start inline-end border to RN (#515) by @Brentlok
|
|
9
|
+
|
|
10
|
+
### 🐛 Bug Fixes
|
|
11
|
+
|
|
12
|
+
* join border radius to fix some components (#517) by @Brentlok
|
|
13
|
+
* remove deprecated push notification ios export (#516) by @Brentlok
|
|
14
|
+
|
|
15
|
+
### 📦 Other
|
|
16
|
+
|
|
17
|
+
* Merge branch 'pre-release' by @divineniiquaye
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
**Full Changelog**: https://github.com/divineniiquaye/uniwind/compare/v1.6.3...v1.6.4
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## What's Changed in 1.6.3
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### 🐛 Bug Fixes
|
|
28
|
+
|
|
29
|
+
* use node resolver to prevent escaped traversal errors (#506) by @Brentlok
|
|
30
|
+
* updateCSSVariable inside scoped theme (#502) by @Brentlok
|
|
31
|
+
* inject cjs instead of esm to initialize (#501) by @Brentlok
|
|
32
|
+
|
|
33
|
+
### 🏠 Chores
|
|
34
|
+
|
|
35
|
+
* update config attributes and lint rules (#504) by @Brentlok
|
|
36
|
+
* use oxlint instead of eslint (#503) by @Brentlok
|
|
37
|
+
|
|
38
|
+
### 📦 Other
|
|
39
|
+
|
|
40
|
+
* Merge branch 'pre-release' by @divineniiquaye
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
**Full Changelog**: https://github.com/divineniiquaye/uniwind/compare/v1.6.2...v1.6.3
|
|
44
|
+
|
|
45
|
+
|
|
1
46
|
## What's Changed in 1.6.2
|
|
2
47
|
|
|
3
48
|
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isDefined = void 0;
|
|
6
|
+
exports.isDefined = exports.arrayEquals = void 0;
|
|
7
7
|
const isDefined = value => value !== void 0 && value !== null;
|
|
8
|
-
exports.isDefined = isDefined;
|
|
8
|
+
exports.isDefined = isDefined;
|
|
9
|
+
const arrayEquals = (a, b) => {
|
|
10
|
+
if (a.length !== b.length) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return a.every((value, index) => value === b[index]);
|
|
14
|
+
};
|
|
15
|
+
exports.arrayEquals = arrayEquals;
|
|
@@ -197,9 +197,6 @@ module.exports = {
|
|
|
197
197
|
get PlatformColor() {
|
|
198
198
|
return require("react-native").PlatformColor;
|
|
199
199
|
},
|
|
200
|
-
get PushNotificationIOS() {
|
|
201
|
-
return require("react-native").PushNotificationIOS;
|
|
202
|
-
},
|
|
203
200
|
get processColor() {
|
|
204
201
|
return require("react-native").processColor;
|
|
205
202
|
},
|
|
@@ -7,6 +7,7 @@ exports.UniwindConfigBuilder = exports.Uniwind = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _withUniwind = require("../../hoc/withUniwind");
|
|
10
|
+
var _useCSSVariable = require("../../hooks/useCSSVariable/useCSSVariable");
|
|
10
11
|
var _types = require("../../types");
|
|
11
12
|
var _listener = require("../listener");
|
|
12
13
|
const SYSTEM_THEME = "system";
|
|
@@ -84,13 +85,15 @@ class UniwindConfigBuilder {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
89
|
+
updateCSSVariables(theme, cssVariables) {}
|
|
90
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
91
|
+
updateInsets(insets) {}
|
|
92
|
+
getCSSVariable = variableName => {
|
|
93
|
+
return (0, _useCSSVariable.getCSSVariable)(variableName, {
|
|
94
|
+
scopedTheme: null
|
|
95
|
+
});
|
|
96
|
+
};
|
|
94
97
|
__reinit(_, themes) {
|
|
95
98
|
this._themes = themes;
|
|
96
99
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
30
|
-
_listener.UniwindListener.notify([_types.StyleDependency.Variables]);
|
|
31
|
-
}
|
|
38
|
+
_listener.UniwindListener.notify([_types.StyleDependency.Variables]);
|
|
32
39
|
}
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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();
|
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return _useCSSVariable[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
6
|
+
Object.defineProperty(exports, "useCSSVariable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useCSSVariable.useCSSVariable;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useCSSVariable = require("./useCSSVariable");
|
|
@@ -3,58 +3,57 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useCSSVariable = void 0;
|
|
6
|
+
exports.useCSSVariable = exports.getCSSVariable = 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
|
-
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
14
|
let warned = false;
|
|
21
15
|
const logDevError = name => {
|
|
22
16
|
warned = true;
|
|
23
17
|
_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`);
|
|
24
18
|
};
|
|
19
|
+
const getCSSVariable = (name, uniwindContext) => {
|
|
20
|
+
const value = Array.isArray(name) ? name.map(name2 => (0, _getVariableValue.getVariableValue)(name2, uniwindContext)) : (0, _getVariableValue.getVariableValue)(name, uniwindContext);
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
value.forEach((val, index) => {
|
|
23
|
+
if (val === void 0 && __DEV__ && !warned) {
|
|
24
|
+
logDevError(name[index] ?? "");
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (value === void 0 && __DEV__ && !warned) {
|
|
29
|
+
logDevError(name);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
exports.getCSSVariable = getCSSVariable;
|
|
25
34
|
const useCSSVariable = name => {
|
|
26
35
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
27
|
-
const [value, setValue] = (0, _react.useState)(
|
|
36
|
+
const [value, setValue] = (0, _react.useState)(getCSSVariable(name, uniwindContext));
|
|
28
37
|
const nameRef = (0, _react.useRef)(name);
|
|
29
38
|
(0, _react.useLayoutEffect)(() => {
|
|
30
39
|
if (Array.isArray(name) && Array.isArray(nameRef.current)) {
|
|
31
|
-
if (arrayEquals(name, nameRef.current)) {
|
|
40
|
+
if ((0, _utils.arrayEquals)(name, nameRef.current)) {
|
|
32
41
|
return;
|
|
33
42
|
}
|
|
34
|
-
setValue(
|
|
43
|
+
setValue(getCSSVariable(name, uniwindContext));
|
|
35
44
|
nameRef.current = name;
|
|
36
45
|
return;
|
|
37
46
|
}
|
|
38
47
|
if (name !== nameRef.current) {
|
|
39
|
-
setValue(
|
|
48
|
+
setValue(getCSSVariable(name, uniwindContext));
|
|
40
49
|
nameRef.current = name;
|
|
41
50
|
}
|
|
42
51
|
}, [name]);
|
|
43
52
|
(0, _react.useLayoutEffect)(() => {
|
|
44
|
-
const updateValue = () => setValue(
|
|
53
|
+
const updateValue = () => setValue(getCSSVariable(nameRef.current, uniwindContext));
|
|
45
54
|
const dispose = _listener.UniwindListener.subscribe(updateValue, [_types.StyleDependency.Theme, _types.StyleDependency.Variables]);
|
|
46
55
|
return dispose;
|
|
47
56
|
}, [uniwindContext]);
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
value.forEach((val, index) => {
|
|
50
|
-
if (val === void 0 && __DEV__ && !warned) {
|
|
51
|
-
logDevError(name[index] ?? "");
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (value === void 0 && __DEV__ && !warned) {
|
|
56
|
-
logDevError(name);
|
|
57
|
-
}
|
|
58
57
|
return value;
|
|
59
58
|
};
|
|
60
59
|
exports.useCSSVariable = useCSSVariable;
|
package/dist/metro/index.cjs
CHANGED
|
@@ -78,8 +78,11 @@ const nativeResolver = (extraComponents) => ({
|
|
|
78
78
|
}) => {
|
|
79
79
|
const resolution = resolver(context, moduleName, platform);
|
|
80
80
|
if (cachedInternalBasePath === null) {
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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;
|
package/dist/metro/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ 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 {
|
|
5
|
+
import { dirname, sep, basename } from 'node:path';
|
|
6
6
|
import { n as name, u as uniq } from '../shared/uniwind.PtWWxxnh.mjs';
|
|
7
7
|
|
|
8
8
|
class FileStore extends FileStoreBase {
|
|
@@ -70,8 +70,11 @@ const nativeResolver = (extraComponents) => ({
|
|
|
70
70
|
}) => {
|
|
71
71
|
const resolution = resolver(context, moduleName, platform);
|
|
72
72
|
if (cachedInternalBasePath === null) {
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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;
|
|
@@ -158,8 +158,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
158
158
|
minWidth,
|
|
159
159
|
maxWidth,
|
|
160
160
|
colorScheme,
|
|
161
|
-
|
|
162
|
-
important,
|
|
161
|
+
important: _,
|
|
163
162
|
importantProperties,
|
|
164
163
|
active,
|
|
165
164
|
focus,
|
|
@@ -961,7 +960,6 @@ class CSS {
|
|
|
961
960
|
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
|
|
962
961
|
return void 0;
|
|
963
962
|
}
|
|
964
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
965
963
|
static TRANSFORM_TYPES = /* @__PURE__ */ new Set([
|
|
966
964
|
"translate",
|
|
967
965
|
"translateX",
|
|
@@ -1487,6 +1485,7 @@ const cssToRNMap = {
|
|
|
1487
1485
|
};
|
|
1488
1486
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1489
1487
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
1488
|
+
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
1490
1489
|
class RN {
|
|
1491
1490
|
constructor(Processor) {
|
|
1492
1491
|
this.Processor = Processor;
|
|
@@ -1498,6 +1497,9 @@ class RN {
|
|
|
1498
1497
|
if (x.includes("padding") || x.includes("margin")) {
|
|
1499
1498
|
return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
|
|
1500
1499
|
}
|
|
1500
|
+
if (x.includes("border")) {
|
|
1501
|
+
return x.replace("InlineStart", "Start").replace("InlineEnd", "End");
|
|
1502
|
+
}
|
|
1501
1503
|
return x;
|
|
1502
1504
|
}
|
|
1503
1505
|
);
|
|
@@ -1601,6 +1603,15 @@ class RN {
|
|
|
1601
1603
|
};
|
|
1602
1604
|
}
|
|
1603
1605
|
}
|
|
1606
|
+
if (BORDER_RADIUS_KEYS.every((key) => keys.includes(key))) {
|
|
1607
|
+
const borderRadius = styles.borderTopLeftRadius;
|
|
1608
|
+
if (BORDER_RADIUS_KEYS.every((key) => styles[key] === borderRadius)) {
|
|
1609
|
+
return {
|
|
1610
|
+
...common.removeKeys(styles, BORDER_RADIUS_KEYS),
|
|
1611
|
+
borderRadius
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1604
1615
|
return styles;
|
|
1605
1616
|
}
|
|
1606
1617
|
}
|
|
@@ -2124,7 +2135,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2124
2135
|
const isWeb = platform === consts.Platform.Web;
|
|
2125
2136
|
data = Buffer.from(
|
|
2126
2137
|
isWeb ? virtualCode : [
|
|
2127
|
-
`
|
|
2138
|
+
`const { Uniwind } = require('${common.name}');`,
|
|
2128
2139
|
`Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`
|
|
2129
2140
|
].join(""),
|
|
2130
2141
|
"utf-8"
|
|
@@ -151,8 +151,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
151
151
|
minWidth,
|
|
152
152
|
maxWidth,
|
|
153
153
|
colorScheme,
|
|
154
|
-
|
|
155
|
-
important,
|
|
154
|
+
important: _,
|
|
156
155
|
importantProperties,
|
|
157
156
|
active,
|
|
158
157
|
focus,
|
|
@@ -954,7 +953,6 @@ class CSS {
|
|
|
954
953
|
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
|
|
955
954
|
return void 0;
|
|
956
955
|
}
|
|
957
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
958
956
|
static TRANSFORM_TYPES = /* @__PURE__ */ new Set([
|
|
959
957
|
"translate",
|
|
960
958
|
"translateX",
|
|
@@ -1480,6 +1478,7 @@ const cssToRNMap = {
|
|
|
1480
1478
|
};
|
|
1481
1479
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1482
1480
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
1481
|
+
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
1483
1482
|
class RN {
|
|
1484
1483
|
constructor(Processor) {
|
|
1485
1484
|
this.Processor = Processor;
|
|
@@ -1491,6 +1490,9 @@ class RN {
|
|
|
1491
1490
|
if (x.includes("padding") || x.includes("margin")) {
|
|
1492
1491
|
return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
|
|
1493
1492
|
}
|
|
1493
|
+
if (x.includes("border")) {
|
|
1494
|
+
return x.replace("InlineStart", "Start").replace("InlineEnd", "End");
|
|
1495
|
+
}
|
|
1494
1496
|
return x;
|
|
1495
1497
|
}
|
|
1496
1498
|
);
|
|
@@ -1594,6 +1596,15 @@ class RN {
|
|
|
1594
1596
|
};
|
|
1595
1597
|
}
|
|
1596
1598
|
}
|
|
1599
|
+
if (BORDER_RADIUS_KEYS.every((key) => keys.includes(key))) {
|
|
1600
|
+
const borderRadius = styles.borderTopLeftRadius;
|
|
1601
|
+
if (BORDER_RADIUS_KEYS.every((key) => styles[key] === borderRadius)) {
|
|
1602
|
+
return {
|
|
1603
|
+
...removeKeys(styles, BORDER_RADIUS_KEYS),
|
|
1604
|
+
borderRadius
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1597
1608
|
return styles;
|
|
1598
1609
|
}
|
|
1599
1610
|
}
|
|
@@ -2117,7 +2128,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2117
2128
|
const isWeb = platform === Platform.Web;
|
|
2118
2129
|
data = Buffer.from(
|
|
2119
2130
|
isWeb ? virtualCode : [
|
|
2120
|
-
`
|
|
2131
|
+
`const { Uniwind } = require('${name}');`,
|
|
2121
2132
|
`Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`
|
|
2122
2133
|
].join(""),
|
|
2123
2134
|
"utf-8"
|
|
@@ -195,9 +195,6 @@ module.exports = {
|
|
|
195
195
|
get PlatformColor() {
|
|
196
196
|
return require("react-native").PlatformColor;
|
|
197
197
|
},
|
|
198
|
-
get PushNotificationIOS() {
|
|
199
|
-
return require("react-native").PushNotificationIOS;
|
|
200
|
-
},
|
|
201
198
|
get processColor() {
|
|
202
199
|
return require("react-native").processColor;
|
|
203
200
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithRef, ElementType } from 'react';
|
|
2
2
|
import { Insets } from 'react-native';
|
|
3
3
|
import { ApplyUniwind } from '../../hoc/types';
|
|
4
|
+
import { GetCSSVariable } from '../../hooks/useCSSVariable/useCSSVariable';
|
|
4
5
|
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
5
6
|
declare const SYSTEM_THEME: "system";
|
|
6
7
|
export declare class UniwindConfigBuilder {
|
|
@@ -15,8 +16,9 @@ export declare class UniwindConfigBuilder {
|
|
|
15
16
|
as: T;
|
|
16
17
|
} & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
|
|
17
18
|
setTheme(theme: ThemeName | typeof SYSTEM_THEME): void;
|
|
18
|
-
updateCSSVariables(theme: ThemeName,
|
|
19
|
+
updateCSSVariables(theme: ThemeName, cssVariables: CSSVariables): void;
|
|
19
20
|
updateInsets(insets: Insets): void;
|
|
21
|
+
getCSSVariable: GetCSSVariable;
|
|
20
22
|
protected __reinit(_: GenerateStyleSheetsCallback, themes: Array<string>): void;
|
|
21
23
|
protected onThemeChange(): void;
|
|
22
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createElement, useMemo } from "react";
|
|
2
2
|
import { Appearance, Platform } from "react-native";
|
|
3
3
|
import { withUniwind } from "../../hoc/withUniwind.js";
|
|
4
|
+
import { getCSSVariable } from "../../hooks/useCSSVariable/useCSSVariable.js";
|
|
4
5
|
import { ColorScheme, StyleDependency } from "../../types.js";
|
|
5
6
|
import { UniwindListener } from "../listener.js";
|
|
6
7
|
const SYSTEM_THEME = "system";
|
|
@@ -76,13 +77,15 @@ export class UniwindConfigBuilder {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
variables;
|
|
80
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
81
|
+
updateCSSVariables(theme, cssVariables) {
|
|
82
82
|
}
|
|
83
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
83
84
|
updateInsets(insets) {
|
|
84
|
-
insets;
|
|
85
85
|
}
|
|
86
|
+
getCSSVariable = ((variableName) => {
|
|
87
|
+
return getCSSVariable(variableName, { scopedTheme: null });
|
|
88
|
+
});
|
|
86
89
|
__reinit(_, themes) {
|
|
87
90
|
this._themes = themes;
|
|
88
91
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CSSVariables, ThemeName } from '../types';
|
|
1
|
+
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
2
2
|
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common';
|
|
3
3
|
declare class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
4
|
-
private
|
|
4
|
+
private cssRules?;
|
|
5
5
|
constructor();
|
|
6
6
|
updateCSSVariables(theme: ThemeName, variables: CSSVariables): void;
|
|
7
|
-
protected
|
|
8
|
-
private
|
|
7
|
+
protected __reinit(generateStyleSheetCallback: GenerateStyleSheetsCallback, themes: Array<string>): void;
|
|
8
|
+
private getUniwindDynamicCSSRules;
|
|
9
9
|
}
|
|
10
10
|
export declare const Uniwind: UniwindConfigBuilder;
|
|
11
11
|
export {};
|