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/vite.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
3
|
+
import * as fs13 from 'fs';
|
|
4
|
+
import fs13__default from 'fs';
|
|
5
|
+
import * as path9 from 'path';
|
|
6
|
+
import path9__default from 'path';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
9
9
|
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
|
|
@@ -220,9 +220,9 @@ function parseNative(schema, data, context) {
|
|
|
220
220
|
const result = schema.safeParse(data);
|
|
221
221
|
if (!result.success) {
|
|
222
222
|
const first = result.error.issues[0];
|
|
223
|
-
const
|
|
223
|
+
const path16 = first?.path?.join(".") ?? "(root)";
|
|
224
224
|
throw new Error(
|
|
225
|
-
`[${context}] Native binding returned unexpected data: ${
|
|
225
|
+
`[${context}] Native binding returned unexpected data: ${path16}: ${first?.message ?? "validation failed"}`
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
return result.data;
|
|
@@ -615,11 +615,11 @@ function resolvePath(...segments) {
|
|
|
615
615
|
return segments.join("/").replace(/\/+/g, "/");
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
function existsSync(
|
|
618
|
+
function existsSync(path16) {
|
|
619
619
|
if (isBrowser2) return false;
|
|
620
620
|
try {
|
|
621
621
|
const nodeFs = __require(NODE_FS);
|
|
622
|
-
return nodeFs.existsSync(
|
|
622
|
+
return nodeFs.existsSync(path16);
|
|
623
623
|
} catch {
|
|
624
624
|
return false;
|
|
625
625
|
}
|
|
@@ -849,12 +849,12 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
849
849
|
if (isBrowser3) {
|
|
850
850
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
851
851
|
}
|
|
852
|
-
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
852
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
853
853
|
return { path: null, source: "not-found", platform, tried: [] };
|
|
854
854
|
}
|
|
855
855
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
856
856
|
if (envPath) {
|
|
857
|
-
if (
|
|
857
|
+
if (fs13.existsSync(envPath)) {
|
|
858
858
|
return { path: envPath, source: "env", platform, tried };
|
|
859
859
|
}
|
|
860
860
|
tried.push(`env:${envPath} (not found)`);
|
|
@@ -863,7 +863,7 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
863
863
|
for (const pkg of prebuiltPkgs) {
|
|
864
864
|
try {
|
|
865
865
|
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
866
|
-
if (
|
|
866
|
+
if (fs13.existsSync(candidate)) {
|
|
867
867
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
868
868
|
}
|
|
869
869
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -874,13 +874,13 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
874
874
|
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
875
875
|
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
876
876
|
if (runtimeDir) {
|
|
877
|
-
for (const depth of ["..",
|
|
878
|
-
const pkgRoot =
|
|
877
|
+
for (const depth of ["..", path9.join("..", ".."), path9.join("..", "..", "..")]) {
|
|
878
|
+
const pkgRoot = path9.resolve(runtimeDir, depth);
|
|
879
879
|
for (const bin of BINARY_NAMES_SELF) {
|
|
880
880
|
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
881
|
-
const candidate =
|
|
881
|
+
const candidate = path9.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
882
882
|
tried.push(`self-bundled:${candidate}`);
|
|
883
|
-
if (
|
|
883
|
+
if (fs13.existsSync(candidate)) {
|
|
884
884
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
885
885
|
}
|
|
886
886
|
}
|
|
@@ -892,29 +892,29 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
892
892
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
893
893
|
const localCandidates = [];
|
|
894
894
|
for (const bin of BINARY_NAMES) {
|
|
895
|
-
localCandidates.push(
|
|
896
|
-
localCandidates.push(
|
|
897
|
-
localCandidates.push(
|
|
898
|
-
localCandidates.push(
|
|
895
|
+
localCandidates.push(path9.resolve(base, `${bin}.node`));
|
|
896
|
+
localCandidates.push(path9.resolve(base, "..", `${bin}.node`));
|
|
897
|
+
localCandidates.push(path9.resolve(base, `${bin}.${platform}.node`));
|
|
898
|
+
localCandidates.push(path9.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
899
899
|
}
|
|
900
900
|
for (const startDir of [cwd, base]) {
|
|
901
901
|
let dir = startDir;
|
|
902
902
|
for (let i = 0; i < 6; i++) {
|
|
903
|
-
const nativeDir =
|
|
903
|
+
const nativeDir = path9.resolve(dir, "native");
|
|
904
904
|
for (const bin of BINARY_NAMES) {
|
|
905
|
-
localCandidates.push(
|
|
906
|
-
localCandidates.push(
|
|
907
|
-
localCandidates.push(
|
|
908
|
-
localCandidates.push(
|
|
905
|
+
localCandidates.push(path9.resolve(nativeDir, `${bin}.node`));
|
|
906
|
+
localCandidates.push(path9.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
907
|
+
localCandidates.push(path9.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
908
|
+
localCandidates.push(path9.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
909
909
|
}
|
|
910
|
-
const parent =
|
|
910
|
+
const parent = path9.resolve(dir, "..");
|
|
911
911
|
if (parent === dir) break;
|
|
912
912
|
dir = parent;
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
for (const candidate of localCandidates) {
|
|
916
916
|
tried.push(`local:${candidate}`);
|
|
917
|
-
if (
|
|
917
|
+
if (fs13.existsSync(candidate)) {
|
|
918
918
|
return { path: candidate, source: "local", platform, tried };
|
|
919
919
|
}
|
|
920
920
|
}
|
|
@@ -953,9 +953,9 @@ var init_native_resolution = __esm({
|
|
|
953
953
|
// packages/domain/shared/src/observability.ts
|
|
954
954
|
function createObservabilityClient(opts = {}) {
|
|
955
955
|
const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
|
|
956
|
-
async function fetchJson(
|
|
956
|
+
async function fetchJson(path16) {
|
|
957
957
|
try {
|
|
958
|
-
const res = await fetch(`${baseUrl}${
|
|
958
|
+
const res = await fetch(`${baseUrl}${path16}`, {
|
|
959
959
|
signal: AbortSignal.timeout(timeoutMs)
|
|
960
960
|
});
|
|
961
961
|
if (!res.ok) return null;
|
|
@@ -987,6 +987,644 @@ var init_observability = __esm({
|
|
|
987
987
|
}
|
|
988
988
|
});
|
|
989
989
|
|
|
990
|
+
// packages/domain/compiler/src/cssGeneratorNative.ts
|
|
991
|
+
async function generateCssNative(classes, options) {
|
|
992
|
+
const {
|
|
993
|
+
theme,
|
|
994
|
+
fallbackToJs = true,
|
|
995
|
+
logFallback = false
|
|
996
|
+
} = options;
|
|
997
|
+
try {
|
|
998
|
+
const native = getNativeBridge();
|
|
999
|
+
if (!native?.generateCssNative) {
|
|
1000
|
+
throw new Error("generateCssNative not available in native binding");
|
|
1001
|
+
}
|
|
1002
|
+
const themeJson = JSON.stringify(theme);
|
|
1003
|
+
const css = native.generateCssNative(classes, themeJson);
|
|
1004
|
+
return css;
|
|
1005
|
+
} catch (error) {
|
|
1006
|
+
if (!fallbackToJs) {
|
|
1007
|
+
throw error;
|
|
1008
|
+
}
|
|
1009
|
+
if (logFallback) {
|
|
1010
|
+
console.warn(
|
|
1011
|
+
"[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
|
|
1012
|
+
error instanceof Error ? error.message : String(error)
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
return generateRawCss(classes);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
var init_cssGeneratorNative = __esm({
|
|
1019
|
+
"packages/domain/compiler/src/cssGeneratorNative.ts"() {
|
|
1020
|
+
init_nativeBridge();
|
|
1021
|
+
init_tailwindEngine();
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
// packages/domain/compiler/src/tailwindEngine.ts
|
|
1026
|
+
var tailwindEngine_exports = {};
|
|
1027
|
+
__export(tailwindEngine_exports, {
|
|
1028
|
+
clearCache: () => clearCache,
|
|
1029
|
+
generateRawCss: () => generateRawCss,
|
|
1030
|
+
getCacheStats: () => getCacheStats,
|
|
1031
|
+
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
1032
|
+
runCssPipeline: () => runCssPipeline,
|
|
1033
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
1034
|
+
});
|
|
1035
|
+
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
1036
|
+
const sorted = [...classes].sort().join(",");
|
|
1037
|
+
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
1038
|
+
return `${sorted}|${flags}`;
|
|
1039
|
+
}
|
|
1040
|
+
function _evictOldestIfNeeded() {
|
|
1041
|
+
if (_cssCache.size >= MAX_CACHE_SIZE) {
|
|
1042
|
+
const firstKey = _cssCache.keys().next().value;
|
|
1043
|
+
if (firstKey !== void 0) {
|
|
1044
|
+
_cssCache.delete(firstKey);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function getCacheStats() {
|
|
1049
|
+
const total = _cacheHits + _cacheMisses;
|
|
1050
|
+
return {
|
|
1051
|
+
hits: _cacheHits,
|
|
1052
|
+
misses: _cacheMisses,
|
|
1053
|
+
hitRate: total > 0 ? _cacheHits / total : 0,
|
|
1054
|
+
size: _cssCache.size,
|
|
1055
|
+
maxSize: MAX_CACHE_SIZE
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
function clearCache() {
|
|
1059
|
+
_cssCache.clear();
|
|
1060
|
+
_cacheHits = 0;
|
|
1061
|
+
_cacheMisses = 0;
|
|
1062
|
+
}
|
|
1063
|
+
function loadTailwindEngine() {
|
|
1064
|
+
if (_twEngine) return _twEngine;
|
|
1065
|
+
if (_twEngineError) throw _twEngineError;
|
|
1066
|
+
try {
|
|
1067
|
+
const tw = require2("tailwindcss");
|
|
1068
|
+
if (typeof tw.compile !== "function") {
|
|
1069
|
+
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
1070
|
+
}
|
|
1071
|
+
_twEngine = tw;
|
|
1072
|
+
return _twEngine;
|
|
1073
|
+
} catch (e) {
|
|
1074
|
+
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
1075
|
+
throw _twEngineError;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1079
|
+
if (classes.length === 0) return "";
|
|
1080
|
+
const tw = loadTailwindEngine();
|
|
1081
|
+
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1082
|
+
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1083
|
+
const { dirname, resolve: resolve2 } = await import('path');
|
|
1084
|
+
const projectRoot = root ?? process.cwd();
|
|
1085
|
+
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
1086
|
+
const loadStylesheet = async (id, base) => {
|
|
1087
|
+
try {
|
|
1088
|
+
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;
|
|
1089
|
+
const pkgPath = req.resolve(cssId);
|
|
1090
|
+
return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
|
|
1091
|
+
} catch {
|
|
1092
|
+
try {
|
|
1093
|
+
const absPath = resolve2(base, id);
|
|
1094
|
+
if (existsSync3(absPath)) {
|
|
1095
|
+
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
1096
|
+
}
|
|
1097
|
+
} catch {
|
|
1098
|
+
}
|
|
1099
|
+
return { content: "", base };
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1103
|
+
return compiler.build(classes);
|
|
1104
|
+
}
|
|
1105
|
+
function getThemeConfig() {
|
|
1106
|
+
return {
|
|
1107
|
+
colors: {
|
|
1108
|
+
slate: {
|
|
1109
|
+
"50": "#f8fafc",
|
|
1110
|
+
"100": "#f1f5f9",
|
|
1111
|
+
"200": "#e2e8f0",
|
|
1112
|
+
"300": "#cbd5e1",
|
|
1113
|
+
"400": "#94a3b8",
|
|
1114
|
+
"500": "#64748b",
|
|
1115
|
+
"600": "#475569",
|
|
1116
|
+
"700": "#334155",
|
|
1117
|
+
"800": "#1e293b",
|
|
1118
|
+
"900": "#0f172a"
|
|
1119
|
+
},
|
|
1120
|
+
gray: {
|
|
1121
|
+
"50": "#f9fafb",
|
|
1122
|
+
"100": "#f3f4f6",
|
|
1123
|
+
"200": "#e5e7eb",
|
|
1124
|
+
"300": "#d1d5db",
|
|
1125
|
+
"400": "#9ca3af",
|
|
1126
|
+
"500": "#6b7280",
|
|
1127
|
+
"600": "#4b5563",
|
|
1128
|
+
"700": "#374151",
|
|
1129
|
+
"800": "#1f2937",
|
|
1130
|
+
"900": "#111827"
|
|
1131
|
+
},
|
|
1132
|
+
white: "#ffffff",
|
|
1133
|
+
black: "#000000",
|
|
1134
|
+
red: {
|
|
1135
|
+
"500": "#ef4444",
|
|
1136
|
+
"600": "#dc2626"
|
|
1137
|
+
},
|
|
1138
|
+
blue: {
|
|
1139
|
+
"500": "#3b82f6",
|
|
1140
|
+
"600": "#1e40af"
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
spacing: {
|
|
1144
|
+
"0": "0px",
|
|
1145
|
+
"1": "0.25rem",
|
|
1146
|
+
"2": "0.5rem",
|
|
1147
|
+
"3": "0.75rem",
|
|
1148
|
+
"4": "1rem",
|
|
1149
|
+
"5": "1.25rem",
|
|
1150
|
+
"6": "1.5rem",
|
|
1151
|
+
"8": "2rem",
|
|
1152
|
+
"10": "2.5rem",
|
|
1153
|
+
"12": "3rem",
|
|
1154
|
+
"16": "4rem",
|
|
1155
|
+
"20": "5rem",
|
|
1156
|
+
"24": "6rem"
|
|
1157
|
+
},
|
|
1158
|
+
breakpoints: {
|
|
1159
|
+
"sm": "640px",
|
|
1160
|
+
"md": "768px",
|
|
1161
|
+
"lg": "1024px",
|
|
1162
|
+
"xl": "1280px",
|
|
1163
|
+
"2xl": "1536px"
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
function postProcessWithLightning(rawCss) {
|
|
1168
|
+
if (!rawCss) return "";
|
|
1169
|
+
const native = getNativeBridge();
|
|
1170
|
+
if (!native?.processTailwindCssLightning) {
|
|
1171
|
+
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
1172
|
+
}
|
|
1173
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
1174
|
+
if (!result?.css) {
|
|
1175
|
+
throw new Error("FATAL: processTailwindCssLightning returned null");
|
|
1176
|
+
}
|
|
1177
|
+
return result.css;
|
|
1178
|
+
}
|
|
1179
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
1180
|
+
const filtered = classes.filter(Boolean);
|
|
1181
|
+
const uniqueMap = /* @__PURE__ */ new Map();
|
|
1182
|
+
filtered.forEach((cls) => uniqueMap.set(cls, cls));
|
|
1183
|
+
const unique = Array.from(uniqueMap.values());
|
|
1184
|
+
if (unique.length === 0) {
|
|
1185
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1186
|
+
}
|
|
1187
|
+
const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
|
|
1188
|
+
const cached = _cssCache.get(cacheKey);
|
|
1189
|
+
if (cached) {
|
|
1190
|
+
_cacheHits++;
|
|
1191
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1192
|
+
console.log(
|
|
1193
|
+
`[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
return cached;
|
|
1197
|
+
}
|
|
1198
|
+
_cacheMisses++;
|
|
1199
|
+
let rawCss;
|
|
1200
|
+
let usedRustCompiler = false;
|
|
1201
|
+
try {
|
|
1202
|
+
const theme = getThemeConfig();
|
|
1203
|
+
rawCss = await generateCssNative(unique, {
|
|
1204
|
+
theme,
|
|
1205
|
+
fallbackToJs: true,
|
|
1206
|
+
logFallback: process.env.DEBUG?.includes("compiler") === true
|
|
1207
|
+
});
|
|
1208
|
+
usedRustCompiler = true;
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1211
|
+
console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
|
|
1212
|
+
}
|
|
1213
|
+
rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
1214
|
+
}
|
|
1215
|
+
const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
|
|
1216
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1217
|
+
console.log(
|
|
1218
|
+
`[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
|
|
1219
|
+
`Size: ${finalCss.length} bytes`
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
const result = {
|
|
1223
|
+
css: finalCss,
|
|
1224
|
+
classes: unique,
|
|
1225
|
+
sizeBytes: finalCss.length,
|
|
1226
|
+
optimized: minify
|
|
1227
|
+
};
|
|
1228
|
+
_evictOldestIfNeeded();
|
|
1229
|
+
_cssCache.set(cacheKey, result);
|
|
1230
|
+
return result;
|
|
1231
|
+
}
|
|
1232
|
+
function runCssPipelineSync(_classes) {
|
|
1233
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1234
|
+
}
|
|
1235
|
+
function processTailwindCssWithTargets(css, targets) {
|
|
1236
|
+
const native = getNativeBridge();
|
|
1237
|
+
if (!native?.processTailwindCssWithTargets) {
|
|
1238
|
+
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
1239
|
+
}
|
|
1240
|
+
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
1241
|
+
if (!result?.css) {
|
|
1242
|
+
throw new Error("FATAL: processTailwindCssWithTargets returned null");
|
|
1243
|
+
}
|
|
1244
|
+
return result.css;
|
|
1245
|
+
}
|
|
1246
|
+
var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
|
|
1247
|
+
var init_tailwindEngine = __esm({
|
|
1248
|
+
"packages/domain/compiler/src/tailwindEngine.ts"() {
|
|
1249
|
+
init_nativeBridge();
|
|
1250
|
+
init_cssGeneratorNative();
|
|
1251
|
+
require2 = createRequire(import.meta.url);
|
|
1252
|
+
_cssCache = /* @__PURE__ */ new Map();
|
|
1253
|
+
_cacheHits = 0;
|
|
1254
|
+
_cacheMisses = 0;
|
|
1255
|
+
MAX_CACHE_SIZE = 100;
|
|
1256
|
+
_twEngine = null;
|
|
1257
|
+
_twEngineError = null;
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
// packages/domain/compiler/src/internal.ts
|
|
1262
|
+
var internal_exports = {};
|
|
1263
|
+
__export(internal_exports, {
|
|
1264
|
+
adaptNativeResult: () => adaptNativeResult,
|
|
1265
|
+
analyzeClassUsage: () => analyzeClassUsage,
|
|
1266
|
+
analyzeClasses: () => analyzeClasses,
|
|
1267
|
+
analyzeFile: () => analyzeFile,
|
|
1268
|
+
analyzeRsc: () => analyzeRsc,
|
|
1269
|
+
analyzeVariantUsage: () => analyzeVariantUsage,
|
|
1270
|
+
astExtractClasses: () => astExtractClasses,
|
|
1271
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
1272
|
+
bucketSort: () => bucketSort,
|
|
1273
|
+
buildStyleTag: () => buildStyleTag,
|
|
1274
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
1275
|
+
classifyAndSortClasses: () => classifyAndSortClasses,
|
|
1276
|
+
classifyNode: () => classifyNode,
|
|
1277
|
+
clearCache: () => clearCache,
|
|
1278
|
+
compileCssFromClasses: () => compileCssFromClasses,
|
|
1279
|
+
compileCssNative: () => compileCssNative,
|
|
1280
|
+
compileVariantTable: () => compileVariantTable,
|
|
1281
|
+
compileVariants: () => compileVariants,
|
|
1282
|
+
detectConflicts: () => detectConflicts,
|
|
1283
|
+
diffClassLists: () => diffClassLists,
|
|
1284
|
+
eliminateDeadCss: () => eliminateDeadCss,
|
|
1285
|
+
extractAllClasses: () => extractAllClasses,
|
|
1286
|
+
extractAndGenerateStateCss: () => extractAndGenerateStateCss,
|
|
1287
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
1288
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
1289
|
+
extractContainerCssFromSource: () => extractContainerCssFromSource,
|
|
1290
|
+
extractTwStateConfigs: () => extractTwStateConfigs,
|
|
1291
|
+
fileToRoute: () => fileToRoute,
|
|
1292
|
+
findDeadVariants: () => findDeadVariants,
|
|
1293
|
+
generateCssForClasses: () => generateCssForClasses,
|
|
1294
|
+
generateRawCss: () => generateRawCss,
|
|
1295
|
+
generateSafelist: () => generateSafelist,
|
|
1296
|
+
generateStaticStateCss: () => generateStaticStateCss,
|
|
1297
|
+
getAllRoutes: () => getAllRoutes,
|
|
1298
|
+
getBucketEngine: () => getBucketEngine,
|
|
1299
|
+
getCacheStats: () => getCacheStats,
|
|
1300
|
+
getContentPaths: () => getContentPaths,
|
|
1301
|
+
getIncrementalEngine: () => getIncrementalEngine,
|
|
1302
|
+
getNativeBridge: () => getNativeBridge,
|
|
1303
|
+
getRouteClasses: () => getRouteClasses,
|
|
1304
|
+
hasTwUsage: () => hasTwUsage,
|
|
1305
|
+
hoistComponents: () => hoistComponents,
|
|
1306
|
+
injectClientDirective: () => injectClientDirective,
|
|
1307
|
+
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
1308
|
+
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
1309
|
+
loadSafelist: () => loadSafelist,
|
|
1310
|
+
loadTailwindConfig: () => loadTailwindConfig,
|
|
1311
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
1312
|
+
mergeCssDeclarations: () => mergeCssDeclarations,
|
|
1313
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
1314
|
+
normalizeClasses: () => normalizeClasses,
|
|
1315
|
+
optimizeCss: () => optimizeCss,
|
|
1316
|
+
parseClasses: () => parseClasses,
|
|
1317
|
+
registerFileClasses: () => registerFileClasses,
|
|
1318
|
+
registerGlobalClasses: () => registerGlobalClasses,
|
|
1319
|
+
resetBucketEngine: () => resetBucketEngine,
|
|
1320
|
+
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
1321
|
+
runCssPipeline: () => runCssPipeline,
|
|
1322
|
+
runCssPipelineSync: () => runCssPipelineSync,
|
|
1323
|
+
runElimination: () => runElimination,
|
|
1324
|
+
runLoaderTransform: () => runLoaderTransform,
|
|
1325
|
+
scanProjectUsage: () => scanProjectUsage,
|
|
1326
|
+
shouldProcess: () => shouldProcess,
|
|
1327
|
+
shouldSkipFile: () => shouldSkipFile,
|
|
1328
|
+
transformSource: () => transformSource
|
|
1329
|
+
});
|
|
1330
|
+
var init_internal = __esm({
|
|
1331
|
+
"packages/domain/compiler/src/internal.ts"() {
|
|
1332
|
+
init_src2();
|
|
1333
|
+
init_tailwindEngine();
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
function getNative() {
|
|
1337
|
+
if (_native) return _native;
|
|
1338
|
+
try {
|
|
1339
|
+
const mod = (init_internal(), __toCommonJS(internal_exports));
|
|
1340
|
+
if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
_native = {
|
|
1344
|
+
extractTwStateConfigs: mod.extractTwStateConfigs,
|
|
1345
|
+
generateStaticStateCss: mod.generateStaticStateCss,
|
|
1346
|
+
extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
|
|
1347
|
+
((source, filename) => {
|
|
1348
|
+
const configs = mod.extractTwStateConfigs(source, filename);
|
|
1349
|
+
if (configs.length === 0) return [];
|
|
1350
|
+
return mod.generateStaticStateCss(configs.map((c) => ({
|
|
1351
|
+
tag: c.tag,
|
|
1352
|
+
componentName: c.componentName,
|
|
1353
|
+
statesJson: c.statesJson
|
|
1354
|
+
})));
|
|
1355
|
+
})
|
|
1356
|
+
};
|
|
1357
|
+
return _native;
|
|
1358
|
+
} catch {
|
|
1359
|
+
return null;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function* walkSourceFiles(dir) {
|
|
1363
|
+
let entries;
|
|
1364
|
+
try {
|
|
1365
|
+
entries = fs13__default.readdirSync(dir, { withFileTypes: true });
|
|
1366
|
+
} catch {
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
for (const entry of entries) {
|
|
1370
|
+
const fullPath = path9__default.join(dir, entry.name);
|
|
1371
|
+
if (entry.isDirectory()) {
|
|
1372
|
+
if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
|
|
1373
|
+
yield* walkSourceFiles(fullPath);
|
|
1374
|
+
} else if (entry.isFile()) {
|
|
1375
|
+
const ext = path9__default.extname(entry.name);
|
|
1376
|
+
if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
function buildCssHeader(result) {
|
|
1381
|
+
return [
|
|
1382
|
+
"/* \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",
|
|
1383
|
+
" * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
|
|
1384
|
+
" * DO NOT EDIT. Re-generated on each build.",
|
|
1385
|
+
" *",
|
|
1386
|
+
` * Files scanned: ${result.filesScanned}`,
|
|
1387
|
+
` * Files with states: ${result.filesWithStates}`,
|
|
1388
|
+
` * Components found: ${result.componentsFound}`,
|
|
1389
|
+
` * Rules generated: ${result.rulesGenerated}`,
|
|
1390
|
+
` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
|
|
1391
|
+
" *",
|
|
1392
|
+
' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
|
|
1393
|
+
" * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
|
|
1394
|
+
" * \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 */",
|
|
1395
|
+
""
|
|
1396
|
+
].join("\n");
|
|
1397
|
+
}
|
|
1398
|
+
function extractStaticStateCss(srcDir, options = {}) {
|
|
1399
|
+
const { verbose = false, maxFiles = Infinity } = options;
|
|
1400
|
+
const native = getNative();
|
|
1401
|
+
if (!native) {
|
|
1402
|
+
if (verbose) {
|
|
1403
|
+
process.stderr.write(
|
|
1404
|
+
"[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
|
|
1405
|
+
);
|
|
1406
|
+
}
|
|
1407
|
+
return {
|
|
1408
|
+
filesScanned: 0,
|
|
1409
|
+
filesWithStates: 0,
|
|
1410
|
+
componentsFound: 0,
|
|
1411
|
+
rulesGenerated: 0,
|
|
1412
|
+
rulesSkipped: 0,
|
|
1413
|
+
generatedCss: "",
|
|
1414
|
+
rules: []
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
const allConfigs = [];
|
|
1418
|
+
let filesScanned = 0;
|
|
1419
|
+
let filesWithStates = 0;
|
|
1420
|
+
if (native.walkAndPrefilterSourceFiles) {
|
|
1421
|
+
const prefiltered = native.walkAndPrefilterSourceFiles(
|
|
1422
|
+
srcDir,
|
|
1423
|
+
[".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
|
|
1424
|
+
["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
|
|
1425
|
+
// Required substrings — AND logic, identik dengan JS pre-filter di bawah
|
|
1426
|
+
["states:", "tw."],
|
|
1427
|
+
maxFiles === Infinity ? null : maxFiles,
|
|
1428
|
+
null
|
|
1429
|
+
// sequential — parallel mode opsional untuk large monorepo
|
|
1430
|
+
);
|
|
1431
|
+
for (const { path: filePath, content: source } of prefiltered) {
|
|
1432
|
+
filesScanned++;
|
|
1433
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
1434
|
+
if (configs.length > 0) {
|
|
1435
|
+
filesWithStates++;
|
|
1436
|
+
allConfigs.push(...configs);
|
|
1437
|
+
if (verbose) {
|
|
1438
|
+
process.stderr.write(
|
|
1439
|
+
`[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
1440
|
+
`
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
} else {
|
|
1446
|
+
for (const filePath of walkSourceFiles(srcDir)) {
|
|
1447
|
+
if (filesScanned >= maxFiles) break;
|
|
1448
|
+
let source;
|
|
1449
|
+
try {
|
|
1450
|
+
source = fs13__default.readFileSync(filePath, "utf-8");
|
|
1451
|
+
} catch {
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
filesScanned++;
|
|
1455
|
+
if (!source.includes("states:") && !source.includes("states :")) continue;
|
|
1456
|
+
if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
|
|
1457
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
1458
|
+
if (configs.length > 0) {
|
|
1459
|
+
filesWithStates++;
|
|
1460
|
+
allConfigs.push(...configs);
|
|
1461
|
+
if (verbose) {
|
|
1462
|
+
process.stderr.write(
|
|
1463
|
+
`[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
1464
|
+
`
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
if (allConfigs.length === 0) {
|
|
1471
|
+
return {
|
|
1472
|
+
filesScanned,
|
|
1473
|
+
filesWithStates: 0,
|
|
1474
|
+
componentsFound: 0,
|
|
1475
|
+
rulesGenerated: 0,
|
|
1476
|
+
rulesSkipped: 0,
|
|
1477
|
+
generatedCss: "",
|
|
1478
|
+
rules: []
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1482
|
+
const uniqueConfigs = [];
|
|
1483
|
+
for (const config of allConfigs) {
|
|
1484
|
+
const key = `${config.tag}::${config.statesJson}`;
|
|
1485
|
+
if (!seen.has(key)) {
|
|
1486
|
+
seen.add(key);
|
|
1487
|
+
uniqueConfigs.push({
|
|
1488
|
+
tag: config.tag,
|
|
1489
|
+
componentName: config.componentName,
|
|
1490
|
+
statesJson: config.statesJson
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
|
|
1495
|
+
const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
|
|
1496
|
+
try {
|
|
1497
|
+
const stateMap = JSON.parse(cfg.statesJson);
|
|
1498
|
+
return total + Object.keys(stateMap).length;
|
|
1499
|
+
} catch {
|
|
1500
|
+
return total;
|
|
1501
|
+
}
|
|
1502
|
+
}, 0) - allRules.length;
|
|
1503
|
+
const byComponent = /* @__PURE__ */ new Map();
|
|
1504
|
+
for (const rule of allRules) {
|
|
1505
|
+
const existing = byComponent.get(rule.componentName) ?? [];
|
|
1506
|
+
existing.push(rule);
|
|
1507
|
+
byComponent.set(rule.componentName, existing);
|
|
1508
|
+
}
|
|
1509
|
+
const cssBlocks = [];
|
|
1510
|
+
for (const [componentName, rules] of byComponent) {
|
|
1511
|
+
cssBlocks.push(`/* ${componentName} */`);
|
|
1512
|
+
for (const rule of rules) {
|
|
1513
|
+
cssBlocks.push(`/* state: ${rule.stateName} */`);
|
|
1514
|
+
cssBlocks.push(rule.cssRule);
|
|
1515
|
+
}
|
|
1516
|
+
cssBlocks.push("");
|
|
1517
|
+
}
|
|
1518
|
+
const result = {
|
|
1519
|
+
filesScanned,
|
|
1520
|
+
filesWithStates,
|
|
1521
|
+
componentsFound: allConfigs.length,
|
|
1522
|
+
rulesGenerated: allRules.length,
|
|
1523
|
+
rulesSkipped: Math.max(0, rulesSkipped),
|
|
1524
|
+
generatedCss: cssBlocks.join("\n"),
|
|
1525
|
+
rules: allRules
|
|
1526
|
+
};
|
|
1527
|
+
result.generatedCss = buildCssHeader(result) + result.generatedCss;
|
|
1528
|
+
return result;
|
|
1529
|
+
}
|
|
1530
|
+
function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
1531
|
+
const result = extractStaticStateCss(srcDir, options);
|
|
1532
|
+
const twClassesDir = path9__default.join(path9__default.dirname(safelistPath), "tw-classes");
|
|
1533
|
+
fs13__default.mkdirSync(twClassesDir, { recursive: true });
|
|
1534
|
+
const stateFilePath = path9__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
1535
|
+
if (result.rulesGenerated === 0) {
|
|
1536
|
+
try {
|
|
1537
|
+
fs13__default.writeFileSync(
|
|
1538
|
+
stateFilePath,
|
|
1539
|
+
"/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
|
|
1540
|
+
"utf-8"
|
|
1541
|
+
);
|
|
1542
|
+
} catch {
|
|
1543
|
+
}
|
|
1544
|
+
return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
|
|
1545
|
+
}
|
|
1546
|
+
try {
|
|
1547
|
+
fs13__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
|
|
1548
|
+
return [
|
|
1549
|
+
`[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
|
|
1550
|
+
` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
|
|
1551
|
+
` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
|
|
1552
|
+
` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
|
|
1553
|
+
].join("\n");
|
|
1554
|
+
} catch (writeErr) {
|
|
1555
|
+
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
1556
|
+
return `[tw:static-state] gagal tulis state CSS: ${msg}`;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
|
|
1560
|
+
var init_staticStateExtractor = __esm({
|
|
1561
|
+
"packages/domain/shared/src/staticStateExtractor.ts"() {
|
|
1562
|
+
SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
|
|
1563
|
+
IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
|
|
1564
|
+
_native = null;
|
|
1565
|
+
TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
function getEnvLevel() {
|
|
1569
|
+
const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
|
|
1570
|
+
if (env && env in LEVELS) return env;
|
|
1571
|
+
return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
|
|
1572
|
+
}
|
|
1573
|
+
function setGlobalLogFile(filePath) {
|
|
1574
|
+
_globalLogFile = filePath;
|
|
1575
|
+
_logFileInitialized = false;
|
|
1576
|
+
try {
|
|
1577
|
+
fs13__default.mkdirSync(path9__default.dirname(filePath), { recursive: true });
|
|
1578
|
+
fs13__default.writeFileSync(
|
|
1579
|
+
filePath,
|
|
1580
|
+
`# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
1581
|
+
`,
|
|
1582
|
+
"utf-8"
|
|
1583
|
+
);
|
|
1584
|
+
_logFileInitialized = true;
|
|
1585
|
+
} catch {
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function writeToFile(line) {
|
|
1589
|
+
if (!_globalLogFile || !_logFileInitialized) return;
|
|
1590
|
+
try {
|
|
1591
|
+
fs13__default.appendFileSync(_globalLogFile, line);
|
|
1592
|
+
} catch {
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
function createLogger(prefix, level) {
|
|
1596
|
+
const loggerState = {
|
|
1597
|
+
currentLevel: getEnvLevel(),
|
|
1598
|
+
setLevel(l) {
|
|
1599
|
+
this.currentLevel = l;
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
const log7 = (msgLevel, stream, args) => {
|
|
1603
|
+
if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
|
|
1604
|
+
const line = `[${prefix}] ${args.map(String).join(" ")}
|
|
1605
|
+
`;
|
|
1606
|
+
process[stream].write(line);
|
|
1607
|
+
writeToFile(line);
|
|
1608
|
+
};
|
|
1609
|
+
return {
|
|
1610
|
+
error: (...a) => log7("error", "stderr", a),
|
|
1611
|
+
warn: (...a) => log7("warn", "stderr", a),
|
|
1612
|
+
info: (...a) => log7("info", "stdout", a),
|
|
1613
|
+
debug: (...a) => log7("debug", "stderr", a),
|
|
1614
|
+
setLevel: loggerState.setLevel,
|
|
1615
|
+
setLogFile: (filePath) => setGlobalLogFile(filePath)
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
var LEVELS, _globalLogFile, _logFileInitialized;
|
|
1619
|
+
var init_logger = __esm({
|
|
1620
|
+
"packages/domain/shared/src/logger.ts"() {
|
|
1621
|
+
LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
1622
|
+
_globalLogFile = null;
|
|
1623
|
+
_logFileInitialized = false;
|
|
1624
|
+
createLogger("tailwind-styled");
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
|
|
990
1628
|
// packages/domain/shared/src/index.ts
|
|
991
1629
|
var src_exports = {};
|
|
992
1630
|
__export(src_exports, {
|
|
@@ -1005,18 +1643,21 @@ __export(src_exports, {
|
|
|
1005
1643
|
RegistryPluginEntrySchema: () => RegistryPluginEntrySchema,
|
|
1006
1644
|
ScanCacheClassEntrySchema: () => ScanCacheClassEntrySchema,
|
|
1007
1645
|
ScanCacheSchema: () => ScanCacheSchema,
|
|
1646
|
+
TW_STATE_STATIC_FILENAME: () => TW_STATE_STATIC_FILENAME,
|
|
1008
1647
|
TailwindConfigSchema: () => TailwindConfigSchema,
|
|
1009
1648
|
TelemetryCollector: () => TelemetryCollector,
|
|
1010
1649
|
TwError: () => TwError,
|
|
1650
|
+
appendStaticStateCssToSafelist: () => appendStaticStateCssToSafelist,
|
|
1011
1651
|
assertTailwindV4: () => assertTailwindV4,
|
|
1012
1652
|
calculateHealth: () => calculateHealth,
|
|
1013
1653
|
createBuildTimer: () => createBuildTimer,
|
|
1014
1654
|
createDebugLogger: () => createDebugLogger,
|
|
1015
1655
|
createEsmRequire: () => createEsmRequire,
|
|
1016
|
-
createLogger: () =>
|
|
1656
|
+
createLogger: () => createLogger2,
|
|
1017
1657
|
createObservabilityClient: () => createObservabilityClient,
|
|
1018
1658
|
createTraceSnapshot: () => createTraceSnapshot,
|
|
1019
1659
|
detectTailwind: () => detectTailwind,
|
|
1660
|
+
extractStaticStateCss: () => extractStaticStateCss,
|
|
1020
1661
|
formatDuration: () => formatDuration,
|
|
1021
1662
|
formatErrorCode: () => formatErrorCode,
|
|
1022
1663
|
formatErrorMessage: () => formatErrorMessage,
|
|
@@ -1052,10 +1693,11 @@ __export(src_exports, {
|
|
|
1052
1693
|
resolveRuntimeDir: () => resolveRuntimeDir,
|
|
1053
1694
|
resolveWorkerPath: () => resolveWorkerPath,
|
|
1054
1695
|
safeParseNative: () => safeParseNative,
|
|
1696
|
+
setGlobalLogFile: () => setGlobalLogFile,
|
|
1055
1697
|
tryRequire: () => tryRequire,
|
|
1056
1698
|
wrapUnknownError: () => wrapUnknownError
|
|
1057
1699
|
});
|
|
1058
|
-
function
|
|
1700
|
+
function createLogger2(namespace) {
|
|
1059
1701
|
const prefix = `[${namespace}]`;
|
|
1060
1702
|
return {
|
|
1061
1703
|
warn(...args) {
|
|
@@ -1084,9 +1726,9 @@ function createDebugLogger(namespace, label) {
|
|
|
1084
1726
|
}
|
|
1085
1727
|
};
|
|
1086
1728
|
}
|
|
1087
|
-
function formatIssuePath(
|
|
1088
|
-
if (!
|
|
1089
|
-
return
|
|
1729
|
+
function formatIssuePath(path16) {
|
|
1730
|
+
if (!path16 || path16.length === 0) return "(root)";
|
|
1731
|
+
return path16.map(
|
|
1090
1732
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1091
1733
|
).join(".");
|
|
1092
1734
|
}
|
|
@@ -1100,9 +1742,9 @@ function loadNativeBinding(options) {
|
|
|
1100
1742
|
const { runtimeDir, candidates, isValid } = options;
|
|
1101
1743
|
const loadErrors = [];
|
|
1102
1744
|
for (const candidate of candidates) {
|
|
1103
|
-
const candidatePath =
|
|
1745
|
+
const candidatePath = path9__default.resolve(runtimeDir, candidate);
|
|
1104
1746
|
try {
|
|
1105
|
-
if (!
|
|
1747
|
+
if (!fs13__default.existsSync(candidatePath) && !fs13__default.existsSync(candidatePath + ".node")) {
|
|
1106
1748
|
continue;
|
|
1107
1749
|
}
|
|
1108
1750
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1134,9 +1776,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1134
1776
|
}
|
|
1135
1777
|
}
|
|
1136
1778
|
if (!includeDefaultCandidates) return candidates;
|
|
1137
|
-
if (
|
|
1779
|
+
if (fs13__default.existsSync(runtimeDir)) {
|
|
1138
1780
|
try {
|
|
1139
|
-
for (const entry of
|
|
1781
|
+
for (const entry of fs13__default.readdirSync(runtimeDir)) {
|
|
1140
1782
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1141
1783
|
}
|
|
1142
1784
|
} catch {
|
|
@@ -1145,22 +1787,22 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1145
1787
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
1146
1788
|
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
1147
1789
|
for (const bin of BINARY_NAMES) {
|
|
1148
|
-
candidates.push(
|
|
1149
|
-
candidates.push(
|
|
1150
|
-
candidates.push(
|
|
1151
|
-
candidates.push(
|
|
1152
|
-
candidates.push(
|
|
1153
|
-
candidates.push(
|
|
1154
|
-
candidates.push(
|
|
1155
|
-
candidates.push(
|
|
1156
|
-
candidates.push(
|
|
1790
|
+
candidates.push(path9__default.resolve(runtimeDir, `${bin}.node`));
|
|
1791
|
+
candidates.push(path9__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
1792
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
1793
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1794
|
+
candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1795
|
+
candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1796
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
1797
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1798
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1157
1799
|
}
|
|
1158
1800
|
return Array.from(new Set(candidates));
|
|
1159
1801
|
}
|
|
1160
1802
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
1161
|
-
if (dir) return
|
|
1803
|
+
if (dir) return path9__default.resolve(dir);
|
|
1162
1804
|
try {
|
|
1163
|
-
return
|
|
1805
|
+
return path9__default.dirname(fileURLToPath(importMetaUrl));
|
|
1164
1806
|
} catch {
|
|
1165
1807
|
return process.cwd();
|
|
1166
1808
|
}
|
|
@@ -1188,6 +1830,8 @@ var init_src = __esm({
|
|
|
1188
1830
|
init_codegen();
|
|
1189
1831
|
init_native_resolution();
|
|
1190
1832
|
init_observability();
|
|
1833
|
+
init_staticStateExtractor();
|
|
1834
|
+
init_logger();
|
|
1191
1835
|
TwError = class _TwError extends Error {
|
|
1192
1836
|
/** @deprecated Gunakan source */
|
|
1193
1837
|
domain;
|
|
@@ -1221,8 +1865,8 @@ var init_src = __esm({
|
|
|
1221
1865
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
1222
1866
|
static fromZod(err) {
|
|
1223
1867
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
1224
|
-
const
|
|
1225
|
-
const message = first ? `${
|
|
1868
|
+
const path16 = formatIssuePath(first?.path);
|
|
1869
|
+
const message = first ? `${path16}: ${first.message}` : "Schema validation failed";
|
|
1226
1870
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
1227
1871
|
}
|
|
1228
1872
|
static wrap(source, code, err) {
|
|
@@ -1286,11 +1930,11 @@ var init_src = __esm({
|
|
|
1286
1930
|
});
|
|
1287
1931
|
|
|
1288
1932
|
// packages/domain/compiler/src/nativeBridge.ts
|
|
1289
|
-
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
1933
|
+
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
|
|
1290
1934
|
var init_nativeBridge = __esm({
|
|
1291
1935
|
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
1292
1936
|
init_src();
|
|
1293
|
-
_loadNative = (
|
|
1937
|
+
_loadNative = (path16) => __require(path16);
|
|
1294
1938
|
log = (...args) => {
|
|
1295
1939
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
1296
1940
|
console.log("[compiler:native]", ...args);
|
|
@@ -1339,6 +1983,15 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
1339
1983
|
throw bridgeLoadError;
|
|
1340
1984
|
}
|
|
1341
1985
|
};
|
|
1986
|
+
adaptNativeResult = (raw) => {
|
|
1987
|
+
return {
|
|
1988
|
+
code: raw.code ?? "",
|
|
1989
|
+
classes: raw.classes ?? [],
|
|
1990
|
+
changed: raw.changed ?? false,
|
|
1991
|
+
rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
|
|
1992
|
+
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
1993
|
+
};
|
|
1994
|
+
};
|
|
1342
1995
|
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
1343
1996
|
try {
|
|
1344
1997
|
getNativeBridge();
|
|
@@ -1347,103 +2000,470 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
1347
2000
|
}
|
|
1348
2001
|
}
|
|
1349
2002
|
});
|
|
1350
|
-
|
|
1351
|
-
// packages/domain/compiler/src/tailwindEngine.ts
|
|
1352
|
-
var tailwindEngine_exports = {};
|
|
1353
|
-
__export(tailwindEngine_exports, {
|
|
1354
|
-
generateRawCss: () => generateRawCss,
|
|
1355
|
-
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
1356
|
-
runCssPipeline: () => runCssPipeline,
|
|
1357
|
-
runCssPipelineSync: () => runCssPipelineSync
|
|
1358
|
-
});
|
|
1359
|
-
function loadTailwindEngine() {
|
|
1360
|
-
if (_twEngine) return _twEngine;
|
|
1361
|
-
if (_twEngineError) throw _twEngineError;
|
|
1362
|
-
try {
|
|
1363
|
-
const tw = require2("tailwindcss");
|
|
1364
|
-
if (typeof tw.compile !== "function") {
|
|
1365
|
-
throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
|
|
1366
|
-
}
|
|
1367
|
-
_twEngine = tw;
|
|
1368
|
-
return _twEngine;
|
|
1369
|
-
} catch (e) {
|
|
1370
|
-
_twEngineError = e instanceof Error ? e : new Error(String(e));
|
|
1371
|
-
throw _twEngineError;
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
async function generateRawCss(classes, cssEntryContent, root) {
|
|
1375
|
-
if (classes.length === 0) return "";
|
|
1376
|
-
const tw = loadTailwindEngine();
|
|
1377
|
-
const input = cssEntryContent ?? "@import 'tailwindcss';";
|
|
1378
|
-
const { readFileSync, existsSync: existsSync3 } = await import('fs');
|
|
1379
|
-
const { dirname, resolve: resolve2 } = await import('path');
|
|
1380
|
-
const projectRoot = root ?? process.cwd();
|
|
1381
|
-
const req = createRequire(resolve2(projectRoot, "package.json"));
|
|
1382
|
-
const loadStylesheet = async (id, base) => {
|
|
1383
|
-
try {
|
|
1384
|
-
const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
|
|
1385
|
-
const pkgPath = req.resolve(cssId);
|
|
1386
|
-
return {
|
|
1387
|
-
content: readFileSync(pkgPath, "utf-8"),
|
|
1388
|
-
base: dirname(pkgPath)
|
|
1389
|
-
};
|
|
1390
|
-
} catch {
|
|
1391
|
-
try {
|
|
1392
|
-
const absPath = resolve2(base, id);
|
|
1393
|
-
if (existsSync3(absPath)) {
|
|
1394
|
-
return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
|
|
1395
|
-
}
|
|
1396
|
-
} catch {
|
|
1397
|
-
}
|
|
1398
|
-
return { content: "", base };
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
|
|
1402
|
-
return compiler.build(classes);
|
|
1403
|
-
}
|
|
1404
|
-
function postProcessWithLightning(rawCss) {
|
|
1405
|
-
if (!rawCss) return "";
|
|
2003
|
+
function _layoutClassesToCss(classes) {
|
|
1406
2004
|
const native = getNativeBridge();
|
|
1407
|
-
if (
|
|
1408
|
-
throw new Error("FATAL: Native binding '
|
|
2005
|
+
if (!native?.layoutClassesToCss) {
|
|
2006
|
+
throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
|
|
1409
2007
|
}
|
|
1410
|
-
|
|
1411
|
-
return result?.css ?? rawCss;
|
|
2008
|
+
return native.layoutClassesToCss(classes);
|
|
1412
2009
|
}
|
|
1413
|
-
|
|
1414
|
-
const
|
|
1415
|
-
if (unique.length === 0) {
|
|
1416
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1417
|
-
}
|
|
1418
|
-
const rawCss = await generateRawCss(unique, cssEntryContent, root);
|
|
2010
|
+
function _hashContainer(tag, containerJson, name) {
|
|
2011
|
+
const sortedKey = tag + (name ?? "") + containerJson;
|
|
1419
2012
|
const native = getNativeBridge();
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
classes: unique,
|
|
1425
|
-
sizeBytes: finalCss.length,
|
|
1426
|
-
optimized: hasLightning
|
|
1427
|
-
};
|
|
1428
|
-
}
|
|
1429
|
-
function runCssPipelineSync(_classes) {
|
|
1430
|
-
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
2013
|
+
if (!native?.hashContent) {
|
|
2014
|
+
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
2015
|
+
}
|
|
2016
|
+
return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
1431
2017
|
}
|
|
1432
|
-
function
|
|
2018
|
+
function extractContainerCssFromSource(source) {
|
|
1433
2019
|
const native = getNativeBridge();
|
|
1434
|
-
if (!native?.
|
|
1435
|
-
throw new Error("FATAL: Native binding '
|
|
2020
|
+
if (!native?.extractTwContainerConfigs) {
|
|
2021
|
+
throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
|
|
2022
|
+
}
|
|
2023
|
+
const configs = native.extractTwContainerConfigs(source);
|
|
2024
|
+
const rules = [];
|
|
2025
|
+
for (const cfg of configs) {
|
|
2026
|
+
const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
|
|
2027
|
+
for (const { key, classes } of cfg.breakpoints) {
|
|
2028
|
+
const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
|
|
2029
|
+
const css = _layoutClassesToCss(classes);
|
|
2030
|
+
if (!css) continue;
|
|
2031
|
+
const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
2032
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
2033
|
+
}
|
|
1436
2034
|
}
|
|
1437
|
-
|
|
1438
|
-
return (result?.css ?? css).trim();
|
|
2035
|
+
return rules.join("\n");
|
|
1439
2036
|
}
|
|
1440
|
-
var
|
|
1441
|
-
var
|
|
1442
|
-
"packages/domain/compiler/src/
|
|
2037
|
+
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;
|
|
2038
|
+
var init_src2 = __esm({
|
|
2039
|
+
"packages/domain/compiler/src/index.ts"() {
|
|
1443
2040
|
init_nativeBridge();
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
2041
|
+
transformSource = (source, opts) => {
|
|
2042
|
+
const native = getNativeBridge();
|
|
2043
|
+
if (!native?.transformSource) {
|
|
2044
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2045
|
+
}
|
|
2046
|
+
const result = native.transformSource(source, opts);
|
|
2047
|
+
if (!result) {
|
|
2048
|
+
throw new Error("FATAL: transformSource returned null");
|
|
2049
|
+
}
|
|
2050
|
+
return result;
|
|
2051
|
+
};
|
|
2052
|
+
hasTwUsage = (source) => {
|
|
2053
|
+
const native = getNativeBridge();
|
|
2054
|
+
if (!native?.hasTwUsage) {
|
|
2055
|
+
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
2056
|
+
}
|
|
2057
|
+
return native.hasTwUsage(source);
|
|
2058
|
+
};
|
|
2059
|
+
isAlreadyTransformed = (source) => {
|
|
2060
|
+
const native = getNativeBridge();
|
|
2061
|
+
if (!native?.isAlreadyTransformed) {
|
|
2062
|
+
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
2063
|
+
}
|
|
2064
|
+
return native.isAlreadyTransformed(source);
|
|
2065
|
+
};
|
|
2066
|
+
shouldProcess = (source) => {
|
|
2067
|
+
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
2068
|
+
};
|
|
2069
|
+
compileCssFromClasses = (classes, prefix) => {
|
|
2070
|
+
const native = getNativeBridge();
|
|
2071
|
+
if (!native?.transformSource) {
|
|
2072
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2073
|
+
}
|
|
2074
|
+
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
2075
|
+
if (!result) {
|
|
2076
|
+
throw new Error("FATAL: transformSource returned null");
|
|
2077
|
+
}
|
|
2078
|
+
return result;
|
|
2079
|
+
};
|
|
2080
|
+
buildStyleTag = (classes) => {
|
|
2081
|
+
const result = compileCssFromClasses(classes);
|
|
2082
|
+
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
2083
|
+
};
|
|
2084
|
+
compileCssNative = (classes, prefix = null) => {
|
|
2085
|
+
return compileCssFromClasses(classes, prefix);
|
|
2086
|
+
};
|
|
2087
|
+
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2088
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2089
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2090
|
+
return result.css;
|
|
2091
|
+
};
|
|
2092
|
+
extractAllClasses = (source) => {
|
|
2093
|
+
const native = getNativeBridge();
|
|
2094
|
+
if (!native?.extractAllClasses) {
|
|
2095
|
+
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
2096
|
+
}
|
|
2097
|
+
return native.extractAllClasses(source) || [];
|
|
2098
|
+
};
|
|
2099
|
+
extractClassesFromSource = (source) => {
|
|
2100
|
+
const native = getNativeBridge();
|
|
2101
|
+
if (!native?.extractClassesFromSource) {
|
|
2102
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
2103
|
+
}
|
|
2104
|
+
const result = native.extractClassesFromSource(source);
|
|
2105
|
+
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
2106
|
+
};
|
|
2107
|
+
astExtractClasses = (source, _filename) => {
|
|
2108
|
+
const native = getNativeBridge();
|
|
2109
|
+
if (!native?.extractClassesFromSource) {
|
|
2110
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
2111
|
+
}
|
|
2112
|
+
return native.extractClassesFromSource(source) || [];
|
|
2113
|
+
};
|
|
2114
|
+
parseClasses = (raw) => {
|
|
2115
|
+
const native = getNativeBridge();
|
|
2116
|
+
if (!native?.parseClasses) {
|
|
2117
|
+
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
2118
|
+
}
|
|
2119
|
+
return native.parseClasses(raw) || [];
|
|
2120
|
+
};
|
|
2121
|
+
normalizeClasses = (raw) => {
|
|
2122
|
+
const result = normalizeAndDedupClasses(raw);
|
|
2123
|
+
return result?.normalized || "";
|
|
2124
|
+
};
|
|
2125
|
+
mergeClassesStatic = (classes) => {
|
|
2126
|
+
const result = normalizeAndDedupClasses(classes);
|
|
2127
|
+
return result?.normalized || "";
|
|
2128
|
+
};
|
|
2129
|
+
normalizeAndDedupClasses = (raw) => {
|
|
2130
|
+
const native = getNativeBridge();
|
|
2131
|
+
if (!native?.normalizeAndDedupClasses) {
|
|
2132
|
+
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
2133
|
+
}
|
|
2134
|
+
const result = native.normalizeAndDedupClasses(raw);
|
|
2135
|
+
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
2136
|
+
};
|
|
2137
|
+
eliminateDeadCss = (css, deadClasses) => {
|
|
2138
|
+
const native = getNativeBridge();
|
|
2139
|
+
if (!native?.eliminateDeadCss) {
|
|
2140
|
+
throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
|
|
2141
|
+
}
|
|
2142
|
+
return native.eliminateDeadCss(css, Array.from(deadClasses));
|
|
2143
|
+
};
|
|
2144
|
+
findDeadVariants = (variantConfig, usage) => {
|
|
2145
|
+
const unused = [];
|
|
2146
|
+
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
2147
|
+
for (const component of configs) {
|
|
2148
|
+
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
2149
|
+
const variants = component.variants;
|
|
2150
|
+
for (const [key, values] of Object.entries(variants)) {
|
|
2151
|
+
for (const [value] of Object.entries(values)) {
|
|
2152
|
+
if (!componentUsage.has(`${key}:${value}`)) {
|
|
2153
|
+
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
return { unusedCount: unused.length, unused };
|
|
2159
|
+
};
|
|
2160
|
+
runElimination = (css, scanResult) => {
|
|
2161
|
+
const native = getNativeBridge();
|
|
2162
|
+
if (!native?.detectDeadCode) {
|
|
2163
|
+
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
2164
|
+
}
|
|
2165
|
+
const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
|
|
2166
|
+
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
2167
|
+
};
|
|
2168
|
+
optimizeCss = (css) => {
|
|
2169
|
+
const native = getNativeBridge();
|
|
2170
|
+
if (!native?.optimizeCss) {
|
|
2171
|
+
throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
|
|
2172
|
+
}
|
|
2173
|
+
return native.optimizeCss(css);
|
|
2174
|
+
};
|
|
2175
|
+
scanProjectUsage = (dirs, cwd) => {
|
|
2176
|
+
const files = dirs.map((dir) => path9__default.resolve(cwd, dir));
|
|
2177
|
+
const results = batchExtractClasses(files) || [];
|
|
2178
|
+
const combined = {};
|
|
2179
|
+
for (const result of results) {
|
|
2180
|
+
if (result.ok && result.classes) {
|
|
2181
|
+
for (const cls of result.classes) {
|
|
2182
|
+
if (!combined[cls]) combined[cls] = {};
|
|
2183
|
+
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
return combined;
|
|
2188
|
+
};
|
|
2189
|
+
extractComponentUsage = (source) => {
|
|
2190
|
+
const native = getNativeBridge();
|
|
2191
|
+
if (!native?.extractComponentUsage) {
|
|
2192
|
+
throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
|
|
2193
|
+
}
|
|
2194
|
+
return native.extractComponentUsage(source) || [];
|
|
2195
|
+
};
|
|
2196
|
+
diffClassLists = (previous, current) => {
|
|
2197
|
+
const native = getNativeBridge();
|
|
2198
|
+
if (!native?.diffClassLists) {
|
|
2199
|
+
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
2200
|
+
}
|
|
2201
|
+
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
2202
|
+
};
|
|
2203
|
+
batchExtractClasses = (filePaths) => {
|
|
2204
|
+
const native = getNativeBridge();
|
|
2205
|
+
if (!native?.batchExtractClasses) {
|
|
2206
|
+
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
2207
|
+
}
|
|
2208
|
+
return native.batchExtractClasses(filePaths) || [];
|
|
2209
|
+
};
|
|
2210
|
+
checkAgainstSafelist = (classes, safelist) => {
|
|
2211
|
+
const native = getNativeBridge();
|
|
2212
|
+
if (!native?.checkAgainstSafelist) {
|
|
2213
|
+
throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
|
|
2214
|
+
}
|
|
2215
|
+
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
2216
|
+
};
|
|
2217
|
+
hoistComponents = (source) => {
|
|
2218
|
+
const native = getNativeBridge();
|
|
2219
|
+
if (!native?.hoistComponents) {
|
|
2220
|
+
throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
|
|
2221
|
+
}
|
|
2222
|
+
return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
|
|
2223
|
+
};
|
|
2224
|
+
compileVariantTable = (configJson) => {
|
|
2225
|
+
const native = getNativeBridge();
|
|
2226
|
+
if (!native?.compileVariantTable) {
|
|
2227
|
+
throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
|
|
2228
|
+
}
|
|
2229
|
+
return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
|
|
2230
|
+
};
|
|
2231
|
+
compileVariants = (componentId, config) => {
|
|
2232
|
+
return compileVariantTable(JSON.stringify({ componentId, ...config }));
|
|
2233
|
+
};
|
|
2234
|
+
classifyAndSortClasses = (classes) => {
|
|
2235
|
+
const native = getNativeBridge();
|
|
2236
|
+
if (!native?.classifyAndSortClasses) {
|
|
2237
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2238
|
+
}
|
|
2239
|
+
return native.classifyAndSortClasses(classes) || [];
|
|
2240
|
+
};
|
|
2241
|
+
mergeCssDeclarations = (cssChunks) => {
|
|
2242
|
+
const native = getNativeBridge();
|
|
2243
|
+
if (!native?.mergeCssDeclarations) {
|
|
2244
|
+
throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
|
|
2245
|
+
}
|
|
2246
|
+
return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
|
|
2247
|
+
};
|
|
2248
|
+
analyzeClassUsage = (classes, scanResultJson, css) => {
|
|
2249
|
+
const native = getNativeBridge();
|
|
2250
|
+
if (!native?.analyzeClassUsage) {
|
|
2251
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
2252
|
+
}
|
|
2253
|
+
return native.analyzeClassUsage(classes, scanResultJson, css) || [];
|
|
2254
|
+
};
|
|
2255
|
+
analyzeRsc = (source, filename) => {
|
|
2256
|
+
const native = getNativeBridge();
|
|
2257
|
+
if (!native?.analyzeRsc) {
|
|
2258
|
+
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
2259
|
+
}
|
|
2260
|
+
return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
|
|
2261
|
+
};
|
|
2262
|
+
analyzeFile = (source, filename) => {
|
|
2263
|
+
const rsc = analyzeRsc(source, filename);
|
|
2264
|
+
return {
|
|
2265
|
+
isServer: rsc?.isServer ?? true,
|
|
2266
|
+
needsClientDirective: rsc?.needsClientDirective ?? false,
|
|
2267
|
+
clientReasons: rsc?.clientReasons ?? [],
|
|
2268
|
+
interactiveClasses: [],
|
|
2269
|
+
canStaticResolveVariants: true
|
|
2270
|
+
};
|
|
2271
|
+
};
|
|
2272
|
+
analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
|
|
2273
|
+
return { resolved: {}, dynamic: [] };
|
|
2274
|
+
};
|
|
2275
|
+
injectClientDirective = (source) => {
|
|
2276
|
+
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
2277
|
+
return '"use client";\n' + source;
|
|
2278
|
+
}
|
|
2279
|
+
return source;
|
|
2280
|
+
};
|
|
2281
|
+
injectServerOnlyComment = (source) => {
|
|
2282
|
+
return `/* @server-only */
|
|
2283
|
+
${source}`;
|
|
2284
|
+
};
|
|
2285
|
+
analyzeClasses = (filesJson, cwd, flags) => {
|
|
2286
|
+
const native = getNativeBridge();
|
|
2287
|
+
if (!native?.analyzeClasses) {
|
|
2288
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
2289
|
+
}
|
|
2290
|
+
return native.analyzeClasses(filesJson, cwd, flags);
|
|
2291
|
+
};
|
|
2292
|
+
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
2293
|
+
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
2294
|
+
const allClasses = Object.keys(classes).sort();
|
|
2295
|
+
if (outputPath) {
|
|
2296
|
+
fs13__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
2297
|
+
}
|
|
2298
|
+
return allClasses;
|
|
2299
|
+
};
|
|
2300
|
+
loadSafelist = (safelistPath) => {
|
|
2301
|
+
try {
|
|
2302
|
+
const content = fs13__default.readFileSync(safelistPath, "utf-8");
|
|
2303
|
+
return JSON.parse(content);
|
|
2304
|
+
} catch {
|
|
2305
|
+
return [];
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
2309
|
+
const configFiles = [
|
|
2310
|
+
"tailwind.config.ts",
|
|
2311
|
+
"tailwind.config.js",
|
|
2312
|
+
"tailwind.config.mjs",
|
|
2313
|
+
"tailwind.config.cjs"
|
|
2314
|
+
];
|
|
2315
|
+
for (const file of configFiles) {
|
|
2316
|
+
const fullPath = path9__default.join(cwd, file);
|
|
2317
|
+
if (fs13__default.existsSync(fullPath)) {
|
|
2318
|
+
const mod = __require(fullPath);
|
|
2319
|
+
return mod.default || mod;
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return {};
|
|
2323
|
+
};
|
|
2324
|
+
getContentPaths = (cwd = process.cwd()) => {
|
|
2325
|
+
return {
|
|
2326
|
+
content: [
|
|
2327
|
+
path9__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
2328
|
+
path9__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
2329
|
+
path9__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
2330
|
+
]
|
|
2331
|
+
};
|
|
2332
|
+
};
|
|
2333
|
+
_CONTAINER_BREAKPOINTS = {
|
|
2334
|
+
xs: "240px",
|
|
2335
|
+
sm: "320px",
|
|
2336
|
+
md: "640px",
|
|
2337
|
+
lg: "1024px",
|
|
2338
|
+
xl: "1280px",
|
|
2339
|
+
"2xl": "1536px"
|
|
2340
|
+
};
|
|
2341
|
+
runLoaderTransform = (ctx) => {
|
|
2342
|
+
const { filepath, source, options } = ctx;
|
|
2343
|
+
const result = transformSource(source, { filename: filepath, ...options });
|
|
2344
|
+
let staticCss;
|
|
2345
|
+
try {
|
|
2346
|
+
const cssChunks = [];
|
|
2347
|
+
const stateRules = extractAndGenerateStateCss(source, filepath);
|
|
2348
|
+
if (stateRules.length > 0) {
|
|
2349
|
+
cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
|
|
2350
|
+
}
|
|
2351
|
+
const containerCss = extractContainerCssFromSource(source);
|
|
2352
|
+
if (containerCss) cssChunks.push(containerCss);
|
|
2353
|
+
const combined = cssChunks.join("\n").trim();
|
|
2354
|
+
if (combined) staticCss = combined;
|
|
2355
|
+
} catch {
|
|
2356
|
+
}
|
|
2357
|
+
return {
|
|
2358
|
+
code: result?.code || "",
|
|
2359
|
+
changed: result?.changed || false,
|
|
2360
|
+
classes: result?.classes || [],
|
|
2361
|
+
staticCss
|
|
2362
|
+
};
|
|
2363
|
+
};
|
|
2364
|
+
shouldSkipFile = (filepath) => {
|
|
2365
|
+
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
2366
|
+
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
2367
|
+
for (const p of SKIP_PATHS) {
|
|
2368
|
+
if (filepath.includes(p)) return true;
|
|
2369
|
+
}
|
|
2370
|
+
for (const ext of skipExtensions) {
|
|
2371
|
+
if (filepath.endsWith(ext)) return true;
|
|
2372
|
+
}
|
|
2373
|
+
return false;
|
|
2374
|
+
};
|
|
2375
|
+
fileToRoute = (filepath) => {
|
|
2376
|
+
const normalized = filepath.replace(/\\/g, "/");
|
|
2377
|
+
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
2378
|
+
return "__global";
|
|
2379
|
+
}
|
|
2380
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
2381
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
2382
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
2383
|
+
if (rootPage) return "/";
|
|
2384
|
+
return null;
|
|
2385
|
+
};
|
|
2386
|
+
getAllRoutes = () => {
|
|
2387
|
+
const native = getNativeBridge();
|
|
2388
|
+
if (!native?.analyzeClasses) {
|
|
2389
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
2390
|
+
}
|
|
2391
|
+
return ["/", "__global"];
|
|
2392
|
+
};
|
|
2393
|
+
getRouteClasses = (_route) => /* @__PURE__ */ new Set();
|
|
2394
|
+
registerFileClasses = (_filepath, _classes) => {
|
|
2395
|
+
};
|
|
2396
|
+
registerGlobalClasses = (_classes) => {
|
|
2397
|
+
};
|
|
2398
|
+
_incrementalEngineInstance = null;
|
|
2399
|
+
getIncrementalEngine = () => {
|
|
2400
|
+
if (!_incrementalEngineInstance) {
|
|
2401
|
+
_incrementalEngineInstance = new IncrementalEngine();
|
|
2402
|
+
}
|
|
2403
|
+
return _incrementalEngineInstance;
|
|
2404
|
+
};
|
|
2405
|
+
resetIncrementalEngine = () => {
|
|
2406
|
+
_incrementalEngineInstance = null;
|
|
2407
|
+
};
|
|
2408
|
+
IncrementalEngine = class {
|
|
2409
|
+
compile(source) {
|
|
2410
|
+
return transformSource(source);
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
getBucketEngine = () => {
|
|
2414
|
+
const native = getNativeBridge();
|
|
2415
|
+
if (!native?.classifyAndSortClasses) {
|
|
2416
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2417
|
+
}
|
|
2418
|
+
return {
|
|
2419
|
+
add: (className) => className,
|
|
2420
|
+
get: (_bucket) => []
|
|
2421
|
+
};
|
|
2422
|
+
};
|
|
2423
|
+
resetBucketEngine = () => {
|
|
2424
|
+
};
|
|
2425
|
+
classifyNode = (_node) => {
|
|
2426
|
+
const native = getNativeBridge();
|
|
2427
|
+
if (!native?.classifyAndSortClasses) {
|
|
2428
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
2429
|
+
}
|
|
2430
|
+
return "unknown";
|
|
2431
|
+
};
|
|
2432
|
+
detectConflicts = (_classes) => {
|
|
2433
|
+
const native = getNativeBridge();
|
|
2434
|
+
if (!native?.analyzeClassUsage) {
|
|
2435
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
2436
|
+
}
|
|
2437
|
+
return [];
|
|
2438
|
+
};
|
|
2439
|
+
bucketSort = (classes) => {
|
|
2440
|
+
return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
|
|
2441
|
+
};
|
|
2442
|
+
extractTwStateConfigs = (source, filename) => {
|
|
2443
|
+
const native = getNativeBridge();
|
|
2444
|
+
if (!native?.extractTwStateConfigs) {
|
|
2445
|
+
throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
|
|
2446
|
+
}
|
|
2447
|
+
return native.extractTwStateConfigs(source, filename);
|
|
2448
|
+
};
|
|
2449
|
+
generateStaticStateCss = (inputs, resolvedCss = null) => {
|
|
2450
|
+
const native = getNativeBridge();
|
|
2451
|
+
if (!native?.generateStaticStateCss) {
|
|
2452
|
+
throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
|
|
2453
|
+
}
|
|
2454
|
+
return native.generateStaticStateCss(inputs, resolvedCss);
|
|
2455
|
+
};
|
|
2456
|
+
extractAndGenerateStateCss = (source, filename) => {
|
|
2457
|
+
const native = getNativeBridge();
|
|
2458
|
+
if (!native?.extractAndGenerateStateCss) {
|
|
2459
|
+
const configs = extractTwStateConfigs(source, filename);
|
|
2460
|
+
if (configs.length === 0) return [];
|
|
2461
|
+
return generateStaticStateCss(
|
|
2462
|
+
configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
|
|
2463
|
+
);
|
|
2464
|
+
}
|
|
2465
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
2466
|
+
};
|
|
1447
2467
|
}
|
|
1448
2468
|
});
|
|
1449
2469
|
|
|
@@ -1481,7 +2501,7 @@ function getDirname2() {
|
|
|
1481
2501
|
return __dirname;
|
|
1482
2502
|
}
|
|
1483
2503
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
1484
|
-
return
|
|
2504
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
1485
2505
|
}
|
|
1486
2506
|
return process.cwd();
|
|
1487
2507
|
}
|
|
@@ -1770,12 +2790,12 @@ var init_native_bridge = __esm({
|
|
|
1770
2790
|
}
|
|
1771
2791
|
});
|
|
1772
2792
|
function defaultCachePath(rootDir, cacheDir) {
|
|
1773
|
-
const dir = cacheDir ?
|
|
1774
|
-
return
|
|
2793
|
+
const dir = cacheDir ? path9__default.resolve(rootDir, cacheDir) : path9__default.join(process.cwd(), ".cache", "tailwind-styled");
|
|
2794
|
+
return path9__default.join(dir, "scanner-cache.json");
|
|
1775
2795
|
}
|
|
1776
2796
|
function readCache(rootDir, cacheDir) {
|
|
1777
2797
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1778
|
-
|
|
2798
|
+
fs13__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
|
|
1779
2799
|
const result = cacheReadNative(cachePath);
|
|
1780
2800
|
if (!result) return [];
|
|
1781
2801
|
return result.entries.map((e) => ({
|
|
@@ -1790,7 +2810,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1790
2810
|
}
|
|
1791
2811
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1792
2812
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1793
|
-
|
|
2813
|
+
fs13__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
|
|
1794
2814
|
const success = cacheWriteNative(cachePath, entries);
|
|
1795
2815
|
if (!success) {
|
|
1796
2816
|
throw new Error(
|
|
@@ -1817,27 +2837,7 @@ var init_cache_native = __esm({
|
|
|
1817
2837
|
function collectFiles(rootDir, extensions, ignoreDirs) {
|
|
1818
2838
|
const native = collectFilesNative(rootDir, extensions, ignoreDirs);
|
|
1819
2839
|
if (native !== null) return native;
|
|
1820
|
-
|
|
1821
|
-
function walk(dir) {
|
|
1822
|
-
let entries;
|
|
1823
|
-
try {
|
|
1824
|
-
entries = fs5__default.readdirSync(dir, { withFileTypes: true });
|
|
1825
|
-
} catch {
|
|
1826
|
-
return;
|
|
1827
|
-
}
|
|
1828
|
-
for (const entry of entries) {
|
|
1829
|
-
const fullPath = path6__default.join(dir, entry.name);
|
|
1830
|
-
const rel = path6__default.relative(rootDir, fullPath);
|
|
1831
|
-
if (entry.isDirectory()) {
|
|
1832
|
-
const ignored = ignoreDirs.some((d) => entry.name === d || rel.startsWith(d + path6__default.sep));
|
|
1833
|
-
if (!ignored) walk(fullPath);
|
|
1834
|
-
} else if (isScannableFile(entry.name, extensions)) {
|
|
1835
|
-
files.push(fullPath);
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
walk(rootDir);
|
|
1840
|
-
return files;
|
|
2840
|
+
throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
|
|
1841
2841
|
}
|
|
1842
2842
|
function mergeResults(batchResults) {
|
|
1843
2843
|
const files = batchResults.map((r) => ({
|
|
@@ -1847,8 +2847,7 @@ function mergeResults(batchResults) {
|
|
|
1847
2847
|
}));
|
|
1848
2848
|
const native = rebuildWorkspaceResultNative(files);
|
|
1849
2849
|
if (native) return native;
|
|
1850
|
-
|
|
1851
|
-
return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
|
|
2850
|
+
throw new Error("FATAL: Native binding 'rebuildWorkspaceResult' is required but not available.");
|
|
1852
2851
|
}
|
|
1853
2852
|
function runChunkInWorker(filePaths) {
|
|
1854
2853
|
return new Promise((resolve2, reject) => {
|
|
@@ -1875,7 +2874,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1875
2874
|
maxWorkers = Math.max(1, availableParallelism() - 1),
|
|
1876
2875
|
chunkSize = DEFAULT_CHUNK_SIZE
|
|
1877
2876
|
} = options;
|
|
1878
|
-
const files = collectFiles(
|
|
2877
|
+
const files = collectFiles(path9__default.resolve(rootDir), extensions, ignoreDirs);
|
|
1879
2878
|
if (files.length < PARALLEL_THRESHOLD) {
|
|
1880
2879
|
return mergeResults(batchExtractClassesNative(files));
|
|
1881
2880
|
}
|
|
@@ -1894,7 +2893,7 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1894
2893
|
var PARALLEL_THRESHOLD, DEFAULT_CHUNK_SIZE, _workerFilename;
|
|
1895
2894
|
var init_parallel_scanner = __esm({
|
|
1896
2895
|
"packages/domain/scanner/src/parallel-scanner.ts"() {
|
|
1897
|
-
|
|
2896
|
+
init_src3();
|
|
1898
2897
|
init_native_bridge();
|
|
1899
2898
|
PARALLEL_THRESHOLD = 50;
|
|
1900
2899
|
DEFAULT_CHUNK_SIZE = 150;
|
|
@@ -1919,12 +2918,12 @@ var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, S
|
|
|
1919
2918
|
var init_schemas = __esm({
|
|
1920
2919
|
"packages/domain/scanner/src/schemas.ts"() {
|
|
1921
2920
|
init_src();
|
|
1922
|
-
formatIssuePath2 = (
|
|
2921
|
+
formatIssuePath2 = (path16) => path16.length > 0 ? path16.map(
|
|
1923
2922
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1924
2923
|
).join(".") : "<root>";
|
|
1925
2924
|
formatIssues = (error) => error.issues.map((issue) => {
|
|
1926
|
-
const
|
|
1927
|
-
return `${
|
|
2925
|
+
const path16 = formatIssuePath2(issue.path);
|
|
2926
|
+
return `${path16}: ${issue.message}`;
|
|
1928
2927
|
}).join("; ");
|
|
1929
2928
|
parseWithSchema = (schema, data, label) => {
|
|
1930
2929
|
const parsed = schema.safeParse(data);
|
|
@@ -1987,7 +2986,7 @@ __export(src_exports2, {
|
|
|
1987
2986
|
DEFAULT_IGNORES: () => DEFAULT_IGNORES,
|
|
1988
2987
|
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
1989
2988
|
extractClassesNative: () => extractClassesNative,
|
|
1990
|
-
isScannableFile: () =>
|
|
2989
|
+
isScannableFile: () => isScannableFile2,
|
|
1991
2990
|
parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
|
|
1992
2991
|
parseScanWorkspaceResult: () => parseScanWorkspaceResult,
|
|
1993
2992
|
parseScannerWorkerMessage: () => parseScannerWorkerMessage,
|
|
@@ -2001,7 +3000,7 @@ function getRuntimeDir() {
|
|
|
2001
3000
|
return __dirname;
|
|
2002
3001
|
}
|
|
2003
3002
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
2004
|
-
return
|
|
3003
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
2005
3004
|
}
|
|
2006
3005
|
return process.cwd();
|
|
2007
3006
|
}
|
|
@@ -2011,17 +3010,17 @@ function resolveScannerWorkerModulePath() {
|
|
|
2011
3010
|
return __dirname;
|
|
2012
3011
|
}
|
|
2013
3012
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
2014
|
-
return
|
|
3013
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
2015
3014
|
}
|
|
2016
3015
|
return process.cwd();
|
|
2017
3016
|
})();
|
|
2018
3017
|
const candidates = [
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
3018
|
+
path9__default.resolve(runtimeDir, "worker.cjs"),
|
|
3019
|
+
path9__default.resolve(runtimeDir, "worker.js"),
|
|
3020
|
+
path9__default.resolve(runtimeDir, "worker.ts")
|
|
2022
3021
|
];
|
|
2023
3022
|
for (const candidate of candidates) {
|
|
2024
|
-
if (
|
|
3023
|
+
if (fs13__default.existsSync(candidate)) return candidate;
|
|
2025
3024
|
}
|
|
2026
3025
|
return null;
|
|
2027
3026
|
}
|
|
@@ -2078,19 +3077,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
2078
3077
|
if (!currentDir) continue;
|
|
2079
3078
|
const entries = (() => {
|
|
2080
3079
|
try {
|
|
2081
|
-
return
|
|
3080
|
+
return fs13__default.readdirSync(currentDir, { withFileTypes: true });
|
|
2082
3081
|
} catch {
|
|
2083
3082
|
return [];
|
|
2084
3083
|
}
|
|
2085
3084
|
})();
|
|
2086
3085
|
for (const entry of entries) {
|
|
2087
|
-
const fullPath =
|
|
3086
|
+
const fullPath = path9__default.join(currentDir, entry.name);
|
|
2088
3087
|
if (entry.isDirectory()) {
|
|
2089
3088
|
if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
|
|
2090
3089
|
continue;
|
|
2091
3090
|
}
|
|
2092
3091
|
if (!entry.isFile()) continue;
|
|
2093
|
-
if (!extensionSet.has(
|
|
3092
|
+
if (!extensionSet.has(path9__default.extname(entry.name))) continue;
|
|
2094
3093
|
candidates.push(fullPath);
|
|
2095
3094
|
}
|
|
2096
3095
|
}
|
|
@@ -2116,8 +3115,8 @@ function scanSource(source) {
|
|
|
2116
3115
|
"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"
|
|
2117
3116
|
);
|
|
2118
3117
|
}
|
|
2119
|
-
function
|
|
2120
|
-
return includeExtensions.includes(
|
|
3118
|
+
function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
|
|
3119
|
+
return includeExtensions.includes(path9__default.extname(filePath));
|
|
2121
3120
|
}
|
|
2122
3121
|
function scanFile(filePath) {
|
|
2123
3122
|
const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
|
|
@@ -2177,7 +3176,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2177
3176
|
for (const filePath of candidates) {
|
|
2178
3177
|
const stat = (() => {
|
|
2179
3178
|
try {
|
|
2180
|
-
return
|
|
3179
|
+
return fs13__default.statSync(filePath);
|
|
2181
3180
|
} catch {
|
|
2182
3181
|
return null;
|
|
2183
3182
|
}
|
|
@@ -2203,7 +3202,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2203
3202
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
2204
3203
|
const content = (() => {
|
|
2205
3204
|
try {
|
|
2206
|
-
return
|
|
3205
|
+
return fs13__default.readFileSync(filePath, "utf8");
|
|
2207
3206
|
} catch {
|
|
2208
3207
|
return null;
|
|
2209
3208
|
}
|
|
@@ -2285,7 +3284,7 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
|
|
|
2285
3284
|
}
|
|
2286
3285
|
}
|
|
2287
3286
|
var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
|
|
2288
|
-
var
|
|
3287
|
+
var init_src3 = __esm({
|
|
2289
3288
|
"packages/domain/scanner/src/index.ts"() {
|
|
2290
3289
|
init_src();
|
|
2291
3290
|
init_cache_native();
|
|
@@ -2294,7 +3293,7 @@ var init_src2 = __esm({
|
|
|
2294
3293
|
init_schemas();
|
|
2295
3294
|
init_schemas();
|
|
2296
3295
|
init_native_bridge();
|
|
2297
|
-
log3 =
|
|
3296
|
+
log3 = createLogger2("scanner");
|
|
2298
3297
|
SCAN_WORKER_TIMEOUT_MS = 12e4;
|
|
2299
3298
|
createNativeParserLoader = () => {
|
|
2300
3299
|
const _state = {
|
|
@@ -2307,7 +3306,7 @@ var init_src2 = __esm({
|
|
|
2307
3306
|
const loadNativeParserBinding = () => {
|
|
2308
3307
|
if (_state.binding !== void 0) return _state.binding;
|
|
2309
3308
|
const runtimeDir = getRuntimeDir();
|
|
2310
|
-
const req = createRequire(
|
|
3309
|
+
const req = createRequire(path9__default.join(runtimeDir, "noop.cjs"));
|
|
2311
3310
|
const _platform = process.platform;
|
|
2312
3311
|
const _arch = process.arch;
|
|
2313
3312
|
const _platformArch = `${_platform}-${_arch}`;
|
|
@@ -2315,27 +3314,27 @@ var init_src2 = __esm({
|
|
|
2315
3314
|
const candidates = [
|
|
2316
3315
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2317
3316
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
3317
|
+
path9__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
3318
|
+
path9__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3319
|
+
path9__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2321
3320
|
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2322
3321
|
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
3322
|
+
path9__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
3323
|
+
path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
3324
|
+
path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2326
3325
|
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2327
|
-
|
|
2328
|
-
|
|
3326
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3327
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2329
3328
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2330
|
-
|
|
2331
|
-
|
|
3329
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
3330
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2332
3331
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
3332
|
+
path9__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
3333
|
+
path9__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
3334
|
+
path9__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
3335
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3336
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
3337
|
+
path9__default.resolve(
|
|
2339
3338
|
runtimeDir,
|
|
2340
3339
|
"..",
|
|
2341
3340
|
"..",
|
|
@@ -2347,7 +3346,7 @@ var init_src2 = __esm({
|
|
|
2347
3346
|
)
|
|
2348
3347
|
];
|
|
2349
3348
|
for (const fullPath of candidates) {
|
|
2350
|
-
if (!
|
|
3349
|
+
if (!fs13__default.existsSync(fullPath)) continue;
|
|
2351
3350
|
try {
|
|
2352
3351
|
const required = req(fullPath);
|
|
2353
3352
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2472,48 +3471,11 @@ var init_native_bridge2 = __esm({
|
|
|
2472
3471
|
}
|
|
2473
3472
|
});
|
|
2474
3473
|
|
|
2475
|
-
// packages/
|
|
2476
|
-
|
|
2477
|
-
var transformSource = (source, opts) => {
|
|
2478
|
-
const native = getNativeBridge();
|
|
2479
|
-
if (!native?.transformSource) {
|
|
2480
|
-
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
2481
|
-
}
|
|
2482
|
-
const result = native.transformSource(source, opts);
|
|
2483
|
-
if (!result) {
|
|
2484
|
-
throw new Error("FATAL: transformSource returned null");
|
|
2485
|
-
}
|
|
2486
|
-
return result;
|
|
2487
|
-
};
|
|
2488
|
-
var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
2489
|
-
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
2490
|
-
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
2491
|
-
return result.css;
|
|
2492
|
-
};
|
|
2493
|
-
var mergeClassesStatic = (classes) => {
|
|
2494
|
-
const result = normalizeAndDedupClasses(classes);
|
|
2495
|
-
return result?.normalized || "";
|
|
2496
|
-
};
|
|
2497
|
-
var normalizeAndDedupClasses = (raw) => {
|
|
2498
|
-
const native = getNativeBridge();
|
|
2499
|
-
if (!native?.normalizeAndDedupClasses) {
|
|
2500
|
-
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
2501
|
-
}
|
|
2502
|
-
const result = native.normalizeAndDedupClasses(raw);
|
|
2503
|
-
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
2504
|
-
};
|
|
2505
|
-
var runLoaderTransform = (ctx) => {
|
|
2506
|
-
const { filepath, source, options } = ctx;
|
|
2507
|
-
const result = transformSource(source, { filename: filepath, ...options });
|
|
2508
|
-
return {
|
|
2509
|
-
code: result?.code || "",
|
|
2510
|
-
changed: result?.changed || false,
|
|
2511
|
-
classes: result?.classes || []
|
|
2512
|
-
};
|
|
2513
|
-
};
|
|
3474
|
+
// packages/presentation/vite/src/plugin.ts
|
|
3475
|
+
init_src2();
|
|
2514
3476
|
|
|
2515
3477
|
// packages/domain/analyzer/src/analyzeWorkspace.ts
|
|
2516
|
-
|
|
3478
|
+
init_src3();
|
|
2517
3479
|
|
|
2518
3480
|
// packages/domain/analyzer/src/binding.ts
|
|
2519
3481
|
init_src();
|
|
@@ -2533,7 +3495,7 @@ function isRecord(value) {
|
|
|
2533
3495
|
}
|
|
2534
3496
|
async function pathExists(filePath) {
|
|
2535
3497
|
try {
|
|
2536
|
-
await
|
|
3498
|
+
await fs13__default.promises.access(filePath, fs13__default.constants.F_OK);
|
|
2537
3499
|
return true;
|
|
2538
3500
|
} catch {
|
|
2539
3501
|
return false;
|
|
@@ -2632,7 +3594,7 @@ async function requireNativeBinding() {
|
|
|
2632
3594
|
|
|
2633
3595
|
// packages/domain/analyzer/src/schemas.ts
|
|
2634
3596
|
init_src();
|
|
2635
|
-
var formatIssuePath3 = (
|
|
3597
|
+
var formatIssuePath3 = (path16) => path16.length > 0 ? path16.map(
|
|
2636
3598
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
2637
3599
|
).join(".") : "<root>";
|
|
2638
3600
|
var isPlainObject = (value) => {
|
|
@@ -2641,8 +3603,8 @@ var isPlainObject = (value) => {
|
|
|
2641
3603
|
return proto === Object.prototype || proto === null;
|
|
2642
3604
|
};
|
|
2643
3605
|
var formatIssues2 = (error) => error.issues.map((issue) => {
|
|
2644
|
-
const
|
|
2645
|
-
return `${
|
|
3606
|
+
const path16 = formatIssuePath3(issue.path);
|
|
3607
|
+
return `${path16}: ${issue.message}`;
|
|
2646
3608
|
}).join("; ");
|
|
2647
3609
|
var parseWithSchema2 = (schema, data, label) => {
|
|
2648
3610
|
const parsed = schema.safeParse(data);
|
|
@@ -2732,7 +3694,7 @@ var parseAnalyzerOptions = (options) => parseWithSchema2(AnalyzerOptionsSchema,
|
|
|
2732
3694
|
var parseNativeReport = (report) => parseWithSchema2(NativeReportSchema, report, "Native analyzer report is invalid");
|
|
2733
3695
|
var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
|
|
2734
3696
|
var tailwindConfigCache = /* @__PURE__ */ new Map();
|
|
2735
|
-
var
|
|
3697
|
+
var detectConflicts2 = async (usages) => {
|
|
2736
3698
|
const native = await getNativeBinding();
|
|
2737
3699
|
if (!native?.detectClassConflicts) {
|
|
2738
3700
|
throw new Error("FATAL: Native binding 'detectClassConflicts' is required but not available.");
|
|
@@ -2749,11 +3711,11 @@ var detectConflicts = async (usages) => {
|
|
|
2749
3711
|
};
|
|
2750
3712
|
};
|
|
2751
3713
|
var isSupportedTailwindConfigPath = (configPath) => {
|
|
2752
|
-
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(
|
|
3714
|
+
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path9__default.extname(configPath).toLowerCase());
|
|
2753
3715
|
};
|
|
2754
3716
|
var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
2755
3717
|
if (explicitPath) {
|
|
2756
|
-
const resolved =
|
|
3718
|
+
const resolved = path9__default.resolve(root, explicitPath);
|
|
2757
3719
|
if (!await pathExists(resolved)) return null;
|
|
2758
3720
|
return resolved;
|
|
2759
3721
|
}
|
|
@@ -2764,7 +3726,7 @@ var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
|
2764
3726
|
"tailwind.config.mjs"
|
|
2765
3727
|
];
|
|
2766
3728
|
for (const candidate of candidates) {
|
|
2767
|
-
const fullPath =
|
|
3729
|
+
const fullPath = path9__default.resolve(root, candidate);
|
|
2768
3730
|
if (await pathExists(fullPath)) return fullPath;
|
|
2769
3731
|
}
|
|
2770
3732
|
return null;
|
|
@@ -2818,8 +3780,8 @@ var collectCustomUtilities = (config) => {
|
|
|
2818
3780
|
return out;
|
|
2819
3781
|
};
|
|
2820
3782
|
var collectSafelistFromSource = async (configPath) => {
|
|
2821
|
-
const source = await
|
|
2822
|
-
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (
|
|
3783
|
+
const source = await fs13__default.promises.readFile(configPath, "utf8");
|
|
3784
|
+
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src3(), src_exports2));
|
|
2823
3785
|
const allTokens = extractClassesNative2(source);
|
|
2824
3786
|
const hasSafelist = source.includes("safelist");
|
|
2825
3787
|
if (!hasSafelist) return [];
|
|
@@ -2832,7 +3794,7 @@ var collectSafelistFromSource = async (configPath) => {
|
|
|
2832
3794
|
}
|
|
2833
3795
|
return allTokens.filter((t) => safelistSet.has(t));
|
|
2834
3796
|
};
|
|
2835
|
-
var
|
|
3797
|
+
var loadTailwindConfig2 = async (root, semanticOption) => {
|
|
2836
3798
|
const startMs = Date.now();
|
|
2837
3799
|
const configPath = await resolveTailwindConfigPath(root, semanticOption?.tailwindConfigPath);
|
|
2838
3800
|
if (!configPath) return null;
|
|
@@ -2845,7 +3807,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2845
3807
|
customUtilities: /* @__PURE__ */ new Set()
|
|
2846
3808
|
};
|
|
2847
3809
|
}
|
|
2848
|
-
const configStat = await
|
|
3810
|
+
const configStat = await fs13__default.promises.stat(configPath).catch(() => null);
|
|
2849
3811
|
if (configStat) {
|
|
2850
3812
|
const cached = tailwindConfigCache.get(configPath);
|
|
2851
3813
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -2913,7 +3875,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2913
3875
|
return loaded;
|
|
2914
3876
|
};
|
|
2915
3877
|
var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
2916
|
-
const loadedConfig = await
|
|
3878
|
+
const loadedConfig = await loadTailwindConfig2(root, semanticOption);
|
|
2917
3879
|
const safelist = loadedConfig?.safelist ?? /* @__PURE__ */ new Set();
|
|
2918
3880
|
const customUtilities = loadedConfig?.customUtilities ?? /* @__PURE__ */ new Set();
|
|
2919
3881
|
const usageNames = new Set(usages.map((usage) => usage.name));
|
|
@@ -2932,7 +3894,7 @@ var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
|
2932
3894
|
results.filter((r) => !r.isKnown).map((r) => r.className)
|
|
2933
3895
|
);
|
|
2934
3896
|
const unknownClasses = usages.filter((usage) => unknownSet.has(usage.name)).map((usage) => ({ ...usage, isUnused: true }));
|
|
2935
|
-
const { conflicts } = await
|
|
3897
|
+
const { conflicts } = await detectConflicts2(usages);
|
|
2936
3898
|
return {
|
|
2937
3899
|
unusedClasses,
|
|
2938
3900
|
unknownClasses,
|
|
@@ -3004,7 +3966,7 @@ async function buildDistribution(usages, native) {
|
|
|
3004
3966
|
}
|
|
3005
3967
|
async function analyzeWorkspace(root, options = {}) {
|
|
3006
3968
|
const startedAtMs = Date.now();
|
|
3007
|
-
const resolvedRoot =
|
|
3969
|
+
const resolvedRoot = path9__default.resolve(root);
|
|
3008
3970
|
const normalizedOptions = parseAnalyzerOptions(options);
|
|
3009
3971
|
const scan = await (async () => {
|
|
3010
3972
|
const scanStartedAtMs = Date.now();
|
|
@@ -3107,15 +4069,16 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
3107
4069
|
}
|
|
3108
4070
|
|
|
3109
4071
|
// packages/domain/engine/src/index.ts
|
|
3110
|
-
|
|
4072
|
+
init_internal();
|
|
4073
|
+
init_src3();
|
|
3111
4074
|
init_src();
|
|
3112
4075
|
|
|
3113
4076
|
// packages/domain/engine/src/incremental.ts
|
|
3114
|
-
|
|
4077
|
+
init_src3();
|
|
3115
4078
|
init_src();
|
|
3116
4079
|
init_native_bridge2();
|
|
3117
4080
|
var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
3118
|
-
var log5 =
|
|
4081
|
+
var log5 = createLogger2("engine:incremental");
|
|
3119
4082
|
function rebuildWorkspaceResult(byFile) {
|
|
3120
4083
|
const files = Array.from(byFile.values());
|
|
3121
4084
|
const native = getNativeEngineBinding();
|
|
@@ -3145,9 +4108,9 @@ function areClassSetsEqual(a, b) {
|
|
|
3145
4108
|
}
|
|
3146
4109
|
function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
3147
4110
|
const includeExtensions = scanner?.includeExtensions ?? DEFAULT_EXTENSIONS2;
|
|
3148
|
-
if (!
|
|
3149
|
-
const byFile = new Map(previous.files.map((f) => [
|
|
3150
|
-
const normalizedPath =
|
|
4111
|
+
if (!isScannableFile2(filePath, includeExtensions)) return previous;
|
|
4112
|
+
const byFile = new Map(previous.files.map((f) => [path9__default.resolve(f.file), f]));
|
|
4113
|
+
const normalizedPath = path9__default.resolve(filePath);
|
|
3151
4114
|
const native = getNativeEngineBinding();
|
|
3152
4115
|
if (!native?.processFileChange) {
|
|
3153
4116
|
throw new Error(
|
|
@@ -3163,7 +4126,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3163
4126
|
}
|
|
3164
4127
|
log5.debug(`native change ${normalizedPath}`);
|
|
3165
4128
|
const scanned = scanFile(normalizedPath);
|
|
3166
|
-
const content =
|
|
4129
|
+
const content = fs13__default.readFileSync(normalizedPath, "utf8");
|
|
3167
4130
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3168
4131
|
const existing = byFile.get(normalizedPath);
|
|
3169
4132
|
if (diff && existing) {
|
|
@@ -3232,8 +4195,8 @@ var METRICS_FILE_NAME = "metrics.json";
|
|
|
3232
4195
|
var CACHE_DIR = ".tw-cache";
|
|
3233
4196
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
3234
4197
|
try {
|
|
3235
|
-
const cacheDir =
|
|
3236
|
-
|
|
4198
|
+
const cacheDir = path9__default.join(cwd, CACHE_DIR);
|
|
4199
|
+
fs13__default.mkdirSync(cacheDir, { recursive: true });
|
|
3237
4200
|
const mem = process.memoryUsage();
|
|
3238
4201
|
const data = {
|
|
3239
4202
|
...metrics,
|
|
@@ -3244,7 +4207,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
3244
4207
|
},
|
|
3245
4208
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3246
4209
|
};
|
|
3247
|
-
|
|
4210
|
+
fs13__default.writeFileSync(path9__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
3248
4211
|
} catch {
|
|
3249
4212
|
}
|
|
3250
4213
|
}
|
|
@@ -3351,19 +4314,19 @@ var parseEngineOptions = (options) => parseWithSchema3(EngineOptionsSchema, opti
|
|
|
3351
4314
|
var parseEngineWatchOptions = (options) => parseWithSchema3(EngineWatchOptionsSchema, options ?? {}, "engine watch options are invalid");
|
|
3352
4315
|
|
|
3353
4316
|
// packages/domain/engine/src/watch.ts
|
|
3354
|
-
var
|
|
4317
|
+
var _native2 = null;
|
|
3355
4318
|
function getNativeWatcher() {
|
|
3356
|
-
if (
|
|
4319
|
+
if (_native2 !== null) return _native2;
|
|
3357
4320
|
try {
|
|
3358
4321
|
const { resolveNativeBinary: resolveNativeBinary2 } = (init_src(), __toCommonJS(src_exports));
|
|
3359
4322
|
const { path: binPath } = resolveNativeBinary2(__dirname);
|
|
3360
4323
|
if (binPath) {
|
|
3361
|
-
|
|
4324
|
+
_native2 = __require(binPath);
|
|
3362
4325
|
}
|
|
3363
4326
|
} catch {
|
|
3364
|
-
|
|
4327
|
+
_native2 = {};
|
|
3365
4328
|
}
|
|
3366
|
-
return
|
|
4329
|
+
return _native2;
|
|
3367
4330
|
}
|
|
3368
4331
|
function watchWorkspaceNative(rootDir, onEvent, options) {
|
|
3369
4332
|
const native = getNativeWatcher();
|
|
@@ -3440,11 +4403,11 @@ var configState = {
|
|
|
3440
4403
|
return this.tailwindConfigLoaded;
|
|
3441
4404
|
}
|
|
3442
4405
|
};
|
|
3443
|
-
var log6 =
|
|
4406
|
+
var log6 = createLogger2("engine");
|
|
3444
4407
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
3445
4408
|
if (!tailwindConfigPath) return void 0;
|
|
3446
|
-
const configPath =
|
|
3447
|
-
if (!
|
|
4409
|
+
const configPath = path9__default.resolve(root, tailwindConfigPath);
|
|
4410
|
+
if (!fs13__default.existsSync(configPath)) {
|
|
3448
4411
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
3449
4412
|
}
|
|
3450
4413
|
const imported = await import(pathToFileURL(configPath).href);
|
|
@@ -3510,13 +4473,14 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3510
4473
|
};
|
|
3511
4474
|
}
|
|
3512
4475
|
function countWorkspacePackages(root) {
|
|
3513
|
-
const packagesDir =
|
|
3514
|
-
if (!
|
|
4476
|
+
const packagesDir = path9__default.join(root, "packages");
|
|
4477
|
+
if (!fs13__default.existsSync(packagesDir)) return 0;
|
|
3515
4478
|
try {
|
|
3516
|
-
return
|
|
3517
|
-
(entry) => entry.isDirectory() &&
|
|
4479
|
+
return fs13__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
4480
|
+
(entry) => entry.isDirectory() && fs13__default.existsSync(path9__default.join(packagesDir, entry.name, "package.json"))
|
|
3518
4481
|
).length;
|
|
3519
|
-
} catch {
|
|
4482
|
+
} catch (err) {
|
|
4483
|
+
log6.debug(`countWorkspacePackages: ${err instanceof Error ? err.message : String(err)}`);
|
|
3520
4484
|
return 0;
|
|
3521
4485
|
}
|
|
3522
4486
|
}
|
|
@@ -3550,7 +4514,7 @@ function writeDashboardMetrics(root, mode, result, metrics) {
|
|
|
3550
4514
|
async function createEngine(rawOptions = {}) {
|
|
3551
4515
|
const options = parseEngineOptions(rawOptions);
|
|
3552
4516
|
const root = options.root ?? process.cwd();
|
|
3553
|
-
const resolvedRoot =
|
|
4517
|
+
const resolvedRoot = path9__default.resolve(root);
|
|
3554
4518
|
const plugins = rawOptions.plugins ?? [];
|
|
3555
4519
|
const getTailwindConfig = async () => {
|
|
3556
4520
|
if (configState.isLoaded()) return configState.getConfig();
|
|
@@ -3697,12 +4661,13 @@ async function createEngine(rawOptions = {}) {
|
|
|
3697
4661
|
const shouldForceFullRescan = (event) => {
|
|
3698
4662
|
if (event.type === "unlink") return false;
|
|
3699
4663
|
try {
|
|
3700
|
-
const stat =
|
|
4664
|
+
const stat = fs13__default.statSync(event.filePath);
|
|
3701
4665
|
if (stat.size > largeFileThreshold) {
|
|
3702
4666
|
metrics.markSkippedLargeFile();
|
|
3703
4667
|
return true;
|
|
3704
4668
|
}
|
|
3705
|
-
} catch {
|
|
4669
|
+
} catch (statErr) {
|
|
4670
|
+
log6.debug(`stat failed for ${event.filePath}: ${statErr instanceof Error ? statErr.message : String(statErr)}`);
|
|
3706
4671
|
return false;
|
|
3707
4672
|
}
|
|
3708
4673
|
return false;
|
|
@@ -3816,7 +4781,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
3816
4781
|
|
|
3817
4782
|
// packages/presentation/vite/src/schemas.ts
|
|
3818
4783
|
init_src();
|
|
3819
|
-
var formatIssuePath4 = (
|
|
4784
|
+
var formatIssuePath4 = (path16) => path16.length > 0 ? path16.map(
|
|
3820
4785
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
3821
4786
|
).join(".") : "<root>";
|
|
3822
4787
|
var formatIssues4 = (error) => error.issues.map((issue) => {
|
|
@@ -3862,14 +4827,14 @@ function warnDeprecated(options, key, message) {
|
|
|
3862
4827
|
}
|
|
3863
4828
|
}
|
|
3864
4829
|
function isInsideDirectory(filePath, directory) {
|
|
3865
|
-
const relative =
|
|
3866
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
4830
|
+
const relative = path9__default.relative(directory, filePath);
|
|
4831
|
+
return relative === "" || !relative.startsWith("..") && !path9__default.isAbsolute(relative);
|
|
3867
4832
|
}
|
|
3868
4833
|
function filterScanToDirs(scan, root, scanDirs) {
|
|
3869
|
-
const resolvedDirs = scanDirs.map((dir) =>
|
|
4834
|
+
const resolvedDirs = scanDirs.map((dir) => path9__default.resolve(root, dir));
|
|
3870
4835
|
if (resolvedDirs.length === 0) return scan;
|
|
3871
4836
|
const files = scan.files.filter((file) => {
|
|
3872
|
-
const absoluteFile =
|
|
4837
|
+
const absoluteFile = path9__default.resolve(file.file);
|
|
3873
4838
|
return resolvedDirs.some((directory) => isInsideDirectory(absoluteFile, directory));
|
|
3874
4839
|
});
|
|
3875
4840
|
const uniqueClasses = Array.from(new Set(files.flatMap((file) => file.classes))).sort();
|
|
@@ -3880,9 +4845,9 @@ function filterScanToDirs(scan, root, scanDirs) {
|
|
|
3880
4845
|
};
|
|
3881
4846
|
}
|
|
3882
4847
|
function writeJsonArtifact(root, relativePath, value) {
|
|
3883
|
-
const outputPath =
|
|
3884
|
-
|
|
3885
|
-
|
|
4848
|
+
const outputPath = path9__default.resolve(root, relativePath);
|
|
4849
|
+
fs13__default.mkdirSync(path9__default.dirname(outputPath), { recursive: true });
|
|
4850
|
+
fs13__default.writeFileSync(outputPath, `${JSON.stringify(value, null, 2)}
|
|
3886
4851
|
`);
|
|
3887
4852
|
}
|
|
3888
4853
|
function tailwindStyledPlugin(opts = {}) {
|
|
@@ -3909,12 +4874,77 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3909
4874
|
const transformRunner = rawOptions.__internalTransformRunner ?? runLoaderTransform;
|
|
3910
4875
|
const engineFactory = rawOptions.__internalCreateEngine ?? createEngine;
|
|
3911
4876
|
const pluginState = { root: process.cwd(), isDev: true };
|
|
4877
|
+
const staticCssPerFile = /* @__PURE__ */ new Map();
|
|
4878
|
+
function deduplicateStaticCss(css) {
|
|
4879
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4880
|
+
const rules = [];
|
|
4881
|
+
for (const chunk of css.split(/(?<=\})\s*/)) {
|
|
4882
|
+
const rule = chunk.trim();
|
|
4883
|
+
if (rule && !seen.has(rule)) {
|
|
4884
|
+
seen.add(rule);
|
|
4885
|
+
rules.push(rule);
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
return rules.join("\n");
|
|
4889
|
+
}
|
|
4890
|
+
function getStaticCssOutputPath(root, safelistOutputPath) {
|
|
4891
|
+
return path9__default.resolve(root, path9__default.dirname(safelistOutputPath), "_tw-state-static.css");
|
|
4892
|
+
}
|
|
4893
|
+
function flushStaticCss(root) {
|
|
4894
|
+
if (staticCssPerFile.size === 0) return;
|
|
4895
|
+
const combined = Array.from(staticCssPerFile.values()).join("\n");
|
|
4896
|
+
const deduped = deduplicateStaticCss(combined);
|
|
4897
|
+
if (!deduped.trim()) return;
|
|
4898
|
+
const outPath = getStaticCssOutputPath(root, safelistOutput);
|
|
4899
|
+
try {
|
|
4900
|
+
fs13__default.mkdirSync(path9__default.dirname(outPath), { recursive: true });
|
|
4901
|
+
fs13__default.writeFileSync(
|
|
4902
|
+
outPath,
|
|
4903
|
+
`/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
|
|
4904
|
+
* Import this in globals.css: @import "./_tw-state-static.css";
|
|
4905
|
+
* Contains: state CSS (.tw-s-*[data-*="true"]) + container queries (@container .tw-cq-*).
|
|
4906
|
+
*/
|
|
4907
|
+
|
|
4908
|
+
${deduped}
|
|
4909
|
+
`
|
|
4910
|
+
);
|
|
4911
|
+
} catch (e) {
|
|
4912
|
+
console.warn("[tailwind-styled-v4] Could not write _tw-state-static.css:", e);
|
|
4913
|
+
}
|
|
4914
|
+
}
|
|
3912
4915
|
return {
|
|
3913
4916
|
name: "tailwind-styled-v4",
|
|
3914
4917
|
enforce: "pre",
|
|
3915
4918
|
configResolved(config) {
|
|
3916
4919
|
pluginState.root = config.root;
|
|
3917
4920
|
pluginState.isDev = config.command === "serve";
|
|
4921
|
+
try {
|
|
4922
|
+
const outPath = getStaticCssOutputPath(config.root, safelistOutput);
|
|
4923
|
+
const CSS_CANDIDATES = [
|
|
4924
|
+
"src/index.css",
|
|
4925
|
+
"src/main.css",
|
|
4926
|
+
"src/App.css",
|
|
4927
|
+
"src/styles/index.css",
|
|
4928
|
+
"src/styles/main.css",
|
|
4929
|
+
"src/globals.css",
|
|
4930
|
+
"src/style.css"
|
|
4931
|
+
];
|
|
4932
|
+
for (const candidate of CSS_CANDIDATES) {
|
|
4933
|
+
const candidatePath = path9__default.resolve(config.root, candidate);
|
|
4934
|
+
if (!fs13__default.existsSync(candidatePath)) continue;
|
|
4935
|
+
const content = fs13__default.readFileSync(candidatePath, "utf-8");
|
|
4936
|
+
if (content.includes("_tw-state-static.css")) break;
|
|
4937
|
+
const rel = path9__default.relative(path9__default.dirname(candidatePath), outPath).replace(/\\/g, "/");
|
|
4938
|
+
const importLine = `@import "./${rel}";`;
|
|
4939
|
+
const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
|
|
4940
|
+
const updated = tailwindImportRe.test(content) ? content.replace(tailwindImportRe, `$1${importLine}
|
|
4941
|
+
`) : `${importLine}
|
|
4942
|
+
${content}`;
|
|
4943
|
+
fs13__default.writeFileSync(candidatePath, updated, "utf-8");
|
|
4944
|
+
break;
|
|
4945
|
+
}
|
|
4946
|
+
} catch {
|
|
4947
|
+
}
|
|
3918
4948
|
},
|
|
3919
4949
|
transform(source, id) {
|
|
3920
4950
|
const filepath = id.split("?")[0];
|
|
@@ -3940,6 +4970,12 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3940
4970
|
return null;
|
|
3941
4971
|
}
|
|
3942
4972
|
if (!output.changed) return null;
|
|
4973
|
+
if (output.staticCss) {
|
|
4974
|
+
staticCssPerFile.set(filepath, output.staticCss);
|
|
4975
|
+
if (pluginState.isDev) {
|
|
4976
|
+
flushStaticCss(pluginState.root);
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
3943
4979
|
return { code: output.code, map: null };
|
|
3944
4980
|
},
|
|
3945
4981
|
async buildEnd() {
|
|
@@ -3957,6 +4993,10 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3957
4993
|
if (doSafelist) {
|
|
3958
4994
|
writeJsonArtifact(pluginState.root, safelistOutput, scan.uniqueClasses);
|
|
3959
4995
|
}
|
|
4996
|
+
flushStaticCss(pluginState.root);
|
|
4997
|
+
console.log(
|
|
4998
|
+
`[tailwind-styled-v4] Static CSS: ${staticCssPerFile.size} files \u2192 _tw-state-static.css`
|
|
4999
|
+
);
|
|
3960
5000
|
writeJsonArtifact(pluginState.root, scanReportOutput, {
|
|
3961
5001
|
root: pluginState.root,
|
|
3962
5002
|
totalFiles: scan.totalFiles,
|