tailwind-styled-v4 5.0.10 → 5.0.11
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 +245 -373
- package/dist/analyzer.js +75 -22
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +74 -21
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.js +4 -2
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +4 -2
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +20 -5
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +20 -5
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +174 -67
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +171 -64
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +7 -1
- package/dist/compiler.d.ts +7 -1
- package/dist/compiler.js +53 -27
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +53 -27
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.js +159 -61
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +159 -61
- package/dist/engine.mjs.map +1 -1
- package/dist/index.browser.mjs +1512 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.d.mts +94 -12
- package/dist/index.d.ts +94 -12
- package/dist/index.js +436 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +436 -106
- package/dist/index.mjs.map +1 -1
- package/dist/next.js +1946 -47
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +1929 -44
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +23 -10
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +23 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs.map +1 -1
- package/dist/scanner.js +72 -19
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +71 -18
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.js +32 -15
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +32 -15
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +38 -12
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -12
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +17 -5
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +17 -5
- package/dist/syntax.mjs.map +1 -1
- package/dist/theme.js +4 -2
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +4 -2
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +87 -33
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +87 -33
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +174 -67
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +171 -64
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +145 -63
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +145 -63
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +38 -12
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -12
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +20 -5
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +20 -5
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +29 -24
package/dist/vite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var module$1 = require('module');
|
|
5
|
-
var
|
|
5
|
+
var fs5 = require('fs');
|
|
6
6
|
var path6 = require('path');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
8
|
var url = require('url');
|
|
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
|
|
|
29
29
|
return Object.freeze(n);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var fs5__namespace = /*#__PURE__*/_interopNamespace(fs5);
|
|
33
33
|
var path6__namespace = /*#__PURE__*/_interopNamespace(path6);
|
|
34
34
|
|
|
35
35
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
@@ -876,7 +876,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
876
876
|
}
|
|
877
877
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
878
878
|
if (envPath) {
|
|
879
|
-
if (
|
|
879
|
+
if (fs5__namespace.existsSync(envPath)) {
|
|
880
880
|
return { path: envPath, source: "env", platform, tried };
|
|
881
881
|
}
|
|
882
882
|
tried.push(`env:${envPath} (not found)`);
|
|
@@ -885,7 +885,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
885
885
|
for (const pkg of prebuiltPkgs) {
|
|
886
886
|
try {
|
|
887
887
|
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
888
|
-
if (
|
|
888
|
+
if (fs5__namespace.existsSync(candidate)) {
|
|
889
889
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
890
890
|
}
|
|
891
891
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -893,9 +893,24 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
893
893
|
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
897
|
+
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
898
|
+
if (runtimeDir) {
|
|
899
|
+
for (const depth of ["..", path6__namespace.join("..", ".."), path6__namespace.join("..", "..", "..")]) {
|
|
900
|
+
const pkgRoot = path6__namespace.resolve(runtimeDir, depth);
|
|
901
|
+
for (const bin of BINARY_NAMES_SELF) {
|
|
902
|
+
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
903
|
+
const candidate = path6__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
904
|
+
tried.push(`self-bundled:${candidate}`);
|
|
905
|
+
if (fs5__namespace.existsSync(candidate)) {
|
|
906
|
+
return { path: candidate, source: "prebuilt", platform, tried };
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
896
912
|
const cwd = process.cwd();
|
|
897
913
|
const base = runtimeDir ?? cwd;
|
|
898
|
-
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
899
914
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
900
915
|
const localCandidates = [];
|
|
901
916
|
for (const bin of BINARY_NAMES) {
|
|
@@ -921,7 +936,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
921
936
|
}
|
|
922
937
|
for (const candidate of localCandidates) {
|
|
923
938
|
tried.push(`local:${candidate}`);
|
|
924
|
-
if (
|
|
939
|
+
if (fs5__namespace.existsSync(candidate)) {
|
|
925
940
|
return { path: candidate, source: "local", platform, tried };
|
|
926
941
|
}
|
|
927
942
|
}
|
|
@@ -947,12 +962,12 @@ var init_native_resolution = __esm({
|
|
|
947
962
|
isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
948
963
|
_require = typeof __require !== "undefined" ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
|
|
949
964
|
PLATFORM_MAP = {
|
|
950
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
951
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
965
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
|
|
966
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
|
|
952
967
|
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
953
968
|
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
954
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
955
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
969
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
|
|
970
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
|
|
956
971
|
};
|
|
957
972
|
}
|
|
958
973
|
});
|
|
@@ -1109,7 +1124,7 @@ function loadNativeBinding(options) {
|
|
|
1109
1124
|
for (const candidate of candidates) {
|
|
1110
1125
|
const candidatePath = path6__namespace.default.resolve(runtimeDir, candidate);
|
|
1111
1126
|
try {
|
|
1112
|
-
if (!
|
|
1127
|
+
if (!fs5__namespace.default.existsSync(candidatePath) && !fs5__namespace.default.existsSync(candidatePath + ".node")) {
|
|
1113
1128
|
continue;
|
|
1114
1129
|
}
|
|
1115
1130
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1141,9 +1156,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1141
1156
|
}
|
|
1142
1157
|
}
|
|
1143
1158
|
if (!includeDefaultCandidates) return candidates;
|
|
1144
|
-
if (
|
|
1159
|
+
if (fs5__namespace.default.existsSync(runtimeDir)) {
|
|
1145
1160
|
try {
|
|
1146
|
-
for (const entry of
|
|
1161
|
+
for (const entry of fs5__namespace.default.readdirSync(runtimeDir)) {
|
|
1147
1162
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1148
1163
|
}
|
|
1149
1164
|
} catch {
|
|
@@ -1154,11 +1169,13 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1154
1169
|
for (const bin of BINARY_NAMES) {
|
|
1155
1170
|
candidates.push(path6__namespace.default.resolve(runtimeDir, `${bin}.node`));
|
|
1156
1171
|
candidates.push(path6__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
1172
|
+
candidates.push(path6__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
1173
|
+
candidates.push(path6__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1174
|
+
candidates.push(path6__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1175
|
+
candidates.push(path6__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1157
1176
|
candidates.push(path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
1158
1177
|
candidates.push(path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1159
1178
|
candidates.push(path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1160
|
-
candidates.push(path6__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1161
|
-
candidates.push(path6__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1162
1179
|
}
|
|
1163
1180
|
return Array.from(new Set(candidates));
|
|
1164
1181
|
}
|
|
@@ -1376,10 +1393,34 @@ function loadTailwindEngine() {
|
|
|
1376
1393
|
throw _twEngineError;
|
|
1377
1394
|
}
|
|
1378
1395
|
}
|
|
1379
|
-
function generateRawCss(classes) {
|
|
1396
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1380
1397
|
if (classes.length === 0) return "";
|
|
1381
1398
|
const tw = loadTailwindEngine();
|
|
1382
|
-
const
|
|
1399
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1400
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1401
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
1402
|
+
const projectRoot = root ?? process.cwd();
|
|
1403
|
+
const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
|
|
1404
|
+
const loadStylesheet = async (id, base) => {
|
|
1405
|
+
try {
|
|
1406
|
+
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;
|
|
1407
|
+
const pkgPath = req.resolve(cssId);
|
|
1408
|
+
return {
|
|
1409
|
+
content: readFileSync(pkgPath, "utf-8"),
|
|
1410
|
+
base: dirname(pkgPath)
|
|
1411
|
+
};
|
|
1412
|
+
} catch {
|
|
1413
|
+
try {
|
|
1414
|
+
const absPath = resolve2(base, id);
|
|
1415
|
+
if (existsSync3(absPath)) {
|
|
1416
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
1417
|
+
}
|
|
1418
|
+
} catch {
|
|
1419
|
+
}
|
|
1420
|
+
return { content: "", base };
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1383
1424
|
return compiler.build(classes);
|
|
1384
1425
|
}
|
|
1385
1426
|
function postProcessWithLightning(rawCss) {
|
|
@@ -1391,14 +1432,14 @@ function postProcessWithLightning(rawCss) {
|
|
|
1391
1432
|
const result = native.processTailwindCssLightning(rawCss);
|
|
1392
1433
|
return result?.css ?? rawCss;
|
|
1393
1434
|
}
|
|
1394
|
-
async function runCssPipeline(classes) {
|
|
1435
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
1395
1436
|
const unique = [...new Set(classes.filter(Boolean))];
|
|
1396
1437
|
if (unique.length === 0) {
|
|
1397
1438
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1398
1439
|
}
|
|
1399
|
-
const rawCss = generateRawCss(unique);
|
|
1440
|
+
const rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1400
1441
|
const native = getNativeBridge();
|
|
1401
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
1442
|
+
const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
|
|
1402
1443
|
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
1403
1444
|
return {
|
|
1404
1445
|
css: finalCss,
|
|
@@ -1407,21 +1448,8 @@ async function runCssPipeline(classes) {
|
|
|
1407
1448
|
optimized: hasLightning
|
|
1408
1449
|
};
|
|
1409
1450
|
}
|
|
1410
|
-
function runCssPipelineSync(
|
|
1411
|
-
|
|
1412
|
-
if (unique.length === 0) {
|
|
1413
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1414
|
-
}
|
|
1415
|
-
const rawCss = generateRawCss(unique);
|
|
1416
|
-
const native = getNativeBridge();
|
|
1417
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
1418
|
-
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
1419
|
-
return {
|
|
1420
|
-
css: finalCss,
|
|
1421
|
-
classes: unique,
|
|
1422
|
-
sizeBytes: finalCss.length,
|
|
1423
|
-
optimized: hasLightning
|
|
1424
|
-
};
|
|
1451
|
+
function runCssPipelineSync(_classes) {
|
|
1452
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1425
1453
|
}
|
|
1426
1454
|
function processTailwindCssWithTargets(css, targets) {
|
|
1427
1455
|
const native = getNativeBridge();
|
|
@@ -1453,8 +1481,10 @@ __export(native_bridge_exports, {
|
|
|
1453
1481
|
extractClassesNative: () => extractClassesNative,
|
|
1454
1482
|
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
1455
1483
|
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
1484
|
+
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
1456
1485
|
hashContentNative: () => hashContentNative,
|
|
1457
1486
|
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
1487
|
+
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
1458
1488
|
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
1459
1489
|
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
1460
1490
|
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
@@ -1464,7 +1494,9 @@ __export(native_bridge_exports, {
|
|
|
1464
1494
|
scanCacheStats: () => scanCacheStats,
|
|
1465
1495
|
scanFileNative: () => scanFileNative,
|
|
1466
1496
|
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
1467
|
-
scanWorkspaceNative: () => scanWorkspaceNative
|
|
1497
|
+
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
1498
|
+
startWatchNative: () => startWatchNative,
|
|
1499
|
+
stopWatchNative: () => stopWatchNative
|
|
1468
1500
|
});
|
|
1469
1501
|
function getDirname2() {
|
|
1470
1502
|
if (typeof __dirname !== "undefined") {
|
|
@@ -1641,6 +1673,41 @@ function computeCacheStatsNative(filesClasses, sizes, top) {
|
|
|
1641
1673
|
if (!binding.computeCacheStats) return null;
|
|
1642
1674
|
return binding.computeCacheStats(filesClasses, sizes, top ?? null);
|
|
1643
1675
|
}
|
|
1676
|
+
function startWatchNative(rootDir) {
|
|
1677
|
+
try {
|
|
1678
|
+
const binding = scannerGetBinding();
|
|
1679
|
+
if (!binding.startWatch) return null;
|
|
1680
|
+
return binding.startWatch(rootDir);
|
|
1681
|
+
} catch {
|
|
1682
|
+
return null;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
function pollWatchEventsNative(handleId) {
|
|
1686
|
+
try {
|
|
1687
|
+
const binding = scannerGetBinding();
|
|
1688
|
+
if (!binding.pollWatchEvents) return [];
|
|
1689
|
+
return binding.pollWatchEvents(handleId);
|
|
1690
|
+
} catch {
|
|
1691
|
+
return [];
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
function stopWatchNative(handleId) {
|
|
1695
|
+
try {
|
|
1696
|
+
const binding = scannerGetBinding();
|
|
1697
|
+
if (!binding.stopWatch) return false;
|
|
1698
|
+
return binding.stopWatch(handleId);
|
|
1699
|
+
} catch {
|
|
1700
|
+
return false;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
function hasNativeWatchBinding() {
|
|
1704
|
+
try {
|
|
1705
|
+
const binding = scannerGetBinding();
|
|
1706
|
+
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
1707
|
+
} catch {
|
|
1708
|
+
return false;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1644
1711
|
var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
1645
1712
|
var init_native_bridge = __esm({
|
|
1646
1713
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
@@ -1730,6 +1797,7 @@ function defaultCachePath(rootDir, cacheDir) {
|
|
|
1730
1797
|
}
|
|
1731
1798
|
function readCache(rootDir, cacheDir) {
|
|
1732
1799
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1800
|
+
fs5__namespace.default.mkdirSync(path6__namespace.default.dirname(cachePath), { recursive: true });
|
|
1733
1801
|
const result = cacheReadNative(cachePath);
|
|
1734
1802
|
if (!result) return [];
|
|
1735
1803
|
return result.entries.map((e) => ({
|
|
@@ -1744,6 +1812,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1744
1812
|
}
|
|
1745
1813
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1746
1814
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1815
|
+
fs5__namespace.default.mkdirSync(path6__namespace.default.dirname(cachePath), { recursive: true });
|
|
1747
1816
|
const success = cacheWriteNative(cachePath, entries);
|
|
1748
1817
|
if (!success) {
|
|
1749
1818
|
throw new Error(
|
|
@@ -1774,7 +1843,7 @@ function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
|
1774
1843
|
function walk(dir) {
|
|
1775
1844
|
let entries;
|
|
1776
1845
|
try {
|
|
1777
|
-
entries =
|
|
1846
|
+
entries = fs5__namespace.default.readdirSync(dir, { withFileTypes: true });
|
|
1778
1847
|
} catch {
|
|
1779
1848
|
return;
|
|
1780
1849
|
}
|
|
@@ -1974,7 +2043,7 @@ function resolveScannerWorkerModulePath() {
|
|
|
1974
2043
|
path6__namespace.default.resolve(runtimeDir, "worker.ts")
|
|
1975
2044
|
];
|
|
1976
2045
|
for (const candidate of candidates) {
|
|
1977
|
-
if (
|
|
2046
|
+
if (fs5__namespace.default.existsSync(candidate)) return candidate;
|
|
1978
2047
|
}
|
|
1979
2048
|
return null;
|
|
1980
2049
|
}
|
|
@@ -2031,7 +2100,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
2031
2100
|
if (!currentDir) continue;
|
|
2032
2101
|
const entries = (() => {
|
|
2033
2102
|
try {
|
|
2034
|
-
return
|
|
2103
|
+
return fs5__namespace.default.readdirSync(currentDir, { withFileTypes: true });
|
|
2035
2104
|
} catch {
|
|
2036
2105
|
return [];
|
|
2037
2106
|
}
|
|
@@ -2130,7 +2199,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2130
2199
|
for (const filePath of candidates) {
|
|
2131
2200
|
const stat = (() => {
|
|
2132
2201
|
try {
|
|
2133
|
-
return
|
|
2202
|
+
return fs5__namespace.default.statSync(filePath);
|
|
2134
2203
|
} catch {
|
|
2135
2204
|
return null;
|
|
2136
2205
|
}
|
|
@@ -2156,7 +2225,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2156
2225
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
2157
2226
|
const content = (() => {
|
|
2158
2227
|
try {
|
|
2159
|
-
return
|
|
2228
|
+
return fs5__namespace.default.readFileSync(filePath, "utf8");
|
|
2160
2229
|
} catch {
|
|
2161
2230
|
return null;
|
|
2162
2231
|
}
|
|
@@ -2261,21 +2330,31 @@ var init_src2 = __esm({
|
|
|
2261
2330
|
if (_state.binding !== void 0) return _state.binding;
|
|
2262
2331
|
const runtimeDir = getRuntimeDir();
|
|
2263
2332
|
const req = module$1.createRequire(path6__namespace.default.join(runtimeDir, "noop.cjs"));
|
|
2333
|
+
const _platform = process.platform;
|
|
2334
|
+
const _arch = process.arch;
|
|
2335
|
+
const _platformArch = `${_platform}-${_arch}`;
|
|
2336
|
+
const _platformArchGnu = _platformArch === "linux-x64" ? "linux-x64-gnu" : _platformArch === "linux-arm64" ? "linux-arm64-gnu" : _platformArch;
|
|
2264
2337
|
const candidates = [
|
|
2265
2338
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2266
2339
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2267
2340
|
path6__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
2268
|
-
path6__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2269
|
-
path6__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2270
|
-
// runtimeDir = dist/ → naik
|
|
2341
|
+
path6__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2342
|
+
path6__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2343
|
+
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2344
|
+
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2345
|
+
path6__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
2346
|
+
path6__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2347
|
+
path6__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2348
|
+
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2271
2349
|
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2272
|
-
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2350
|
+
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2273
2351
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2274
2352
|
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2275
|
-
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2353
|
+
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2276
2354
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2277
2355
|
path6__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
2278
2356
|
path6__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
2357
|
+
path6__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
2279
2358
|
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2280
2359
|
path6__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2281
2360
|
path6__namespace.default.resolve(
|
|
@@ -2290,7 +2369,7 @@ var init_src2 = __esm({
|
|
|
2290
2369
|
)
|
|
2291
2370
|
];
|
|
2292
2371
|
for (const fullPath of candidates) {
|
|
2293
|
-
if (!
|
|
2372
|
+
if (!fs5__namespace.default.existsSync(fullPath)) continue;
|
|
2294
2373
|
try {
|
|
2295
2374
|
const required = req(fullPath);
|
|
2296
2375
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2428,9 +2507,9 @@ var transformSource = (source, opts) => {
|
|
|
2428
2507
|
}
|
|
2429
2508
|
return result;
|
|
2430
2509
|
};
|
|
2431
|
-
var generateCssForClasses = async (classes, _tailwindConfig,
|
|
2510
|
+
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2432
2511
|
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2433
|
-
const result = await runCssPipeline2(classes);
|
|
2512
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2434
2513
|
return result.css;
|
|
2435
2514
|
};
|
|
2436
2515
|
var mergeClassesStatic = (classes) => {
|
|
@@ -2476,7 +2555,7 @@ function isRecord(value) {
|
|
|
2476
2555
|
}
|
|
2477
2556
|
async function pathExists(filePath) {
|
|
2478
2557
|
try {
|
|
2479
|
-
await
|
|
2558
|
+
await fs5__namespace.default.promises.access(filePath, fs5__namespace.default.constants.F_OK);
|
|
2480
2559
|
return true;
|
|
2481
2560
|
} catch {
|
|
2482
2561
|
return false;
|
|
@@ -2761,7 +2840,7 @@ var collectCustomUtilities = (config) => {
|
|
|
2761
2840
|
return out;
|
|
2762
2841
|
};
|
|
2763
2842
|
var collectSafelistFromSource = async (configPath) => {
|
|
2764
|
-
const source = await
|
|
2843
|
+
const source = await fs5__namespace.default.promises.readFile(configPath, "utf8");
|
|
2765
2844
|
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
2766
2845
|
const allTokens = extractClassesNative2(source);
|
|
2767
2846
|
const hasSafelist = source.includes("safelist");
|
|
@@ -2788,7 +2867,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2788
2867
|
customUtilities: /* @__PURE__ */ new Set()
|
|
2789
2868
|
};
|
|
2790
2869
|
}
|
|
2791
|
-
const configStat = await
|
|
2870
|
+
const configStat = await fs5__namespace.default.promises.stat(configPath).catch(() => null);
|
|
2792
2871
|
if (configStat) {
|
|
2793
2872
|
const cached = tailwindConfigCache.get(configPath);
|
|
2794
2873
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -3106,7 +3185,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3106
3185
|
}
|
|
3107
3186
|
log5.debug(`native change ${normalizedPath}`);
|
|
3108
3187
|
const scanned = scanFile(normalizedPath);
|
|
3109
|
-
const content =
|
|
3188
|
+
const content = fs5__namespace.default.readFileSync(normalizedPath, "utf8");
|
|
3110
3189
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3111
3190
|
const existing = byFile.get(normalizedPath);
|
|
3112
3191
|
if (diff && existing) {
|
|
@@ -3176,7 +3255,7 @@ var CACHE_DIR = ".tw-cache";
|
|
|
3176
3255
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
3177
3256
|
try {
|
|
3178
3257
|
const cacheDir = path6__namespace.default.join(cwd, CACHE_DIR);
|
|
3179
|
-
|
|
3258
|
+
fs5__namespace.default.mkdirSync(cacheDir, { recursive: true });
|
|
3180
3259
|
const mem = process.memoryUsage();
|
|
3181
3260
|
const data = {
|
|
3182
3261
|
...metrics,
|
|
@@ -3187,7 +3266,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
3187
3266
|
},
|
|
3188
3267
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3189
3268
|
};
|
|
3190
|
-
|
|
3269
|
+
fs5__namespace.default.writeFileSync(path6__namespace.default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
3191
3270
|
} catch {
|
|
3192
3271
|
}
|
|
3193
3272
|
}
|
|
@@ -3387,7 +3466,7 @@ var log6 = createLogger("engine");
|
|
|
3387
3466
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
3388
3467
|
if (!tailwindConfigPath) return void 0;
|
|
3389
3468
|
const configPath = path6__namespace.default.resolve(root, tailwindConfigPath);
|
|
3390
|
-
if (!
|
|
3469
|
+
if (!fs5__namespace.default.existsSync(configPath)) {
|
|
3391
3470
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
3392
3471
|
}
|
|
3393
3472
|
const imported = await import(url.pathToFileURL(configPath).href);
|
|
@@ -3430,7 +3509,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3430
3509
|
const transformedClasses = await runTransformClasses(plugins, scan.uniqueClasses, context);
|
|
3431
3510
|
const mergedClassList = mergeClassesStatic(transformedClasses.join(" "));
|
|
3432
3511
|
const css = options.compileCss !== false && mergedClassList.length > 0 ? await generateCssForClasses(
|
|
3433
|
-
mergedClassList.split(/\s+/).filter(Boolean)
|
|
3512
|
+
mergedClassList.split(/\s+/).filter(Boolean),
|
|
3513
|
+
tailwindConfig,
|
|
3514
|
+
root
|
|
3515
|
+
) : "";
|
|
3434
3516
|
const compileMs = Date.now() - compileStartedAt;
|
|
3435
3517
|
const analyzeStartedAt = Date.now();
|
|
3436
3518
|
const analysis = options.analyze ? await tryRunAnalyzer(root, options) : void 0;
|
|
@@ -3451,10 +3533,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3451
3533
|
}
|
|
3452
3534
|
function countWorkspacePackages(root) {
|
|
3453
3535
|
const packagesDir = path6__namespace.default.join(root, "packages");
|
|
3454
|
-
if (!
|
|
3536
|
+
if (!fs5__namespace.default.existsSync(packagesDir)) return 0;
|
|
3455
3537
|
try {
|
|
3456
|
-
return
|
|
3457
|
-
(entry) => entry.isDirectory() &&
|
|
3538
|
+
return fs5__namespace.default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
3539
|
+
(entry) => entry.isDirectory() && fs5__namespace.default.existsSync(path6__namespace.default.join(packagesDir, entry.name, "package.json"))
|
|
3458
3540
|
).length;
|
|
3459
3541
|
} catch {
|
|
3460
3542
|
return 0;
|
|
@@ -3637,7 +3719,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
3637
3719
|
const shouldForceFullRescan = (event) => {
|
|
3638
3720
|
if (event.type === "unlink") return false;
|
|
3639
3721
|
try {
|
|
3640
|
-
const stat =
|
|
3722
|
+
const stat = fs5__namespace.default.statSync(event.filePath);
|
|
3641
3723
|
if (stat.size > largeFileThreshold) {
|
|
3642
3724
|
metrics.markSkippedLargeFile();
|
|
3643
3725
|
return true;
|
|
@@ -3821,8 +3903,8 @@ function filterScanToDirs(scan, root, scanDirs) {
|
|
|
3821
3903
|
}
|
|
3822
3904
|
function writeJsonArtifact(root, relativePath, value) {
|
|
3823
3905
|
const outputPath = path6__namespace.default.resolve(root, relativePath);
|
|
3824
|
-
|
|
3825
|
-
|
|
3906
|
+
fs5__namespace.default.mkdirSync(path6__namespace.default.dirname(outputPath), { recursive: true });
|
|
3907
|
+
fs5__namespace.default.writeFileSync(outputPath, `${JSON.stringify(value, null, 2)}
|
|
3826
3908
|
`);
|
|
3827
3909
|
}
|
|
3828
3910
|
function tailwindStyledPlugin(opts = {}) {
|