@niibase/uniwind 1.7.0 → 1.8.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/CHANGELOG.md +35 -0
- package/dist/cli/index.cjs +91 -0
- package/dist/cli/index.mjs +84 -0
- package/dist/common/bundler/artifacts/css/themes.js +3 -0
- package/dist/common/bundler/cli/index.js +76 -0
- package/dist/common/bundler/config.js +6 -0
- package/dist/common/bundler/css-compiler/compileNativeCSS.js +3 -3
- package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +3 -3
- package/dist/common/bundler/css-processor/color.js +1 -1
- package/dist/common/bundler/css-processor/css.js +2 -2
- package/dist/common/bundler/css-processor/processor.js +7 -7
- package/dist/common/bundler/css-processor/units.js +1 -1
- package/dist/common/bundler/css-processor/utils.js +3 -5
- package/dist/common/bundler/css-processor/var.js +1 -1
- package/dist/common/bundler/css-visitor/rule-visitor.js +2 -2
- package/dist/common/bundler/logger.js +3 -0
- package/dist/common/core/config/config.native.js +1 -5
- package/dist/common/core/native/native-utils.js +1 -8
- package/dist/common/core/native/parsers/textShadow.js +6 -18
- package/dist/common/core/native/parsers/transforms.js +1 -5
- package/dist/common/core/native/store.js +19 -65
- package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +4 -1
- package/dist/metro/index.cjs +29 -13
- package/dist/metro/index.mjs +22 -6
- package/dist/metro/transformer.cjs +61 -65
- package/dist/metro/transformer.mjs +23 -27
- package/dist/module/bundler/artifacts/css/themes.js +3 -0
- package/dist/module/bundler/cli/index.d.ts +2 -0
- package/dist/module/bundler/cli/index.js +81 -0
- package/dist/module/bundler/config.d.ts +1 -0
- package/dist/module/bundler/config.js +8 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.js +3 -3
- package/dist/module/bundler/css-compiler/compileTailwind.d.ts +1 -1
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +3 -3
- package/dist/module/bundler/css-processor/color.js +1 -1
- package/dist/module/bundler/css-processor/css.js +2 -2
- package/dist/module/bundler/css-processor/processor.js +7 -7
- package/dist/module/bundler/css-processor/units.js +1 -1
- package/dist/module/bundler/css-processor/utils.d.ts +0 -1
- package/dist/module/bundler/css-processor/utils.js +2 -4
- package/dist/module/bundler/css-processor/var.js +1 -1
- package/dist/module/bundler/css-visitor/rule-visitor.js +2 -2
- package/dist/module/bundler/logger.d.ts +1 -0
- package/dist/module/bundler/logger.js +3 -0
- package/dist/module/components/native/useStyle.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Text.d.ts +4 -1
- package/dist/module/core/config/config.native.js +1 -5
- package/dist/module/core/native/native-utils.d.ts +0 -1
- package/dist/module/core/native/native-utils.js +0 -6
- package/dist/module/core/native/parsers/textShadow.js +6 -18
- package/dist/module/core/native/parsers/transforms.js +1 -5
- package/dist/module/core/native/store.d.ts +2 -2
- package/dist/module/core/native/store.js +21 -63
- package/dist/module/core/types.d.ts +6 -4
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +4 -1
- package/dist/shared/{uniwind.CFiAZ3D-.cjs → uniwind.BEqYiPBB.cjs} +17 -5
- package/dist/shared/uniwind.CFAAUZ2t.mjs +3 -0
- package/dist/shared/uniwind.DJ5M1Q4q.cjs +5 -0
- package/dist/shared/{uniwind.u-s1XVU8.mjs → uniwind.DgC4MT51.mjs} +18 -5
- package/dist/vite/index.cjs +75 -42
- package/dist/vite/index.mjs +72 -40
- package/package.json +37 -21
- package/src/bundler/adapters/metro/metro.ts +24 -3
- package/src/bundler/adapters/metro/patches.ts +1 -1
- package/src/bundler/adapters/vite/vite.ts +104 -51
- package/src/bundler/artifacts/css/themes.ts +6 -1
- package/src/bundler/cli/index.ts +105 -0
- package/src/bundler/config.ts +10 -0
- package/src/bundler/css-compiler/compileNativeCSS.ts +3 -3
- package/src/bundler/css-processor/addMetaToStylesTemplate.ts +3 -3
- package/src/bundler/css-processor/color.ts +1 -1
- package/src/bundler/css-processor/css.ts +2 -2
- package/src/bundler/css-processor/processor.ts +7 -7
- package/src/bundler/css-processor/units.ts +1 -1
- package/src/bundler/css-processor/utils.ts +2 -5
- package/src/bundler/css-processor/var.ts +1 -1
- package/src/bundler/css-visitor/rule-visitor.ts +2 -2
- package/src/bundler/logger.ts +4 -0
- package/src/core/config/config.native.ts +1 -5
- package/src/core/native/native-utils.ts +0 -9
- package/src/core/native/parsers/textShadow.ts +6 -18
- package/src/core/native/parsers/transforms.ts +1 -5
- package/src/core/native/runtime.ts +1 -1
- package/src/core/native/store.ts +24 -66
- package/src/core/types.ts +7 -4
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +5 -2
|
@@ -7,7 +7,6 @@ exports.UniwindStore = void 0;
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _consts = require("../../common/consts");
|
|
9
9
|
var _listener = require("../listener");
|
|
10
|
-
var _nativeUtils = require("./native-utils");
|
|
11
10
|
var _parsers = require("./parsers");
|
|
12
11
|
var _runtime = require("./runtime");
|
|
13
12
|
const emptyState = {
|
|
@@ -51,18 +50,18 @@ class UniwindStoreBuilder {
|
|
|
51
50
|
const commonPlatformVars = scopedVars[`${_consts.UNIWIND_PLATFORM_VARIABLES}${commonPlatform}`];
|
|
52
51
|
const platformVars = scopedVars[`${_consts.UNIWIND_PLATFORM_VARIABLES}${platform}`];
|
|
53
52
|
if (commonPlatformVars) {
|
|
54
|
-
Object.
|
|
53
|
+
Object.assign(vars, commonPlatformVars);
|
|
55
54
|
}
|
|
56
55
|
if (platformVars) {
|
|
57
|
-
Object.
|
|
56
|
+
Object.assign(vars, platformVars);
|
|
58
57
|
}
|
|
59
58
|
this.keyframes = keyframes;
|
|
60
59
|
this.stylesheet = stylesheet;
|
|
61
60
|
this.vars = Object.fromEntries(themes.map(theme => {
|
|
62
|
-
const clonedVars =
|
|
61
|
+
const clonedVars = Object.create(vars);
|
|
63
62
|
const themeVars = scopedVars[`${_consts.UNIWIND_THEME_VARIABLES}${theme}`];
|
|
64
63
|
if (themeVars) {
|
|
65
|
-
Object.
|
|
64
|
+
Object.assign(clonedVars, themeVars);
|
|
66
65
|
}
|
|
67
66
|
return [theme, clonedVars];
|
|
68
67
|
}));
|
|
@@ -72,7 +71,7 @@ class UniwindStoreBuilder {
|
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
resolveStyles(classNames, componentProps, state, uniwindContext) {
|
|
75
|
-
const
|
|
74
|
+
const resultGetters = {};
|
|
76
75
|
const theme = uniwindContext.scopedTheme ?? this.runtime.currentThemeName;
|
|
77
76
|
let vars = this.vars[theme];
|
|
78
77
|
const originalVars = vars;
|
|
@@ -108,95 +107,50 @@ class UniwindStoreBuilder {
|
|
|
108
107
|
}
|
|
109
108
|
if (property[0] === "-") {
|
|
110
109
|
if (vars === originalVars) {
|
|
111
|
-
vars =
|
|
110
|
+
vars = Object.create(originalVars);
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
configurable: true,
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: valueGetter
|
|
117
|
-
});
|
|
112
|
+
vars[property] = valueGetter;
|
|
118
113
|
} else {
|
|
119
|
-
|
|
120
|
-
configurable: true,
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: () => valueGetter.call(vars)
|
|
123
|
-
});
|
|
114
|
+
resultGetters[property] = valueGetter;
|
|
124
115
|
}
|
|
125
116
|
bestBreakpoints.set(property, style);
|
|
126
117
|
}
|
|
127
118
|
}
|
|
128
119
|
}
|
|
120
|
+
const result = Object.fromEntries(Object.entries(resultGetters).map(([property, valueGetter]) => [property, valueGetter(vars)]));
|
|
129
121
|
if (result.lineHeight !== void 0 && result.lineHeight < 6) {
|
|
130
|
-
|
|
131
|
-
value: result.fontSize * result.lineHeight,
|
|
132
|
-
configurable: true,
|
|
133
|
-
enumerable: true
|
|
134
|
-
});
|
|
122
|
+
result.lineHeight *= result.fontSize;
|
|
135
123
|
}
|
|
136
124
|
if (result.boxShadow !== void 0) {
|
|
137
|
-
|
|
138
|
-
value: (0, _parsers.parseBoxShadow)(result.boxShadow),
|
|
139
|
-
configurable: true,
|
|
140
|
-
enumerable: true
|
|
141
|
-
});
|
|
125
|
+
result.boxShadow = (0, _parsers.parseBoxShadow)(result.boxShadow);
|
|
142
126
|
}
|
|
143
127
|
if (result.visibility === "hidden") {
|
|
144
|
-
|
|
145
|
-
value: "none",
|
|
146
|
-
configurable: true,
|
|
147
|
-
enumerable: true
|
|
148
|
-
});
|
|
128
|
+
result.display = "none";
|
|
149
129
|
}
|
|
150
130
|
if (result.borderStyle !== void 0 && result.borderColor === void 0) {
|
|
151
|
-
|
|
152
|
-
value: "#000000",
|
|
153
|
-
configurable: true,
|
|
154
|
-
enumerable: true
|
|
155
|
-
});
|
|
131
|
+
result.borderColor = "#000000";
|
|
156
132
|
}
|
|
157
133
|
if (result.outlineStyle !== void 0 && result.outlineColor === void 0) {
|
|
158
|
-
|
|
159
|
-
value: "#000000",
|
|
160
|
-
configurable: true,
|
|
161
|
-
enumerable: true
|
|
162
|
-
});
|
|
134
|
+
result.outlineColor = "#000000";
|
|
163
135
|
}
|
|
164
136
|
if (result.fontVariant !== void 0) {
|
|
165
|
-
|
|
166
|
-
value: (0, _parsers.parseFontVariant)(result.fontVariant),
|
|
167
|
-
configurable: true,
|
|
168
|
-
enumerable: true
|
|
169
|
-
});
|
|
137
|
+
result.fontVariant = (0, _parsers.parseFontVariant)(result.fontVariant);
|
|
170
138
|
}
|
|
171
139
|
(0, _parsers.parseTransformsMutation)(result);
|
|
172
140
|
(0, _parsers.parseTransitionsMutation)(result);
|
|
173
141
|
if (typeof result.animationName === "string") {
|
|
174
|
-
|
|
175
|
-
value: this.keyframes[result.animationName] ?? [],
|
|
176
|
-
configurable: true,
|
|
177
|
-
enumerable: true
|
|
178
|
-
});
|
|
142
|
+
result.animationName = this.keyframes[result.animationName] ?? [];
|
|
179
143
|
} else if (Array.isArray(result.animationName)) {
|
|
180
|
-
|
|
181
|
-
value: result.animationName.map(animationName => this.keyframes[animationName] ?? void 0).filter(Boolean),
|
|
182
|
-
configurable: true,
|
|
183
|
-
enumerable: true
|
|
184
|
-
});
|
|
144
|
+
result.animationName = result.animationName.map(animationName => this.keyframes[animationName] ?? void 0).filter(Boolean);
|
|
185
145
|
}
|
|
186
146
|
if (result.experimental_backgroundImage !== void 0) {
|
|
187
|
-
|
|
188
|
-
value: (0, _parsers.resolveGradient)(result.experimental_backgroundImage),
|
|
189
|
-
configurable: true,
|
|
190
|
-
enumerable: true
|
|
191
|
-
});
|
|
147
|
+
result.experimental_backgroundImage = (0, _parsers.resolveGradient)(result.experimental_backgroundImage);
|
|
192
148
|
}
|
|
193
149
|
if (result.textShadow !== void 0) {
|
|
194
150
|
(0, _parsers.parseTextShadowMutation)(result);
|
|
195
151
|
}
|
|
196
152
|
return {
|
|
197
|
-
styles:
|
|
198
|
-
...result
|
|
199
|
-
},
|
|
153
|
+
styles: result,
|
|
200
154
|
dependencies: Array.from(dependencies),
|
|
201
155
|
dependencySum,
|
|
202
156
|
hasDataAttributes
|
|
@@ -5,5 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getVariableValue = void 0;
|
|
7
7
|
var _native = require("../../core/native");
|
|
8
|
-
const getVariableValue = (name, uniwindContext) =>
|
|
8
|
+
const getVariableValue = (name, uniwindContext) => {
|
|
9
|
+
const vars = _native.UniwindStore.vars[uniwindContext.scopedTheme ?? _native.UniwindRuntime.currentThemeName];
|
|
10
|
+
return vars?.[name]?.(vars);
|
|
11
|
+
};
|
|
9
12
|
exports.getVariableValue = getVariableValue;
|
package/dist/metro/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const config = require('../shared/uniwind.BEqYiPBB.cjs');
|
|
4
|
+
const node_path = require('node:path');
|
|
5
|
+
const _package = require('../shared/uniwind.DJ5M1Q4q.cjs');
|
|
4
6
|
const FileStoreBase = require('metro-cache/private/stores/FileStore');
|
|
5
7
|
const os = require('os');
|
|
6
8
|
const path = require('path');
|
|
7
|
-
const node_path = require('node:path');
|
|
8
9
|
require('fs');
|
|
9
10
|
require('@tailwindcss/node');
|
|
10
11
|
require('lightningcss');
|
|
@@ -35,7 +36,7 @@ const patchMetroGraphToSupportUncachedModules = () => {
|
|
|
35
36
|
original_traverseDependencies.__patched = true;
|
|
36
37
|
function traverseDependencies(paths, options) {
|
|
37
38
|
this.dependencies.forEach((dependency) => {
|
|
38
|
-
if (dependency.output.find((file) => file.data
|
|
39
|
+
if (dependency.output.find((file) => file.data?.css?.skipCache === true) && !paths.includes(dependency.path)) {
|
|
39
40
|
dependency.unstable_transformResultKey = `${dependency.unstable_transformResultKey}.`;
|
|
40
41
|
paths.push(dependency.path);
|
|
41
42
|
}
|
|
@@ -146,30 +147,45 @@ const webResolver = (extraComponents) => ({
|
|
|
146
147
|
return resolver(context, `${_package.name}/components/${module}`, platform);
|
|
147
148
|
};
|
|
148
149
|
|
|
149
|
-
const
|
|
150
|
-
|
|
150
|
+
const isUniwindRequest = (moduleName) => moduleName === _package.name || moduleName.startsWith(`${_package.name}/`);
|
|
151
|
+
const withUniwindConfig = (config$1, uniwindConfig) => {
|
|
152
|
+
const bundlerConfig = config.UniwindBundlerConfig.fromMetroConfig(uniwindConfig);
|
|
153
|
+
const pinnedUniwindOrigin = node_path.join(config$1.projectRoot ?? process.cwd(), "package.json");
|
|
151
154
|
patchMetroGraphToSupportUncachedModules();
|
|
152
155
|
return {
|
|
153
|
-
...config,
|
|
156
|
+
...config$1,
|
|
154
157
|
cacheStores: [cacheStore],
|
|
155
158
|
transformerPath: require.resolve("./transformer.cjs"),
|
|
156
159
|
transformer: {
|
|
157
|
-
...config.transformer,
|
|
160
|
+
...config$1.transformer,
|
|
158
161
|
uniwind: bundlerConfig.toMetroConfig()
|
|
159
162
|
},
|
|
160
163
|
resolver: {
|
|
161
|
-
...config.resolver,
|
|
164
|
+
...config$1.resolver,
|
|
162
165
|
sourceExts: [
|
|
163
|
-
...config.resolver?.sourceExts ?? [],
|
|
166
|
+
...config$1.resolver?.sourceExts ?? [],
|
|
164
167
|
"css"
|
|
165
168
|
],
|
|
166
|
-
assetExts: config.resolver?.assetExts?.filter(
|
|
169
|
+
assetExts: config$1.resolver?.assetExts?.filter(
|
|
167
170
|
(ext) => ext !== "css"
|
|
168
171
|
),
|
|
169
172
|
resolveRequest: (context, moduleName, platform) => {
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
+
const baseResolver = config$1.resolver?.resolveRequest ?? context.resolveRequest;
|
|
174
|
+
const resolver = (nextContext, nextModuleName, nextPlatform) => {
|
|
175
|
+
if (isUniwindRequest(nextModuleName)) {
|
|
176
|
+
return baseResolver(
|
|
177
|
+
{
|
|
178
|
+
...nextContext,
|
|
179
|
+
originModulePath: pinnedUniwindOrigin
|
|
180
|
+
},
|
|
181
|
+
nextModuleName,
|
|
182
|
+
nextPlatform
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return baseResolver(nextContext, nextModuleName, nextPlatform);
|
|
186
|
+
};
|
|
187
|
+
const platformResolver = platform === config.Platform.Web ? webResolver : nativeResolver;
|
|
188
|
+
const resolved = platformResolver(uniwindConfig.extraComponents ?? {})({
|
|
173
189
|
context,
|
|
174
190
|
moduleName,
|
|
175
191
|
platform,
|
package/dist/metro/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as UniwindBundlerConfig, P as Platform } from '../shared/uniwind.DgC4MT51.mjs';
|
|
2
|
+
import { dirname, sep, basename, join } from 'node:path';
|
|
3
|
+
import { n as name } from '../shared/uniwind.CFAAUZ2t.mjs';
|
|
2
4
|
import FileStoreBase from 'metro-cache/private/stores/FileStore';
|
|
3
5
|
import os from 'os';
|
|
4
6
|
import path from 'path';
|
|
5
|
-
import { dirname, sep, basename } from 'node:path';
|
|
6
7
|
import 'fs';
|
|
7
8
|
import '@tailwindcss/node';
|
|
8
9
|
import 'lightningcss';
|
|
@@ -27,7 +28,7 @@ const patchMetroGraphToSupportUncachedModules = () => {
|
|
|
27
28
|
original_traverseDependencies.__patched = true;
|
|
28
29
|
function traverseDependencies(paths, options) {
|
|
29
30
|
this.dependencies.forEach((dependency) => {
|
|
30
|
-
if (dependency.output.find((file) => file.data
|
|
31
|
+
if (dependency.output.find((file) => file.data?.css?.skipCache === true) && !paths.includes(dependency.path)) {
|
|
31
32
|
dependency.unstable_transformResultKey = `${dependency.unstable_transformResultKey}.`;
|
|
32
33
|
paths.push(dependency.path);
|
|
33
34
|
}
|
|
@@ -138,8 +139,10 @@ const webResolver = (extraComponents) => ({
|
|
|
138
139
|
return resolver(context, `${name}/components/${module}`, platform);
|
|
139
140
|
};
|
|
140
141
|
|
|
142
|
+
const isUniwindRequest = (moduleName) => moduleName === name || moduleName.startsWith(`${name}/`);
|
|
141
143
|
const withUniwindConfig = (config, uniwindConfig) => {
|
|
142
144
|
const bundlerConfig = UniwindBundlerConfig.fromMetroConfig(uniwindConfig);
|
|
145
|
+
const pinnedUniwindOrigin = join(config.projectRoot ?? process.cwd(), "package.json");
|
|
143
146
|
patchMetroGraphToSupportUncachedModules();
|
|
144
147
|
return {
|
|
145
148
|
...config,
|
|
@@ -159,9 +162,22 @@ const withUniwindConfig = (config, uniwindConfig) => {
|
|
|
159
162
|
(ext) => ext !== "css"
|
|
160
163
|
),
|
|
161
164
|
resolveRequest: (context, moduleName, platform) => {
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
+
const baseResolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
166
|
+
const resolver = (nextContext, nextModuleName, nextPlatform) => {
|
|
167
|
+
if (isUniwindRequest(nextModuleName)) {
|
|
168
|
+
return baseResolver(
|
|
169
|
+
{
|
|
170
|
+
...nextContext,
|
|
171
|
+
originModulePath: pinnedUniwindOrigin
|
|
172
|
+
},
|
|
173
|
+
nextModuleName,
|
|
174
|
+
nextPlatform
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return baseResolver(nextContext, nextModuleName, nextPlatform);
|
|
178
|
+
};
|
|
179
|
+
const platformResolver = platform === Platform.Web ? webResolver : nativeResolver;
|
|
180
|
+
const resolved = platformResolver(uniwindConfig.extraComponents ?? {})({
|
|
165
181
|
context,
|
|
166
182
|
moduleName,
|
|
167
183
|
platform,
|