tailwind-to-style 2.7.3 → 2.7.5
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/dist/index.browser.js +106 -45
- package/dist/index.cjs +106 -45
- package/dist/index.esm.js +106 -45
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.5
|
|
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
|
-
|
|
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,72 @@ var tailwindToStyle = (function (exports) {
|
|
|
6392
6397
|
},
|
|
6393
6398
|
inject: true
|
|
6394
6399
|
};
|
|
6400
|
+
class ConfigManager {
|
|
6401
|
+
constructor() {
|
|
6402
|
+
this.storage = null;
|
|
6403
|
+
this.initialized = false;
|
|
6404
|
+
}
|
|
6405
|
+
initialize() {
|
|
6406
|
+
if (this.initialized) return this.storage;
|
|
6407
|
+
if (typeof window !== "undefined") {
|
|
6408
|
+
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6409
|
+
window[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6410
|
+
}
|
|
6411
|
+
this.storage = window[CONFIG_STORAGE_KEY];
|
|
6412
|
+
} else if (typeof global !== "undefined") {
|
|
6413
|
+
// Node.js environment
|
|
6414
|
+
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6415
|
+
global[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6416
|
+
}
|
|
6417
|
+
this.storage = global[CONFIG_STORAGE_KEY];
|
|
6418
|
+
} else {
|
|
6419
|
+
// Fallback
|
|
6420
|
+
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6421
|
+
this.storage = JSON.parse(JSON.stringify(defaultConfig));
|
|
6422
|
+
}
|
|
6423
|
+
this.initialized = true;
|
|
6424
|
+
return this.storage;
|
|
6425
|
+
}
|
|
6426
|
+
get() {
|
|
6427
|
+
return this.initialize();
|
|
6428
|
+
}
|
|
6429
|
+
set(config) {
|
|
6430
|
+
const storage = this.initialize();
|
|
6431
|
+
this.deepMerge(storage, config);
|
|
6432
|
+
return storage;
|
|
6433
|
+
}
|
|
6434
|
+
reset() {
|
|
6435
|
+
const storage = this.initialize();
|
|
6436
|
+
Object.keys(storage).forEach(key => delete storage[key]);
|
|
6437
|
+
Object.assign(storage, JSON.parse(JSON.stringify(defaultConfig)));
|
|
6438
|
+
return storage;
|
|
6439
|
+
}
|
|
6440
|
+
deepMerge(target, source) {
|
|
6441
|
+
for (const key in source) {
|
|
6442
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
6443
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
6444
|
+
target[key] = {};
|
|
6445
|
+
}
|
|
6446
|
+
this.deepMerge(target[key], source[key]);
|
|
6447
|
+
} else {
|
|
6448
|
+
target[key] = source[key];
|
|
6449
|
+
}
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6453
|
+
const configManager = new ConfigManager();
|
|
6454
|
+
function getGlobalStorage() {
|
|
6455
|
+
return configManager.get();
|
|
6456
|
+
}
|
|
6457
|
+
let globalConfig = null;
|
|
6395
6458
|
function initializeCss() {
|
|
6396
6459
|
if (!twString) {
|
|
6460
|
+
// Always get fresh config from global storage
|
|
6461
|
+
const currentConfig = getGlobalStorage();
|
|
6397
6462
|
const configForGeneration = {
|
|
6398
|
-
...
|
|
6463
|
+
...currentConfig,
|
|
6399
6464
|
theme: {
|
|
6400
|
-
...
|
|
6465
|
+
...currentConfig.theme
|
|
6401
6466
|
}
|
|
6402
6467
|
};
|
|
6403
6468
|
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
@@ -6421,37 +6486,39 @@ var tailwindToStyle = (function (exports) {
|
|
|
6421
6486
|
* @returns {Object} Current global configuration
|
|
6422
6487
|
*/
|
|
6423
6488
|
function setConfig(config) {
|
|
6424
|
-
var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
|
|
6425
6489
|
// Reset CSS object cache when config changes
|
|
6426
6490
|
twString = null;
|
|
6427
6491
|
cssObject = null;
|
|
6428
6492
|
configOptionsCache.clear();
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6493
|
+
|
|
6494
|
+
// Use ConfigManager to set config
|
|
6495
|
+
const globalStorage = configManager.set(config);
|
|
6496
|
+
|
|
6497
|
+
// Handle legacy breakpoints with deprecation warning
|
|
6498
|
+
if (config.breakpoints) {
|
|
6499
|
+
console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
|
|
6500
|
+
|
|
6501
|
+
// Convert legacy breakpoints to screens format
|
|
6502
|
+
const screens = {};
|
|
6503
|
+
for (const [key, value] of Object.entries(config.breakpoints)) {
|
|
6504
|
+
// Extract min-width value from media query
|
|
6505
|
+
const match = value.match(/min-width:\s*([^)]+)/);
|
|
6506
|
+
if (match) {
|
|
6507
|
+
screens[key] = match[1].trim();
|
|
6442
6508
|
}
|
|
6443
6509
|
}
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
globalConfig.theme.screens = {
|
|
6449
|
-
...globalConfig.theme.screens,
|
|
6450
|
-
...config.theme.screens
|
|
6451
|
-
};
|
|
6510
|
+
if (!globalStorage.theme.screens) {
|
|
6511
|
+
globalStorage.theme.screens = {};
|
|
6512
|
+
}
|
|
6513
|
+
Object.assign(globalStorage.theme.screens, screens);
|
|
6452
6514
|
}
|
|
6515
|
+
|
|
6516
|
+
// Update local reference
|
|
6517
|
+
globalConfig = globalStorage;
|
|
6453
6518
|
initializeCss();
|
|
6454
|
-
return
|
|
6519
|
+
return {
|
|
6520
|
+
...globalStorage
|
|
6521
|
+
};
|
|
6455
6522
|
}
|
|
6456
6523
|
|
|
6457
6524
|
/**
|
|
@@ -6459,6 +6526,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
6459
6526
|
* @returns {Object} Current global configuration
|
|
6460
6527
|
*/
|
|
6461
6528
|
function getConfig() {
|
|
6529
|
+
globalConfig = configManager.get();
|
|
6462
6530
|
return {
|
|
6463
6531
|
...globalConfig
|
|
6464
6532
|
};
|
|
@@ -6472,24 +6540,15 @@ var tailwindToStyle = (function (exports) {
|
|
|
6472
6540
|
twString = null;
|
|
6473
6541
|
cssObject = null;
|
|
6474
6542
|
configOptionsCache.clear();
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
},
|
|
6480
|
-
screens: {
|
|
6481
|
-
sm: "640px",
|
|
6482
|
-
md: "768px",
|
|
6483
|
-
lg: "1024px",
|
|
6484
|
-
xl: "1280px",
|
|
6485
|
-
"2xl": "1536px"
|
|
6486
|
-
}
|
|
6487
|
-
},
|
|
6488
|
-
inject: true
|
|
6489
|
-
};
|
|
6543
|
+
const globalStorage = configManager.reset();
|
|
6544
|
+
|
|
6545
|
+
// Update local reference
|
|
6546
|
+
globalConfig = globalStorage;
|
|
6490
6547
|
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6491
6548
|
cssObject = convertCssToObject(twString);
|
|
6492
|
-
return
|
|
6549
|
+
return {
|
|
6550
|
+
...globalConfig
|
|
6551
|
+
};
|
|
6493
6552
|
}
|
|
6494
6553
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6495
6554
|
const specialVariants = {
|
|
@@ -6540,7 +6599,9 @@ var tailwindToStyle = (function (exports) {
|
|
|
6540
6599
|
let media = null;
|
|
6541
6600
|
let finalSelector = selector;
|
|
6542
6601
|
for (const v of variants) {
|
|
6543
|
-
|
|
6602
|
+
// Always get fresh config from global storage
|
|
6603
|
+
const currentConfig = getGlobalStorage();
|
|
6604
|
+
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6544
6605
|
if (breakpoints[v]) {
|
|
6545
6606
|
media = breakpoints[v];
|
|
6546
6607
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -7156,7 +7217,7 @@ var tailwindToStyle = (function (exports) {
|
|
|
7156
7217
|
return "";
|
|
7157
7218
|
}
|
|
7158
7219
|
const mergedOptions = {
|
|
7159
|
-
...
|
|
7220
|
+
...getGlobalStorage(),
|
|
7160
7221
|
...options
|
|
7161
7222
|
};
|
|
7162
7223
|
const {
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.5
|
|
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
|
-
|
|
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,72 @@ let globalConfig = {
|
|
|
6393
6398
|
},
|
|
6394
6399
|
inject: true
|
|
6395
6400
|
};
|
|
6401
|
+
class ConfigManager {
|
|
6402
|
+
constructor() {
|
|
6403
|
+
this.storage = null;
|
|
6404
|
+
this.initialized = false;
|
|
6405
|
+
}
|
|
6406
|
+
initialize() {
|
|
6407
|
+
if (this.initialized) return this.storage;
|
|
6408
|
+
if (typeof window !== "undefined") {
|
|
6409
|
+
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6410
|
+
window[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6411
|
+
}
|
|
6412
|
+
this.storage = window[CONFIG_STORAGE_KEY];
|
|
6413
|
+
} else if (typeof global !== "undefined") {
|
|
6414
|
+
// Node.js environment
|
|
6415
|
+
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6416
|
+
global[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6417
|
+
}
|
|
6418
|
+
this.storage = global[CONFIG_STORAGE_KEY];
|
|
6419
|
+
} else {
|
|
6420
|
+
// Fallback
|
|
6421
|
+
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6422
|
+
this.storage = JSON.parse(JSON.stringify(defaultConfig));
|
|
6423
|
+
}
|
|
6424
|
+
this.initialized = true;
|
|
6425
|
+
return this.storage;
|
|
6426
|
+
}
|
|
6427
|
+
get() {
|
|
6428
|
+
return this.initialize();
|
|
6429
|
+
}
|
|
6430
|
+
set(config) {
|
|
6431
|
+
const storage = this.initialize();
|
|
6432
|
+
this.deepMerge(storage, config);
|
|
6433
|
+
return storage;
|
|
6434
|
+
}
|
|
6435
|
+
reset() {
|
|
6436
|
+
const storage = this.initialize();
|
|
6437
|
+
Object.keys(storage).forEach(key => delete storage[key]);
|
|
6438
|
+
Object.assign(storage, JSON.parse(JSON.stringify(defaultConfig)));
|
|
6439
|
+
return storage;
|
|
6440
|
+
}
|
|
6441
|
+
deepMerge(target, source) {
|
|
6442
|
+
for (const key in source) {
|
|
6443
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
6444
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
6445
|
+
target[key] = {};
|
|
6446
|
+
}
|
|
6447
|
+
this.deepMerge(target[key], source[key]);
|
|
6448
|
+
} else {
|
|
6449
|
+
target[key] = source[key];
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
const configManager = new ConfigManager();
|
|
6455
|
+
function getGlobalStorage() {
|
|
6456
|
+
return configManager.get();
|
|
6457
|
+
}
|
|
6458
|
+
let globalConfig = null;
|
|
6396
6459
|
function initializeCss() {
|
|
6397
6460
|
if (!twString) {
|
|
6461
|
+
// Always get fresh config from global storage
|
|
6462
|
+
const currentConfig = getGlobalStorage();
|
|
6398
6463
|
const configForGeneration = {
|
|
6399
|
-
...
|
|
6464
|
+
...currentConfig,
|
|
6400
6465
|
theme: {
|
|
6401
|
-
...
|
|
6466
|
+
...currentConfig.theme
|
|
6402
6467
|
}
|
|
6403
6468
|
};
|
|
6404
6469
|
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
@@ -6422,37 +6487,39 @@ function convertScreensToBreakpoints(screens) {
|
|
|
6422
6487
|
* @returns {Object} Current global configuration
|
|
6423
6488
|
*/
|
|
6424
6489
|
function setConfig(config) {
|
|
6425
|
-
var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
|
|
6426
6490
|
// Reset CSS object cache when config changes
|
|
6427
6491
|
twString = null;
|
|
6428
6492
|
cssObject = null;
|
|
6429
6493
|
configOptionsCache.clear();
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6494
|
+
|
|
6495
|
+
// Use ConfigManager to set config
|
|
6496
|
+
const globalStorage = configManager.set(config);
|
|
6497
|
+
|
|
6498
|
+
// Handle legacy breakpoints with deprecation warning
|
|
6499
|
+
if (config.breakpoints) {
|
|
6500
|
+
console.warn("Warning: config.breakpoints is deprecated. Use config.theme.screens instead.");
|
|
6501
|
+
|
|
6502
|
+
// Convert legacy breakpoints to screens format
|
|
6503
|
+
const screens = {};
|
|
6504
|
+
for (const [key, value] of Object.entries(config.breakpoints)) {
|
|
6505
|
+
// Extract min-width value from media query
|
|
6506
|
+
const match = value.match(/min-width:\s*([^)]+)/);
|
|
6507
|
+
if (match) {
|
|
6508
|
+
screens[key] = match[1].trim();
|
|
6443
6509
|
}
|
|
6444
6510
|
}
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
globalConfig.theme.screens = {
|
|
6450
|
-
...globalConfig.theme.screens,
|
|
6451
|
-
...config.theme.screens
|
|
6452
|
-
};
|
|
6511
|
+
if (!globalStorage.theme.screens) {
|
|
6512
|
+
globalStorage.theme.screens = {};
|
|
6513
|
+
}
|
|
6514
|
+
Object.assign(globalStorage.theme.screens, screens);
|
|
6453
6515
|
}
|
|
6516
|
+
|
|
6517
|
+
// Update local reference
|
|
6518
|
+
globalConfig = globalStorage;
|
|
6454
6519
|
initializeCss();
|
|
6455
|
-
return
|
|
6520
|
+
return {
|
|
6521
|
+
...globalStorage
|
|
6522
|
+
};
|
|
6456
6523
|
}
|
|
6457
6524
|
|
|
6458
6525
|
/**
|
|
@@ -6460,6 +6527,7 @@ function setConfig(config) {
|
|
|
6460
6527
|
* @returns {Object} Current global configuration
|
|
6461
6528
|
*/
|
|
6462
6529
|
function getConfig() {
|
|
6530
|
+
globalConfig = configManager.get();
|
|
6463
6531
|
return {
|
|
6464
6532
|
...globalConfig
|
|
6465
6533
|
};
|
|
@@ -6473,24 +6541,15 @@ function resetConfig() {
|
|
|
6473
6541
|
twString = null;
|
|
6474
6542
|
cssObject = null;
|
|
6475
6543
|
configOptionsCache.clear();
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
},
|
|
6481
|
-
screens: {
|
|
6482
|
-
sm: "640px",
|
|
6483
|
-
md: "768px",
|
|
6484
|
-
lg: "1024px",
|
|
6485
|
-
xl: "1280px",
|
|
6486
|
-
"2xl": "1536px"
|
|
6487
|
-
}
|
|
6488
|
-
},
|
|
6489
|
-
inject: true
|
|
6490
|
-
};
|
|
6544
|
+
const globalStorage = configManager.reset();
|
|
6545
|
+
|
|
6546
|
+
// Update local reference
|
|
6547
|
+
globalConfig = globalStorage;
|
|
6491
6548
|
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6492
6549
|
cssObject = convertCssToObject(twString);
|
|
6493
|
-
return
|
|
6550
|
+
return {
|
|
6551
|
+
...globalConfig
|
|
6552
|
+
};
|
|
6494
6553
|
}
|
|
6495
6554
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6496
6555
|
const specialVariants = {
|
|
@@ -6541,7 +6600,9 @@ function resolveVariants(selector, variants) {
|
|
|
6541
6600
|
let media = null;
|
|
6542
6601
|
let finalSelector = selector;
|
|
6543
6602
|
for (const v of variants) {
|
|
6544
|
-
|
|
6603
|
+
// Always get fresh config from global storage
|
|
6604
|
+
const currentConfig = getGlobalStorage();
|
|
6605
|
+
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6545
6606
|
if (breakpoints[v]) {
|
|
6546
6607
|
media = breakpoints[v];
|
|
6547
6608
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -7157,7 +7218,7 @@ function twsx(obj) {
|
|
|
7157
7218
|
return "";
|
|
7158
7219
|
}
|
|
7159
7220
|
const mergedOptions = {
|
|
7160
|
-
...
|
|
7221
|
+
...getGlobalStorage(),
|
|
7161
7222
|
...options
|
|
7162
7223
|
};
|
|
7163
7224
|
const {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v2.7.
|
|
2
|
+
* tailwind-to-style v2.7.5
|
|
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
|
-
|
|
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,72 @@ let globalConfig = {
|
|
|
6389
6394
|
},
|
|
6390
6395
|
inject: true
|
|
6391
6396
|
};
|
|
6397
|
+
class ConfigManager {
|
|
6398
|
+
constructor() {
|
|
6399
|
+
this.storage = null;
|
|
6400
|
+
this.initialized = false;
|
|
6401
|
+
}
|
|
6402
|
+
initialize() {
|
|
6403
|
+
if (this.initialized) return this.storage;
|
|
6404
|
+
if (typeof window !== "undefined") {
|
|
6405
|
+
if (!window[CONFIG_STORAGE_KEY]) {
|
|
6406
|
+
window[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6407
|
+
}
|
|
6408
|
+
this.storage = window[CONFIG_STORAGE_KEY];
|
|
6409
|
+
} else if (typeof global !== "undefined") {
|
|
6410
|
+
// Node.js environment
|
|
6411
|
+
if (!global[CONFIG_STORAGE_KEY]) {
|
|
6412
|
+
global[CONFIG_STORAGE_KEY] = JSON.parse(JSON.stringify(defaultConfig));
|
|
6413
|
+
}
|
|
6414
|
+
this.storage = global[CONFIG_STORAGE_KEY];
|
|
6415
|
+
} else {
|
|
6416
|
+
// Fallback
|
|
6417
|
+
console.warn("tailwind-to-style: Unable to create global config storage. Config will only work within the same module.");
|
|
6418
|
+
this.storage = JSON.parse(JSON.stringify(defaultConfig));
|
|
6419
|
+
}
|
|
6420
|
+
this.initialized = true;
|
|
6421
|
+
return this.storage;
|
|
6422
|
+
}
|
|
6423
|
+
get() {
|
|
6424
|
+
return this.initialize();
|
|
6425
|
+
}
|
|
6426
|
+
set(config) {
|
|
6427
|
+
const storage = this.initialize();
|
|
6428
|
+
this.deepMerge(storage, config);
|
|
6429
|
+
return storage;
|
|
6430
|
+
}
|
|
6431
|
+
reset() {
|
|
6432
|
+
const storage = this.initialize();
|
|
6433
|
+
Object.keys(storage).forEach(key => delete storage[key]);
|
|
6434
|
+
Object.assign(storage, JSON.parse(JSON.stringify(defaultConfig)));
|
|
6435
|
+
return storage;
|
|
6436
|
+
}
|
|
6437
|
+
deepMerge(target, source) {
|
|
6438
|
+
for (const key in source) {
|
|
6439
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
6440
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
6441
|
+
target[key] = {};
|
|
6442
|
+
}
|
|
6443
|
+
this.deepMerge(target[key], source[key]);
|
|
6444
|
+
} else {
|
|
6445
|
+
target[key] = source[key];
|
|
6446
|
+
}
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
}
|
|
6450
|
+
const configManager = new ConfigManager();
|
|
6451
|
+
function getGlobalStorage() {
|
|
6452
|
+
return configManager.get();
|
|
6453
|
+
}
|
|
6454
|
+
let globalConfig = null;
|
|
6392
6455
|
function initializeCss() {
|
|
6393
6456
|
if (!twString) {
|
|
6457
|
+
// Always get fresh config from global storage
|
|
6458
|
+
const currentConfig = getGlobalStorage();
|
|
6394
6459
|
const configForGeneration = {
|
|
6395
|
-
...
|
|
6460
|
+
...currentConfig,
|
|
6396
6461
|
theme: {
|
|
6397
|
-
...
|
|
6462
|
+
...currentConfig.theme
|
|
6398
6463
|
}
|
|
6399
6464
|
};
|
|
6400
6465
|
twString = generateTailwindCssString(configForGeneration).replace(/\s\s+/g, " ");
|
|
@@ -6418,37 +6483,39 @@ function convertScreensToBreakpoints(screens) {
|
|
|
6418
6483
|
* @returns {Object} Current global configuration
|
|
6419
6484
|
*/
|
|
6420
6485
|
function setConfig(config) {
|
|
6421
|
-
var _config$theme, _config$theme2, _config$theme2$extend, _config$theme3;
|
|
6422
6486
|
// Reset CSS object cache when config changes
|
|
6423
6487
|
twString = null;
|
|
6424
6488
|
cssObject = null;
|
|
6425
6489
|
configOptionsCache.clear();
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6490
|
+
|
|
6491
|
+
// Use ConfigManager to set config
|
|
6492
|
+
const globalStorage = configManager.set(config);
|
|
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();
|
|
6439
6505
|
}
|
|
6440
6506
|
}
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
globalConfig.theme.screens = {
|
|
6446
|
-
...globalConfig.theme.screens,
|
|
6447
|
-
...config.theme.screens
|
|
6448
|
-
};
|
|
6507
|
+
if (!globalStorage.theme.screens) {
|
|
6508
|
+
globalStorage.theme.screens = {};
|
|
6509
|
+
}
|
|
6510
|
+
Object.assign(globalStorage.theme.screens, screens);
|
|
6449
6511
|
}
|
|
6512
|
+
|
|
6513
|
+
// Update local reference
|
|
6514
|
+
globalConfig = globalStorage;
|
|
6450
6515
|
initializeCss();
|
|
6451
|
-
return
|
|
6516
|
+
return {
|
|
6517
|
+
...globalStorage
|
|
6518
|
+
};
|
|
6452
6519
|
}
|
|
6453
6520
|
|
|
6454
6521
|
/**
|
|
@@ -6456,6 +6523,7 @@ function setConfig(config) {
|
|
|
6456
6523
|
* @returns {Object} Current global configuration
|
|
6457
6524
|
*/
|
|
6458
6525
|
function getConfig() {
|
|
6526
|
+
globalConfig = configManager.get();
|
|
6459
6527
|
return {
|
|
6460
6528
|
...globalConfig
|
|
6461
6529
|
};
|
|
@@ -6469,24 +6537,15 @@ function resetConfig() {
|
|
|
6469
6537
|
twString = null;
|
|
6470
6538
|
cssObject = null;
|
|
6471
6539
|
configOptionsCache.clear();
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
},
|
|
6477
|
-
screens: {
|
|
6478
|
-
sm: "640px",
|
|
6479
|
-
md: "768px",
|
|
6480
|
-
lg: "1024px",
|
|
6481
|
-
xl: "1280px",
|
|
6482
|
-
"2xl": "1536px"
|
|
6483
|
-
}
|
|
6484
|
-
},
|
|
6485
|
-
inject: true
|
|
6486
|
-
};
|
|
6540
|
+
const globalStorage = configManager.reset();
|
|
6541
|
+
|
|
6542
|
+
// Update local reference
|
|
6543
|
+
globalConfig = globalStorage;
|
|
6487
6544
|
twString = generateTailwindCssString(globalConfig).replace(/\s\s+/g, " ");
|
|
6488
6545
|
cssObject = convertCssToObject(twString);
|
|
6489
|
-
return
|
|
6546
|
+
return {
|
|
6547
|
+
...globalConfig
|
|
6548
|
+
};
|
|
6490
6549
|
}
|
|
6491
6550
|
const pseudoVariants = new Set(["hover", "focus", "focus-within", "active", "visited", "disabled", "first", "last", "checked", "invalid", "required"]);
|
|
6492
6551
|
const specialVariants = {
|
|
@@ -6537,7 +6596,9 @@ function resolveVariants(selector, variants) {
|
|
|
6537
6596
|
let media = null;
|
|
6538
6597
|
let finalSelector = selector;
|
|
6539
6598
|
for (const v of variants) {
|
|
6540
|
-
|
|
6599
|
+
// Always get fresh config from global storage
|
|
6600
|
+
const currentConfig = getGlobalStorage();
|
|
6601
|
+
const breakpoints = convertScreensToBreakpoints(currentConfig.theme.screens || {});
|
|
6541
6602
|
if (breakpoints[v]) {
|
|
6542
6603
|
media = breakpoints[v];
|
|
6543
6604
|
} else if (pseudoVariants.has(v)) {
|
|
@@ -7153,7 +7214,7 @@ function twsx(obj) {
|
|
|
7153
7214
|
return "";
|
|
7154
7215
|
}
|
|
7155
7216
|
const mergedOptions = {
|
|
7156
|
-
...
|
|
7217
|
+
...getGlobalStorage(),
|
|
7157
7218
|
...options
|
|
7158
7219
|
};
|
|
7159
7220
|
const {
|