tailwind-styled-v4 5.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.cts → animate.d.mts} +3 -30
- package/dist/animate.d.ts +3 -30
- package/dist/animate.js +149 -99
- package/dist/animate.js.map +1 -1
- package/dist/{animate.cjs → animate.mjs} +130 -119
- 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.mts +1009 -0
- package/dist/compiler.d.ts +1009 -0
- package/dist/compiler.js +4518 -0
- package/dist/compiler.js.map +1 -0
- package/dist/compiler.mjs +4443 -0
- 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 +170 -157
- package/dist/devtools.js.map +1 -1
- package/dist/{devtools.cjs → devtools.mjs} +165 -166
- 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} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +945 -36
- package/dist/index.js.map +1 -1
- package/dist/{index.cjs → index.mjs} +899 -90
- 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.cts → next.d.mts} +2 -1
- package/dist/next.d.ts +2 -1
- package/dist/next.js +6853 -35
- 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.js +9 -4
- package/dist/preset.js.map +1 -1
- package/dist/{preset.cjs → preset.mjs} +5 -14
- 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/{css.cjs → runtimeCss.js} +71 -4
- package/dist/runtimeCss.js.map +1 -0
- package/dist/{css.js → runtimeCss.mjs} +66 -5
- 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.mts +188 -0
- package/dist/theme.d.ts +188 -0
- package/dist/theme.js +334 -0
- package/dist/theme.js.map +1 -0
- 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.js +4181 -16
- 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 +168 -65
- package/dist/animate.cjs.map +0 -1
- package/dist/chunk-VZEJV27B.js +0 -11
- package/dist/chunk-VZEJV27B.js.map +0 -1
- package/dist/chunk-Y5D3E72P.cjs +0 -13
- package/dist/chunk-Y5D3E72P.cjs.map +0 -1
- package/dist/css.cjs.map +0 -1
- package/dist/css.d.cts +0 -30
- package/dist/css.d.ts +0 -30
- package/dist/css.js.map +0 -1
- package/dist/devtools.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/next.cjs +0 -248
- package/dist/next.cjs.map +0 -1
- package/dist/preset.cjs.map +0 -1
- package/dist/turbopackLoader.cjs +0 -37
- package/dist/turbopackLoader.cjs.map +0 -1
- package/dist/turbopackLoader.d.cts +0 -12
- package/dist/turbopackLoader.d.ts +0 -12
- package/dist/turbopackLoader.js +0 -35
- package/dist/turbopackLoader.js.map +0 -1
- package/dist/vite.cjs +0 -138
- package/dist/vite.cjs.map +0 -1
- package/dist/webpackLoader.cjs +0 -51
- package/dist/webpackLoader.cjs.map +0 -1
- package/dist/webpackLoader.d.cts +0 -17
- package/dist/webpackLoader.d.ts +0 -17
- package/dist/webpackLoader.js +0 -49
- package/dist/webpackLoader.js.map +0 -1
- /package/dist/{devtools.d.cts → devtools.d.mts} +0 -0
- /package/dist/{preset.d.cts → preset.d.mts} +0 -0
- /package/dist/{vite.d.cts → vite.d.mts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,877 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { twMerge } from 'tailwind-merge';
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
5
|
-
|
|
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');
|
|
6
10
|
|
|
7
|
-
|
|
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 */
|
|
20
|
+
var __defProp = Object.defineProperty;
|
|
21
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
22
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
23
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
25
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
26
|
+
}) : x)(function(x) {
|
|
27
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
28
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
29
|
+
});
|
|
30
|
+
var __esm = (fn, res) => function __init() {
|
|
31
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
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
|
+
});
|
|
873
|
+
|
|
874
|
+
// packages/core/src/containerQuery.ts
|
|
8
875
|
var CONTAINER_BREAKPOINTS = {
|
|
9
876
|
xs: "240px",
|
|
10
877
|
sm: "320px",
|
|
@@ -154,7 +1021,7 @@ function getContainerRegistry() {
|
|
|
154
1021
|
return containerRegistry;
|
|
155
1022
|
}
|
|
156
1023
|
|
|
157
|
-
// src/stateEngine.ts
|
|
1024
|
+
// packages/core/src/stateEngine.ts
|
|
158
1025
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
159
1026
|
if (typeof window !== "undefined") {
|
|
160
1027
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
@@ -330,7 +1197,7 @@ function getStateRegistry() {
|
|
|
330
1197
|
return stateRegistry;
|
|
331
1198
|
}
|
|
332
1199
|
|
|
333
|
-
// src/createComponent.ts
|
|
1200
|
+
// packages/core/src/createComponent.ts
|
|
334
1201
|
var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
|
|
335
1202
|
function makeFilterProps(variantKeys) {
|
|
336
1203
|
return function filterProps(props) {
|
|
@@ -379,26 +1246,26 @@ function createComponent(tag, config) {
|
|
|
379
1246
|
const filterProps = makeFilterProps(variantKeySet);
|
|
380
1247
|
const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
381
1248
|
if (isStatic || Object.keys(variants).length === 0) {
|
|
382
|
-
const Component2 =
|
|
1249
|
+
const Component2 = React__default.default.forwardRef((props, ref) => {
|
|
383
1250
|
const { className, ...rest } = props;
|
|
384
|
-
return
|
|
1251
|
+
return React__default.default.createElement(tag, {
|
|
385
1252
|
ref,
|
|
386
1253
|
...filterProps(rest),
|
|
387
|
-
className: twMerge(base, engineClasses, className)
|
|
1254
|
+
className: tailwindMerge.twMerge(base, engineClasses, className)
|
|
388
1255
|
});
|
|
389
1256
|
});
|
|
390
1257
|
Component2.displayName = `tw.${tagStr}`;
|
|
391
1258
|
attachExtend(Component2, tag, base, config);
|
|
392
1259
|
return Component2;
|
|
393
1260
|
}
|
|
394
|
-
const Component =
|
|
1261
|
+
const Component = React__default.default.forwardRef((props, ref) => {
|
|
395
1262
|
const { className } = props;
|
|
396
1263
|
const variantClasses = resolveVariants(variants, props, defaultVariants);
|
|
397
1264
|
const compoundClasses = resolveCompound(compoundVariants, props);
|
|
398
|
-
return
|
|
1265
|
+
return React__default.default.createElement(tag, {
|
|
399
1266
|
ref,
|
|
400
1267
|
...filterProps(props),
|
|
401
|
-
className: twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
1268
|
+
className: tailwindMerge.twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
402
1269
|
});
|
|
403
1270
|
});
|
|
404
1271
|
Component.displayName = `tw.${tagStr}`;
|
|
@@ -408,7 +1275,7 @@ function createComponent(tag, config) {
|
|
|
408
1275
|
function attachExtend(Component, originalTag, base, config) {
|
|
409
1276
|
Component.extend = (strings, ..._exprs) => {
|
|
410
1277
|
const extra = strings.raw.join("").trim().replace(/\s+/g, " ");
|
|
411
|
-
const merged = twMerge(base, extra);
|
|
1278
|
+
const merged = tailwindMerge.twMerge(base, extra);
|
|
412
1279
|
return createComponent(
|
|
413
1280
|
originalTag,
|
|
414
1281
|
typeof config === "string" ? merged : { ...config, base: merged }
|
|
@@ -432,9 +1299,9 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
432
1299
|
};
|
|
433
1300
|
Component.animate = async (opts) => {
|
|
434
1301
|
try {
|
|
435
|
-
const { animate: animateFn } =
|
|
1302
|
+
const { animate: animateFn } = (init_src3(), __toCommonJS(src_exports));
|
|
436
1303
|
const animClass = await animateFn(opts);
|
|
437
|
-
const merged = twMerge(base, animClass);
|
|
1304
|
+
const merged = tailwindMerge.twMerge(base, animClass);
|
|
438
1305
|
return createComponent(
|
|
439
1306
|
originalTag,
|
|
440
1307
|
typeof config === "string" ? merged : { ...config, base: merged }
|
|
@@ -461,23 +1328,23 @@ function cv(config) {
|
|
|
461
1328
|
if (match) classes.push(cls);
|
|
462
1329
|
}
|
|
463
1330
|
if (props.className) classes.push(props.className);
|
|
464
|
-
return twMerge(...classes);
|
|
1331
|
+
return tailwindMerge.twMerge(...classes);
|
|
465
1332
|
};
|
|
466
1333
|
}
|
|
467
1334
|
function cn(...inputs) {
|
|
468
1335
|
return inputs.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
469
1336
|
}
|
|
470
1337
|
function cx(...inputs) {
|
|
471
|
-
return twMerge(...inputs.filter(Boolean));
|
|
1338
|
+
return tailwindMerge.twMerge(...inputs.filter(Boolean));
|
|
472
1339
|
}
|
|
473
1340
|
var cxm = cx;
|
|
474
|
-
function
|
|
1341
|
+
function normalizeClassInput2(classLists) {
|
|
475
1342
|
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
476
1343
|
}
|
|
477
1344
|
function createTwMerge(_options = {}) {
|
|
478
1345
|
return function twMerge5(...classLists) {
|
|
479
|
-
const clean =
|
|
480
|
-
return twMerge(clean.join(" "));
|
|
1346
|
+
const clean = normalizeClassInput2(classLists);
|
|
1347
|
+
return tailwindMerge.twMerge(clean.join(" "));
|
|
481
1348
|
};
|
|
482
1349
|
}
|
|
483
1350
|
var twMerge4 = createTwMerge();
|
|
@@ -491,7 +1358,7 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
491
1358
|
return classes.join(" ");
|
|
492
1359
|
}
|
|
493
1360
|
|
|
494
|
-
// src/liveTokenEngine.ts
|
|
1361
|
+
// packages/core/src/liveTokenEngine.ts
|
|
495
1362
|
var _currentTokens = {};
|
|
496
1363
|
var _subscribers = /* @__PURE__ */ new Set();
|
|
497
1364
|
var _styleEl = null;
|
|
@@ -624,7 +1491,7 @@ function createUseTokens() {
|
|
|
624
1491
|
};
|
|
625
1492
|
}
|
|
626
1493
|
|
|
627
|
-
// src/styledSystem.ts
|
|
1494
|
+
// packages/core/src/styledSystem.ts
|
|
628
1495
|
function tokenVarName(prefix, group, name) {
|
|
629
1496
|
return `--${prefix}-${group}-${name}`;
|
|
630
1497
|
}
|
|
@@ -633,8 +1500,8 @@ function tokenVarRef(prefix, group, name) {
|
|
|
633
1500
|
}
|
|
634
1501
|
function resolveTokenRef(tokens, prefix, value) {
|
|
635
1502
|
if (value.startsWith("token:")) {
|
|
636
|
-
const
|
|
637
|
-
const [group, name] =
|
|
1503
|
+
const path2 = value.slice(6);
|
|
1504
|
+
const [group, name] = path2.split(".");
|
|
638
1505
|
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
639
1506
|
return tokenVarRef(prefix, group, name);
|
|
640
1507
|
}
|
|
@@ -732,13 +1599,13 @@ function createStyledSystem(config) {
|
|
|
732
1599
|
return createComponent(tag, merged);
|
|
733
1600
|
};
|
|
734
1601
|
}
|
|
735
|
-
function token(
|
|
736
|
-
const [group, name] =
|
|
737
|
-
if (!group || !name) return
|
|
1602
|
+
function token(path2) {
|
|
1603
|
+
const [group, name] = path2.split(".");
|
|
1604
|
+
if (!group || !name) return path2;
|
|
738
1605
|
return tokenVarRef(prefix, group, name);
|
|
739
1606
|
}
|
|
740
|
-
function rawToken(
|
|
741
|
-
const [group, name] =
|
|
1607
|
+
function rawToken(path2) {
|
|
1608
|
+
const [group, name] = path2.split(".");
|
|
742
1609
|
if (!group || !name) return void 0;
|
|
743
1610
|
return tokens[group]?.[name];
|
|
744
1611
|
}
|
|
@@ -778,7 +1645,7 @@ function createStyledSystem(config) {
|
|
|
778
1645
|
});
|
|
779
1646
|
}
|
|
780
1647
|
|
|
781
|
-
// src/styled.ts
|
|
1648
|
+
// packages/core/src/styled.ts
|
|
782
1649
|
function resolveVariantClass(options, props) {
|
|
783
1650
|
const out = [];
|
|
784
1651
|
const variants = options.variants ?? {};
|
|
@@ -809,7 +1676,7 @@ function styled(options) {
|
|
|
809
1676
|
};
|
|
810
1677
|
}
|
|
811
1678
|
|
|
812
|
-
// src/twProxy.ts
|
|
1679
|
+
// packages/core/src/twProxy.ts
|
|
813
1680
|
function parseTemplate(strings, exprs) {
|
|
814
1681
|
return strings.raw.reduce((acc, str, i) => {
|
|
815
1682
|
const expr = exprs[i];
|
|
@@ -961,7 +1828,7 @@ var tw = Object.assign(twCallable, tagFactories, {
|
|
|
961
1828
|
server
|
|
962
1829
|
});
|
|
963
1830
|
|
|
964
|
-
// src/twTheme.ts
|
|
1831
|
+
// packages/core/src/twTheme.ts
|
|
965
1832
|
function cssVar(varName, fallback) {
|
|
966
1833
|
const name = varName.startsWith("--") ? varName : `--${varName}`;
|
|
967
1834
|
return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
|
|
@@ -1026,7 +1893,7 @@ var v4Tokens = {
|
|
|
1026
1893
|
fontMono: twVar("font", "font-mono")
|
|
1027
1894
|
};
|
|
1028
1895
|
|
|
1029
|
-
// src/parser.ts
|
|
1896
|
+
// packages/core/src/parser.ts
|
|
1030
1897
|
var _getNodePath = () => typeof __require !== "undefined" ? __require("path") : null;
|
|
1031
1898
|
var _getCreateRequire = () => {
|
|
1032
1899
|
if (typeof __require !== "undefined") {
|
|
@@ -1198,7 +2065,7 @@ function parseTailwindClasses(input) {
|
|
|
1198
2065
|
return splitClassListJS(input).map(parseClassTokenJS);
|
|
1199
2066
|
}
|
|
1200
2067
|
|
|
1201
|
-
// src/themeReader.ts
|
|
2068
|
+
// packages/core/src/themeReader.ts
|
|
1202
2069
|
var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
|
|
1203
2070
|
var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
|
|
1204
2071
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -1300,6 +2167,48 @@ function clearThemeReaderCache() {
|
|
|
1300
2167
|
cache.clear();
|
|
1301
2168
|
}
|
|
1302
2169
|
|
|
1303
|
-
|
|
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;
|
|
1304
2213
|
//# sourceMappingURL=index.js.map
|
|
1305
2214
|
//# sourceMappingURL=index.js.map
|