@kbach/react 0.5.47 → 0.5.49
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/{chunk-U3GY5Y6J.mjs → chunk-3UUTNNWV.mjs} +104 -4
- package/dist/{chunk-NIBECTRQ.mjs → chunk-BKSXIWL7.mjs} +8 -7
- package/dist/{chunk-LCK5OGHT.mjs → chunk-KWB2XQSF.mjs} +34 -22
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +145 -26
- package/dist/index.mjs +38 -18
- package/dist/jsx-dev-runtime.js +119 -29
- package/dist/jsx-dev-runtime.mjs +3 -3
- package/dist/jsx-runtime.d.mts +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime.js +128 -31
- package/dist/jsx-runtime.mjs +7 -4
- package/dist/vite-plugin.js +29 -18
- package/dist/vite-plugin.mjs +22 -12
- package/dist/web-substitute-CfpYFnE7.d.mts +22 -0
- package/dist/web-substitute-CfpYFnE7.d.ts +22 -0
- package/package.json +1 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -642,7 +642,12 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
if (!hex) return null;
|
|
645
|
-
if (!opacityPart)
|
|
645
|
+
if (!opacityPart) {
|
|
646
|
+
if (!isWeb && hex.startsWith("#") && hex.length === 9) {
|
|
647
|
+
return hexToRgba(hex, Math.round(parseInt(hex.slice(7, 9), 16) / 255 * 1e3) / 1e3);
|
|
648
|
+
}
|
|
649
|
+
return hex;
|
|
650
|
+
}
|
|
646
651
|
let alpha;
|
|
647
652
|
if (opacityPart.startsWith("[") && opacityPart.endsWith("]")) {
|
|
648
653
|
const v = parseFloat(opacityPart.slice(1, -1));
|
|
@@ -2205,12 +2210,6 @@ var RESOLVERS = {
|
|
|
2205
2210
|
function resolveUtility(parsed, theme) {
|
|
2206
2211
|
if (!parsed.value) {
|
|
2207
2212
|
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
2208
|
-
if (parsed.utility === "grd" || parsed.utility === "grid") {
|
|
2209
|
-
return getEffectiveIsWeb() ? { display: "grid" } : null;
|
|
2210
|
-
}
|
|
2211
|
-
if (parsed.utility === "inline-grid") {
|
|
2212
|
-
return getEffectiveIsWeb() ? { display: "inline-grid" } : null;
|
|
2213
|
-
}
|
|
2214
2213
|
if (parsed.utility in getStandalone()) return getStandalone()[parsed.utility] ?? null;
|
|
2215
2214
|
}
|
|
2216
2215
|
const resolver = PLUGIN_RESOLVERS[parsed.utility] ?? RESOLVERS[parsed.utility];
|
|
@@ -2763,6 +2762,8 @@ function buildConfig(userConfig) {
|
|
|
2763
2762
|
};
|
|
2764
2763
|
clearPluginUtilities();
|
|
2765
2764
|
clearPluginModifiers();
|
|
2765
|
+
const _store = getConfigStore();
|
|
2766
|
+
for (const k of Object.keys(_store.customVariants)) delete _store.customVariants[k];
|
|
2766
2767
|
const pluginAPI = makePluginAPI(resolved.theme);
|
|
2767
2768
|
for (const plugin of resolved.plugins) {
|
|
2768
2769
|
plugin(pluginAPI);
|
|
@@ -3008,13 +3009,25 @@ function extractClassStrings(code) {
|
|
|
3008
3009
|
i++;
|
|
3009
3010
|
}
|
|
3010
3011
|
jsxExprRe.lastIndex = i + 1;
|
|
3011
|
-
const innerStrings = block.match(/["'`]([^"'`]{1,
|
|
3012
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
3012
3013
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
3013
3014
|
}
|
|
3014
|
-
const
|
|
3015
|
-
while ((m =
|
|
3016
|
-
|
|
3017
|
-
|
|
3015
|
+
const clsxCallRe = /(?:clsx|cn|classnames|cx)\(/g;
|
|
3016
|
+
while ((m = clsxCallRe.exec(code)) !== null) {
|
|
3017
|
+
let depth = 1;
|
|
3018
|
+
let i = m.index + m[0].length;
|
|
3019
|
+
let block = "";
|
|
3020
|
+
while (i < code.length && depth > 0) {
|
|
3021
|
+
const ch = code[i];
|
|
3022
|
+
if (ch === "(") depth++;
|
|
3023
|
+
else if (ch === ")") {
|
|
3024
|
+
if (--depth === 0) break;
|
|
3025
|
+
}
|
|
3026
|
+
block += ch;
|
|
3027
|
+
i++;
|
|
3028
|
+
}
|
|
3029
|
+
clsxCallRe.lastIndex = i + 1;
|
|
3030
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
3018
3031
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
3019
3032
|
}
|
|
3020
3033
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
@@ -3064,12 +3077,10 @@ function kbach(userConfig) {
|
|
|
3064
3077
|
function processFile(filePath, code) {
|
|
3065
3078
|
const key = normPath(filePath);
|
|
3066
3079
|
const tokens = /* @__PURE__ */ new Set();
|
|
3067
|
-
for (const
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
3072
|
-
}
|
|
3080
|
+
for (const tok of extractClassStrings(code)) {
|
|
3081
|
+
tokens.add(tok);
|
|
3082
|
+
if (!tokenCSS.has(tok)) {
|
|
3083
|
+
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
3073
3084
|
}
|
|
3074
3085
|
}
|
|
3075
3086
|
fileTokens.set(key, tokens);
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
generateClassCSS,
|
|
5
5
|
setCSSGenMode,
|
|
6
6
|
splitClassTokens
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BKSXIWL7.mjs";
|
|
8
8
|
|
|
9
9
|
// src/vite-plugin.ts
|
|
10
10
|
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
@@ -186,13 +186,25 @@ function extractClassStrings(code) {
|
|
|
186
186
|
i++;
|
|
187
187
|
}
|
|
188
188
|
jsxExprRe.lastIndex = i + 1;
|
|
189
|
-
const innerStrings = block.match(/["'`]([^"'`]{1,
|
|
189
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
190
190
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
191
191
|
}
|
|
192
|
-
const
|
|
193
|
-
while ((m =
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
const clsxCallRe = /(?:clsx|cn|classnames|cx)\(/g;
|
|
193
|
+
while ((m = clsxCallRe.exec(code)) !== null) {
|
|
194
|
+
let depth = 1;
|
|
195
|
+
let i = m.index + m[0].length;
|
|
196
|
+
let block = "";
|
|
197
|
+
while (i < code.length && depth > 0) {
|
|
198
|
+
const ch = code[i];
|
|
199
|
+
if (ch === "(") depth++;
|
|
200
|
+
else if (ch === ")") {
|
|
201
|
+
if (--depth === 0) break;
|
|
202
|
+
}
|
|
203
|
+
block += ch;
|
|
204
|
+
i++;
|
|
205
|
+
}
|
|
206
|
+
clsxCallRe.lastIndex = i + 1;
|
|
207
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
196
208
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
197
209
|
}
|
|
198
210
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
@@ -242,12 +254,10 @@ function kbach(userConfig) {
|
|
|
242
254
|
function processFile(filePath, code) {
|
|
243
255
|
const key = normPath(filePath);
|
|
244
256
|
const tokens = /* @__PURE__ */ new Set();
|
|
245
|
-
for (const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
250
|
-
}
|
|
257
|
+
for (const tok of extractClassStrings(code)) {
|
|
258
|
+
tokens.add(tok);
|
|
259
|
+
if (!tokenCSS.has(tok)) {
|
|
260
|
+
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
263
|
fileTokens.set(key, tokens);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native → HTML element substitution for web rendering.
|
|
3
|
+
*
|
|
4
|
+
* When isWeb is true, known React Native component types (View, Text, Pressable, …)
|
|
5
|
+
* are replaced with plain HTML element strings ('div', 'span', …) so the DOM shows
|
|
6
|
+
* clean Kbach class names instead of React Native Web's generated css-view-* classes.
|
|
7
|
+
*
|
|
8
|
+
* Used by: jsx-runtime (bare JSX), styled(), DarkWrapper, InteractiveWrapper.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Register a custom React Native component → HTML tag substitution.
|
|
12
|
+
* Call once at app startup before first render.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Animated } from 'react-native';
|
|
16
|
+
* import { registerWebElement } from '@kbach/react';
|
|
17
|
+
* registerWebElement(Animated.View, 'div');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function registerWebElement(rnComponent: unknown, htmlTag: string): void;
|
|
21
|
+
|
|
22
|
+
export { registerWebElement as r };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native → HTML element substitution for web rendering.
|
|
3
|
+
*
|
|
4
|
+
* When isWeb is true, known React Native component types (View, Text, Pressable, …)
|
|
5
|
+
* are replaced with plain HTML element strings ('div', 'span', …) so the DOM shows
|
|
6
|
+
* clean Kbach class names instead of React Native Web's generated css-view-* classes.
|
|
7
|
+
*
|
|
8
|
+
* Used by: jsx-runtime (bare JSX), styled(), DarkWrapper, InteractiveWrapper.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Register a custom React Native component → HTML tag substitution.
|
|
12
|
+
* Call once at app startup before first render.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Animated } from 'react-native';
|
|
16
|
+
* import { registerWebElement } from '@kbach/react';
|
|
17
|
+
* registerWebElement(Animated.View, 'div');
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function registerWebElement(rnComponent: unknown, htmlTag: string): void;
|
|
21
|
+
|
|
22
|
+
export { registerWebElement as r };
|