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.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
3
|
+
import * as fs5 from 'fs';
|
|
4
|
+
import fs5__default from 'fs';
|
|
5
5
|
import * as path6 from 'path';
|
|
6
6
|
import path6__default from 'path';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
@@ -854,7 +854,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
854
854
|
}
|
|
855
855
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
856
856
|
if (envPath) {
|
|
857
|
-
if (
|
|
857
|
+
if (fs5.existsSync(envPath)) {
|
|
858
858
|
return { path: envPath, source: "env", platform, tried };
|
|
859
859
|
}
|
|
860
860
|
tried.push(`env:${envPath} (not found)`);
|
|
@@ -863,7 +863,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
863
863
|
for (const pkg of prebuiltPkgs) {
|
|
864
864
|
try {
|
|
865
865
|
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
866
|
-
if (
|
|
866
|
+
if (fs5.existsSync(candidate)) {
|
|
867
867
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
868
868
|
}
|
|
869
869
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -871,9 +871,24 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
871
871
|
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
875
|
+
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
876
|
+
if (runtimeDir) {
|
|
877
|
+
for (const depth of ["..", path6.join("..", ".."), path6.join("..", "..", "..")]) {
|
|
878
|
+
const pkgRoot = path6.resolve(runtimeDir, depth);
|
|
879
|
+
for (const bin of BINARY_NAMES_SELF) {
|
|
880
|
+
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
881
|
+
const candidate = path6.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
882
|
+
tried.push(`self-bundled:${candidate}`);
|
|
883
|
+
if (fs5.existsSync(candidate)) {
|
|
884
|
+
return { path: candidate, source: "prebuilt", platform, tried };
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
874
890
|
const cwd = process.cwd();
|
|
875
891
|
const base = runtimeDir ?? cwd;
|
|
876
|
-
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
877
892
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
878
893
|
const localCandidates = [];
|
|
879
894
|
for (const bin of BINARY_NAMES) {
|
|
@@ -899,7 +914,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
899
914
|
}
|
|
900
915
|
for (const candidate of localCandidates) {
|
|
901
916
|
tried.push(`local:${candidate}`);
|
|
902
|
-
if (
|
|
917
|
+
if (fs5.existsSync(candidate)) {
|
|
903
918
|
return { path: candidate, source: "local", platform, tried };
|
|
904
919
|
}
|
|
905
920
|
}
|
|
@@ -925,12 +940,12 @@ var init_native_resolution = __esm({
|
|
|
925
940
|
isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
926
941
|
_require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
927
942
|
PLATFORM_MAP = {
|
|
928
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
929
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
943
|
+
"linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
|
|
944
|
+
"linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
|
|
930
945
|
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
931
946
|
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
932
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64"],
|
|
933
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64"]
|
|
947
|
+
"win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
|
|
948
|
+
"win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
|
|
934
949
|
};
|
|
935
950
|
}
|
|
936
951
|
});
|
|
@@ -1087,7 +1102,7 @@ function loadNativeBinding(options) {
|
|
|
1087
1102
|
for (const candidate of candidates) {
|
|
1088
1103
|
const candidatePath = path6__default.resolve(runtimeDir, candidate);
|
|
1089
1104
|
try {
|
|
1090
|
-
if (!
|
|
1105
|
+
if (!fs5__default.existsSync(candidatePath) && !fs5__default.existsSync(candidatePath + ".node")) {
|
|
1091
1106
|
continue;
|
|
1092
1107
|
}
|
|
1093
1108
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1119,9 +1134,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1119
1134
|
}
|
|
1120
1135
|
}
|
|
1121
1136
|
if (!includeDefaultCandidates) return candidates;
|
|
1122
|
-
if (
|
|
1137
|
+
if (fs5__default.existsSync(runtimeDir)) {
|
|
1123
1138
|
try {
|
|
1124
|
-
for (const entry of
|
|
1139
|
+
for (const entry of fs5__default.readdirSync(runtimeDir)) {
|
|
1125
1140
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1126
1141
|
}
|
|
1127
1142
|
} catch {
|
|
@@ -1132,11 +1147,13 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1132
1147
|
for (const bin of BINARY_NAMES) {
|
|
1133
1148
|
candidates.push(path6__default.resolve(runtimeDir, `${bin}.node`));
|
|
1134
1149
|
candidates.push(path6__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
1150
|
+
candidates.push(path6__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
1151
|
+
candidates.push(path6__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1152
|
+
candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1153
|
+
candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1135
1154
|
candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
1136
1155
|
candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1137
1156
|
candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1138
|
-
candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1139
|
-
candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1140
1157
|
}
|
|
1141
1158
|
return Array.from(new Set(candidates));
|
|
1142
1159
|
}
|
|
@@ -1354,10 +1371,34 @@ function loadTailwindEngine() {
|
|
|
1354
1371
|
throw _twEngineError;
|
|
1355
1372
|
}
|
|
1356
1373
|
}
|
|
1357
|
-
function generateRawCss(classes) {
|
|
1374
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1358
1375
|
if (classes.length === 0) return "";
|
|
1359
1376
|
const tw = loadTailwindEngine();
|
|
1360
|
-
const
|
|
1377
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1378
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1379
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
1380
|
+
const projectRoot = root ?? process.cwd();
|
|
1381
|
+
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
1382
|
+
const loadStylesheet = async (id, base) => {
|
|
1383
|
+
try {
|
|
1384
|
+
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;
|
|
1385
|
+
const pkgPath = req.resolve(cssId);
|
|
1386
|
+
return {
|
|
1387
|
+
content: readFileSync(pkgPath, "utf-8"),
|
|
1388
|
+
base: dirname(pkgPath)
|
|
1389
|
+
};
|
|
1390
|
+
} catch {
|
|
1391
|
+
try {
|
|
1392
|
+
const absPath = resolve2(base, id);
|
|
1393
|
+
if (existsSync3(absPath)) {
|
|
1394
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
1395
|
+
}
|
|
1396
|
+
} catch {
|
|
1397
|
+
}
|
|
1398
|
+
return { content: "", base };
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1361
1402
|
return compiler.build(classes);
|
|
1362
1403
|
}
|
|
1363
1404
|
function postProcessWithLightning(rawCss) {
|
|
@@ -1369,14 +1410,14 @@ function postProcessWithLightning(rawCss) {
|
|
|
1369
1410
|
const result = native.processTailwindCssLightning(rawCss);
|
|
1370
1411
|
return result?.css ?? rawCss;
|
|
1371
1412
|
}
|
|
1372
|
-
async function runCssPipeline(classes) {
|
|
1413
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
1373
1414
|
const unique = [...new Set(classes.filter(Boolean))];
|
|
1374
1415
|
if (unique.length === 0) {
|
|
1375
1416
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1376
1417
|
}
|
|
1377
|
-
const rawCss = generateRawCss(unique);
|
|
1418
|
+
const rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1378
1419
|
const native = getNativeBridge();
|
|
1379
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
1420
|
+
const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
|
|
1380
1421
|
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
1381
1422
|
return {
|
|
1382
1423
|
css: finalCss,
|
|
@@ -1385,21 +1426,8 @@ async function runCssPipeline(classes) {
|
|
|
1385
1426
|
optimized: hasLightning
|
|
1386
1427
|
};
|
|
1387
1428
|
}
|
|
1388
|
-
function runCssPipelineSync(
|
|
1389
|
-
|
|
1390
|
-
if (unique.length === 0) {
|
|
1391
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1392
|
-
}
|
|
1393
|
-
const rawCss = generateRawCss(unique);
|
|
1394
|
-
const native = getNativeBridge();
|
|
1395
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
1396
|
-
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
1397
|
-
return {
|
|
1398
|
-
css: finalCss,
|
|
1399
|
-
classes: unique,
|
|
1400
|
-
sizeBytes: finalCss.length,
|
|
1401
|
-
optimized: hasLightning
|
|
1402
|
-
};
|
|
1429
|
+
function runCssPipelineSync(_classes) {
|
|
1430
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1403
1431
|
}
|
|
1404
1432
|
function processTailwindCssWithTargets(css, targets) {
|
|
1405
1433
|
const native = getNativeBridge();
|
|
@@ -1431,8 +1459,10 @@ __export(native_bridge_exports, {
|
|
|
1431
1459
|
extractClassesNative: () => extractClassesNative,
|
|
1432
1460
|
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
1433
1461
|
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
1462
|
+
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
1434
1463
|
hashContentNative: () => hashContentNative,
|
|
1435
1464
|
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
1465
|
+
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
1436
1466
|
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
1437
1467
|
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
1438
1468
|
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
@@ -1442,7 +1472,9 @@ __export(native_bridge_exports, {
|
|
|
1442
1472
|
scanCacheStats: () => scanCacheStats,
|
|
1443
1473
|
scanFileNative: () => scanFileNative,
|
|
1444
1474
|
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
1445
|
-
scanWorkspaceNative: () => scanWorkspaceNative
|
|
1475
|
+
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
1476
|
+
startWatchNative: () => startWatchNative,
|
|
1477
|
+
stopWatchNative: () => stopWatchNative
|
|
1446
1478
|
});
|
|
1447
1479
|
function getDirname2() {
|
|
1448
1480
|
if (typeof __dirname !== "undefined") {
|
|
@@ -1619,6 +1651,41 @@ function computeCacheStatsNative(filesClasses, sizes, top) {
|
|
|
1619
1651
|
if (!binding.computeCacheStats) return null;
|
|
1620
1652
|
return binding.computeCacheStats(filesClasses, sizes, top ?? null);
|
|
1621
1653
|
}
|
|
1654
|
+
function startWatchNative(rootDir) {
|
|
1655
|
+
try {
|
|
1656
|
+
const binding = scannerGetBinding();
|
|
1657
|
+
if (!binding.startWatch) return null;
|
|
1658
|
+
return binding.startWatch(rootDir);
|
|
1659
|
+
} catch {
|
|
1660
|
+
return null;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function pollWatchEventsNative(handleId) {
|
|
1664
|
+
try {
|
|
1665
|
+
const binding = scannerGetBinding();
|
|
1666
|
+
if (!binding.pollWatchEvents) return [];
|
|
1667
|
+
return binding.pollWatchEvents(handleId);
|
|
1668
|
+
} catch {
|
|
1669
|
+
return [];
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
function stopWatchNative(handleId) {
|
|
1673
|
+
try {
|
|
1674
|
+
const binding = scannerGetBinding();
|
|
1675
|
+
if (!binding.stopWatch) return false;
|
|
1676
|
+
return binding.stopWatch(handleId);
|
|
1677
|
+
} catch {
|
|
1678
|
+
return false;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function hasNativeWatchBinding() {
|
|
1682
|
+
try {
|
|
1683
|
+
const binding = scannerGetBinding();
|
|
1684
|
+
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
1685
|
+
} catch {
|
|
1686
|
+
return false;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1622
1689
|
var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
1623
1690
|
var init_native_bridge = __esm({
|
|
1624
1691
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
@@ -1708,6 +1775,7 @@ function defaultCachePath(rootDir, cacheDir) {
|
|
|
1708
1775
|
}
|
|
1709
1776
|
function readCache(rootDir, cacheDir) {
|
|
1710
1777
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1778
|
+
fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
|
|
1711
1779
|
const result = cacheReadNative(cachePath);
|
|
1712
1780
|
if (!result) return [];
|
|
1713
1781
|
return result.entries.map((e) => ({
|
|
@@ -1722,6 +1790,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1722
1790
|
}
|
|
1723
1791
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1724
1792
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1793
|
+
fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
|
|
1725
1794
|
const success = cacheWriteNative(cachePath, entries);
|
|
1726
1795
|
if (!success) {
|
|
1727
1796
|
throw new Error(
|
|
@@ -1752,7 +1821,7 @@ function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
|
1752
1821
|
function walk(dir) {
|
|
1753
1822
|
let entries;
|
|
1754
1823
|
try {
|
|
1755
|
-
entries =
|
|
1824
|
+
entries = fs5__default.readdirSync(dir, { withFileTypes: true });
|
|
1756
1825
|
} catch {
|
|
1757
1826
|
return;
|
|
1758
1827
|
}
|
|
@@ -1952,7 +2021,7 @@ function resolveScannerWorkerModulePath() {
|
|
|
1952
2021
|
path6__default.resolve(runtimeDir, "worker.ts")
|
|
1953
2022
|
];
|
|
1954
2023
|
for (const candidate of candidates) {
|
|
1955
|
-
if (
|
|
2024
|
+
if (fs5__default.existsSync(candidate)) return candidate;
|
|
1956
2025
|
}
|
|
1957
2026
|
return null;
|
|
1958
2027
|
}
|
|
@@ -2009,7 +2078,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
2009
2078
|
if (!currentDir) continue;
|
|
2010
2079
|
const entries = (() => {
|
|
2011
2080
|
try {
|
|
2012
|
-
return
|
|
2081
|
+
return fs5__default.readdirSync(currentDir, { withFileTypes: true });
|
|
2013
2082
|
} catch {
|
|
2014
2083
|
return [];
|
|
2015
2084
|
}
|
|
@@ -2108,7 +2177,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2108
2177
|
for (const filePath of candidates) {
|
|
2109
2178
|
const stat = (() => {
|
|
2110
2179
|
try {
|
|
2111
|
-
return
|
|
2180
|
+
return fs5__default.statSync(filePath);
|
|
2112
2181
|
} catch {
|
|
2113
2182
|
return null;
|
|
2114
2183
|
}
|
|
@@ -2134,7 +2203,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2134
2203
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
2135
2204
|
const content = (() => {
|
|
2136
2205
|
try {
|
|
2137
|
-
return
|
|
2206
|
+
return fs5__default.readFileSync(filePath, "utf8");
|
|
2138
2207
|
} catch {
|
|
2139
2208
|
return null;
|
|
2140
2209
|
}
|
|
@@ -2239,21 +2308,31 @@ var init_src2 = __esm({
|
|
|
2239
2308
|
if (_state.binding !== void 0) return _state.binding;
|
|
2240
2309
|
const runtimeDir = getRuntimeDir();
|
|
2241
2310
|
const req = createRequire(path6__default.join(runtimeDir, "noop.cjs"));
|
|
2311
|
+
const _platform = process.platform;
|
|
2312
|
+
const _arch = process.arch;
|
|
2313
|
+
const _platformArch = `${_platform}-${_arch}`;
|
|
2314
|
+
const _platformArchGnu = _platformArch === "linux-x64" ? "linux-x64-gnu" : _platformArch === "linux-arm64" ? "linux-arm64-gnu" : _platformArch;
|
|
2242
2315
|
const candidates = [
|
|
2243
2316
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2244
2317
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2245
2318
|
path6__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
2246
|
-
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2247
|
-
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2248
|
-
// runtimeDir = dist/ → naik
|
|
2319
|
+
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2320
|
+
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2321
|
+
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2322
|
+
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2323
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
2324
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2325
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2326
|
+
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2249
2327
|
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2250
|
-
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2328
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2251
2329
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2252
2330
|
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2253
|
-
path6__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2331
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2254
2332
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2255
2333
|
path6__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
2256
2334
|
path6__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
2335
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
2257
2336
|
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2258
2337
|
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2259
2338
|
path6__default.resolve(
|
|
@@ -2268,7 +2347,7 @@ var init_src2 = __esm({
|
|
|
2268
2347
|
)
|
|
2269
2348
|
];
|
|
2270
2349
|
for (const fullPath of candidates) {
|
|
2271
|
-
if (!
|
|
2350
|
+
if (!fs5__default.existsSync(fullPath)) continue;
|
|
2272
2351
|
try {
|
|
2273
2352
|
const required = req(fullPath);
|
|
2274
2353
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2406,9 +2485,9 @@ var transformSource = (source, opts) => {
|
|
|
2406
2485
|
}
|
|
2407
2486
|
return result;
|
|
2408
2487
|
};
|
|
2409
|
-
var generateCssForClasses = async (classes, _tailwindConfig,
|
|
2488
|
+
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2410
2489
|
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2411
|
-
const result = await runCssPipeline2(classes);
|
|
2490
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2412
2491
|
return result.css;
|
|
2413
2492
|
};
|
|
2414
2493
|
var mergeClassesStatic = (classes) => {
|
|
@@ -2454,7 +2533,7 @@ function isRecord(value) {
|
|
|
2454
2533
|
}
|
|
2455
2534
|
async function pathExists(filePath) {
|
|
2456
2535
|
try {
|
|
2457
|
-
await
|
|
2536
|
+
await fs5__default.promises.access(filePath, fs5__default.constants.F_OK);
|
|
2458
2537
|
return true;
|
|
2459
2538
|
} catch {
|
|
2460
2539
|
return false;
|
|
@@ -2739,7 +2818,7 @@ var collectCustomUtilities = (config) => {
|
|
|
2739
2818
|
return out;
|
|
2740
2819
|
};
|
|
2741
2820
|
var collectSafelistFromSource = async (configPath) => {
|
|
2742
|
-
const source = await
|
|
2821
|
+
const source = await fs5__default.promises.readFile(configPath, "utf8");
|
|
2743
2822
|
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
2744
2823
|
const allTokens = extractClassesNative2(source);
|
|
2745
2824
|
const hasSafelist = source.includes("safelist");
|
|
@@ -2766,7 +2845,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2766
2845
|
customUtilities: /* @__PURE__ */ new Set()
|
|
2767
2846
|
};
|
|
2768
2847
|
}
|
|
2769
|
-
const configStat = await
|
|
2848
|
+
const configStat = await fs5__default.promises.stat(configPath).catch(() => null);
|
|
2770
2849
|
if (configStat) {
|
|
2771
2850
|
const cached = tailwindConfigCache.get(configPath);
|
|
2772
2851
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -3084,7 +3163,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3084
3163
|
}
|
|
3085
3164
|
log5.debug(`native change ${normalizedPath}`);
|
|
3086
3165
|
const scanned = scanFile(normalizedPath);
|
|
3087
|
-
const content =
|
|
3166
|
+
const content = fs5__default.readFileSync(normalizedPath, "utf8");
|
|
3088
3167
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3089
3168
|
const existing = byFile.get(normalizedPath);
|
|
3090
3169
|
if (diff && existing) {
|
|
@@ -3154,7 +3233,7 @@ var CACHE_DIR = ".tw-cache";
|
|
|
3154
3233
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
3155
3234
|
try {
|
|
3156
3235
|
const cacheDir = path6__default.join(cwd, CACHE_DIR);
|
|
3157
|
-
|
|
3236
|
+
fs5__default.mkdirSync(cacheDir, { recursive: true });
|
|
3158
3237
|
const mem = process.memoryUsage();
|
|
3159
3238
|
const data = {
|
|
3160
3239
|
...metrics,
|
|
@@ -3165,7 +3244,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
3165
3244
|
},
|
|
3166
3245
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3167
3246
|
};
|
|
3168
|
-
|
|
3247
|
+
fs5__default.writeFileSync(path6__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
3169
3248
|
} catch {
|
|
3170
3249
|
}
|
|
3171
3250
|
}
|
|
@@ -3365,7 +3444,7 @@ var log6 = createLogger("engine");
|
|
|
3365
3444
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
3366
3445
|
if (!tailwindConfigPath) return void 0;
|
|
3367
3446
|
const configPath = path6__default.resolve(root, tailwindConfigPath);
|
|
3368
|
-
if (!
|
|
3447
|
+
if (!fs5__default.existsSync(configPath)) {
|
|
3369
3448
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
3370
3449
|
}
|
|
3371
3450
|
const imported = await import(pathToFileURL(configPath).href);
|
|
@@ -3408,7 +3487,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3408
3487
|
const transformedClasses = await runTransformClasses(plugins, scan.uniqueClasses, context);
|
|
3409
3488
|
const mergedClassList = mergeClassesStatic(transformedClasses.join(" "));
|
|
3410
3489
|
const css = options.compileCss !== false && mergedClassList.length > 0 ? await generateCssForClasses(
|
|
3411
|
-
mergedClassList.split(/\s+/).filter(Boolean)
|
|
3490
|
+
mergedClassList.split(/\s+/).filter(Boolean),
|
|
3491
|
+
tailwindConfig,
|
|
3492
|
+
root
|
|
3493
|
+
) : "";
|
|
3412
3494
|
const compileMs = Date.now() - compileStartedAt;
|
|
3413
3495
|
const analyzeStartedAt = Date.now();
|
|
3414
3496
|
const analysis = options.analyze ? await tryRunAnalyzer(root, options) : void 0;
|
|
@@ -3429,10 +3511,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3429
3511
|
}
|
|
3430
3512
|
function countWorkspacePackages(root) {
|
|
3431
3513
|
const packagesDir = path6__default.join(root, "packages");
|
|
3432
|
-
if (!
|
|
3514
|
+
if (!fs5__default.existsSync(packagesDir)) return 0;
|
|
3433
3515
|
try {
|
|
3434
|
-
return
|
|
3435
|
-
(entry) => entry.isDirectory() &&
|
|
3516
|
+
return fs5__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
3517
|
+
(entry) => entry.isDirectory() && fs5__default.existsSync(path6__default.join(packagesDir, entry.name, "package.json"))
|
|
3436
3518
|
).length;
|
|
3437
3519
|
} catch {
|
|
3438
3520
|
return 0;
|
|
@@ -3615,7 +3697,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
3615
3697
|
const shouldForceFullRescan = (event) => {
|
|
3616
3698
|
if (event.type === "unlink") return false;
|
|
3617
3699
|
try {
|
|
3618
|
-
const stat =
|
|
3700
|
+
const stat = fs5__default.statSync(event.filePath);
|
|
3619
3701
|
if (stat.size > largeFileThreshold) {
|
|
3620
3702
|
metrics.markSkippedLargeFile();
|
|
3621
3703
|
return true;
|
|
@@ -3799,8 +3881,8 @@ function filterScanToDirs(scan, root, scanDirs) {
|
|
|
3799
3881
|
}
|
|
3800
3882
|
function writeJsonArtifact(root, relativePath, value) {
|
|
3801
3883
|
const outputPath = path6__default.resolve(root, relativePath);
|
|
3802
|
-
|
|
3803
|
-
|
|
3884
|
+
fs5__default.mkdirSync(path6__default.dirname(outputPath), { recursive: true });
|
|
3885
|
+
fs5__default.writeFileSync(outputPath, `${JSON.stringify(value, null, 2)}
|
|
3804
3886
|
`);
|
|
3805
3887
|
}
|
|
3806
3888
|
function tailwindStyledPlugin(opts = {}) {
|