tailwind-to-style 3.2.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -666
- package/dist/animations/index.cjs +9391 -0
- package/dist/animations/index.d.ts +58 -0
- package/dist/animations/index.esm.js +9385 -0
- package/dist/animations/index.esm.js.map +1 -0
- package/dist/className/index.cjs +9080 -0
- package/dist/className/index.esm.js +9075 -0
- package/dist/className/index.esm.js.map +1 -0
- package/dist/core/tws.cjs +136 -114
- package/dist/core/tws.cjs.map +1 -0
- package/dist/core/tws.esm.js +136 -114
- package/dist/core/tws.esm.js.map +1 -1
- package/dist/core/twsx.cjs +2442 -4245
- package/dist/core/twsx.esm.js +2442 -4245
- package/dist/core/twsx.esm.js.map +1 -1
- package/dist/core/twsxVariants.cjs +2470 -4262
- package/dist/core/twsxVariants.esm.js +2470 -4262
- package/dist/core/twsxVariants.esm.js.map +1 -1
- package/dist/cx.cjs +2 -2
- package/dist/cx.cjs.map +1 -0
- package/dist/cx.esm.js +2 -2
- package/dist/index.cjs +5128 -6057
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +993 -1
- package/dist/index.esm.js +5124 -6022
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/react/index.cjs +10177 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +69 -0
- package/dist/react/index.esm.js +10173 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/styled/index.cjs +9094 -0
- package/dist/styled/index.cjs.map +1 -0
- package/dist/styled/index.d.ts +17 -0
- package/dist/styled/index.esm.js +9087 -0
- package/dist/styled/index.esm.js.map +1 -0
- package/dist/tokens/index.cjs +359 -0
- package/dist/tokens/index.d.ts +33 -0
- package/dist/tokens/index.esm.js +355 -0
- package/dist/tokens/index.esm.js.map +1 -0
- package/dist/utils/index.cjs +313 -297
- package/dist/utils/index.esm.js +313 -297
- package/dist/utils/index.esm.js.map +1 -1
- package/package.json +38 -24
- package/types/animations/index.d.ts +58 -0
- package/types/className/index.d.ts +41 -0
- package/types/index.d.ts +993 -1
- package/types/react/index.d.ts +69 -0
- package/types/tokens/index.d.ts +33 -0
- package/types/v4.d.ts +191 -0
package/dist/core/tws.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style
|
|
3
|
-
*
|
|
2
|
+
* tailwind-to-style v4.0.0
|
|
3
|
+
* Zero-build runtime Tailwind CSS engine
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
/**
|
|
9
|
-
* TailwindCache singleton for managing generated Tailwind CSS
|
|
10
|
-
* Replaces global state with proper encapsulation
|
|
8
|
+
/**
|
|
9
|
+
* TailwindCache singleton for managing generated Tailwind CSS
|
|
10
|
+
* Replaces global state with proper encapsulation
|
|
11
11
|
*/
|
|
12
12
|
class TailwindCache {
|
|
13
13
|
constructor() {
|
|
@@ -16,11 +16,11 @@ class TailwindCache {
|
|
|
16
16
|
this.initialized = false;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Get or generate the CSS object
|
|
21
|
-
* @param {Function} generateFn - Function to generate CSS string
|
|
22
|
-
* @param {Function} convertFn - Function to convert CSS string to object
|
|
23
|
-
* @returns {Object} CSS object lookup
|
|
19
|
+
/**
|
|
20
|
+
* Get or generate the CSS object
|
|
21
|
+
* @param {Function} generateFn - Function to generate CSS string
|
|
22
|
+
* @param {Function} convertFn - Function to convert CSS string to object
|
|
23
|
+
* @returns {Object} CSS object lookup
|
|
24
24
|
*/
|
|
25
25
|
getOrGenerate(generateFn, convertFn) {
|
|
26
26
|
if (!this.initialized) {
|
|
@@ -31,29 +31,29 @@ class TailwindCache {
|
|
|
31
31
|
return this.cssObject;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Get the CSS string
|
|
34
|
+
/**
|
|
35
|
+
* Get the CSS string
|
|
36
36
|
*/
|
|
37
37
|
getCssString() {
|
|
38
38
|
return this.twString;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
* Get the CSS object
|
|
41
|
+
/**
|
|
42
|
+
* Get the CSS object
|
|
43
43
|
*/
|
|
44
44
|
getCssObject() {
|
|
45
45
|
return this.cssObject;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/**
|
|
49
|
-
* Check if cache is initialized
|
|
48
|
+
/**
|
|
49
|
+
* Check if cache is initialized
|
|
50
50
|
*/
|
|
51
51
|
isInitialized() {
|
|
52
52
|
return this.initialized;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Reset the cache (useful for testing)
|
|
55
|
+
/**
|
|
56
|
+
* Reset the cache (useful for testing)
|
|
57
57
|
*/
|
|
58
58
|
reset() {
|
|
59
59
|
this.twString = null;
|
|
@@ -65,9 +65,9 @@ class TailwindCache {
|
|
|
65
65
|
// Singleton instance
|
|
66
66
|
let instance = null;
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Get the TailwindCache singleton instance
|
|
70
|
-
* @returns {TailwindCache} The cache instance
|
|
68
|
+
/**
|
|
69
|
+
* Get the TailwindCache singleton instance
|
|
70
|
+
* @returns {TailwindCache} The cache instance
|
|
71
71
|
*/
|
|
72
72
|
function getTailwindCache() {
|
|
73
73
|
if (!instance) {
|
|
@@ -76,9 +76,9 @@ function getTailwindCache() {
|
|
|
76
76
|
return instance;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* Logger class with configurable log levels
|
|
81
|
-
* Prevents console spam in production
|
|
79
|
+
/**
|
|
80
|
+
* Logger class with configurable log levels
|
|
81
|
+
* Prevents console spam in production
|
|
82
82
|
*/
|
|
83
83
|
class Logger {
|
|
84
84
|
constructor() {
|
|
@@ -93,9 +93,9 @@ class Logger {
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
/**
|
|
97
|
-
* Set the log level
|
|
98
|
-
* @param {string} level - One of 'debug', 'info', 'warn', 'error', 'silent'
|
|
96
|
+
/**
|
|
97
|
+
* Set the log level
|
|
98
|
+
* @param {string} level - One of 'debug', 'info', 'warn', 'error', 'silent'
|
|
99
99
|
*/
|
|
100
100
|
setLevel(level) {
|
|
101
101
|
if (this.levels[level] !== undefined) {
|
|
@@ -103,65 +103,65 @@ class Logger {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
/**
|
|
107
|
-
* Get current log level
|
|
106
|
+
/**
|
|
107
|
+
* Get current log level
|
|
108
108
|
*/
|
|
109
109
|
getLevel() {
|
|
110
110
|
return this.level;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* Check if a message should be logged
|
|
113
|
+
/**
|
|
114
|
+
* Check if a message should be logged
|
|
115
115
|
*/
|
|
116
116
|
shouldLog(level) {
|
|
117
117
|
return this.levels[level] >= this.levels[this.level];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/**
|
|
121
|
-
* Log debug message
|
|
120
|
+
/**
|
|
121
|
+
* Log debug message
|
|
122
122
|
*/
|
|
123
123
|
debug(message) {
|
|
124
124
|
if (this.shouldLog("debug")) {
|
|
125
125
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
126
126
|
args[_key - 1] = arguments[_key];
|
|
127
127
|
}
|
|
128
|
-
console.debug(
|
|
128
|
+
console.debug("[twsx:debug] ".concat(message), ...args);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/**
|
|
133
|
-
* Log info message
|
|
132
|
+
/**
|
|
133
|
+
* Log info message
|
|
134
134
|
*/
|
|
135
135
|
info(message) {
|
|
136
136
|
if (this.shouldLog("info")) {
|
|
137
137
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
138
138
|
args[_key2 - 1] = arguments[_key2];
|
|
139
139
|
}
|
|
140
|
-
console.info(
|
|
140
|
+
console.info("[twsx:info] ".concat(message), ...args);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
/**
|
|
145
|
-
* Log warning message
|
|
144
|
+
/**
|
|
145
|
+
* Log warning message
|
|
146
146
|
*/
|
|
147
147
|
warn(message) {
|
|
148
148
|
if (this.shouldLog("warn")) {
|
|
149
149
|
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
150
150
|
args[_key3 - 1] = arguments[_key3];
|
|
151
151
|
}
|
|
152
|
-
console.warn(
|
|
152
|
+
console.warn("[twsx:warn] ".concat(message), ...args);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
/**
|
|
157
|
-
* Log error message
|
|
156
|
+
/**
|
|
157
|
+
* Log error message
|
|
158
158
|
*/
|
|
159
159
|
error(message) {
|
|
160
160
|
if (this.shouldLog("error")) {
|
|
161
161
|
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
162
162
|
args[_key4 - 1] = arguments[_key4];
|
|
163
163
|
}
|
|
164
|
-
console.error(
|
|
164
|
+
console.error("[twsx:error] ".concat(message), ...args);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -175,14 +175,14 @@ try {
|
|
|
175
175
|
// e.g., TWSX_LOG_LEVEL=debug or TWSX_LOG_LEVEL=warn
|
|
176
176
|
logLevel = process.env.TWSX_LOG_LEVEL || "silent";
|
|
177
177
|
}
|
|
178
|
-
} catch {
|
|
178
|
+
} catch (_unused) {
|
|
179
179
|
// Silently fail - in browser environment, default to silent
|
|
180
180
|
logLevel = "silent";
|
|
181
181
|
}
|
|
182
182
|
const logger = new Logger(logLevel);
|
|
183
183
|
|
|
184
|
-
/**
|
|
185
|
-
* Custom error class for tailwind-to-style
|
|
184
|
+
/**
|
|
185
|
+
* Custom error class for tailwind-to-style
|
|
186
186
|
*/
|
|
187
187
|
class TwsError extends Error {
|
|
188
188
|
constructor(message) {
|
|
@@ -194,15 +194,15 @@ class TwsError extends Error {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Error event handlers
|
|
197
|
+
/**
|
|
198
|
+
* Error event handlers
|
|
199
199
|
*/
|
|
200
200
|
const errorHandlers = new Set();
|
|
201
201
|
|
|
202
|
-
/**
|
|
203
|
-
* Handle and broadcast errors
|
|
204
|
-
* @param {Error} error - The error that occurred
|
|
205
|
-
* @param {Object} context - Additional context about the error
|
|
202
|
+
/**
|
|
203
|
+
* Handle and broadcast errors
|
|
204
|
+
* @param {Error} error - The error that occurred
|
|
205
|
+
* @param {Object} context - Additional context about the error
|
|
206
206
|
*/
|
|
207
207
|
function handleError(error) {
|
|
208
208
|
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -261,7 +261,7 @@ const performanceMonitor = {
|
|
|
261
261
|
const duration = performance.now() - marker.startTime;
|
|
262
262
|
if (duration > 5) {
|
|
263
263
|
// Only log if > 5ms
|
|
264
|
-
logger.warn(
|
|
264
|
+
logger.warn("Slow ".concat(marker.label, ": ").concat(duration.toFixed(2), "ms"));
|
|
265
265
|
}
|
|
266
266
|
},
|
|
267
267
|
/**
|
|
@@ -284,9 +284,53 @@ const performanceMonitor = {
|
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
286
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
function _defineProperty(e, r, t) {
|
|
288
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
289
|
+
value: t,
|
|
290
|
+
enumerable: true,
|
|
291
|
+
configurable: true,
|
|
292
|
+
writable: true
|
|
293
|
+
}) : e[r] = t, e;
|
|
294
|
+
}
|
|
295
|
+
function ownKeys(e, r) {
|
|
296
|
+
var t = Object.keys(e);
|
|
297
|
+
if (Object.getOwnPropertySymbols) {
|
|
298
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
299
|
+
r && (o = o.filter(function (r) {
|
|
300
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
301
|
+
})), t.push.apply(t, o);
|
|
302
|
+
}
|
|
303
|
+
return t;
|
|
304
|
+
}
|
|
305
|
+
function _objectSpread2(e) {
|
|
306
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
307
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
308
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
309
|
+
_defineProperty(e, r, t[r]);
|
|
310
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
311
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
return e;
|
|
315
|
+
}
|
|
316
|
+
function _toPrimitive(t, r) {
|
|
317
|
+
if ("object" != typeof t || !t) return t;
|
|
318
|
+
var e = t[Symbol.toPrimitive];
|
|
319
|
+
if (void 0 !== e) {
|
|
320
|
+
var i = e.call(t, r);
|
|
321
|
+
if ("object" != typeof i) return i;
|
|
322
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
323
|
+
}
|
|
324
|
+
return ("string" === r ? String : Number)(t);
|
|
325
|
+
}
|
|
326
|
+
function _toPropertyKey(t) {
|
|
327
|
+
var i = _toPrimitive(t, "string");
|
|
328
|
+
return "symbol" == typeof i ? i : i + "";
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Proper LRU (Least Recently Used) Cache implementation
|
|
333
|
+
* Efficiently manages memory by removing least recently used items
|
|
290
334
|
*/
|
|
291
335
|
class LRUCache {
|
|
292
336
|
constructor() {
|
|
@@ -295,9 +339,9 @@ class LRUCache {
|
|
|
295
339
|
this.cache = new Map();
|
|
296
340
|
}
|
|
297
341
|
|
|
298
|
-
/**
|
|
299
|
-
* Get value from cache
|
|
300
|
-
* Updates the item as most recently used
|
|
342
|
+
/**
|
|
343
|
+
* Get value from cache
|
|
344
|
+
* Updates the item as most recently used
|
|
301
345
|
*/
|
|
302
346
|
get(key) {
|
|
303
347
|
if (!this.cache.has(key)) {
|
|
@@ -310,9 +354,9 @@ class LRUCache {
|
|
|
310
354
|
return value;
|
|
311
355
|
}
|
|
312
356
|
|
|
313
|
-
/**
|
|
314
|
-
* Set value in cache
|
|
315
|
-
* Removes least recently used item if cache is full
|
|
357
|
+
/**
|
|
358
|
+
* Set value in cache
|
|
359
|
+
* Removes least recently used item if cache is full
|
|
316
360
|
*/
|
|
317
361
|
set(key, value) {
|
|
318
362
|
// If key exists, delete it first to update position
|
|
@@ -326,29 +370,29 @@ class LRUCache {
|
|
|
326
370
|
this.cache.set(key, value);
|
|
327
371
|
}
|
|
328
372
|
|
|
329
|
-
/**
|
|
330
|
-
* Check if key exists in cache
|
|
373
|
+
/**
|
|
374
|
+
* Check if key exists in cache
|
|
331
375
|
*/
|
|
332
376
|
has(key) {
|
|
333
377
|
return this.cache.has(key);
|
|
334
378
|
}
|
|
335
379
|
|
|
336
|
-
/**
|
|
337
|
-
* Clear all cache entries
|
|
380
|
+
/**
|
|
381
|
+
* Clear all cache entries
|
|
338
382
|
*/
|
|
339
383
|
clear() {
|
|
340
384
|
this.cache.clear();
|
|
341
385
|
}
|
|
342
386
|
|
|
343
|
-
/**
|
|
344
|
-
* Get current cache size
|
|
387
|
+
/**
|
|
388
|
+
* Get current cache size
|
|
345
389
|
*/
|
|
346
390
|
get size() {
|
|
347
391
|
return this.cache.size;
|
|
348
392
|
}
|
|
349
393
|
|
|
350
|
-
/**
|
|
351
|
-
* Delete specific key
|
|
394
|
+
/**
|
|
395
|
+
* Delete specific key
|
|
352
396
|
*/
|
|
353
397
|
delete(key) {
|
|
354
398
|
return this.cache.delete(key);
|
|
@@ -426,11 +470,11 @@ const COLOR_REGEX_PATTERNS = new Map();
|
|
|
426
470
|
for (const prop of COLOR_PROPERTIES) {
|
|
427
471
|
const escapedProp = prop.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
428
472
|
COLOR_REGEX_PATTERNS.set(prop, {
|
|
429
|
-
rgb: new RegExp(
|
|
430
|
-
rgba: new RegExp(
|
|
431
|
-
hsl: new RegExp(
|
|
432
|
-
hsla: new RegExp(
|
|
433
|
-
hex: new RegExp(
|
|
473
|
+
rgb: new RegExp("(".concat(escapedProp, "\\s*:\\s*)rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)"), "gi"),
|
|
474
|
+
rgba: new RegExp("(".concat(escapedProp, "\\s*:\\s*)rgba\\((\\d+),\\s*(\\d+),\\s*(\\d+),\\s*[\\d.]+\\)"), "gi"),
|
|
475
|
+
hsl: new RegExp("(".concat(escapedProp, "\\s*:\\s*)hsl\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%)\\)"), "gi"),
|
|
476
|
+
hsla: new RegExp("(".concat(escapedProp, "\\s*:\\s*)hsla\\((\\d+),\\s*([\\d.]+%),\\s*([\\d.]+%),\\s*[\\d.]+\\)"), "gi"),
|
|
477
|
+
hex: new RegExp("(".concat(escapedProp, "\\s*:\\s*)(#[0-9a-fA-F]{3,6})"), "gi")
|
|
434
478
|
});
|
|
435
479
|
}
|
|
436
480
|
|
|
@@ -444,16 +488,6 @@ const FRACTION_DENOMINATORS = [2, 3, 4, 5, 6, 12];
|
|
|
444
488
|
/** Prefixes that support fractional values */
|
|
445
489
|
const FRACTION_PREFIXES = ["w-", "h-", "max-w-", "max-h-", "min-w-", "min-h-", "top-", "bottom-", "left-", "right-", "inset-", "inset-x-", "inset-y-", "translate-x-", "translate-y-", "rounded-t-", "rounded-b-", "rounded-l-", "rounded-r-", "rounded-bl-", "rounded-br-", "rounded-tl-", "rounded-tr-", "flex-basis-", "z-"];
|
|
446
490
|
|
|
447
|
-
/**
|
|
448
|
-
* CSS Resolution Utilities
|
|
449
|
-
*
|
|
450
|
-
* Handles CSS custom property (var) resolution, CSS declaration parsing,
|
|
451
|
-
* and conversion between different CSS formats.
|
|
452
|
-
*
|
|
453
|
-
* @module css/resolver
|
|
454
|
-
*/
|
|
455
|
-
|
|
456
|
-
|
|
457
491
|
// Cache for CSS resolution
|
|
458
492
|
const cssResolutionCache = new LRUCache(1000);
|
|
459
493
|
|
|
@@ -508,11 +542,11 @@ function resolveCssToClearCss(cssString) {
|
|
|
508
542
|
const varKeys = Object.keys(customVars);
|
|
509
543
|
for (let i = 0; i < varKeys.length; i++) {
|
|
510
544
|
const key = varKeys[i];
|
|
511
|
-
result +=
|
|
545
|
+
result += "".concat(key, ": ").concat(customVars[key], "; ");
|
|
512
546
|
}
|
|
513
547
|
for (let i = 0; i < propKeys.length; i++) {
|
|
514
548
|
const key = propKeys[i];
|
|
515
|
-
result +=
|
|
549
|
+
result += "".concat(key, ": ").concat(props[key], "; ");
|
|
516
550
|
}
|
|
517
551
|
return result.trim();
|
|
518
552
|
}
|
|
@@ -563,9 +597,7 @@ function separateAndResolveCSS(arr) {
|
|
|
563
597
|
logger.warn("Error processing CSS declaration:", item, error);
|
|
564
598
|
}
|
|
565
599
|
}
|
|
566
|
-
const resolvedProperties = {
|
|
567
|
-
...cssProperties
|
|
568
|
-
};
|
|
600
|
+
const resolvedProperties = _objectSpread2({}, cssProperties);
|
|
569
601
|
|
|
570
602
|
/**
|
|
571
603
|
* Optimized CSS variable resolution using regex-based approach
|
|
@@ -639,7 +671,7 @@ function separateAndResolveCSS(arr) {
|
|
|
639
671
|
const finalKeys = Object.keys(resolvedProperties);
|
|
640
672
|
for (let i = 0; i < finalKeys.length; i++) {
|
|
641
673
|
const key = finalKeys[i];
|
|
642
|
-
result +=
|
|
674
|
+
result += "".concat(key, ": ").concat(resolvedProperties[key], "; ");
|
|
643
675
|
}
|
|
644
676
|
result = result.trim();
|
|
645
677
|
cssResolutionCache.set(cacheKey, result);
|
|
@@ -707,16 +739,6 @@ function inlineStyleToJson(styleString) {
|
|
|
707
739
|
return styleObject;
|
|
708
740
|
}
|
|
709
741
|
|
|
710
|
-
/**
|
|
711
|
-
* CSS Parser Utilities
|
|
712
|
-
*
|
|
713
|
-
* Handles parsing of Tailwind class names, opacity modifiers,
|
|
714
|
-
* bracket value encoding/decoding, and custom value extraction.
|
|
715
|
-
*
|
|
716
|
-
* @module css/parser
|
|
717
|
-
*/
|
|
718
|
-
|
|
719
|
-
|
|
720
742
|
/**
|
|
721
743
|
* Process opacity modifier from class name
|
|
722
744
|
*
|
|
@@ -745,7 +767,7 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
745
767
|
for (const prop in OPACITY_PROP_REGEXES) {
|
|
746
768
|
const regex = OPACITY_PROP_REGEXES[prop];
|
|
747
769
|
regex.lastIndex = 0; // Reset global regex
|
|
748
|
-
modifiedDeclaration = modifiedDeclaration.replace(regex,
|
|
770
|
+
modifiedDeclaration = modifiedDeclaration.replace(regex, "".concat(prop, ": ").concat(alphaValue));
|
|
749
771
|
}
|
|
750
772
|
|
|
751
773
|
// Also handle direct color values using pre-compiled regex patterns
|
|
@@ -761,16 +783,16 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
761
783
|
patterns.hex.lastIndex = 0;
|
|
762
784
|
|
|
763
785
|
// Convert rgb to rgba with opacity
|
|
764
|
-
modifiedDeclaration = modifiedDeclaration.replace(patterns.rgb,
|
|
786
|
+
modifiedDeclaration = modifiedDeclaration.replace(patterns.rgb, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
|
|
765
787
|
|
|
766
788
|
// Update existing rgba opacity
|
|
767
|
-
modifiedDeclaration = modifiedDeclaration.replace(patterns.rgba,
|
|
789
|
+
modifiedDeclaration = modifiedDeclaration.replace(patterns.rgba, "$1rgba($2, $3, $4, ".concat(alphaValue, ")"));
|
|
768
790
|
|
|
769
791
|
// Convert hsl to hsla with opacity
|
|
770
|
-
modifiedDeclaration = modifiedDeclaration.replace(patterns.hsl,
|
|
792
|
+
modifiedDeclaration = modifiedDeclaration.replace(patterns.hsl, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
|
|
771
793
|
|
|
772
794
|
// Update existing hsla opacity
|
|
773
|
-
modifiedDeclaration = modifiedDeclaration.replace(patterns.hsla,
|
|
795
|
+
modifiedDeclaration = modifiedDeclaration.replace(patterns.hsla, "$1hsla($2, $3, $4, ".concat(alphaValue, ")"));
|
|
774
796
|
|
|
775
797
|
// Handle hex colors - convert to rgba
|
|
776
798
|
modifiedDeclaration = modifiedDeclaration.replace(patterns.hex, (match, propPart, hexColor) => {
|
|
@@ -786,7 +808,7 @@ function processOpacityModifier(className, cssDeclaration) {
|
|
|
786
808
|
g = parseInt(hex.substring(2, 4), 16);
|
|
787
809
|
b = parseInt(hex.substring(4, 6), 16);
|
|
788
810
|
}
|
|
789
|
-
return
|
|
811
|
+
return "".concat(propPart, "rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alphaValue, ")");
|
|
790
812
|
});
|
|
791
813
|
}
|
|
792
814
|
return modifiedDeclaration;
|
|
@@ -861,12 +883,12 @@ function tws(classNames) {
|
|
|
861
883
|
|
|
862
884
|
// If no valid classes are found
|
|
863
885
|
if (!classes || classes.length === 0) {
|
|
864
|
-
logger.warn(
|
|
886
|
+
logger.warn("No valid Tailwind classes found in input: \"".concat(classNames, "\""));
|
|
865
887
|
performanceMonitor.end(totalMarker);
|
|
866
888
|
return convertToJson ? {} : "";
|
|
867
889
|
}
|
|
868
890
|
} catch (error) {
|
|
869
|
-
logger.error(
|
|
891
|
+
logger.error("Error parsing Tailwind classes: ".concat(error.message));
|
|
870
892
|
performanceMonitor.end(totalMarker);
|
|
871
893
|
return convertToJson ? {} : "";
|
|
872
894
|
}
|
|
@@ -886,7 +908,7 @@ function tws(classNames) {
|
|
|
886
908
|
if (opacityValue >= 0 && opacityValue <= 100) {
|
|
887
909
|
// Check if this could be a fraction (e.g., w-2/3, h-1/2)
|
|
888
910
|
// Fractions typically have denominators of 2, 3, 4, 5, 6, 12
|
|
889
|
-
const couldBeFraction = FRACTION_DENOMINATORS.includes(opacityValue) && FRACTION_PREFIXES.some(prefix => className.startsWith(prefix) || className.startsWith(
|
|
911
|
+
const couldBeFraction = FRACTION_DENOMINATORS.includes(opacityValue) && FRACTION_PREFIXES.some(prefix => className.startsWith(prefix) || className.startsWith("-".concat(prefix)));
|
|
890
912
|
if (!couldBeFraction) {
|
|
891
913
|
baseClassName = className.replace(/\/\d+$/, "");
|
|
892
914
|
hasOpacityModifier = true;
|
|
@@ -905,8 +927,8 @@ function tws(classNames) {
|
|
|
905
927
|
if (match) {
|
|
906
928
|
const customValue = match[1];
|
|
907
929
|
const baseKey = baseClassName.split("[")[0];
|
|
908
|
-
if (cssObject[
|
|
909
|
-
let customResult = cssObject[
|
|
930
|
+
if (cssObject["".concat(baseKey, "custom")]) {
|
|
931
|
+
let customResult = cssObject["".concat(baseKey, "custom")].replace(/custom_value/g, customValue);
|
|
910
932
|
// Apply opacity modifier to custom values too
|
|
911
933
|
if (hasOpacityModifier && className.includes("/") && /\/\d+$/.test(className)) {
|
|
912
934
|
customResult = processOpacityModifier(className, customResult);
|
|
@@ -960,14 +982,14 @@ function debounce(func) {
|
|
|
960
982
|
callCount++;
|
|
961
983
|
clearTimeout(timeout);
|
|
962
984
|
timeout = setTimeout(() => {
|
|
963
|
-
const marker = performanceMonitor.start(
|
|
985
|
+
const marker = performanceMonitor.start("debounced:".concat(func.name || "anonymous"));
|
|
964
986
|
try {
|
|
965
987
|
const result = func.apply(context, args);
|
|
966
988
|
performanceMonitor.end(marker);
|
|
967
989
|
return result;
|
|
968
990
|
} catch (error) {
|
|
969
991
|
performanceMonitor.end(marker);
|
|
970
|
-
logger.error(
|
|
992
|
+
logger.error("Debounced function error (call #".concat(callCount, "):"), error);
|
|
971
993
|
throw error;
|
|
972
994
|
}
|
|
973
995
|
}, wait);
|