tailwind-styled-v4 5.0.34 → 5.0.36
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 +458 -339
- package/dist/cli.js +9 -6
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +9 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.js +60 -8
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +60 -8
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +60 -8
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +60 -8
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +689 -508
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +98 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -28
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +304 -182
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +304 -182
- package/dist/next.mjs.map +1 -1
- package/dist/shared.js +60 -8
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +60 -8
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +4 -4
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +4 -4
- package/dist/svelte.mjs.map +1 -1
- package/dist/turbopackLoader.js +60 -8
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +60 -8
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +9 -6
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +9 -6
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +60 -8
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +60 -8
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +4 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +4 -4
- package/dist/vue.mjs.map +1 -1
- package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -1614,6 +1614,56 @@ var init_streamingNative = __esm({
|
|
|
1614
1614
|
init_nativeBridge();
|
|
1615
1615
|
}
|
|
1616
1616
|
});
|
|
1617
|
+
function loadTailwindEngine() {
|
|
1618
|
+
if (_twEngine) return _twEngine;
|
|
1619
|
+
if (_twEngineError) throw _twEngineError;
|
|
1620
|
+
try {
|
|
1621
|
+
const tw2 = require2("tailwindcss");
|
|
1622
|
+
if (typeof tw2.compile !== "function") {
|
|
1623
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
1624
|
+
}
|
|
1625
|
+
_twEngine = tw2;
|
|
1626
|
+
return _twEngine;
|
|
1627
|
+
} catch (e) {
|
|
1628
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
1629
|
+
throw _twEngineError;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1633
|
+
if (classes.length === 0) return "";
|
|
1634
|
+
const tw2 = loadTailwindEngine();
|
|
1635
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1636
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1637
|
+
const { dirname: dirname2, resolve: resolve2 } = await import('path');
|
|
1638
|
+
const projectRoot = root ?? process.cwd();
|
|
1639
|
+
const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
|
|
1640
|
+
const loadStylesheet = async (id, base) => {
|
|
1641
|
+
try {
|
|
1642
|
+
const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
|
|
1643
|
+
const pkgPath = req.resolve(cssId);
|
|
1644
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname2(pkgPath) };
|
|
1645
|
+
} catch {
|
|
1646
|
+
try {
|
|
1647
|
+
const absPath = resolve2(base, id);
|
|
1648
|
+
if (existsSync3(absPath)) {
|
|
1649
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname2(absPath) };
|
|
1650
|
+
}
|
|
1651
|
+
} catch {
|
|
1652
|
+
}
|
|
1653
|
+
return { content: "", base };
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
const compiler = await Promise.resolve(tw2.compile(input, { loadStylesheet }));
|
|
1657
|
+
return compiler.build(classes);
|
|
1658
|
+
}
|
|
1659
|
+
var require2, _twEngine, _twEngineError;
|
|
1660
|
+
var init_tailwindEngine = __esm({
|
|
1661
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
1662
|
+
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
1663
|
+
_twEngine = null;
|
|
1664
|
+
_twEngineError = null;
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1617
1667
|
|
|
1618
1668
|
// packages/domain/compiler/src/compiler/tailwindEngine.ts
|
|
1619
1669
|
var tailwindEngine_exports = {};
|
|
@@ -1747,10 +1797,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
1747
1797
|
}
|
|
1748
1798
|
_cacheMisses++;
|
|
1749
1799
|
let rawCss;
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1800
|
+
try {
|
|
1801
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1802
|
+
} catch {
|
|
1803
|
+
rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
|
|
1804
|
+
}
|
|
1754
1805
|
let finalCss = rawCss;
|
|
1755
1806
|
if (minify) {
|
|
1756
1807
|
if (minifier === "fast") {
|
|
@@ -1761,7 +1812,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
1761
1812
|
}
|
|
1762
1813
|
if (process.env.DEBUG?.includes("compiler")) {
|
|
1763
1814
|
console.log(
|
|
1764
|
-
`[Compiler] Generated CSS from ${unique.length} classes
|
|
1815
|
+
`[Compiler] Generated CSS from ${unique.length} classes`,
|
|
1765
1816
|
`Size: ${finalCss.length} bytes`
|
|
1766
1817
|
);
|
|
1767
1818
|
}
|
|
@@ -1790,11 +1841,12 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
1790
1841
|
return result.css;
|
|
1791
1842
|
}
|
|
1792
1843
|
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
1793
|
-
var
|
|
1844
|
+
var init_tailwindEngine2 = __esm({
|
|
1794
1845
|
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
1795
1846
|
init_nativeBridge();
|
|
1796
1847
|
init_cssGeneratorNative();
|
|
1797
1848
|
init_cssCompilationNative();
|
|
1849
|
+
init_tailwindEngine();
|
|
1798
1850
|
module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
1799
1851
|
_cssCache = /* @__PURE__ */ new Map();
|
|
1800
1852
|
_cacheHits = 0;
|
|
@@ -2832,7 +2884,7 @@ var init_src = __esm({
|
|
|
2832
2884
|
};
|
|
2833
2885
|
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2834
2886
|
try {
|
|
2835
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (
|
|
2887
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
|
|
2836
2888
|
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2837
2889
|
return result.css;
|
|
2838
2890
|
} catch {
|
|
@@ -3342,7 +3394,7 @@ __export(internal_exports, {
|
|
|
3342
3394
|
var init_internal = __esm({
|
|
3343
3395
|
"packages/domain/compiler/src/internal.ts"() {
|
|
3344
3396
|
init_src();
|
|
3345
|
-
|
|
3397
|
+
init_tailwindEngine2();
|
|
3346
3398
|
init_compiler();
|
|
3347
3399
|
init_parser();
|
|
3348
3400
|
init_analyzer();
|
|
@@ -5176,17 +5228,12 @@ function hashState(tag, state) {
|
|
|
5176
5228
|
_hashStateCache.set(sortedKey, id);
|
|
5177
5229
|
return id;
|
|
5178
5230
|
}
|
|
5179
|
-
|
|
5180
|
-
function twClassesToCss(classes) {
|
|
5181
|
-
const cached = _twClassesToCssCache.get(classes);
|
|
5182
|
-
if (cached !== void 0) return cached;
|
|
5231
|
+
function generateStateRules(id, state) {
|
|
5183
5232
|
const native = getNativeBinding();
|
|
5184
|
-
if (!native?.
|
|
5185
|
-
throw new Error("FATAL: Native binding '
|
|
5233
|
+
if (!native?.generateRuntimeStateCss) {
|
|
5234
|
+
throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
|
|
5186
5235
|
}
|
|
5187
|
-
|
|
5188
|
-
_twClassesToCssCache.set(classes, result);
|
|
5189
|
-
return result;
|
|
5236
|
+
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
5190
5237
|
}
|
|
5191
5238
|
var _staticCssDetected = /* @__PURE__ */ new Set();
|
|
5192
5239
|
var _batchedInjectFn = null;
|
|
@@ -5218,10 +5265,7 @@ function injectStateStyles(id, state) {
|
|
|
5218
5265
|
}
|
|
5219
5266
|
}
|
|
5220
5267
|
}
|
|
5221
|
-
const rules =
|
|
5222
|
-
const css = twClassesToCss(classes);
|
|
5223
|
-
return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
|
|
5224
|
-
}).filter(Boolean);
|
|
5268
|
+
const rules = generateStateRules(id, state);
|
|
5225
5269
|
if (rules.length === 0) return;
|
|
5226
5270
|
if (_batchedInjectFn) {
|
|
5227
5271
|
for (const rule of rules) _batchedInjectFn(rule);
|
|
@@ -5251,11 +5295,7 @@ function processState(tag, state, precomputedHash) {
|
|
|
5251
5295
|
}
|
|
5252
5296
|
function generateStateCss(tag, state) {
|
|
5253
5297
|
const id = hashState(tag, state);
|
|
5254
|
-
|
|
5255
|
-
const css = twClassesToCss(classes);
|
|
5256
|
-
return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
|
|
5257
|
-
}).filter(Boolean);
|
|
5258
|
-
return rules.join("\n");
|
|
5298
|
+
return generateStateRules(id, state).join("\n");
|
|
5259
5299
|
}
|
|
5260
5300
|
function getStateRegistry() {
|
|
5261
5301
|
return stateRegistry;
|
|
@@ -5660,7 +5700,13 @@ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
|
|
|
5660
5700
|
}
|
|
5661
5701
|
const binding = getNativeBinding();
|
|
5662
5702
|
if (!binding?.buildVariantLookupKey) {
|
|
5663
|
-
|
|
5703
|
+
const parts = [];
|
|
5704
|
+
for (const k of sortedKeys) {
|
|
5705
|
+
const v = props[k] ?? defaultVariants?.[k];
|
|
5706
|
+
if (v != null) parts.push(`${k}:${String(v)}`);
|
|
5707
|
+
}
|
|
5708
|
+
const key2 = parts.join("|");
|
|
5709
|
+
return table[key2];
|
|
5664
5710
|
}
|
|
5665
5711
|
const relevantDefaults = {};
|
|
5666
5712
|
const relevantProps = {};
|
|
@@ -5703,7 +5749,31 @@ function resolveVariantsNative(config, props) {
|
|
|
5703
5749
|
const { variants = {}, defaultVariants = {} } = config;
|
|
5704
5750
|
const binding = getNativeBinding();
|
|
5705
5751
|
if (!binding?.resolveVariants) {
|
|
5706
|
-
|
|
5752
|
+
const variantKeys2 = Object.keys(variants);
|
|
5753
|
+
const classes = [];
|
|
5754
|
+
for (const key of variantKeys2) {
|
|
5755
|
+
const value = props[key] ?? defaultVariants[key];
|
|
5756
|
+
if (value != null) {
|
|
5757
|
+
const variantClass = variants[key]?.[String(value)];
|
|
5758
|
+
if (variantClass) classes.push(variantClass);
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
if (config.compoundVariants) {
|
|
5762
|
+
for (const compound of config.compoundVariants) {
|
|
5763
|
+
const { class: compoundClass, ...conditions } = compound;
|
|
5764
|
+
const resolved = {};
|
|
5765
|
+
for (const key of variantKeys2) {
|
|
5766
|
+
resolved[key] = String(
|
|
5767
|
+
props[key] ?? defaultVariants[key] ?? ""
|
|
5768
|
+
);
|
|
5769
|
+
}
|
|
5770
|
+
const matches = Object.entries(conditions).every(
|
|
5771
|
+
([k, v]) => resolved[k] === v
|
|
5772
|
+
);
|
|
5773
|
+
if (matches) classes.push(compoundClass);
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
return classes.join(" ");
|
|
5707
5777
|
}
|
|
5708
5778
|
const variantKeys = Object.keys(variants);
|
|
5709
5779
|
const configJson = _getConfigJson(config);
|