tailwind-styled-v4 5.0.8 → 5.0.10
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 +204 -416
- package/README.md +45 -15
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +63 -32
- package/dist/index.d.ts +63 -32
- package/dist/index.js +335 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -169
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.d.mts +10 -4
- package/dist/next.d.ts +10 -4
- package/dist/next.js +32 -45
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +30 -43
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +84 -126
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +68 -124
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +69 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +49 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
package/dist/index.js
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var url = require('url');
|
|
5
|
+
require('crypto');
|
|
6
|
+
var fs = require('fs');
|
|
7
|
+
var module$1 = require('module');
|
|
3
8
|
var React3 = require('react');
|
|
4
|
-
var tailwindMerge = require('tailwind-merge');
|
|
5
9
|
|
|
10
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
12
|
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
32
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
8
33
|
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
9
34
|
|
|
10
35
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
@@ -14,6 +39,119 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
14
39
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
40
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
41
|
});
|
|
42
|
+
var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
43
|
+
var _require = typeof __require !== "undefined" ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
44
|
+
var PLATFORM_MAP = {
|
|
45
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
46
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
47
|
+
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
48
|
+
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
49
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
50
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
51
|
+
};
|
|
52
|
+
function platformKey() {
|
|
53
|
+
if (isBrowser) return "browser";
|
|
54
|
+
return `${process.platform}-${process.arch}`;
|
|
55
|
+
}
|
|
56
|
+
function resolveNativeBinary(runtimeDir) {
|
|
57
|
+
const platform = platformKey();
|
|
58
|
+
const tried = [];
|
|
59
|
+
if (isBrowser) {
|
|
60
|
+
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
61
|
+
}
|
|
62
|
+
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
63
|
+
return { path: null, source: "not-found", platform, tried: [] };
|
|
64
|
+
}
|
|
65
|
+
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
66
|
+
if (envPath) {
|
|
67
|
+
if (fs__namespace.existsSync(envPath)) {
|
|
68
|
+
return { path: envPath, source: "env", platform, tried };
|
|
69
|
+
}
|
|
70
|
+
tried.push(`env:${envPath} (not found)`);
|
|
71
|
+
}
|
|
72
|
+
const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
|
|
73
|
+
for (const pkg of prebuiltPkgs) {
|
|
74
|
+
try {
|
|
75
|
+
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
76
|
+
if (fs__namespace.existsSync(candidate)) {
|
|
77
|
+
return { path: candidate, source: "prebuilt", platform, tried };
|
|
78
|
+
}
|
|
79
|
+
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
80
|
+
} catch {
|
|
81
|
+
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const base = runtimeDir ?? cwd;
|
|
86
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
87
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
88
|
+
const localCandidates = [];
|
|
89
|
+
for (const bin of BINARY_NAMES) {
|
|
90
|
+
localCandidates.push(path__namespace.resolve(base, `${bin}.node`));
|
|
91
|
+
localCandidates.push(path__namespace.resolve(base, "..", `${bin}.node`));
|
|
92
|
+
localCandidates.push(path__namespace.resolve(base, `${bin}.${platform}.node`));
|
|
93
|
+
localCandidates.push(path__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
94
|
+
}
|
|
95
|
+
for (const startDir of [cwd, base]) {
|
|
96
|
+
let dir = startDir;
|
|
97
|
+
for (let i = 0; i < 6; i++) {
|
|
98
|
+
const nativeDir = path__namespace.resolve(dir, "native");
|
|
99
|
+
for (const bin of BINARY_NAMES) {
|
|
100
|
+
localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.node`));
|
|
101
|
+
localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
102
|
+
localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
103
|
+
localCandidates.push(path__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
104
|
+
}
|
|
105
|
+
const parent = path__namespace.resolve(dir, "..");
|
|
106
|
+
if (parent === dir) break;
|
|
107
|
+
dir = parent;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const candidate of localCandidates) {
|
|
111
|
+
tried.push(`local:${candidate}`);
|
|
112
|
+
if (fs__namespace.existsSync(candidate)) {
|
|
113
|
+
return { path: candidate, source: "local", platform, tried };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { path: null, source: "not-found", platform, tried };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// packages/domain/shared/src/index.ts
|
|
120
|
+
module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
121
|
+
|
|
122
|
+
// packages/domain/core/src/native.ts
|
|
123
|
+
var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
124
|
+
var NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/core] Native binding is required but not available.\nPlease ensure you have run: npm run build:rust";
|
|
125
|
+
var _loadNative = (path3) => __require(path3);
|
|
126
|
+
var nativeBinding = null;
|
|
127
|
+
var bindingLoadAttempted = false;
|
|
128
|
+
var getBinding = () => {
|
|
129
|
+
if (isBrowser2) {
|
|
130
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE + "\n\nNative bindings are not available in browser. Use the compiled CSS output instead.");
|
|
131
|
+
}
|
|
132
|
+
if (nativeBinding) return nativeBinding;
|
|
133
|
+
if (bindingLoadAttempted) {
|
|
134
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
135
|
+
}
|
|
136
|
+
bindingLoadAttempted = true;
|
|
137
|
+
try {
|
|
138
|
+
const runtimeDir = isBrowser2 ? "" : path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))));
|
|
139
|
+
const result = isBrowser2 ? { path: null, source: "not-found", platform: "browser", tried: [] } : resolveNativeBinary(runtimeDir);
|
|
140
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
141
|
+
const mod = _loadNative(result.path);
|
|
142
|
+
if (mod?.batchSplitClasses) {
|
|
143
|
+
nativeBinding = mod;
|
|
144
|
+
return nativeBinding;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
148
|
+
|
|
149
|
+
Tried: ${result.tried.join("\n")}`);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var getNativeBinding = getBinding;
|
|
17
155
|
|
|
18
156
|
// packages/domain/core/src/containerQuery.ts
|
|
19
157
|
var CONTAINER_BREAKPOINTS = {
|
|
@@ -85,6 +223,13 @@ var LAYOUT_MAP = {
|
|
|
85
223
|
"justify-end": "justify-content:flex-end"
|
|
86
224
|
};
|
|
87
225
|
function layoutClassesToCss(classes) {
|
|
226
|
+
try {
|
|
227
|
+
const native = getNativeBinding();
|
|
228
|
+
if (native?.layoutClassesToCss) {
|
|
229
|
+
return native.layoutClassesToCss(classes);
|
|
230
|
+
}
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
88
233
|
const decls = [];
|
|
89
234
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
90
235
|
if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
|
|
@@ -148,18 +293,36 @@ function processContainer(tag, container, containerName) {
|
|
|
148
293
|
}
|
|
149
294
|
function generateContainerCss(tag, container, containerName) {
|
|
150
295
|
const id = hashContainer(tag, container, containerName);
|
|
296
|
+
try {
|
|
297
|
+
const native = getNativeBinding();
|
|
298
|
+
if (native?.buildContainerRules) {
|
|
299
|
+
const breakpoints = Object.entries(container).map(([key, value]) => ({
|
|
300
|
+
key,
|
|
301
|
+
classes: typeof value === "string" ? value : value.classes
|
|
302
|
+
}));
|
|
303
|
+
return native.buildContainerRules(id, breakpoints, containerName ?? null);
|
|
304
|
+
}
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
151
307
|
return buildContainerRules(id, container, containerName);
|
|
152
308
|
}
|
|
153
309
|
function getContainerRegistry() {
|
|
154
310
|
return containerRegistry;
|
|
155
311
|
}
|
|
312
|
+
|
|
313
|
+
// packages/domain/core/src/merge.ts
|
|
156
314
|
function normalizeClassInput(classLists) {
|
|
157
315
|
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
158
316
|
}
|
|
159
317
|
function createTwMerge(_options = {}) {
|
|
160
|
-
return function
|
|
318
|
+
return function twMerge2(...classLists) {
|
|
161
319
|
const clean = normalizeClassInput(classLists);
|
|
162
|
-
|
|
320
|
+
if (clean.length === 0) return "";
|
|
321
|
+
const native = getNativeBinding();
|
|
322
|
+
if (!native?.twMergeMany) {
|
|
323
|
+
throw new Error("FATAL: Native binding 'twMergeMany' is required but not available.");
|
|
324
|
+
}
|
|
325
|
+
return native.twMergeMany(clean);
|
|
163
326
|
};
|
|
164
327
|
}
|
|
165
328
|
var twMerge = createTwMerge();
|
|
@@ -182,113 +345,12 @@ function hashState(tag, state) {
|
|
|
182
345
|
const hash = key.split("").reduce((h, char) => (h << 5) + h ^ char.charCodeAt(0), 5381);
|
|
183
346
|
return `tw-s-${Math.abs(hash).toString(36).slice(0, 6)}`;
|
|
184
347
|
}
|
|
185
|
-
var TW_MAP = {
|
|
186
|
-
// Display
|
|
187
|
-
hidden: "display:none",
|
|
188
|
-
block: "display:block",
|
|
189
|
-
flex: "display:flex",
|
|
190
|
-
inline: "display:inline",
|
|
191
|
-
"inline-flex": "display:inline-flex",
|
|
192
|
-
grid: "display:grid",
|
|
193
|
-
// Opacity
|
|
194
|
-
"opacity-0": "opacity:0",
|
|
195
|
-
"opacity-5": "opacity:0.05",
|
|
196
|
-
"opacity-10": "opacity:0.1",
|
|
197
|
-
"opacity-20": "opacity:0.2",
|
|
198
|
-
"opacity-25": "opacity:0.25",
|
|
199
|
-
"opacity-30": "opacity:0.3",
|
|
200
|
-
"opacity-40": "opacity:0.4",
|
|
201
|
-
"opacity-50": "opacity:0.5",
|
|
202
|
-
"opacity-60": "opacity:0.6",
|
|
203
|
-
"opacity-70": "opacity:0.7",
|
|
204
|
-
"opacity-75": "opacity:0.75",
|
|
205
|
-
"opacity-80": "opacity:0.8",
|
|
206
|
-
"opacity-90": "opacity:0.9",
|
|
207
|
-
"opacity-95": "opacity:0.95",
|
|
208
|
-
"opacity-100": "opacity:1",
|
|
209
|
-
// Cursor
|
|
210
|
-
"cursor-pointer": "cursor:pointer",
|
|
211
|
-
"cursor-not-allowed": "cursor:not-allowed",
|
|
212
|
-
"cursor-default": "cursor:default",
|
|
213
|
-
"cursor-wait": "cursor:wait",
|
|
214
|
-
"cursor-move": "cursor:move",
|
|
215
|
-
"cursor-grab": "cursor:grab",
|
|
216
|
-
"cursor-grabbing": "cursor:grabbing",
|
|
217
|
-
// Pointer events
|
|
218
|
-
"pointer-events-none": "pointer-events:none",
|
|
219
|
-
"pointer-events-auto": "pointer-events:auto",
|
|
220
|
-
// Scale
|
|
221
|
-
"scale-90": "transform:scale(0.9)",
|
|
222
|
-
"scale-95": "transform:scale(0.95)",
|
|
223
|
-
"scale-100": "transform:scale(1)",
|
|
224
|
-
"scale-105": "transform:scale(1.05)",
|
|
225
|
-
"scale-110": "transform:scale(1.1)",
|
|
226
|
-
// Translate
|
|
227
|
-
"translate-x-0": "transform:translateX(0)",
|
|
228
|
-
"translate-y-0": "transform:translateY(0)",
|
|
229
|
-
"-translate-x-1": "transform:translateX(-0.25rem)",
|
|
230
|
-
"-translate-y-1": "transform:translateY(-0.25rem)",
|
|
231
|
-
"translate-x-1": "transform:translateX(0.25rem)",
|
|
232
|
-
"translate-y-1": "transform:translateY(0.25rem)",
|
|
233
|
-
// Ring
|
|
234
|
-
ring: "box-shadow:0 0 0 3px rgba(59,130,246,0.5)",
|
|
235
|
-
"ring-2": "box-shadow:0 0 0 2px rgba(59,130,246,0.5)",
|
|
236
|
-
"ring-4": "box-shadow:0 0 0 4px rgba(59,130,246,0.5)",
|
|
237
|
-
"ring-inset": "box-shadow:inset 0 0 0 3px rgba(59,130,246,0.5)",
|
|
238
|
-
// Border
|
|
239
|
-
border: "border-width:1px",
|
|
240
|
-
"border-2": "border-width:2px",
|
|
241
|
-
"border-transparent": "border-color:transparent",
|
|
242
|
-
// Outline
|
|
243
|
-
"outline-none": "outline:2px solid transparent;outline-offset:2px",
|
|
244
|
-
outline: "outline:2px solid currentColor",
|
|
245
|
-
// Overflow
|
|
246
|
-
"overflow-hidden": "overflow:hidden",
|
|
247
|
-
"overflow-auto": "overflow:auto",
|
|
248
|
-
"overflow-scroll": "overflow:scroll",
|
|
249
|
-
// Text decoration
|
|
250
|
-
underline: "text-decoration-line:underline",
|
|
251
|
-
"no-underline": "text-decoration-line:none",
|
|
252
|
-
"line-through": "text-decoration-line:line-through",
|
|
253
|
-
// Font weight
|
|
254
|
-
"font-bold": "font-weight:700",
|
|
255
|
-
"font-semibold": "font-weight:600",
|
|
256
|
-
"font-medium": "font-weight:500",
|
|
257
|
-
"font-normal": "font-weight:400",
|
|
258
|
-
// Background colors (common)
|
|
259
|
-
"bg-transparent": "background-color:transparent",
|
|
260
|
-
"bg-white": "background-color:#fff",
|
|
261
|
-
"bg-black": "background-color:#000",
|
|
262
|
-
"bg-blue-500": "background-color:rgb(59,130,246)",
|
|
263
|
-
"bg-blue-600": "background-color:rgb(37,99,235)",
|
|
264
|
-
"bg-red-500": "background-color:rgb(239,68,68)",
|
|
265
|
-
"bg-green-500": "background-color:rgb(34,197,94)",
|
|
266
|
-
"bg-yellow-500": "background-color:rgb(234,179,8)",
|
|
267
|
-
"bg-zinc-900": "background-color:rgb(24,24,27)",
|
|
268
|
-
"bg-zinc-800": "background-color:rgb(39,39,42)",
|
|
269
|
-
// Text colors
|
|
270
|
-
"text-white": "color:#fff",
|
|
271
|
-
"text-black": "color:#000",
|
|
272
|
-
"text-blue-500": "color:rgb(59,130,246)",
|
|
273
|
-
"text-red-500": "color:rgb(239,68,68)",
|
|
274
|
-
"text-zinc-400": "color:rgb(161,161,170)",
|
|
275
|
-
"text-zinc-500": "color:rgb(113,113,122)"
|
|
276
|
-
};
|
|
277
348
|
function twClassesToCss(classes) {
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
else if (cls.includes("[") && cls.includes("]")) {
|
|
282
|
-
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
283
|
-
if (!val) continue;
|
|
284
|
-
if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
|
|
285
|
-
else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
|
|
286
|
-
else if (cls.startsWith("w-[")) decls.push(`width:${val}`);
|
|
287
|
-
else if (cls.startsWith("h-[")) decls.push(`height:${val}`);
|
|
288
|
-
else if (cls.startsWith("opacity-[")) decls.push(`opacity:${val}`);
|
|
289
|
-
}
|
|
349
|
+
const native = getNativeBinding();
|
|
350
|
+
if (!native?.twClassesToCss) {
|
|
351
|
+
throw new Error("FATAL: Native binding 'twClassesToCss' is required but not available.");
|
|
290
352
|
}
|
|
291
|
-
return
|
|
353
|
+
return native.twClassesToCss(classes);
|
|
292
354
|
}
|
|
293
355
|
function injectStateStyles(id, state) {
|
|
294
356
|
if (typeof document === "undefined") return;
|
|
@@ -341,28 +403,50 @@ function getStateRegistry() {
|
|
|
341
403
|
|
|
342
404
|
// packages/domain/core/src/createComponent.ts
|
|
343
405
|
var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
|
|
344
|
-
function
|
|
345
|
-
const
|
|
346
|
-
|
|
406
|
+
function parseSubComponentBlocks(template) {
|
|
407
|
+
const native = getNativeBinding();
|
|
408
|
+
if (!native?.parseSubcomponentBlocksNapi) {
|
|
409
|
+
throw new Error("FATAL: Native binding 'parseSubcomponentBlocksNapi' is required but not available.");
|
|
410
|
+
}
|
|
411
|
+
const result = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
412
|
+
const raw = JSON.parse(result.subMapJson);
|
|
413
|
+
return new Map(Object.entries(raw));
|
|
347
414
|
}
|
|
348
415
|
function extractBaseClasses(template) {
|
|
349
|
-
|
|
416
|
+
try {
|
|
417
|
+
const native = getNativeBinding();
|
|
418
|
+
if (native?.parseSubcomponentBlocksNapi) {
|
|
419
|
+
const result = native.parseSubcomponentBlocksNapi(template, "tw");
|
|
420
|
+
return result.baseClasses;
|
|
421
|
+
}
|
|
422
|
+
} catch {
|
|
423
|
+
}
|
|
424
|
+
return template.replace(/(?:\[[a-zA-Z][a-zA-Z0-9_-]*\]|[a-zA-Z][a-zA-Z0-9_-]*)\s*\{[^}]*\}/g, "").replace(/\s+/g, " ").trim();
|
|
350
425
|
}
|
|
351
|
-
function createSubComponentAccessor(parentDisplayName, name) {
|
|
426
|
+
function createSubComponentAccessor(parentDisplayName, name, classes) {
|
|
352
427
|
const SubComponent = ({
|
|
353
428
|
children,
|
|
354
429
|
className
|
|
355
|
-
}) => React3__default.default.createElement(
|
|
430
|
+
}) => React3__default.default.createElement(
|
|
431
|
+
"span",
|
|
432
|
+
{ className: className ? `${classes} ${className}` : classes },
|
|
433
|
+
children
|
|
434
|
+
);
|
|
356
435
|
SubComponent.displayName = `${parentDisplayName}[${name}]`;
|
|
357
436
|
return SubComponent;
|
|
358
437
|
}
|
|
359
|
-
function registerSubComponents(component, template) {
|
|
360
|
-
const names = parseSubComponentNames(template);
|
|
438
|
+
function registerSubComponents(component, template, configSub) {
|
|
361
439
|
const displayName = component.displayName ?? "tw";
|
|
362
440
|
const map = component;
|
|
363
|
-
|
|
441
|
+
if (configSub) {
|
|
442
|
+
for (const [name, classes] of Object.entries(configSub)) {
|
|
443
|
+
map[name] = createSubComponentAccessor(displayName, name, classes.trim().replace(/\s+/g, " "));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const blocks = parseSubComponentBlocks(template);
|
|
447
|
+
for (const [name, classes] of blocks) {
|
|
364
448
|
if (!(name in map)) {
|
|
365
|
-
map[name] = createSubComponentAccessor(displayName, name);
|
|
449
|
+
map[name] = createSubComponentAccessor(displayName, name, classes);
|
|
366
450
|
}
|
|
367
451
|
}
|
|
368
452
|
}
|
|
@@ -382,14 +466,15 @@ function makeFilterProps(variantKeys) {
|
|
|
382
466
|
};
|
|
383
467
|
}
|
|
384
468
|
function resolveVariants(variants, props, defaults) {
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (value !== void 0 && variants[key][String(value)]) {
|
|
389
|
-
classes.push(variants[key][String(value)]);
|
|
390
|
-
}
|
|
469
|
+
const binding = getNativeBinding();
|
|
470
|
+
if (!binding?.resolveSimpleVariants) {
|
|
471
|
+
throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
|
|
391
472
|
}
|
|
392
|
-
|
|
473
|
+
const cleanProps = {};
|
|
474
|
+
for (const [k, v] of Object.entries(props)) {
|
|
475
|
+
if (v !== void 0 && v !== null) cleanProps[k] = String(v);
|
|
476
|
+
}
|
|
477
|
+
return binding.resolveSimpleVariants(null, variants, defaults, cleanProps);
|
|
393
478
|
}
|
|
394
479
|
function resolveCompound(compounds, props) {
|
|
395
480
|
const classes = [];
|
|
@@ -413,13 +498,21 @@ function carryOverSubComponents(target, source) {
|
|
|
413
498
|
function attachExtend(component, originalTag, base, config) {
|
|
414
499
|
function extendWithClasses(stringsOrConfig) {
|
|
415
500
|
if (Array.isArray(stringsOrConfig) && "raw" in stringsOrConfig) {
|
|
416
|
-
const
|
|
417
|
-
const merged2 = twMerge(extractBaseClasses(base),
|
|
501
|
+
const rawExtra = stringsOrConfig.raw.join("").trim().replace(/\s+/g, " ");
|
|
502
|
+
const merged2 = twMerge(extractBaseClasses(base), extractBaseClasses(rawExtra));
|
|
418
503
|
const extended2 = createComponent(
|
|
419
504
|
originalTag,
|
|
420
505
|
typeof config === "string" ? merged2 : { ...config, base: merged2 }
|
|
421
506
|
);
|
|
422
507
|
carryOverSubComponents(extended2, component);
|
|
508
|
+
const extendSubBlocks = parseSubComponentBlocks(rawExtra);
|
|
509
|
+
if (extendSubBlocks.size > 0) {
|
|
510
|
+
const extComp = extended2;
|
|
511
|
+
const displayName = extended2.displayName ?? "tw";
|
|
512
|
+
for (const [subName, subClasses] of extendSubBlocks) {
|
|
513
|
+
extComp[subName] = createSubComponentAccessor(displayName, subName, subClasses);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
423
516
|
return extended2;
|
|
424
517
|
}
|
|
425
518
|
const extCfg = stringsOrConfig;
|
|
@@ -477,6 +570,7 @@ function createComponent(tag, config) {
|
|
|
477
570
|
const stateConfig = typeof config === "string" ? void 0 : config.state;
|
|
478
571
|
const containerConfig = typeof config === "string" ? void 0 : config.container;
|
|
479
572
|
const containerName = typeof config === "string" ? void 0 : config.containerName;
|
|
573
|
+
const configSub = typeof config === "string" ? void 0 : config.sub;
|
|
480
574
|
const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
|
|
481
575
|
const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
|
|
482
576
|
const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
|
|
@@ -495,8 +589,8 @@ function createComponent(tag, config) {
|
|
|
495
589
|
const component2 = baseComponent2;
|
|
496
590
|
component2.displayName = `tw.${tagLabel}`;
|
|
497
591
|
const result2 = attachExtend(component2, tag, base, config);
|
|
498
|
-
registerSubComponents(result2, base);
|
|
499
|
-
return result2;
|
|
592
|
+
registerSubComponents(result2, base, configSub);
|
|
593
|
+
return wrapWithSubProxy(result2, tagLabel);
|
|
500
594
|
}
|
|
501
595
|
const baseComponent = React3__default.default.forwardRef((props, ref) => {
|
|
502
596
|
const { className, ...rest } = props;
|
|
@@ -512,9 +606,39 @@ function createComponent(tag, config) {
|
|
|
512
606
|
const component = baseComponent;
|
|
513
607
|
component.displayName = `tw.${tagLabel}`;
|
|
514
608
|
const result = attachExtend(component, tag, base, config);
|
|
515
|
-
registerSubComponents(result, base);
|
|
516
|
-
return result;
|
|
609
|
+
registerSubComponents(result, base, configSub);
|
|
610
|
+
return wrapWithSubProxy(result, tagLabel);
|
|
611
|
+
}
|
|
612
|
+
var SKIP_PROXY_KEYS = /* @__PURE__ */ new Set([
|
|
613
|
+
"extend",
|
|
614
|
+
"withVariants",
|
|
615
|
+
"animate",
|
|
616
|
+
"withSub",
|
|
617
|
+
"displayName",
|
|
618
|
+
"$$typeof",
|
|
619
|
+
"render",
|
|
620
|
+
"prototype",
|
|
621
|
+
"__esModule",
|
|
622
|
+
"then"
|
|
623
|
+
]);
|
|
624
|
+
function wrapWithSubProxy(component, tagLabel) {
|
|
625
|
+
return new Proxy(component, {
|
|
626
|
+
get(target, prop) {
|
|
627
|
+
const value = target[prop];
|
|
628
|
+
if (value !== void 0) return value;
|
|
629
|
+
if (typeof prop === "symbol") return value;
|
|
630
|
+
if (SKIP_PROXY_KEYS.has(prop)) return value;
|
|
631
|
+
const Fallback = ({
|
|
632
|
+
children,
|
|
633
|
+
className
|
|
634
|
+
}) => React3__default.default.createElement("span", { className }, children);
|
|
635
|
+
Fallback.displayName = `tw.${tagLabel}.${prop}(fallback)`;
|
|
636
|
+
return Fallback;
|
|
637
|
+
}
|
|
638
|
+
});
|
|
517
639
|
}
|
|
640
|
+
|
|
641
|
+
// packages/domain/core/src/cv.ts
|
|
518
642
|
var __generatedRegistry = {};
|
|
519
643
|
function lookupGenerated(componentId, props, defaultVariants) {
|
|
520
644
|
const table = __generatedRegistry[componentId];
|
|
@@ -523,27 +647,40 @@ function lookupGenerated(componentId, props, defaultVariants) {
|
|
|
523
647
|
const key = Object.keys(merged).sort().filter((k) => k !== "className").map((k) => `${k}:${String(merged[k])}`).join("|");
|
|
524
648
|
return table[key];
|
|
525
649
|
}
|
|
526
|
-
function
|
|
650
|
+
function resolveVariantsNative(config, props) {
|
|
527
651
|
const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
|
|
528
|
-
const
|
|
529
|
-
if (
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
if (value !== void 0 && value !== null) {
|
|
534
|
-
const variantClass = variantMap[String(value)];
|
|
535
|
-
if (variantClass) classes.push(...variantClass.split(" ").filter(Boolean));
|
|
652
|
+
const binding = getNativeBinding();
|
|
653
|
+
if (binding?.resolveSimpleVariants) {
|
|
654
|
+
const mergedProps = {};
|
|
655
|
+
for (const [k, v] of Object.entries(defaultVariants)) {
|
|
656
|
+
if (v !== void 0 && v !== null) mergedProps[k] = String(v);
|
|
536
657
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
658
|
+
for (const [k, v] of Object.entries(props)) {
|
|
659
|
+
if (v !== void 0 && v !== null && k !== "className") {
|
|
660
|
+
mergedProps[k] = String(v);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
let result = binding.resolveSimpleVariants(
|
|
664
|
+
base || null,
|
|
665
|
+
variants,
|
|
666
|
+
{},
|
|
667
|
+
// already merged into mergedProps
|
|
668
|
+
mergedProps
|
|
669
|
+
);
|
|
670
|
+
const resolved = { ...defaultVariants, ...props };
|
|
671
|
+
const extra = [];
|
|
672
|
+
for (const compound of compoundVariants) {
|
|
673
|
+
const { class: compoundClass, className: compoundClassName, ...conditions } = compound;
|
|
674
|
+
const matches = Object.entries(conditions).every(([key, val]) => resolved[key] === val);
|
|
675
|
+
if (matches) {
|
|
676
|
+
if (compoundClass) extra.push(String(compoundClass));
|
|
677
|
+
if (compoundClassName) extra.push(String(compoundClassName));
|
|
678
|
+
}
|
|
544
679
|
}
|
|
680
|
+
if (extra.length > 0) result = `${result} ${extra.join(" ")}`.trim();
|
|
681
|
+
return result;
|
|
545
682
|
}
|
|
546
|
-
|
|
683
|
+
throw new Error("FATAL: Native binding 'resolveSimpleVariants' is required but not available.");
|
|
547
684
|
}
|
|
548
685
|
function cv(config, componentId) {
|
|
549
686
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -562,18 +699,34 @@ function cv(config, componentId) {
|
|
|
562
699
|
props,
|
|
563
700
|
config.defaultVariants
|
|
564
701
|
);
|
|
565
|
-
result = generated ??
|
|
702
|
+
result = generated ?? resolveVariantsNative(config, props);
|
|
566
703
|
} else {
|
|
567
|
-
result =
|
|
704
|
+
result = resolveVariantsNative(config, props);
|
|
568
705
|
}
|
|
569
|
-
return props.className ?
|
|
706
|
+
return props.className ? twMerge(result, props.className) : result;
|
|
570
707
|
};
|
|
571
708
|
}
|
|
709
|
+
|
|
710
|
+
// packages/domain/core/src/cx.ts
|
|
572
711
|
function cn(...inputs) {
|
|
573
|
-
|
|
712
|
+
const native = getNativeBinding();
|
|
713
|
+
if (!native?.resolveClassNames) {
|
|
714
|
+
throw new Error("FATAL: Native binding 'resolveClassNames' is required but not available.");
|
|
715
|
+
}
|
|
716
|
+
const strings = inputs.flat().filter(Boolean);
|
|
717
|
+
return native.resolveClassNames(strings);
|
|
574
718
|
}
|
|
575
719
|
function cx(...inputs) {
|
|
576
|
-
|
|
720
|
+
const filtered = inputs.flat().filter(Boolean);
|
|
721
|
+
if (filtered.length === 0) return "";
|
|
722
|
+
const native = getNativeBinding();
|
|
723
|
+
if (!native?.twMergeMany && !native?.twMerge) {
|
|
724
|
+
throw new Error("FATAL: Native binding 'twMerge' or 'twMergeMany' is required but not available.");
|
|
725
|
+
}
|
|
726
|
+
if (native.twMergeMany) {
|
|
727
|
+
return native.twMergeMany(filtered);
|
|
728
|
+
}
|
|
729
|
+
return native.twMerge(filtered.join(" "));
|
|
577
730
|
}
|
|
578
731
|
var cxm = cx;
|
|
579
732
|
var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
|
|
@@ -863,8 +1016,8 @@ function tokenVarRef(prefix, group, name) {
|
|
|
863
1016
|
}
|
|
864
1017
|
function resolveTokenRef(tokens, prefix, value) {
|
|
865
1018
|
if (value.startsWith("token:")) {
|
|
866
|
-
const
|
|
867
|
-
const [group, name] =
|
|
1019
|
+
const path3 = value.slice(6);
|
|
1020
|
+
const [group, name] = path3.split(".");
|
|
868
1021
|
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
869
1022
|
return tokenVarRef(prefix, group, name);
|
|
870
1023
|
}
|
|
@@ -963,13 +1116,13 @@ function createStyledSystem(config) {
|
|
|
963
1116
|
return createComponent(runtimeTag, merged);
|
|
964
1117
|
};
|
|
965
1118
|
}
|
|
966
|
-
function token(
|
|
967
|
-
const [group, name] =
|
|
968
|
-
if (!group || !name) return
|
|
1119
|
+
function token(path3) {
|
|
1120
|
+
const [group, name] = path3.split(".");
|
|
1121
|
+
if (!group || !name) return path3;
|
|
969
1122
|
return tokenVarRef(prefix, group, name);
|
|
970
1123
|
}
|
|
971
|
-
function rawToken(
|
|
972
|
-
const [group, name] =
|
|
1124
|
+
function rawToken(path3) {
|
|
1125
|
+
const [group, name] = path3.split(".");
|
|
973
1126
|
if (!group || !name) return void 0;
|
|
974
1127
|
return tokens[group]?.[name];
|
|
975
1128
|
}
|
|
@@ -1008,9 +1161,9 @@ function createStyledSystem(config) {
|
|
|
1008
1161
|
tokens
|
|
1009
1162
|
});
|
|
1010
1163
|
}
|
|
1011
|
-
var SUB_RE =
|
|
1164
|
+
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
1012
1165
|
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
1013
|
-
function
|
|
1166
|
+
function parseTemplateFallback(strings, exprs) {
|
|
1014
1167
|
const raw = strings.raw.reduce((acc, str, i) => {
|
|
1015
1168
|
const expr = exprs[i];
|
|
1016
1169
|
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
@@ -1021,17 +1174,30 @@ function parseTemplate(strings, exprs) {
|
|
|
1021
1174
|
let match;
|
|
1022
1175
|
SUB_RE.lastIndex = 0;
|
|
1023
1176
|
while ((match = SUB_RE.exec(raw)) !== null) {
|
|
1024
|
-
const name = match[1];
|
|
1025
|
-
const inner = match[
|
|
1177
|
+
const name = match[1] ?? match[2];
|
|
1178
|
+
const inner = match[3].replace(COMMENT_RE, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
1026
1179
|
subs[name] = inner;
|
|
1027
1180
|
base = base.replace(match[0], "");
|
|
1028
1181
|
}
|
|
1029
1182
|
const cleanBase = base.replace(COMMENT_RE, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
1030
|
-
return {
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1183
|
+
return { base: cleanBase, subs, hasSubs: Object.keys(subs).length > 0 };
|
|
1184
|
+
}
|
|
1185
|
+
function parseTemplate(strings, exprs) {
|
|
1186
|
+
const raw = strings.raw.reduce((acc, str, i) => {
|
|
1187
|
+
const expr = exprs[i];
|
|
1188
|
+
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
1189
|
+
return acc + str + String(exprStr);
|
|
1190
|
+
}, "");
|
|
1191
|
+
try {
|
|
1192
|
+
const binding = getNativeBinding();
|
|
1193
|
+
if (binding?.parseTemplate) {
|
|
1194
|
+
const result = binding.parseTemplate(raw);
|
|
1195
|
+
const subs = result.hasSubs ? JSON.parse(result.subsJson) : {};
|
|
1196
|
+
return { base: result.base, subs, hasSubs: result.hasSubs };
|
|
1197
|
+
}
|
|
1198
|
+
} catch {
|
|
1199
|
+
}
|
|
1200
|
+
return parseTemplateFallback(strings, exprs);
|
|
1035
1201
|
}
|
|
1036
1202
|
function makeTag(tag) {
|
|
1037
1203
|
return ((stringsOrConfig, ...exprs) => {
|