tailwind-to-style 2.6.2 → 2.7.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 CHANGED
@@ -359,6 +359,91 @@ twsx({ ... }, { inject: false }) // CSS is NOT injected, just returned as string
359
359
 
360
360
  > Note: This option only affects browser usage. In Node.js or SSR, no injection occurs.
361
361
 
362
+ ## Performance Monitoring & Debugging (v2.7.0+)
363
+
364
+ Starting from version 2.7.0, `tailwind-to-style` includes built-in performance monitoring and debugging utilities to help you optimize your application and troubleshoot issues.
365
+
366
+ ### Performance Utils
367
+
368
+ ```javascript
369
+ import { performanceUtils } from "tailwind-to-style";
370
+
371
+ // Enable performance logging (logs operations > 5ms as warnings)
372
+ performanceUtils.enablePerformanceLogging(true);
373
+
374
+ // Get cache and injection statistics
375
+ const stats = performanceUtils.getStats();
376
+ console.log(stats);
377
+ // Output:
378
+ // {
379
+ // cacheStats: {
380
+ // cssResolution: 45,
381
+ // configOptions: 2,
382
+ // parseSelector: 23,
383
+ // encodeBracket: 12,
384
+ // decodeBracket: 8
385
+ // },
386
+ // injectionStats: {
387
+ // uniqueStylesheets: 15
388
+ // }
389
+ // }
390
+
391
+ // Clear all caches (useful for memory management)
392
+ performanceUtils.clearCaches();
393
+ ```
394
+
395
+ ### Performance Metrics
396
+
397
+ The library automatically tracks performance for key operations:
398
+
399
+ - **tws:total** - Total execution time for `tws()`
400
+ - **tws:parse** - Time spent parsing classes
401
+ - **tws:process** - Time spent processing classes
402
+ - **twsx:total** - Total execution time for `twsx()`
403
+ - **twsx:flatten** - Time spent flattening objects
404
+ - **twsx:generate** - Time spent generating CSS
405
+ - **css:inject** - Time spent injecting CSS to DOM
406
+
407
+ ### Debounced Functions
408
+
409
+ For high-frequency usage, use the debounced versions:
410
+
411
+ ```javascript
412
+ import { debouncedTws, debouncedTwsx } from "tailwind-to-style";
413
+
414
+ // Debounced versions (50ms for tws, 100ms for twsx)
415
+ const styles = debouncedTws("bg-red-500 p-4");
416
+ const complexStyles = debouncedTwsx({ ".card": "bg-white p-6" });
417
+ ```
418
+
419
+ ### Example: Performance Monitoring
420
+
421
+ ```javascript
422
+ import { tws, twsx, performanceUtils } from "tailwind-to-style";
423
+
424
+ // Enable monitoring
425
+ performanceUtils.enablePerformanceLogging(true);
426
+
427
+ // Your code that uses tws/twsx
428
+ const styles = tws("bg-gradient-to-r from-purple-400 to-pink-500 p-8");
429
+ const complexStyles = twsx({
430
+ ".hero": [
431
+ "bg-gradient-to-br from-indigo-900 to-purple-900 min-h-screen",
432
+ {
433
+ "h1": "text-6xl font-bold text-white",
434
+ "@media (max-width: 768px)": {
435
+ "h1": "text-4xl"
436
+ }
437
+ }
438
+ ]
439
+ });
440
+
441
+ // Check performance stats
442
+ console.log(performanceUtils.getStats());
443
+ ```
444
+
445
+ This will automatically log warnings for operations taking longer than 5ms and provide insights into cache usage and performance bottlenecks.
446
+
362
447
  ## License
363
448
 
364
449
  ## Contributing