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.mjs
CHANGED
|
@@ -1589,6 +1589,56 @@ var init_streamingNative = __esm({
|
|
|
1589
1589
|
init_nativeBridge();
|
|
1590
1590
|
}
|
|
1591
1591
|
});
|
|
1592
|
+
function loadTailwindEngine() {
|
|
1593
|
+
if (_twEngine) return _twEngine;
|
|
1594
|
+
if (_twEngineError) throw _twEngineError;
|
|
1595
|
+
try {
|
|
1596
|
+
const tw2 = require2("tailwindcss");
|
|
1597
|
+
if (typeof tw2.compile !== "function") {
|
|
1598
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
1599
|
+
}
|
|
1600
|
+
_twEngine = tw2;
|
|
1601
|
+
return _twEngine;
|
|
1602
|
+
} catch (e) {
|
|
1603
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
1604
|
+
throw _twEngineError;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1608
|
+
if (classes.length === 0) return "";
|
|
1609
|
+
const tw2 = loadTailwindEngine();
|
|
1610
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1611
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1612
|
+
const { dirname: dirname2, resolve: resolve2 } = await import('path');
|
|
1613
|
+
const projectRoot = root ?? process.cwd();
|
|
1614
|
+
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
1615
|
+
const loadStylesheet = async (id, base) => {
|
|
1616
|
+
try {
|
|
1617
|
+
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;
|
|
1618
|
+
const pkgPath = req.resolve(cssId);
|
|
1619
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname2(pkgPath) };
|
|
1620
|
+
} catch {
|
|
1621
|
+
try {
|
|
1622
|
+
const absPath = resolve2(base, id);
|
|
1623
|
+
if (existsSync3(absPath)) {
|
|
1624
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname2(absPath) };
|
|
1625
|
+
}
|
|
1626
|
+
} catch {
|
|
1627
|
+
}
|
|
1628
|
+
return { content: "", base };
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
const compiler = await Promise.resolve(tw2.compile(input, { loadStylesheet }));
|
|
1632
|
+
return compiler.build(classes);
|
|
1633
|
+
}
|
|
1634
|
+
var require2, _twEngine, _twEngineError;
|
|
1635
|
+
var init_tailwindEngine = __esm({
|
|
1636
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
1637
|
+
require2 = createRequire(import.meta.url);
|
|
1638
|
+
_twEngine = null;
|
|
1639
|
+
_twEngineError = null;
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1592
1642
|
|
|
1593
1643
|
// packages/domain/compiler/src/compiler/tailwindEngine.ts
|
|
1594
1644
|
var tailwindEngine_exports = {};
|
|
@@ -1722,10 +1772,11 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
1722
1772
|
}
|
|
1723
1773
|
_cacheMisses++;
|
|
1724
1774
|
let rawCss;
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1775
|
+
try {
|
|
1776
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1777
|
+
} catch {
|
|
1778
|
+
rawCss = await generateCssNative(unique, { theme: getThemeConfig() });
|
|
1779
|
+
}
|
|
1729
1780
|
let finalCss = rawCss;
|
|
1730
1781
|
if (minify) {
|
|
1731
1782
|
if (minifier === "fast") {
|
|
@@ -1736,7 +1787,7 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true, min
|
|
|
1736
1787
|
}
|
|
1737
1788
|
if (process.env.DEBUG?.includes("compiler")) {
|
|
1738
1789
|
console.log(
|
|
1739
|
-
`[Compiler] Generated CSS from ${unique.length} classes
|
|
1790
|
+
`[Compiler] Generated CSS from ${unique.length} classes`,
|
|
1740
1791
|
`Size: ${finalCss.length} bytes`
|
|
1741
1792
|
);
|
|
1742
1793
|
}
|
|
@@ -1765,11 +1816,12 @@ function processTailwindCssWithTargets(css, targets) {
|
|
|
1765
1816
|
return result.css;
|
|
1766
1817
|
}
|
|
1767
1818
|
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
1768
|
-
var
|
|
1819
|
+
var init_tailwindEngine2 = __esm({
|
|
1769
1820
|
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
1770
1821
|
init_nativeBridge();
|
|
1771
1822
|
init_cssGeneratorNative();
|
|
1772
1823
|
init_cssCompilationNative();
|
|
1824
|
+
init_tailwindEngine();
|
|
1773
1825
|
createRequire(import.meta.url);
|
|
1774
1826
|
_cssCache = /* @__PURE__ */ new Map();
|
|
1775
1827
|
_cacheHits = 0;
|
|
@@ -2807,7 +2859,7 @@ var init_src = __esm({
|
|
|
2807
2859
|
};
|
|
2808
2860
|
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2809
2861
|
try {
|
|
2810
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (
|
|
2862
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine2(), tailwindEngine_exports));
|
|
2811
2863
|
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2812
2864
|
return result.css;
|
|
2813
2865
|
} catch {
|
|
@@ -3317,7 +3369,7 @@ __export(internal_exports, {
|
|
|
3317
3369
|
var init_internal = __esm({
|
|
3318
3370
|
"packages/domain/compiler/src/internal.ts"() {
|
|
3319
3371
|
init_src();
|
|
3320
|
-
|
|
3372
|
+
init_tailwindEngine2();
|
|
3321
3373
|
init_compiler();
|
|
3322
3374
|
init_parser();
|
|
3323
3375
|
init_analyzer();
|
|
@@ -5151,17 +5203,12 @@ function hashState(tag, state) {
|
|
|
5151
5203
|
_hashStateCache.set(sortedKey, id);
|
|
5152
5204
|
return id;
|
|
5153
5205
|
}
|
|
5154
|
-
|
|
5155
|
-
function twClassesToCss(classes) {
|
|
5156
|
-
const cached = _twClassesToCssCache.get(classes);
|
|
5157
|
-
if (cached !== void 0) return cached;
|
|
5206
|
+
function generateStateRules(id, state) {
|
|
5158
5207
|
const native = getNativeBinding();
|
|
5159
|
-
if (!native?.
|
|
5160
|
-
throw new Error("FATAL: Native binding '
|
|
5208
|
+
if (!native?.generateRuntimeStateCss) {
|
|
5209
|
+
throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
|
|
5161
5210
|
}
|
|
5162
|
-
|
|
5163
|
-
_twClassesToCssCache.set(classes, result);
|
|
5164
|
-
return result;
|
|
5211
|
+
return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
|
|
5165
5212
|
}
|
|
5166
5213
|
var _staticCssDetected = /* @__PURE__ */ new Set();
|
|
5167
5214
|
var _batchedInjectFn = null;
|
|
@@ -5193,10 +5240,7 @@ function injectStateStyles(id, state) {
|
|
|
5193
5240
|
}
|
|
5194
5241
|
}
|
|
5195
5242
|
}
|
|
5196
|
-
const rules =
|
|
5197
|
-
const css = twClassesToCss(classes);
|
|
5198
|
-
return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
|
|
5199
|
-
}).filter(Boolean);
|
|
5243
|
+
const rules = generateStateRules(id, state);
|
|
5200
5244
|
if (rules.length === 0) return;
|
|
5201
5245
|
if (_batchedInjectFn) {
|
|
5202
5246
|
for (const rule of rules) _batchedInjectFn(rule);
|
|
@@ -5226,11 +5270,7 @@ function processState(tag, state, precomputedHash) {
|
|
|
5226
5270
|
}
|
|
5227
5271
|
function generateStateCss(tag, state) {
|
|
5228
5272
|
const id = hashState(tag, state);
|
|
5229
|
-
|
|
5230
|
-
const css = twClassesToCss(classes);
|
|
5231
|
-
return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
|
|
5232
|
-
}).filter(Boolean);
|
|
5233
|
-
return rules.join("\n");
|
|
5273
|
+
return generateStateRules(id, state).join("\n");
|
|
5234
5274
|
}
|
|
5235
5275
|
function getStateRegistry() {
|
|
5236
5276
|
return stateRegistry;
|
|
@@ -5635,7 +5675,13 @@ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
|
|
|
5635
5675
|
}
|
|
5636
5676
|
const binding = getNativeBinding();
|
|
5637
5677
|
if (!binding?.buildVariantLookupKey) {
|
|
5638
|
-
|
|
5678
|
+
const parts = [];
|
|
5679
|
+
for (const k of sortedKeys) {
|
|
5680
|
+
const v = props[k] ?? defaultVariants?.[k];
|
|
5681
|
+
if (v != null) parts.push(`${k}:${String(v)}`);
|
|
5682
|
+
}
|
|
5683
|
+
const key2 = parts.join("|");
|
|
5684
|
+
return table[key2];
|
|
5639
5685
|
}
|
|
5640
5686
|
const relevantDefaults = {};
|
|
5641
5687
|
const relevantProps = {};
|
|
@@ -5678,7 +5724,31 @@ function resolveVariantsNative(config, props) {
|
|
|
5678
5724
|
const { variants = {}, defaultVariants = {} } = config;
|
|
5679
5725
|
const binding = getNativeBinding();
|
|
5680
5726
|
if (!binding?.resolveVariants) {
|
|
5681
|
-
|
|
5727
|
+
const variantKeys2 = Object.keys(variants);
|
|
5728
|
+
const classes = [];
|
|
5729
|
+
for (const key of variantKeys2) {
|
|
5730
|
+
const value = props[key] ?? defaultVariants[key];
|
|
5731
|
+
if (value != null) {
|
|
5732
|
+
const variantClass = variants[key]?.[String(value)];
|
|
5733
|
+
if (variantClass) classes.push(variantClass);
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
if (config.compoundVariants) {
|
|
5737
|
+
for (const compound of config.compoundVariants) {
|
|
5738
|
+
const { class: compoundClass, ...conditions } = compound;
|
|
5739
|
+
const resolved = {};
|
|
5740
|
+
for (const key of variantKeys2) {
|
|
5741
|
+
resolved[key] = String(
|
|
5742
|
+
props[key] ?? defaultVariants[key] ?? ""
|
|
5743
|
+
);
|
|
5744
|
+
}
|
|
5745
|
+
const matches = Object.entries(conditions).every(
|
|
5746
|
+
([k, v]) => resolved[k] === v
|
|
5747
|
+
);
|
|
5748
|
+
if (matches) classes.push(compoundClass);
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
return classes.join(" ");
|
|
5682
5752
|
}
|
|
5683
5753
|
const variantKeys = Object.keys(variants);
|
|
5684
5754
|
const configJson = _getConfigJson(config);
|