tailwind-styled-v4 5.0.11 → 5.0.12
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/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
- package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
- package/dist/analyzer.d.mts +4 -4
- package/dist/analyzer.d.ts +4 -4
- package/dist/analyzer.js +34 -69
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +33 -68
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.js +11 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +11 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +16 -7
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +16 -7
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +262 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +259 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2543 -109
- package/dist/compiler.d.ts +2543 -109
- package/dist/compiler.js +1962 -435
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1816 -382
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +17 -4
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +17 -4
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +11 -470
- package/dist/engine.d.ts +11 -470
- package/dist/engine.js +1442 -417
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +1442 -417
- package/dist/engine.mjs.map +1 -1
- package/dist/index-BDQw13kn.d.ts +464 -0
- package/dist/index-DJv28Uzq.d.mts +464 -0
- package/dist/index.browser.mjs +143 -255
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +23 -39
- package/dist/index.d.ts +23 -39
- package/dist/index.js +6000 -1463
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5995 -1458
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +44 -1
- package/dist/next.d.ts +44 -1
- package/dist/next.js +3197 -1128
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3196 -1129
- package/dist/next.mjs.map +1 -1
- package/dist/rspack.d.mts +9 -0
- package/dist/rspack.d.ts +9 -0
- package/dist/rspack.js +99 -61
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +99 -61
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime-css.d.mts +8 -0
- package/dist/runtime-css.d.ts +8 -0
- package/dist/runtime-css.js +23 -7
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +23 -7
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/scanner.js +16 -37
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +15 -36
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +107 -1
- package/dist/shared.d.ts +107 -1
- package/dist/shared.js +1627 -376
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +1620 -354
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +39 -35
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -34
- package/dist/svelte.mjs.map +1 -1
- package/dist/theme.js +85 -76
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +83 -74
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +943 -76
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +943 -76
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +262 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +259 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1336 -296
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1336 -296
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +39 -35
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -34
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +140 -34
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +140 -34
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/index.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
- package/package.json +9 -4
- package/CHANGELOG.md +0 -285
package/dist/engine.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var module$1 = require('module');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var fs3 = require('fs');
|
|
6
|
+
var path9 = require('path');
|
|
7
7
|
var crypto = require('crypto');
|
|
8
8
|
var url = require('url');
|
|
9
9
|
var worker_threads = require('worker_threads');
|
|
@@ -29,8 +29,8 @@ function _interopNamespace(e) {
|
|
|
29
29
|
return Object.freeze(n);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
var
|
|
33
|
-
var
|
|
32
|
+
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
33
|
+
var path9__namespace = /*#__PURE__*/_interopNamespace(path9);
|
|
34
34
|
|
|
35
35
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
36
36
|
var __defProp = Object.defineProperty;
|
|
@@ -242,9 +242,9 @@ function parseNative(schema, data, context) {
|
|
|
242
242
|
const result = schema.safeParse(data);
|
|
243
243
|
if (!result.success) {
|
|
244
244
|
const first = result.error.issues[0];
|
|
245
|
-
const
|
|
245
|
+
const path16 = first?.path?.join(".") ?? "(root)";
|
|
246
246
|
throw new Error(
|
|
247
|
-
`[${context}] Native binding returned unexpected data: ${
|
|
247
|
+
`[${context}] Native binding returned unexpected data: ${path16}: ${first?.message ?? "validation failed"}`
|
|
248
248
|
);
|
|
249
249
|
}
|
|
250
250
|
return result.data;
|
|
@@ -637,11 +637,11 @@ function resolvePath(...segments) {
|
|
|
637
637
|
return segments.join("/").replace(/\/+/g, "/");
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
function existsSync(
|
|
640
|
+
function existsSync(path16) {
|
|
641
641
|
if (isBrowser2) return false;
|
|
642
642
|
try {
|
|
643
643
|
const nodeFs = __require(NODE_FS);
|
|
644
|
-
return nodeFs.existsSync(
|
|
644
|
+
return nodeFs.existsSync(path16);
|
|
645
645
|
} catch {
|
|
646
646
|
return false;
|
|
647
647
|
}
|
|
@@ -871,12 +871,12 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
871
871
|
if (isBrowser3) {
|
|
872
872
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
873
873
|
}
|
|
874
|
-
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
874
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
875
875
|
return { path: null, source: "not-found", platform, tried: [] };
|
|
876
876
|
}
|
|
877
877
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
878
878
|
if (envPath) {
|
|
879
|
-
if (
|
|
879
|
+
if (fs3__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 (fs3__namespace.existsSync(candidate)) {
|
|
889
889
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
890
890
|
}
|
|
891
891
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -896,13 +896,13 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
896
896
|
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
897
897
|
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
898
898
|
if (runtimeDir) {
|
|
899
|
-
for (const depth of ["..",
|
|
900
|
-
const pkgRoot =
|
|
899
|
+
for (const depth of ["..", path9__namespace.join("..", ".."), path9__namespace.join("..", "..", "..")]) {
|
|
900
|
+
const pkgRoot = path9__namespace.resolve(runtimeDir, depth);
|
|
901
901
|
for (const bin of BINARY_NAMES_SELF) {
|
|
902
902
|
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
903
|
-
const candidate =
|
|
903
|
+
const candidate = path9__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
904
904
|
tried.push(`self-bundled:${candidate}`);
|
|
905
|
-
if (
|
|
905
|
+
if (fs3__namespace.existsSync(candidate)) {
|
|
906
906
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
907
907
|
}
|
|
908
908
|
}
|
|
@@ -914,29 +914,29 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
914
914
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
915
915
|
const localCandidates = [];
|
|
916
916
|
for (const bin of BINARY_NAMES) {
|
|
917
|
-
localCandidates.push(
|
|
918
|
-
localCandidates.push(
|
|
919
|
-
localCandidates.push(
|
|
920
|
-
localCandidates.push(
|
|
917
|
+
localCandidates.push(path9__namespace.resolve(base, `${bin}.node`));
|
|
918
|
+
localCandidates.push(path9__namespace.resolve(base, "..", `${bin}.node`));
|
|
919
|
+
localCandidates.push(path9__namespace.resolve(base, `${bin}.${platform}.node`));
|
|
920
|
+
localCandidates.push(path9__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
921
921
|
}
|
|
922
922
|
for (const startDir of [cwd, base]) {
|
|
923
923
|
let dir = startDir;
|
|
924
924
|
for (let i = 0; i < 6; i++) {
|
|
925
|
-
const nativeDir =
|
|
925
|
+
const nativeDir = path9__namespace.resolve(dir, "native");
|
|
926
926
|
for (const bin of BINARY_NAMES) {
|
|
927
|
-
localCandidates.push(
|
|
928
|
-
localCandidates.push(
|
|
929
|
-
localCandidates.push(
|
|
930
|
-
localCandidates.push(
|
|
927
|
+
localCandidates.push(path9__namespace.resolve(nativeDir, `${bin}.node`));
|
|
928
|
+
localCandidates.push(path9__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
929
|
+
localCandidates.push(path9__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
930
|
+
localCandidates.push(path9__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
931
931
|
}
|
|
932
|
-
const parent =
|
|
932
|
+
const parent = path9__namespace.resolve(dir, "..");
|
|
933
933
|
if (parent === dir) break;
|
|
934
934
|
dir = parent;
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
937
|
for (const candidate of localCandidates) {
|
|
938
938
|
tried.push(`local:${candidate}`);
|
|
939
|
-
if (
|
|
939
|
+
if (fs3__namespace.existsSync(candidate)) {
|
|
940
940
|
return { path: candidate, source: "local", platform, tried };
|
|
941
941
|
}
|
|
942
942
|
}
|
|
@@ -975,9 +975,9 @@ var init_native_resolution = __esm({
|
|
|
975
975
|
// packages/domain/shared/src/observability.ts
|
|
976
976
|
function createObservabilityClient(opts = {}) {
|
|
977
977
|
const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
|
|
978
|
-
async function fetchJson(
|
|
978
|
+
async function fetchJson(path16) {
|
|
979
979
|
try {
|
|
980
|
-
const res = await fetch(`${baseUrl}${
|
|
980
|
+
const res = await fetch(`${baseUrl}${path16}`, {
|
|
981
981
|
signal: AbortSignal.timeout(timeoutMs)
|
|
982
982
|
});
|
|
983
983
|
if (!res.ok) return null;
|
|
@@ -1009,6 +1009,1182 @@ var init_observability = __esm({
|
|
|
1009
1009
|
}
|
|
1010
1010
|
});
|
|
1011
1011
|
|
|
1012
|
+
// packages/domain/compiler/src/nativeBridge.ts
|
|
1013
|
+
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
|
|
1014
|
+
var init_nativeBridge = __esm({
|
|
1015
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
1016
|
+
init_src2();
|
|
1017
|
+
_loadNative = (path16) => __require(path16);
|
|
1018
|
+
log = (...args) => {
|
|
1019
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
1020
|
+
console.log("[compiler:native]", ...args);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
|
|
1024
|
+
nativeBridge = null;
|
|
1025
|
+
bridgeLoadAttempted = false;
|
|
1026
|
+
bridgeLoadError = null;
|
|
1027
|
+
isValidNativeBridge = (mod) => {
|
|
1028
|
+
const m = mod;
|
|
1029
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
1030
|
+
};
|
|
1031
|
+
getNativeBridge = () => {
|
|
1032
|
+
if (nativeBridge) {
|
|
1033
|
+
return nativeBridge;
|
|
1034
|
+
}
|
|
1035
|
+
if (bridgeLoadAttempted) {
|
|
1036
|
+
if (bridgeLoadError) {
|
|
1037
|
+
throw bridgeLoadError;
|
|
1038
|
+
}
|
|
1039
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
1040
|
+
}
|
|
1041
|
+
bridgeLoadAttempted = true;
|
|
1042
|
+
try {
|
|
1043
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
1044
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
1045
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
1046
|
+
try {
|
|
1047
|
+
const binding = _loadNative(result.path);
|
|
1048
|
+
if (isValidNativeBridge(binding)) {
|
|
1049
|
+
nativeBridge = binding;
|
|
1050
|
+
log("Native bridge loaded successfully from:", result.path);
|
|
1051
|
+
return nativeBridge;
|
|
1052
|
+
}
|
|
1053
|
+
} catch (e) {
|
|
1054
|
+
log("Failed to require native binding:", e);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
1058
|
+
|
|
1059
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
1060
|
+
} catch (err) {
|
|
1061
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
1062
|
+
log("Failed to load native bridge:", bridgeLoadError.message);
|
|
1063
|
+
throw bridgeLoadError;
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
adaptNativeResult = (raw) => {
|
|
1067
|
+
return {
|
|
1068
|
+
code: raw.code ?? "",
|
|
1069
|
+
classes: raw.classes ?? [],
|
|
1070
|
+
changed: raw.changed ?? false,
|
|
1071
|
+
rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
|
|
1072
|
+
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
1076
|
+
try {
|
|
1077
|
+
getNativeBridge();
|
|
1078
|
+
} catch {
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
1085
|
+
var tailwindEngine_exports = {};
|
|
1086
|
+
__export(tailwindEngine_exports, {
|
|
1087
|
+
clearCache: () => clearCache,
|
|
1088
|
+
generateRawCss: () => generateRawCss,
|
|
1089
|
+
getCacheStats: () => getCacheStats,
|
|
1090
|
+
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
1091
|
+
runCssPipeline: () => runCssPipeline,
|
|
1092
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
1093
|
+
});
|
|
1094
|
+
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
1095
|
+
const sorted = [...classes].sort().join(",");
|
|
1096
|
+
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
1097
|
+
return `${sorted}|${flags}`;
|
|
1098
|
+
}
|
|
1099
|
+
function _evictOldestIfNeeded() {
|
|
1100
|
+
if (_cssCache.size >= MAX_CACHE_SIZE) {
|
|
1101
|
+
const firstKey = _cssCache.keys().next().value;
|
|
1102
|
+
if (firstKey !== void 0) {
|
|
1103
|
+
_cssCache.delete(firstKey);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function getCacheStats() {
|
|
1108
|
+
const total = _cacheHits + _cacheMisses;
|
|
1109
|
+
return {
|
|
1110
|
+
hits: _cacheHits,
|
|
1111
|
+
misses: _cacheMisses,
|
|
1112
|
+
hitRate: total > 0 ? _cacheHits / total : 0,
|
|
1113
|
+
size: _cssCache.size,
|
|
1114
|
+
maxSize: MAX_CACHE_SIZE
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
function clearCache() {
|
|
1118
|
+
_cssCache.clear();
|
|
1119
|
+
_cacheHits = 0;
|
|
1120
|
+
_cacheMisses = 0;
|
|
1121
|
+
}
|
|
1122
|
+
function loadTailwindEngine() {
|
|
1123
|
+
if (_twEngine) return _twEngine;
|
|
1124
|
+
if (_twEngineError) throw _twEngineError;
|
|
1125
|
+
try {
|
|
1126
|
+
const tw = require2("tailwindcss");
|
|
1127
|
+
if (typeof tw.compile !== "function") {
|
|
1128
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
1129
|
+
}
|
|
1130
|
+
_twEngine = tw;
|
|
1131
|
+
return _twEngine;
|
|
1132
|
+
} catch (e) {
|
|
1133
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
1134
|
+
throw _twEngineError;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1138
|
+
if (classes.length === 0) return "";
|
|
1139
|
+
const tw = loadTailwindEngine();
|
|
1140
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1141
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1142
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
1143
|
+
const projectRoot = root ?? process.cwd();
|
|
1144
|
+
const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
|
|
1145
|
+
const loadStylesheet = async (id, base) => {
|
|
1146
|
+
try {
|
|
1147
|
+
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;
|
|
1148
|
+
const pkgPath = req.resolve(cssId);
|
|
1149
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
|
|
1150
|
+
} catch {
|
|
1151
|
+
try {
|
|
1152
|
+
const absPath = resolve2(base, id);
|
|
1153
|
+
if (existsSync3(absPath)) {
|
|
1154
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
1155
|
+
}
|
|
1156
|
+
} catch {
|
|
1157
|
+
}
|
|
1158
|
+
return { content: "", base };
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1162
|
+
return compiler.build(classes);
|
|
1163
|
+
}
|
|
1164
|
+
function getThemeConfig() {
|
|
1165
|
+
return {
|
|
1166
|
+
colors: {
|
|
1167
|
+
slate: {
|
|
1168
|
+
"50": "#f8fafc",
|
|
1169
|
+
"100": "#f1f5f9",
|
|
1170
|
+
"200": "#e2e8f0",
|
|
1171
|
+
"300": "#cbd5e1",
|
|
1172
|
+
"400": "#94a3b8",
|
|
1173
|
+
"500": "#64748b",
|
|
1174
|
+
"600": "#475569",
|
|
1175
|
+
"700": "#334155",
|
|
1176
|
+
"800": "#1e293b",
|
|
1177
|
+
"900": "#0f172a"
|
|
1178
|
+
},
|
|
1179
|
+
gray: {
|
|
1180
|
+
"50": "#f9fafb",
|
|
1181
|
+
"100": "#f3f4f6",
|
|
1182
|
+
"200": "#e5e7eb",
|
|
1183
|
+
"300": "#d1d5db",
|
|
1184
|
+
"400": "#9ca3af",
|
|
1185
|
+
"500": "#6b7280",
|
|
1186
|
+
"600": "#4b5563",
|
|
1187
|
+
"700": "#374151",
|
|
1188
|
+
"800": "#1f2937",
|
|
1189
|
+
"900": "#111827"
|
|
1190
|
+
},
|
|
1191
|
+
white: "#ffffff",
|
|
1192
|
+
black: "#000000",
|
|
1193
|
+
red: {
|
|
1194
|
+
"500": "#ef4444",
|
|
1195
|
+
"600": "#dc2626"
|
|
1196
|
+
},
|
|
1197
|
+
blue: {
|
|
1198
|
+
"500": "#3b82f6",
|
|
1199
|
+
"600": "#1e40af"
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
spacing: {
|
|
1203
|
+
"0": "0px",
|
|
1204
|
+
"1": "0.25rem",
|
|
1205
|
+
"2": "0.5rem",
|
|
1206
|
+
"3": "0.75rem",
|
|
1207
|
+
"4": "1rem",
|
|
1208
|
+
"5": "1.25rem",
|
|
1209
|
+
"6": "1.5rem",
|
|
1210
|
+
"8": "2rem",
|
|
1211
|
+
"10": "2.5rem",
|
|
1212
|
+
"12": "3rem",
|
|
1213
|
+
"16": "4rem",
|
|
1214
|
+
"20": "5rem",
|
|
1215
|
+
"24": "6rem"
|
|
1216
|
+
},
|
|
1217
|
+
breakpoints: {
|
|
1218
|
+
"sm": "640px",
|
|
1219
|
+
"md": "768px",
|
|
1220
|
+
"lg": "1024px",
|
|
1221
|
+
"xl": "1280px",
|
|
1222
|
+
"2xl": "1536px"
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
function postProcessWithLightning(rawCss) {
|
|
1227
|
+
if (!rawCss) return "";
|
|
1228
|
+
const native = getNativeBridge();
|
|
1229
|
+
if (!native?.processTailwindCssLightning) {
|
|
1230
|
+
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
1231
|
+
}
|
|
1232
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
1233
|
+
if (!result?.css) {
|
|
1234
|
+
throw new Error("FATAL: processTailwindCssLightning returned null");
|
|
1235
|
+
}
|
|
1236
|
+
return result.css;
|
|
1237
|
+
}
|
|
1238
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
1239
|
+
const filtered = classes.filter(Boolean);
|
|
1240
|
+
const uniqueMap = /* @__PURE__ */ new Map();
|
|
1241
|
+
filtered.forEach((cls) => uniqueMap.set(cls, cls));
|
|
1242
|
+
const unique = Array.from(uniqueMap.values());
|
|
1243
|
+
if (unique.length === 0) {
|
|
1244
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1245
|
+
}
|
|
1246
|
+
const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
|
|
1247
|
+
const cached = _cssCache.get(cacheKey);
|
|
1248
|
+
if (cached) {
|
|
1249
|
+
_cacheHits++;
|
|
1250
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1251
|
+
console.log(
|
|
1252
|
+
`[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
return cached;
|
|
1256
|
+
}
|
|
1257
|
+
_cacheMisses++;
|
|
1258
|
+
let rawCss;
|
|
1259
|
+
let usedRustCompiler = false;
|
|
1260
|
+
try {
|
|
1261
|
+
const theme = getThemeConfig();
|
|
1262
|
+
rawCss = await generateCssNative(unique, {
|
|
1263
|
+
theme,
|
|
1264
|
+
fallbackToJs: true,
|
|
1265
|
+
logFallback: process.env.DEBUG?.includes("compiler") === true
|
|
1266
|
+
});
|
|
1267
|
+
usedRustCompiler = true;
|
|
1268
|
+
} catch (error) {
|
|
1269
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1270
|
+
console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
|
|
1271
|
+
}
|
|
1272
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1273
|
+
}
|
|
1274
|
+
const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
|
|
1275
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1276
|
+
console.log(
|
|
1277
|
+
`[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
|
|
1278
|
+
`Size: ${finalCss.length} bytes`
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
const result = {
|
|
1282
|
+
css: finalCss,
|
|
1283
|
+
classes: unique,
|
|
1284
|
+
sizeBytes: finalCss.length,
|
|
1285
|
+
optimized: minify
|
|
1286
|
+
};
|
|
1287
|
+
_evictOldestIfNeeded();
|
|
1288
|
+
_cssCache.set(cacheKey, result);
|
|
1289
|
+
return result;
|
|
1290
|
+
}
|
|
1291
|
+
function runCssPipelineSync(_classes) {
|
|
1292
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1293
|
+
}
|
|
1294
|
+
function processTailwindCssWithTargets(css, targets) {
|
|
1295
|
+
const native = getNativeBridge();
|
|
1296
|
+
if (!native?.processTailwindCssWithTargets) {
|
|
1297
|
+
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
1298
|
+
}
|
|
1299
|
+
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
1300
|
+
if (!result?.css) {
|
|
1301
|
+
throw new Error("FATAL: processTailwindCssWithTargets returned null");
|
|
1302
|
+
}
|
|
1303
|
+
return result.css;
|
|
1304
|
+
}
|
|
1305
|
+
var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
|
|
1306
|
+
var init_tailwindEngine = __esm({
|
|
1307
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
1308
|
+
init_nativeBridge();
|
|
1309
|
+
init_cssGeneratorNative();
|
|
1310
|
+
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
1311
|
+
_cssCache = /* @__PURE__ */ new Map();
|
|
1312
|
+
_cacheHits = 0;
|
|
1313
|
+
_cacheMisses = 0;
|
|
1314
|
+
MAX_CACHE_SIZE = 100;
|
|
1315
|
+
_twEngine = null;
|
|
1316
|
+
_twEngineError = null;
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
|
|
1320
|
+
// packages/domain/compiler/src/cssGeneratorNative.ts
|
|
1321
|
+
async function generateCssNative(classes, options) {
|
|
1322
|
+
const {
|
|
1323
|
+
theme,
|
|
1324
|
+
fallbackToJs = true,
|
|
1325
|
+
logFallback = false
|
|
1326
|
+
} = options;
|
|
1327
|
+
try {
|
|
1328
|
+
const native = getNativeBridge();
|
|
1329
|
+
if (!native?.generateCssNative) {
|
|
1330
|
+
throw new Error("generateCssNative not available in native binding");
|
|
1331
|
+
}
|
|
1332
|
+
const themeJson = JSON.stringify(theme);
|
|
1333
|
+
const css = native.generateCssNative(classes, themeJson);
|
|
1334
|
+
return css;
|
|
1335
|
+
} catch (error) {
|
|
1336
|
+
if (!fallbackToJs) {
|
|
1337
|
+
throw error;
|
|
1338
|
+
}
|
|
1339
|
+
if (logFallback) {
|
|
1340
|
+
console.warn(
|
|
1341
|
+
"[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
|
|
1342
|
+
error instanceof Error ? error.message : String(error)
|
|
1343
|
+
);
|
|
1344
|
+
}
|
|
1345
|
+
return generateRawCss(classes);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
var init_cssGeneratorNative = __esm({
|
|
1349
|
+
"packages/domain/compiler/src/cssGeneratorNative.ts"() {
|
|
1350
|
+
init_nativeBridge();
|
|
1351
|
+
init_tailwindEngine();
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
function _layoutClassesToCss(classes) {
|
|
1355
|
+
const native = getNativeBridge();
|
|
1356
|
+
if (!native?.layoutClassesToCss) {
|
|
1357
|
+
throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
|
|
1358
|
+
}
|
|
1359
|
+
return native.layoutClassesToCss(classes);
|
|
1360
|
+
}
|
|
1361
|
+
function _hashContainer(tag, containerJson, name) {
|
|
1362
|
+
const sortedKey = tag + (name ?? "") + containerJson;
|
|
1363
|
+
const native = getNativeBridge();
|
|
1364
|
+
if (!native?.hashContent) {
|
|
1365
|
+
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
1366
|
+
}
|
|
1367
|
+
return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
1368
|
+
}
|
|
1369
|
+
function extractContainerCssFromSource(source) {
|
|
1370
|
+
const native = getNativeBridge();
|
|
1371
|
+
if (!native?.extractTwContainerConfigs) {
|
|
1372
|
+
throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
|
|
1373
|
+
}
|
|
1374
|
+
const configs = native.extractTwContainerConfigs(source);
|
|
1375
|
+
const rules = [];
|
|
1376
|
+
for (const cfg of configs) {
|
|
1377
|
+
const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
|
|
1378
|
+
for (const { key, classes } of cfg.breakpoints) {
|
|
1379
|
+
const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
|
|
1380
|
+
const css = _layoutClassesToCss(classes);
|
|
1381
|
+
if (!css) continue;
|
|
1382
|
+
const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
1383
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return rules.join("\n");
|
|
1387
|
+
}
|
|
1388
|
+
var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
1389
|
+
var init_src = __esm({
|
|
1390
|
+
"packages/domain/compiler/src/index.ts"() {
|
|
1391
|
+
init_nativeBridge();
|
|
1392
|
+
transformSource = (source, opts) => {
|
|
1393
|
+
const native = getNativeBridge();
|
|
1394
|
+
if (!native?.transformSource) {
|
|
1395
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
1396
|
+
}
|
|
1397
|
+
const result = native.transformSource(source, opts);
|
|
1398
|
+
if (!result) {
|
|
1399
|
+
throw new Error("FATAL: transformSource returned null");
|
|
1400
|
+
}
|
|
1401
|
+
return result;
|
|
1402
|
+
};
|
|
1403
|
+
hasTwUsage = (source) => {
|
|
1404
|
+
const native = getNativeBridge();
|
|
1405
|
+
if (!native?.hasTwUsage) {
|
|
1406
|
+
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
1407
|
+
}
|
|
1408
|
+
return native.hasTwUsage(source);
|
|
1409
|
+
};
|
|
1410
|
+
isAlreadyTransformed = (source) => {
|
|
1411
|
+
const native = getNativeBridge();
|
|
1412
|
+
if (!native?.isAlreadyTransformed) {
|
|
1413
|
+
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
1414
|
+
}
|
|
1415
|
+
return native.isAlreadyTransformed(source);
|
|
1416
|
+
};
|
|
1417
|
+
shouldProcess = (source) => {
|
|
1418
|
+
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
1419
|
+
};
|
|
1420
|
+
compileCssFromClasses = (classes, prefix) => {
|
|
1421
|
+
const native = getNativeBridge();
|
|
1422
|
+
if (!native?.transformSource) {
|
|
1423
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
1424
|
+
}
|
|
1425
|
+
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
1426
|
+
if (!result) {
|
|
1427
|
+
throw new Error("FATAL: transformSource returned null");
|
|
1428
|
+
}
|
|
1429
|
+
return result;
|
|
1430
|
+
};
|
|
1431
|
+
buildStyleTag = (classes) => {
|
|
1432
|
+
const result = compileCssFromClasses(classes);
|
|
1433
|
+
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
1434
|
+
};
|
|
1435
|
+
compileCssNative = (classes, prefix = null) => {
|
|
1436
|
+
return compileCssFromClasses(classes, prefix);
|
|
1437
|
+
};
|
|
1438
|
+
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
1439
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
1440
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
1441
|
+
return result.css;
|
|
1442
|
+
};
|
|
1443
|
+
extractAllClasses = (source) => {
|
|
1444
|
+
const native = getNativeBridge();
|
|
1445
|
+
if (!native?.extractAllClasses) {
|
|
1446
|
+
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
1447
|
+
}
|
|
1448
|
+
return native.extractAllClasses(source) || [];
|
|
1449
|
+
};
|
|
1450
|
+
extractClassesFromSource = (source) => {
|
|
1451
|
+
const native = getNativeBridge();
|
|
1452
|
+
if (!native?.extractClassesFromSource) {
|
|
1453
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1454
|
+
}
|
|
1455
|
+
const result = native.extractClassesFromSource(source);
|
|
1456
|
+
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
1457
|
+
};
|
|
1458
|
+
astExtractClasses = (source, _filename) => {
|
|
1459
|
+
const native = getNativeBridge();
|
|
1460
|
+
if (!native?.extractClassesFromSource) {
|
|
1461
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1462
|
+
}
|
|
1463
|
+
return native.extractClassesFromSource(source) || [];
|
|
1464
|
+
};
|
|
1465
|
+
parseClasses = (raw) => {
|
|
1466
|
+
const native = getNativeBridge();
|
|
1467
|
+
if (!native?.parseClasses) {
|
|
1468
|
+
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
1469
|
+
}
|
|
1470
|
+
return native.parseClasses(raw) || [];
|
|
1471
|
+
};
|
|
1472
|
+
normalizeClasses = (raw) => {
|
|
1473
|
+
const result = normalizeAndDedupClasses(raw);
|
|
1474
|
+
return result?.normalized || "";
|
|
1475
|
+
};
|
|
1476
|
+
mergeClassesStatic = (classes) => {
|
|
1477
|
+
const result = normalizeAndDedupClasses(classes);
|
|
1478
|
+
return result?.normalized || "";
|
|
1479
|
+
};
|
|
1480
|
+
normalizeAndDedupClasses = (raw) => {
|
|
1481
|
+
const native = getNativeBridge();
|
|
1482
|
+
if (!native?.normalizeAndDedupClasses) {
|
|
1483
|
+
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
1484
|
+
}
|
|
1485
|
+
const result = native.normalizeAndDedupClasses(raw);
|
|
1486
|
+
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
1487
|
+
};
|
|
1488
|
+
eliminateDeadCss = (css, deadClasses) => {
|
|
1489
|
+
const native = getNativeBridge();
|
|
1490
|
+
if (!native?.eliminateDeadCss) {
|
|
1491
|
+
throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
|
|
1492
|
+
}
|
|
1493
|
+
return native.eliminateDeadCss(css, Array.from(deadClasses));
|
|
1494
|
+
};
|
|
1495
|
+
findDeadVariants = (variantConfig, usage) => {
|
|
1496
|
+
const unused = [];
|
|
1497
|
+
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
1498
|
+
for (const component of configs) {
|
|
1499
|
+
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
1500
|
+
const variants = component.variants;
|
|
1501
|
+
for (const [key, values] of Object.entries(variants)) {
|
|
1502
|
+
for (const [value] of Object.entries(values)) {
|
|
1503
|
+
if (!componentUsage.has(`${key}:${value}`)) {
|
|
1504
|
+
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
return { unusedCount: unused.length, unused };
|
|
1510
|
+
};
|
|
1511
|
+
runElimination = (css, scanResult) => {
|
|
1512
|
+
const native = getNativeBridge();
|
|
1513
|
+
if (!native?.detectDeadCode) {
|
|
1514
|
+
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
1515
|
+
}
|
|
1516
|
+
const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
|
|
1517
|
+
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
1518
|
+
};
|
|
1519
|
+
optimizeCss = (css) => {
|
|
1520
|
+
const native = getNativeBridge();
|
|
1521
|
+
if (!native?.optimizeCss) {
|
|
1522
|
+
throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
|
|
1523
|
+
}
|
|
1524
|
+
return native.optimizeCss(css);
|
|
1525
|
+
};
|
|
1526
|
+
scanProjectUsage = (dirs, cwd) => {
|
|
1527
|
+
const files = dirs.map((dir) => path9__namespace.default.resolve(cwd, dir));
|
|
1528
|
+
const results = batchExtractClasses(files) || [];
|
|
1529
|
+
const combined = {};
|
|
1530
|
+
for (const result of results) {
|
|
1531
|
+
if (result.ok && result.classes) {
|
|
1532
|
+
for (const cls of result.classes) {
|
|
1533
|
+
if (!combined[cls]) combined[cls] = {};
|
|
1534
|
+
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return combined;
|
|
1539
|
+
};
|
|
1540
|
+
extractComponentUsage = (source) => {
|
|
1541
|
+
const native = getNativeBridge();
|
|
1542
|
+
if (!native?.extractComponentUsage) {
|
|
1543
|
+
throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
|
|
1544
|
+
}
|
|
1545
|
+
return native.extractComponentUsage(source) || [];
|
|
1546
|
+
};
|
|
1547
|
+
diffClassLists = (previous, current) => {
|
|
1548
|
+
const native = getNativeBridge();
|
|
1549
|
+
if (!native?.diffClassLists) {
|
|
1550
|
+
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
1551
|
+
}
|
|
1552
|
+
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
1553
|
+
};
|
|
1554
|
+
batchExtractClasses = (filePaths) => {
|
|
1555
|
+
const native = getNativeBridge();
|
|
1556
|
+
if (!native?.batchExtractClasses) {
|
|
1557
|
+
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
1558
|
+
}
|
|
1559
|
+
return native.batchExtractClasses(filePaths) || [];
|
|
1560
|
+
};
|
|
1561
|
+
checkAgainstSafelist = (classes, safelist) => {
|
|
1562
|
+
const native = getNativeBridge();
|
|
1563
|
+
if (!native?.checkAgainstSafelist) {
|
|
1564
|
+
throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
|
|
1565
|
+
}
|
|
1566
|
+
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
1567
|
+
};
|
|
1568
|
+
hoistComponents = (source) => {
|
|
1569
|
+
const native = getNativeBridge();
|
|
1570
|
+
if (!native?.hoistComponents) {
|
|
1571
|
+
throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
|
|
1572
|
+
}
|
|
1573
|
+
return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
|
|
1574
|
+
};
|
|
1575
|
+
compileVariantTable = (configJson) => {
|
|
1576
|
+
const native = getNativeBridge();
|
|
1577
|
+
if (!native?.compileVariantTable) {
|
|
1578
|
+
throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
|
|
1579
|
+
}
|
|
1580
|
+
return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
|
|
1581
|
+
};
|
|
1582
|
+
compileVariants = (componentId, config) => {
|
|
1583
|
+
return compileVariantTable(JSON.stringify({ componentId, ...config }));
|
|
1584
|
+
};
|
|
1585
|
+
classifyAndSortClasses = (classes) => {
|
|
1586
|
+
const native = getNativeBridge();
|
|
1587
|
+
if (!native?.classifyAndSortClasses) {
|
|
1588
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1589
|
+
}
|
|
1590
|
+
return native.classifyAndSortClasses(classes) || [];
|
|
1591
|
+
};
|
|
1592
|
+
mergeCssDeclarations = (cssChunks) => {
|
|
1593
|
+
const native = getNativeBridge();
|
|
1594
|
+
if (!native?.mergeCssDeclarations) {
|
|
1595
|
+
throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
|
|
1596
|
+
}
|
|
1597
|
+
return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
|
|
1598
|
+
};
|
|
1599
|
+
analyzeClassUsage = (classes, scanResultJson, css) => {
|
|
1600
|
+
const native = getNativeBridge();
|
|
1601
|
+
if (!native?.analyzeClassUsage) {
|
|
1602
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
1603
|
+
}
|
|
1604
|
+
return native.analyzeClassUsage(classes, scanResultJson, css) || [];
|
|
1605
|
+
};
|
|
1606
|
+
analyzeRsc = (source, filename) => {
|
|
1607
|
+
const native = getNativeBridge();
|
|
1608
|
+
if (!native?.analyzeRsc) {
|
|
1609
|
+
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
1610
|
+
}
|
|
1611
|
+
return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
|
|
1612
|
+
};
|
|
1613
|
+
analyzeFile = (source, filename) => {
|
|
1614
|
+
const rsc = analyzeRsc(source, filename);
|
|
1615
|
+
return {
|
|
1616
|
+
isServer: rsc?.isServer ?? true,
|
|
1617
|
+
needsClientDirective: rsc?.needsClientDirective ?? false,
|
|
1618
|
+
clientReasons: rsc?.clientReasons ?? [],
|
|
1619
|
+
interactiveClasses: [],
|
|
1620
|
+
canStaticResolveVariants: true
|
|
1621
|
+
};
|
|
1622
|
+
};
|
|
1623
|
+
analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
|
|
1624
|
+
return { resolved: {}, dynamic: [] };
|
|
1625
|
+
};
|
|
1626
|
+
injectClientDirective = (source) => {
|
|
1627
|
+
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
1628
|
+
return '"use client";\n' + source;
|
|
1629
|
+
}
|
|
1630
|
+
return source;
|
|
1631
|
+
};
|
|
1632
|
+
injectServerOnlyComment = (source) => {
|
|
1633
|
+
return `/* @server-only */
|
|
1634
|
+
${source}`;
|
|
1635
|
+
};
|
|
1636
|
+
analyzeClasses = (filesJson, cwd, flags) => {
|
|
1637
|
+
const native = getNativeBridge();
|
|
1638
|
+
if (!native?.analyzeClasses) {
|
|
1639
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
1640
|
+
}
|
|
1641
|
+
return native.analyzeClasses(filesJson, cwd, flags);
|
|
1642
|
+
};
|
|
1643
|
+
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
1644
|
+
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
1645
|
+
const allClasses = Object.keys(classes).sort();
|
|
1646
|
+
if (outputPath) {
|
|
1647
|
+
fs3__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
1648
|
+
}
|
|
1649
|
+
return allClasses;
|
|
1650
|
+
};
|
|
1651
|
+
loadSafelist = (safelistPath) => {
|
|
1652
|
+
try {
|
|
1653
|
+
const content = fs3__namespace.default.readFileSync(safelistPath, "utf-8");
|
|
1654
|
+
return JSON.parse(content);
|
|
1655
|
+
} catch {
|
|
1656
|
+
return [];
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
1660
|
+
const configFiles = [
|
|
1661
|
+
"tailwind.config.ts",
|
|
1662
|
+
"tailwind.config.js",
|
|
1663
|
+
"tailwind.config.mjs",
|
|
1664
|
+
"tailwind.config.cjs"
|
|
1665
|
+
];
|
|
1666
|
+
for (const file of configFiles) {
|
|
1667
|
+
const fullPath = path9__namespace.default.join(cwd, file);
|
|
1668
|
+
if (fs3__namespace.default.existsSync(fullPath)) {
|
|
1669
|
+
const mod = __require(fullPath);
|
|
1670
|
+
return mod.default || mod;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return {};
|
|
1674
|
+
};
|
|
1675
|
+
getContentPaths = (cwd = process.cwd()) => {
|
|
1676
|
+
return {
|
|
1677
|
+
content: [
|
|
1678
|
+
path9__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
1679
|
+
path9__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
1680
|
+
path9__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
1681
|
+
]
|
|
1682
|
+
};
|
|
1683
|
+
};
|
|
1684
|
+
_CONTAINER_BREAKPOINTS = {
|
|
1685
|
+
xs: "240px",
|
|
1686
|
+
sm: "320px",
|
|
1687
|
+
md: "640px",
|
|
1688
|
+
lg: "1024px",
|
|
1689
|
+
xl: "1280px",
|
|
1690
|
+
"2xl": "1536px"
|
|
1691
|
+
};
|
|
1692
|
+
runLoaderTransform = (ctx) => {
|
|
1693
|
+
const { filepath, source, options } = ctx;
|
|
1694
|
+
const result = transformSource(source, { filename: filepath, ...options });
|
|
1695
|
+
let staticCss;
|
|
1696
|
+
try {
|
|
1697
|
+
const cssChunks = [];
|
|
1698
|
+
const stateRules = extractAndGenerateStateCss(source, filepath);
|
|
1699
|
+
if (stateRules.length > 0) {
|
|
1700
|
+
cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
|
|
1701
|
+
}
|
|
1702
|
+
const containerCss = extractContainerCssFromSource(source);
|
|
1703
|
+
if (containerCss) cssChunks.push(containerCss);
|
|
1704
|
+
const combined = cssChunks.join("\n").trim();
|
|
1705
|
+
if (combined) staticCss = combined;
|
|
1706
|
+
} catch {
|
|
1707
|
+
}
|
|
1708
|
+
return {
|
|
1709
|
+
code: result?.code || "",
|
|
1710
|
+
changed: result?.changed || false,
|
|
1711
|
+
classes: result?.classes || [],
|
|
1712
|
+
staticCss
|
|
1713
|
+
};
|
|
1714
|
+
};
|
|
1715
|
+
shouldSkipFile = (filepath) => {
|
|
1716
|
+
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
1717
|
+
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
1718
|
+
for (const p of SKIP_PATHS) {
|
|
1719
|
+
if (filepath.includes(p)) return true;
|
|
1720
|
+
}
|
|
1721
|
+
for (const ext of skipExtensions) {
|
|
1722
|
+
if (filepath.endsWith(ext)) return true;
|
|
1723
|
+
}
|
|
1724
|
+
return false;
|
|
1725
|
+
};
|
|
1726
|
+
fileToRoute = (filepath) => {
|
|
1727
|
+
const normalized = filepath.replace(/\\/g, "/");
|
|
1728
|
+
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
1729
|
+
return "__global";
|
|
1730
|
+
}
|
|
1731
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
1732
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
1733
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
1734
|
+
if (rootPage) return "/";
|
|
1735
|
+
return null;
|
|
1736
|
+
};
|
|
1737
|
+
getAllRoutes = () => {
|
|
1738
|
+
const native = getNativeBridge();
|
|
1739
|
+
if (!native?.analyzeClasses) {
|
|
1740
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
1741
|
+
}
|
|
1742
|
+
return ["/", "__global"];
|
|
1743
|
+
};
|
|
1744
|
+
getRouteClasses = (_route) => /* @__PURE__ */ new Set();
|
|
1745
|
+
registerFileClasses = (_filepath, _classes) => {
|
|
1746
|
+
};
|
|
1747
|
+
registerGlobalClasses = (_classes) => {
|
|
1748
|
+
};
|
|
1749
|
+
_incrementalEngineInstance = null;
|
|
1750
|
+
getIncrementalEngine = () => {
|
|
1751
|
+
if (!_incrementalEngineInstance) {
|
|
1752
|
+
_incrementalEngineInstance = new IncrementalEngine();
|
|
1753
|
+
}
|
|
1754
|
+
return _incrementalEngineInstance;
|
|
1755
|
+
};
|
|
1756
|
+
resetIncrementalEngine = () => {
|
|
1757
|
+
_incrementalEngineInstance = null;
|
|
1758
|
+
};
|
|
1759
|
+
IncrementalEngine = class {
|
|
1760
|
+
compile(source) {
|
|
1761
|
+
return transformSource(source);
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
getBucketEngine = () => {
|
|
1765
|
+
const native = getNativeBridge();
|
|
1766
|
+
if (!native?.classifyAndSortClasses) {
|
|
1767
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1768
|
+
}
|
|
1769
|
+
return {
|
|
1770
|
+
add: (className) => className,
|
|
1771
|
+
get: (_bucket) => []
|
|
1772
|
+
};
|
|
1773
|
+
};
|
|
1774
|
+
resetBucketEngine = () => {
|
|
1775
|
+
};
|
|
1776
|
+
classifyNode = (_node) => {
|
|
1777
|
+
const native = getNativeBridge();
|
|
1778
|
+
if (!native?.classifyAndSortClasses) {
|
|
1779
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
1780
|
+
}
|
|
1781
|
+
return "unknown";
|
|
1782
|
+
};
|
|
1783
|
+
detectConflicts = (_classes) => {
|
|
1784
|
+
const native = getNativeBridge();
|
|
1785
|
+
if (!native?.analyzeClassUsage) {
|
|
1786
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
1787
|
+
}
|
|
1788
|
+
return [];
|
|
1789
|
+
};
|
|
1790
|
+
bucketSort = (classes) => {
|
|
1791
|
+
return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
|
|
1792
|
+
};
|
|
1793
|
+
extractTwStateConfigs = (source, filename) => {
|
|
1794
|
+
const native = getNativeBridge();
|
|
1795
|
+
if (!native?.extractTwStateConfigs) {
|
|
1796
|
+
throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
|
|
1797
|
+
}
|
|
1798
|
+
return native.extractTwStateConfigs(source, filename);
|
|
1799
|
+
};
|
|
1800
|
+
generateStaticStateCss = (inputs, resolvedCss = null) => {
|
|
1801
|
+
const native = getNativeBridge();
|
|
1802
|
+
if (!native?.generateStaticStateCss) {
|
|
1803
|
+
throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
|
|
1804
|
+
}
|
|
1805
|
+
return native.generateStaticStateCss(inputs, resolvedCss);
|
|
1806
|
+
};
|
|
1807
|
+
extractAndGenerateStateCss = (source, filename) => {
|
|
1808
|
+
const native = getNativeBridge();
|
|
1809
|
+
if (!native?.extractAndGenerateStateCss) {
|
|
1810
|
+
const configs = extractTwStateConfigs(source, filename);
|
|
1811
|
+
if (configs.length === 0) return [];
|
|
1812
|
+
return generateStaticStateCss(
|
|
1813
|
+
configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
// packages/domain/compiler/src/internal.ts
|
|
1822
|
+
var internal_exports = {};
|
|
1823
|
+
__export(internal_exports, {
|
|
1824
|
+
adaptNativeResult: () => adaptNativeResult,
|
|
1825
|
+
analyzeClassUsage: () => analyzeClassUsage,
|
|
1826
|
+
analyzeClasses: () => analyzeClasses,
|
|
1827
|
+
analyzeFile: () => analyzeFile,
|
|
1828
|
+
analyzeRsc: () => analyzeRsc,
|
|
1829
|
+
analyzeVariantUsage: () => analyzeVariantUsage,
|
|
1830
|
+
astExtractClasses: () => astExtractClasses,
|
|
1831
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
1832
|
+
bucketSort: () => bucketSort,
|
|
1833
|
+
buildStyleTag: () => buildStyleTag,
|
|
1834
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
1835
|
+
classifyAndSortClasses: () => classifyAndSortClasses,
|
|
1836
|
+
classifyNode: () => classifyNode,
|
|
1837
|
+
clearCache: () => clearCache,
|
|
1838
|
+
compileCssFromClasses: () => compileCssFromClasses,
|
|
1839
|
+
compileCssNative: () => compileCssNative,
|
|
1840
|
+
compileVariantTable: () => compileVariantTable,
|
|
1841
|
+
compileVariants: () => compileVariants,
|
|
1842
|
+
detectConflicts: () => detectConflicts,
|
|
1843
|
+
diffClassLists: () => diffClassLists,
|
|
1844
|
+
eliminateDeadCss: () => eliminateDeadCss,
|
|
1845
|
+
extractAllClasses: () => extractAllClasses,
|
|
1846
|
+
extractAndGenerateStateCss: () => extractAndGenerateStateCss,
|
|
1847
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
1848
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
1849
|
+
extractContainerCssFromSource: () => extractContainerCssFromSource,
|
|
1850
|
+
extractTwStateConfigs: () => extractTwStateConfigs,
|
|
1851
|
+
fileToRoute: () => fileToRoute,
|
|
1852
|
+
findDeadVariants: () => findDeadVariants,
|
|
1853
|
+
generateCssForClasses: () => generateCssForClasses,
|
|
1854
|
+
generateRawCss: () => generateRawCss,
|
|
1855
|
+
generateSafelist: () => generateSafelist,
|
|
1856
|
+
generateStaticStateCss: () => generateStaticStateCss,
|
|
1857
|
+
getAllRoutes: () => getAllRoutes,
|
|
1858
|
+
getBucketEngine: () => getBucketEngine,
|
|
1859
|
+
getCacheStats: () => getCacheStats,
|
|
1860
|
+
getContentPaths: () => getContentPaths,
|
|
1861
|
+
getIncrementalEngine: () => getIncrementalEngine,
|
|
1862
|
+
getNativeBridge: () => getNativeBridge,
|
|
1863
|
+
getRouteClasses: () => getRouteClasses,
|
|
1864
|
+
hasTwUsage: () => hasTwUsage,
|
|
1865
|
+
hoistComponents: () => hoistComponents,
|
|
1866
|
+
injectClientDirective: () => injectClientDirective,
|
|
1867
|
+
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
1868
|
+
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
1869
|
+
loadSafelist: () => loadSafelist,
|
|
1870
|
+
loadTailwindConfig: () => loadTailwindConfig,
|
|
1871
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
1872
|
+
mergeCssDeclarations: () => mergeCssDeclarations,
|
|
1873
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
1874
|
+
normalizeClasses: () => normalizeClasses,
|
|
1875
|
+
optimizeCss: () => optimizeCss,
|
|
1876
|
+
parseClasses: () => parseClasses,
|
|
1877
|
+
registerFileClasses: () => registerFileClasses,
|
|
1878
|
+
registerGlobalClasses: () => registerGlobalClasses,
|
|
1879
|
+
resetBucketEngine: () => resetBucketEngine,
|
|
1880
|
+
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
1881
|
+
runCssPipeline: () => runCssPipeline,
|
|
1882
|
+
runCssPipelineSync: () => runCssPipelineSync,
|
|
1883
|
+
runElimination: () => runElimination,
|
|
1884
|
+
runLoaderTransform: () => runLoaderTransform,
|
|
1885
|
+
scanProjectUsage: () => scanProjectUsage,
|
|
1886
|
+
shouldProcess: () => shouldProcess,
|
|
1887
|
+
shouldSkipFile: () => shouldSkipFile,
|
|
1888
|
+
transformSource: () => transformSource
|
|
1889
|
+
});
|
|
1890
|
+
var init_internal = __esm({
|
|
1891
|
+
"packages/domain/compiler/src/internal.ts"() {
|
|
1892
|
+
init_src();
|
|
1893
|
+
init_tailwindEngine();
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
function getNative() {
|
|
1897
|
+
if (_native) return _native;
|
|
1898
|
+
try {
|
|
1899
|
+
const mod = (init_internal(), __toCommonJS(internal_exports));
|
|
1900
|
+
if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
|
|
1901
|
+
return null;
|
|
1902
|
+
}
|
|
1903
|
+
_native = {
|
|
1904
|
+
extractTwStateConfigs: mod.extractTwStateConfigs,
|
|
1905
|
+
generateStaticStateCss: mod.generateStaticStateCss,
|
|
1906
|
+
extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
|
|
1907
|
+
((source, filename) => {
|
|
1908
|
+
const configs = mod.extractTwStateConfigs(source, filename);
|
|
1909
|
+
if (configs.length === 0) return [];
|
|
1910
|
+
return mod.generateStaticStateCss(configs.map((c) => ({
|
|
1911
|
+
tag: c.tag,
|
|
1912
|
+
componentName: c.componentName,
|
|
1913
|
+
statesJson: c.statesJson
|
|
1914
|
+
})));
|
|
1915
|
+
})
|
|
1916
|
+
};
|
|
1917
|
+
return _native;
|
|
1918
|
+
} catch {
|
|
1919
|
+
return null;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
function* walkSourceFiles(dir) {
|
|
1923
|
+
let entries;
|
|
1924
|
+
try {
|
|
1925
|
+
entries = fs3__namespace.default.readdirSync(dir, { withFileTypes: true });
|
|
1926
|
+
} catch {
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1929
|
+
for (const entry of entries) {
|
|
1930
|
+
const fullPath = path9__namespace.default.join(dir, entry.name);
|
|
1931
|
+
if (entry.isDirectory()) {
|
|
1932
|
+
if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
|
|
1933
|
+
yield* walkSourceFiles(fullPath);
|
|
1934
|
+
} else if (entry.isFile()) {
|
|
1935
|
+
const ext = path9__namespace.default.extname(entry.name);
|
|
1936
|
+
if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
function buildCssHeader(result) {
|
|
1941
|
+
return [
|
|
1942
|
+
"/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
1943
|
+
" * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
|
|
1944
|
+
" * DO NOT EDIT. Re-generated on each build.",
|
|
1945
|
+
" *",
|
|
1946
|
+
` * Files scanned: ${result.filesScanned}`,
|
|
1947
|
+
` * Files with states: ${result.filesWithStates}`,
|
|
1948
|
+
` * Components found: ${result.componentsFound}`,
|
|
1949
|
+
` * Rules generated: ${result.rulesGenerated}`,
|
|
1950
|
+
` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
|
|
1951
|
+
" *",
|
|
1952
|
+
' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
|
|
1953
|
+
" * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
|
|
1954
|
+
" * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */",
|
|
1955
|
+
""
|
|
1956
|
+
].join("\n");
|
|
1957
|
+
}
|
|
1958
|
+
function extractStaticStateCss(srcDir, options = {}) {
|
|
1959
|
+
const { verbose = false, maxFiles = Infinity } = options;
|
|
1960
|
+
const native = getNative();
|
|
1961
|
+
if (!native) {
|
|
1962
|
+
if (verbose) {
|
|
1963
|
+
process.stderr.write(
|
|
1964
|
+
"[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
return {
|
|
1968
|
+
filesScanned: 0,
|
|
1969
|
+
filesWithStates: 0,
|
|
1970
|
+
componentsFound: 0,
|
|
1971
|
+
rulesGenerated: 0,
|
|
1972
|
+
rulesSkipped: 0,
|
|
1973
|
+
generatedCss: "",
|
|
1974
|
+
rules: []
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
const allConfigs = [];
|
|
1978
|
+
let filesScanned = 0;
|
|
1979
|
+
let filesWithStates = 0;
|
|
1980
|
+
if (native.walkAndPrefilterSourceFiles) {
|
|
1981
|
+
const prefiltered = native.walkAndPrefilterSourceFiles(
|
|
1982
|
+
srcDir,
|
|
1983
|
+
[".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
|
|
1984
|
+
["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
|
|
1985
|
+
// Required substrings — AND logic, identik dengan JS pre-filter di bawah
|
|
1986
|
+
["states:", "tw."],
|
|
1987
|
+
maxFiles === Infinity ? null : maxFiles,
|
|
1988
|
+
null
|
|
1989
|
+
// sequential — parallel mode opsional untuk large monorepo
|
|
1990
|
+
);
|
|
1991
|
+
for (const { path: filePath, content: source } of prefiltered) {
|
|
1992
|
+
filesScanned++;
|
|
1993
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
1994
|
+
if (configs.length > 0) {
|
|
1995
|
+
filesWithStates++;
|
|
1996
|
+
allConfigs.push(...configs);
|
|
1997
|
+
if (verbose) {
|
|
1998
|
+
process.stderr.write(
|
|
1999
|
+
`[tw:static-state] ${path9__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2000
|
+
`
|
|
2001
|
+
);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
} else {
|
|
2006
|
+
for (const filePath of walkSourceFiles(srcDir)) {
|
|
2007
|
+
if (filesScanned >= maxFiles) break;
|
|
2008
|
+
let source;
|
|
2009
|
+
try {
|
|
2010
|
+
source = fs3__namespace.default.readFileSync(filePath, "utf-8");
|
|
2011
|
+
} catch {
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
filesScanned++;
|
|
2015
|
+
if (!source.includes("states:") && !source.includes("states :")) continue;
|
|
2016
|
+
if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
|
|
2017
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
2018
|
+
if (configs.length > 0) {
|
|
2019
|
+
filesWithStates++;
|
|
2020
|
+
allConfigs.push(...configs);
|
|
2021
|
+
if (verbose) {
|
|
2022
|
+
process.stderr.write(
|
|
2023
|
+
`[tw:static-state] ${path9__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2024
|
+
`
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
if (allConfigs.length === 0) {
|
|
2031
|
+
return {
|
|
2032
|
+
filesScanned,
|
|
2033
|
+
filesWithStates: 0,
|
|
2034
|
+
componentsFound: 0,
|
|
2035
|
+
rulesGenerated: 0,
|
|
2036
|
+
rulesSkipped: 0,
|
|
2037
|
+
generatedCss: "",
|
|
2038
|
+
rules: []
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2042
|
+
const uniqueConfigs = [];
|
|
2043
|
+
for (const config of allConfigs) {
|
|
2044
|
+
const key = `${config.tag}::${config.statesJson}`;
|
|
2045
|
+
if (!seen.has(key)) {
|
|
2046
|
+
seen.add(key);
|
|
2047
|
+
uniqueConfigs.push({
|
|
2048
|
+
tag: config.tag,
|
|
2049
|
+
componentName: config.componentName,
|
|
2050
|
+
statesJson: config.statesJson
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
|
|
2055
|
+
const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
|
|
2056
|
+
try {
|
|
2057
|
+
const stateMap = JSON.parse(cfg.statesJson);
|
|
2058
|
+
return total + Object.keys(stateMap).length;
|
|
2059
|
+
} catch {
|
|
2060
|
+
return total;
|
|
2061
|
+
}
|
|
2062
|
+
}, 0) - allRules.length;
|
|
2063
|
+
const byComponent = /* @__PURE__ */ new Map();
|
|
2064
|
+
for (const rule of allRules) {
|
|
2065
|
+
const existing = byComponent.get(rule.componentName) ?? [];
|
|
2066
|
+
existing.push(rule);
|
|
2067
|
+
byComponent.set(rule.componentName, existing);
|
|
2068
|
+
}
|
|
2069
|
+
const cssBlocks = [];
|
|
2070
|
+
for (const [componentName, rules] of byComponent) {
|
|
2071
|
+
cssBlocks.push(`/* ${componentName} */`);
|
|
2072
|
+
for (const rule of rules) {
|
|
2073
|
+
cssBlocks.push(`/* state: ${rule.stateName} */`);
|
|
2074
|
+
cssBlocks.push(rule.cssRule);
|
|
2075
|
+
}
|
|
2076
|
+
cssBlocks.push("");
|
|
2077
|
+
}
|
|
2078
|
+
const result = {
|
|
2079
|
+
filesScanned,
|
|
2080
|
+
filesWithStates,
|
|
2081
|
+
componentsFound: allConfigs.length,
|
|
2082
|
+
rulesGenerated: allRules.length,
|
|
2083
|
+
rulesSkipped: Math.max(0, rulesSkipped),
|
|
2084
|
+
generatedCss: cssBlocks.join("\n"),
|
|
2085
|
+
rules: allRules
|
|
2086
|
+
};
|
|
2087
|
+
result.generatedCss = buildCssHeader(result) + result.generatedCss;
|
|
2088
|
+
return result;
|
|
2089
|
+
}
|
|
2090
|
+
function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
2091
|
+
const result = extractStaticStateCss(srcDir, options);
|
|
2092
|
+
const twClassesDir = path9__namespace.default.join(path9__namespace.default.dirname(safelistPath), "tw-classes");
|
|
2093
|
+
fs3__namespace.default.mkdirSync(twClassesDir, { recursive: true });
|
|
2094
|
+
const stateFilePath = path9__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
2095
|
+
if (result.rulesGenerated === 0) {
|
|
2096
|
+
try {
|
|
2097
|
+
fs3__namespace.default.writeFileSync(
|
|
2098
|
+
stateFilePath,
|
|
2099
|
+
"/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
|
|
2100
|
+
"utf-8"
|
|
2101
|
+
);
|
|
2102
|
+
} catch {
|
|
2103
|
+
}
|
|
2104
|
+
return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
|
|
2105
|
+
}
|
|
2106
|
+
try {
|
|
2107
|
+
fs3__namespace.default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
|
|
2108
|
+
return [
|
|
2109
|
+
`[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
|
|
2110
|
+
` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
|
|
2111
|
+
` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
|
|
2112
|
+
` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
|
|
2113
|
+
].join("\n");
|
|
2114
|
+
} catch (writeErr) {
|
|
2115
|
+
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
2116
|
+
return `[tw:static-state] gagal tulis state CSS: ${msg}`;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
|
|
2120
|
+
var init_staticStateExtractor = __esm({
|
|
2121
|
+
"packages/domain/shared/src/staticStateExtractor.ts"() {
|
|
2122
|
+
SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
|
|
2123
|
+
IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
|
|
2124
|
+
_native = null;
|
|
2125
|
+
TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
function getEnvLevel() {
|
|
2129
|
+
const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
|
|
2130
|
+
if (env && env in LEVELS) return env;
|
|
2131
|
+
return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
|
|
2132
|
+
}
|
|
2133
|
+
function setGlobalLogFile(filePath) {
|
|
2134
|
+
_globalLogFile = filePath;
|
|
2135
|
+
_logFileInitialized = false;
|
|
2136
|
+
try {
|
|
2137
|
+
fs3__namespace.default.mkdirSync(path9__namespace.default.dirname(filePath), { recursive: true });
|
|
2138
|
+
fs3__namespace.default.writeFileSync(
|
|
2139
|
+
filePath,
|
|
2140
|
+
`# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2141
|
+
`,
|
|
2142
|
+
"utf-8"
|
|
2143
|
+
);
|
|
2144
|
+
_logFileInitialized = true;
|
|
2145
|
+
} catch {
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function writeToFile(line) {
|
|
2149
|
+
if (!_globalLogFile || !_logFileInitialized) return;
|
|
2150
|
+
try {
|
|
2151
|
+
fs3__namespace.default.appendFileSync(_globalLogFile, line);
|
|
2152
|
+
} catch {
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
function createLogger(prefix, level) {
|
|
2156
|
+
const loggerState = {
|
|
2157
|
+
currentLevel: getEnvLevel(),
|
|
2158
|
+
setLevel(l) {
|
|
2159
|
+
this.currentLevel = l;
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2162
|
+
const log8 = (msgLevel, stream, args) => {
|
|
2163
|
+
if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
|
|
2164
|
+
const line = `[${prefix}] ${args.map(String).join(" ")}
|
|
2165
|
+
`;
|
|
2166
|
+
process[stream].write(line);
|
|
2167
|
+
writeToFile(line);
|
|
2168
|
+
};
|
|
2169
|
+
return {
|
|
2170
|
+
error: (...a) => log8("error", "stderr", a),
|
|
2171
|
+
warn: (...a) => log8("warn", "stderr", a),
|
|
2172
|
+
info: (...a) => log8("info", "stdout", a),
|
|
2173
|
+
debug: (...a) => log8("debug", "stderr", a),
|
|
2174
|
+
setLevel: loggerState.setLevel,
|
|
2175
|
+
setLogFile: (filePath) => setGlobalLogFile(filePath)
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
var LEVELS, _globalLogFile, _logFileInitialized;
|
|
2179
|
+
var init_logger = __esm({
|
|
2180
|
+
"packages/domain/shared/src/logger.ts"() {
|
|
2181
|
+
LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
2182
|
+
_globalLogFile = null;
|
|
2183
|
+
_logFileInitialized = false;
|
|
2184
|
+
createLogger("tailwind-styled");
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2187
|
+
|
|
1012
2188
|
// packages/domain/shared/src/index.ts
|
|
1013
2189
|
var src_exports = {};
|
|
1014
2190
|
__export(src_exports, {
|
|
@@ -1027,18 +2203,21 @@ __export(src_exports, {
|
|
|
1027
2203
|
RegistryPluginEntrySchema: () => RegistryPluginEntrySchema,
|
|
1028
2204
|
ScanCacheClassEntrySchema: () => ScanCacheClassEntrySchema,
|
|
1029
2205
|
ScanCacheSchema: () => ScanCacheSchema,
|
|
2206
|
+
TW_STATE_STATIC_FILENAME: () => TW_STATE_STATIC_FILENAME,
|
|
1030
2207
|
TailwindConfigSchema: () => TailwindConfigSchema,
|
|
1031
2208
|
TelemetryCollector: () => TelemetryCollector,
|
|
1032
2209
|
TwError: () => TwError,
|
|
2210
|
+
appendStaticStateCssToSafelist: () => appendStaticStateCssToSafelist,
|
|
1033
2211
|
assertTailwindV4: () => assertTailwindV4,
|
|
1034
2212
|
calculateHealth: () => calculateHealth,
|
|
1035
2213
|
createBuildTimer: () => createBuildTimer,
|
|
1036
2214
|
createDebugLogger: () => createDebugLogger,
|
|
1037
2215
|
createEsmRequire: () => createEsmRequire,
|
|
1038
|
-
createLogger: () =>
|
|
2216
|
+
createLogger: () => createLogger2,
|
|
1039
2217
|
createObservabilityClient: () => createObservabilityClient,
|
|
1040
2218
|
createTraceSnapshot: () => createTraceSnapshot,
|
|
1041
2219
|
detectTailwind: () => detectTailwind,
|
|
2220
|
+
extractStaticStateCss: () => extractStaticStateCss,
|
|
1042
2221
|
formatDuration: () => formatDuration,
|
|
1043
2222
|
formatErrorCode: () => formatErrorCode,
|
|
1044
2223
|
formatErrorMessage: () => formatErrorMessage,
|
|
@@ -1074,10 +2253,11 @@ __export(src_exports, {
|
|
|
1074
2253
|
resolveRuntimeDir: () => resolveRuntimeDir,
|
|
1075
2254
|
resolveWorkerPath: () => resolveWorkerPath,
|
|
1076
2255
|
safeParseNative: () => safeParseNative,
|
|
2256
|
+
setGlobalLogFile: () => setGlobalLogFile,
|
|
1077
2257
|
tryRequire: () => tryRequire,
|
|
1078
2258
|
wrapUnknownError: () => wrapUnknownError
|
|
1079
2259
|
});
|
|
1080
|
-
function
|
|
2260
|
+
function createLogger2(namespace) {
|
|
1081
2261
|
const prefix = `[${namespace}]`;
|
|
1082
2262
|
return {
|
|
1083
2263
|
warn(...args) {
|
|
@@ -1106,9 +2286,9 @@ function createDebugLogger(namespace, label) {
|
|
|
1106
2286
|
}
|
|
1107
2287
|
};
|
|
1108
2288
|
}
|
|
1109
|
-
function formatIssuePath(
|
|
1110
|
-
if (!
|
|
1111
|
-
return
|
|
2289
|
+
function formatIssuePath(path16) {
|
|
2290
|
+
if (!path16 || path16.length === 0) return "(root)";
|
|
2291
|
+
return path16.map(
|
|
1112
2292
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1113
2293
|
).join(".");
|
|
1114
2294
|
}
|
|
@@ -1122,9 +2302,9 @@ function loadNativeBinding(options) {
|
|
|
1122
2302
|
const { runtimeDir, candidates, isValid } = options;
|
|
1123
2303
|
const loadErrors = [];
|
|
1124
2304
|
for (const candidate of candidates) {
|
|
1125
|
-
const candidatePath =
|
|
2305
|
+
const candidatePath = path9__namespace.default.resolve(runtimeDir, candidate);
|
|
1126
2306
|
try {
|
|
1127
|
-
if (!
|
|
2307
|
+
if (!fs3__namespace.default.existsSync(candidatePath) && !fs3__namespace.default.existsSync(candidatePath + ".node")) {
|
|
1128
2308
|
continue;
|
|
1129
2309
|
}
|
|
1130
2310
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1156,9 +2336,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1156
2336
|
}
|
|
1157
2337
|
}
|
|
1158
2338
|
if (!includeDefaultCandidates) return candidates;
|
|
1159
|
-
if (
|
|
2339
|
+
if (fs3__namespace.default.existsSync(runtimeDir)) {
|
|
1160
2340
|
try {
|
|
1161
|
-
for (const entry of
|
|
2341
|
+
for (const entry of fs3__namespace.default.readdirSync(runtimeDir)) {
|
|
1162
2342
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1163
2343
|
}
|
|
1164
2344
|
} catch {
|
|
@@ -1167,22 +2347,22 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1167
2347
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
1168
2348
|
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
1169
2349
|
for (const bin of BINARY_NAMES) {
|
|
1170
|
-
candidates.push(
|
|
1171
|
-
candidates.push(
|
|
1172
|
-
candidates.push(
|
|
1173
|
-
candidates.push(
|
|
1174
|
-
candidates.push(
|
|
1175
|
-
candidates.push(
|
|
1176
|
-
candidates.push(
|
|
1177
|
-
candidates.push(
|
|
1178
|
-
candidates.push(
|
|
2350
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, `${bin}.node`));
|
|
2351
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
2352
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
2353
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
2354
|
+
candidates.push(path9__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
2355
|
+
candidates.push(path9__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
2356
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
2357
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
2358
|
+
candidates.push(path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1179
2359
|
}
|
|
1180
2360
|
return Array.from(new Set(candidates));
|
|
1181
2361
|
}
|
|
1182
2362
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
1183
|
-
if (dir) return
|
|
2363
|
+
if (dir) return path9__namespace.default.resolve(dir);
|
|
1184
2364
|
try {
|
|
1185
|
-
return
|
|
2365
|
+
return path9__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
|
|
1186
2366
|
} catch {
|
|
1187
2367
|
return process.cwd();
|
|
1188
2368
|
}
|
|
@@ -1197,7 +2377,7 @@ function formatErrorMessage(error) {
|
|
|
1197
2377
|
return String(error);
|
|
1198
2378
|
}
|
|
1199
2379
|
var TwError, _require2, LRUCache;
|
|
1200
|
-
var
|
|
2380
|
+
var init_src2 = __esm({
|
|
1201
2381
|
"packages/domain/shared/src/index.ts"() {
|
|
1202
2382
|
init_trace();
|
|
1203
2383
|
init_error_codes();
|
|
@@ -1210,6 +2390,8 @@ var init_src = __esm({
|
|
|
1210
2390
|
init_codegen();
|
|
1211
2391
|
init_native_resolution();
|
|
1212
2392
|
init_observability();
|
|
2393
|
+
init_staticStateExtractor();
|
|
2394
|
+
init_logger();
|
|
1213
2395
|
TwError = class _TwError extends Error {
|
|
1214
2396
|
/** @deprecated Gunakan source */
|
|
1215
2397
|
domain;
|
|
@@ -1243,8 +2425,8 @@ var init_src = __esm({
|
|
|
1243
2425
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
1244
2426
|
static fromZod(err) {
|
|
1245
2427
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
1246
|
-
const
|
|
1247
|
-
const message = first ? `${
|
|
2428
|
+
const path16 = formatIssuePath(first?.path);
|
|
2429
|
+
const message = first ? `${path16}: ${first.message}` : "Schema validation failed";
|
|
1248
2430
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
1249
2431
|
}
|
|
1250
2432
|
static wrap(source, code, err) {
|
|
@@ -1341,7 +2523,7 @@ function getDirname2() {
|
|
|
1341
2523
|
return __dirname;
|
|
1342
2524
|
}
|
|
1343
2525
|
if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))) {
|
|
1344
|
-
return
|
|
2526
|
+
return path9__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))));
|
|
1345
2527
|
}
|
|
1346
2528
|
return process.cwd();
|
|
1347
2529
|
}
|
|
@@ -1546,11 +2728,11 @@ function hasNativeWatchBinding() {
|
|
|
1546
2728
|
return false;
|
|
1547
2729
|
}
|
|
1548
2730
|
}
|
|
1549
|
-
var
|
|
2731
|
+
var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
|
|
1550
2732
|
var init_native_bridge = __esm({
|
|
1551
2733
|
"packages/domain/scanner/src/native-bridge.ts"() {
|
|
1552
|
-
|
|
1553
|
-
|
|
2734
|
+
init_src2();
|
|
2735
|
+
log2 = createDebugLogger("scanner:native");
|
|
1554
2736
|
isValidScannerBinding = (module) => {
|
|
1555
2737
|
const candidate = module;
|
|
1556
2738
|
return !!(candidate && (candidate.scanWorkspace || candidate.extractClassesFromSource || candidate.hashFileContent || candidate.cacheRead || candidate.cacheWrite));
|
|
@@ -1604,7 +2786,7 @@ var init_native_bridge = __esm({
|
|
|
1604
2786
|
invalidExportMessage: "Module loaded but missing expected scanner binding functions"
|
|
1605
2787
|
});
|
|
1606
2788
|
if (binding) {
|
|
1607
|
-
|
|
2789
|
+
log2(`scanner native binding loaded successfully`);
|
|
1608
2790
|
_state.binding = binding;
|
|
1609
2791
|
return _state.binding;
|
|
1610
2792
|
}
|
|
@@ -1630,12 +2812,12 @@ var init_native_bridge = __esm({
|
|
|
1630
2812
|
}
|
|
1631
2813
|
});
|
|
1632
2814
|
function defaultCachePath(rootDir, cacheDir) {
|
|
1633
|
-
const dir = cacheDir ?
|
|
1634
|
-
return
|
|
2815
|
+
const dir = cacheDir ? path9__namespace.default.resolve(rootDir, cacheDir) : path9__namespace.default.join(process.cwd(), ".cache", "tailwind-styled");
|
|
2816
|
+
return path9__namespace.default.join(dir, "scanner-cache.json");
|
|
1635
2817
|
}
|
|
1636
2818
|
function readCache(rootDir, cacheDir) {
|
|
1637
2819
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1638
|
-
|
|
2820
|
+
fs3__namespace.default.mkdirSync(path9__namespace.default.dirname(cachePath), { recursive: true });
|
|
1639
2821
|
const result = cacheReadNative(cachePath);
|
|
1640
2822
|
if (!result) return [];
|
|
1641
2823
|
return result.entries.map((e) => ({
|
|
@@ -1650,7 +2832,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1650
2832
|
}
|
|
1651
2833
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1652
2834
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1653
|
-
|
|
2835
|
+
fs3__namespace.default.mkdirSync(path9__namespace.default.dirname(cachePath), { recursive: true });
|
|
1654
2836
|
const success = cacheWriteNative(cachePath, entries);
|
|
1655
2837
|
if (!success) {
|
|
1656
2838
|
throw new Error(
|
|
@@ -1677,27 +2859,7 @@ var init_cache_native = __esm({
|
|
|
1677
2859
|
function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
1678
2860
|
const native = collectFilesNative(rootDir, extensions, ignoreDirs);
|
|
1679
2861
|
if (native !== null) return native;
|
|
1680
|
-
|
|
1681
|
-
function walk(dir) {
|
|
1682
|
-
let entries;
|
|
1683
|
-
try {
|
|
1684
|
-
entries = fs5__namespace.default.readdirSync(dir, { withFileTypes: true });
|
|
1685
|
-
} catch {
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
for (const entry of entries) {
|
|
1689
|
-
const fullPath = path6__namespace.default.join(dir, entry.name);
|
|
1690
|
-
const rel = path6__namespace.default.relative(rootDir, fullPath);
|
|
1691
|
-
if (entry.isDirectory()) {
|
|
1692
|
-
const ignored = ignoreDirs.some((d) => entry.name === d || rel.startsWith(d + path6__namespace.default.sep));
|
|
1693
|
-
if (!ignored) walk(fullPath);
|
|
1694
|
-
} else if (isScannableFile(entry.name, extensions)) {
|
|
1695
|
-
files.push(fullPath);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
walk(rootDir);
|
|
1700
|
-
return files;
|
|
2862
|
+
throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
|
|
1701
2863
|
}
|
|
1702
2864
|
function mergeResults(batchResults) {
|
|
1703
2865
|
const files = batchResults.map((r) => ({
|
|
@@ -1707,8 +2869,7 @@ function mergeResults(batchResults) {
|
|
|
1707
2869
|
}));
|
|
1708
2870
|
const native = rebuildWorkspaceResultNative(files);
|
|
1709
2871
|
if (native) return native;
|
|
1710
|
-
|
|
1711
|
-
return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
|
|
2872
|
+
throw new Error("FATAL: Native binding 'rebuildWorkspaceResult' is required but not available.");
|
|
1712
2873
|
}
|
|
1713
2874
|
function runChunkInWorker(filePaths) {
|
|
1714
2875
|
return new Promise((resolve2, reject) => {
|
|
@@ -1735,7 +2896,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1735
2896
|
maxWorkers = Math.max(1, os.availableParallelism() - 1),
|
|
1736
2897
|
chunkSize = DEFAULT_CHUNK_SIZE
|
|
1737
2898
|
} = options;
|
|
1738
|
-
const files = collectFiles(
|
|
2899
|
+
const files = collectFiles(path9__namespace.default.resolve(rootDir), extensions, ignoreDirs);
|
|
1739
2900
|
if (files.length < PARALLEL_THRESHOLD) {
|
|
1740
2901
|
return mergeResults(batchExtractClassesNative(files));
|
|
1741
2902
|
}
|
|
@@ -1754,7 +2915,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1754
2915
|
var PARALLEL_THRESHOLD, DEFAULT_CHUNK_SIZE, _workerFilename;
|
|
1755
2916
|
var init_parallel_scanner = __esm({
|
|
1756
2917
|
"packages/domain/scanner/src/parallel-scanner.ts"() {
|
|
1757
|
-
|
|
2918
|
+
init_src3();
|
|
1758
2919
|
init_native_bridge();
|
|
1759
2920
|
PARALLEL_THRESHOLD = 50;
|
|
1760
2921
|
DEFAULT_CHUNK_SIZE = 150;
|
|
@@ -1778,13 +2939,13 @@ var init_parallel_scanner = __esm({
|
|
|
1778
2939
|
var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, ScanWorkspaceOptionsSchema, ScanFileResultSchema, ScanWorkspaceResultSchema, ScannerWorkerSuccessMessageSchema, ScannerWorkerErrorMessageSchema, ScannerWorkerMessageSchema, parseScanWorkspaceOptions, parseScanWorkspaceResult, parseScannerWorkerMessage;
|
|
1779
2940
|
var init_schemas = __esm({
|
|
1780
2941
|
"packages/domain/scanner/src/schemas.ts"() {
|
|
1781
|
-
|
|
1782
|
-
formatIssuePath2 = (
|
|
2942
|
+
init_src2();
|
|
2943
|
+
formatIssuePath2 = (path16) => path16.length > 0 ? path16.map(
|
|
1783
2944
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1784
2945
|
).join(".") : "<root>";
|
|
1785
2946
|
formatIssues = (error) => error.issues.map((issue) => {
|
|
1786
|
-
const
|
|
1787
|
-
return `${
|
|
2947
|
+
const path16 = formatIssuePath2(issue.path);
|
|
2948
|
+
return `${path16}: ${issue.message}`;
|
|
1788
2949
|
}).join("; ");
|
|
1789
2950
|
parseWithSchema = (schema, data, label) => {
|
|
1790
2951
|
const parsed = schema.safeParse(data);
|
|
@@ -1847,7 +3008,7 @@ __export(src_exports2, {
|
|
|
1847
3008
|
DEFAULT_IGNORES: () => DEFAULT_IGNORES,
|
|
1848
3009
|
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
1849
3010
|
extractClassesNative: () => extractClassesNative,
|
|
1850
|
-
isScannableFile: () =>
|
|
3011
|
+
isScannableFile: () => isScannableFile2,
|
|
1851
3012
|
parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
|
|
1852
3013
|
parseScanWorkspaceResult: () => parseScanWorkspaceResult,
|
|
1853
3014
|
parseScannerWorkerMessage: () => parseScannerWorkerMessage,
|
|
@@ -1861,7 +3022,7 @@ function getRuntimeDir() {
|
|
|
1861
3022
|
return __dirname;
|
|
1862
3023
|
}
|
|
1863
3024
|
if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))) {
|
|
1864
|
-
return
|
|
3025
|
+
return path9__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))));
|
|
1865
3026
|
}
|
|
1866
3027
|
return process.cwd();
|
|
1867
3028
|
}
|
|
@@ -1871,17 +3032,17 @@ function resolveScannerWorkerModulePath() {
|
|
|
1871
3032
|
return __dirname;
|
|
1872
3033
|
}
|
|
1873
3034
|
if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))) {
|
|
1874
|
-
return
|
|
3035
|
+
return path9__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href))));
|
|
1875
3036
|
}
|
|
1876
3037
|
return process.cwd();
|
|
1877
3038
|
})();
|
|
1878
3039
|
const candidates = [
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
3040
|
+
path9__namespace.default.resolve(runtimeDir, "worker.cjs"),
|
|
3041
|
+
path9__namespace.default.resolve(runtimeDir, "worker.js"),
|
|
3042
|
+
path9__namespace.default.resolve(runtimeDir, "worker.ts")
|
|
1882
3043
|
];
|
|
1883
3044
|
for (const candidate of candidates) {
|
|
1884
|
-
if (
|
|
3045
|
+
if (fs3__namespace.default.existsSync(candidate)) return candidate;
|
|
1885
3046
|
}
|
|
1886
3047
|
return null;
|
|
1887
3048
|
}
|
|
@@ -1938,19 +3099,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
1938
3099
|
if (!currentDir) continue;
|
|
1939
3100
|
const entries = (() => {
|
|
1940
3101
|
try {
|
|
1941
|
-
return
|
|
3102
|
+
return fs3__namespace.default.readdirSync(currentDir, { withFileTypes: true });
|
|
1942
3103
|
} catch {
|
|
1943
3104
|
return [];
|
|
1944
3105
|
}
|
|
1945
3106
|
})();
|
|
1946
3107
|
for (const entry of entries) {
|
|
1947
|
-
const fullPath =
|
|
3108
|
+
const fullPath = path9__namespace.default.join(currentDir, entry.name);
|
|
1948
3109
|
if (entry.isDirectory()) {
|
|
1949
3110
|
if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
|
|
1950
3111
|
continue;
|
|
1951
3112
|
}
|
|
1952
3113
|
if (!entry.isFile()) continue;
|
|
1953
|
-
if (!extensionSet.has(
|
|
3114
|
+
if (!extensionSet.has(path9__namespace.default.extname(entry.name))) continue;
|
|
1954
3115
|
candidates.push(fullPath);
|
|
1955
3116
|
}
|
|
1956
3117
|
}
|
|
@@ -1976,8 +3137,8 @@ function scanSource(source) {
|
|
|
1976
3137
|
"FATAL: Native parser binding is required but not available.\nThis package requires native Rust bindings.\n\nResolution steps:\n1. Build the native Rust module: npm run build:rust"
|
|
1977
3138
|
);
|
|
1978
3139
|
}
|
|
1979
|
-
function
|
|
1980
|
-
return includeExtensions.includes(
|
|
3140
|
+
function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
|
|
3141
|
+
return includeExtensions.includes(path9__namespace.default.extname(filePath));
|
|
1981
3142
|
}
|
|
1982
3143
|
function scanFile(filePath) {
|
|
1983
3144
|
const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
|
|
@@ -2025,7 +3186,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2025
3186
|
try {
|
|
2026
3187
|
return readCache(rootDir, normalizedOptions.cacheDir);
|
|
2027
3188
|
} catch (error) {
|
|
2028
|
-
|
|
3189
|
+
log3.debug(
|
|
2029
3190
|
`cache read failed, continuing without persisted cache: ${error instanceof Error ? error.message : String(error)}`
|
|
2030
3191
|
);
|
|
2031
3192
|
return [];
|
|
@@ -2037,7 +3198,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2037
3198
|
for (const filePath of candidates) {
|
|
2038
3199
|
const stat = (() => {
|
|
2039
3200
|
try {
|
|
2040
|
-
return
|
|
3201
|
+
return fs3__namespace.default.statSync(filePath);
|
|
2041
3202
|
} catch {
|
|
2042
3203
|
return null;
|
|
2043
3204
|
}
|
|
@@ -2063,7 +3224,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2063
3224
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
2064
3225
|
const content = (() => {
|
|
2065
3226
|
try {
|
|
2066
|
-
return
|
|
3227
|
+
return fs3__namespace.default.readFileSync(filePath, "utf8");
|
|
2067
3228
|
} catch {
|
|
2068
3229
|
return null;
|
|
2069
3230
|
}
|
|
@@ -2071,7 +3232,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2071
3232
|
if (!content) continue;
|
|
2072
3233
|
const hash = hashContentNative(content);
|
|
2073
3234
|
if (cached && cached.hash === hash && cached.mtimeMs === stat.mtimeMs && cached.size === size) {
|
|
2074
|
-
|
|
3235
|
+
log3.debug(`cache HIT ${filePath}`);
|
|
2075
3236
|
processResult({ file: filePath, classes: cached.classes });
|
|
2076
3237
|
updatedEntries.push({
|
|
2077
3238
|
file: filePath,
|
|
@@ -2083,7 +3244,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2083
3244
|
});
|
|
2084
3245
|
continue;
|
|
2085
3246
|
}
|
|
2086
|
-
|
|
3247
|
+
log3.debug(`cache MISS ${filePath}`);
|
|
2087
3248
|
const classes = scanSource(content);
|
|
2088
3249
|
processResult({ file: filePath, classes });
|
|
2089
3250
|
updatedEntries.push({
|
|
@@ -2098,7 +3259,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2098
3259
|
try {
|
|
2099
3260
|
writeCache(rootDir, updatedEntries, normalizedOptions.cacheDir);
|
|
2100
3261
|
} catch (error) {
|
|
2101
|
-
|
|
3262
|
+
log3.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
2102
3263
|
}
|
|
2103
3264
|
return parseScanWorkspaceResult({
|
|
2104
3265
|
files,
|
|
@@ -2131,30 +3292,30 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
|
|
|
2131
3292
|
ignoreDirs: normalizedOptions.ignoreDirectories
|
|
2132
3293
|
});
|
|
2133
3294
|
} catch (parallelError) {
|
|
2134
|
-
|
|
3295
|
+
log3.debug(
|
|
2135
3296
|
`parallel scan failed, retrying with single worker: ${parallelError instanceof Error ? parallelError.message : String(parallelError)}`
|
|
2136
3297
|
);
|
|
2137
3298
|
}
|
|
2138
3299
|
try {
|
|
2139
3300
|
return await scanWorkspaceInWorker(rootDir, normalizedOptions);
|
|
2140
3301
|
} catch (error) {
|
|
2141
|
-
|
|
3302
|
+
log3.debug(
|
|
2142
3303
|
`worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
|
|
2143
3304
|
);
|
|
2144
3305
|
return scanWorkspace(rootDir, normalizedOptions);
|
|
2145
3306
|
}
|
|
2146
3307
|
}
|
|
2147
|
-
var
|
|
2148
|
-
var
|
|
3308
|
+
var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
|
|
3309
|
+
var init_src3 = __esm({
|
|
2149
3310
|
"packages/domain/scanner/src/index.ts"() {
|
|
2150
|
-
|
|
3311
|
+
init_src2();
|
|
2151
3312
|
init_cache_native();
|
|
2152
3313
|
init_native_bridge();
|
|
2153
3314
|
init_parallel_scanner();
|
|
2154
3315
|
init_schemas();
|
|
2155
3316
|
init_schemas();
|
|
2156
3317
|
init_native_bridge();
|
|
2157
|
-
|
|
3318
|
+
log3 = createLogger2("scanner");
|
|
2158
3319
|
SCAN_WORKER_TIMEOUT_MS = 12e4;
|
|
2159
3320
|
createNativeParserLoader = () => {
|
|
2160
3321
|
const _state = {
|
|
@@ -2162,12 +3323,12 @@ var init_src2 = __esm({
|
|
|
2162
3323
|
initError: null
|
|
2163
3324
|
};
|
|
2164
3325
|
const debugNative = (message) => {
|
|
2165
|
-
|
|
3326
|
+
log3.debug(`[native] ${message}`);
|
|
2166
3327
|
};
|
|
2167
3328
|
const loadNativeParserBinding = () => {
|
|
2168
3329
|
if (_state.binding !== void 0) return _state.binding;
|
|
2169
3330
|
const runtimeDir = getRuntimeDir();
|
|
2170
|
-
const req = module$1.createRequire(
|
|
3331
|
+
const req = module$1.createRequire(path9__namespace.default.join(runtimeDir, "noop.cjs"));
|
|
2171
3332
|
const _platform = process.platform;
|
|
2172
3333
|
const _arch = process.arch;
|
|
2173
3334
|
const _platformArch = `${_platform}-${_arch}`;
|
|
@@ -2175,27 +3336,27 @@ var init_src2 = __esm({
|
|
|
2175
3336
|
const candidates = [
|
|
2176
3337
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2177
3338
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
3339
|
+
path9__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
3340
|
+
path9__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3341
|
+
path9__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2181
3342
|
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2182
3343
|
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
3344
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
3345
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3346
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2186
3347
|
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2187
|
-
|
|
2188
|
-
|
|
3348
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3349
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2189
3350
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2190
|
-
|
|
2191
|
-
|
|
3351
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3352
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2192
3353
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
3354
|
+
path9__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
3355
|
+
path9__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
3356
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
3357
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3358
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3359
|
+
path9__namespace.default.resolve(
|
|
2199
3360
|
runtimeDir,
|
|
2200
3361
|
"..",
|
|
2201
3362
|
"..",
|
|
@@ -2207,7 +3368,7 @@ var init_src2 = __esm({
|
|
|
2207
3368
|
)
|
|
2208
3369
|
];
|
|
2209
3370
|
for (const fullPath of candidates) {
|
|
2210
|
-
if (!
|
|
3371
|
+
if (!fs3__namespace.default.existsSync(fullPath)) continue;
|
|
2211
3372
|
try {
|
|
2212
3373
|
const required = req(fullPath);
|
|
2213
3374
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2240,168 +3401,6 @@ var init_src2 = __esm({
|
|
|
2240
3401
|
}
|
|
2241
3402
|
});
|
|
2242
3403
|
|
|
2243
|
-
// packages/domain/compiler/src/nativeBridge.ts
|
|
2244
|
-
var _loadNative, log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
2245
|
-
var init_nativeBridge = __esm({
|
|
2246
|
-
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
2247
|
-
init_src();
|
|
2248
|
-
_loadNative = (path13) => __require(path13);
|
|
2249
|
-
log3 = (...args) => {
|
|
2250
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
2251
|
-
console.log("[compiler:native]", ...args);
|
|
2252
|
-
}
|
|
2253
|
-
};
|
|
2254
|
-
NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
|
|
2255
|
-
nativeBridge = null;
|
|
2256
|
-
bridgeLoadAttempted = false;
|
|
2257
|
-
bridgeLoadError = null;
|
|
2258
|
-
isValidNativeBridge = (mod) => {
|
|
2259
|
-
const m = mod;
|
|
2260
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
2261
|
-
};
|
|
2262
|
-
getNativeBridge = () => {
|
|
2263
|
-
if (nativeBridge) {
|
|
2264
|
-
return nativeBridge;
|
|
2265
|
-
}
|
|
2266
|
-
if (bridgeLoadAttempted) {
|
|
2267
|
-
if (bridgeLoadError) {
|
|
2268
|
-
throw bridgeLoadError;
|
|
2269
|
-
}
|
|
2270
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
2271
|
-
}
|
|
2272
|
-
bridgeLoadAttempted = true;
|
|
2273
|
-
try {
|
|
2274
|
-
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
2275
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
2276
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
2277
|
-
try {
|
|
2278
|
-
const binding = _loadNative(result.path);
|
|
2279
|
-
if (isValidNativeBridge(binding)) {
|
|
2280
|
-
nativeBridge = binding;
|
|
2281
|
-
log3("Native bridge loaded successfully from:", result.path);
|
|
2282
|
-
return nativeBridge;
|
|
2283
|
-
}
|
|
2284
|
-
} catch (e) {
|
|
2285
|
-
log3("Failed to require native binding:", e);
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
2289
|
-
|
|
2290
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
2291
|
-
} catch (err) {
|
|
2292
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
2293
|
-
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
2294
|
-
throw bridgeLoadError;
|
|
2295
|
-
}
|
|
2296
|
-
};
|
|
2297
|
-
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
2298
|
-
try {
|
|
2299
|
-
getNativeBridge();
|
|
2300
|
-
} catch {
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
});
|
|
2305
|
-
|
|
2306
|
-
// packages/domain/compiler/src/tailwindEngine.ts
|
|
2307
|
-
var tailwindEngine_exports = {};
|
|
2308
|
-
__export(tailwindEngine_exports, {
|
|
2309
|
-
generateRawCss: () => generateRawCss,
|
|
2310
|
-
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
2311
|
-
runCssPipeline: () => runCssPipeline,
|
|
2312
|
-
runCssPipelineSync: () => runCssPipelineSync
|
|
2313
|
-
});
|
|
2314
|
-
function loadTailwindEngine() {
|
|
2315
|
-
if (_twEngine) return _twEngine;
|
|
2316
|
-
if (_twEngineError) throw _twEngineError;
|
|
2317
|
-
try {
|
|
2318
|
-
const tw = require2("tailwindcss");
|
|
2319
|
-
if (typeof tw.compile !== "function") {
|
|
2320
|
-
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
2321
|
-
}
|
|
2322
|
-
_twEngine = tw;
|
|
2323
|
-
return _twEngine;
|
|
2324
|
-
} catch (e) {
|
|
2325
|
-
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
2326
|
-
throw _twEngineError;
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
async function generateRawCss(classes, cssEntryContent, root) {
|
|
2330
|
-
if (classes.length === 0) return "";
|
|
2331
|
-
const tw = loadTailwindEngine();
|
|
2332
|
-
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
2333
|
-
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
2334
|
-
const { dirname, resolve: resolve2 } = await import('path');
|
|
2335
|
-
const projectRoot = root ?? process.cwd();
|
|
2336
|
-
const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
|
|
2337
|
-
const loadStylesheet = async (id, base) => {
|
|
2338
|
-
try {
|
|
2339
|
-
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;
|
|
2340
|
-
const pkgPath = req.resolve(cssId);
|
|
2341
|
-
return {
|
|
2342
|
-
content: readFileSync(pkgPath, "utf-8"),
|
|
2343
|
-
base: dirname(pkgPath)
|
|
2344
|
-
};
|
|
2345
|
-
} catch {
|
|
2346
|
-
try {
|
|
2347
|
-
const absPath = resolve2(base, id);
|
|
2348
|
-
if (existsSync3(absPath)) {
|
|
2349
|
-
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
2350
|
-
}
|
|
2351
|
-
} catch {
|
|
2352
|
-
}
|
|
2353
|
-
return { content: "", base };
|
|
2354
|
-
}
|
|
2355
|
-
};
|
|
2356
|
-
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
2357
|
-
return compiler.build(classes);
|
|
2358
|
-
}
|
|
2359
|
-
function postProcessWithLightning(rawCss) {
|
|
2360
|
-
if (!rawCss) return "";
|
|
2361
|
-
const native = getNativeBridge();
|
|
2362
|
-
if (typeof native.processTailwindCssLightning !== "function") {
|
|
2363
|
-
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
2364
|
-
}
|
|
2365
|
-
const result = native.processTailwindCssLightning(rawCss);
|
|
2366
|
-
return result?.css ?? rawCss;
|
|
2367
|
-
}
|
|
2368
|
-
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
2369
|
-
const unique = [...new Set(classes.filter(Boolean))];
|
|
2370
|
-
if (unique.length === 0) {
|
|
2371
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2372
|
-
}
|
|
2373
|
-
const rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
2374
|
-
const native = getNativeBridge();
|
|
2375
|
-
const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
|
|
2376
|
-
const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
|
|
2377
|
-
return {
|
|
2378
|
-
css: finalCss,
|
|
2379
|
-
classes: unique,
|
|
2380
|
-
sizeBytes: finalCss.length,
|
|
2381
|
-
optimized: hasLightning
|
|
2382
|
-
};
|
|
2383
|
-
}
|
|
2384
|
-
function runCssPipelineSync(_classes) {
|
|
2385
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2386
|
-
}
|
|
2387
|
-
function processTailwindCssWithTargets(css, targets) {
|
|
2388
|
-
const native = getNativeBridge();
|
|
2389
|
-
if (!native?.processTailwindCssWithTargets) {
|
|
2390
|
-
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
2391
|
-
}
|
|
2392
|
-
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
2393
|
-
return (result?.css ?? css).trim();
|
|
2394
|
-
}
|
|
2395
|
-
var require2, _twEngine, _twEngineError;
|
|
2396
|
-
var init_tailwindEngine = __esm({
|
|
2397
|
-
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
2398
|
-
init_nativeBridge();
|
|
2399
|
-
require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('engine.js', document.baseURI).href)));
|
|
2400
|
-
_twEngine = null;
|
|
2401
|
-
_twEngineError = null;
|
|
2402
|
-
}
|
|
2403
|
-
});
|
|
2404
|
-
|
|
2405
3404
|
// packages/domain/engine/src/native-bridge.ts
|
|
2406
3405
|
function getDirname3() {
|
|
2407
3406
|
if (typeof __dirname !== "undefined") return __dirname;
|
|
@@ -2416,7 +3415,7 @@ function getNativeEngineBinding() {
|
|
|
2416
3415
|
var log4, isValidEngineBinding, createEngineBindingLoader, engineBindingLoader;
|
|
2417
3416
|
var init_native_bridge2 = __esm({
|
|
2418
3417
|
"packages/domain/engine/src/native-bridge.ts"() {
|
|
2419
|
-
|
|
3418
|
+
init_src2();
|
|
2420
3419
|
log4 = createDebugLogger("engine:native");
|
|
2421
3420
|
isValidEngineBinding = (module) => {
|
|
2422
3421
|
const candidate = module;
|
|
@@ -2497,47 +3496,38 @@ var init_native_bridge2 = __esm({
|
|
|
2497
3496
|
// packages/domain/engine/src/ir.ts
|
|
2498
3497
|
function registerPropertyName(id, name) {
|
|
2499
3498
|
const native = getNativeEngineBinding();
|
|
2500
|
-
if (native?.registerPropertyName) {
|
|
2501
|
-
|
|
2502
|
-
return;
|
|
3499
|
+
if (!native?.registerPropertyName) {
|
|
3500
|
+
throw new Error("FATAL: Native binding 'registerPropertyName' is required but not available.");
|
|
2503
3501
|
}
|
|
2504
|
-
|
|
3502
|
+
native.registerPropertyName(id.value, name);
|
|
2505
3503
|
}
|
|
2506
3504
|
function registerValueName(id, name) {
|
|
2507
3505
|
const native = getNativeEngineBinding();
|
|
2508
|
-
if (native?.registerValueName) {
|
|
2509
|
-
|
|
2510
|
-
return;
|
|
3506
|
+
if (!native?.registerValueName) {
|
|
3507
|
+
throw new Error("FATAL: Native binding 'registerValueName' is required but not available.");
|
|
2511
3508
|
}
|
|
2512
|
-
|
|
3509
|
+
native.registerValueName(id.value, name);
|
|
2513
3510
|
}
|
|
2514
3511
|
function propertyIdToString(id) {
|
|
2515
3512
|
const native = getNativeEngineBinding();
|
|
2516
|
-
if (native?.propertyIdToString) {
|
|
2517
|
-
|
|
3513
|
+
if (!native?.propertyIdToString) {
|
|
3514
|
+
throw new Error("FATAL: Native binding 'propertyIdToString' is required but not available.");
|
|
2518
3515
|
}
|
|
2519
|
-
return
|
|
3516
|
+
return native.propertyIdToString(id.value);
|
|
2520
3517
|
}
|
|
2521
3518
|
function valueIdToString(id) {
|
|
2522
3519
|
const native = getNativeEngineBinding();
|
|
2523
|
-
if (native?.valueIdToString) {
|
|
2524
|
-
|
|
3520
|
+
if (!native?.valueIdToString) {
|
|
3521
|
+
throw new Error("FATAL: Native binding 'valueIdToString' is required but not available.");
|
|
2525
3522
|
}
|
|
2526
|
-
return
|
|
2527
|
-
}
|
|
2528
|
-
function createFingerprintFallback(parts) {
|
|
2529
|
-
const hash = parts.reduce(
|
|
2530
|
-
(acc, part) => part.split("").reduce((h, char) => (h << 5) - h + char.charCodeAt(0) & h, acc),
|
|
2531
|
-
0
|
|
2532
|
-
);
|
|
2533
|
-
return Math.abs(hash).toString(36);
|
|
3523
|
+
return native.valueIdToString(id.value);
|
|
2534
3524
|
}
|
|
2535
3525
|
function createFingerprint(parts) {
|
|
2536
3526
|
const native = getNativeEngineBinding();
|
|
2537
|
-
if (native?.createFingerprint) {
|
|
2538
|
-
|
|
3527
|
+
if (!native?.createFingerprint) {
|
|
3528
|
+
throw new Error("FATAL: Native binding 'createFingerprint' is required but not available.");
|
|
2539
3529
|
}
|
|
2540
|
-
return
|
|
3530
|
+
return native.createFingerprint(parts);
|
|
2541
3531
|
}
|
|
2542
3532
|
function createResolutionReason(causes, finalDecision) {
|
|
2543
3533
|
return {
|
|
@@ -2545,7 +3535,7 @@ function createResolutionReason(causes, finalDecision) {
|
|
|
2545
3535
|
finalDecision
|
|
2546
3536
|
};
|
|
2547
3537
|
}
|
|
2548
|
-
exports.RuleId = void 0; exports.SelectorId = void 0; exports.VariantChainId = void 0; exports.PropertyId = void 0; exports.ValueId = void 0; exports.LayerId = void 0; exports.ConditionId = void 0; exports.CascadeResolutionId = void 0;
|
|
3538
|
+
exports.RuleId = void 0; exports.SelectorId = void 0; exports.VariantChainId = void 0; exports.PropertyId = void 0; exports.ValueId = void 0; exports.LayerId = void 0; exports.ConditionId = void 0; exports.CascadeResolutionId = void 0; exports.Origin = void 0; exports.Importance = void 0; exports.ConditionResult = void 0; exports.CascadeStage = void 0;
|
|
2549
3539
|
var init_ir = __esm({
|
|
2550
3540
|
"packages/domain/engine/src/ir.ts"() {
|
|
2551
3541
|
init_native_bridge2();
|
|
@@ -2633,8 +3623,6 @@ var init_ir = __esm({
|
|
|
2633
3623
|
return `R${this.value}`;
|
|
2634
3624
|
}
|
|
2635
3625
|
};
|
|
2636
|
-
_propertyNamesFallback = /* @__PURE__ */ new Map();
|
|
2637
|
-
_valueNamesFallback = /* @__PURE__ */ new Map();
|
|
2638
3626
|
exports.Origin = /* @__PURE__ */ ((Origin2) => {
|
|
2639
3627
|
Origin2[Origin2["UserAgent"] = 0] = "UserAgent";
|
|
2640
3628
|
Origin2[Origin2["UserNormal"] = 1] = "UserNormal";
|
|
@@ -2848,14 +3836,68 @@ function detectLayerFromClassName(className) {
|
|
|
2848
3836
|
return null;
|
|
2849
3837
|
}
|
|
2850
3838
|
function parseCssToIr(css, options = {}) {
|
|
2851
|
-
|
|
3839
|
+
const native = getNativeEngineBinding();
|
|
3840
|
+
const prefix = options.prefix ?? "";
|
|
3841
|
+
if (native?.assembleCssIr) {
|
|
3842
|
+
return _parseCssToIrFast(native.assembleCssIr(css, prefix || null));
|
|
3843
|
+
}
|
|
3844
|
+
return _parseCssToIrFallback(css, prefix, native);
|
|
3845
|
+
}
|
|
3846
|
+
function _parseCssToIrFast(assembled) {
|
|
3847
|
+
const native = getNativeEngineBinding();
|
|
2852
3848
|
layerMap.clear();
|
|
2853
3849
|
layerOrderMap.clear();
|
|
2854
|
-
const
|
|
3850
|
+
for (const le of assembled.layers) {
|
|
3851
|
+
const lid = new exports.LayerId(le.layerId);
|
|
3852
|
+
layerMap.set(le.name, lid);
|
|
3853
|
+
layerOrderMap.set(le.name, le.order);
|
|
3854
|
+
}
|
|
3855
|
+
const rules = assembled.rules.map((r) => {
|
|
3856
|
+
const propertyId = new exports.PropertyId(r.propertyId);
|
|
3857
|
+
const valueId = new exports.ValueId(r.valueId);
|
|
3858
|
+
if (native?.registerPropertyName) {
|
|
3859
|
+
native.registerPropertyName(r.propertyId, r.propertyName);
|
|
3860
|
+
} else {
|
|
3861
|
+
registerPropertyName(propertyId, r.propertyName);
|
|
3862
|
+
}
|
|
3863
|
+
if (native?.registerValueName) {
|
|
3864
|
+
native.registerValueName(r.valueId, r.valueName);
|
|
3865
|
+
} else {
|
|
3866
|
+
registerValueName(valueId, r.valueName);
|
|
3867
|
+
}
|
|
3868
|
+
return {
|
|
3869
|
+
id: new exports.RuleId(r.ruleId),
|
|
3870
|
+
selector: new exports.SelectorId(r.selectorId),
|
|
3871
|
+
variantChain: new exports.VariantChainId(0),
|
|
3872
|
+
property: propertyId,
|
|
3873
|
+
value: valueId,
|
|
3874
|
+
origin: r.origin,
|
|
3875
|
+
importance: r.importance,
|
|
3876
|
+
layer: r.layerId >= 0 ? new exports.LayerId(r.layerId) : null,
|
|
3877
|
+
layerOrder: r.layerOrder,
|
|
3878
|
+
specificity: r.specificity,
|
|
3879
|
+
condition: r.conditionId >= 0 ? new exports.ConditionId(r.conditionId) : null,
|
|
3880
|
+
conditionResult: r.conditionResult,
|
|
3881
|
+
insertionOrder: r.insertionOrder,
|
|
3882
|
+
fingerprint: r.fingerprint,
|
|
3883
|
+
source: { file: "", line: 1, column: 1 }
|
|
3884
|
+
};
|
|
3885
|
+
});
|
|
3886
|
+
const classToRuleIds = new Map(
|
|
3887
|
+
assembled.classToRuleIds.map((m) => [
|
|
3888
|
+
m.className,
|
|
3889
|
+
m.ruleIds.map((id) => new exports.RuleId(id))
|
|
3890
|
+
])
|
|
3891
|
+
);
|
|
3892
|
+
return { rules, classToRuleIds };
|
|
3893
|
+
}
|
|
3894
|
+
function _parseCssToIrFallback(css, prefix, native) {
|
|
2855
3895
|
if (!native?.parseCssRules) {
|
|
2856
3896
|
throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
|
|
2857
3897
|
}
|
|
2858
|
-
|
|
3898
|
+
resetIdGenerator();
|
|
3899
|
+
layerMap.clear();
|
|
3900
|
+
layerOrderMap.clear();
|
|
2859
3901
|
const rules = [];
|
|
2860
3902
|
const classToRuleIds = /* @__PURE__ */ new Map();
|
|
2861
3903
|
const parsed = native.parseCssRules(css);
|
|
@@ -2870,7 +3912,7 @@ function parseCssToIr(css, options = {}) {
|
|
|
2870
3912
|
const valueId = generateValueId(r.value);
|
|
2871
3913
|
const hasMedia = r.variants.some((v) => v.startsWith("@") || v === "dark" || v === "print");
|
|
2872
3914
|
const conditionId = hasMedia ? generateConditionId() : null;
|
|
2873
|
-
const conditionResult =
|
|
3915
|
+
const conditionResult = 2 /* Unknown */;
|
|
2874
3916
|
const ruleId = generateRuleId();
|
|
2875
3917
|
const fingerprint = createFingerprint([className, r.property, r.value]);
|
|
2876
3918
|
const rule = {
|
|
@@ -2884,7 +3926,6 @@ function parseCssToIr(css, options = {}) {
|
|
|
2884
3926
|
layer,
|
|
2885
3927
|
layerOrder,
|
|
2886
3928
|
specificity: r.specificity,
|
|
2887
|
-
// from native — no JS recalculation
|
|
2888
3929
|
condition: conditionId,
|
|
2889
3930
|
conditionResult,
|
|
2890
3931
|
insertionOrder: getNextInsertionOrder(),
|
|
@@ -3038,13 +4079,13 @@ var init_trace2 = __esm({
|
|
|
3038
4079
|
});
|
|
3039
4080
|
|
|
3040
4081
|
// packages/domain/analyzer/src/analyzeWorkspace.ts
|
|
3041
|
-
|
|
4082
|
+
init_src3();
|
|
3042
4083
|
|
|
3043
4084
|
// packages/domain/analyzer/src/binding.ts
|
|
3044
|
-
|
|
4085
|
+
init_src2();
|
|
3045
4086
|
|
|
3046
4087
|
// packages/domain/analyzer/src/utils.ts
|
|
3047
|
-
|
|
4088
|
+
init_src2();
|
|
3048
4089
|
var DEFAULT_TOP_LIMIT = 10;
|
|
3049
4090
|
var DEFAULT_FREQUENT_THRESHOLD = 2;
|
|
3050
4091
|
var DEBUG_NAMESPACE = "tailwind-styled:analyzer";
|
|
@@ -3058,7 +4099,7 @@ function isRecord(value) {
|
|
|
3058
4099
|
}
|
|
3059
4100
|
async function pathExists(filePath) {
|
|
3060
4101
|
try {
|
|
3061
|
-
await
|
|
4102
|
+
await fs3__namespace.default.promises.access(filePath, fs3__namespace.default.constants.F_OK);
|
|
3062
4103
|
return true;
|
|
3063
4104
|
} catch {
|
|
3064
4105
|
return false;
|
|
@@ -3156,8 +4197,8 @@ async function requireNativeBinding() {
|
|
|
3156
4197
|
}
|
|
3157
4198
|
|
|
3158
4199
|
// packages/domain/analyzer/src/schemas.ts
|
|
3159
|
-
|
|
3160
|
-
var formatIssuePath3 = (
|
|
4200
|
+
init_src2();
|
|
4201
|
+
var formatIssuePath3 = (path16) => path16.length > 0 ? path16.map(
|
|
3161
4202
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
3162
4203
|
).join(".") : "<root>";
|
|
3163
4204
|
var isPlainObject = (value) => {
|
|
@@ -3166,8 +4207,8 @@ var isPlainObject = (value) => {
|
|
|
3166
4207
|
return proto === Object.prototype || proto === null;
|
|
3167
4208
|
};
|
|
3168
4209
|
var formatIssues2 = (error) => error.issues.map((issue) => {
|
|
3169
|
-
const
|
|
3170
|
-
return `${
|
|
4210
|
+
const path16 = formatIssuePath3(issue.path);
|
|
4211
|
+
return `${path16}: ${issue.message}`;
|
|
3171
4212
|
}).join("; ");
|
|
3172
4213
|
var parseWithSchema2 = (schema, data, label) => {
|
|
3173
4214
|
const parsed = schema.safeParse(data);
|
|
@@ -3257,7 +4298,7 @@ var parseAnalyzerOptions = (options) => parseWithSchema2(AnalyzerOptionsSchema,
|
|
|
3257
4298
|
var parseNativeReport = (report) => parseWithSchema2(NativeReportSchema, report, "Native analyzer report is invalid");
|
|
3258
4299
|
var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
|
|
3259
4300
|
var tailwindConfigCache = /* @__PURE__ */ new Map();
|
|
3260
|
-
var
|
|
4301
|
+
var detectConflicts2 = async (usages) => {
|
|
3261
4302
|
const native = await getNativeBinding();
|
|
3262
4303
|
if (!native?.detectClassConflicts) {
|
|
3263
4304
|
throw new Error("FATAL: Native binding 'detectClassConflicts' is required but not available.");
|
|
@@ -3274,11 +4315,11 @@ var detectConflicts = async (usages) => {
|
|
|
3274
4315
|
};
|
|
3275
4316
|
};
|
|
3276
4317
|
var isSupportedTailwindConfigPath = (configPath) => {
|
|
3277
|
-
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(
|
|
4318
|
+
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path9__namespace.default.extname(configPath).toLowerCase());
|
|
3278
4319
|
};
|
|
3279
4320
|
var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
3280
4321
|
if (explicitPath) {
|
|
3281
|
-
const resolved =
|
|
4322
|
+
const resolved = path9__namespace.default.resolve(root, explicitPath);
|
|
3282
4323
|
if (!await pathExists(resolved)) return null;
|
|
3283
4324
|
return resolved;
|
|
3284
4325
|
}
|
|
@@ -3289,7 +4330,7 @@ var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
|
3289
4330
|
"tailwind.config.mjs"
|
|
3290
4331
|
];
|
|
3291
4332
|
for (const candidate of candidates) {
|
|
3292
|
-
const fullPath =
|
|
4333
|
+
const fullPath = path9__namespace.default.resolve(root, candidate);
|
|
3293
4334
|
if (await pathExists(fullPath)) return fullPath;
|
|
3294
4335
|
}
|
|
3295
4336
|
return null;
|
|
@@ -3343,8 +4384,8 @@ var collectCustomUtilities = (config) => {
|
|
|
3343
4384
|
return out;
|
|
3344
4385
|
};
|
|
3345
4386
|
var collectSafelistFromSource = async (configPath) => {
|
|
3346
|
-
const source = await
|
|
3347
|
-
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (
|
|
4387
|
+
const source = await fs3__namespace.default.promises.readFile(configPath, "utf8");
|
|
4388
|
+
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src3(), src_exports2));
|
|
3348
4389
|
const allTokens = extractClassesNative2(source);
|
|
3349
4390
|
const hasSafelist = source.includes("safelist");
|
|
3350
4391
|
if (!hasSafelist) return [];
|
|
@@ -3357,7 +4398,7 @@ var collectSafelistFromSource = async (configPath) => {
|
|
|
3357
4398
|
}
|
|
3358
4399
|
return allTokens.filter((t) => safelistSet.has(t));
|
|
3359
4400
|
};
|
|
3360
|
-
var
|
|
4401
|
+
var loadTailwindConfig2 = async (root, semanticOption) => {
|
|
3361
4402
|
const startMs = Date.now();
|
|
3362
4403
|
const configPath = await resolveTailwindConfigPath(root, semanticOption?.tailwindConfigPath);
|
|
3363
4404
|
if (!configPath) return null;
|
|
@@ -3370,7 +4411,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
3370
4411
|
customUtilities: /* @__PURE__ */ new Set()
|
|
3371
4412
|
};
|
|
3372
4413
|
}
|
|
3373
|
-
const configStat = await
|
|
4414
|
+
const configStat = await fs3__namespace.default.promises.stat(configPath).catch(() => null);
|
|
3374
4415
|
if (configStat) {
|
|
3375
4416
|
const cached = tailwindConfigCache.get(configPath);
|
|
3376
4417
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -3438,7 +4479,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
3438
4479
|
return loaded;
|
|
3439
4480
|
};
|
|
3440
4481
|
var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
3441
|
-
const loadedConfig = await
|
|
4482
|
+
const loadedConfig = await loadTailwindConfig2(root, semanticOption);
|
|
3442
4483
|
const safelist = loadedConfig?.safelist ?? /* @__PURE__ */ new Set();
|
|
3443
4484
|
const customUtilities = loadedConfig?.customUtilities ?? /* @__PURE__ */ new Set();
|
|
3444
4485
|
const usageNames = new Set(usages.map((usage) => usage.name));
|
|
@@ -3457,7 +4498,7 @@ var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
|
3457
4498
|
results.filter((r) => !r.isKnown).map((r) => r.className)
|
|
3458
4499
|
);
|
|
3459
4500
|
const unknownClasses = usages.filter((usage) => unknownSet.has(usage.name)).map((usage) => ({ ...usage, isUnused: true }));
|
|
3460
|
-
const { conflicts } = await
|
|
4501
|
+
const { conflicts } = await detectConflicts2(usages);
|
|
3461
4502
|
return {
|
|
3462
4503
|
unusedClasses,
|
|
3463
4504
|
unknownClasses,
|
|
@@ -3529,7 +4570,7 @@ async function buildDistribution(usages, native) {
|
|
|
3529
4570
|
}
|
|
3530
4571
|
async function analyzeWorkspace(root, options = {}) {
|
|
3531
4572
|
const startedAtMs = Date.now();
|
|
3532
|
-
const resolvedRoot =
|
|
4573
|
+
const resolvedRoot = path9__namespace.default.resolve(root);
|
|
3533
4574
|
const normalizedOptions = parseAnalyzerOptions(options);
|
|
3534
4575
|
const scan = await (async () => {
|
|
3535
4576
|
const scanStartedAtMs = Date.now();
|
|
@@ -3631,36 +4672,17 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
3631
4672
|
};
|
|
3632
4673
|
}
|
|
3633
4674
|
|
|
3634
|
-
// packages/domain/compiler/src/index.ts
|
|
3635
|
-
init_nativeBridge();
|
|
3636
|
-
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
3637
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
3638
|
-
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
3639
|
-
return result.css;
|
|
3640
|
-
};
|
|
3641
|
-
var mergeClassesStatic = (classes) => {
|
|
3642
|
-
const result = normalizeAndDedupClasses(classes);
|
|
3643
|
-
return result?.normalized || "";
|
|
3644
|
-
};
|
|
3645
|
-
var normalizeAndDedupClasses = (raw) => {
|
|
3646
|
-
const native = getNativeBridge();
|
|
3647
|
-
if (!native?.normalizeAndDedupClasses) {
|
|
3648
|
-
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
3649
|
-
}
|
|
3650
|
-
const result = native.normalizeAndDedupClasses(raw);
|
|
3651
|
-
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
3652
|
-
};
|
|
3653
|
-
|
|
3654
4675
|
// packages/domain/engine/src/index.ts
|
|
4676
|
+
init_internal();
|
|
4677
|
+
init_src3();
|
|
3655
4678
|
init_src2();
|
|
3656
|
-
init_src();
|
|
3657
4679
|
|
|
3658
4680
|
// packages/domain/engine/src/incremental.ts
|
|
4681
|
+
init_src3();
|
|
3659
4682
|
init_src2();
|
|
3660
|
-
init_src();
|
|
3661
4683
|
init_native_bridge2();
|
|
3662
4684
|
var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
3663
|
-
var log5 =
|
|
4685
|
+
var log5 = createLogger2("engine:incremental");
|
|
3664
4686
|
function rebuildWorkspaceResult(byFile) {
|
|
3665
4687
|
const files = Array.from(byFile.values());
|
|
3666
4688
|
const native = getNativeEngineBinding();
|
|
@@ -3690,9 +4712,9 @@ function areClassSetsEqual(a, b) {
|
|
|
3690
4712
|
}
|
|
3691
4713
|
function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
3692
4714
|
const includeExtensions = scanner?.includeExtensions ?? DEFAULT_EXTENSIONS2;
|
|
3693
|
-
if (!
|
|
3694
|
-
const byFile = new Map(previous.files.map((f) => [
|
|
3695
|
-
const normalizedPath =
|
|
4715
|
+
if (!isScannableFile2(filePath, includeExtensions)) return previous;
|
|
4716
|
+
const byFile = new Map(previous.files.map((f) => [path9__namespace.default.resolve(f.file), f]));
|
|
4717
|
+
const normalizedPath = path9__namespace.default.resolve(filePath);
|
|
3696
4718
|
const native = getNativeEngineBinding();
|
|
3697
4719
|
if (!native?.processFileChange) {
|
|
3698
4720
|
throw new Error(
|
|
@@ -3708,7 +4730,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3708
4730
|
}
|
|
3709
4731
|
log5.debug(`native change ${normalizedPath}`);
|
|
3710
4732
|
const scanned = scanFile(normalizedPath);
|
|
3711
|
-
const content =
|
|
4733
|
+
const content = fs3__namespace.default.readFileSync(normalizedPath, "utf8");
|
|
3712
4734
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3713
4735
|
const existing = byFile.get(normalizedPath);
|
|
3714
4736
|
if (diff && existing) {
|
|
@@ -4053,13 +5075,13 @@ var EngineMetricsCollector = class {
|
|
|
4053
5075
|
};
|
|
4054
5076
|
|
|
4055
5077
|
// packages/domain/engine/src/metricsWriter.ts
|
|
4056
|
-
|
|
5078
|
+
init_src2();
|
|
4057
5079
|
var METRICS_FILE_NAME = "metrics.json";
|
|
4058
5080
|
var CACHE_DIR = ".tw-cache";
|
|
4059
5081
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
4060
5082
|
try {
|
|
4061
|
-
const cacheDir =
|
|
4062
|
-
|
|
5083
|
+
const cacheDir = path9__namespace.default.join(cwd, CACHE_DIR);
|
|
5084
|
+
fs3__namespace.default.mkdirSync(cacheDir, { recursive: true });
|
|
4063
5085
|
const mem = process.memoryUsage();
|
|
4064
5086
|
const data = {
|
|
4065
5087
|
...metrics,
|
|
@@ -4070,7 +5092,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
4070
5092
|
},
|
|
4071
5093
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4072
5094
|
};
|
|
4073
|
-
|
|
5095
|
+
fs3__namespace.default.writeFileSync(path9__namespace.default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
4074
5096
|
} catch {
|
|
4075
5097
|
}
|
|
4076
5098
|
}
|
|
@@ -4177,19 +5199,19 @@ var parseEngineOptions = (options) => parseWithSchema3(EngineOptionsSchema, opti
|
|
|
4177
5199
|
var parseEngineWatchOptions = (options) => parseWithSchema3(EngineWatchOptionsSchema, options ?? {}, "engine watch options are invalid");
|
|
4178
5200
|
|
|
4179
5201
|
// packages/domain/engine/src/watch.ts
|
|
4180
|
-
var
|
|
5202
|
+
var _native2 = null;
|
|
4181
5203
|
function getNativeWatcher() {
|
|
4182
|
-
if (
|
|
5204
|
+
if (_native2 !== null) return _native2;
|
|
4183
5205
|
try {
|
|
4184
|
-
const { resolveNativeBinary: resolveNativeBinary2 } = (
|
|
5206
|
+
const { resolveNativeBinary: resolveNativeBinary2 } = (init_src2(), __toCommonJS(src_exports));
|
|
4185
5207
|
const { path: binPath } = resolveNativeBinary2(__dirname);
|
|
4186
5208
|
if (binPath) {
|
|
4187
|
-
|
|
5209
|
+
_native2 = __require(binPath);
|
|
4188
5210
|
}
|
|
4189
5211
|
} catch {
|
|
4190
|
-
|
|
5212
|
+
_native2 = {};
|
|
4191
5213
|
}
|
|
4192
|
-
return
|
|
5214
|
+
return _native2;
|
|
4193
5215
|
}
|
|
4194
5216
|
function watchWorkspaceNative(rootDir, onEvent, options) {
|
|
4195
5217
|
const native = getNativeWatcher();
|
|
@@ -4253,7 +5275,7 @@ init_ir();
|
|
|
4253
5275
|
|
|
4254
5276
|
// packages/domain/engine/src/reverseLookup.ts
|
|
4255
5277
|
init_native_bridge2();
|
|
4256
|
-
function
|
|
5278
|
+
function getNative2() {
|
|
4257
5279
|
const native = getNativeEngineBinding();
|
|
4258
5280
|
if (!native?.reverseLookupFromCss || !native?.reverseLookupByProperty || !native?.reverseLookupFindDependents) {
|
|
4259
5281
|
throw new Error(
|
|
@@ -4278,15 +5300,15 @@ function normaliseNativeResults(raw) {
|
|
|
4278
5300
|
var ReverseLookup = class {
|
|
4279
5301
|
fromCSS(cssProperty, cssValue, css) {
|
|
4280
5302
|
if (!css || !cssProperty) return [];
|
|
4281
|
-
return normaliseNativeResults(
|
|
5303
|
+
return normaliseNativeResults(getNative2().reverseLookupFromCss(css, cssProperty, cssValue));
|
|
4282
5304
|
}
|
|
4283
5305
|
findByProperty(property, css) {
|
|
4284
5306
|
if (!css || !property) return [];
|
|
4285
|
-
return normaliseNativeResults(
|
|
5307
|
+
return normaliseNativeResults(getNative2().reverseLookupByProperty(css, property));
|
|
4286
5308
|
}
|
|
4287
5309
|
findDependents(className, css) {
|
|
4288
5310
|
if (!css || !className) return [];
|
|
4289
|
-
return
|
|
5311
|
+
return getNative2().reverseLookupFindDependents(css, className);
|
|
4290
5312
|
}
|
|
4291
5313
|
fromBundle(className, css) {
|
|
4292
5314
|
if (!css || !className) return [];
|
|
@@ -4331,7 +5353,7 @@ init_resolver();
|
|
|
4331
5353
|
init_cssToIr();
|
|
4332
5354
|
|
|
4333
5355
|
// packages/domain/engine/src/watch-native.ts
|
|
4334
|
-
|
|
5356
|
+
init_src2();
|
|
4335
5357
|
var watchBindingState = {
|
|
4336
5358
|
binding: void 0
|
|
4337
5359
|
};
|
|
@@ -4350,22 +5372,22 @@ var getBinding = () => {
|
|
|
4350
5372
|
const _paGnu = _pa === "linux-x64" ? "linux-x64-gnu" : _pa === "linux-arm64" ? "linux-arm64-gnu" : _pa;
|
|
4351
5373
|
const candidates = [
|
|
4352
5374
|
// new binary name: tailwind-styled-native
|
|
4353
|
-
|
|
4354
|
-
|
|
5375
|
+
path9__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
5376
|
+
path9__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_pa}.node`),
|
|
4355
5377
|
// npm install case: dist/../native/
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
5378
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
5379
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_pa}.node`),
|
|
5380
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_paGnu}.node`),
|
|
4359
5381
|
// monorepo dev: 4-level up
|
|
4360
|
-
|
|
4361
|
-
|
|
5382
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
5383
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_paGnu}.node`),
|
|
4362
5384
|
// 3-level fallback
|
|
4363
|
-
|
|
5385
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4364
5386
|
// backward compat: tailwind_styled_parser
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
5387
|
+
path9__namespace.default.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
5388
|
+
path9__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
5389
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
5390
|
+
path9__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
4369
5391
|
];
|
|
4370
5392
|
for (const c of candidates) {
|
|
4371
5393
|
try {
|
|
@@ -4382,11 +5404,11 @@ var getBinding = () => {
|
|
|
4382
5404
|
"FATAL: Native watch binding not found in any candidate path.\nThis package requires native Rust bindings.\n\nCandidates checked:\n" + candidates.map((p) => ` - ${p}`).join("\n") + "\n\nResolution steps:\n1. Build the native Rust module: npm run build:rust"
|
|
4383
5405
|
);
|
|
4384
5406
|
};
|
|
4385
|
-
var log6 =
|
|
5407
|
+
var log6 = createLogger2("engine:watch-native");
|
|
4386
5408
|
function watchWorkspace2(rootDir, callback, options = {}) {
|
|
4387
5409
|
const binding = getBinding();
|
|
4388
5410
|
const pollMs = options.pollIntervalMs ?? 500;
|
|
4389
|
-
const resolvedRoot =
|
|
5411
|
+
const resolvedRoot = path9__namespace.default.resolve(rootDir);
|
|
4390
5412
|
const result = (() => {
|
|
4391
5413
|
try {
|
|
4392
5414
|
return binding.startWatch(resolvedRoot);
|
|
@@ -4423,7 +5445,7 @@ This package requires native Rust bindings.`
|
|
|
4423
5445
|
const deduped = /* @__PURE__ */ new Set();
|
|
4424
5446
|
const events = [];
|
|
4425
5447
|
for (const e of raw) {
|
|
4426
|
-
const absPath =
|
|
5448
|
+
const absPath = path9__namespace.default.isAbsolute(e.path) ? path9__namespace.default.normalize(e.path) : path9__namespace.default.resolve(resolvedRoot, e.path);
|
|
4427
5449
|
const kind = e.kind;
|
|
4428
5450
|
const key = `${kind}:${absPath}`;
|
|
4429
5451
|
if (deduped.has(key)) continue;
|
|
@@ -4460,11 +5482,11 @@ var configState = {
|
|
|
4460
5482
|
return this.tailwindConfigLoaded;
|
|
4461
5483
|
}
|
|
4462
5484
|
};
|
|
4463
|
-
var log7 =
|
|
5485
|
+
var log7 = createLogger2("engine");
|
|
4464
5486
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
4465
5487
|
if (!tailwindConfigPath) return void 0;
|
|
4466
|
-
const configPath =
|
|
4467
|
-
if (!
|
|
5488
|
+
const configPath = path9__namespace.default.resolve(root, tailwindConfigPath);
|
|
5489
|
+
if (!fs3__namespace.default.existsSync(configPath)) {
|
|
4468
5490
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
4469
5491
|
}
|
|
4470
5492
|
const imported = await import(url.pathToFileURL(configPath).href);
|
|
@@ -4530,13 +5552,14 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
4530
5552
|
};
|
|
4531
5553
|
}
|
|
4532
5554
|
function countWorkspacePackages(root) {
|
|
4533
|
-
const packagesDir =
|
|
4534
|
-
if (!
|
|
5555
|
+
const packagesDir = path9__namespace.default.join(root, "packages");
|
|
5556
|
+
if (!fs3__namespace.default.existsSync(packagesDir)) return 0;
|
|
4535
5557
|
try {
|
|
4536
|
-
return
|
|
4537
|
-
(entry) => entry.isDirectory() &&
|
|
5558
|
+
return fs3__namespace.default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
5559
|
+
(entry) => entry.isDirectory() && fs3__namespace.default.existsSync(path9__namespace.default.join(packagesDir, entry.name, "package.json"))
|
|
4538
5560
|
).length;
|
|
4539
|
-
} catch {
|
|
5561
|
+
} catch (err) {
|
|
5562
|
+
log7.debug(`countWorkspacePackages: ${err instanceof Error ? err.message : String(err)}`);
|
|
4540
5563
|
return 0;
|
|
4541
5564
|
}
|
|
4542
5565
|
}
|
|
@@ -4570,7 +5593,7 @@ function writeDashboardMetrics(root, mode, result, metrics) {
|
|
|
4570
5593
|
async function createEngine(rawOptions = {}) {
|
|
4571
5594
|
const options = parseEngineOptions(rawOptions);
|
|
4572
5595
|
const root = options.root ?? process.cwd();
|
|
4573
|
-
const resolvedRoot =
|
|
5596
|
+
const resolvedRoot = path9__namespace.default.resolve(root);
|
|
4574
5597
|
const plugins = rawOptions.plugins ?? [];
|
|
4575
5598
|
const getTailwindConfig = async () => {
|
|
4576
5599
|
if (configState.isLoaded()) return configState.getConfig();
|
|
@@ -4717,12 +5740,13 @@ async function createEngine(rawOptions = {}) {
|
|
|
4717
5740
|
const shouldForceFullRescan = (event) => {
|
|
4718
5741
|
if (event.type === "unlink") return false;
|
|
4719
5742
|
try {
|
|
4720
|
-
const stat =
|
|
5743
|
+
const stat = fs3__namespace.default.statSync(event.filePath);
|
|
4721
5744
|
if (stat.size > largeFileThreshold) {
|
|
4722
5745
|
metrics.markSkippedLargeFile();
|
|
4723
5746
|
return true;
|
|
4724
5747
|
}
|
|
4725
|
-
} catch {
|
|
5748
|
+
} catch (statErr) {
|
|
5749
|
+
log7.debug(`stat failed for ${event.filePath}: ${statErr instanceof Error ? statErr.message : String(statErr)}`);
|
|
4726
5750
|
return false;
|
|
4727
5751
|
}
|
|
4728
5752
|
return false;
|
|
@@ -4834,14 +5858,14 @@ async function createEngine(rawOptions = {}) {
|
|
|
4834
5858
|
};
|
|
4835
5859
|
}
|
|
4836
5860
|
async function scanWorkspace2(opts = {}) {
|
|
4837
|
-
const root =
|
|
5861
|
+
const root = path9__namespace.default.resolve(opts.root ?? process.cwd());
|
|
4838
5862
|
return scanWorkspaceAsync(root, {
|
|
4839
5863
|
includeExtensions: opts.extensions,
|
|
4840
5864
|
ignoreDirectories: opts.ignoreDirectories
|
|
4841
5865
|
});
|
|
4842
5866
|
}
|
|
4843
5867
|
async function analyzeWorkspace2(opts = {}) {
|
|
4844
|
-
const root =
|
|
5868
|
+
const root = path9__namespace.default.resolve(opts.root ?? process.cwd());
|
|
4845
5869
|
return analyzeWorkspace(root, {
|
|
4846
5870
|
classStats: { top: opts.top ?? 20 }
|
|
4847
5871
|
});
|
|
@@ -4872,7 +5896,8 @@ async function traceClass(className, scanResult, css) {
|
|
|
4872
5896
|
resolver.registerClass(registeredClassName, ruleIds);
|
|
4873
5897
|
}
|
|
4874
5898
|
return trace2(className, resolver);
|
|
4875
|
-
} catch {
|
|
5899
|
+
} catch (traceErr) {
|
|
5900
|
+
log7.debug(`traceClass("${className}"): ${traceErr instanceof Error ? traceErr.message : String(traceErr)}`);
|
|
4876
5901
|
return null;
|
|
4877
5902
|
}
|
|
4878
5903
|
}
|