@niibase/uniwind 1.4.0 → 1.5.0
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/common/consts.js +18 -0
- package/dist/common/components/native/Pressable.js +13 -2
- package/dist/common/components/native/TouchableHighlight.js +11 -1
- package/dist/common/components/native/TouchableOpacity.js +11 -1
- package/dist/common/core/native/runtime.js +11 -1
- package/dist/common/core/native/store.js +19 -2
- package/dist/common/css/variants.js +1 -1
- package/dist/common/css-visitor/function-visitor.js +9 -0
- package/dist/common/css-visitor/rule-visitor.js +49 -5
- package/dist/metro/index.cjs +2 -2
- package/dist/metro/index.d.ts +1 -0
- package/dist/metro/index.mjs +1 -1
- package/dist/metro/metro-transformer.cjs +47 -11
- package/dist/metro/metro-transformer.mjs +45 -9
- package/dist/module/common/consts.d.ts +11 -0
- package/dist/module/common/consts.js +12 -0
- package/dist/module/components/native/Pressable.d.ts +5 -0
- package/dist/module/components/native/Pressable.js +12 -2
- package/dist/module/components/native/TouchableHighlight.js +11 -1
- package/dist/module/components/native/TouchableOpacity.js +11 -1
- package/dist/module/core/native/parsers/gradient.d.ts +1 -1
- package/dist/module/core/native/runtime.js +5 -2
- package/dist/module/core/native/store.d.ts +1 -0
- package/dist/module/core/native/store.js +19 -2
- package/dist/module/core/types.d.ts +1 -0
- package/dist/module/css/variants.js +1 -1
- package/dist/module/css-visitor/function-visitor.d.ts +1 -0
- package/dist/module/css-visitor/function-visitor.js +3 -0
- package/dist/module/css-visitor/rule-visitor.d.ts +3 -1
- package/dist/module/css-visitor/rule-visitor.js +54 -5
- package/dist/shared/uniwind.B5q8hBGv.cjs +18 -0
- package/dist/shared/{uniwind.D-ahjOrG.mjs → uniwind.BWb5KNML.mjs} +58 -6
- package/dist/shared/{uniwind.CyACT0sD.cjs → uniwind.DTMo4epG.cjs} +58 -6
- package/dist/shared/uniwind.JSWK3vHl.mjs +14 -0
- package/dist/vite/index.cjs +1 -1
- package/dist/vite/index.mjs +1 -1
- package/package.json +19 -13
- package/readme.md +4 -12
- package/src/common/consts.ts +12 -0
- package/src/components/native/Pressable.tsx +17 -1
- package/src/components/native/TouchableHighlight.tsx +10 -0
- package/src/components/native/TouchableOpacity.tsx +10 -0
- package/src/core/config/config.common.ts +1 -2
- package/src/core/native/parsers/gradient.ts +1 -1
- package/src/core/native/runtime.ts +5 -1
- package/src/core/native/store.ts +24 -2
- package/src/core/types.ts +1 -0
- package/src/css/variants.ts +1 -1
- package/src/css-visitor/function-visitor.ts +4 -0
- package/src/css-visitor/rule-visitor.ts +68 -9
- package/src/metro/addMetaToStylesTemplate.ts +9 -3
- package/src/metro/compileVirtual.ts +2 -1
- package/src/metro/index.d.ts +1 -0
- package/src/metro/metro-transformer.ts +19 -2
- package/src/metro/processor/functions.ts +4 -0
- package/src/metro/processor/mq.ts +12 -2
- package/src/metro/processor/processor.ts +3 -2
- package/src/metro/processor/rn.ts +10 -0
- package/src/metro/types.ts +2 -7
- package/src/metro/withUniwindConfig.ts +2 -1
- package/uniwind.css +5 -2
- package/dist/shared/uniwind.BZIuaszw.cjs +0 -11
- package/dist/shared/uniwind.CyoRUwOj.mjs +0 -9
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UNIWIND_THEME_VARIABLES = exports.UNIWIND_PLATFORM_VARIABLES = exports.Platform = void 0;
|
|
7
|
+
var Platform = exports.Platform = /* @__PURE__ */(Platform2 => {
|
|
8
|
+
Platform2["Android"] = "android";
|
|
9
|
+
Platform2["iOS"] = "ios";
|
|
10
|
+
Platform2["Web"] = "web";
|
|
11
|
+
Platform2["Native"] = "native";
|
|
12
|
+
Platform2["TV"] = "tv";
|
|
13
|
+
Platform2["AndroidTV"] = "android-tv";
|
|
14
|
+
Platform2["AppleTV"] = "apple-tv";
|
|
15
|
+
return Platform2;
|
|
16
|
+
})(Platform || {});
|
|
17
|
+
const UNIWIND_PLATFORM_VARIABLES = exports.UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
18
|
+
const UNIWIND_THEME_VARIABLES = exports.UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
@@ -11,17 +11,20 @@ var _utils = require("../utils");
|
|
|
11
11
|
var _useStyle = require("./useStyle");
|
|
12
12
|
const Pressable = exports.Pressable = (0, _utils.copyComponentProperties)(_reactNative.Pressable, props => {
|
|
13
13
|
const [isPressed, setIsPressed] = (0, _react.useState)(false);
|
|
14
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
14
15
|
const {
|
|
15
16
|
Component,
|
|
16
17
|
style
|
|
17
18
|
} = (0, _useStyle.useStyle)(_reactNative.Pressable, props.className, props, {
|
|
18
19
|
isDisabled: Boolean(props.disabled),
|
|
19
|
-
isPressed
|
|
20
|
+
isPressed,
|
|
21
|
+
isFocused
|
|
20
22
|
});
|
|
21
23
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component, {
|
|
22
24
|
...props,
|
|
23
25
|
style: [style, typeof props.style === "function" ? props.style({
|
|
24
|
-
pressed: isPressed
|
|
26
|
+
pressed: isPressed,
|
|
27
|
+
focused: isFocused
|
|
25
28
|
}) : props.style],
|
|
26
29
|
onPressIn: event => {
|
|
27
30
|
setIsPressed(true);
|
|
@@ -30,6 +33,14 @@ const Pressable = exports.Pressable = (0, _utils.copyComponentProperties)(_react
|
|
|
30
33
|
onPressOut: event => {
|
|
31
34
|
setIsPressed(false);
|
|
32
35
|
props.onPressOut?.(event);
|
|
36
|
+
},
|
|
37
|
+
onFocus: event => {
|
|
38
|
+
setIsFocused(true);
|
|
39
|
+
props.onFocus?.(event);
|
|
40
|
+
},
|
|
41
|
+
onBlur: event => {
|
|
42
|
+
setIsFocused(false);
|
|
43
|
+
props.onBlur?.(event);
|
|
33
44
|
}
|
|
34
45
|
});
|
|
35
46
|
});
|
|
@@ -11,9 +11,11 @@ var _utils = require("../utils");
|
|
|
11
11
|
var _useStyle = require("./useStyle");
|
|
12
12
|
const TouchableHighlight = exports.TouchableHighlight = (0, _utils.copyComponentProperties)(_reactNative.TouchableHighlight, props => {
|
|
13
13
|
const [isPressed, setIsPressed] = (0, _react.useState)(false);
|
|
14
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
14
15
|
const state = {
|
|
15
16
|
isDisabled: Boolean(props.disabled),
|
|
16
|
-
isPressed
|
|
17
|
+
isPressed,
|
|
18
|
+
isFocused
|
|
17
19
|
};
|
|
18
20
|
const {
|
|
19
21
|
Component,
|
|
@@ -31,6 +33,14 @@ const TouchableHighlight = exports.TouchableHighlight = (0, _utils.copyComponent
|
|
|
31
33
|
onPressOut: event => {
|
|
32
34
|
setIsPressed(false);
|
|
33
35
|
props.onPressOut?.(event);
|
|
36
|
+
},
|
|
37
|
+
onFocus: event => {
|
|
38
|
+
setIsFocused(true);
|
|
39
|
+
props.onFocus?.(event);
|
|
40
|
+
},
|
|
41
|
+
onBlur: event => {
|
|
42
|
+
setIsFocused(false);
|
|
43
|
+
props.onBlur?.(event);
|
|
34
44
|
}
|
|
35
45
|
});
|
|
36
46
|
});
|
|
@@ -11,9 +11,11 @@ var _utils = require("../utils");
|
|
|
11
11
|
var _useStyle = require("./useStyle");
|
|
12
12
|
const TouchableOpacity = exports.TouchableOpacity = (0, _utils.copyComponentProperties)(_reactNative.TouchableOpacity, props => {
|
|
13
13
|
const [isPressed, setIsPressed] = (0, _react.useState)(false);
|
|
14
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
14
15
|
const state = {
|
|
15
16
|
isDisabled: Boolean(props.disabled),
|
|
16
|
-
isPressed
|
|
17
|
+
isPressed,
|
|
18
|
+
isFocused
|
|
17
19
|
};
|
|
18
20
|
const {
|
|
19
21
|
Component,
|
|
@@ -29,6 +31,14 @@ const TouchableOpacity = exports.TouchableOpacity = (0, _utils.copyComponentProp
|
|
|
29
31
|
onPressOut: event => {
|
|
30
32
|
setIsPressed(false);
|
|
31
33
|
props.onPressOut?.(event);
|
|
34
|
+
},
|
|
35
|
+
onFocus: event => {
|
|
36
|
+
setIsFocused(true);
|
|
37
|
+
props.onFocus?.(event);
|
|
38
|
+
},
|
|
39
|
+
onBlur: event => {
|
|
40
|
+
setIsFocused(false);
|
|
41
|
+
props.onBlur?.(event);
|
|
32
42
|
}
|
|
33
43
|
});
|
|
34
44
|
});
|
|
@@ -34,6 +34,16 @@ const UniwindRuntime = exports.UniwindRuntime = {
|
|
|
34
34
|
steps: _reactNativeReanimated.steps,
|
|
35
35
|
linear: _reactNativeReanimated.linear,
|
|
36
36
|
lightDark: () => "",
|
|
37
|
-
parseColor: _nativeUtils.parseColor
|
|
37
|
+
parseColor: _nativeUtils.parseColor,
|
|
38
|
+
platformSelect: (android, ios, other) => {
|
|
39
|
+
return _reactNative.Platform.select(Boolean(other) ? {
|
|
40
|
+
android,
|
|
41
|
+
ios,
|
|
42
|
+
default: other
|
|
43
|
+
} : {
|
|
44
|
+
android,
|
|
45
|
+
default: ios
|
|
46
|
+
});
|
|
47
|
+
}
|
|
38
48
|
};
|
|
39
49
|
UniwindRuntime.lightDark = _nativeUtils.lightDark.bind(UniwindRuntime);
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UniwindStore = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _consts = require("../../common/consts");
|
|
8
9
|
var _types = require("../../types");
|
|
9
10
|
var _listener = require("../listener");
|
|
10
11
|
var _nativeUtils = require("./native-utils");
|
|
@@ -46,7 +47,13 @@ class UniwindStoreBuilder {
|
|
|
46
47
|
vars,
|
|
47
48
|
keyframes
|
|
48
49
|
} = generateStyleSheetCallback(this.runtime);
|
|
49
|
-
const
|
|
50
|
+
const platform = this.getCurrentPlatform();
|
|
51
|
+
const commonPlatform = platform.includes("tv") ? _consts.Platform.TV : _consts.Platform.Native;
|
|
52
|
+
const commonPlatformVars = scopedVars[`${_consts.UNIWIND_PLATFORM_VARIABLES}${commonPlatform}`];
|
|
53
|
+
const platformVars = scopedVars[`${_consts.UNIWIND_PLATFORM_VARIABLES}${platform}`];
|
|
54
|
+
if (commonPlatformVars) {
|
|
55
|
+
Object.defineProperties(vars, Object.getOwnPropertyDescriptors(commonPlatformVars));
|
|
56
|
+
}
|
|
50
57
|
if (platformVars) {
|
|
51
58
|
Object.defineProperties(vars, Object.getOwnPropertyDescriptors(platformVars));
|
|
52
59
|
}
|
|
@@ -54,7 +61,7 @@ class UniwindStoreBuilder {
|
|
|
54
61
|
this.stylesheet = stylesheet;
|
|
55
62
|
this.vars = Object.fromEntries(themes.map(theme => {
|
|
56
63
|
const clonedVars = (0, _nativeUtils.cloneWithAccessors)(vars);
|
|
57
|
-
const themeVars = scopedVars[
|
|
64
|
+
const themeVars = scopedVars[`${_consts.UNIWIND_THEME_VARIABLES}${theme}`];
|
|
58
65
|
if (themeVars) {
|
|
59
66
|
Object.defineProperties(clonedVars, Object.getOwnPropertyDescriptors(themeVars));
|
|
60
67
|
}
|
|
@@ -217,6 +224,16 @@ class UniwindStoreBuilder {
|
|
|
217
224
|
}
|
|
218
225
|
return true;
|
|
219
226
|
}
|
|
227
|
+
getCurrentPlatform() {
|
|
228
|
+
const platform = _reactNative.Platform.OS;
|
|
229
|
+
if (platform === "android") {
|
|
230
|
+
return _reactNative.Platform.isTV ? _consts.Platform.AndroidTV : _consts.Platform.Android;
|
|
231
|
+
}
|
|
232
|
+
if (platform === "ios") {
|
|
233
|
+
return _reactNative.Platform.isTV ? _consts.Platform.AppleTV : _consts.Platform.iOS;
|
|
234
|
+
}
|
|
235
|
+
return platform;
|
|
236
|
+
}
|
|
220
237
|
}
|
|
221
238
|
const UniwindStore = exports.UniwindStore = new UniwindStoreBuilder();
|
|
222
239
|
_reactNative.Dimensions.addEventListener("change", ({
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateCSSForVariants = void 0;
|
|
7
|
-
const variants = ["ios", "android", "web", "native"];
|
|
7
|
+
const variants = ["ios", "android", "web", "native", "tv", "android-tv", "apple-tv"];
|
|
8
8
|
const generateCSSForVariants = () => {
|
|
9
9
|
let css = "";
|
|
10
10
|
variants.forEach(variant => {
|
|
@@ -13,6 +13,15 @@ const ONE_PX = {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
class FunctionVisitor {
|
|
16
|
+
platformSelect(fn) {
|
|
17
|
+
return fn.arguments.at(0) ?? {
|
|
18
|
+
type: "token",
|
|
19
|
+
value: {
|
|
20
|
+
type: "ident",
|
|
21
|
+
value: "initial"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
16
25
|
pixelRatio(fn) {
|
|
17
26
|
return {
|
|
18
27
|
type: "function",
|
|
@@ -16,9 +16,8 @@ class RuleVisitor {
|
|
|
16
16
|
};
|
|
17
17
|
style = styleRule => {
|
|
18
18
|
const firstSelector = styleRule.value.selectors.at(0)?.at(0);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return this.processThemeStyle(styleRule, secondSelector);
|
|
19
|
+
if (this.currentLayerName === "theme" && firstSelector?.type === "pseudo-class" && firstSelector.kind === "root") {
|
|
20
|
+
return this.removeNulls(this.processThemeRoot(styleRule));
|
|
22
21
|
}
|
|
23
22
|
if (firstSelector?.type === "class") {
|
|
24
23
|
return this.processClassStyle(styleRule, firstSelector);
|
|
@@ -29,14 +28,44 @@ class RuleVisitor {
|
|
|
29
28
|
this.processedClassNames.clear();
|
|
30
29
|
this.processedVariables.clear();
|
|
31
30
|
}
|
|
31
|
+
processThemeRoot(styleRule) {
|
|
32
|
+
const themeScopedRules = styleRule.value.rules?.filter(rule => {
|
|
33
|
+
if (rule.type !== "style") {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const firstSelector = rule.value.selectors.at(0)?.at(0);
|
|
37
|
+
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
38
|
+
return firstSelector?.type === "nesting" && secondSelector?.type === "pseudo-class" && secondSelector.kind === "where";
|
|
39
|
+
}) ?? [];
|
|
40
|
+
const nonThemeRules = styleRule.value.rules?.filter(rule => !themeScopedRules.includes(rule));
|
|
41
|
+
const processedThemeScopedRules = themeScopedRules.map(rule => {
|
|
42
|
+
if (rule.type !== "style") {
|
|
43
|
+
return rule;
|
|
44
|
+
}
|
|
45
|
+
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
46
|
+
if (secondSelector?.type === "pseudo-class" && secondSelector.kind === "where") {
|
|
47
|
+
return this.processThemeStyle(rule, secondSelector);
|
|
48
|
+
}
|
|
49
|
+
return rule;
|
|
50
|
+
});
|
|
51
|
+
return [{
|
|
52
|
+
type: "style",
|
|
53
|
+
value: {
|
|
54
|
+
loc: styleRule.value.loc,
|
|
55
|
+
selectors: styleRule.value.selectors,
|
|
56
|
+
rules: nonThemeRules,
|
|
57
|
+
declarations: styleRule.value.declarations
|
|
58
|
+
}
|
|
59
|
+
}, ...processedThemeScopedRules];
|
|
60
|
+
}
|
|
32
61
|
processThemeStyle(styleRule, secondSelector) {
|
|
33
62
|
const whereSelector = secondSelector.selectors.at(0)?.at(0);
|
|
34
63
|
if (whereSelector?.type !== "class") {
|
|
35
|
-
return;
|
|
64
|
+
return styleRule;
|
|
36
65
|
}
|
|
37
66
|
const selectedVariant = this.themes.find(theme => whereSelector.name === theme);
|
|
38
67
|
if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
|
|
39
|
-
return;
|
|
68
|
+
return styleRule;
|
|
40
69
|
}
|
|
41
70
|
this.processedVariables.add(selectedVariant);
|
|
42
71
|
return {
|
|
@@ -74,5 +103,20 @@ class RuleVisitor {
|
|
|
74
103
|
}
|
|
75
104
|
};
|
|
76
105
|
}
|
|
106
|
+
// Fixes lightningcss serialization bug
|
|
107
|
+
removeNulls(value) {
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
return value.map(v => this.removeNulls(v));
|
|
110
|
+
}
|
|
111
|
+
if (typeof value === "object" && value !== null) {
|
|
112
|
+
return Object.fromEntries(Object.entries(value).filter(([_, value2]) => {
|
|
113
|
+
if (value2 === null) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}).map(([key, value2]) => [key, this.removeNulls(value2)]));
|
|
118
|
+
}
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
77
121
|
}
|
|
78
122
|
exports.RuleVisitor = RuleVisitor;
|
package/dist/metro/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const consts = require('../shared/uniwind.B5q8hBGv.cjs');
|
|
3
4
|
const FileStoreBase = require('metro-cache/private/stores/FileStore');
|
|
4
5
|
const os = require('os');
|
|
5
6
|
const path = require('path');
|
|
6
7
|
const node_path = require('node:path');
|
|
7
8
|
const common = require('../shared/uniwind.nl8746mK.cjs');
|
|
8
|
-
const types = require('../shared/uniwind.BZIuaszw.cjs');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
11
|
|
|
@@ -172,7 +172,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
|
|
|
172
172
|
),
|
|
173
173
|
resolveRequest: (context, moduleName, platform) => {
|
|
174
174
|
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
175
|
-
const platformResolver = (platform ===
|
|
175
|
+
const platformResolver = (platform === consts.Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
|
|
176
176
|
const resolved = platformResolver({
|
|
177
177
|
context,
|
|
178
178
|
moduleName,
|
package/dist/metro/index.d.ts
CHANGED
package/dist/metro/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { P as Platform } from '../shared/uniwind.JSWK3vHl.mjs';
|
|
1
2
|
import FileStoreBase from 'metro-cache/private/stores/FileStore';
|
|
2
3
|
import os from 'os';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import { join, dirname, sep, basename } from 'node:path';
|
|
5
6
|
import { n as name, u as uniq } from '../shared/uniwind.F-0-Rr--.mjs';
|
|
6
|
-
import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
|
|
7
7
|
|
|
8
8
|
class FileStore extends FileStoreBase {
|
|
9
9
|
async set(key, value) {
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const common = require('../shared/uniwind.nl8746mK.cjs');
|
|
6
|
+
const consts = require('../shared/uniwind.B5q8hBGv.cjs');
|
|
6
7
|
const node = require('@tailwindcss/node');
|
|
7
8
|
const oxide = require('@tailwindcss/oxide');
|
|
8
9
|
const lightningcss = require('lightningcss');
|
|
9
|
-
const
|
|
10
|
-
const stringifyThemes = require('../shared/uniwind.CyACT0sD.cjs');
|
|
10
|
+
const stringifyThemes = require('../shared/uniwind.DTMo4epG.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; }
|
|
@@ -163,8 +163,12 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
163
163
|
...rest
|
|
164
164
|
} = style;
|
|
165
165
|
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
|
|
166
|
-
if (platform
|
|
167
|
-
|
|
166
|
+
if (platform) {
|
|
167
|
+
const isTV = currentPlatform === consts.Platform.AndroidTV || currentPlatform === consts.Platform.AppleTV;
|
|
168
|
+
const commonPlatform = isTV ? consts.Platform.TV : consts.Platform.Native;
|
|
169
|
+
if (platform !== commonPlatform && platform !== currentPlatform) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
168
172
|
}
|
|
169
173
|
if (entries.length === 0) {
|
|
170
174
|
return null;
|
|
@@ -1118,6 +1122,9 @@ class Functions {
|
|
|
1118
1122
|
if (fn.name === "hairlineWidth") {
|
|
1119
1123
|
return "rt.hairlineWidth";
|
|
1120
1124
|
}
|
|
1125
|
+
if (fn.name === "platformSelect") {
|
|
1126
|
+
return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
1127
|
+
}
|
|
1121
1128
|
if (fn.name === "pixelRatio") {
|
|
1122
1129
|
if (fn.arguments.length === 0) {
|
|
1123
1130
|
return "rt.pixelRatio(1)";
|
|
@@ -1187,7 +1194,14 @@ class MQ {
|
|
|
1187
1194
|
const mq = this.getInitialMediaQueryResolver();
|
|
1188
1195
|
for (const mediaQuery of mediaQueries) {
|
|
1189
1196
|
const { condition, mediaType } = mediaQuery;
|
|
1190
|
-
if ([
|
|
1197
|
+
if ([
|
|
1198
|
+
consts.Platform.Android,
|
|
1199
|
+
consts.Platform.iOS,
|
|
1200
|
+
consts.Platform.Native,
|
|
1201
|
+
consts.Platform.AndroidTV,
|
|
1202
|
+
consts.Platform.AppleTV,
|
|
1203
|
+
consts.Platform.TV
|
|
1204
|
+
].includes(mediaType)) {
|
|
1191
1205
|
mq.platform = mediaType;
|
|
1192
1206
|
continue;
|
|
1193
1207
|
}
|
|
@@ -1422,7 +1436,17 @@ const cssToRNMap = {
|
|
|
1422
1436
|
},
|
|
1423
1437
|
fontVariantNumeric: (value) => ({
|
|
1424
1438
|
fontVariant: value
|
|
1425
|
-
})
|
|
1439
|
+
}),
|
|
1440
|
+
display: (value) => {
|
|
1441
|
+
if (value === '"box"') {
|
|
1442
|
+
return {
|
|
1443
|
+
display: '"flex"'
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
return {
|
|
1447
|
+
display: value
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1426
1450
|
};
|
|
1427
1451
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1428
1452
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
@@ -1686,7 +1710,7 @@ class ProcessorBuilder {
|
|
|
1686
1710
|
return this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
1687
1711
|
}
|
|
1688
1712
|
if (mq.platform !== null) {
|
|
1689
|
-
const platformKey =
|
|
1713
|
+
const platformKey = `${consts.UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
|
|
1690
1714
|
this.scopedVars[platformKey] ??= {};
|
|
1691
1715
|
return this.scopedVars[platformKey];
|
|
1692
1716
|
}
|
|
@@ -1698,7 +1722,7 @@ class ProcessorBuilder {
|
|
|
1698
1722
|
if (this.declarationConfig.theme === null) {
|
|
1699
1723
|
return this.vars;
|
|
1700
1724
|
}
|
|
1701
|
-
const themeKey =
|
|
1725
|
+
const themeKey = `${consts.UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
|
|
1702
1726
|
this.scopedVars[themeKey] ??= {};
|
|
1703
1727
|
return this.scopedVars[themeKey];
|
|
1704
1728
|
})();
|
|
@@ -1950,7 +1974,7 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
1950
1974
|
]
|
|
1951
1975
|
});
|
|
1952
1976
|
const tailwindCSS = compiler.build(candidates ?? scanner.scan());
|
|
1953
|
-
if (platform ===
|
|
1977
|
+
if (platform === consts.Platform.Web) {
|
|
1954
1978
|
return lightningcss.transform({
|
|
1955
1979
|
code: Buffer.from(tailwindCSS),
|
|
1956
1980
|
filename: "uniwind.css",
|
|
@@ -2032,6 +2056,18 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2032
2056
|
if (!isCss) {
|
|
2033
2057
|
return worker.transform(config, projectRoot, filePath, data, options);
|
|
2034
2058
|
}
|
|
2059
|
+
const getPlatform = () => {
|
|
2060
|
+
if (!config.uniwind.isTV) {
|
|
2061
|
+
return options.platform;
|
|
2062
|
+
}
|
|
2063
|
+
if (options.platform === consts.Platform.Android) {
|
|
2064
|
+
return consts.Platform.AndroidTV;
|
|
2065
|
+
}
|
|
2066
|
+
if (options.platform === consts.Platform.iOS) {
|
|
2067
|
+
return consts.Platform.AppleTV;
|
|
2068
|
+
}
|
|
2069
|
+
throw new Error(`Platform ${options.platform} not supported`);
|
|
2070
|
+
};
|
|
2035
2071
|
const cssPath = path__default.join(process.cwd(), config.uniwind.cssEntryFile);
|
|
2036
2072
|
const injectedThemesCode = await injectThemes({
|
|
2037
2073
|
input: cssPath,
|
|
@@ -2039,7 +2075,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2039
2075
|
dtsPath: config.uniwind.dtsFile
|
|
2040
2076
|
});
|
|
2041
2077
|
const css = fs__default.readFileSync(filePath, "utf-8");
|
|
2042
|
-
const platform =
|
|
2078
|
+
const platform = getPlatform();
|
|
2043
2079
|
const virtualCode = await compileVirtual({
|
|
2044
2080
|
css,
|
|
2045
2081
|
platform,
|
|
@@ -2048,7 +2084,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2048
2084
|
cssPath,
|
|
2049
2085
|
debug: config.uniwind.debug
|
|
2050
2086
|
});
|
|
2051
|
-
const isWeb = platform ===
|
|
2087
|
+
const isWeb = platform === consts.Platform.Web;
|
|
2052
2088
|
data = Buffer.from(
|
|
2053
2089
|
isWeb ? virtualCode : [
|
|
2054
2090
|
`import { Uniwind } from '${common.name}';`,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, c as isDefined, d as deepEqual, e as shouldBeSerialized, f as removeKeys, n as name } from '../shared/uniwind.F-0-Rr--.mjs';
|
|
4
|
+
import { P as Platform, U as UNIWIND_PLATFORM_VARIABLES, a as UNIWIND_THEME_VARIABLES } from '../shared/uniwind.JSWK3vHl.mjs';
|
|
4
5
|
import { compile } from '@tailwindcss/node';
|
|
5
6
|
import { Scanner } from '@tailwindcss/oxide';
|
|
6
7
|
import { transform as transform$1 } from 'lightningcss';
|
|
7
|
-
import {
|
|
8
|
-
import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.D-ahjOrG.mjs';
|
|
8
|
+
import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.BWb5KNML.mjs';
|
|
9
9
|
import { converter, parse, formatHex, formatHex8 } from 'culori';
|
|
10
10
|
|
|
11
11
|
const parseStringValue = (value) => {
|
|
@@ -156,8 +156,12 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
156
156
|
...rest
|
|
157
157
|
} = style;
|
|
158
158
|
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
|
|
159
|
-
if (platform
|
|
160
|
-
|
|
159
|
+
if (platform) {
|
|
160
|
+
const isTV = currentPlatform === Platform.AndroidTV || currentPlatform === Platform.AppleTV;
|
|
161
|
+
const commonPlatform = isTV ? Platform.TV : Platform.Native;
|
|
162
|
+
if (platform !== commonPlatform && platform !== currentPlatform) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
161
165
|
}
|
|
162
166
|
if (entries.length === 0) {
|
|
163
167
|
return null;
|
|
@@ -1111,6 +1115,9 @@ class Functions {
|
|
|
1111
1115
|
if (fn.name === "hairlineWidth") {
|
|
1112
1116
|
return "rt.hairlineWidth";
|
|
1113
1117
|
}
|
|
1118
|
+
if (fn.name === "platformSelect") {
|
|
1119
|
+
return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
1120
|
+
}
|
|
1114
1121
|
if (fn.name === "pixelRatio") {
|
|
1115
1122
|
if (fn.arguments.length === 0) {
|
|
1116
1123
|
return "rt.pixelRatio(1)";
|
|
@@ -1180,7 +1187,14 @@ class MQ {
|
|
|
1180
1187
|
const mq = this.getInitialMediaQueryResolver();
|
|
1181
1188
|
for (const mediaQuery of mediaQueries) {
|
|
1182
1189
|
const { condition, mediaType } = mediaQuery;
|
|
1183
|
-
if ([
|
|
1190
|
+
if ([
|
|
1191
|
+
Platform.Android,
|
|
1192
|
+
Platform.iOS,
|
|
1193
|
+
Platform.Native,
|
|
1194
|
+
Platform.AndroidTV,
|
|
1195
|
+
Platform.AppleTV,
|
|
1196
|
+
Platform.TV
|
|
1197
|
+
].includes(mediaType)) {
|
|
1184
1198
|
mq.platform = mediaType;
|
|
1185
1199
|
continue;
|
|
1186
1200
|
}
|
|
@@ -1415,7 +1429,17 @@ const cssToRNMap = {
|
|
|
1415
1429
|
},
|
|
1416
1430
|
fontVariantNumeric: (value) => ({
|
|
1417
1431
|
fontVariant: value
|
|
1418
|
-
})
|
|
1432
|
+
}),
|
|
1433
|
+
display: (value) => {
|
|
1434
|
+
if (value === '"box"') {
|
|
1435
|
+
return {
|
|
1436
|
+
display: '"flex"'
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
return {
|
|
1440
|
+
display: value
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1419
1443
|
};
|
|
1420
1444
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1421
1445
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
@@ -1679,7 +1703,7 @@ class ProcessorBuilder {
|
|
|
1679
1703
|
return this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
1680
1704
|
}
|
|
1681
1705
|
if (mq.platform !== null) {
|
|
1682
|
-
const platformKey =
|
|
1706
|
+
const platformKey = `${UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
|
|
1683
1707
|
this.scopedVars[platformKey] ??= {};
|
|
1684
1708
|
return this.scopedVars[platformKey];
|
|
1685
1709
|
}
|
|
@@ -1691,7 +1715,7 @@ class ProcessorBuilder {
|
|
|
1691
1715
|
if (this.declarationConfig.theme === null) {
|
|
1692
1716
|
return this.vars;
|
|
1693
1717
|
}
|
|
1694
|
-
const themeKey =
|
|
1718
|
+
const themeKey = `${UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
|
|
1695
1719
|
this.scopedVars[themeKey] ??= {};
|
|
1696
1720
|
return this.scopedVars[themeKey];
|
|
1697
1721
|
})();
|
|
@@ -2025,6 +2049,18 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2025
2049
|
if (!isCss) {
|
|
2026
2050
|
return worker.transform(config, projectRoot, filePath, data, options);
|
|
2027
2051
|
}
|
|
2052
|
+
const getPlatform = () => {
|
|
2053
|
+
if (!config.uniwind.isTV) {
|
|
2054
|
+
return options.platform;
|
|
2055
|
+
}
|
|
2056
|
+
if (options.platform === Platform.Android) {
|
|
2057
|
+
return Platform.AndroidTV;
|
|
2058
|
+
}
|
|
2059
|
+
if (options.platform === Platform.iOS) {
|
|
2060
|
+
return Platform.AppleTV;
|
|
2061
|
+
}
|
|
2062
|
+
throw new Error(`Platform ${options.platform} not supported`);
|
|
2063
|
+
};
|
|
2028
2064
|
const cssPath = path.join(process.cwd(), config.uniwind.cssEntryFile);
|
|
2029
2065
|
const injectedThemesCode = await injectThemes({
|
|
2030
2066
|
input: cssPath,
|
|
@@ -2032,7 +2068,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2032
2068
|
dtsPath: config.uniwind.dtsFile
|
|
2033
2069
|
});
|
|
2034
2070
|
const css = fs.readFileSync(filePath, "utf-8");
|
|
2035
|
-
const platform =
|
|
2071
|
+
const platform = getPlatform();
|
|
2036
2072
|
const virtualCode = await compileVirtual({
|
|
2037
2073
|
css,
|
|
2038
2074
|
platform,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const enum Platform {
|
|
2
|
+
Android = "android",
|
|
3
|
+
iOS = "ios",
|
|
4
|
+
Web = "web",
|
|
5
|
+
Native = "native",
|
|
6
|
+
TV = "tv",
|
|
7
|
+
AndroidTV = "android-tv",
|
|
8
|
+
AppleTV = "apple-tv"
|
|
9
|
+
}
|
|
10
|
+
export declare const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
11
|
+
export declare const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
2
|
+
Platform2["Android"] = "android";
|
|
3
|
+
Platform2["iOS"] = "ios";
|
|
4
|
+
Platform2["Web"] = "web";
|
|
5
|
+
Platform2["Native"] = "native";
|
|
6
|
+
Platform2["TV"] = "tv";
|
|
7
|
+
Platform2["AndroidTV"] = "android-tv";
|
|
8
|
+
Platform2["AppleTV"] = "apple-tv";
|
|
9
|
+
return Platform2;
|
|
10
|
+
})(Platform || {});
|
|
11
|
+
export const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
12
|
+
export const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { PressableProps } from 'react-native';
|
|
2
|
+
declare module 'react-native' {
|
|
3
|
+
interface PressableStateCallbackType {
|
|
4
|
+
focused?: boolean;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
2
7
|
export declare const Pressable: import("react").ForwardRefExoticComponent<PressableProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
8
|
export default Pressable;
|
|
@@ -5,9 +5,11 @@ import { copyComponentProperties } from "../utils.js";
|
|
|
5
5
|
import { useStyle } from "./useStyle.js";
|
|
6
6
|
export const Pressable = copyComponentProperties(RNPressable, (props) => {
|
|
7
7
|
const [isPressed, setIsPressed] = useState(false);
|
|
8
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
8
9
|
const { Component, style } = useStyle(RNPressable, props.className, props, {
|
|
9
10
|
isDisabled: Boolean(props.disabled),
|
|
10
|
-
isPressed
|
|
11
|
+
isPressed,
|
|
12
|
+
isFocused
|
|
11
13
|
});
|
|
12
14
|
return /* @__PURE__ */ jsx(
|
|
13
15
|
Component,
|
|
@@ -15,7 +17,7 @@ export const Pressable = copyComponentProperties(RNPressable, (props) => {
|
|
|
15
17
|
...props,
|
|
16
18
|
style: [
|
|
17
19
|
style,
|
|
18
|
-
typeof props.style === "function" ? props.style({ pressed: isPressed }) : props.style
|
|
20
|
+
typeof props.style === "function" ? props.style({ pressed: isPressed, focused: isFocused }) : props.style
|
|
19
21
|
],
|
|
20
22
|
onPressIn: (event) => {
|
|
21
23
|
setIsPressed(true);
|
|
@@ -24,6 +26,14 @@ export const Pressable = copyComponentProperties(RNPressable, (props) => {
|
|
|
24
26
|
onPressOut: (event) => {
|
|
25
27
|
setIsPressed(false);
|
|
26
28
|
props.onPressOut?.(event);
|
|
29
|
+
},
|
|
30
|
+
onFocus: (event) => {
|
|
31
|
+
setIsFocused(true);
|
|
32
|
+
props.onFocus?.(event);
|
|
33
|
+
},
|
|
34
|
+
onBlur: (event) => {
|
|
35
|
+
setIsFocused(false);
|
|
36
|
+
props.onBlur?.(event);
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
);
|