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/engine.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
|
}
|
|
@@ -1280,8 +1297,10 @@ __export(native_bridge_exports, {
|
|
|
1280
1297
|
extractClassesNative: () => extractClassesNative,
|
|
1281
1298
|
generateSubComponentTypesNative: () => generateSubComponentTypesNative,
|
|
1282
1299
|
hasNativeScannerBinding: () => hasNativeScannerBinding,
|
|
1300
|
+
hasNativeWatchBinding: () => hasNativeWatchBinding,
|
|
1283
1301
|
hashContentNative: () => hashContentNative,
|
|
1284
1302
|
isRustCacheAvailable: () => isRustCacheAvailable,
|
|
1303
|
+
pollWatchEventsNative: () => pollWatchEventsNative,
|
|
1285
1304
|
pruneStaleEntriesNative: () => pruneStaleEntriesNative,
|
|
1286
1305
|
rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
|
|
1287
1306
|
resetScannerBridgeCache: () => resetScannerBridgeCache,
|
|
@@ -1291,7 +1310,9 @@ __export(native_bridge_exports, {
|
|
|
1291
1310
|
scanCacheStats: () => scanCacheStats,
|
|
1292
1311
|
scanFileNative: () => scanFileNative,
|
|
1293
1312
|
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
1294
|
-
scanWorkspaceNative: () => scanWorkspaceNative
|
|
1313
|
+
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
1314
|
+
startWatchNative: () => startWatchNative,
|
|
1315
|
+
stopWatchNative: () => stopWatchNative
|
|
1295
1316
|
});
|
|
1296
1317
|
function getDirname2() {
|
|
1297
1318
|
if (typeof __dirname !== "undefined") {
|
|
@@ -1468,6 +1489,41 @@ function computeCacheStatsNative(filesClasses, sizes, top) {
|
|
|
1468
1489
|
if (!binding.computeCacheStats) return null;
|
|
1469
1490
|
return binding.computeCacheStats(filesClasses, sizes, top ?? null);
|
|
1470
1491
|
}
|
|
1492
|
+
function startWatchNative(rootDir) {
|
|
1493
|
+
try {
|
|
1494
|
+
const binding = scannerGetBinding();
|
|
1495
|
+
if (!binding.startWatch) return null;
|
|
1496
|
+
return binding.startWatch(rootDir);
|
|
1497
|
+
} catch {
|
|
1498
|
+
return null;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function pollWatchEventsNative(handleId) {
|
|
1502
|
+
try {
|
|
1503
|
+
const binding = scannerGetBinding();
|
|
1504
|
+
if (!binding.pollWatchEvents) return [];
|
|
1505
|
+
return binding.pollWatchEvents(handleId);
|
|
1506
|
+
} catch {
|
|
1507
|
+
return [];
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
function stopWatchNative(handleId) {
|
|
1511
|
+
try {
|
|
1512
|
+
const binding = scannerGetBinding();
|
|
1513
|
+
if (!binding.stopWatch) return false;
|
|
1514
|
+
return binding.stopWatch(handleId);
|
|
1515
|
+
} catch {
|
|
1516
|
+
return false;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
function hasNativeWatchBinding() {
|
|
1520
|
+
try {
|
|
1521
|
+
const binding = scannerGetBinding();
|
|
1522
|
+
return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
|
|
1523
|
+
} catch {
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1471
1527
|
var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
1472
1528
|
var init_native_bridge = __esm({
|
|
1473
1529
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
@@ -1557,6 +1613,7 @@ function defaultCachePath(rootDir, cacheDir) {
|
|
|
1557
1613
|
}
|
|
1558
1614
|
function readCache(rootDir, cacheDir) {
|
|
1559
1615
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1616
|
+
fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
|
|
1560
1617
|
const result = cacheReadNative(cachePath);
|
|
1561
1618
|
if (!result) return [];
|
|
1562
1619
|
return result.entries.map((e) => ({
|
|
@@ -1571,6 +1628,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1571
1628
|
}
|
|
1572
1629
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1573
1630
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1631
|
+
fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
|
|
1574
1632
|
const success = cacheWriteNative(cachePath, entries);
|
|
1575
1633
|
if (!success) {
|
|
1576
1634
|
throw new Error(
|
|
@@ -1601,7 +1659,7 @@ function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
|
1601
1659
|
function walk(dir) {
|
|
1602
1660
|
let entries;
|
|
1603
1661
|
try {
|
|
1604
|
-
entries =
|
|
1662
|
+
entries = fs5__default.readdirSync(dir, { withFileTypes: true });
|
|
1605
1663
|
} catch {
|
|
1606
1664
|
return;
|
|
1607
1665
|
}
|
|
@@ -1801,7 +1859,7 @@ function resolveScannerWorkerModulePath() {
|
|
|
1801
1859
|
path6__default.resolve(runtimeDir, "worker.ts")
|
|
1802
1860
|
];
|
|
1803
1861
|
for (const candidate of candidates) {
|
|
1804
|
-
if (
|
|
1862
|
+
if (fs5__default.existsSync(candidate)) return candidate;
|
|
1805
1863
|
}
|
|
1806
1864
|
return null;
|
|
1807
1865
|
}
|
|
@@ -1858,7 +1916,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
1858
1916
|
if (!currentDir) continue;
|
|
1859
1917
|
const entries = (() => {
|
|
1860
1918
|
try {
|
|
1861
|
-
return
|
|
1919
|
+
return fs5__default.readdirSync(currentDir, { withFileTypes: true });
|
|
1862
1920
|
} catch {
|
|
1863
1921
|
return [];
|
|
1864
1922
|
}
|
|
@@ -1957,7 +2015,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1957
2015
|
for (const filePath of candidates) {
|
|
1958
2016
|
const stat = (() => {
|
|
1959
2017
|
try {
|
|
1960
|
-
return
|
|
2018
|
+
return fs5__default.statSync(filePath);
|
|
1961
2019
|
} catch {
|
|
1962
2020
|
return null;
|
|
1963
2021
|
}
|
|
@@ -1983,7 +2041,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
1983
2041
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
1984
2042
|
const content = (() => {
|
|
1985
2043
|
try {
|
|
1986
|
-
return
|
|
2044
|
+
return fs5__default.readFileSync(filePath, "utf8");
|
|
1987
2045
|
} catch {
|
|
1988
2046
|
return null;
|
|
1989
2047
|
}
|
|
@@ -2088,21 +2146,31 @@ var init_src2 = __esm({
|
|
|
2088
2146
|
if (_state.binding !== void 0) return _state.binding;
|
|
2089
2147
|
const runtimeDir = getRuntimeDir();
|
|
2090
2148
|
const req = createRequire(path6__default.join(runtimeDir, "noop.cjs"));
|
|
2149
|
+
const _platform = process.platform;
|
|
2150
|
+
const _arch = process.arch;
|
|
2151
|
+
const _platformArch = `${_platform}-${_arch}`;
|
|
2152
|
+
const _platformArchGnu = _platformArch === "linux-x64" ? "linux-x64-gnu" : _platformArch === "linux-arm64" ? "linux-arm64-gnu" : _platformArch;
|
|
2091
2153
|
const candidates = [
|
|
2092
2154
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2093
2155
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2094
2156
|
path6__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
2095
|
-
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2096
|
-
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${
|
|
2097
|
-
// runtimeDir = dist/ → naik
|
|
2157
|
+
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2158
|
+
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2159
|
+
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2160
|
+
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2161
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
2162
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
2163
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2164
|
+
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2098
2165
|
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2099
|
-
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2166
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2100
2167
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2101
2168
|
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
2102
|
-
path6__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${
|
|
2169
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2103
2170
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2104
2171
|
path6__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
2105
2172
|
path6__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
2173
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
2106
2174
|
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2107
2175
|
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
2108
2176
|
path6__default.resolve(
|
|
@@ -2117,7 +2185,7 @@ var init_src2 = __esm({
|
|
|
2117
2185
|
)
|
|
2118
2186
|
];
|
|
2119
2187
|
for (const fullPath of candidates) {
|
|
2120
|
-
if (!
|
|
2188
|
+
if (!fs5__default.existsSync(fullPath)) continue;
|
|
2121
2189
|
try {
|
|
2122
2190
|
const required = req(fullPath);
|
|
2123
2191
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2236,10 +2304,34 @@ function loadTailwindEngine() {
|
|
|
2236
2304
|
throw _twEngineError;
|
|
2237
2305
|
}
|
|
2238
2306
|
}
|
|
2239
|
-
function generateRawCss(classes) {
|
|
2307
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
2240
2308
|
if (classes.length === 0) return "";
|
|
2241
2309
|
const tw = loadTailwindEngine();
|
|
2242
|
-
const
|
|
2310
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
2311
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
2312
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
2313
|
+
const projectRoot = root ?? process.cwd();
|
|
2314
|
+
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
2315
|
+
const loadStylesheet = async (id, base) => {
|
|
2316
|
+
try {
|
|
2317
|
+
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;
|
|
2318
|
+
const pkgPath = req.resolve(cssId);
|
|
2319
|
+
return {
|
|
2320
|
+
content: readFileSync(pkgPath, "utf-8"),
|
|
2321
|
+
base: dirname(pkgPath)
|
|
2322
|
+
};
|
|
2323
|
+
} catch {
|
|
2324
|
+
try {
|
|
2325
|
+
const absPath = resolve2(base, id);
|
|
2326
|
+
if (existsSync3(absPath)) {
|
|
2327
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
2328
|
+
}
|
|
2329
|
+
} catch {
|
|
2330
|
+
}
|
|
2331
|
+
return { content: "", base };
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
2243
2335
|
return compiler.build(classes);
|
|
2244
2336
|
}
|
|
2245
2337
|
function postProcessWithLightning(rawCss) {
|
|
@@ -2251,14 +2343,14 @@ function postProcessWithLightning(rawCss) {
|
|
|
2251
2343
|
const result = native.processTailwindCssLightning(rawCss);
|
|
2252
2344
|
return result?.css ?? rawCss;
|
|
2253
2345
|
}
|
|
2254
|
-
async function runCssPipeline(classes) {
|
|
2346
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
2255
2347
|
const unique = [...new Set(classes.filter(Boolean))];
|
|
2256
2348
|
if (unique.length === 0) {
|
|
2257
2349
|
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2258
2350
|
}
|
|
2259
|
-
const rawCss = generateRawCss(unique);
|
|
2351
|
+
const rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
2260
2352
|
const native = getNativeBridge();
|
|
2261
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
2353
|
+
const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
|
|
2262
2354
|
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
2263
2355
|
return {
|
|
2264
2356
|
css: finalCss,
|
|
@@ -2267,21 +2359,8 @@ async function runCssPipeline(classes) {
|
|
|
2267
2359
|
optimized: hasLightning
|
|
2268
2360
|
};
|
|
2269
2361
|
}
|
|
2270
|
-
function runCssPipelineSync(
|
|
2271
|
-
|
|
2272
|
-
if (unique.length === 0) {
|
|
2273
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2274
|
-
}
|
|
2275
|
-
const rawCss = generateRawCss(unique);
|
|
2276
|
-
const native = getNativeBridge();
|
|
2277
|
-
const hasLightning = typeof native.processTailwindCssLightning === "function";
|
|
2278
|
-
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
2279
|
-
return {
|
|
2280
|
-
css: finalCss,
|
|
2281
|
-
classes: unique,
|
|
2282
|
-
sizeBytes: finalCss.length,
|
|
2283
|
-
optimized: hasLightning
|
|
2284
|
-
};
|
|
2362
|
+
function runCssPipelineSync(_classes) {
|
|
2363
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2285
2364
|
}
|
|
2286
2365
|
function processTailwindCssWithTargets(css, targets) {
|
|
2287
2366
|
const native = getNativeBridge();
|
|
@@ -2957,7 +3036,7 @@ function isRecord(value) {
|
|
|
2957
3036
|
}
|
|
2958
3037
|
async function pathExists(filePath) {
|
|
2959
3038
|
try {
|
|
2960
|
-
await
|
|
3039
|
+
await fs5__default.promises.access(filePath, fs5__default.constants.F_OK);
|
|
2961
3040
|
return true;
|
|
2962
3041
|
} catch {
|
|
2963
3042
|
return false;
|
|
@@ -3242,7 +3321,7 @@ var collectCustomUtilities = (config) => {
|
|
|
3242
3321
|
return out;
|
|
3243
3322
|
};
|
|
3244
3323
|
var collectSafelistFromSource = async (configPath) => {
|
|
3245
|
-
const source = await
|
|
3324
|
+
const source = await fs5__default.promises.readFile(configPath, "utf8");
|
|
3246
3325
|
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
3247
3326
|
const allTokens = extractClassesNative2(source);
|
|
3248
3327
|
const hasSafelist = source.includes("safelist");
|
|
@@ -3269,7 +3348,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
3269
3348
|
customUtilities: /* @__PURE__ */ new Set()
|
|
3270
3349
|
};
|
|
3271
3350
|
}
|
|
3272
|
-
const configStat = await
|
|
3351
|
+
const configStat = await fs5__default.promises.stat(configPath).catch(() => null);
|
|
3273
3352
|
if (configStat) {
|
|
3274
3353
|
const cached = tailwindConfigCache.get(configPath);
|
|
3275
3354
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -3532,9 +3611,9 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
3532
3611
|
|
|
3533
3612
|
// packages/domain/compiler/src/index.ts
|
|
3534
3613
|
init_nativeBridge();
|
|
3535
|
-
var generateCssForClasses = async (classes, _tailwindConfig,
|
|
3614
|
+
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
3536
3615
|
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
3537
|
-
const result = await runCssPipeline2(classes);
|
|
3616
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
3538
3617
|
return result.css;
|
|
3539
3618
|
};
|
|
3540
3619
|
var mergeClassesStatic = (classes) => {
|
|
@@ -3607,7 +3686,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3607
3686
|
}
|
|
3608
3687
|
log5.debug(`native change ${normalizedPath}`);
|
|
3609
3688
|
const scanned = scanFile(normalizedPath);
|
|
3610
|
-
const content =
|
|
3689
|
+
const content = fs5__default.readFileSync(normalizedPath, "utf8");
|
|
3611
3690
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3612
3691
|
const existing = byFile.get(normalizedPath);
|
|
3613
3692
|
if (diff && existing) {
|
|
@@ -3958,7 +4037,7 @@ var CACHE_DIR = ".tw-cache";
|
|
|
3958
4037
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
3959
4038
|
try {
|
|
3960
4039
|
const cacheDir = path6__default.join(cwd, CACHE_DIR);
|
|
3961
|
-
|
|
4040
|
+
fs5__default.mkdirSync(cacheDir, { recursive: true });
|
|
3962
4041
|
const mem = process.memoryUsage();
|
|
3963
4042
|
const data = {
|
|
3964
4043
|
...metrics,
|
|
@@ -3969,7 +4048,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
3969
4048
|
},
|
|
3970
4049
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3971
4050
|
};
|
|
3972
|
-
|
|
4051
|
+
fs5__default.writeFileSync(path6__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
3973
4052
|
} catch {
|
|
3974
4053
|
}
|
|
3975
4054
|
}
|
|
@@ -4245,8 +4324,24 @@ var getBinding = () => {
|
|
|
4245
4324
|
}
|
|
4246
4325
|
const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
|
|
4247
4326
|
const req = createRequire(import.meta.url);
|
|
4327
|
+
const _pa = `${process.platform}-${process.arch}`;
|
|
4328
|
+
const _paGnu = _pa === "linux-x64" ? "linux-x64-gnu" : _pa === "linux-arm64" ? "linux-arm64-gnu" : _pa;
|
|
4248
4329
|
const candidates = [
|
|
4330
|
+
// new binary name: tailwind-styled-native
|
|
4331
|
+
path6__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
4332
|
+
path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_pa}.node`),
|
|
4333
|
+
// npm install case: dist/../native/
|
|
4334
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
4335
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_pa}.node`),
|
|
4336
|
+
path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_paGnu}.node`),
|
|
4337
|
+
// monorepo dev: 4-level up
|
|
4338
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4339
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_paGnu}.node`),
|
|
4340
|
+
// 3-level fallback
|
|
4341
|
+
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4342
|
+
// backward compat: tailwind_styled_parser
|
|
4249
4343
|
path6__default.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
4344
|
+
path6__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
4250
4345
|
path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
4251
4346
|
path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
4252
4347
|
];
|
|
@@ -4347,7 +4442,7 @@ var log7 = createLogger("engine");
|
|
|
4347
4442
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
4348
4443
|
if (!tailwindConfigPath) return void 0;
|
|
4349
4444
|
const configPath = path6__default.resolve(root, tailwindConfigPath);
|
|
4350
|
-
if (!
|
|
4445
|
+
if (!fs5__default.existsSync(configPath)) {
|
|
4351
4446
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
4352
4447
|
}
|
|
4353
4448
|
const imported = await import(pathToFileURL(configPath).href);
|
|
@@ -4390,7 +4485,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
4390
4485
|
const transformedClasses = await runTransformClasses(plugins, scan.uniqueClasses, context);
|
|
4391
4486
|
const mergedClassList = mergeClassesStatic(transformedClasses.join(" "));
|
|
4392
4487
|
const css = options.compileCss !== false && mergedClassList.length > 0 ? await generateCssForClasses(
|
|
4393
|
-
mergedClassList.split(/\s+/).filter(Boolean)
|
|
4488
|
+
mergedClassList.split(/\s+/).filter(Boolean),
|
|
4489
|
+
tailwindConfig,
|
|
4490
|
+
root
|
|
4491
|
+
) : "";
|
|
4394
4492
|
const compileMs = Date.now() - compileStartedAt;
|
|
4395
4493
|
const analyzeStartedAt = Date.now();
|
|
4396
4494
|
const analysis = options.analyze ? await tryRunAnalyzer(root, options) : void 0;
|
|
@@ -4411,10 +4509,10 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
4411
4509
|
}
|
|
4412
4510
|
function countWorkspacePackages(root) {
|
|
4413
4511
|
const packagesDir = path6__default.join(root, "packages");
|
|
4414
|
-
if (!
|
|
4512
|
+
if (!fs5__default.existsSync(packagesDir)) return 0;
|
|
4415
4513
|
try {
|
|
4416
|
-
return
|
|
4417
|
-
(entry) => entry.isDirectory() &&
|
|
4514
|
+
return fs5__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
4515
|
+
(entry) => entry.isDirectory() && fs5__default.existsSync(path6__default.join(packagesDir, entry.name, "package.json"))
|
|
4418
4516
|
).length;
|
|
4419
4517
|
} catch {
|
|
4420
4518
|
return 0;
|
|
@@ -4597,7 +4695,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
4597
4695
|
const shouldForceFullRescan = (event) => {
|
|
4598
4696
|
if (event.type === "unlink") return false;
|
|
4599
4697
|
try {
|
|
4600
|
-
const stat =
|
|
4698
|
+
const stat = fs5__default.statSync(event.filePath);
|
|
4601
4699
|
if (stat.size > largeFileThreshold) {
|
|
4602
4700
|
metrics.markSkippedLargeFile();
|
|
4603
4701
|
return true;
|