tailwind-styled-v4 4.0.0 → 5.0.1
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 +398 -0
- package/LICENSE +21 -0
- package/README.md +532 -0
- package/dist/analyzer.d.mts +114 -0
- package/dist/analyzer.d.ts +114 -0
- package/dist/analyzer.js +1555 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/analyzer.mjs +1544 -0
- package/dist/analyzer.mjs.map +1 -0
- package/dist/animate.d.mts +46 -0
- package/dist/animate.d.ts +41 -112
- package/dist/animate.js +792 -235
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +782 -0
- package/dist/animate.mjs.map +1 -0
- package/dist/atomic.d.mts +18 -0
- package/dist/atomic.d.ts +18 -0
- package/dist/atomic.js +191 -0
- package/dist/atomic.js.map +1 -0
- package/dist/atomic.mjs +185 -0
- package/dist/atomic.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +6063 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +6053 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/{compiler.d.cts → compiler.d.mts} +503 -210
- package/dist/compiler.d.ts +503 -210
- package/dist/compiler.js +1549 -566
- package/dist/compiler.js.map +1 -1
- package/dist/{compiler.cjs → compiler.mjs} +1476 -627
- package/dist/compiler.mjs.map +1 -0
- package/dist/dashboard.d.mts +272 -0
- package/dist/dashboard.d.ts +272 -0
- package/dist/dashboard.js +249 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/dashboard.mjs +239 -0
- package/dist/dashboard.mjs.map +1 -0
- package/dist/devtools.js +336 -211
- package/dist/devtools.js.map +1 -1
- package/dist/{devtools.cjs → devtools.mjs} +331 -220
- package/dist/devtools.mjs.map +1 -0
- package/dist/engine.d.mts +84 -0
- package/dist/engine.d.ts +84 -0
- package/dist/engine.js +3014 -0
- package/dist/engine.js.map +1 -0
- package/dist/engine.mjs +3005 -0
- package/dist/engine.mjs.map +1 -0
- package/dist/{index.d.cts → index.d.mts} +75 -4
- package/dist/index.d.ts +75 -4
- package/dist/index.js +1341 -149
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2162 -0
- package/dist/index.mjs.map +1 -0
- package/dist/liveTokenEngine-DYN3Zale.d.mts +34 -0
- package/dist/liveTokenEngine-DYN3Zale.d.ts +34 -0
- package/dist/next.d.mts +55 -0
- package/dist/next.d.ts +30 -20
- package/dist/next.js +6947 -149
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +7050 -0
- package/dist/next.mjs.map +1 -0
- package/dist/plugin.d.mts +90 -0
- package/dist/plugin.d.ts +90 -0
- package/dist/plugin.js +185 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugin.mjs +174 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/pluginRegistry.d.mts +83 -0
- package/dist/pluginRegistry.d.ts +83 -0
- package/dist/pluginRegistry.js +303 -0
- package/dist/pluginRegistry.js.map +1 -0
- package/dist/pluginRegistry.mjs +298 -0
- package/dist/pluginRegistry.mjs.map +1 -0
- package/dist/{preset.d.cts → preset.d.mts} +29 -2
- package/dist/preset.d.ts +29 -2
- package/dist/preset.js +318 -21
- package/dist/preset.js.map +1 -1
- package/dist/preset.mjs +414 -0
- package/dist/preset.mjs.map +1 -0
- package/dist/rspack.d.mts +33 -0
- package/dist/rspack.d.ts +33 -0
- package/dist/rspack.js +55 -0
- package/dist/rspack.js.map +1 -0
- package/dist/rspack.mjs +45 -0
- package/dist/rspack.mjs.map +1 -0
- package/dist/runtime.d.mts +62 -0
- package/dist/runtime.d.ts +62 -0
- package/dist/runtime.js +207 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.mjs +188 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/runtimeCss.d.mts +65 -0
- package/dist/runtimeCss.d.ts +65 -0
- package/dist/runtimeCss.js +188 -0
- package/dist/runtimeCss.js.map +1 -0
- package/dist/runtimeCss.mjs +173 -0
- package/dist/runtimeCss.mjs.map +1 -0
- package/dist/scanner.d.mts +25 -0
- package/dist/scanner.d.ts +25 -0
- package/dist/scanner.js +717 -0
- package/dist/scanner.js.map +1 -0
- package/dist/scanner.mjs +703 -0
- package/dist/scanner.mjs.map +1 -0
- package/dist/shared.d.mts +85 -0
- package/dist/shared.d.ts +85 -0
- package/dist/shared.js +255 -0
- package/dist/shared.js.map +1 -0
- package/dist/shared.mjs +233 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/storybookAddon.d.mts +108 -0
- package/dist/storybookAddon.d.ts +108 -0
- package/dist/storybookAddon.js +95 -0
- package/dist/storybookAddon.js.map +1 -0
- package/dist/storybookAddon.mjs +88 -0
- package/dist/storybookAddon.mjs.map +1 -0
- package/dist/svelte.d.mts +114 -0
- package/dist/svelte.d.ts +114 -0
- package/dist/svelte.js +67 -0
- package/dist/svelte.js.map +1 -0
- package/dist/svelte.mjs +59 -0
- package/dist/svelte.mjs.map +1 -0
- package/dist/testing.d.mts +185 -0
- package/dist/testing.d.ts +185 -0
- package/dist/testing.js +173 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.mjs +158 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/{theme.d.cts → theme.d.mts} +18 -11
- package/dist/theme.d.ts +18 -11
- package/dist/theme.js +205 -19
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +311 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/types-DXr2PmGP.d.mts +31 -0
- package/dist/types-DXr2PmGP.d.ts +31 -0
- package/dist/vite.d.mts +51 -0
- package/dist/vite.d.ts +35 -6
- package/dist/vite.js +4254 -57
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +4281 -0
- package/dist/vite.mjs.map +1 -0
- package/dist/vue.d.mts +89 -0
- package/dist/vue.d.ts +89 -0
- package/dist/vue.js +104 -0
- package/dist/vue.js.map +1 -0
- package/dist/vue.mjs +96 -0
- package/dist/vue.mjs.map +1 -0
- package/package.json +173 -67
- package/dist/animate.cjs +0 -252
- package/dist/animate.cjs.map +0 -1
- package/dist/animate.d.cts +0 -117
- package/dist/astTransform-ua-eapqs.d.cts +0 -41
- package/dist/astTransform-ua-eapqs.d.ts +0 -41
- package/dist/compiler.cjs.map +0 -1
- package/dist/css.cjs +0 -71
- package/dist/css.cjs.map +0 -1
- package/dist/css.d.cts +0 -45
- package/dist/css.d.ts +0 -45
- package/dist/css.js +0 -62
- package/dist/css.js.map +0 -1
- package/dist/devtools.cjs.map +0 -1
- package/dist/index.cjs +0 -1058
- package/dist/index.cjs.map +0 -1
- package/dist/next.cjs +0 -268
- package/dist/next.cjs.map +0 -1
- package/dist/next.d.cts +0 -45
- package/dist/plugins.cjs +0 -396
- package/dist/plugins.cjs.map +0 -1
- package/dist/plugins.d.cts +0 -231
- package/dist/plugins.d.ts +0 -231
- package/dist/plugins.js +0 -381
- package/dist/plugins.js.map +0 -1
- package/dist/preset.cjs +0 -129
- package/dist/preset.cjs.map +0 -1
- package/dist/theme.cjs +0 -154
- package/dist/theme.cjs.map +0 -1
- package/dist/turbopackLoader.cjs +0 -2689
- package/dist/turbopackLoader.cjs.map +0 -1
- package/dist/turbopackLoader.d.cts +0 -22
- package/dist/turbopackLoader.d.ts +0 -22
- package/dist/turbopackLoader.js +0 -2681
- package/dist/turbopackLoader.js.map +0 -1
- package/dist/vite.cjs +0 -105
- package/dist/vite.cjs.map +0 -1
- package/dist/vite.d.cts +0 -22
- package/dist/webpackLoader.cjs +0 -2670
- package/dist/webpackLoader.cjs.map +0 -1
- package/dist/webpackLoader.d.cts +0 -24
- package/dist/webpackLoader.d.ts +0 -24
- package/dist/webpackLoader.js +0 -2662
- package/dist/webpackLoader.js.map +0 -1
- /package/dist/{devtools.d.cts → devtools.d.mts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,46 +1,877 @@
|
|
|
1
|
-
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var module$1 = require('module');
|
|
5
|
+
var os = require('os');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var url = require('url');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var tailwindMerge = require('tailwind-merge');
|
|
10
|
+
|
|
11
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
12
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
15
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
16
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
|
+
|
|
19
|
+
/* tailwind-styled-v4 v5.0.1 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
5
20
|
var __defProp = Object.defineProperty;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
21
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
22
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
23
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
25
25
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
26
26
|
}) : x)(function(x) {
|
|
27
27
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
28
28
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
29
29
|
});
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
for (var prop in source)
|
|
33
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
34
|
-
target[prop] = source[prop];
|
|
35
|
-
if (source != null && __getOwnPropSymbols)
|
|
36
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
37
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
38
|
-
target[prop] = source[prop];
|
|
39
|
-
}
|
|
40
|
-
return target;
|
|
30
|
+
var __esm = (fn, res) => function __init() {
|
|
31
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
41
32
|
};
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name in all)
|
|
35
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
|
+
};
|
|
37
|
+
var __copyProps = (to, from, except, desc) => {
|
|
38
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
39
|
+
for (let key of __getOwnPropNames(from))
|
|
40
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
41
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
42
|
+
}
|
|
43
|
+
return to;
|
|
44
|
+
};
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
|
|
47
|
+
// packages/shared/src/cache.ts
|
|
48
|
+
var LRUCache;
|
|
49
|
+
var init_cache = __esm({
|
|
50
|
+
"packages/shared/src/cache.ts"() {
|
|
51
|
+
LRUCache = class {
|
|
52
|
+
constructor(max = 256, ttlMs = null) {
|
|
53
|
+
this.map = /* @__PURE__ */ new Map();
|
|
54
|
+
this.max = max;
|
|
55
|
+
this.ttlMs = ttlMs;
|
|
56
|
+
}
|
|
57
|
+
get(key) {
|
|
58
|
+
const entry = this.map.get(key);
|
|
59
|
+
if (!entry) return void 0;
|
|
60
|
+
if (this.ttlMs !== null && Date.now() - entry.ts > this.ttlMs) {
|
|
61
|
+
this.map.delete(key);
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
this.map.delete(key);
|
|
65
|
+
this.map.set(key, entry);
|
|
66
|
+
return entry.value;
|
|
67
|
+
}
|
|
68
|
+
set(key, value) {
|
|
69
|
+
if (this.map.has(key)) this.map.delete(key);
|
|
70
|
+
else if (this.map.size >= this.max) {
|
|
71
|
+
this.map.delete(this.map.keys().next().value);
|
|
72
|
+
}
|
|
73
|
+
this.map.set(key, { value, ts: Date.now() });
|
|
74
|
+
}
|
|
75
|
+
has(key) {
|
|
76
|
+
return this.get(key) !== void 0;
|
|
77
|
+
}
|
|
78
|
+
delete(key) {
|
|
79
|
+
this.map.delete(key);
|
|
80
|
+
}
|
|
81
|
+
clear() {
|
|
82
|
+
this.map.clear();
|
|
83
|
+
}
|
|
84
|
+
get size() {
|
|
85
|
+
return this.map.size;
|
|
86
|
+
}
|
|
87
|
+
keys() {
|
|
88
|
+
return this.map.keys();
|
|
89
|
+
}
|
|
90
|
+
*values() {
|
|
91
|
+
for (const entry of this.map.values()) {
|
|
92
|
+
yield entry.value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
*entries() {
|
|
96
|
+
for (const [key, entry] of this.map.entries()) {
|
|
97
|
+
yield [key, entry.value];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
function getPlatformExtension() {
|
|
104
|
+
const platform = os__default.default.platform();
|
|
105
|
+
switch (platform) {
|
|
106
|
+
case "win32":
|
|
107
|
+
return ".node";
|
|
108
|
+
case "darwin":
|
|
109
|
+
return ".dylib";
|
|
110
|
+
case "linux":
|
|
111
|
+
return ".so";
|
|
112
|
+
default:
|
|
113
|
+
return ".node";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function formatErrorMessage(error) {
|
|
117
|
+
return error instanceof Error ? error.message : String(error);
|
|
118
|
+
}
|
|
119
|
+
function resolveRuntimeDir(dirnameValue, moduleImportUrl) {
|
|
120
|
+
if (typeof dirnameValue === "string" && dirnameValue.length > 0) return dirnameValue;
|
|
121
|
+
return path__default.default.dirname(url.fileURLToPath(moduleImportUrl));
|
|
122
|
+
}
|
|
123
|
+
function resolveNativeBindingCandidates(options) {
|
|
124
|
+
const out = [];
|
|
125
|
+
const envVarNames = options.envVarNames ?? ["TWS_NATIVE_PATH"];
|
|
126
|
+
for (const envVarName of envVarNames) {
|
|
127
|
+
const raw = process.env[envVarName]?.trim();
|
|
128
|
+
if (!raw) continue;
|
|
129
|
+
const resolved = path__default.default.resolve(raw);
|
|
130
|
+
if (options.enforceNodeExtensionForEnvPath) {
|
|
131
|
+
if (path__default.default.extname(resolved).toLowerCase() !== ".node") {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Invalid native binding path from ${envVarName}="${raw}". Expected a .node file.`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
out.push(resolved);
|
|
138
|
+
}
|
|
139
|
+
if (options.includeDefaultCandidates !== false) {
|
|
140
|
+
const ext = options.platformExtension ?? getPlatformExtension();
|
|
141
|
+
const defaultBindingName = `tailwind_styled_parser${ext}`;
|
|
142
|
+
out.push(path__default.default.resolve(process.cwd(), "native", defaultBindingName));
|
|
143
|
+
out.push(path__default.default.resolve(options.runtimeDir, "..", "..", "..", "native", defaultBindingName));
|
|
144
|
+
}
|
|
145
|
+
return Array.from(new Set(out));
|
|
146
|
+
}
|
|
147
|
+
function parseDebugToken(namespace, token) {
|
|
148
|
+
if (token === "*" || token === namespace || token === "tailwind-styled:*") return true;
|
|
149
|
+
return token.endsWith("*") && namespace.startsWith(token.slice(0, -1));
|
|
150
|
+
}
|
|
151
|
+
function isDebugNamespaceEnabled(namespace) {
|
|
152
|
+
if (process.env.TWS_DEBUG === "1" || process.env.TAILWIND_STYLED_DEBUG === "1") return true;
|
|
153
|
+
const raw = process.env.DEBUG;
|
|
154
|
+
if (!raw) return false;
|
|
155
|
+
return raw.split(",").map((token) => token.trim()).some((token) => parseDebugToken(namespace, token));
|
|
156
|
+
}
|
|
157
|
+
function createDebugLogger(namespace, label = namespace) {
|
|
158
|
+
const debugEnabled = isDebugNamespaceEnabled(namespace);
|
|
159
|
+
return (message) => {
|
|
160
|
+
if (!debugEnabled) return;
|
|
161
|
+
console.debug(`[${label}] ${message}`);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function loadNativeBinding(options) {
|
|
165
|
+
const req = module$1.createRequire(path__default.default.join(options.runtimeDir, "noop.cjs"));
|
|
166
|
+
const loadErrors = [];
|
|
167
|
+
for (const candidate of options.candidates) {
|
|
168
|
+
if (!fs__default.default.existsSync(candidate)) continue;
|
|
169
|
+
try {
|
|
170
|
+
const mod = req(candidate);
|
|
171
|
+
if (options.isValid(mod)) {
|
|
172
|
+
return {
|
|
173
|
+
binding: mod,
|
|
174
|
+
loadedPath: candidate,
|
|
175
|
+
loadErrors
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
loadErrors.push({
|
|
179
|
+
path: candidate,
|
|
180
|
+
message: options.invalidExportMessage
|
|
181
|
+
});
|
|
182
|
+
} catch (error) {
|
|
183
|
+
loadErrors.push({
|
|
184
|
+
path: candidate,
|
|
185
|
+
message: formatErrorMessage(error)
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
binding: null,
|
|
191
|
+
loadedPath: null,
|
|
192
|
+
loadErrors
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var init_nativeBinding = __esm({
|
|
196
|
+
"packages/shared/src/nativeBinding.ts"() {
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// packages/shared/src/index.ts
|
|
201
|
+
var init_src = __esm({
|
|
202
|
+
"packages/shared/src/index.ts"() {
|
|
203
|
+
init_cache();
|
|
204
|
+
init_nativeBinding();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// packages/animate/src/binding.ts
|
|
209
|
+
function isAnimateModule(module) {
|
|
210
|
+
const candidate = module;
|
|
211
|
+
return typeof candidate?.compileAnimation === "function" && typeof candidate?.compileKeyframes === "function";
|
|
212
|
+
}
|
|
213
|
+
function resolveBindingCandidates(runtimeDir) {
|
|
214
|
+
return resolveNativeBindingCandidates({
|
|
215
|
+
runtimeDir,
|
|
216
|
+
envVarNames: ["TWS_ANIMATE_NATIVE_PATH", "TWS_NATIVE_PATH"],
|
|
217
|
+
enforceNodeExtensionForEnvPath: true
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function loadAnimateBinding() {
|
|
221
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
222
|
+
throw new Error(
|
|
223
|
+
"Native animate backend is required in v5. TWS_NO_NATIVE/TWS_NO_RUST is not supported."
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
const runtimeDir = resolveRuntimeDir(
|
|
227
|
+
typeof __dirname === "string" ? __dirname : void 0,
|
|
228
|
+
(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))
|
|
229
|
+
);
|
|
230
|
+
const candidates = resolveBindingCandidates(runtimeDir);
|
|
231
|
+
const { binding, loadErrors, loadedPath } = loadNativeBinding({
|
|
232
|
+
runtimeDir,
|
|
233
|
+
candidates,
|
|
234
|
+
isValid: isAnimateModule,
|
|
235
|
+
invalidExportMessage: "Module loaded but missing compileAnimation/compileKeyframes exports."
|
|
236
|
+
});
|
|
237
|
+
if (binding) {
|
|
238
|
+
debugLog(`native animate binding loaded from: ${loadedPath}`);
|
|
239
|
+
return binding;
|
|
240
|
+
}
|
|
241
|
+
if (loadErrors.length > 0) {
|
|
242
|
+
debugLog(
|
|
243
|
+
`native animate binding load failed for ${loadErrors.length} candidate(s): ${loadErrors.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
|
|
244
|
+
);
|
|
245
|
+
} else {
|
|
246
|
+
debugLog("native animate binding not found in any candidate path");
|
|
247
|
+
}
|
|
248
|
+
const lines = [
|
|
249
|
+
"Native animate backend not found. Ensure `tailwind_styled_parser.node` is built.",
|
|
250
|
+
"Checked paths:",
|
|
251
|
+
...candidates.map((candidate) => `- ${candidate}`)
|
|
252
|
+
];
|
|
253
|
+
if (loadErrors.length > 0) {
|
|
254
|
+
lines.push("Load errors:");
|
|
255
|
+
for (const error of loadErrors) lines.push(`- ${error.path}: ${error.message}`);
|
|
256
|
+
}
|
|
257
|
+
throw new Error(lines.join("\n"));
|
|
258
|
+
}
|
|
259
|
+
async function getAnimateBinding() {
|
|
260
|
+
if (!bindingPromise) {
|
|
261
|
+
bindingPromise = Promise.resolve().then(loadAnimateBinding);
|
|
262
|
+
}
|
|
263
|
+
return bindingPromise;
|
|
264
|
+
}
|
|
265
|
+
async function initAnimate() {
|
|
266
|
+
await getAnimateBinding();
|
|
267
|
+
}
|
|
268
|
+
var bindingPromise, DEBUG_NAMESPACE, debugLog;
|
|
269
|
+
var init_binding = __esm({
|
|
270
|
+
"packages/animate/src/binding.ts"() {
|
|
271
|
+
init_src();
|
|
272
|
+
bindingPromise = null;
|
|
273
|
+
DEBUG_NAMESPACE = "tailwind-styled:animate";
|
|
274
|
+
debugLog = createDebugLogger(DEBUG_NAMESPACE, "tailwind-styled/animate");
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// packages/animate/src/preset.ts
|
|
279
|
+
function createAnimationPresets(registry) {
|
|
280
|
+
const cache2 = new LRUCache(DEFAULT_PRESET_CACHE_LIMIT);
|
|
281
|
+
const withCache = (cacheKey, factory) => async () => {
|
|
282
|
+
const cached = cache2.get(cacheKey);
|
|
283
|
+
if (cached) {
|
|
284
|
+
const className = await cached;
|
|
285
|
+
if (registry.has(className)) return className;
|
|
286
|
+
cache2.delete(cacheKey);
|
|
287
|
+
}
|
|
288
|
+
const pending = factory();
|
|
289
|
+
cache2.set(cacheKey, pending);
|
|
290
|
+
try {
|
|
291
|
+
return await pending;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
cache2.delete(cacheKey);
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
fadeIn: withCache(
|
|
299
|
+
"fadeIn",
|
|
300
|
+
async () => (await registry.compileAnimation({ from: "opacity-0", to: "opacity-100", duration: 200 })).className
|
|
301
|
+
),
|
|
302
|
+
fadeOut: withCache(
|
|
303
|
+
"fadeOut",
|
|
304
|
+
async () => (await registry.compileAnimation({ from: "opacity-100", to: "opacity-0", duration: 200 })).className
|
|
305
|
+
),
|
|
306
|
+
slideUp: withCache(
|
|
307
|
+
"slideUp",
|
|
308
|
+
async () => (await registry.compileAnimation({
|
|
309
|
+
from: "opacity-0 translate-y-4",
|
|
310
|
+
to: "opacity-100 translate-y-0",
|
|
311
|
+
duration: 300
|
|
312
|
+
})).className
|
|
313
|
+
),
|
|
314
|
+
slideDown: withCache(
|
|
315
|
+
"slideDown",
|
|
316
|
+
async () => (await registry.compileAnimation({
|
|
317
|
+
from: "opacity-0 -translate-y-4",
|
|
318
|
+
to: "opacity-100 translate-y-0",
|
|
319
|
+
duration: 300
|
|
320
|
+
})).className
|
|
321
|
+
),
|
|
322
|
+
slideLeft: withCache(
|
|
323
|
+
"slideLeft",
|
|
324
|
+
async () => (await registry.compileAnimation({
|
|
325
|
+
from: "opacity-0 translate-x-4",
|
|
326
|
+
to: "opacity-100 translate-x-0",
|
|
327
|
+
duration: 300
|
|
328
|
+
})).className
|
|
329
|
+
),
|
|
330
|
+
slideRight: withCache(
|
|
331
|
+
"slideRight",
|
|
332
|
+
async () => (await registry.compileAnimation({
|
|
333
|
+
from: "opacity-0 -translate-x-4",
|
|
334
|
+
to: "opacity-100 translate-x-0",
|
|
335
|
+
duration: 300
|
|
336
|
+
})).className
|
|
337
|
+
),
|
|
338
|
+
scaleIn: withCache(
|
|
339
|
+
"scaleIn",
|
|
340
|
+
async () => (await registry.compileAnimation({
|
|
341
|
+
from: "opacity-0 scale-95",
|
|
342
|
+
to: "opacity-100 scale-100",
|
|
343
|
+
duration: 200,
|
|
344
|
+
easing: "cubic-bezier(0.16,1,0.3,1)"
|
|
345
|
+
})).className
|
|
346
|
+
),
|
|
347
|
+
scaleOut: withCache(
|
|
348
|
+
"scaleOut",
|
|
349
|
+
async () => (await registry.compileAnimation({
|
|
350
|
+
from: "opacity-100 scale-100",
|
|
351
|
+
to: "opacity-0 scale-95",
|
|
352
|
+
duration: 150
|
|
353
|
+
})).className
|
|
354
|
+
),
|
|
355
|
+
blurIn: withCache(
|
|
356
|
+
"blurIn",
|
|
357
|
+
async () => (await registry.compileAnimation({
|
|
358
|
+
from: "opacity-0 blur-sm",
|
|
359
|
+
to: "opacity-100 blur-none",
|
|
360
|
+
duration: 300
|
|
361
|
+
})).className
|
|
362
|
+
),
|
|
363
|
+
bounceIn: withCache(
|
|
364
|
+
"bounceIn",
|
|
365
|
+
async () => (await registry.compileAnimation({
|
|
366
|
+
from: "opacity-0 scale-50",
|
|
367
|
+
to: "opacity-100 scale-100",
|
|
368
|
+
duration: 400,
|
|
369
|
+
easing: "cubic-bezier(0.34,1.56,0.64,1)"
|
|
370
|
+
})).className
|
|
371
|
+
),
|
|
372
|
+
spinIn: withCache(
|
|
373
|
+
"spinIn",
|
|
374
|
+
async () => (await registry.compileAnimation({
|
|
375
|
+
from: "opacity-0 rotate-180 scale-50",
|
|
376
|
+
to: "opacity-100 rotate-0 scale-100",
|
|
377
|
+
duration: 400,
|
|
378
|
+
easing: "cubic-bezier(0.16,1,0.3,1)"
|
|
379
|
+
})).className
|
|
380
|
+
)
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
var DEFAULT_PRESET_CACHE_LIMIT;
|
|
384
|
+
var init_preset = __esm({
|
|
385
|
+
"packages/animate/src/preset.ts"() {
|
|
386
|
+
init_src();
|
|
387
|
+
DEFAULT_PRESET_CACHE_LIMIT = 32;
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
function formatErrorMessage2(error) {
|
|
391
|
+
return error instanceof Error ? error.message : String(error);
|
|
392
|
+
}
|
|
393
|
+
var DEBUG_NAMESPACE2, debugLog2;
|
|
394
|
+
var init_utils = __esm({
|
|
395
|
+
"packages/analyzer/src/utils.ts"() {
|
|
396
|
+
init_src();
|
|
397
|
+
DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
|
|
398
|
+
debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// packages/analyzer/src/binding.ts
|
|
403
|
+
function isAnalyzerModule(module) {
|
|
404
|
+
const candidate = module;
|
|
405
|
+
return typeof candidate?.analyzeClasses === "function";
|
|
406
|
+
}
|
|
407
|
+
function getNativeBinding() {
|
|
408
|
+
if (bindingCache !== void 0) return bindingCache;
|
|
409
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
410
|
+
bindingCandidateCache = [];
|
|
411
|
+
bindingLoadErrorsCache = [];
|
|
412
|
+
loadedBindingPathCache = null;
|
|
413
|
+
debugLog2("native binding disabled by TWS_NO_NATIVE/TWS_NO_RUST");
|
|
414
|
+
bindingCache = null;
|
|
415
|
+
return bindingCache;
|
|
416
|
+
}
|
|
417
|
+
const runtimeDir = resolveRuntimeDir(
|
|
418
|
+
typeof __dirname === "string" ? __dirname : void 0,
|
|
419
|
+
(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))
|
|
420
|
+
);
|
|
421
|
+
const candidates = resolveNativeBindingCandidates({
|
|
422
|
+
runtimeDir,
|
|
423
|
+
envVarNames: ["TWS_NATIVE_PATH"]
|
|
424
|
+
});
|
|
425
|
+
const { binding, loadErrors, loadedPath } = loadNativeBinding({
|
|
426
|
+
runtimeDir,
|
|
427
|
+
candidates,
|
|
428
|
+
isValid: isAnalyzerModule,
|
|
429
|
+
invalidExportMessage: "Module loaded but missing `analyzeClasses` export."
|
|
430
|
+
});
|
|
431
|
+
bindingCandidateCache = candidates;
|
|
432
|
+
bindingLoadErrorsCache = loadErrors;
|
|
433
|
+
loadedBindingPathCache = loadedPath;
|
|
434
|
+
if (binding) {
|
|
435
|
+
debugLog2(`native binding loaded from: ${loadedPath}`);
|
|
436
|
+
bindingCache = binding;
|
|
437
|
+
return bindingCache;
|
|
438
|
+
}
|
|
439
|
+
if (bindingLoadErrorsCache.length > 0) {
|
|
440
|
+
debugLog2(
|
|
441
|
+
`native binding load failed for ${bindingLoadErrorsCache.length} candidate(s): ${bindingLoadErrorsCache.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
|
|
442
|
+
);
|
|
443
|
+
} else {
|
|
444
|
+
debugLog2("native binding not found in any candidate path");
|
|
445
|
+
}
|
|
446
|
+
bindingCache = null;
|
|
447
|
+
return bindingCache;
|
|
448
|
+
}
|
|
449
|
+
function requireNativeBinding() {
|
|
450
|
+
const binding = getNativeBinding();
|
|
451
|
+
if (binding?.analyzeClasses) return binding;
|
|
452
|
+
const lines = [
|
|
453
|
+
"Native analyzer binding not found. Ensure `tailwind_styled_parser.node` is built."
|
|
454
|
+
];
|
|
455
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
456
|
+
lines.push("Native loading is disabled by TWS_NO_NATIVE/TWS_NO_RUST.");
|
|
457
|
+
} else {
|
|
458
|
+
lines.push("Checked paths:");
|
|
459
|
+
for (const candidate of bindingCandidateCache) lines.push(`- ${candidate}`);
|
|
460
|
+
if (bindingLoadErrorsCache.length > 0) {
|
|
461
|
+
lines.push("Load errors:");
|
|
462
|
+
for (const failure of bindingLoadErrorsCache) {
|
|
463
|
+
lines.push(`- ${failure.path}: ${failure.message}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
throw new Error(lines.join("\n"));
|
|
468
|
+
}
|
|
469
|
+
function requireNativeCssCompiler() {
|
|
470
|
+
const binding = requireNativeBinding();
|
|
471
|
+
if (typeof binding.compileCss === "function") return binding;
|
|
472
|
+
const loadedPathText = loadedBindingPathCache ? ` (${loadedBindingPathCache})` : "";
|
|
473
|
+
throw new Error(`Native analyzer compileCss binding is missing in v5${loadedPathText}.`);
|
|
474
|
+
}
|
|
475
|
+
var bindingCache, bindingCandidateCache, bindingLoadErrorsCache, loadedBindingPathCache;
|
|
476
|
+
var init_binding2 = __esm({
|
|
477
|
+
"packages/analyzer/src/binding.ts"() {
|
|
478
|
+
init_src();
|
|
479
|
+
init_utils();
|
|
480
|
+
bindingCandidateCache = [];
|
|
481
|
+
bindingLoadErrorsCache = [];
|
|
482
|
+
loadedBindingPathCache = null;
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// packages/analyzer/src/classToCss.ts
|
|
487
|
+
function normalizeClassInput(input) {
|
|
488
|
+
if (typeof input === "string") {
|
|
489
|
+
return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
490
|
+
}
|
|
491
|
+
if (!Array.isArray(input)) {
|
|
492
|
+
throw new TypeError("classToCss input must be a string or an array of strings.");
|
|
493
|
+
}
|
|
494
|
+
const out = [];
|
|
495
|
+
for (const item of input) {
|
|
496
|
+
if (typeof item !== "string") {
|
|
497
|
+
throw new TypeError("classToCss input array must contain only strings.");
|
|
498
|
+
}
|
|
499
|
+
const value = item.trim();
|
|
500
|
+
if (value.length > 0) out.push(value);
|
|
501
|
+
}
|
|
502
|
+
return out;
|
|
503
|
+
}
|
|
504
|
+
function normalizeClassToCssOptions(options) {
|
|
505
|
+
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
|
506
|
+
throw new TypeError("classToCss options must be an object.");
|
|
507
|
+
}
|
|
508
|
+
const strict = options.strict ?? false;
|
|
509
|
+
if (typeof strict !== "boolean") {
|
|
510
|
+
throw new TypeError("classToCss options.strict must be a boolean when provided.");
|
|
511
|
+
}
|
|
512
|
+
const prefix = options.prefix ?? null;
|
|
513
|
+
if (prefix !== null && typeof prefix !== "string") {
|
|
514
|
+
throw new TypeError("classToCss options.prefix must be a string or null when provided.");
|
|
515
|
+
}
|
|
516
|
+
return { prefix, strict };
|
|
517
|
+
}
|
|
518
|
+
function mergeDeclarationMap(target, css) {
|
|
519
|
+
const ruleRegex = /\{([^}]*)\}/g;
|
|
520
|
+
let ruleMatch = ruleRegex.exec(css);
|
|
521
|
+
while (ruleMatch) {
|
|
522
|
+
const body = ruleMatch[1];
|
|
523
|
+
for (const raw of body.split(";")) {
|
|
524
|
+
const declaration = raw.trim();
|
|
525
|
+
if (declaration.length === 0) continue;
|
|
526
|
+
const colonIndex = declaration.indexOf(":");
|
|
527
|
+
if (colonIndex <= 0) continue;
|
|
528
|
+
const property = declaration.slice(0, colonIndex).trim();
|
|
529
|
+
const value = declaration.slice(colonIndex + 1).trim();
|
|
530
|
+
if (property.length === 0 || value.length === 0) continue;
|
|
531
|
+
if (target.has(property)) target.delete(property);
|
|
532
|
+
target.set(property, value);
|
|
533
|
+
}
|
|
534
|
+
ruleMatch = ruleRegex.exec(css);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function declarationMapToString(declarationMap) {
|
|
538
|
+
return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
|
|
539
|
+
}
|
|
540
|
+
async function classToCss(input, options = {}) {
|
|
541
|
+
const inputClasses = normalizeClassInput(input);
|
|
542
|
+
const normalizedOptions = normalizeClassToCssOptions(options);
|
|
543
|
+
if (inputClasses.length === 0) {
|
|
544
|
+
return {
|
|
545
|
+
inputClasses: [],
|
|
546
|
+
css: "",
|
|
547
|
+
declarations: "",
|
|
548
|
+
resolvedClasses: [],
|
|
549
|
+
unknownClasses: [],
|
|
550
|
+
sizeBytes: 0
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
const binding = requireNativeCssCompiler();
|
|
554
|
+
const prefix = normalizedOptions.prefix;
|
|
555
|
+
const cssChunks = [];
|
|
556
|
+
const resolvedClasses = [];
|
|
557
|
+
const unknownClasses = [];
|
|
558
|
+
let sizeBytes = 0;
|
|
559
|
+
const declarationMap = /* @__PURE__ */ new Map();
|
|
560
|
+
for (const className of inputClasses) {
|
|
561
|
+
let compiled = null;
|
|
562
|
+
try {
|
|
563
|
+
compiled = binding.compileCss([className], prefix);
|
|
564
|
+
} catch (error) {
|
|
565
|
+
throw new Error(
|
|
566
|
+
`Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
|
|
567
|
+
{ cause: error }
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
if (!compiled) {
|
|
571
|
+
throw new Error(`Native analyzer returned no result for class "${className}".`);
|
|
572
|
+
}
|
|
573
|
+
cssChunks.push(compiled.css);
|
|
574
|
+
resolvedClasses.push(...compiled.resolvedClasses);
|
|
575
|
+
unknownClasses.push(...compiled.unknownClasses);
|
|
576
|
+
sizeBytes += compiled.sizeBytes;
|
|
577
|
+
mergeDeclarationMap(declarationMap, compiled.css);
|
|
578
|
+
}
|
|
579
|
+
const uniqueUnknown = Array.from(new Set(unknownClasses));
|
|
580
|
+
if (normalizedOptions.strict && uniqueUnknown.length > 0) {
|
|
581
|
+
throw new Error(`Unknown Tailwind classes: ${uniqueUnknown.join(", ")}`);
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
inputClasses,
|
|
585
|
+
css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
|
|
586
|
+
declarations: declarationMapToString(declarationMap),
|
|
587
|
+
resolvedClasses: Array.from(new Set(resolvedClasses)),
|
|
588
|
+
unknownClasses: uniqueUnknown,
|
|
589
|
+
sizeBytes
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
var init_classToCss = __esm({
|
|
593
|
+
"packages/analyzer/src/classToCss.ts"() {
|
|
594
|
+
init_binding2();
|
|
595
|
+
init_utils();
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// packages/analyzer/src/index.ts
|
|
600
|
+
var init_src2 = __esm({
|
|
601
|
+
"packages/analyzer/src/index.ts"() {
|
|
602
|
+
init_classToCss();
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// packages/animate/src/registry.ts
|
|
607
|
+
function normalizeNumber(value, fallback) {
|
|
608
|
+
if (!Number.isFinite(value)) return fallback;
|
|
609
|
+
return Math.max(0, Math.trunc(value));
|
|
610
|
+
}
|
|
611
|
+
function normalizeCacheLimit(value) {
|
|
612
|
+
if (!Number.isFinite(value)) return DEFAULT_CACHE_LIMIT;
|
|
613
|
+
return Math.max(1, Math.trunc(value));
|
|
614
|
+
}
|
|
615
|
+
function normalizeIterations(value) {
|
|
616
|
+
if (value === "infinite") return "infinite";
|
|
617
|
+
if (!Number.isFinite(value)) return String(DEFAULT_ITERATIONS);
|
|
618
|
+
return String(Math.max(0, Math.trunc(value)));
|
|
619
|
+
}
|
|
620
|
+
function stableKeyframesEntries(stops) {
|
|
621
|
+
return Object.entries(stops).map(([offset, classes]) => ({ offset, classes })).sort((left, right) => left.offset.localeCompare(right.offset));
|
|
622
|
+
}
|
|
623
|
+
function animationCacheKey(opts) {
|
|
624
|
+
const normalized = {
|
|
625
|
+
from: opts.from.trim(),
|
|
626
|
+
to: opts.to.trim(),
|
|
627
|
+
duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
|
|
628
|
+
easing: (opts.easing ?? DEFAULT_EASING).trim(),
|
|
629
|
+
delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
|
|
630
|
+
fill: opts.fill ?? DEFAULT_FILL,
|
|
631
|
+
iterations: normalizeIterations(opts.iterations),
|
|
632
|
+
direction: opts.direction ?? DEFAULT_DIRECTION,
|
|
633
|
+
name: opts.name ?? ""
|
|
634
|
+
};
|
|
635
|
+
return JSON.stringify(normalized);
|
|
636
|
+
}
|
|
637
|
+
function keyframesCacheKey(name, stops) {
|
|
638
|
+
return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
|
|
639
|
+
}
|
|
640
|
+
function splitClasses(classList) {
|
|
641
|
+
return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
642
|
+
}
|
|
643
|
+
async function validateTailwindClasses(entries) {
|
|
644
|
+
const binding = await getAnimateBinding();
|
|
645
|
+
const unknownByContext = /* @__PURE__ */ new Map();
|
|
646
|
+
const failures = [];
|
|
647
|
+
for (const entry of entries) {
|
|
648
|
+
const classes = splitClasses(entry.classList);
|
|
649
|
+
if (classes.length === 0) continue;
|
|
650
|
+
try {
|
|
651
|
+
if (typeof binding.compileCss === "function") {
|
|
652
|
+
const compiled = binding.compileCss(classes, null);
|
|
653
|
+
if (!compiled) {
|
|
654
|
+
failures.push(
|
|
655
|
+
`Animation ${entry.context} failed validation: native compileCss returned no result.`
|
|
656
|
+
);
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (compiled.unknownClasses.length > 0) {
|
|
660
|
+
const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
|
|
661
|
+
for (const className of compiled.unknownClasses) bucket.add(className);
|
|
662
|
+
unknownByContext.set(entry.context, bucket);
|
|
663
|
+
}
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const checked = await classToCss(classes, { strict: false });
|
|
667
|
+
if (checked.unknownClasses.length > 0) {
|
|
668
|
+
const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
|
|
669
|
+
for (const className of checked.unknownClasses) bucket.add(className);
|
|
670
|
+
unknownByContext.set(entry.context, bucket);
|
|
671
|
+
}
|
|
672
|
+
} catch (error) {
|
|
673
|
+
failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
const issues = [];
|
|
677
|
+
for (const [context, classes] of unknownByContext.entries()) {
|
|
678
|
+
issues.push(
|
|
679
|
+
`Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
issues.push(...failures);
|
|
683
|
+
if (issues.length > 0) {
|
|
684
|
+
throw new Error(issues.join("\n"));
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
function createAnimationRegistry(options = {}) {
|
|
688
|
+
return new AnimationRegistry(options);
|
|
689
|
+
}
|
|
690
|
+
var DEFAULT_DURATION, DEFAULT_EASING, DEFAULT_DELAY, DEFAULT_FILL, DEFAULT_ITERATIONS, DEFAULT_DIRECTION, DEFAULT_CACHE_LIMIT, AnimationRegistry;
|
|
691
|
+
var init_registry = __esm({
|
|
692
|
+
"packages/animate/src/registry.ts"() {
|
|
693
|
+
init_src2();
|
|
694
|
+
init_src();
|
|
695
|
+
init_binding();
|
|
696
|
+
DEFAULT_DURATION = 300;
|
|
697
|
+
DEFAULT_EASING = "ease-out";
|
|
698
|
+
DEFAULT_DELAY = 0;
|
|
699
|
+
DEFAULT_FILL = "both";
|
|
700
|
+
DEFAULT_ITERATIONS = 1;
|
|
701
|
+
DEFAULT_DIRECTION = "normal";
|
|
702
|
+
DEFAULT_CACHE_LIMIT = 512;
|
|
703
|
+
AnimationRegistry = class {
|
|
704
|
+
constructor(options = {}) {
|
|
705
|
+
const cacheLimit = normalizeCacheLimit(options.cacheLimit);
|
|
706
|
+
this.animations = new LRUCache(cacheLimit);
|
|
707
|
+
this.animationBySignature = new LRUCache(cacheLimit);
|
|
708
|
+
this.keyframesBySignature = new LRUCache(cacheLimit);
|
|
709
|
+
}
|
|
710
|
+
async compileAnimation(opts) {
|
|
711
|
+
const signature = animationCacheKey(opts);
|
|
712
|
+
const existingClassName = this.animationBySignature.get(signature);
|
|
713
|
+
if (existingClassName) {
|
|
714
|
+
const cached = this.animations.get(existingClassName);
|
|
715
|
+
if (cached) return cached;
|
|
716
|
+
this.animationBySignature.delete(signature);
|
|
717
|
+
}
|
|
718
|
+
await validateTailwindClasses([
|
|
719
|
+
{ classList: opts.from, context: `"from" in ${opts.name ?? "anonymous animation"}` },
|
|
720
|
+
{ classList: opts.to, context: `"to" in ${opts.name ?? "anonymous animation"}` }
|
|
721
|
+
]);
|
|
722
|
+
const binding = await getAnimateBinding();
|
|
723
|
+
const duration = normalizeNumber(opts.duration, DEFAULT_DURATION);
|
|
724
|
+
const easing = opts.easing ?? DEFAULT_EASING;
|
|
725
|
+
const delay = normalizeNumber(opts.delay, DEFAULT_DELAY);
|
|
726
|
+
const fill = opts.fill ?? DEFAULT_FILL;
|
|
727
|
+
const iterations = normalizeIterations(opts.iterations);
|
|
728
|
+
const direction = opts.direction ?? DEFAULT_DIRECTION;
|
|
729
|
+
const compiled = binding.compileAnimation?.(
|
|
730
|
+
opts.from,
|
|
731
|
+
opts.to,
|
|
732
|
+
opts.name ?? null,
|
|
733
|
+
duration,
|
|
734
|
+
easing,
|
|
735
|
+
delay,
|
|
736
|
+
fill,
|
|
737
|
+
iterations,
|
|
738
|
+
direction
|
|
739
|
+
);
|
|
740
|
+
if (!compiled) {
|
|
741
|
+
throw new Error(
|
|
742
|
+
`Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
const result = {
|
|
746
|
+
className: compiled.className,
|
|
747
|
+
keyframesCss: compiled.keyframesCss,
|
|
748
|
+
animationCss: compiled.animationCss
|
|
749
|
+
};
|
|
750
|
+
this.animations.set(result.className, result);
|
|
751
|
+
this.animationBySignature.set(signature, result.className);
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
754
|
+
async compileKeyframes(name, stops) {
|
|
755
|
+
const signature = keyframesCacheKey(name, stops);
|
|
756
|
+
const existingClassName = this.keyframesBySignature.get(signature);
|
|
757
|
+
if (existingClassName) {
|
|
758
|
+
const cached = this.animations.get(existingClassName);
|
|
759
|
+
if (cached) return cached;
|
|
760
|
+
this.keyframesBySignature.delete(signature);
|
|
761
|
+
}
|
|
762
|
+
await validateTailwindClasses(
|
|
763
|
+
Object.entries(stops).map(([offset, classes]) => ({
|
|
764
|
+
classList: classes,
|
|
765
|
+
context: `"${offset}" stop in keyframes "${name}"`
|
|
766
|
+
}))
|
|
767
|
+
);
|
|
768
|
+
const binding = await getAnimateBinding();
|
|
769
|
+
const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
|
|
770
|
+
const compiled = binding.compileKeyframes?.(name, stopsJson);
|
|
771
|
+
if (!compiled) {
|
|
772
|
+
throw new Error(`Native animate backend failed to compile keyframes "${name}".`);
|
|
773
|
+
}
|
|
774
|
+
const result = {
|
|
775
|
+
className: compiled.className,
|
|
776
|
+
keyframesCss: compiled.keyframesCss,
|
|
777
|
+
animationCss: compiled.animationCss
|
|
778
|
+
};
|
|
779
|
+
this.animations.set(result.className, result);
|
|
780
|
+
this.keyframesBySignature.set(signature, result.className);
|
|
781
|
+
return result;
|
|
782
|
+
}
|
|
783
|
+
extractCss() {
|
|
784
|
+
const lines = [];
|
|
785
|
+
for (const [, compiled] of this.animations.entries()) {
|
|
786
|
+
lines.push(compiled.keyframesCss);
|
|
787
|
+
lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
|
|
788
|
+
}
|
|
789
|
+
return lines.join("\n\n");
|
|
790
|
+
}
|
|
791
|
+
reset() {
|
|
792
|
+
this.animations.clear();
|
|
793
|
+
this.animationBySignature.clear();
|
|
794
|
+
this.keyframesBySignature.clear();
|
|
795
|
+
}
|
|
796
|
+
has(className) {
|
|
797
|
+
return this.animations.has(className);
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
// packages/animate/src/index.ts
|
|
804
|
+
var src_exports = {};
|
|
805
|
+
__export(src_exports, {
|
|
806
|
+
AnimationRegistry: () => AnimationRegistry,
|
|
807
|
+
animate: () => animate,
|
|
808
|
+
animations: () => animations,
|
|
809
|
+
compileAnimation: () => compileAnimation,
|
|
810
|
+
compileKeyframes: () => compileKeyframes,
|
|
811
|
+
createAnimationRegistry: () => createAnimationRegistry,
|
|
812
|
+
extractAnimationCss: () => extractAnimationCss,
|
|
813
|
+
getDefaultAnimationRegistry: () => getDefaultAnimationRegistry,
|
|
814
|
+
initAnimate: () => initAnimate2,
|
|
815
|
+
injectAnimationCss: () => injectAnimationCss,
|
|
816
|
+
keyframes: () => keyframes,
|
|
817
|
+
resetAnimationRegistry: () => resetAnimationRegistry
|
|
818
|
+
});
|
|
819
|
+
async function initAnimate2() {
|
|
820
|
+
await initAnimate();
|
|
821
|
+
}
|
|
822
|
+
function getDefaultAnimationRegistry() {
|
|
823
|
+
return defaultRegistry;
|
|
824
|
+
}
|
|
825
|
+
async function compileAnimation(opts, registry = defaultRegistry) {
|
|
826
|
+
return registry.compileAnimation(opts);
|
|
827
|
+
}
|
|
828
|
+
async function compileKeyframes(name, stops, registry = defaultRegistry) {
|
|
829
|
+
return registry.compileKeyframes(name, stops);
|
|
830
|
+
}
|
|
831
|
+
async function animate(opts, registry = defaultRegistry) {
|
|
832
|
+
return (await registry.compileAnimation(opts)).className;
|
|
833
|
+
}
|
|
834
|
+
async function keyframes(name, stops, registry = defaultRegistry) {
|
|
835
|
+
return (await registry.compileKeyframes(name, stops)).className;
|
|
836
|
+
}
|
|
837
|
+
function extractAnimationCss(registry = defaultRegistry) {
|
|
838
|
+
return registry.extractCss();
|
|
839
|
+
}
|
|
840
|
+
function resetAnimationRegistry(registry = defaultRegistry) {
|
|
841
|
+
registry.reset();
|
|
842
|
+
}
|
|
843
|
+
function injectAnimationCss(registry = defaultRegistry, options = {}) {
|
|
844
|
+
const targetDocument = options.document ?? (typeof document !== "undefined" ? document : void 0);
|
|
845
|
+
if (!targetDocument) {
|
|
846
|
+
if (options.silent) return;
|
|
847
|
+
throw new Error("injectAnimationCss requires a browser Document.");
|
|
848
|
+
}
|
|
849
|
+
const styleId = options.styleId ?? "__tw_animate_styles__";
|
|
850
|
+
let styleEl = targetDocument.getElementById(styleId);
|
|
851
|
+
if (!styleEl) {
|
|
852
|
+
if (!targetDocument.head) {
|
|
853
|
+
if (options.silent) return;
|
|
854
|
+
throw new Error("injectAnimationCss requires document.head to exist.");
|
|
855
|
+
}
|
|
856
|
+
styleEl = targetDocument.createElement("style");
|
|
857
|
+
styleEl.id = styleId;
|
|
858
|
+
targetDocument.head.appendChild(styleEl);
|
|
859
|
+
}
|
|
860
|
+
styleEl.textContent = registry.extractCss();
|
|
861
|
+
}
|
|
862
|
+
var defaultRegistry, animations;
|
|
863
|
+
var init_src3 = __esm({
|
|
864
|
+
"packages/animate/src/index.ts"() {
|
|
865
|
+
init_binding();
|
|
866
|
+
init_preset();
|
|
867
|
+
init_registry();
|
|
868
|
+
init_registry();
|
|
869
|
+
defaultRegistry = createAnimationRegistry();
|
|
870
|
+
animations = createAnimationPresets(defaultRegistry);
|
|
871
|
+
}
|
|
872
|
+
});
|
|
42
873
|
|
|
43
|
-
// src/containerQuery.ts
|
|
874
|
+
// packages/core/src/containerQuery.ts
|
|
44
875
|
var CONTAINER_BREAKPOINTS = {
|
|
45
876
|
xs: "240px",
|
|
46
877
|
sm: "320px",
|
|
@@ -54,7 +885,7 @@ if (typeof window !== "undefined") {
|
|
|
54
885
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
55
886
|
}
|
|
56
887
|
function hashContainer(tag, container, name) {
|
|
57
|
-
const key = tag + (name
|
|
888
|
+
const key = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
58
889
|
let hash = 5381;
|
|
59
890
|
for (let i = 0; i < key.length; i++) {
|
|
60
891
|
hash = (hash << 5) + hash ^ key.charCodeAt(i);
|
|
@@ -113,31 +944,29 @@ var LAYOUT_MAP = {
|
|
|
113
944
|
"justify-end": "justify-content:flex-end"
|
|
114
945
|
};
|
|
115
946
|
function layoutClassesToCss(classes) {
|
|
116
|
-
var _a, _b;
|
|
117
947
|
const decls = [];
|
|
118
948
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
119
949
|
if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
|
|
120
950
|
else if (cls.startsWith("w-[")) {
|
|
121
|
-
const val =
|
|
951
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
122
952
|
if (val) decls.push(`width:${val}`);
|
|
123
953
|
} else if (cls.startsWith("max-w-[")) {
|
|
124
|
-
const val =
|
|
954
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
125
955
|
if (val) decls.push(`max-width:${val}`);
|
|
126
956
|
}
|
|
127
957
|
}
|
|
128
958
|
return decls.join(";");
|
|
129
959
|
}
|
|
130
960
|
function buildContainerRules(id, container, containerName) {
|
|
131
|
-
var _a, _b, _c;
|
|
132
961
|
const rules = [];
|
|
133
962
|
for (const [key, value] of Object.entries(container)) {
|
|
134
963
|
let minWidth;
|
|
135
964
|
let classes;
|
|
136
965
|
if (typeof value === "string") {
|
|
137
|
-
minWidth =
|
|
966
|
+
minWidth = CONTAINER_BREAKPOINTS[key] ?? key;
|
|
138
967
|
classes = value;
|
|
139
968
|
} else {
|
|
140
|
-
minWidth =
|
|
969
|
+
minWidth = value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
|
|
141
970
|
classes = value.classes;
|
|
142
971
|
}
|
|
143
972
|
const css = layoutClassesToCss(classes);
|
|
@@ -157,7 +986,7 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
157
986
|
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
158
987
|
for (const rule of css.split("\n").filter(Boolean)) batchedInject(rule);
|
|
159
988
|
return;
|
|
160
|
-
} catch
|
|
989
|
+
} catch {
|
|
161
990
|
}
|
|
162
991
|
const style = document.createElement("style");
|
|
163
992
|
style.id = styleId;
|
|
@@ -168,13 +997,10 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
168
997
|
function processContainer(tag, container, containerName) {
|
|
169
998
|
const id = hashContainer(tag, container, containerName);
|
|
170
999
|
if (!containerRegistry.has(id)) {
|
|
171
|
-
const breakpoints = Object.entries(container).map(([key, value]) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
classes: typeof value === "string" ? value : value.classes
|
|
176
|
-
};
|
|
177
|
-
});
|
|
1000
|
+
const breakpoints = Object.entries(container).map(([key, value]) => ({
|
|
1001
|
+
minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
|
|
1002
|
+
classes: typeof value === "string" ? value : value.classes
|
|
1003
|
+
}));
|
|
178
1004
|
containerRegistry.set(id, {
|
|
179
1005
|
id,
|
|
180
1006
|
tag,
|
|
@@ -195,7 +1021,7 @@ function getContainerRegistry() {
|
|
|
195
1021
|
return containerRegistry;
|
|
196
1022
|
}
|
|
197
1023
|
|
|
198
|
-
// src/stateEngine.ts
|
|
1024
|
+
// packages/core/src/stateEngine.ts
|
|
199
1025
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
200
1026
|
if (typeof window !== "undefined") {
|
|
201
1027
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
@@ -301,12 +1127,11 @@ var TW_MAP = {
|
|
|
301
1127
|
"text-zinc-500": "color:rgb(113,113,122)"
|
|
302
1128
|
};
|
|
303
1129
|
function twClassesToCss(classes) {
|
|
304
|
-
var _a;
|
|
305
1130
|
const decls = [];
|
|
306
1131
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
307
1132
|
if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
|
|
308
1133
|
else if (cls.includes("[") && cls.includes("]")) {
|
|
309
|
-
const val =
|
|
1134
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
310
1135
|
if (!val) continue;
|
|
311
1136
|
if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
|
|
312
1137
|
else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
|
|
@@ -333,7 +1158,7 @@ function injectStateStyles(id, state) {
|
|
|
333
1158
|
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
334
1159
|
for (const rule of rules) batchedInject(rule);
|
|
335
1160
|
return;
|
|
336
|
-
} catch
|
|
1161
|
+
} catch {
|
|
337
1162
|
}
|
|
338
1163
|
const style = document.createElement("style");
|
|
339
1164
|
style.id = styleId;
|
|
@@ -372,7 +1197,7 @@ function getStateRegistry() {
|
|
|
372
1197
|
return stateRegistry;
|
|
373
1198
|
}
|
|
374
1199
|
|
|
375
|
-
// src/createComponent.ts
|
|
1200
|
+
// packages/core/src/createComponent.ts
|
|
376
1201
|
var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
|
|
377
1202
|
function makeFilterProps(variantKeys) {
|
|
378
1203
|
return function filterProps(props) {
|
|
@@ -387,10 +1212,9 @@ function makeFilterProps(variantKeys) {
|
|
|
387
1212
|
};
|
|
388
1213
|
}
|
|
389
1214
|
function resolveVariants(variants, props, defaults) {
|
|
390
|
-
var _a;
|
|
391
1215
|
const classes = [];
|
|
392
1216
|
for (const key in variants) {
|
|
393
|
-
const val =
|
|
1217
|
+
const val = props[key] ?? defaults[key];
|
|
394
1218
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
395
1219
|
classes.push(variants[key][String(val)]);
|
|
396
1220
|
}
|
|
@@ -400,50 +1224,49 @@ function resolveVariants(variants, props, defaults) {
|
|
|
400
1224
|
function resolveCompound(compounds, props) {
|
|
401
1225
|
const classes = [];
|
|
402
1226
|
for (const compound of compounds) {
|
|
403
|
-
const
|
|
1227
|
+
const { class: cls, ...conditions } = compound;
|
|
404
1228
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
405
1229
|
if (match) classes.push(cls);
|
|
406
1230
|
}
|
|
407
1231
|
return classes.join(" ");
|
|
408
1232
|
}
|
|
409
1233
|
function createComponent(tag, config) {
|
|
410
|
-
var _a, _b, _c, _d, _e;
|
|
411
1234
|
const isStatic = typeof config === "string";
|
|
412
|
-
const base = isStatic ? config :
|
|
413
|
-
const variants = isStatic ? {} :
|
|
414
|
-
const compoundVariants = isStatic ? [] :
|
|
415
|
-
const defaultVariants = isStatic ? {} :
|
|
1235
|
+
const base = isStatic ? config : config.base ?? "";
|
|
1236
|
+
const variants = isStatic ? {} : config.variants ?? {};
|
|
1237
|
+
const compoundVariants = isStatic ? [] : config.compoundVariants ?? [];
|
|
1238
|
+
const defaultVariants = isStatic ? {} : config.defaultVariants ?? {};
|
|
416
1239
|
const stateConfig = isStatic ? void 0 : config.state;
|
|
417
1240
|
const containerConfig = isStatic ? void 0 : config.container;
|
|
418
1241
|
const containerName = isStatic ? void 0 : config.containerName;
|
|
419
1242
|
const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
|
|
420
1243
|
const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
|
|
421
|
-
const engineClasses = [stateResult
|
|
1244
|
+
const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
|
|
422
1245
|
const variantKeySet = new Set(Object.keys(variants));
|
|
423
1246
|
const filterProps = makeFilterProps(variantKeySet);
|
|
424
|
-
const tagStr = typeof tag === "string" ? tag :
|
|
1247
|
+
const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
425
1248
|
if (isStatic || Object.keys(variants).length === 0) {
|
|
426
|
-
const Component2 =
|
|
427
|
-
const
|
|
428
|
-
return
|
|
429
|
-
ref
|
|
430
|
-
|
|
431
|
-
className: twMerge(base, engineClasses, className)
|
|
432
|
-
})
|
|
1249
|
+
const Component2 = React__default.default.forwardRef((props, ref) => {
|
|
1250
|
+
const { className, ...rest } = props;
|
|
1251
|
+
return React__default.default.createElement(tag, {
|
|
1252
|
+
ref,
|
|
1253
|
+
...filterProps(rest),
|
|
1254
|
+
className: tailwindMerge.twMerge(base, engineClasses, className)
|
|
1255
|
+
});
|
|
433
1256
|
});
|
|
434
1257
|
Component2.displayName = `tw.${tagStr}`;
|
|
435
1258
|
attachExtend(Component2, tag, base, config);
|
|
436
1259
|
return Component2;
|
|
437
1260
|
}
|
|
438
|
-
const Component =
|
|
1261
|
+
const Component = React__default.default.forwardRef((props, ref) => {
|
|
439
1262
|
const { className } = props;
|
|
440
1263
|
const variantClasses = resolveVariants(variants, props, defaultVariants);
|
|
441
1264
|
const compoundClasses = resolveCompound(compoundVariants, props);
|
|
442
|
-
return
|
|
443
|
-
ref
|
|
444
|
-
|
|
445
|
-
className: twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
446
|
-
})
|
|
1265
|
+
return React__default.default.createElement(tag, {
|
|
1266
|
+
ref,
|
|
1267
|
+
...filterProps(props),
|
|
1268
|
+
className: tailwindMerge.twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
1269
|
+
});
|
|
447
1270
|
});
|
|
448
1271
|
Component.displayName = `tw.${tagStr}`;
|
|
449
1272
|
attachExtend(Component, tag, base, config);
|
|
@@ -452,35 +1275,38 @@ function createComponent(tag, config) {
|
|
|
452
1275
|
function attachExtend(Component, originalTag, base, config) {
|
|
453
1276
|
Component.extend = (strings, ..._exprs) => {
|
|
454
1277
|
const extra = strings.raw.join("").trim().replace(/\s+/g, " ");
|
|
455
|
-
const merged = twMerge(base, extra);
|
|
1278
|
+
const merged = tailwindMerge.twMerge(base, extra);
|
|
456
1279
|
return createComponent(
|
|
457
1280
|
originalTag,
|
|
458
|
-
typeof config === "string" ? merged :
|
|
1281
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
459
1282
|
);
|
|
460
1283
|
};
|
|
461
1284
|
Component.withVariants = (newConfig) => {
|
|
462
|
-
var _a, _b, _c, _d, _e, _f;
|
|
463
1285
|
const existing = typeof config === "object" ? config : {};
|
|
464
|
-
return createComponent(originalTag,
|
|
1286
|
+
return createComponent(originalTag, {
|
|
1287
|
+
...existing,
|
|
465
1288
|
base,
|
|
466
|
-
variants:
|
|
1289
|
+
variants: { ...existing.variants ?? void 0, ...newConfig.variants ?? void 0 },
|
|
467
1290
|
compoundVariants: [
|
|
468
|
-
...
|
|
469
|
-
...
|
|
1291
|
+
...existing.compoundVariants ?? [],
|
|
1292
|
+
...newConfig.compoundVariants ?? []
|
|
470
1293
|
],
|
|
471
|
-
defaultVariants:
|
|
472
|
-
|
|
1294
|
+
defaultVariants: {
|
|
1295
|
+
...existing.defaultVariants ?? void 0,
|
|
1296
|
+
...newConfig.defaultVariants ?? void 0
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
473
1299
|
};
|
|
474
|
-
Component.animate = (opts) => {
|
|
1300
|
+
Component.animate = async (opts) => {
|
|
475
1301
|
try {
|
|
476
|
-
const { animate: animateFn } =
|
|
477
|
-
const animClass = animateFn(opts);
|
|
478
|
-
const merged = twMerge(base, animClass);
|
|
1302
|
+
const { animate: animateFn } = (init_src3(), __toCommonJS(src_exports));
|
|
1303
|
+
const animClass = await animateFn(opts);
|
|
1304
|
+
const merged = tailwindMerge.twMerge(base, animClass);
|
|
479
1305
|
return createComponent(
|
|
480
1306
|
originalTag,
|
|
481
|
-
typeof config === "string" ? merged :
|
|
1307
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
482
1308
|
);
|
|
483
|
-
} catch
|
|
1309
|
+
} catch {
|
|
484
1310
|
console.warn("[tailwind-styled-v4] .animate() requires @tailwind-styled/animate");
|
|
485
1311
|
return Component;
|
|
486
1312
|
}
|
|
@@ -489,32 +1315,50 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
489
1315
|
function cv(config) {
|
|
490
1316
|
const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
|
|
491
1317
|
return (props = {}) => {
|
|
492
|
-
var _a;
|
|
493
1318
|
const classes = [base];
|
|
494
1319
|
for (const key in variants) {
|
|
495
|
-
const val =
|
|
1320
|
+
const val = props[key] ?? defaultVariants[key];
|
|
496
1321
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
497
1322
|
classes.push(variants[key][String(val)]);
|
|
498
1323
|
}
|
|
499
1324
|
}
|
|
500
1325
|
for (const compound of compoundVariants) {
|
|
501
|
-
const
|
|
1326
|
+
const { class: cls, ...conditions } = compound;
|
|
502
1327
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
503
1328
|
if (match) classes.push(cls);
|
|
504
1329
|
}
|
|
505
1330
|
if (props.className) classes.push(props.className);
|
|
506
|
-
return twMerge(...classes);
|
|
1331
|
+
return tailwindMerge.twMerge(...classes);
|
|
507
1332
|
};
|
|
508
1333
|
}
|
|
509
1334
|
function cn(...inputs) {
|
|
510
1335
|
return inputs.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
511
1336
|
}
|
|
512
1337
|
function cx(...inputs) {
|
|
513
|
-
return twMerge(...inputs.filter(Boolean));
|
|
1338
|
+
return tailwindMerge.twMerge(...inputs.filter(Boolean));
|
|
514
1339
|
}
|
|
515
1340
|
var cxm = cx;
|
|
1341
|
+
function normalizeClassInput2(classLists) {
|
|
1342
|
+
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
1343
|
+
}
|
|
1344
|
+
function createTwMerge(_options = {}) {
|
|
1345
|
+
return function twMerge5(...classLists) {
|
|
1346
|
+
const clean = normalizeClassInput2(classLists);
|
|
1347
|
+
return tailwindMerge.twMerge(clean.join(" "));
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
var twMerge4 = createTwMerge();
|
|
1351
|
+
function mergeWithRules(rules, ...classLists) {
|
|
1352
|
+
const base = twMerge4(...classLists);
|
|
1353
|
+
let classes = base.split(/\s+/).filter(Boolean);
|
|
1354
|
+
for (const rule of Object.values(rules)) {
|
|
1355
|
+
const next = rule(classes);
|
|
1356
|
+
classes = twMerge4(next).split(/\s+/).filter(Boolean);
|
|
1357
|
+
}
|
|
1358
|
+
return classes.join(" ");
|
|
1359
|
+
}
|
|
516
1360
|
|
|
517
|
-
// src/liveTokenEngine.ts
|
|
1361
|
+
// packages/core/src/liveTokenEngine.ts
|
|
518
1362
|
var _currentTokens = {};
|
|
519
1363
|
var _subscribers = /* @__PURE__ */ new Set();
|
|
520
1364
|
var _styleEl = null;
|
|
@@ -549,16 +1393,16 @@ function syncStyleEl() {
|
|
|
549
1393
|
_styleEl.textContent = buildRootCss(_currentTokens);
|
|
550
1394
|
}
|
|
551
1395
|
function notifySubscribers() {
|
|
552
|
-
const snapshot =
|
|
1396
|
+
const snapshot = { ..._currentTokens };
|
|
553
1397
|
for (const sub of _subscribers) {
|
|
554
1398
|
try {
|
|
555
1399
|
sub(snapshot);
|
|
556
|
-
} catch
|
|
1400
|
+
} catch {
|
|
557
1401
|
}
|
|
558
1402
|
}
|
|
559
1403
|
}
|
|
560
1404
|
function liveToken(tokens) {
|
|
561
|
-
_currentTokens =
|
|
1405
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
562
1406
|
syncStyleEl();
|
|
563
1407
|
const vars = {};
|
|
564
1408
|
for (const name of Object.keys(tokens)) {
|
|
@@ -576,19 +1420,19 @@ function liveToken(tokens) {
|
|
|
576
1420
|
setTokens(newTokens);
|
|
577
1421
|
},
|
|
578
1422
|
snapshot() {
|
|
579
|
-
return
|
|
1423
|
+
return { ..._currentTokens };
|
|
580
1424
|
}
|
|
581
1425
|
};
|
|
582
1426
|
}
|
|
583
1427
|
function setToken(name, value) {
|
|
584
|
-
_currentTokens =
|
|
1428
|
+
_currentTokens = { ..._currentTokens, [name]: value };
|
|
585
1429
|
if (typeof document !== "undefined") {
|
|
586
1430
|
document.documentElement.style.setProperty(tokenVar(name), value);
|
|
587
1431
|
}
|
|
588
1432
|
notifySubscribers();
|
|
589
1433
|
}
|
|
590
1434
|
function setTokens(tokens) {
|
|
591
|
-
_currentTokens =
|
|
1435
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
592
1436
|
if (typeof document !== "undefined") {
|
|
593
1437
|
const root = document.documentElement;
|
|
594
1438
|
for (const [name, value] of Object.entries(tokens)) {
|
|
@@ -606,7 +1450,7 @@ function applyTokenSet(tokens) {
|
|
|
606
1450
|
}
|
|
607
1451
|
}
|
|
608
1452
|
}
|
|
609
|
-
_currentTokens =
|
|
1453
|
+
_currentTokens = { ...tokens };
|
|
610
1454
|
syncStyleEl();
|
|
611
1455
|
notifySubscribers();
|
|
612
1456
|
}
|
|
@@ -614,7 +1458,7 @@ function getToken(name) {
|
|
|
614
1458
|
return _currentTokens[name];
|
|
615
1459
|
}
|
|
616
1460
|
function getTokens() {
|
|
617
|
-
return
|
|
1461
|
+
return { ..._currentTokens };
|
|
618
1462
|
}
|
|
619
1463
|
function subscribeTokens(fn) {
|
|
620
1464
|
_subscribers.add(fn);
|
|
@@ -631,21 +1475,23 @@ function createUseTokens() {
|
|
|
631
1475
|
const react = __require("react");
|
|
632
1476
|
useState = react.useState;
|
|
633
1477
|
useEffect = react.useEffect;
|
|
634
|
-
} catch
|
|
1478
|
+
} catch {
|
|
635
1479
|
return null;
|
|
636
1480
|
}
|
|
637
1481
|
return function useTokens() {
|
|
638
|
-
const [tokens, setTokens_] = useState(
|
|
1482
|
+
const [tokens, setTokens_] = useState({
|
|
1483
|
+
..._currentTokens
|
|
1484
|
+
});
|
|
639
1485
|
useEffect(() => {
|
|
640
|
-
setTokens_(
|
|
641
|
-
const unsub = subscribeTokens((t2) => setTokens_(
|
|
1486
|
+
setTokens_({ ..._currentTokens });
|
|
1487
|
+
const unsub = subscribeTokens((t2) => setTokens_({ ...t2 }));
|
|
642
1488
|
return unsub;
|
|
643
1489
|
}, []);
|
|
644
1490
|
return tokens;
|
|
645
1491
|
};
|
|
646
1492
|
}
|
|
647
1493
|
|
|
648
|
-
// src/styledSystem.ts
|
|
1494
|
+
// packages/core/src/styledSystem.ts
|
|
649
1495
|
function tokenVarName(prefix, group, name) {
|
|
650
1496
|
return `--${prefix}-${group}-${name}`;
|
|
651
1497
|
}
|
|
@@ -653,11 +1499,10 @@ function tokenVarRef(prefix, group, name) {
|
|
|
653
1499
|
return `var(${tokenVarName(prefix, group, name)})`;
|
|
654
1500
|
}
|
|
655
1501
|
function resolveTokenRef(tokens, prefix, value) {
|
|
656
|
-
var _a;
|
|
657
1502
|
if (value.startsWith("token:")) {
|
|
658
|
-
const
|
|
659
|
-
const [group, name] =
|
|
660
|
-
if (group && name &&
|
|
1503
|
+
const path2 = value.slice(6);
|
|
1504
|
+
const [group, name] = path2.split(".");
|
|
1505
|
+
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
661
1506
|
return tokenVarRef(prefix, group, name);
|
|
662
1507
|
}
|
|
663
1508
|
}
|
|
@@ -680,37 +1525,35 @@ function injectTokensToRoot(tokens, prefix) {
|
|
|
680
1525
|
document.head.appendChild(style);
|
|
681
1526
|
}
|
|
682
1527
|
function resolveComponentConfig(config, tokens, prefix) {
|
|
683
|
-
var _a, _b, _c, _d, _e;
|
|
684
1528
|
const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
|
|
685
|
-
const base = resolveStr(
|
|
686
|
-
const systemBase = resolveStr(
|
|
1529
|
+
const base = resolveStr(config.base ?? "");
|
|
1530
|
+
const systemBase = resolveStr(config.systemBase ?? "");
|
|
687
1531
|
const mergedBase = [systemBase, base].filter(Boolean).join(" ");
|
|
688
1532
|
const variants = {};
|
|
689
|
-
for (const [variantKey, variantMap] of Object.entries(
|
|
1533
|
+
for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
|
|
690
1534
|
variants[variantKey] = {};
|
|
691
1535
|
for (const [optKey, classes] of Object.entries(variantMap)) {
|
|
692
1536
|
variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
|
|
693
1537
|
}
|
|
694
1538
|
}
|
|
695
|
-
const compoundVariants = (
|
|
696
|
-
const
|
|
697
|
-
return
|
|
1539
|
+
const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
|
|
1540
|
+
const { class: cls, ...rest } = cv2;
|
|
1541
|
+
return { class: resolveStr(cls), ...rest };
|
|
698
1542
|
});
|
|
699
1543
|
return {
|
|
700
1544
|
base: mergedBase,
|
|
701
1545
|
variants,
|
|
702
1546
|
compoundVariants,
|
|
703
|
-
defaultVariants:
|
|
1547
|
+
defaultVariants: config.defaultVariants ?? {},
|
|
704
1548
|
state: config.state,
|
|
705
1549
|
container: config.container,
|
|
706
1550
|
containerName: config.containerName
|
|
707
1551
|
};
|
|
708
1552
|
}
|
|
709
1553
|
function createStyledSystem(config) {
|
|
710
|
-
|
|
711
|
-
const
|
|
712
|
-
const
|
|
713
|
-
const componentDefs = (_c = config.components) != null ? _c : {};
|
|
1554
|
+
const prefix = config.prefix ?? "sys";
|
|
1555
|
+
const tokens = config.tokens ?? {};
|
|
1556
|
+
const componentDefs = config.components ?? {};
|
|
714
1557
|
const shouldInject = config.injectTokens !== false;
|
|
715
1558
|
if (shouldInject && typeof window !== "undefined") {
|
|
716
1559
|
injectTokensToRoot(tokens, prefix);
|
|
@@ -724,9 +1567,8 @@ function createStyledSystem(config) {
|
|
|
724
1567
|
}
|
|
725
1568
|
const factories = {};
|
|
726
1569
|
for (const [name, compCfg] of Object.entries(componentDefs)) {
|
|
727
|
-
const tag =
|
|
1570
|
+
const tag = compCfg.tag ?? "div";
|
|
728
1571
|
factories[name] = (overrides) => {
|
|
729
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
730
1572
|
const baseResolved = resolvedConfigs.get(name);
|
|
731
1573
|
if (!overrides || Object.keys(overrides).length === 0) {
|
|
732
1574
|
return createComponent(tag, baseResolved);
|
|
@@ -738,29 +1580,34 @@ function createStyledSystem(config) {
|
|
|
738
1580
|
);
|
|
739
1581
|
const merged = {
|
|
740
1582
|
base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
|
|
741
|
-
variants:
|
|
1583
|
+
variants: {
|
|
1584
|
+
...baseResolved.variants ?? void 0,
|
|
1585
|
+
...overrideResolved.variants ?? void 0
|
|
1586
|
+
},
|
|
742
1587
|
compoundVariants: [
|
|
743
|
-
...
|
|
744
|
-
...
|
|
1588
|
+
...baseResolved.compoundVariants ?? [],
|
|
1589
|
+
...overrideResolved.compoundVariants ?? []
|
|
745
1590
|
],
|
|
746
|
-
defaultVariants:
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
1591
|
+
defaultVariants: {
|
|
1592
|
+
...baseResolved.defaultVariants ?? void 0,
|
|
1593
|
+
...overrideResolved.defaultVariants ?? void 0
|
|
1594
|
+
},
|
|
1595
|
+
state: overrideResolved.state ?? baseResolved.state,
|
|
1596
|
+
container: overrideResolved.container ?? baseResolved.container,
|
|
1597
|
+
containerName: overrideResolved.containerName ?? baseResolved.containerName
|
|
750
1598
|
};
|
|
751
1599
|
return createComponent(tag, merged);
|
|
752
1600
|
};
|
|
753
1601
|
}
|
|
754
|
-
function token(
|
|
755
|
-
const [group, name] =
|
|
756
|
-
if (!group || !name) return
|
|
1602
|
+
function token(path2) {
|
|
1603
|
+
const [group, name] = path2.split(".");
|
|
1604
|
+
if (!group || !name) return path2;
|
|
757
1605
|
return tokenVarRef(prefix, group, name);
|
|
758
1606
|
}
|
|
759
|
-
function rawToken(
|
|
760
|
-
|
|
761
|
-
const [group, name] = path.split(".");
|
|
1607
|
+
function rawToken(path2) {
|
|
1608
|
+
const [group, name] = path2.split(".");
|
|
762
1609
|
if (!group || !name) return void 0;
|
|
763
|
-
return
|
|
1610
|
+
return tokens[group]?.[name];
|
|
764
1611
|
}
|
|
765
1612
|
function setTokens2(updates) {
|
|
766
1613
|
if (typeof document === "undefined") return;
|
|
@@ -798,11 +1645,42 @@ function createStyledSystem(config) {
|
|
|
798
1645
|
});
|
|
799
1646
|
}
|
|
800
1647
|
|
|
801
|
-
// src/
|
|
1648
|
+
// packages/core/src/styled.ts
|
|
1649
|
+
function resolveVariantClass(options, props) {
|
|
1650
|
+
const out = [];
|
|
1651
|
+
const variants = options.variants ?? {};
|
|
1652
|
+
const defaults = options.defaultVariants ?? {};
|
|
1653
|
+
for (const [variantName, valueMap] of Object.entries(variants)) {
|
|
1654
|
+
const value = props[variantName] ?? defaults[variantName];
|
|
1655
|
+
if (value === void 0) continue;
|
|
1656
|
+
const key = String(value);
|
|
1657
|
+
const cls = valueMap[key];
|
|
1658
|
+
if (cls) out.push(cls);
|
|
1659
|
+
}
|
|
1660
|
+
for (const compound of options.compoundVariants ?? []) {
|
|
1661
|
+
const matches = Object.entries(compound.variants).every(([k, expected]) => {
|
|
1662
|
+
const current = props[k] ?? defaults[k];
|
|
1663
|
+
return String(current) === expected;
|
|
1664
|
+
});
|
|
1665
|
+
if (matches) out.push(compound.className);
|
|
1666
|
+
}
|
|
1667
|
+
return out;
|
|
1668
|
+
}
|
|
1669
|
+
function resolveStyledClassName(options, props = {}) {
|
|
1670
|
+
const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
|
|
1671
|
+
return twMerge4(...parts);
|
|
1672
|
+
}
|
|
1673
|
+
function styled(options) {
|
|
1674
|
+
return function getClassName(props = {}) {
|
|
1675
|
+
return resolveStyledClassName(options, props);
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
// packages/core/src/twProxy.ts
|
|
802
1680
|
function parseTemplate(strings, exprs) {
|
|
803
1681
|
return strings.raw.reduce((acc, str, i) => {
|
|
804
1682
|
const expr = exprs[i];
|
|
805
|
-
const exprStr = typeof expr === "function" ? "" : expr
|
|
1683
|
+
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
806
1684
|
return acc + str + String(exprStr);
|
|
807
1685
|
}, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
808
1686
|
}
|
|
@@ -925,8 +1803,7 @@ function makeServerTag(tag) {
|
|
|
925
1803
|
const baseFactory = makeTag(tag);
|
|
926
1804
|
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
927
1805
|
return ((...args) => {
|
|
928
|
-
|
|
929
|
-
const tagName = typeof tag === "string" ? tag : (_a = tag.displayName) != null ? _a : "Component";
|
|
1806
|
+
const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
930
1807
|
console.warn(
|
|
931
1808
|
`[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
|
|
932
1809
|
);
|
|
@@ -951,7 +1828,7 @@ var tw = Object.assign(twCallable, tagFactories, {
|
|
|
951
1828
|
server
|
|
952
1829
|
});
|
|
953
1830
|
|
|
954
|
-
// src/twTheme.ts
|
|
1831
|
+
// packages/core/src/twTheme.ts
|
|
955
1832
|
function cssVar(varName, fallback) {
|
|
956
1833
|
const name = varName.startsWith("--") ? varName : `--${varName}`;
|
|
957
1834
|
return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
|
|
@@ -996,7 +1873,6 @@ function createTheme(tokenMap) {
|
|
|
996
1873
|
return resolved;
|
|
997
1874
|
}
|
|
998
1875
|
function getGroupPrefix(group) {
|
|
999
|
-
var _a;
|
|
1000
1876
|
const map = {
|
|
1001
1877
|
colors: "bg",
|
|
1002
1878
|
// default to bg; user can use t.text() for text colors
|
|
@@ -1004,7 +1880,7 @@ function getGroupPrefix(group) {
|
|
|
1004
1880
|
spacing: "p",
|
|
1005
1881
|
shadows: "shadow"
|
|
1006
1882
|
};
|
|
1007
|
-
return
|
|
1883
|
+
return map[group] ?? "";
|
|
1008
1884
|
}
|
|
1009
1885
|
var v4Tokens = {
|
|
1010
1886
|
/** bg-[var(--color-background)] */
|
|
@@ -1017,6 +1893,322 @@ var v4Tokens = {
|
|
|
1017
1893
|
fontMono: twVar("font", "font-mono")
|
|
1018
1894
|
};
|
|
1019
1895
|
|
|
1020
|
-
|
|
1896
|
+
// packages/core/src/parser.ts
|
|
1897
|
+
var _getNodePath = () => typeof __require !== "undefined" ? __require("path") : null;
|
|
1898
|
+
var _getCreateRequire = () => {
|
|
1899
|
+
if (typeof __require !== "undefined") {
|
|
1900
|
+
try {
|
|
1901
|
+
return __require("module").createRequire;
|
|
1902
|
+
} catch {
|
|
1903
|
+
return null;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
return null;
|
|
1907
|
+
};
|
|
1908
|
+
var _binding;
|
|
1909
|
+
function getBinding() {
|
|
1910
|
+
if (_binding !== void 0) return _binding;
|
|
1911
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
1912
|
+
return _binding = null;
|
|
1913
|
+
}
|
|
1914
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
1915
|
+
return _binding = null;
|
|
1916
|
+
}
|
|
1917
|
+
const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
|
|
1918
|
+
const nodePath = _getNodePath();
|
|
1919
|
+
const nodeCreateRequire = _getCreateRequire();
|
|
1920
|
+
if (!nodePath) return _binding = null;
|
|
1921
|
+
const req = typeof __require === "function" ? __require : nodeCreateRequire ? nodeCreateRequire(nodePath.join(runtimeDir, "noop.cjs")) : null;
|
|
1922
|
+
if (!req) return _binding = null;
|
|
1923
|
+
const candidates = [
|
|
1924
|
+
nodePath.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
1925
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
1926
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
1927
|
+
];
|
|
1928
|
+
for (const c of candidates) {
|
|
1929
|
+
try {
|
|
1930
|
+
const mod = req(c);
|
|
1931
|
+
if (mod?.parseClasses) return _binding = mod;
|
|
1932
|
+
} catch {
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
return _binding = null;
|
|
1936
|
+
}
|
|
1937
|
+
function splitClassListJS(input) {
|
|
1938
|
+
const out = [];
|
|
1939
|
+
let token = "";
|
|
1940
|
+
let square = 0;
|
|
1941
|
+
let round = 0;
|
|
1942
|
+
let escaped = false;
|
|
1943
|
+
for (const ch of input) {
|
|
1944
|
+
if (escaped) {
|
|
1945
|
+
token += ch;
|
|
1946
|
+
escaped = false;
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
if (ch === "\\") {
|
|
1950
|
+
token += ch;
|
|
1951
|
+
escaped = true;
|
|
1952
|
+
continue;
|
|
1953
|
+
}
|
|
1954
|
+
if (ch === "[") square++;
|
|
1955
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1956
|
+
else if (ch === "(") round++;
|
|
1957
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1958
|
+
const isSpace = /\s/.test(ch);
|
|
1959
|
+
if (isSpace && square === 0 && round === 0) {
|
|
1960
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1961
|
+
token = "";
|
|
1962
|
+
continue;
|
|
1963
|
+
}
|
|
1964
|
+
token += ch;
|
|
1965
|
+
}
|
|
1966
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1967
|
+
return out;
|
|
1968
|
+
}
|
|
1969
|
+
function parseClassTokenJS(rawToken) {
|
|
1970
|
+
const parts = [];
|
|
1971
|
+
let current = "";
|
|
1972
|
+
let square = 0;
|
|
1973
|
+
let round = 0;
|
|
1974
|
+
let escaped = false;
|
|
1975
|
+
for (const ch of rawToken) {
|
|
1976
|
+
if (escaped) {
|
|
1977
|
+
current += ch;
|
|
1978
|
+
escaped = false;
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
if (ch === "\\") {
|
|
1982
|
+
current += ch;
|
|
1983
|
+
escaped = true;
|
|
1984
|
+
continue;
|
|
1985
|
+
}
|
|
1986
|
+
if (ch === "[") square++;
|
|
1987
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1988
|
+
else if (ch === "(") round++;
|
|
1989
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1990
|
+
if (ch === ":" && square === 0 && round === 0) {
|
|
1991
|
+
parts.push(current);
|
|
1992
|
+
current = "";
|
|
1993
|
+
continue;
|
|
1994
|
+
}
|
|
1995
|
+
current += ch;
|
|
1996
|
+
}
|
|
1997
|
+
parts.push(current);
|
|
1998
|
+
const variants = parts.slice(0, -1).filter(Boolean);
|
|
1999
|
+
const baseToken = parts[parts.length - 1] ?? "";
|
|
2000
|
+
const parsed = { raw: rawToken, base: baseToken, variants };
|
|
2001
|
+
const opacityMatch = baseToken.match(/^(.*)\/(\d{1,3})$/);
|
|
2002
|
+
if (opacityMatch && opacityMatch[1].length > 0) {
|
|
2003
|
+
parsed.base = opacityMatch[1];
|
|
2004
|
+
parsed.modifier = { type: "opacity", value: opacityMatch[2] };
|
|
2005
|
+
return parsed;
|
|
2006
|
+
}
|
|
2007
|
+
const arbitraryMatch = baseToken.match(/\((--[a-zA-Z0-9_-]+)\)/);
|
|
2008
|
+
if (arbitraryMatch) {
|
|
2009
|
+
parsed.modifier = { type: "arbitrary", value: arbitraryMatch[1] };
|
|
2010
|
+
}
|
|
2011
|
+
return parsed;
|
|
2012
|
+
}
|
|
2013
|
+
function splitClassList(input) {
|
|
2014
|
+
const binding = getBinding();
|
|
2015
|
+
if (binding?.parseClasses) {
|
|
2016
|
+
try {
|
|
2017
|
+
return binding.parseClasses(input).map((p) => p.raw);
|
|
2018
|
+
} catch {
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return splitClassListJS(input);
|
|
2022
|
+
}
|
|
2023
|
+
function parseClassToken(rawToken) {
|
|
2024
|
+
const binding = getBinding();
|
|
2025
|
+
if (binding?.parseClasses) {
|
|
2026
|
+
try {
|
|
2027
|
+
const results = binding.parseClasses(rawToken);
|
|
2028
|
+
if (results.length === 1) {
|
|
2029
|
+
const r = results[0];
|
|
2030
|
+
const parsed = {
|
|
2031
|
+
raw: r.raw,
|
|
2032
|
+
base: r.base,
|
|
2033
|
+
variants: r.variants
|
|
2034
|
+
};
|
|
2035
|
+
if (r.modifierType && r.modifierValue) {
|
|
2036
|
+
parsed.modifier = {
|
|
2037
|
+
type: r.modifierType,
|
|
2038
|
+
value: r.modifierValue
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
return parsed;
|
|
2042
|
+
}
|
|
2043
|
+
} catch {
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return parseClassTokenJS(rawToken);
|
|
2047
|
+
}
|
|
2048
|
+
function parseTailwindClasses(input) {
|
|
2049
|
+
const binding = getBinding();
|
|
2050
|
+
if (binding?.parseClasses) {
|
|
2051
|
+
try {
|
|
2052
|
+
return binding.parseClasses(input).map((r) => {
|
|
2053
|
+
const parsed = { raw: r.raw, base: r.base, variants: r.variants };
|
|
2054
|
+
if (r.modifierType && r.modifierValue) {
|
|
2055
|
+
parsed.modifier = {
|
|
2056
|
+
type: r.modifierType,
|
|
2057
|
+
value: r.modifierValue
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
return parsed;
|
|
2061
|
+
});
|
|
2062
|
+
} catch {
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
return splitClassListJS(input).map(parseClassTokenJS);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
// packages/core/src/themeReader.ts
|
|
2069
|
+
var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
|
|
2070
|
+
var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
|
|
2071
|
+
var cache = /* @__PURE__ */ new Map();
|
|
2072
|
+
function createEmptyTheme() {
|
|
2073
|
+
return {
|
|
2074
|
+
colors: {},
|
|
2075
|
+
spacing: {},
|
|
2076
|
+
fonts: {},
|
|
2077
|
+
breakpoints: {},
|
|
2078
|
+
animations: {},
|
|
2079
|
+
raw: {}
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
function setToken2(theme, key, value) {
|
|
2083
|
+
theme.raw[key] = value;
|
|
2084
|
+
if (key.startsWith("color-")) {
|
|
2085
|
+
theme.colors[key.slice("color-".length)] = value;
|
|
2086
|
+
return;
|
|
2087
|
+
}
|
|
2088
|
+
if (key.startsWith("spacing-")) {
|
|
2089
|
+
theme.spacing[key.slice("spacing-".length)] = value;
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
if (key.startsWith("font-")) {
|
|
2093
|
+
theme.fonts[key.slice("font-".length)] = value;
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
if (key.startsWith("breakpoint-")) {
|
|
2097
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = value;
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2100
|
+
if (key.startsWith("animate-")) {
|
|
2101
|
+
theme.animations[key.slice("animate-".length)] = value;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
function resolveThemeValue(key, theme, visited = /* @__PURE__ */ new Set()) {
|
|
2105
|
+
const token = key.replace(/^--/, "");
|
|
2106
|
+
const raw = theme.raw[token];
|
|
2107
|
+
if (!raw) return "";
|
|
2108
|
+
if (visited.has(token)) return raw;
|
|
2109
|
+
const nested = raw.match(/^var\((--[a-zA-Z0-9_-]+)\)$/);
|
|
2110
|
+
if (!nested) return raw;
|
|
2111
|
+
visited.add(token);
|
|
2112
|
+
return resolveThemeValue(nested[1], theme, visited);
|
|
2113
|
+
}
|
|
2114
|
+
function extractThemeFromCSS(cssContent) {
|
|
2115
|
+
const hit = cache.get(cssContent);
|
|
2116
|
+
if (hit) return hit;
|
|
2117
|
+
const theme = createEmptyTheme();
|
|
2118
|
+
let blockMatch;
|
|
2119
|
+
while ((blockMatch = THEME_BLOCK_RE.exec(cssContent)) !== null) {
|
|
2120
|
+
const block = blockMatch[1];
|
|
2121
|
+
let varMatch;
|
|
2122
|
+
while ((varMatch = CSS_VAR_RE.exec(block)) !== null) {
|
|
2123
|
+
const key = varMatch[1];
|
|
2124
|
+
const value = varMatch[2].trim();
|
|
2125
|
+
setToken2(theme, key, value);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
for (const key of Object.keys(theme.raw)) {
|
|
2129
|
+
const resolved = resolveThemeValue(`--${key}`, theme);
|
|
2130
|
+
theme.raw[key] = resolved;
|
|
2131
|
+
if (key.startsWith("color-")) {
|
|
2132
|
+
theme.colors[key.slice("color-".length)] = resolved;
|
|
2133
|
+
} else if (key.startsWith("spacing-")) {
|
|
2134
|
+
theme.spacing[key.slice("spacing-".length)] = resolved;
|
|
2135
|
+
} else if (key.startsWith("font-")) {
|
|
2136
|
+
theme.fonts[key.slice("font-".length)] = resolved;
|
|
2137
|
+
} else if (key.startsWith("breakpoint-")) {
|
|
2138
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = resolved;
|
|
2139
|
+
} else if (key.startsWith("animate-")) {
|
|
2140
|
+
theme.animations[key.slice("animate-".length)] = resolved;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
cache.set(cssContent, theme);
|
|
2144
|
+
return theme;
|
|
2145
|
+
}
|
|
2146
|
+
function generateTypeDefinitions(theme) {
|
|
2147
|
+
const toRecordType = (name, obj) => {
|
|
2148
|
+
const keys = Object.keys(obj);
|
|
2149
|
+
if (keys.length === 0) return ` ${name}: Record<string, string>`;
|
|
2150
|
+
const mapped = keys.map((k) => ` "${k}": string`).join("\n");
|
|
2151
|
+
return ` ${name}: {
|
|
2152
|
+
${mapped}
|
|
2153
|
+
}`;
|
|
2154
|
+
};
|
|
2155
|
+
return [
|
|
2156
|
+
"export interface TailwindStyledThemeTokens {",
|
|
2157
|
+
toRecordType("colors", theme.colors),
|
|
2158
|
+
toRecordType("spacing", theme.spacing),
|
|
2159
|
+
toRecordType("fonts", theme.fonts),
|
|
2160
|
+
toRecordType("breakpoints", theme.breakpoints),
|
|
2161
|
+
toRecordType("animations", theme.animations),
|
|
2162
|
+
"}",
|
|
2163
|
+
""
|
|
2164
|
+
].join("\n");
|
|
2165
|
+
}
|
|
2166
|
+
function clearThemeReaderCache() {
|
|
2167
|
+
cache.clear();
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
exports.applyTokenSet = applyTokenSet;
|
|
2171
|
+
exports.clearThemeReaderCache = clearThemeReaderCache;
|
|
2172
|
+
exports.cn = cn;
|
|
2173
|
+
exports.containerRef = tokenRef;
|
|
2174
|
+
exports.createComponent = createComponent;
|
|
2175
|
+
exports.createStyledSystem = createStyledSystem;
|
|
2176
|
+
exports.createTheme = createTheme;
|
|
2177
|
+
exports.createTwMerge = createTwMerge;
|
|
2178
|
+
exports.createUseTokens = createUseTokens;
|
|
2179
|
+
exports.cssVar = cssVar;
|
|
2180
|
+
exports.cv = cv;
|
|
2181
|
+
exports.cx = cx;
|
|
2182
|
+
exports.cxm = cxm;
|
|
2183
|
+
exports.extractThemeFromCSS = extractThemeFromCSS;
|
|
2184
|
+
exports.generateContainerCss = generateContainerCss;
|
|
2185
|
+
exports.generateStateCss = generateStateCss;
|
|
2186
|
+
exports.generateTokenCssString = generateTokenCssString;
|
|
2187
|
+
exports.generateTypeDefinitions = generateTypeDefinitions;
|
|
2188
|
+
exports.getContainerRegistry = getContainerRegistry;
|
|
2189
|
+
exports.getStateRegistry = getStateRegistry;
|
|
2190
|
+
exports.getToken = getToken;
|
|
2191
|
+
exports.getTokens = getTokens;
|
|
2192
|
+
exports.liveToken = liveToken;
|
|
2193
|
+
exports.mergeWithRules = mergeWithRules;
|
|
2194
|
+
exports.parseClassToken = parseClassToken;
|
|
2195
|
+
exports.parseTailwindClasses = parseTailwindClasses;
|
|
2196
|
+
exports.processContainer = processContainer;
|
|
2197
|
+
exports.processState = processState;
|
|
2198
|
+
exports.resolveStyledClassName = resolveStyledClassName;
|
|
2199
|
+
exports.resolveThemeValue = resolveThemeValue;
|
|
2200
|
+
exports.server = server;
|
|
2201
|
+
exports.setToken = setToken;
|
|
2202
|
+
exports.setTokens = setTokens;
|
|
2203
|
+
exports.splitClassList = splitClassList;
|
|
2204
|
+
exports.styled = styled;
|
|
2205
|
+
exports.subscribeTokens = subscribeTokens;
|
|
2206
|
+
exports.t = t;
|
|
2207
|
+
exports.tokenRef = tokenRef;
|
|
2208
|
+
exports.tokenVar = tokenVar;
|
|
2209
|
+
exports.tw = tw;
|
|
2210
|
+
exports.twMerge = twMerge4;
|
|
2211
|
+
exports.twVar = twVar;
|
|
2212
|
+
exports.v4Tokens = v4Tokens;
|
|
1021
2213
|
//# sourceMappingURL=index.js.map
|
|
1022
2214
|
//# sourceMappingURL=index.js.map
|