tailwind-to-style 2.7.3 → 2.7.4

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.3
2
+ * tailwind-to-style v2.7.4
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -6377,7 +6377,12 @@ var tailwindToStyle = (function (exports) {
6377
6377
  }
6378
6378
  let twString = null;
6379
6379
  let cssObject = null;
6380
- let globalConfig = {
6380
+
6381
+ // Global config storage key
6382
+ const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
6383
+
6384
+ // Default configuration
6385
+ const defaultConfig = {
6381
6386
  theme: {
6382
6387
  extend: {
6383
6388
  colors: {}
@@ -6392,12 +6397,42 @@ var tailwindToStyle = (function (exports) {
6392
6397
  },
6393
6398
  inject: true
6394
6399
  };
6400
+
6401
+ // Detect environment and create global storage
6402
+ function getGlobalStorage() {
6403
+ if (typeof window !== "undefined") {
6404
+ // Browser environment - use window object
6405
+ if (!window[CONFIG_STORAGE_KEY]) {
6406
+ window[CONFIG_STORAGE_KEY] = {
6407
+ ...defaultConfig
6408
+ };
6409
+ }
6410
+ return window[CONFIG_STORAGE_KEY];
6411
+ } else if (typeof global !== "undefined") {
6412
+ // Node.js environment - use global object
6413
+ if (!global[CONFIG_STORAGE_KEY]) {
6414
+ global[CONFIG_STORAGE_KEY] = {
6415
+ ...defaultConfig
6416
+ };
6417
+ }
6418
+ return global[CONFIG_STORAGE_KEY];
6419
+ } else {
6420
+ // Fallback - use module-level variable (will work only within same file)
6421
+ console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
6422
+ return defaultConfig;
6423
+ }
6424
+ }
6425
+
6426
+ // Get global config reference
6427
+ let globalConfig = getGlobalStorage();
6395
6428
  function initializeCss() {
6396
6429
  if (!twString) {
6430
+ // Always get fresh config from global storage
6431
+ const currentConfig = getGlobalStorage();
6397
6432
  const configForGeneration = {
6398
- ...globalConfig,
6433
+ ...currentConfig,
6399
6434
  theme: {
6400
- ...globalConfig.theme
6435
+ ...currentConfig.theme
6401
6436
  }
6402
6437
  };
6403
6438
  twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
@@ -6426,32 +6461,61 @@ var tailwindToStyle = (function (exports) {
6426
6461
  twString = null;
6427
6462
  cssObject = null;
6428
6463
  configOptionsCache.clear();
6429
- globalConfig = {
6430
- ...globalConfig,
6464
+
6465
+ // Get current global storage reference
6466
+ const globalStorage = getGlobalStorage();
6467
+
6468
+ // Update global storage directly
6469
+ Object.assign(globalStorage, {
6470
+ ...globalStorage,
6431
6471
  ...config,
6432
6472
  theme: {
6433
- ...globalConfig.theme,
6473
+ ...globalStorage.theme,
6434
6474
  ...(config.theme || {}),
6435
6475
  extend: {
6436
- ...globalConfig.theme.extend,
6476
+ ...globalStorage.theme.extend,
6437
6477
  ...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
6438
6478
  colors: {
6439
- ...globalConfig.theme.extend.colors,
6479
+ ...globalStorage.theme.extend.colors,
6440
6480
  ...(((_config$theme2 = config.theme) === null || _config$theme2 === void 0 ? void 0 : (_config$theme2$extend = _config$theme2.extend) === null || _config$theme2$extend === void 0 ? void 0 : _config$theme2$extend.colors) || {})
6441
6481
  }
6442
6482
  }
6443
6483
  }
6444
- };
6484
+ });
6445
6485
 
6446
6486
  // Handle screens configuration
6447
6487
  if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
6448
- globalConfig.theme.screens = {
6449
- ...globalConfig.theme.screens,
6488
+ globalStorage.theme.screens = {
6489
+ ...globalStorage.theme.screens,
6450
6490
  ...config.theme.screens
6451
6491
  };
6452
6492
  }
6493
+
6494
+ // Handle legacy breakpoints with deprecation warning
6495
+ if (config.breakpoints) {
6496
+ console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
6497
+
6498
+ // Convert legacy breakpoints to screens format
6499
+ const screens = {};
6500
+ for (const [key, value] of Object.entries(config.breakpoints)) {
6501
+ // Extract min-width value from media query
6502
+ const match = value.match(/min-width:\s*([^)]+)/);
6503
+ if (match) {
6504
+ screens[key] = match[1].trim();
6505
+ }
6506
+ }
6507
+ globalStorage.theme.screens = {
6508
+ ...globalStorage.theme.screens,
6509
+ ...screens
6510
+ };
6511
+ }
6512
+
6513
+ // Update local reference
6514
+ globalConfig = globalStorage;
6453
6515
  initializeCss();
6454
- return globalConfig;
6516
+ return {
6517
+ ...globalConfig
6518
+ };
6455
6519
  }
6456
6520
 
6457
6521
  /**
@@ -6459,6 +6523,8 @@ var tailwindToStyle = (function (exports) {
6459
6523
  * @returns {Object} Current global configuration
6460
6524
  */
6461
6525
  function getConfig() {
6526
+ // Always get fresh reference from global storage
6527
+ globalConfig = getGlobalStorage();
6462
6528
  return {
6463
6529
  ...globalConfig
6464
6530
  };
@@ -6472,7 +6538,12 @@ var tailwindToStyle = (function (exports) {
6472
6538
  twString = null;
6473
6539
  cssObject = null;
6474
6540
  configOptionsCache.clear();
6475
- globalConfig = {
6541
+
6542
+ // Get global storage reference and reset it
6543
+ const globalStorage = getGlobalStorage();
6544
+
6545
+ // Reset to default config
6546
+ Object.assign(globalStorage, {
6476
6547
  theme: {
6477
6548
  extend: {
6478
6549
  colors: {}
@@ -6486,10 +6557,15 @@ var tailwindToStyle = (function (exports) {
6486
6557
  }
6487
6558
  },
6488
6559
  inject: true
6489
- };
6560
+ });
6561
+
6562
+ // Update local reference
6563
+ globalConfig = globalStorage;
6490
6564
  twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
6491
6565
  cssObject = convertCssToObject(twString);
6492
- return globalConfig;
6566
+ return {
6567
+ ...globalConfig
6568
+ };
6493
6569
  }
6494
6570
  const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
6495
6571
  const specialVariants = {
@@ -6540,7 +6616,9 @@ var tailwindToStyle = (function (exports) {
6540
6616
  let media = null;
6541
6617
  let finalSelector = selector;
6542
6618
  for (const v of variants) {
6543
- const breakpoints = convertScreensToBreakpoints(globalConfig.theme.screens || {});
6619
+ // Always get fresh config from global storage
6620
+ const currentConfig = getGlobalStorage();
6621
+ const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
6544
6622
  if (breakpoints[v]) {
6545
6623
  media = breakpoints[v];
6546
6624
  } else if (pseudoVariants.has(v)) {
@@ -7156,7 +7234,7 @@ var tailwindToStyle = (function (exports) {
7156
7234
  return "";
7157
7235
  }
7158
7236
  const mergedOptions = {
7159
- ...globalConfig,
7237
+ ...getGlobalStorage(),
7160
7238
  ...options
7161
7239
  };
7162
7240
  const {
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.3
2
+ * tailwind-to-style v2.7.4
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -6378,7 +6378,12 @@ function convertCssToObject(cssString) {
6378
6378
  }
6379
6379
  let twString = null;
6380
6380
  let cssObject = null;
6381
- let globalConfig = {
6381
+
6382
+ // Global config storage key
6383
+ const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
6384
+
6385
+ // Default configuration
6386
+ const defaultConfig = {
6382
6387
  theme: {
6383
6388
  extend: {
6384
6389
  colors: {}
@@ -6393,12 +6398,42 @@ let globalConfig = {
6393
6398
  },
6394
6399
  inject: true
6395
6400
  };
6401
+
6402
+ // Detect environment and create global storage
6403
+ function getGlobalStorage() {
6404
+ if (typeof window !== "undefined") {
6405
+ // Browser environment - use window object
6406
+ if (!window[CONFIG_STORAGE_KEY]) {
6407
+ window[CONFIG_STORAGE_KEY] = {
6408
+ ...defaultConfig
6409
+ };
6410
+ }
6411
+ return window[CONFIG_STORAGE_KEY];
6412
+ } else if (typeof global !== "undefined") {
6413
+ // Node.js environment - use global object
6414
+ if (!global[CONFIG_STORAGE_KEY]) {
6415
+ global[CONFIG_STORAGE_KEY] = {
6416
+ ...defaultConfig
6417
+ };
6418
+ }
6419
+ return global[CONFIG_STORAGE_KEY];
6420
+ } else {
6421
+ // Fallback - use module-level variable (will work only within same file)
6422
+ console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
6423
+ return defaultConfig;
6424
+ }
6425
+ }
6426
+
6427
+ // Get global config reference
6428
+ let globalConfig = getGlobalStorage();
6396
6429
  function initializeCss() {
6397
6430
  if (!twString) {
6431
+ // Always get fresh config from global storage
6432
+ const currentConfig = getGlobalStorage();
6398
6433
  const configForGeneration = {
6399
- ...globalConfig,
6434
+ ...currentConfig,
6400
6435
  theme: {
6401
- ...globalConfig.theme
6436
+ ...currentConfig.theme
6402
6437
  }
6403
6438
  };
6404
6439
  twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
@@ -6427,32 +6462,61 @@ function setConfig(config) {
6427
6462
  twString = null;
6428
6463
  cssObject = null;
6429
6464
  configOptionsCache.clear();
6430
- globalConfig = {
6431
- ...globalConfig,
6465
+
6466
+ // Get current global storage reference
6467
+ const globalStorage = getGlobalStorage();
6468
+
6469
+ // Update global storage directly
6470
+ Object.assign(globalStorage, {
6471
+ ...globalStorage,
6432
6472
  ...config,
6433
6473
  theme: {
6434
- ...globalConfig.theme,
6474
+ ...globalStorage.theme,
6435
6475
  ...(config.theme || {}),
6436
6476
  extend: {
6437
- ...globalConfig.theme.extend,
6477
+ ...globalStorage.theme.extend,
6438
6478
  ...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
6439
6479
  colors: {
6440
- ...globalConfig.theme.extend.colors,
6480
+ ...globalStorage.theme.extend.colors,
6441
6481
  ...(((_config$theme2 = config.theme) === null || _config$theme2 === void 0 ? void 0 : (_config$theme2$extend = _config$theme2.extend) === null || _config$theme2$extend === void 0 ? void 0 : _config$theme2$extend.colors) || {})
6442
6482
  }
6443
6483
  }
6444
6484
  }
6445
- };
6485
+ });
6446
6486
 
6447
6487
  // Handle screens configuration
6448
6488
  if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
6449
- globalConfig.theme.screens = {
6450
- ...globalConfig.theme.screens,
6489
+ globalStorage.theme.screens = {
6490
+ ...globalStorage.theme.screens,
6451
6491
  ...config.theme.screens
6452
6492
  };
6453
6493
  }
6494
+
6495
+ // Handle legacy breakpoints with deprecation warning
6496
+ if (config.breakpoints) {
6497
+ console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
6498
+
6499
+ // Convert legacy breakpoints to screens format
6500
+ const screens = {};
6501
+ for (const [key, value] of Object.entries(config.breakpoints)) {
6502
+ // Extract min-width value from media query
6503
+ const match = value.match(/min-width:\s*([^)]+)/);
6504
+ if (match) {
6505
+ screens[key] = match[1].trim();
6506
+ }
6507
+ }
6508
+ globalStorage.theme.screens = {
6509
+ ...globalStorage.theme.screens,
6510
+ ...screens
6511
+ };
6512
+ }
6513
+
6514
+ // Update local reference
6515
+ globalConfig = globalStorage;
6454
6516
  initializeCss();
6455
- return globalConfig;
6517
+ return {
6518
+ ...globalConfig
6519
+ };
6456
6520
  }
6457
6521
 
6458
6522
  /**
@@ -6460,6 +6524,8 @@ function setConfig(config) {
6460
6524
  * @returns {Object} Current global configuration
6461
6525
  */
6462
6526
  function getConfig() {
6527
+ // Always get fresh reference from global storage
6528
+ globalConfig = getGlobalStorage();
6463
6529
  return {
6464
6530
  ...globalConfig
6465
6531
  };
@@ -6473,7 +6539,12 @@ function resetConfig() {
6473
6539
  twString = null;
6474
6540
  cssObject = null;
6475
6541
  configOptionsCache.clear();
6476
- globalConfig = {
6542
+
6543
+ // Get global storage reference and reset it
6544
+ const globalStorage = getGlobalStorage();
6545
+
6546
+ // Reset to default config
6547
+ Object.assign(globalStorage, {
6477
6548
  theme: {
6478
6549
  extend: {
6479
6550
  colors: {}
@@ -6487,10 +6558,15 @@ function resetConfig() {
6487
6558
  }
6488
6559
  },
6489
6560
  inject: true
6490
- };
6561
+ });
6562
+
6563
+ // Update local reference
6564
+ globalConfig = globalStorage;
6491
6565
  twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
6492
6566
  cssObject = convertCssToObject(twString);
6493
- return globalConfig;
6567
+ return {
6568
+ ...globalConfig
6569
+ };
6494
6570
  }
6495
6571
  const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
6496
6572
  const specialVariants = {
@@ -6541,7 +6617,9 @@ function resolveVariants(selector, variants) {
6541
6617
  let media = null;
6542
6618
  let finalSelector = selector;
6543
6619
  for (const v of variants) {
6544
- const breakpoints = convertScreensToBreakpoints(globalConfig.theme.screens || {});
6620
+ // Always get fresh config from global storage
6621
+ const currentConfig = getGlobalStorage();
6622
+ const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
6545
6623
  if (breakpoints[v]) {
6546
6624
  media = breakpoints[v];
6547
6625
  } else if (pseudoVariants.has(v)) {
@@ -7157,7 +7235,7 @@ function twsx(obj) {
7157
7235
  return "";
7158
7236
  }
7159
7237
  const mergedOptions = {
7160
- ...globalConfig,
7238
+ ...getGlobalStorage(),
7161
7239
  ...options
7162
7240
  };
7163
7241
  const {
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.7.3
2
+ * tailwind-to-style v2.7.4
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
@@ -6374,7 +6374,12 @@ function convertCssToObject(cssString) {
6374
6374
  }
6375
6375
  let twString = null;
6376
6376
  let cssObject = null;
6377
- let globalConfig = {
6377
+
6378
+ // Global config storage key
6379
+ const CONFIG_STORAGE_KEY = "__tailwind_to_style_global_config__";
6380
+
6381
+ // Default configuration
6382
+ const defaultConfig = {
6378
6383
  theme: {
6379
6384
  extend: {
6380
6385
  colors: {}
@@ -6389,12 +6394,42 @@ let globalConfig = {
6389
6394
  },
6390
6395
  inject: true
6391
6396
  };
6397
+
6398
+ // Detect environment and create global storage
6399
+ function getGlobalStorage() {
6400
+ if (typeof window !== "undefined") {
6401
+ // Browser environment - use window object
6402
+ if (!window[CONFIG_STORAGE_KEY]) {
6403
+ window[CONFIG_STORAGE_KEY] = {
6404
+ ...defaultConfig
6405
+ };
6406
+ }
6407
+ return window[CONFIG_STORAGE_KEY];
6408
+ } else if (typeof global !== "undefined") {
6409
+ // Node.js environment - use global object
6410
+ if (!global[CONFIG_STORAGE_KEY]) {
6411
+ global[CONFIG_STORAGE_KEY] = {
6412
+ ...defaultConfig
6413
+ };
6414
+ }
6415
+ return global[CONFIG_STORAGE_KEY];
6416
+ } else {
6417
+ // Fallback - use module-level variable (will work only within same file)
6418
+ console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
6419
+ return defaultConfig;
6420
+ }
6421
+ }
6422
+
6423
+ // Get global config reference
6424
+ let globalConfig = getGlobalStorage();
6392
6425
  function initializeCss() {
6393
6426
  if (!twString) {
6427
+ // Always get fresh config from global storage
6428
+ const currentConfig = getGlobalStorage();
6394
6429
  const configForGeneration = {
6395
- ...globalConfig,
6430
+ ...currentConfig,
6396
6431
  theme: {
6397
- ...globalConfig.theme
6432
+ ...currentConfig.theme
6398
6433
  }
6399
6434
  };
6400
6435
  twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
@@ -6423,32 +6458,61 @@ function setConfig(config) {
6423
6458
  twString = null;
6424
6459
  cssObject = null;
6425
6460
  configOptionsCache.clear();
6426
- globalConfig = {
6427
- ...globalConfig,
6461
+
6462
+ // Get current global storage reference
6463
+ const globalStorage = getGlobalStorage();
6464
+
6465
+ // Update global storage directly
6466
+ Object.assign(globalStorage, {
6467
+ ...globalStorage,
6428
6468
  ...config,
6429
6469
  theme: {
6430
- ...globalConfig.theme,
6470
+ ...globalStorage.theme,
6431
6471
  ...(config.theme || {}),
6432
6472
  extend: {
6433
- ...globalConfig.theme.extend,
6473
+ ...globalStorage.theme.extend,
6434
6474
  ...(((_config$theme = config.theme) === null || _config$theme === void 0 ? void 0 : _config$theme.extend) || {}),
6435
6475
  colors: {
6436
- ...globalConfig.theme.extend.colors,
6476
+ ...globalStorage.theme.extend.colors,
6437
6477
  ...(((_config$theme2 = config.theme) === null || _config$theme2 === void 0 ? void 0 : (_config$theme2$extend = _config$theme2.extend) === null || _config$theme2$extend === void 0 ? void 0 : _config$theme2$extend.colors) || {})
6438
6478
  }
6439
6479
  }
6440
6480
  }
6441
- };
6481
+ });
6442
6482
 
6443
6483
  // Handle screens configuration
6444
6484
  if ((_config$theme3 = config.theme) !== null && _config$theme3 !== void 0 && _config$theme3.screens) {
6445
- globalConfig.theme.screens = {
6446
- ...globalConfig.theme.screens,
6485
+ globalStorage.theme.screens = {
6486
+ ...globalStorage.theme.screens,
6447
6487
  ...config.theme.screens
6448
6488
  };
6449
6489
  }
6490
+
6491
+ // Handle legacy breakpoints with deprecation warning
6492
+ if (config.breakpoints) {
6493
+ console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
6494
+
6495
+ // Convert legacy breakpoints to screens format
6496
+ const screens = {};
6497
+ for (const [key, value] of Object.entries(config.breakpoints)) {
6498
+ // Extract min-width value from media query
6499
+ const match = value.match(/min-width:\s*([^)]+)/);
6500
+ if (match) {
6501
+ screens[key] = match[1].trim();
6502
+ }
6503
+ }
6504
+ globalStorage.theme.screens = {
6505
+ ...globalStorage.theme.screens,
6506
+ ...screens
6507
+ };
6508
+ }
6509
+
6510
+ // Update local reference
6511
+ globalConfig = globalStorage;
6450
6512
  initializeCss();
6451
- return globalConfig;
6513
+ return {
6514
+ ...globalConfig
6515
+ };
6452
6516
  }
6453
6517
 
6454
6518
  /**
@@ -6456,6 +6520,8 @@ function setConfig(config) {
6456
6520
  * @returns {Object} Current global configuration
6457
6521
  */
6458
6522
  function getConfig() {
6523
+ // Always get fresh reference from global storage
6524
+ globalConfig = getGlobalStorage();
6459
6525
  return {
6460
6526
  ...globalConfig
6461
6527
  };
@@ -6469,7 +6535,12 @@ function resetConfig() {
6469
6535
  twString = null;
6470
6536
  cssObject = null;
6471
6537
  configOptionsCache.clear();
6472
- globalConfig = {
6538
+
6539
+ // Get global storage reference and reset it
6540
+ const globalStorage = getGlobalStorage();
6541
+
6542
+ // Reset to default config
6543
+ Object.assign(globalStorage, {
6473
6544
  theme: {
6474
6545
  extend: {
6475
6546
  colors: {}
@@ -6483,10 +6554,15 @@ function resetConfig() {
6483
6554
  }
6484
6555
  },
6485
6556
  inject: true
6486
- };
6557
+ });
6558
+
6559
+ // Update local reference
6560
+ globalConfig = globalStorage;
6487
6561
  twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
6488
6562
  cssObject = convertCssToObject(twString);
6489
- return globalConfig;
6563
+ return {
6564
+ ...globalConfig
6565
+ };
6490
6566
  }
6491
6567
  const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
6492
6568
  const specialVariants = {
@@ -6537,7 +6613,9 @@ function resolveVariants(selector, variants) {
6537
6613
  let media = null;
6538
6614
  let finalSelector = selector;
6539
6615
  for (const v of variants) {
6540
- const breakpoints = convertScreensToBreakpoints(globalConfig.theme.screens || {});
6616
+ // Always get fresh config from global storage
6617
+ const currentConfig = getGlobalStorage();
6618
+ const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
6541
6619
  if (breakpoints[v]) {
6542
6620
  media = breakpoints[v];
6543
6621
  } else if (pseudoVariants.has(v)) {
@@ -7153,7 +7231,7 @@ function twsx(obj) {
7153
7231
  return "";
7154
7232
  }
7155
7233
  const mergedOptions = {
7156
- ...globalConfig,
7234
+ ...getGlobalStorage(),
7157
7235
  ...options
7158
7236
  };
7159
7237
  const {