tailwind-styled-v4 5.0.11 → 5.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -4
- 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.d.mts +4 -0
- package/dist/animate.d.ts +4 -0
- package/dist/animate.js +33 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +33 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +57 -6
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +57 -6
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +404 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +401 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2700 -212
- package/dist/compiler.d.ts +2700 -212
- package/dist/compiler.js +1996 -503
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1847 -448
- 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 +2777 -455
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2776 -454
- 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 +7234 -1400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7234 -1400
- 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 +3224 -1065
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3223 -1066
- 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 +3014 -466
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +3008 -445
- 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 +2351 -187
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +2351 -187
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +404 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +401 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +2657 -320
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +2657 -320
- 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 +190 -33
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +190 -33
- 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,2041 @@ var init_observability = __esm({
|
|
|
987
987
|
}
|
|
988
988
|
});
|
|
989
989
|
|
|
990
|
+
// packages/domain/compiler/src/compiler/cssGeneratorNative.ts
|
|
991
|
+
async function generateCssNative(classes, options) {
|
|
992
|
+
const { theme } = options;
|
|
993
|
+
const native = getNativeBridge();
|
|
994
|
+
if (!native?.generateCssNative) {
|
|
995
|
+
throw new Error(
|
|
996
|
+
"FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
const themeJson = JSON.stringify(theme);
|
|
1000
|
+
const css = native.generateCssNative(classes, themeJson);
|
|
1001
|
+
return css;
|
|
1002
|
+
}
|
|
1003
|
+
function clearThemeCache() {
|
|
1004
|
+
try {
|
|
1005
|
+
const native = getNativeBridge();
|
|
1006
|
+
if (!native?.clearThemeCache) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
native.clearThemeCache();
|
|
1010
|
+
} catch {
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
var init_cssGeneratorNative = __esm({
|
|
1014
|
+
"packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
|
|
1015
|
+
init_nativeBridge();
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
// packages/domain/compiler/src/compiler/tailwindEngine.ts
|
|
1020
|
+
var tailwindEngine_exports = {};
|
|
1021
|
+
__export(tailwindEngine_exports, {
|
|
1022
|
+
clearCache: () => clearCache,
|
|
1023
|
+
getCacheStats: () => getCacheStats,
|
|
1024
|
+
processTailwindCssWithTargets: () => processTailwindCssWithTargets,
|
|
1025
|
+
runCssPipeline: () => runCssPipeline,
|
|
1026
|
+
runCssPipelineSync: () => runCssPipelineSync
|
|
1027
|
+
});
|
|
1028
|
+
function _getCacheKey(classes, minify, cssEntry, root) {
|
|
1029
|
+
const sorted = [...classes].sort().join(",");
|
|
1030
|
+
const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
|
|
1031
|
+
return `${sorted}|${flags}`;
|
|
1032
|
+
}
|
|
1033
|
+
function _evictOldestIfNeeded() {
|
|
1034
|
+
if (_cssCache.size >= MAX_CACHE_SIZE) {
|
|
1035
|
+
const firstKey = _cssCache.keys().next().value;
|
|
1036
|
+
if (firstKey !== void 0) {
|
|
1037
|
+
_cssCache.delete(firstKey);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function getCacheStats() {
|
|
1042
|
+
const total = _cacheHits + _cacheMisses;
|
|
1043
|
+
return {
|
|
1044
|
+
hits: _cacheHits,
|
|
1045
|
+
misses: _cacheMisses,
|
|
1046
|
+
hitRate: total > 0 ? _cacheHits / total : 0,
|
|
1047
|
+
size: _cssCache.size,
|
|
1048
|
+
maxSize: MAX_CACHE_SIZE
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
function clearCache() {
|
|
1052
|
+
_cssCache.clear();
|
|
1053
|
+
_cacheHits = 0;
|
|
1054
|
+
_cacheMisses = 0;
|
|
1055
|
+
}
|
|
1056
|
+
function getThemeConfig() {
|
|
1057
|
+
return {
|
|
1058
|
+
colors: {
|
|
1059
|
+
slate: {
|
|
1060
|
+
"50": "#f8fafc",
|
|
1061
|
+
"100": "#f1f5f9",
|
|
1062
|
+
"200": "#e2e8f0",
|
|
1063
|
+
"300": "#cbd5e1",
|
|
1064
|
+
"400": "#94a3b8",
|
|
1065
|
+
"500": "#64748b",
|
|
1066
|
+
"600": "#475569",
|
|
1067
|
+
"700": "#334155",
|
|
1068
|
+
"800": "#1e293b",
|
|
1069
|
+
"900": "#0f172a"
|
|
1070
|
+
},
|
|
1071
|
+
gray: {
|
|
1072
|
+
"50": "#f9fafb",
|
|
1073
|
+
"100": "#f3f4f6",
|
|
1074
|
+
"200": "#e5e7eb",
|
|
1075
|
+
"300": "#d1d5db",
|
|
1076
|
+
"400": "#9ca3af",
|
|
1077
|
+
"500": "#6b7280",
|
|
1078
|
+
"600": "#4b5563",
|
|
1079
|
+
"700": "#374151",
|
|
1080
|
+
"800": "#1f2937",
|
|
1081
|
+
"900": "#111827"
|
|
1082
|
+
},
|
|
1083
|
+
white: "#ffffff",
|
|
1084
|
+
black: "#000000",
|
|
1085
|
+
red: {
|
|
1086
|
+
"500": "#ef4444",
|
|
1087
|
+
"600": "#dc2626"
|
|
1088
|
+
},
|
|
1089
|
+
blue: {
|
|
1090
|
+
"500": "#3b82f6",
|
|
1091
|
+
"600": "#1e40af"
|
|
1092
|
+
}
|
|
1093
|
+
},
|
|
1094
|
+
spacing: {
|
|
1095
|
+
"0": "0px",
|
|
1096
|
+
"1": "0.25rem",
|
|
1097
|
+
"2": "0.5rem",
|
|
1098
|
+
"3": "0.75rem",
|
|
1099
|
+
"4": "1rem",
|
|
1100
|
+
"5": "1.25rem",
|
|
1101
|
+
"6": "1.5rem",
|
|
1102
|
+
"8": "2rem",
|
|
1103
|
+
"10": "2.5rem",
|
|
1104
|
+
"12": "3rem",
|
|
1105
|
+
"16": "4rem",
|
|
1106
|
+
"20": "5rem",
|
|
1107
|
+
"24": "6rem"
|
|
1108
|
+
},
|
|
1109
|
+
breakpoints: {
|
|
1110
|
+
"sm": "640px",
|
|
1111
|
+
"md": "768px",
|
|
1112
|
+
"lg": "1024px",
|
|
1113
|
+
"xl": "1280px",
|
|
1114
|
+
"2xl": "1536px"
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function postProcessWithLightning(rawCss) {
|
|
1119
|
+
if (!rawCss) return "";
|
|
1120
|
+
const native = getNativeBridge();
|
|
1121
|
+
if (!native?.processTailwindCssLightning) {
|
|
1122
|
+
throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
|
|
1123
|
+
}
|
|
1124
|
+
const result = native.processTailwindCssLightning(rawCss);
|
|
1125
|
+
if (!result?.css) {
|
|
1126
|
+
throw new Error("FATAL: processTailwindCssLightning returned null");
|
|
1127
|
+
}
|
|
1128
|
+
return result.css;
|
|
1129
|
+
}
|
|
1130
|
+
async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
|
|
1131
|
+
const filtered = classes.filter(Boolean);
|
|
1132
|
+
const uniqueMap = /* @__PURE__ */ new Map();
|
|
1133
|
+
filtered.forEach((cls) => uniqueMap.set(cls, cls));
|
|
1134
|
+
const unique = Array.from(uniqueMap.values());
|
|
1135
|
+
if (unique.length === 0) {
|
|
1136
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1137
|
+
}
|
|
1138
|
+
const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
|
|
1139
|
+
const cached = _cssCache.get(cacheKey);
|
|
1140
|
+
if (cached) {
|
|
1141
|
+
_cacheHits++;
|
|
1142
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1143
|
+
console.log(
|
|
1144
|
+
`[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
return cached;
|
|
1148
|
+
}
|
|
1149
|
+
_cacheMisses++;
|
|
1150
|
+
let rawCss;
|
|
1151
|
+
let usedRustCompiler = false;
|
|
1152
|
+
const theme = getThemeConfig();
|
|
1153
|
+
rawCss = await generateCssNative(unique, { theme });
|
|
1154
|
+
usedRustCompiler = true;
|
|
1155
|
+
const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
|
|
1156
|
+
if (process.env.DEBUG?.includes("compiler")) {
|
|
1157
|
+
console.log(
|
|
1158
|
+
`[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
|
|
1159
|
+
`Size: ${finalCss.length} bytes`
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
const result = {
|
|
1163
|
+
css: finalCss,
|
|
1164
|
+
classes: unique,
|
|
1165
|
+
sizeBytes: finalCss.length,
|
|
1166
|
+
optimized: minify
|
|
1167
|
+
};
|
|
1168
|
+
_evictOldestIfNeeded();
|
|
1169
|
+
_cssCache.set(cacheKey, result);
|
|
1170
|
+
return result;
|
|
1171
|
+
}
|
|
1172
|
+
function runCssPipelineSync(_classes) {
|
|
1173
|
+
return { css: "", classes: [], sizeBytes: 0, optimized: false };
|
|
1174
|
+
}
|
|
1175
|
+
function processTailwindCssWithTargets(css, targets) {
|
|
1176
|
+
const native = getNativeBridge();
|
|
1177
|
+
if (!native?.processTailwindCssWithTargets) {
|
|
1178
|
+
throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
|
|
1179
|
+
}
|
|
1180
|
+
const result = native.processTailwindCssWithTargets(css, targets ?? null);
|
|
1181
|
+
if (!result?.css) {
|
|
1182
|
+
throw new Error("FATAL: processTailwindCssWithTargets returned null");
|
|
1183
|
+
}
|
|
1184
|
+
return result.css;
|
|
1185
|
+
}
|
|
1186
|
+
var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
|
|
1187
|
+
var init_tailwindEngine = __esm({
|
|
1188
|
+
"packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
|
|
1189
|
+
init_nativeBridge();
|
|
1190
|
+
init_cssGeneratorNative();
|
|
1191
|
+
createRequire(import.meta.url);
|
|
1192
|
+
_cssCache = /* @__PURE__ */ new Map();
|
|
1193
|
+
_cacheHits = 0;
|
|
1194
|
+
_cacheMisses = 0;
|
|
1195
|
+
MAX_CACHE_SIZE = 100;
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
// packages/domain/compiler/src/compiler/compilationNative.ts
|
|
1200
|
+
function compileCssNative2(classes, prefix) {
|
|
1201
|
+
const native = getNativeBridge();
|
|
1202
|
+
if (!native?.compileCss) throw new Error("compileCss not available");
|
|
1203
|
+
return native.compileCss(classes, prefix);
|
|
1204
|
+
}
|
|
1205
|
+
function compileCssLightning(classes) {
|
|
1206
|
+
const native = getNativeBridge();
|
|
1207
|
+
if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
|
|
1208
|
+
return native.compileCssLightning(classes);
|
|
1209
|
+
}
|
|
1210
|
+
function extractTwStateConfigsNative(source, filename) {
|
|
1211
|
+
const native = getNativeBridge();
|
|
1212
|
+
if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
|
|
1213
|
+
return native.extractTwStateConfigs(source, filename);
|
|
1214
|
+
}
|
|
1215
|
+
function generateStaticStateCssNative(inputs, resolvedCss) {
|
|
1216
|
+
const native = getNativeBridge();
|
|
1217
|
+
if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
|
|
1218
|
+
return native.generateStaticStateCss(inputs, resolvedCss ?? null);
|
|
1219
|
+
}
|
|
1220
|
+
function extractAndGenerateStateCssNative(source, filename) {
|
|
1221
|
+
const native = getNativeBridge();
|
|
1222
|
+
if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
|
|
1223
|
+
return native.extractAndGenerateStateCss(source, filename);
|
|
1224
|
+
}
|
|
1225
|
+
function layoutClassesToCss(classes) {
|
|
1226
|
+
const native = getNativeBridge();
|
|
1227
|
+
if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
|
|
1228
|
+
return native.layoutClassesToCss(classes);
|
|
1229
|
+
}
|
|
1230
|
+
function hashContent(input, algorithm = "sha256", length = 8) {
|
|
1231
|
+
const native = getNativeBridge();
|
|
1232
|
+
if (!native?.hashContent) throw new Error("hashContent not available");
|
|
1233
|
+
return native.hashContent(input, algorithm, length);
|
|
1234
|
+
}
|
|
1235
|
+
function extractTwContainerConfigs(source) {
|
|
1236
|
+
const native = getNativeBridge();
|
|
1237
|
+
if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
|
|
1238
|
+
return native.extractTwContainerConfigs(source);
|
|
1239
|
+
}
|
|
1240
|
+
function parseAtomicClass(twClass) {
|
|
1241
|
+
const native = getNativeBridge();
|
|
1242
|
+
if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
|
|
1243
|
+
return native.parseAtomicClass(twClass);
|
|
1244
|
+
}
|
|
1245
|
+
function generateAtomicCss(rulesJson) {
|
|
1246
|
+
const native = getNativeBridge();
|
|
1247
|
+
if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
|
|
1248
|
+
return native.generateAtomicCss(rulesJson);
|
|
1249
|
+
}
|
|
1250
|
+
function toAtomicClasses(twClasses) {
|
|
1251
|
+
const native = getNativeBridge();
|
|
1252
|
+
if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
|
|
1253
|
+
return native.toAtomicClasses(twClasses);
|
|
1254
|
+
}
|
|
1255
|
+
function clearAtomicRegistry() {
|
|
1256
|
+
const native = getNativeBridge();
|
|
1257
|
+
if (!native?.clearAtomicRegistry) return;
|
|
1258
|
+
native.clearAtomicRegistry();
|
|
1259
|
+
}
|
|
1260
|
+
function atomicRegistrySize() {
|
|
1261
|
+
const native = getNativeBridge();
|
|
1262
|
+
if (!native?.atomicRegistrySize) return 0;
|
|
1263
|
+
return native.atomicRegistrySize();
|
|
1264
|
+
}
|
|
1265
|
+
var init_compilationNative = __esm({
|
|
1266
|
+
"packages/domain/compiler/src/compiler/compilationNative.ts"() {
|
|
1267
|
+
init_nativeBridge();
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
// packages/domain/compiler/src/compiler/cssCompilationNative.ts
|
|
1272
|
+
function compileClass(input) {
|
|
1273
|
+
const native = getNativeBridge();
|
|
1274
|
+
if (!native?.compile_class) throw new Error("compile_class not available");
|
|
1275
|
+
const resultJson = native.compile_class(input);
|
|
1276
|
+
try {
|
|
1277
|
+
return JSON.parse(resultJson);
|
|
1278
|
+
} catch {
|
|
1279
|
+
return {
|
|
1280
|
+
selector: "",
|
|
1281
|
+
declarations: "",
|
|
1282
|
+
properties: [],
|
|
1283
|
+
specificity: 0
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
function compileClasses(inputs) {
|
|
1288
|
+
const native = getNativeBridge();
|
|
1289
|
+
if (!native?.compile_classes) throw new Error("compile_classes not available");
|
|
1290
|
+
const resultJson = native.compile_classes(inputs);
|
|
1291
|
+
try {
|
|
1292
|
+
return JSON.parse(resultJson);
|
|
1293
|
+
} catch {
|
|
1294
|
+
return {
|
|
1295
|
+
css: "",
|
|
1296
|
+
resolved_classes: [],
|
|
1297
|
+
unknown_classes: [],
|
|
1298
|
+
size_bytes: 0,
|
|
1299
|
+
duration_ms: 0
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
function compileToCss(input, minify) {
|
|
1304
|
+
const native = getNativeBridge();
|
|
1305
|
+
if (!native?.compile_to_css) throw new Error("compile_to_css not available");
|
|
1306
|
+
return native.compile_to_css(input, minify ?? false);
|
|
1307
|
+
}
|
|
1308
|
+
function compileToCssBatch(inputs, minify) {
|
|
1309
|
+
const native = getNativeBridge();
|
|
1310
|
+
if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
|
|
1311
|
+
return native.compile_to_css_batch(inputs, minify ?? false);
|
|
1312
|
+
}
|
|
1313
|
+
function minifyCss(css) {
|
|
1314
|
+
const native = getNativeBridge();
|
|
1315
|
+
if (!native?.minify_css) throw new Error("minify_css not available");
|
|
1316
|
+
return native.minify_css(css);
|
|
1317
|
+
}
|
|
1318
|
+
function compileAnimation(animationName, from, to) {
|
|
1319
|
+
const native = getNativeBridge();
|
|
1320
|
+
if (!native?.compile_animation) throw new Error("compile_animation not available");
|
|
1321
|
+
const resultJson = native.compile_animation(animationName, from, to);
|
|
1322
|
+
try {
|
|
1323
|
+
return JSON.parse(resultJson);
|
|
1324
|
+
} catch {
|
|
1325
|
+
return {
|
|
1326
|
+
animation_id: "",
|
|
1327
|
+
keyframes_css: "",
|
|
1328
|
+
animation_rule: "",
|
|
1329
|
+
duration_ms: 0
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function compileKeyframes(name, stopsJson) {
|
|
1334
|
+
const native = getNativeBridge();
|
|
1335
|
+
if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
|
|
1336
|
+
const resultJson = native.compile_keyframes(name, stopsJson);
|
|
1337
|
+
try {
|
|
1338
|
+
return JSON.parse(resultJson);
|
|
1339
|
+
} catch {
|
|
1340
|
+
return {
|
|
1341
|
+
animation_id: "",
|
|
1342
|
+
keyframes_css: "",
|
|
1343
|
+
animation_rule: "",
|
|
1344
|
+
duration_ms: 0
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
function compileTheme(tokensJson, themeName, prefix) {
|
|
1349
|
+
const native = getNativeBridge();
|
|
1350
|
+
if (!native?.compile_theme) throw new Error("compile_theme not available");
|
|
1351
|
+
const resultJson = native.compile_theme(tokensJson, themeName, prefix);
|
|
1352
|
+
try {
|
|
1353
|
+
return JSON.parse(resultJson);
|
|
1354
|
+
} catch {
|
|
1355
|
+
return {
|
|
1356
|
+
selector: ":root",
|
|
1357
|
+
variables: [],
|
|
1358
|
+
variables_css: "",
|
|
1359
|
+
theme_name: themeName
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
function twMerge(classString) {
|
|
1364
|
+
const native = getNativeBridge();
|
|
1365
|
+
if (!native?.tw_merge) throw new Error("tw_merge not available");
|
|
1366
|
+
return native.tw_merge(classString);
|
|
1367
|
+
}
|
|
1368
|
+
function twMergeMany(classStrings) {
|
|
1369
|
+
const native = getNativeBridge();
|
|
1370
|
+
if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
|
|
1371
|
+
return native.tw_merge_many(classStrings);
|
|
1372
|
+
}
|
|
1373
|
+
function twMergeWithSeparator(classString, options) {
|
|
1374
|
+
const native = getNativeBridge();
|
|
1375
|
+
if (!native?.tw_merge_with_separator)
|
|
1376
|
+
throw new Error("tw_merge_with_separator not available");
|
|
1377
|
+
const opts = {
|
|
1378
|
+
separator: options.separator,
|
|
1379
|
+
debug: options.debug
|
|
1380
|
+
};
|
|
1381
|
+
return native.tw_merge_with_separator(classString, opts);
|
|
1382
|
+
}
|
|
1383
|
+
function twMergeManyWithSeparator(classStrings, options) {
|
|
1384
|
+
const native = getNativeBridge();
|
|
1385
|
+
if (!native?.tw_merge_many_with_separator)
|
|
1386
|
+
throw new Error("tw_merge_many_with_separator not available");
|
|
1387
|
+
const opts = {
|
|
1388
|
+
separator: options.separator,
|
|
1389
|
+
debug: options.debug
|
|
1390
|
+
};
|
|
1391
|
+
return native.tw_merge_many_with_separator(classStrings, opts);
|
|
1392
|
+
}
|
|
1393
|
+
function twMergeRaw(classLists) {
|
|
1394
|
+
const native = getNativeBridge();
|
|
1395
|
+
if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
|
|
1396
|
+
return native.tw_merge_raw(classLists);
|
|
1397
|
+
}
|
|
1398
|
+
var init_cssCompilationNative = __esm({
|
|
1399
|
+
"packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
|
|
1400
|
+
init_nativeBridge();
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// packages/domain/compiler/src/compiler/idRegistryNative.ts
|
|
1405
|
+
function idRegistryCreate() {
|
|
1406
|
+
const native = getNativeBridge();
|
|
1407
|
+
if (!native?.id_registry_create) throw new Error("id_registry_create not available");
|
|
1408
|
+
return native.id_registry_create();
|
|
1409
|
+
}
|
|
1410
|
+
function idRegistryGenerate(handle, name) {
|
|
1411
|
+
const native = getNativeBridge();
|
|
1412
|
+
if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
|
|
1413
|
+
return native.id_registry_generate(handle, name);
|
|
1414
|
+
}
|
|
1415
|
+
function idRegistryLookup(handle, name) {
|
|
1416
|
+
const native = getNativeBridge();
|
|
1417
|
+
if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
|
|
1418
|
+
return native.id_registry_lookup(handle, name);
|
|
1419
|
+
}
|
|
1420
|
+
function idRegistryNext(handle) {
|
|
1421
|
+
const native = getNativeBridge();
|
|
1422
|
+
if (!native?.id_registry_next) throw new Error("id_registry_next not available");
|
|
1423
|
+
return native.id_registry_next(handle);
|
|
1424
|
+
}
|
|
1425
|
+
function idRegistryDestroy(handle) {
|
|
1426
|
+
const native = getNativeBridge();
|
|
1427
|
+
if (!native?.id_registry_destroy) return;
|
|
1428
|
+
native.id_registry_destroy(handle);
|
|
1429
|
+
}
|
|
1430
|
+
function idRegistryReset(handle) {
|
|
1431
|
+
const native = getNativeBridge();
|
|
1432
|
+
if (!native?.id_registry_reset) return;
|
|
1433
|
+
native.id_registry_reset(handle);
|
|
1434
|
+
}
|
|
1435
|
+
function idRegistrySnapshot(handle) {
|
|
1436
|
+
const native = getNativeBridge();
|
|
1437
|
+
if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
|
|
1438
|
+
const snapshotJson = native.id_registry_snapshot(handle);
|
|
1439
|
+
try {
|
|
1440
|
+
return JSON.parse(snapshotJson);
|
|
1441
|
+
} catch {
|
|
1442
|
+
return {
|
|
1443
|
+
handle,
|
|
1444
|
+
next_id: 0,
|
|
1445
|
+
entries: [],
|
|
1446
|
+
total_entries: 0
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function idRegistryActiveCount() {
|
|
1451
|
+
const native = getNativeBridge();
|
|
1452
|
+
if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
|
|
1453
|
+
return native.id_registry_active_count();
|
|
1454
|
+
}
|
|
1455
|
+
function registerPropertyName(propertyName) {
|
|
1456
|
+
const native = getNativeBridge();
|
|
1457
|
+
if (!native?.register_property_name)
|
|
1458
|
+
throw new Error("register_property_name not available");
|
|
1459
|
+
return native.register_property_name(propertyName);
|
|
1460
|
+
}
|
|
1461
|
+
function registerValueName(valueName) {
|
|
1462
|
+
const native = getNativeBridge();
|
|
1463
|
+
if (!native?.register_value_name) throw new Error("register_value_name not available");
|
|
1464
|
+
return native.register_value_name(valueName);
|
|
1465
|
+
}
|
|
1466
|
+
function propertyIdToString(propertyId) {
|
|
1467
|
+
const native = getNativeBridge();
|
|
1468
|
+
if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
|
|
1469
|
+
return native.property_id_to_string(propertyId);
|
|
1470
|
+
}
|
|
1471
|
+
function valueIdToString(valueId) {
|
|
1472
|
+
const native = getNativeBridge();
|
|
1473
|
+
if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
|
|
1474
|
+
return native.value_id_to_string(valueId);
|
|
1475
|
+
}
|
|
1476
|
+
function reverseLookupProperty(propertyId) {
|
|
1477
|
+
const native = getNativeBridge();
|
|
1478
|
+
if (!native?.reverse_lookup_property)
|
|
1479
|
+
throw new Error("reverse_lookup_property not available");
|
|
1480
|
+
return native.reverse_lookup_property(propertyId);
|
|
1481
|
+
}
|
|
1482
|
+
function reverseLookupValue(valueId) {
|
|
1483
|
+
const native = getNativeBridge();
|
|
1484
|
+
if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
|
|
1485
|
+
return native.reverse_lookup_value(valueId);
|
|
1486
|
+
}
|
|
1487
|
+
function idRegistryExport(handle) {
|
|
1488
|
+
const native = getNativeBridge();
|
|
1489
|
+
if (!native?.id_registry_export) throw new Error("id_registry_export not available");
|
|
1490
|
+
return native.id_registry_export(handle);
|
|
1491
|
+
}
|
|
1492
|
+
function idRegistryImport(importedData) {
|
|
1493
|
+
const native = getNativeBridge();
|
|
1494
|
+
if (!native?.id_registry_import) throw new Error("id_registry_import not available");
|
|
1495
|
+
return native.id_registry_import(importedData);
|
|
1496
|
+
}
|
|
1497
|
+
var init_idRegistryNative = __esm({
|
|
1498
|
+
"packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
|
|
1499
|
+
init_nativeBridge();
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1503
|
+
// packages/domain/compiler/src/compiler/streamingNative.ts
|
|
1504
|
+
function processFileChange(fileChangeJson) {
|
|
1505
|
+
const native = getNativeBridge();
|
|
1506
|
+
if (!native?.process_file_change) throw new Error("process_file_change not available");
|
|
1507
|
+
const resultJson = native.process_file_change(fileChangeJson);
|
|
1508
|
+
try {
|
|
1509
|
+
return JSON.parse(resultJson);
|
|
1510
|
+
} catch {
|
|
1511
|
+
return {
|
|
1512
|
+
file_path: "",
|
|
1513
|
+
status: "error",
|
|
1514
|
+
old_classes: [],
|
|
1515
|
+
new_classes: [],
|
|
1516
|
+
added_classes: [],
|
|
1517
|
+
removed_classes: [],
|
|
1518
|
+
changed: false,
|
|
1519
|
+
fingerprint: "",
|
|
1520
|
+
error: "Failed to parse result"
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
function computeIncrementalDiff(oldScanJson, newScanJson) {
|
|
1525
|
+
const native = getNativeBridge();
|
|
1526
|
+
if (!native?.compute_incremental_diff)
|
|
1527
|
+
throw new Error("compute_incremental_diff not available");
|
|
1528
|
+
const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
|
|
1529
|
+
try {
|
|
1530
|
+
return JSON.parse(resultJson);
|
|
1531
|
+
} catch {
|
|
1532
|
+
return {
|
|
1533
|
+
is_changed: false,
|
|
1534
|
+
changes_count: 0,
|
|
1535
|
+
diff: {
|
|
1536
|
+
added_files: [],
|
|
1537
|
+
removed_files: [],
|
|
1538
|
+
modified_files: [],
|
|
1539
|
+
added_classes: [],
|
|
1540
|
+
removed_classes: [],
|
|
1541
|
+
total_changes: 0
|
|
1542
|
+
},
|
|
1543
|
+
processing_time_ms: 0
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
function createFingerprint(filePath, fileContent) {
|
|
1548
|
+
const native = getNativeBridge();
|
|
1549
|
+
if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
|
|
1550
|
+
const fingerprintJson = native.create_fingerprint(filePath, fileContent);
|
|
1551
|
+
try {
|
|
1552
|
+
return JSON.parse(fingerprintJson);
|
|
1553
|
+
} catch {
|
|
1554
|
+
return {
|
|
1555
|
+
file_path: filePath,
|
|
1556
|
+
content_hash: "",
|
|
1557
|
+
size_bytes: fileContent.length,
|
|
1558
|
+
mtime_ms: Date.now(),
|
|
1559
|
+
class_hash: "",
|
|
1560
|
+
signature: ""
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function injectStateHash(css, stateHash) {
|
|
1565
|
+
const native = getNativeBridge();
|
|
1566
|
+
if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
|
|
1567
|
+
const resultJson = native.inject_state_hash(css, stateHash);
|
|
1568
|
+
try {
|
|
1569
|
+
return JSON.parse(resultJson);
|
|
1570
|
+
} catch {
|
|
1571
|
+
return {
|
|
1572
|
+
injected: false,
|
|
1573
|
+
state_hash: stateHash,
|
|
1574
|
+
affected_files: 0,
|
|
1575
|
+
total_injected_bytes: 0
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
|
|
1580
|
+
const native = getNativeBridge();
|
|
1581
|
+
if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
|
|
1582
|
+
const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
|
|
1583
|
+
try {
|
|
1584
|
+
return JSON.parse(resultJson);
|
|
1585
|
+
} catch {
|
|
1586
|
+
return {
|
|
1587
|
+
entries_before: 0,
|
|
1588
|
+
entries_after: 0,
|
|
1589
|
+
entries_removed: 0,
|
|
1590
|
+
freed_bytes: 0
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
function rebuildWorkspaceResult(rootDir, extensions) {
|
|
1595
|
+
const native = getNativeBridge();
|
|
1596
|
+
if (!native?.rebuild_workspace_result)
|
|
1597
|
+
throw new Error("rebuild_workspace_result not available");
|
|
1598
|
+
const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
|
|
1599
|
+
try {
|
|
1600
|
+
return JSON.parse(resultJson);
|
|
1601
|
+
} catch {
|
|
1602
|
+
return {
|
|
1603
|
+
total_files_scanned: 0,
|
|
1604
|
+
total_classes_found: 0,
|
|
1605
|
+
unique_classes: 0,
|
|
1606
|
+
build_time_ms: 0,
|
|
1607
|
+
files_with_changes: 0
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
function scanFileNative(filePath, fileContent) {
|
|
1612
|
+
const native = getNativeBridge();
|
|
1613
|
+
if (!native?.scan_file_native) throw new Error("scan_file_native not available");
|
|
1614
|
+
const resultJson = native.scan_file_native(filePath, fileContent);
|
|
1615
|
+
try {
|
|
1616
|
+
return JSON.parse(resultJson);
|
|
1617
|
+
} catch {
|
|
1618
|
+
return {
|
|
1619
|
+
file: filePath,
|
|
1620
|
+
classes: [],
|
|
1621
|
+
added_classes: [],
|
|
1622
|
+
removed_classes: [],
|
|
1623
|
+
changed: false
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function scanFilesBatchNative(filesJson) {
|
|
1628
|
+
const native = getNativeBridge();
|
|
1629
|
+
if (!native?.scan_files_batch_native)
|
|
1630
|
+
throw new Error("scan_files_batch_native not available");
|
|
1631
|
+
const resultJson = native.scan_files_batch_native(filesJson);
|
|
1632
|
+
try {
|
|
1633
|
+
return JSON.parse(resultJson);
|
|
1634
|
+
} catch {
|
|
1635
|
+
return [];
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
var init_streamingNative = __esm({
|
|
1639
|
+
"packages/domain/compiler/src/compiler/streamingNative.ts"() {
|
|
1640
|
+
init_nativeBridge();
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
// packages/domain/compiler/src/compiler/index.ts
|
|
1645
|
+
var init_compiler = __esm({
|
|
1646
|
+
"packages/domain/compiler/src/compiler/index.ts"() {
|
|
1647
|
+
init_cssGeneratorNative();
|
|
1648
|
+
init_compilationNative();
|
|
1649
|
+
init_cssCompilationNative();
|
|
1650
|
+
init_idRegistryNative();
|
|
1651
|
+
init_streamingNative();
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
|
|
1655
|
+
// packages/domain/compiler/src/parser/index.ts
|
|
1656
|
+
var parser_exports = {};
|
|
1657
|
+
__export(parser_exports, {
|
|
1658
|
+
astExtractClasses: () => astExtractClasses,
|
|
1659
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
1660
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
1661
|
+
diffClassLists: () => diffClassLists,
|
|
1662
|
+
extractAllClasses: () => extractAllClasses,
|
|
1663
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
1664
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
1665
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
1666
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
1667
|
+
normalizeClasses: () => normalizeClasses,
|
|
1668
|
+
parseClasses: () => parseClasses
|
|
1669
|
+
});
|
|
1670
|
+
var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
|
|
1671
|
+
var init_parser = __esm({
|
|
1672
|
+
"packages/domain/compiler/src/parser/index.ts"() {
|
|
1673
|
+
init_nativeBridge();
|
|
1674
|
+
parseClasses = (raw) => {
|
|
1675
|
+
const native = getNativeBridge();
|
|
1676
|
+
if (!native?.parseClasses) {
|
|
1677
|
+
throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
|
|
1678
|
+
}
|
|
1679
|
+
return native.parseClasses(raw) || [];
|
|
1680
|
+
};
|
|
1681
|
+
extractAllClasses = (source) => {
|
|
1682
|
+
const native = getNativeBridge();
|
|
1683
|
+
if (!native?.extractAllClasses) {
|
|
1684
|
+
throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
|
|
1685
|
+
}
|
|
1686
|
+
return native.extractAllClasses(source) || [];
|
|
1687
|
+
};
|
|
1688
|
+
extractClassesFromSource = (source) => {
|
|
1689
|
+
const native = getNativeBridge();
|
|
1690
|
+
if (!native?.extractClassesFromSource) {
|
|
1691
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1692
|
+
}
|
|
1693
|
+
const result = native.extractClassesFromSource(source);
|
|
1694
|
+
return Array.isArray(result) ? result.join(" ") : String(result || "");
|
|
1695
|
+
};
|
|
1696
|
+
astExtractClasses = (source, _filename) => {
|
|
1697
|
+
const native = getNativeBridge();
|
|
1698
|
+
if (!native?.extractClassesFromSource) {
|
|
1699
|
+
throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
|
|
1700
|
+
}
|
|
1701
|
+
return native.extractClassesFromSource(source) || [];
|
|
1702
|
+
};
|
|
1703
|
+
normalizeClasses = (raw) => {
|
|
1704
|
+
const result = normalizeAndDedupClasses(raw);
|
|
1705
|
+
return result?.normalized || "";
|
|
1706
|
+
};
|
|
1707
|
+
mergeClassesStatic = (classes) => {
|
|
1708
|
+
const result = normalizeAndDedupClasses(classes);
|
|
1709
|
+
return result?.normalized || "";
|
|
1710
|
+
};
|
|
1711
|
+
normalizeAndDedupClasses = (raw) => {
|
|
1712
|
+
const native = getNativeBridge();
|
|
1713
|
+
if (!native?.normalizeAndDedupClasses) {
|
|
1714
|
+
throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
|
|
1715
|
+
}
|
|
1716
|
+
const result = native.normalizeAndDedupClasses(raw);
|
|
1717
|
+
return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
|
|
1718
|
+
};
|
|
1719
|
+
extractComponentUsage = (source) => {
|
|
1720
|
+
const native = getNativeBridge();
|
|
1721
|
+
if (!native?.extractComponentUsage) {
|
|
1722
|
+
throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
|
|
1723
|
+
}
|
|
1724
|
+
return native.extractComponentUsage(source) || [];
|
|
1725
|
+
};
|
|
1726
|
+
batchExtractClasses = (filePaths) => {
|
|
1727
|
+
const native = getNativeBridge();
|
|
1728
|
+
if (!native?.batchExtractClasses) {
|
|
1729
|
+
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
1730
|
+
}
|
|
1731
|
+
return native.batchExtractClasses(filePaths) || [];
|
|
1732
|
+
};
|
|
1733
|
+
checkAgainstSafelist = (classes, safelist) => {
|
|
1734
|
+
const native = getNativeBridge();
|
|
1735
|
+
if (!native?.checkAgainstSafelist) {
|
|
1736
|
+
throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
|
|
1737
|
+
}
|
|
1738
|
+
return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
|
|
1739
|
+
};
|
|
1740
|
+
diffClassLists = (previous, current) => {
|
|
1741
|
+
const native = getNativeBridge();
|
|
1742
|
+
if (!native?.diffClassLists) {
|
|
1743
|
+
throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
|
|
1744
|
+
}
|
|
1745
|
+
return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
|
|
1750
|
+
// packages/domain/compiler/src/analyzer/analyzerNative.ts
|
|
1751
|
+
function detectDeadCode(scanResultJson, css) {
|
|
1752
|
+
const native = getNativeBridge();
|
|
1753
|
+
if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
|
|
1754
|
+
return native.detectDeadCode(scanResultJson, css);
|
|
1755
|
+
}
|
|
1756
|
+
function analyzeClassUsageNative(classes, scanResultJson, css) {
|
|
1757
|
+
const native = getNativeBridge();
|
|
1758
|
+
if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
|
|
1759
|
+
return native.analyzeClassUsage(classes, scanResultJson, css);
|
|
1760
|
+
}
|
|
1761
|
+
function analyzeClassesNative(filesJson, cwd, flags) {
|
|
1762
|
+
const native = getNativeBridge();
|
|
1763
|
+
if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
|
|
1764
|
+
return native.analyzeClasses(filesJson, cwd, flags ?? 0);
|
|
1765
|
+
}
|
|
1766
|
+
function analyzeRscNative(source, filename) {
|
|
1767
|
+
const native = getNativeBridge();
|
|
1768
|
+
if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
|
|
1769
|
+
return native.analyzeRsc(source, filename);
|
|
1770
|
+
}
|
|
1771
|
+
function optimizeCssNative(css) {
|
|
1772
|
+
const native = getNativeBridge();
|
|
1773
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
1774
|
+
const result = native.processTailwindCssLightning(css);
|
|
1775
|
+
return {
|
|
1776
|
+
css: result.css,
|
|
1777
|
+
originalSize: css.length,
|
|
1778
|
+
optimizedSize: result.size_bytes,
|
|
1779
|
+
reductionPercentage: (css.length - result.size_bytes) / css.length * 100
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
function processTailwindCssLightning(css) {
|
|
1783
|
+
const native = getNativeBridge();
|
|
1784
|
+
if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
|
|
1785
|
+
return native.processTailwindCssLightning(css);
|
|
1786
|
+
}
|
|
1787
|
+
function eliminateDeadCssNative(css, deadClasses) {
|
|
1788
|
+
const native = getNativeBridge();
|
|
1789
|
+
if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
|
|
1790
|
+
return native.eliminateDeadCss(css, deadClasses);
|
|
1791
|
+
}
|
|
1792
|
+
function hoistComponentsNative(source) {
|
|
1793
|
+
const native = getNativeBridge();
|
|
1794
|
+
if (!native?.hoistComponents) throw new Error("hoistComponents not available");
|
|
1795
|
+
return native.hoistComponents(source);
|
|
1796
|
+
}
|
|
1797
|
+
function compileVariantTableNative(configJson) {
|
|
1798
|
+
const native = getNativeBridge();
|
|
1799
|
+
if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
|
|
1800
|
+
return native.compileVariantTable(configJson);
|
|
1801
|
+
}
|
|
1802
|
+
function classifyAndSortClassesNative(classes) {
|
|
1803
|
+
const native = getNativeBridge();
|
|
1804
|
+
if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
|
|
1805
|
+
return native.classifyAndSortClasses(classes);
|
|
1806
|
+
}
|
|
1807
|
+
function mergeCssDeclarationsNative(cssChunks) {
|
|
1808
|
+
const native = getNativeBridge();
|
|
1809
|
+
if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
|
|
1810
|
+
return native.mergeCssDeclarations(cssChunks);
|
|
1811
|
+
}
|
|
1812
|
+
var init_analyzerNative = __esm({
|
|
1813
|
+
"packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
|
|
1814
|
+
init_nativeBridge();
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// packages/domain/compiler/src/analyzer/themeResolutionNative.ts
|
|
1819
|
+
function resolveVariants(configJson) {
|
|
1820
|
+
const native = getNativeBridge();
|
|
1821
|
+
if (!native?.resolve_variants) throw new Error("resolve_variants not available");
|
|
1822
|
+
const resultJson = native.resolve_variants(configJson);
|
|
1823
|
+
try {
|
|
1824
|
+
return JSON.parse(resultJson);
|
|
1825
|
+
} catch {
|
|
1826
|
+
return {
|
|
1827
|
+
variants: [],
|
|
1828
|
+
supported: [],
|
|
1829
|
+
deprecated: [],
|
|
1830
|
+
conflicting: []
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function validateThemeConfig(configJson) {
|
|
1835
|
+
const native = getNativeBridge();
|
|
1836
|
+
if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
|
|
1837
|
+
const resultJson = native.validate_variant_config(configJson);
|
|
1838
|
+
try {
|
|
1839
|
+
return JSON.parse(resultJson);
|
|
1840
|
+
} catch {
|
|
1841
|
+
return {
|
|
1842
|
+
is_valid: false,
|
|
1843
|
+
errors: ["Unable to parse configuration"],
|
|
1844
|
+
warnings: [],
|
|
1845
|
+
suggestions: []
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function resolveCascade(baseThemeJson, overridesJson) {
|
|
1850
|
+
const native = getNativeBridge();
|
|
1851
|
+
if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
|
|
1852
|
+
const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
|
|
1853
|
+
try {
|
|
1854
|
+
return JSON.parse(resultJson);
|
|
1855
|
+
} catch {
|
|
1856
|
+
return {
|
|
1857
|
+
base_theme: {},
|
|
1858
|
+
user_overrides: {},
|
|
1859
|
+
merged_theme: {},
|
|
1860
|
+
conflict_resolutions: []
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
function resolveClassNames(classNames, themeJson) {
|
|
1865
|
+
const native = getNativeBridge();
|
|
1866
|
+
if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
|
|
1867
|
+
const resultJson = native.resolve_class_names(classNames, themeJson);
|
|
1868
|
+
try {
|
|
1869
|
+
return JSON.parse(resultJson);
|
|
1870
|
+
} catch {
|
|
1871
|
+
return [];
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
function resolveConflictGroup(groupName, themeJson) {
|
|
1875
|
+
const native = getNativeBridge();
|
|
1876
|
+
if (!native?.resolve_conflict_group)
|
|
1877
|
+
throw new Error("resolve_conflict_group not available");
|
|
1878
|
+
const resultJson = native.resolve_conflict_group(groupName, themeJson);
|
|
1879
|
+
try {
|
|
1880
|
+
return JSON.parse(resultJson);
|
|
1881
|
+
} catch {
|
|
1882
|
+
return {
|
|
1883
|
+
group_name: groupName,
|
|
1884
|
+
conflicting_classes: [],
|
|
1885
|
+
description: "",
|
|
1886
|
+
resolution_strategy: "last-wins"
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
function resolveThemeValue(keyPath, themeJson) {
|
|
1891
|
+
const native = getNativeBridge();
|
|
1892
|
+
if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
|
|
1893
|
+
return native.resolve_theme_value(keyPath, themeJson);
|
|
1894
|
+
}
|
|
1895
|
+
function resolveSimpleVariants(configJson) {
|
|
1896
|
+
const native = getNativeBridge();
|
|
1897
|
+
if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
|
|
1898
|
+
const resultJson = native.resolve_simple_variants(configJson);
|
|
1899
|
+
try {
|
|
1900
|
+
return JSON.parse(resultJson);
|
|
1901
|
+
} catch {
|
|
1902
|
+
return [];
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
var init_themeResolutionNative = __esm({
|
|
1906
|
+
"packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
|
|
1907
|
+
init_nativeBridge();
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
|
|
1911
|
+
// packages/domain/compiler/src/analyzer/scannerNative.ts
|
|
1912
|
+
function scanWorkspace(root, extensions) {
|
|
1913
|
+
const native = getNativeBridge();
|
|
1914
|
+
if (!native?.scan_workspace) throw new Error("scan_workspace not available");
|
|
1915
|
+
return native.scan_workspace(root, extensions);
|
|
1916
|
+
}
|
|
1917
|
+
function extractClassesFromSourceNative(source) {
|
|
1918
|
+
const native = getNativeBridge();
|
|
1919
|
+
if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
|
|
1920
|
+
return native.extract_classes_from_source(source);
|
|
1921
|
+
}
|
|
1922
|
+
function batchExtractClassesNative(filePaths) {
|
|
1923
|
+
const native = getNativeBridge();
|
|
1924
|
+
if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
|
|
1925
|
+
return native.batch_extract_classes(filePaths);
|
|
1926
|
+
}
|
|
1927
|
+
function checkAgainstSafelistNative(classes, safelist) {
|
|
1928
|
+
const native = getNativeBridge();
|
|
1929
|
+
if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
|
|
1930
|
+
return native.check_against_safelist(classes, safelist);
|
|
1931
|
+
}
|
|
1932
|
+
function scanFile(filePath) {
|
|
1933
|
+
const native = getNativeBridge();
|
|
1934
|
+
if (!native?.scan_file) throw new Error("scan_file not available");
|
|
1935
|
+
return native.scan_file(filePath);
|
|
1936
|
+
}
|
|
1937
|
+
function collectFiles(root, extensions) {
|
|
1938
|
+
const native = getNativeBridge();
|
|
1939
|
+
if (!native?.collect_files) throw new Error("collect_files not available");
|
|
1940
|
+
return native.collect_files(root, extensions);
|
|
1941
|
+
}
|
|
1942
|
+
function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
|
|
1943
|
+
const native = getNativeBridge();
|
|
1944
|
+
if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
|
|
1945
|
+
return native.walk_and_prefilter_source_files(root, extensions);
|
|
1946
|
+
}
|
|
1947
|
+
function generateSubComponentTypes(root, outputPath) {
|
|
1948
|
+
const native = getNativeBridge();
|
|
1949
|
+
if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
|
|
1950
|
+
return native.generate_sub_component_types(root, outputPath);
|
|
1951
|
+
}
|
|
1952
|
+
var init_scannerNative = __esm({
|
|
1953
|
+
"packages/domain/compiler/src/analyzer/scannerNative.ts"() {
|
|
1954
|
+
init_nativeBridge();
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
|
|
1958
|
+
// packages/domain/compiler/src/analyzer/index.ts
|
|
1959
|
+
var init_analyzer = __esm({
|
|
1960
|
+
"packages/domain/compiler/src/analyzer/index.ts"() {
|
|
1961
|
+
init_analyzerNative();
|
|
1962
|
+
init_themeResolutionNative();
|
|
1963
|
+
init_scannerNative();
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
|
|
1967
|
+
// packages/domain/compiler/src/cache/cacheNative.ts
|
|
1968
|
+
function getCacheStatistics() {
|
|
1969
|
+
const native = getNativeBridge();
|
|
1970
|
+
if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
|
|
1971
|
+
const statsJson = native.get_cache_statistics();
|
|
1972
|
+
try {
|
|
1973
|
+
return JSON.parse(statsJson);
|
|
1974
|
+
} catch {
|
|
1975
|
+
return {
|
|
1976
|
+
parse_cache: { hits: 0, misses: 0, size: 0 },
|
|
1977
|
+
resolve_cache: { hits: 0, misses: 0, size: 0 },
|
|
1978
|
+
compile_cache: { hits: 0, misses: 0, size: 0 },
|
|
1979
|
+
css_gen_cache: { hits: 0, misses: 0, size: 0 },
|
|
1980
|
+
overall_hit_rate: 0,
|
|
1981
|
+
total_memory_bytes: 0
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
function clearAllCaches() {
|
|
1986
|
+
const native = getNativeBridge();
|
|
1987
|
+
if (!native?.clear_all_caches) return;
|
|
1988
|
+
try {
|
|
1989
|
+
native.clear_all_caches();
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function clearParseCache() {
|
|
1994
|
+
const native = getNativeBridge();
|
|
1995
|
+
if (!native?.clear_parse_cache) return;
|
|
1996
|
+
try {
|
|
1997
|
+
native.clear_parse_cache();
|
|
1998
|
+
} catch {
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
function clearResolveCache() {
|
|
2002
|
+
const native = getNativeBridge();
|
|
2003
|
+
if (!native?.clear_resolve_cache) return;
|
|
2004
|
+
try {
|
|
2005
|
+
native.clear_resolve_cache();
|
|
2006
|
+
} catch {
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
function clearCompileCache() {
|
|
2010
|
+
const native = getNativeBridge();
|
|
2011
|
+
if (!native?.clear_compile_cache) return;
|
|
2012
|
+
try {
|
|
2013
|
+
native.clear_compile_cache();
|
|
2014
|
+
} catch {
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
function clearCssGenCache() {
|
|
2018
|
+
const native = getNativeBridge();
|
|
2019
|
+
if (!native?.clear_css_gen_cache) return;
|
|
2020
|
+
try {
|
|
2021
|
+
native.clear_css_gen_cache();
|
|
2022
|
+
} catch {
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
|
|
2026
|
+
const native = getNativeBridge();
|
|
2027
|
+
if (!native?.get_cache_optimization_hints)
|
|
2028
|
+
throw new Error("get_cache_optimization_hints not available");
|
|
2029
|
+
const hintsJson = native.get_cache_optimization_hints(
|
|
2030
|
+
Math.min(100, Math.max(0, hitRatePercent)),
|
|
2031
|
+
Math.max(1, memoryUsedMb)
|
|
2032
|
+
);
|
|
2033
|
+
try {
|
|
2034
|
+
return JSON.parse(hintsJson);
|
|
2035
|
+
} catch {
|
|
2036
|
+
return {
|
|
2037
|
+
current_strategy: "unknown",
|
|
2038
|
+
recommended_strategy: "increase_size",
|
|
2039
|
+
estimated_improvement_percent: 0,
|
|
2040
|
+
suggested_memory_mb: 256,
|
|
2041
|
+
notes: ["Unable to analyze cache statistics"]
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
|
|
2046
|
+
const native = getNativeBridge();
|
|
2047
|
+
if (!native?.estimate_optimal_cache_config_native)
|
|
2048
|
+
throw new Error("estimate_optimal_cache_config_native not available");
|
|
2049
|
+
const configJson = native.estimate_optimal_cache_config_native(
|
|
2050
|
+
Math.max(64, totalBudgetMb),
|
|
2051
|
+
workloadType
|
|
2052
|
+
);
|
|
2053
|
+
try {
|
|
2054
|
+
return JSON.parse(configJson);
|
|
2055
|
+
} catch {
|
|
2056
|
+
return {
|
|
2057
|
+
parse_cache_size: 128,
|
|
2058
|
+
resolve_cache_size: 64,
|
|
2059
|
+
compile_cache_size: 256,
|
|
2060
|
+
css_gen_cache_size: 128,
|
|
2061
|
+
recommended_eviction_policy: "lru",
|
|
2062
|
+
ttl_seconds: 3600,
|
|
2063
|
+
expected_hit_rate_percent: 75
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
function cacheRead(cachePath) {
|
|
2068
|
+
const native = getNativeBridge();
|
|
2069
|
+
if (!native?.cache_read) throw new Error("cache_read not available");
|
|
2070
|
+
const result = native.cache_read(cachePath);
|
|
2071
|
+
try {
|
|
2072
|
+
return JSON.parse(result.entries_json || "[]");
|
|
2073
|
+
} catch {
|
|
2074
|
+
return [];
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
function cacheWrite(cachePath, entries) {
|
|
2078
|
+
const native = getNativeBridge();
|
|
2079
|
+
if (!native?.cache_write) throw new Error("cache_write not available");
|
|
2080
|
+
try {
|
|
2081
|
+
const result = native.cache_write(
|
|
2082
|
+
cachePath,
|
|
2083
|
+
entries.map((e) => ({
|
|
2084
|
+
file: e.file,
|
|
2085
|
+
content_hash: e.contentHash,
|
|
2086
|
+
classes: e.classes,
|
|
2087
|
+
mtime_ms: e.mtimeMs,
|
|
2088
|
+
size_bytes: e.sizeBytes
|
|
2089
|
+
}))
|
|
2090
|
+
);
|
|
2091
|
+
return typeof result === "boolean" ? result : result === true;
|
|
2092
|
+
} catch {
|
|
2093
|
+
return false;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
function cachePriority(mtimeMs, sizeBytes, hitCount) {
|
|
2097
|
+
const native = getNativeBridge();
|
|
2098
|
+
if (!native?.cache_priority) throw new Error("cache_priority not available");
|
|
2099
|
+
return native.cache_priority(mtimeMs, sizeBytes, hitCount);
|
|
2100
|
+
}
|
|
2101
|
+
var init_cacheNative = __esm({
|
|
2102
|
+
"packages/domain/compiler/src/cache/cacheNative.ts"() {
|
|
2103
|
+
init_nativeBridge();
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
|
|
2107
|
+
// packages/domain/compiler/src/cache/index.ts
|
|
2108
|
+
var init_cache = __esm({
|
|
2109
|
+
"packages/domain/compiler/src/cache/index.ts"() {
|
|
2110
|
+
init_cacheNative();
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
|
|
2114
|
+
// packages/domain/compiler/src/redis/redisNative.ts
|
|
2115
|
+
function redisPing() {
|
|
2116
|
+
const native = getNativeBridge();
|
|
2117
|
+
if (!native?.redis_ping) throw new Error("redis_ping not available");
|
|
2118
|
+
return native.redis_ping();
|
|
2119
|
+
}
|
|
2120
|
+
function redisGet(key) {
|
|
2121
|
+
const native = getNativeBridge();
|
|
2122
|
+
if (!native?.redis_get) throw new Error("redis_get not available");
|
|
2123
|
+
const result = native.redis_get(key);
|
|
2124
|
+
return result === "nil" ? null : result;
|
|
2125
|
+
}
|
|
2126
|
+
function redisSet(key, value, ttl_seconds) {
|
|
2127
|
+
const native = getNativeBridge();
|
|
2128
|
+
if (!native?.redis_set) throw new Error("redis_set not available");
|
|
2129
|
+
return native.redis_set(key, value, ttl_seconds);
|
|
2130
|
+
}
|
|
2131
|
+
function redisDelete(key) {
|
|
2132
|
+
const native = getNativeBridge();
|
|
2133
|
+
if (!native?.redis_delete) throw new Error("redis_delete not available");
|
|
2134
|
+
return native.redis_delete(key);
|
|
2135
|
+
}
|
|
2136
|
+
function redisExists(key) {
|
|
2137
|
+
const native = getNativeBridge();
|
|
2138
|
+
if (!native?.redis_exists) throw new Error("redis_exists not available");
|
|
2139
|
+
return native.redis_exists(key);
|
|
2140
|
+
}
|
|
2141
|
+
function redisMget(keys) {
|
|
2142
|
+
const native = getNativeBridge();
|
|
2143
|
+
if (!native?.redis_mget) throw new Error("redis_mget not available");
|
|
2144
|
+
const result = native.redis_mget(keys);
|
|
2145
|
+
try {
|
|
2146
|
+
return JSON.parse(result);
|
|
2147
|
+
} catch {
|
|
2148
|
+
return keys.map(() => null);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
function redisMset(pairs) {
|
|
2152
|
+
const native = getNativeBridge();
|
|
2153
|
+
if (!native?.redis_mset) throw new Error("redis_mset not available");
|
|
2154
|
+
return native.redis_mset(pairs);
|
|
2155
|
+
}
|
|
2156
|
+
function redisFlushDb() {
|
|
2157
|
+
const native = getNativeBridge();
|
|
2158
|
+
if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
|
|
2159
|
+
return native.redis_flush_db();
|
|
2160
|
+
}
|
|
2161
|
+
function redisFlushAll() {
|
|
2162
|
+
const native = getNativeBridge();
|
|
2163
|
+
if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
|
|
2164
|
+
return native.redis_flush_all();
|
|
2165
|
+
}
|
|
2166
|
+
function redisPoolConnect(host, port, pool_size) {
|
|
2167
|
+
const native = getNativeBridge();
|
|
2168
|
+
if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
|
|
2169
|
+
return native.redis_pool_connect(host, port, pool_size);
|
|
2170
|
+
}
|
|
2171
|
+
function redisPoolStats() {
|
|
2172
|
+
const native = getNativeBridge();
|
|
2173
|
+
if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
|
|
2174
|
+
const result = native.redis_pool_stats();
|
|
2175
|
+
try {
|
|
2176
|
+
return JSON.parse(result);
|
|
2177
|
+
} catch {
|
|
2178
|
+
return {
|
|
2179
|
+
connected_count: 0,
|
|
2180
|
+
idle_count: 0,
|
|
2181
|
+
waiting_count: 0,
|
|
2182
|
+
total_requests: 0,
|
|
2183
|
+
total_errors: 0
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
function redisPoolReconnect() {
|
|
2188
|
+
const native = getNativeBridge();
|
|
2189
|
+
if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
|
|
2190
|
+
return native.redis_pool_reconnect();
|
|
2191
|
+
}
|
|
2192
|
+
function redisEnableCluster(initial_nodes) {
|
|
2193
|
+
const native = getNativeBridge();
|
|
2194
|
+
if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
|
|
2195
|
+
const result = native.redis_enable_cluster(initial_nodes);
|
|
2196
|
+
try {
|
|
2197
|
+
return JSON.parse(result);
|
|
2198
|
+
} catch {
|
|
2199
|
+
return {
|
|
2200
|
+
enabled: false,
|
|
2201
|
+
cluster_state: "error",
|
|
2202
|
+
nodes: [],
|
|
2203
|
+
slots_assigned: 0,
|
|
2204
|
+
slots_ok: 0,
|
|
2205
|
+
slots_fail: 0
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
function redisDisableCluster() {
|
|
2210
|
+
const native = getNativeBridge();
|
|
2211
|
+
if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
|
|
2212
|
+
return native.redis_disable_cluster();
|
|
2213
|
+
}
|
|
2214
|
+
function redisClusterStatus() {
|
|
2215
|
+
const native = getNativeBridge();
|
|
2216
|
+
if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
|
|
2217
|
+
const result = native.redis_cluster_status();
|
|
2218
|
+
try {
|
|
2219
|
+
return JSON.parse(result);
|
|
2220
|
+
} catch {
|
|
2221
|
+
return {
|
|
2222
|
+
enabled: false,
|
|
2223
|
+
cluster_state: "unknown",
|
|
2224
|
+
nodes: [],
|
|
2225
|
+
slots_assigned: 0,
|
|
2226
|
+
slots_ok: 0,
|
|
2227
|
+
slots_fail: 0
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
function redisSubscribe(channel) {
|
|
2232
|
+
const native = getNativeBridge();
|
|
2233
|
+
if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
|
|
2234
|
+
return native.redis_subscribe(channel);
|
|
2235
|
+
}
|
|
2236
|
+
function redisPublish(channel, message) {
|
|
2237
|
+
const native = getNativeBridge();
|
|
2238
|
+
if (!native?.redis_publish) throw new Error("redis_publish not available");
|
|
2239
|
+
return native.redis_publish(channel, message);
|
|
2240
|
+
}
|
|
2241
|
+
function redisExpirationSet(key, ttl_seconds) {
|
|
2242
|
+
const native = getNativeBridge();
|
|
2243
|
+
if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
|
|
2244
|
+
return native.redis_expiration_set(key, ttl_seconds);
|
|
2245
|
+
}
|
|
2246
|
+
function redisExpirationGet(key) {
|
|
2247
|
+
const native = getNativeBridge();
|
|
2248
|
+
if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
|
|
2249
|
+
const result = native.redis_expiration_get(key);
|
|
2250
|
+
try {
|
|
2251
|
+
return JSON.parse(result);
|
|
2252
|
+
} catch {
|
|
2253
|
+
return {
|
|
2254
|
+
key,
|
|
2255
|
+
ttl_seconds: -1,
|
|
2256
|
+
expiration_timestamp: 0,
|
|
2257
|
+
is_persistent: true
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
function redisInfo() {
|
|
2262
|
+
const native = getNativeBridge();
|
|
2263
|
+
if (!native?.redis_info) throw new Error("redis_info not available");
|
|
2264
|
+
return native.redis_info();
|
|
2265
|
+
}
|
|
2266
|
+
function redisMonitor() {
|
|
2267
|
+
const native = getNativeBridge();
|
|
2268
|
+
if (!native?.redis_monitor) throw new Error("redis_monitor not available");
|
|
2269
|
+
return native.redis_monitor();
|
|
2270
|
+
}
|
|
2271
|
+
function redisCacheSize() {
|
|
2272
|
+
const native = getNativeBridge();
|
|
2273
|
+
if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
|
|
2274
|
+
return native.redis_cache_size();
|
|
2275
|
+
}
|
|
2276
|
+
function redisCacheKeyCount() {
|
|
2277
|
+
const native = getNativeBridge();
|
|
2278
|
+
if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
|
|
2279
|
+
return native.redis_cache_key_count();
|
|
2280
|
+
}
|
|
2281
|
+
function redisCacheClear() {
|
|
2282
|
+
const native = getNativeBridge();
|
|
2283
|
+
if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
|
|
2284
|
+
return native.redis_cache_clear();
|
|
2285
|
+
}
|
|
2286
|
+
function redisCacheHitRate() {
|
|
2287
|
+
const native = getNativeBridge();
|
|
2288
|
+
if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
|
|
2289
|
+
return native.redis_cache_hit_rate();
|
|
2290
|
+
}
|
|
2291
|
+
function redisEnablePersistence(mode) {
|
|
2292
|
+
const native = getNativeBridge();
|
|
2293
|
+
if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
|
|
2294
|
+
return native.redis_enable_persistence(mode);
|
|
2295
|
+
}
|
|
2296
|
+
function redisDisablePersistence() {
|
|
2297
|
+
const native = getNativeBridge();
|
|
2298
|
+
if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
|
|
2299
|
+
return native.redis_disable_persistence();
|
|
2300
|
+
}
|
|
2301
|
+
function redisSnapshot() {
|
|
2302
|
+
const native = getNativeBridge();
|
|
2303
|
+
if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
|
|
2304
|
+
return native.redis_snapshot();
|
|
2305
|
+
}
|
|
2306
|
+
function redisMemoryStats() {
|
|
2307
|
+
const native = getNativeBridge();
|
|
2308
|
+
if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
|
|
2309
|
+
return native.redis_memory_stats();
|
|
2310
|
+
}
|
|
2311
|
+
function redisOptimizeMemory() {
|
|
2312
|
+
const native = getNativeBridge();
|
|
2313
|
+
if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
|
|
2314
|
+
return native.redis_optimize_memory();
|
|
2315
|
+
}
|
|
2316
|
+
function redisSetEvictionPolicy(policy) {
|
|
2317
|
+
const native = getNativeBridge();
|
|
2318
|
+
if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
|
|
2319
|
+
return native.redis_set_eviction_policy(policy);
|
|
2320
|
+
}
|
|
2321
|
+
function redisGetEvictionPolicy() {
|
|
2322
|
+
const native = getNativeBridge();
|
|
2323
|
+
if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
|
|
2324
|
+
return native.redis_get_eviction_policy();
|
|
2325
|
+
}
|
|
2326
|
+
function redisReplicate(target_host, target_port) {
|
|
2327
|
+
const native = getNativeBridge();
|
|
2328
|
+
if (!native?.redis_replicate) throw new Error("redis_replicate not available");
|
|
2329
|
+
return native.redis_replicate(target_host, target_port);
|
|
2330
|
+
}
|
|
2331
|
+
function redisReplicationStatus() {
|
|
2332
|
+
const native = getNativeBridge();
|
|
2333
|
+
if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
|
|
2334
|
+
return native.redis_replication_status();
|
|
2335
|
+
}
|
|
2336
|
+
function redisCacheSync(peers) {
|
|
2337
|
+
const native = getNativeBridge();
|
|
2338
|
+
if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
|
|
2339
|
+
return native.redis_cache_sync(peers);
|
|
2340
|
+
}
|
|
2341
|
+
function redisEnableCacheWarming(key_pattern) {
|
|
2342
|
+
const native = getNativeBridge();
|
|
2343
|
+
if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
|
|
2344
|
+
return native.redis_enable_cache_warming(key_pattern);
|
|
2345
|
+
}
|
|
2346
|
+
function redisDisableCacheWarming() {
|
|
2347
|
+
const native = getNativeBridge();
|
|
2348
|
+
if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
|
|
2349
|
+
return native.redis_disable_cache_warming();
|
|
2350
|
+
}
|
|
2351
|
+
function redisDiagnose() {
|
|
2352
|
+
const native = getNativeBridge();
|
|
2353
|
+
if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
|
|
2354
|
+
return native.redis_diagnose();
|
|
2355
|
+
}
|
|
2356
|
+
var init_redisNative = __esm({
|
|
2357
|
+
"packages/domain/compiler/src/redis/redisNative.ts"() {
|
|
2358
|
+
init_nativeBridge();
|
|
2359
|
+
}
|
|
2360
|
+
});
|
|
2361
|
+
|
|
2362
|
+
// packages/domain/compiler/src/redis/index.ts
|
|
2363
|
+
var init_redis = __esm({
|
|
2364
|
+
"packages/domain/compiler/src/redis/index.ts"() {
|
|
2365
|
+
init_redisNative();
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
|
|
2369
|
+
// packages/domain/compiler/src/watch/watchSystemNative.ts
|
|
2370
|
+
function startWatch(root_path, patterns) {
|
|
2371
|
+
const native = getNativeBridge();
|
|
2372
|
+
if (!native?.start_watch) throw new Error("start_watch not available");
|
|
2373
|
+
return native.start_watch(root_path, patterns);
|
|
2374
|
+
}
|
|
2375
|
+
function pollWatchEvents(handle, timeout_ms) {
|
|
2376
|
+
const native = getNativeBridge();
|
|
2377
|
+
if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
|
|
2378
|
+
const result = native.poll_watch_events(handle, timeout_ms);
|
|
2379
|
+
try {
|
|
2380
|
+
return JSON.parse(result);
|
|
2381
|
+
} catch {
|
|
2382
|
+
return [];
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
function stopWatch(handle) {
|
|
2386
|
+
const native = getNativeBridge();
|
|
2387
|
+
if (!native?.stop_watch) throw new Error("stop_watch not available");
|
|
2388
|
+
return native.stop_watch(handle);
|
|
2389
|
+
}
|
|
2390
|
+
function watchAddPattern(handle, pattern) {
|
|
2391
|
+
const native = getNativeBridge();
|
|
2392
|
+
if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
|
|
2393
|
+
return native.watch_add_pattern(handle, pattern);
|
|
2394
|
+
}
|
|
2395
|
+
function watchRemovePattern(handle, pattern) {
|
|
2396
|
+
const native = getNativeBridge();
|
|
2397
|
+
if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
|
|
2398
|
+
return native.watch_remove_pattern(handle, pattern);
|
|
2399
|
+
}
|
|
2400
|
+
function watchGetActiveHandles() {
|
|
2401
|
+
const native = getNativeBridge();
|
|
2402
|
+
if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
|
|
2403
|
+
const result = native.watch_get_active_handles();
|
|
2404
|
+
try {
|
|
2405
|
+
return JSON.parse(result);
|
|
2406
|
+
} catch {
|
|
2407
|
+
return [];
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
function watchClearAll() {
|
|
2411
|
+
const native = getNativeBridge();
|
|
2412
|
+
if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
|
|
2413
|
+
return native.watch_clear_all();
|
|
2414
|
+
}
|
|
2415
|
+
function watchEventTypeToString(event_type_code) {
|
|
2416
|
+
const native = getNativeBridge();
|
|
2417
|
+
if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
|
|
2418
|
+
return native.watch_event_type_to_string(event_type_code);
|
|
2419
|
+
}
|
|
2420
|
+
function isWatchRunning(handle) {
|
|
2421
|
+
const native = getNativeBridge();
|
|
2422
|
+
if (!native?.is_watch_running) throw new Error("is_watch_running not available");
|
|
2423
|
+
return native.is_watch_running(handle);
|
|
2424
|
+
}
|
|
2425
|
+
function getWatchStats() {
|
|
2426
|
+
const native = getNativeBridge();
|
|
2427
|
+
if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
|
|
2428
|
+
const result = native.get_watch_stats();
|
|
2429
|
+
try {
|
|
2430
|
+
return JSON.parse(result);
|
|
2431
|
+
} catch {
|
|
2432
|
+
return {
|
|
2433
|
+
active_watchers: 0,
|
|
2434
|
+
total_events: 0,
|
|
2435
|
+
events_this_second: 0,
|
|
2436
|
+
average_latency_ms: 0,
|
|
2437
|
+
largest_batch_size: 0
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
function watchPause(handle) {
|
|
2442
|
+
const native = getNativeBridge();
|
|
2443
|
+
if (!native?.watch_pause) throw new Error("watch_pause not available");
|
|
2444
|
+
return native.watch_pause(handle);
|
|
2445
|
+
}
|
|
2446
|
+
function watchResume(handle) {
|
|
2447
|
+
const native = getNativeBridge();
|
|
2448
|
+
if (!native?.watch_resume) throw new Error("watch_resume not available");
|
|
2449
|
+
return native.watch_resume(handle);
|
|
2450
|
+
}
|
|
2451
|
+
function scanCacheOptimizations() {
|
|
2452
|
+
const native = getNativeBridge();
|
|
2453
|
+
if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
|
|
2454
|
+
return native.scan_cache_optimizations();
|
|
2455
|
+
}
|
|
2456
|
+
function getPluginHooks() {
|
|
2457
|
+
const native = getNativeBridge();
|
|
2458
|
+
if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
|
|
2459
|
+
const result = native.get_plugin_hooks();
|
|
2460
|
+
try {
|
|
2461
|
+
return JSON.parse(result);
|
|
2462
|
+
} catch {
|
|
2463
|
+
return [];
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
function registerPluginHook(hook_name, handler_id) {
|
|
2467
|
+
const native = getNativeBridge();
|
|
2468
|
+
if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
|
|
2469
|
+
return native.register_plugin_hook(hook_name, handler_id);
|
|
2470
|
+
}
|
|
2471
|
+
function unregisterPluginHook(hook_name, handler_id) {
|
|
2472
|
+
const native = getNativeBridge();
|
|
2473
|
+
if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
|
|
2474
|
+
return native.unregister_plugin_hook(hook_name, handler_id);
|
|
2475
|
+
}
|
|
2476
|
+
function emitPluginHook(hook_name, data_json) {
|
|
2477
|
+
const native = getNativeBridge();
|
|
2478
|
+
if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
|
|
2479
|
+
return native.emit_plugin_hook(hook_name, data_json);
|
|
2480
|
+
}
|
|
2481
|
+
function getCompilationMetrics() {
|
|
2482
|
+
const native = getNativeBridge();
|
|
2483
|
+
if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
|
|
2484
|
+
return native.get_compilation_metrics();
|
|
2485
|
+
}
|
|
2486
|
+
function resetCompilationMetrics() {
|
|
2487
|
+
const native = getNativeBridge();
|
|
2488
|
+
if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
|
|
2489
|
+
return native.reset_compilation_metrics();
|
|
2490
|
+
}
|
|
2491
|
+
function validateCssOutput(css) {
|
|
2492
|
+
const native = getNativeBridge();
|
|
2493
|
+
if (!native?.validate_css_output) throw new Error("validate_css_output not available");
|
|
2494
|
+
return native.validate_css_output(css);
|
|
2495
|
+
}
|
|
2496
|
+
function getCompilerDiagnostics() {
|
|
2497
|
+
const native = getNativeBridge();
|
|
2498
|
+
if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
|
|
2499
|
+
return native.get_compiler_diagnostics();
|
|
2500
|
+
}
|
|
2501
|
+
var init_watchSystemNative = __esm({
|
|
2502
|
+
"packages/domain/compiler/src/watch/watchSystemNative.ts"() {
|
|
2503
|
+
init_nativeBridge();
|
|
2504
|
+
}
|
|
2505
|
+
});
|
|
2506
|
+
|
|
2507
|
+
// packages/domain/compiler/src/watch/index.ts
|
|
2508
|
+
var init_watch = __esm({
|
|
2509
|
+
"packages/domain/compiler/src/watch/index.ts"() {
|
|
2510
|
+
init_watchSystemNative();
|
|
2511
|
+
}
|
|
2512
|
+
});
|
|
2513
|
+
|
|
2514
|
+
// packages/domain/compiler/src/internal.ts
|
|
2515
|
+
var internal_exports = {};
|
|
2516
|
+
__export(internal_exports, {
|
|
2517
|
+
adaptNativeResult: () => adaptNativeResult,
|
|
2518
|
+
analyzeClassUsageNative: () => analyzeClassUsageNative,
|
|
2519
|
+
analyzeClasses: () => analyzeClasses,
|
|
2520
|
+
analyzeClassesNative: () => analyzeClassesNative,
|
|
2521
|
+
analyzeFile: () => analyzeFile,
|
|
2522
|
+
analyzeRscNative: () => analyzeRscNative,
|
|
2523
|
+
analyzeVariantUsage: () => analyzeVariantUsage,
|
|
2524
|
+
astExtractClasses: () => astExtractClasses,
|
|
2525
|
+
atomicRegistrySize: () => atomicRegistrySize,
|
|
2526
|
+
batchExtractClasses: () => batchExtractClasses,
|
|
2527
|
+
batchExtractClassesNative: () => batchExtractClassesNative,
|
|
2528
|
+
bucketSort: () => bucketSort,
|
|
2529
|
+
buildStyleTag: () => buildStyleTag,
|
|
2530
|
+
cachePriority: () => cachePriority,
|
|
2531
|
+
cacheRead: () => cacheRead,
|
|
2532
|
+
cacheWrite: () => cacheWrite,
|
|
2533
|
+
checkAgainstSafelist: () => checkAgainstSafelist,
|
|
2534
|
+
checkAgainstSafelistNative: () => checkAgainstSafelistNative,
|
|
2535
|
+
classifyAndSortClassesNative: () => classifyAndSortClassesNative,
|
|
2536
|
+
classifyNode: () => classifyNode,
|
|
2537
|
+
clearAllCaches: () => clearAllCaches,
|
|
2538
|
+
clearAtomicRegistry: () => clearAtomicRegistry,
|
|
2539
|
+
clearCache: () => clearCache,
|
|
2540
|
+
clearCompileCache: () => clearCompileCache,
|
|
2541
|
+
clearCssGenCache: () => clearCssGenCache,
|
|
2542
|
+
clearParseCache: () => clearParseCache,
|
|
2543
|
+
clearResolveCache: () => clearResolveCache,
|
|
2544
|
+
clearThemeCache: () => clearThemeCache,
|
|
2545
|
+
collectFiles: () => collectFiles,
|
|
2546
|
+
compileAnimation: () => compileAnimation,
|
|
2547
|
+
compileClass: () => compileClass,
|
|
2548
|
+
compileClasses: () => compileClasses,
|
|
2549
|
+
compileCssFromClasses: () => compileCssFromClasses,
|
|
2550
|
+
compileCssLightning: () => compileCssLightning,
|
|
2551
|
+
compileCssNative2: () => compileCssNative2,
|
|
2552
|
+
compileKeyframes: () => compileKeyframes,
|
|
2553
|
+
compileTheme: () => compileTheme,
|
|
2554
|
+
compileToCss: () => compileToCss,
|
|
2555
|
+
compileToCssBatch: () => compileToCssBatch,
|
|
2556
|
+
compileVariantTableNative: () => compileVariantTableNative,
|
|
2557
|
+
computeIncrementalDiff: () => computeIncrementalDiff,
|
|
2558
|
+
createFingerprint: () => createFingerprint,
|
|
2559
|
+
detectConflicts: () => detectConflicts,
|
|
2560
|
+
detectDeadCode: () => detectDeadCode,
|
|
2561
|
+
diffClassLists: () => diffClassLists,
|
|
2562
|
+
eliminateDeadCss: () => eliminateDeadCss,
|
|
2563
|
+
eliminateDeadCssNative: () => eliminateDeadCssNative,
|
|
2564
|
+
emitPluginHook: () => emitPluginHook,
|
|
2565
|
+
estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
|
|
2566
|
+
extractAllClasses: () => extractAllClasses,
|
|
2567
|
+
extractAndGenerateStateCss: () => extractAndGenerateStateCss,
|
|
2568
|
+
extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
|
|
2569
|
+
extractClassesFromSource: () => extractClassesFromSource,
|
|
2570
|
+
extractClassesFromSourceNative: () => extractClassesFromSourceNative,
|
|
2571
|
+
extractComponentUsage: () => extractComponentUsage,
|
|
2572
|
+
extractContainerCssFromSource: () => extractContainerCssFromSource,
|
|
2573
|
+
extractTwContainerConfigs: () => extractTwContainerConfigs,
|
|
2574
|
+
extractTwStateConfigs: () => extractTwStateConfigs,
|
|
2575
|
+
extractTwStateConfigsNative: () => extractTwStateConfigsNative,
|
|
2576
|
+
fileToRoute: () => fileToRoute,
|
|
2577
|
+
findDeadVariants: () => findDeadVariants,
|
|
2578
|
+
generateAtomicCss: () => generateAtomicCss,
|
|
2579
|
+
generateCssForClasses: () => generateCssForClasses,
|
|
2580
|
+
generateCssNative: () => generateCssNative,
|
|
2581
|
+
generateSafelist: () => generateSafelist,
|
|
2582
|
+
generateStaticStateCss: () => generateStaticStateCss,
|
|
2583
|
+
generateStaticStateCssNative: () => generateStaticStateCssNative,
|
|
2584
|
+
generateSubComponentTypes: () => generateSubComponentTypes,
|
|
2585
|
+
getAllRoutes: () => getAllRoutes,
|
|
2586
|
+
getBucketEngine: () => getBucketEngine,
|
|
2587
|
+
getCacheOptimizationHints: () => getCacheOptimizationHints,
|
|
2588
|
+
getCacheStatistics: () => getCacheStatistics,
|
|
2589
|
+
getCacheStats: () => getCacheStats,
|
|
2590
|
+
getCompilationMetrics: () => getCompilationMetrics,
|
|
2591
|
+
getCompilerDiagnostics: () => getCompilerDiagnostics,
|
|
2592
|
+
getContentPaths: () => getContentPaths,
|
|
2593
|
+
getIncrementalEngine: () => getIncrementalEngine,
|
|
2594
|
+
getNativeBridge: () => getNativeBridge,
|
|
2595
|
+
getPluginHooks: () => getPluginHooks,
|
|
2596
|
+
getRouteClasses: () => getRouteClasses,
|
|
2597
|
+
getWatchStats: () => getWatchStats,
|
|
2598
|
+
hasTwUsage: () => hasTwUsage,
|
|
2599
|
+
hashContent: () => hashContent,
|
|
2600
|
+
hoistComponentsNative: () => hoistComponentsNative,
|
|
2601
|
+
idRegistryActiveCount: () => idRegistryActiveCount,
|
|
2602
|
+
idRegistryCreate: () => idRegistryCreate,
|
|
2603
|
+
idRegistryDestroy: () => idRegistryDestroy,
|
|
2604
|
+
idRegistryExport: () => idRegistryExport,
|
|
2605
|
+
idRegistryGenerate: () => idRegistryGenerate,
|
|
2606
|
+
idRegistryImport: () => idRegistryImport,
|
|
2607
|
+
idRegistryLookup: () => idRegistryLookup,
|
|
2608
|
+
idRegistryNext: () => idRegistryNext,
|
|
2609
|
+
idRegistryReset: () => idRegistryReset,
|
|
2610
|
+
idRegistrySnapshot: () => idRegistrySnapshot,
|
|
2611
|
+
injectClientDirective: () => injectClientDirective,
|
|
2612
|
+
injectServerOnlyComment: () => injectServerOnlyComment,
|
|
2613
|
+
injectStateHash: () => injectStateHash,
|
|
2614
|
+
isAlreadyTransformed: () => isAlreadyTransformed,
|
|
2615
|
+
isWatchRunning: () => isWatchRunning,
|
|
2616
|
+
layoutClassesToCss: () => layoutClassesToCss,
|
|
2617
|
+
loadSafelist: () => loadSafelist,
|
|
2618
|
+
loadTailwindConfig: () => loadTailwindConfig,
|
|
2619
|
+
mergeClassesStatic: () => mergeClassesStatic,
|
|
2620
|
+
mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
|
|
2621
|
+
minifyCss: () => minifyCss,
|
|
2622
|
+
normalizeAndDedupClasses: () => normalizeAndDedupClasses,
|
|
2623
|
+
normalizeClasses: () => normalizeClasses,
|
|
2624
|
+
optimizeCssNative: () => optimizeCssNative,
|
|
2625
|
+
parseAtomicClass: () => parseAtomicClass,
|
|
2626
|
+
parseClasses: () => parseClasses,
|
|
2627
|
+
pollWatchEvents: () => pollWatchEvents,
|
|
2628
|
+
processFileChange: () => processFileChange,
|
|
2629
|
+
processTailwindCssLightning: () => processTailwindCssLightning,
|
|
2630
|
+
propertyIdToString: () => propertyIdToString,
|
|
2631
|
+
pruneStaleCacheEntries: () => pruneStaleCacheEntries,
|
|
2632
|
+
rebuildWorkspaceResult: () => rebuildWorkspaceResult,
|
|
2633
|
+
redisCacheClear: () => redisCacheClear,
|
|
2634
|
+
redisCacheHitRate: () => redisCacheHitRate,
|
|
2635
|
+
redisCacheKeyCount: () => redisCacheKeyCount,
|
|
2636
|
+
redisCacheSize: () => redisCacheSize,
|
|
2637
|
+
redisCacheSync: () => redisCacheSync,
|
|
2638
|
+
redisClusterStatus: () => redisClusterStatus,
|
|
2639
|
+
redisDelete: () => redisDelete,
|
|
2640
|
+
redisDiagnose: () => redisDiagnose,
|
|
2641
|
+
redisDisableCacheWarming: () => redisDisableCacheWarming,
|
|
2642
|
+
redisDisableCluster: () => redisDisableCluster,
|
|
2643
|
+
redisDisablePersistence: () => redisDisablePersistence,
|
|
2644
|
+
redisEnableCacheWarming: () => redisEnableCacheWarming,
|
|
2645
|
+
redisEnableCluster: () => redisEnableCluster,
|
|
2646
|
+
redisEnablePersistence: () => redisEnablePersistence,
|
|
2647
|
+
redisExists: () => redisExists,
|
|
2648
|
+
redisExpirationGet: () => redisExpirationGet,
|
|
2649
|
+
redisExpirationSet: () => redisExpirationSet,
|
|
2650
|
+
redisFlushAll: () => redisFlushAll,
|
|
2651
|
+
redisFlushDb: () => redisFlushDb,
|
|
2652
|
+
redisGet: () => redisGet,
|
|
2653
|
+
redisGetEvictionPolicy: () => redisGetEvictionPolicy,
|
|
2654
|
+
redisInfo: () => redisInfo,
|
|
2655
|
+
redisMemoryStats: () => redisMemoryStats,
|
|
2656
|
+
redisMget: () => redisMget,
|
|
2657
|
+
redisMonitor: () => redisMonitor,
|
|
2658
|
+
redisMset: () => redisMset,
|
|
2659
|
+
redisOptimizeMemory: () => redisOptimizeMemory,
|
|
2660
|
+
redisPing: () => redisPing,
|
|
2661
|
+
redisPoolConnect: () => redisPoolConnect,
|
|
2662
|
+
redisPoolReconnect: () => redisPoolReconnect,
|
|
2663
|
+
redisPoolStats: () => redisPoolStats,
|
|
2664
|
+
redisPublish: () => redisPublish,
|
|
2665
|
+
redisReplicate: () => redisReplicate,
|
|
2666
|
+
redisReplicationStatus: () => redisReplicationStatus,
|
|
2667
|
+
redisSet: () => redisSet,
|
|
2668
|
+
redisSetEvictionPolicy: () => redisSetEvictionPolicy,
|
|
2669
|
+
redisSnapshot: () => redisSnapshot,
|
|
2670
|
+
redisSubscribe: () => redisSubscribe,
|
|
2671
|
+
registerFileClasses: () => registerFileClasses,
|
|
2672
|
+
registerGlobalClasses: () => registerGlobalClasses,
|
|
2673
|
+
registerPluginHook: () => registerPluginHook,
|
|
2674
|
+
registerPropertyName: () => registerPropertyName,
|
|
2675
|
+
registerValueName: () => registerValueName,
|
|
2676
|
+
resetBucketEngine: () => resetBucketEngine,
|
|
2677
|
+
resetCompilationMetrics: () => resetCompilationMetrics,
|
|
2678
|
+
resetIncrementalEngine: () => resetIncrementalEngine,
|
|
2679
|
+
resolveCascade: () => resolveCascade,
|
|
2680
|
+
resolveClassNames: () => resolveClassNames,
|
|
2681
|
+
resolveConflictGroup: () => resolveConflictGroup,
|
|
2682
|
+
resolveSimpleVariants: () => resolveSimpleVariants,
|
|
2683
|
+
resolveThemeValue: () => resolveThemeValue,
|
|
2684
|
+
resolveVariants: () => resolveVariants,
|
|
2685
|
+
reverseLookupProperty: () => reverseLookupProperty,
|
|
2686
|
+
reverseLookupValue: () => reverseLookupValue,
|
|
2687
|
+
runCssPipeline: () => runCssPipeline,
|
|
2688
|
+
runCssPipelineSync: () => runCssPipelineSync,
|
|
2689
|
+
runElimination: () => runElimination,
|
|
2690
|
+
runLoaderTransform: () => runLoaderTransform,
|
|
2691
|
+
scanCacheOptimizations: () => scanCacheOptimizations,
|
|
2692
|
+
scanFile: () => scanFile,
|
|
2693
|
+
scanFileNative: () => scanFileNative,
|
|
2694
|
+
scanFilesBatchNative: () => scanFilesBatchNative,
|
|
2695
|
+
scanProjectUsage: () => scanProjectUsage,
|
|
2696
|
+
scanWorkspace: () => scanWorkspace,
|
|
2697
|
+
shouldProcess: () => shouldProcess,
|
|
2698
|
+
shouldSkipFile: () => shouldSkipFile,
|
|
2699
|
+
startWatch: () => startWatch,
|
|
2700
|
+
stopWatch: () => stopWatch,
|
|
2701
|
+
toAtomicClasses: () => toAtomicClasses,
|
|
2702
|
+
transformSource: () => transformSource,
|
|
2703
|
+
twMerge: () => twMerge,
|
|
2704
|
+
twMergeMany: () => twMergeMany,
|
|
2705
|
+
twMergeManyWithSeparator: () => twMergeManyWithSeparator,
|
|
2706
|
+
twMergeRaw: () => twMergeRaw,
|
|
2707
|
+
twMergeWithSeparator: () => twMergeWithSeparator,
|
|
2708
|
+
unregisterPluginHook: () => unregisterPluginHook,
|
|
2709
|
+
validateCssOutput: () => validateCssOutput,
|
|
2710
|
+
validateThemeConfig: () => validateThemeConfig,
|
|
2711
|
+
valueIdToString: () => valueIdToString,
|
|
2712
|
+
walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
|
|
2713
|
+
watchAddPattern: () => watchAddPattern,
|
|
2714
|
+
watchClearAll: () => watchClearAll,
|
|
2715
|
+
watchEventTypeToString: () => watchEventTypeToString,
|
|
2716
|
+
watchGetActiveHandles: () => watchGetActiveHandles,
|
|
2717
|
+
watchPause: () => watchPause,
|
|
2718
|
+
watchRemovePattern: () => watchRemovePattern,
|
|
2719
|
+
watchResume: () => watchResume
|
|
2720
|
+
});
|
|
2721
|
+
var init_internal = __esm({
|
|
2722
|
+
"packages/domain/compiler/src/internal.ts"() {
|
|
2723
|
+
init_src2();
|
|
2724
|
+
init_tailwindEngine();
|
|
2725
|
+
init_compiler();
|
|
2726
|
+
init_parser();
|
|
2727
|
+
init_analyzer();
|
|
2728
|
+
init_cache();
|
|
2729
|
+
init_redis();
|
|
2730
|
+
init_watch();
|
|
2731
|
+
}
|
|
2732
|
+
});
|
|
2733
|
+
function getNative() {
|
|
2734
|
+
if (_native) return _native;
|
|
2735
|
+
try {
|
|
2736
|
+
const mod = (init_internal(), __toCommonJS(internal_exports));
|
|
2737
|
+
if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
|
|
2738
|
+
return null;
|
|
2739
|
+
}
|
|
2740
|
+
_native = {
|
|
2741
|
+
extractTwStateConfigs: mod.extractTwStateConfigs,
|
|
2742
|
+
generateStaticStateCss: mod.generateStaticStateCss,
|
|
2743
|
+
extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
|
|
2744
|
+
((source, filename) => {
|
|
2745
|
+
const configs = mod.extractTwStateConfigs(source, filename);
|
|
2746
|
+
if (configs.length === 0) return [];
|
|
2747
|
+
return mod.generateStaticStateCss(configs.map((c) => ({
|
|
2748
|
+
tag: c.tag,
|
|
2749
|
+
componentName: c.componentName,
|
|
2750
|
+
statesJson: c.statesJson
|
|
2751
|
+
})));
|
|
2752
|
+
})
|
|
2753
|
+
};
|
|
2754
|
+
return _native;
|
|
2755
|
+
} catch {
|
|
2756
|
+
return null;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
function* walkSourceFiles(dir) {
|
|
2760
|
+
let entries;
|
|
2761
|
+
try {
|
|
2762
|
+
entries = fs13__default.readdirSync(dir, { withFileTypes: true });
|
|
2763
|
+
} catch {
|
|
2764
|
+
return;
|
|
2765
|
+
}
|
|
2766
|
+
for (const entry of entries) {
|
|
2767
|
+
const fullPath = path9__default.join(dir, entry.name);
|
|
2768
|
+
if (entry.isDirectory()) {
|
|
2769
|
+
if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
|
|
2770
|
+
yield* walkSourceFiles(fullPath);
|
|
2771
|
+
} else if (entry.isFile()) {
|
|
2772
|
+
const ext = path9__default.extname(entry.name);
|
|
2773
|
+
if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
function buildCssHeader(result) {
|
|
2778
|
+
return [
|
|
2779
|
+
"/* \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",
|
|
2780
|
+
" * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
|
|
2781
|
+
" * DO NOT EDIT. Re-generated on each build.",
|
|
2782
|
+
" *",
|
|
2783
|
+
` * Files scanned: ${result.filesScanned}`,
|
|
2784
|
+
` * Files with states: ${result.filesWithStates}`,
|
|
2785
|
+
` * Components found: ${result.componentsFound}`,
|
|
2786
|
+
` * Rules generated: ${result.rulesGenerated}`,
|
|
2787
|
+
` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
|
|
2788
|
+
" *",
|
|
2789
|
+
' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
|
|
2790
|
+
" * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
|
|
2791
|
+
" * \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 */",
|
|
2792
|
+
""
|
|
2793
|
+
].join("\n");
|
|
2794
|
+
}
|
|
2795
|
+
function extractStaticStateCss(srcDir, options = {}) {
|
|
2796
|
+
const { verbose = false, maxFiles = Infinity } = options;
|
|
2797
|
+
const native = getNative();
|
|
2798
|
+
if (!native) {
|
|
2799
|
+
if (verbose) {
|
|
2800
|
+
process.stderr.write(
|
|
2801
|
+
"[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
|
|
2802
|
+
);
|
|
2803
|
+
}
|
|
2804
|
+
return {
|
|
2805
|
+
filesScanned: 0,
|
|
2806
|
+
filesWithStates: 0,
|
|
2807
|
+
componentsFound: 0,
|
|
2808
|
+
rulesGenerated: 0,
|
|
2809
|
+
rulesSkipped: 0,
|
|
2810
|
+
generatedCss: "",
|
|
2811
|
+
rules: []
|
|
2812
|
+
};
|
|
2813
|
+
}
|
|
2814
|
+
const allConfigs = [];
|
|
2815
|
+
let filesScanned = 0;
|
|
2816
|
+
let filesWithStates = 0;
|
|
2817
|
+
if (native.walkAndPrefilterSourceFiles) {
|
|
2818
|
+
const prefiltered = native.walkAndPrefilterSourceFiles(
|
|
2819
|
+
srcDir,
|
|
2820
|
+
[".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
|
|
2821
|
+
["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
|
|
2822
|
+
// Required substrings — AND logic, identik dengan JS pre-filter di bawah
|
|
2823
|
+
["states:", "tw."],
|
|
2824
|
+
maxFiles === Infinity ? null : maxFiles,
|
|
2825
|
+
null
|
|
2826
|
+
// sequential — parallel mode opsional untuk large monorepo
|
|
2827
|
+
);
|
|
2828
|
+
for (const { path: filePath, content: source } of prefiltered) {
|
|
2829
|
+
filesScanned++;
|
|
2830
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
2831
|
+
if (configs.length > 0) {
|
|
2832
|
+
filesWithStates++;
|
|
2833
|
+
allConfigs.push(...configs);
|
|
2834
|
+
if (verbose) {
|
|
2835
|
+
process.stderr.write(
|
|
2836
|
+
`[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2837
|
+
`
|
|
2838
|
+
);
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
} else {
|
|
2843
|
+
for (const filePath of walkSourceFiles(srcDir)) {
|
|
2844
|
+
if (filesScanned >= maxFiles) break;
|
|
2845
|
+
let source;
|
|
2846
|
+
try {
|
|
2847
|
+
source = fs13__default.readFileSync(filePath, "utf-8");
|
|
2848
|
+
} catch {
|
|
2849
|
+
continue;
|
|
2850
|
+
}
|
|
2851
|
+
filesScanned++;
|
|
2852
|
+
if (!source.includes("states:") && !source.includes("states :")) continue;
|
|
2853
|
+
if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
|
|
2854
|
+
const configs = native.extractTwStateConfigs(source, filePath);
|
|
2855
|
+
if (configs.length > 0) {
|
|
2856
|
+
filesWithStates++;
|
|
2857
|
+
allConfigs.push(...configs);
|
|
2858
|
+
if (verbose) {
|
|
2859
|
+
process.stderr.write(
|
|
2860
|
+
`[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
|
|
2861
|
+
`
|
|
2862
|
+
);
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
if (allConfigs.length === 0) {
|
|
2868
|
+
return {
|
|
2869
|
+
filesScanned,
|
|
2870
|
+
filesWithStates: 0,
|
|
2871
|
+
componentsFound: 0,
|
|
2872
|
+
rulesGenerated: 0,
|
|
2873
|
+
rulesSkipped: 0,
|
|
2874
|
+
generatedCss: "",
|
|
2875
|
+
rules: []
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2878
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2879
|
+
const uniqueConfigs = [];
|
|
2880
|
+
for (const config of allConfigs) {
|
|
2881
|
+
const key = `${config.tag}::${config.statesJson}`;
|
|
2882
|
+
if (!seen.has(key)) {
|
|
2883
|
+
seen.add(key);
|
|
2884
|
+
uniqueConfigs.push({
|
|
2885
|
+
tag: config.tag,
|
|
2886
|
+
componentName: config.componentName,
|
|
2887
|
+
statesJson: config.statesJson
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
|
|
2892
|
+
const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
|
|
2893
|
+
try {
|
|
2894
|
+
const stateMap = JSON.parse(cfg.statesJson);
|
|
2895
|
+
return total + Object.keys(stateMap).length;
|
|
2896
|
+
} catch {
|
|
2897
|
+
return total;
|
|
2898
|
+
}
|
|
2899
|
+
}, 0) - allRules.length;
|
|
2900
|
+
const byComponent = /* @__PURE__ */ new Map();
|
|
2901
|
+
for (const rule of allRules) {
|
|
2902
|
+
const existing = byComponent.get(rule.componentName) ?? [];
|
|
2903
|
+
existing.push(rule);
|
|
2904
|
+
byComponent.set(rule.componentName, existing);
|
|
2905
|
+
}
|
|
2906
|
+
const cssBlocks = [];
|
|
2907
|
+
for (const [componentName, rules] of byComponent) {
|
|
2908
|
+
cssBlocks.push(`/* ${componentName} */`);
|
|
2909
|
+
for (const rule of rules) {
|
|
2910
|
+
cssBlocks.push(`/* state: ${rule.stateName} */`);
|
|
2911
|
+
cssBlocks.push(rule.cssRule);
|
|
2912
|
+
}
|
|
2913
|
+
cssBlocks.push("");
|
|
2914
|
+
}
|
|
2915
|
+
const result = {
|
|
2916
|
+
filesScanned,
|
|
2917
|
+
filesWithStates,
|
|
2918
|
+
componentsFound: allConfigs.length,
|
|
2919
|
+
rulesGenerated: allRules.length,
|
|
2920
|
+
rulesSkipped: Math.max(0, rulesSkipped),
|
|
2921
|
+
generatedCss: cssBlocks.join("\n"),
|
|
2922
|
+
rules: allRules
|
|
2923
|
+
};
|
|
2924
|
+
result.generatedCss = buildCssHeader(result) + result.generatedCss;
|
|
2925
|
+
return result;
|
|
2926
|
+
}
|
|
2927
|
+
function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
|
|
2928
|
+
const result = extractStaticStateCss(srcDir, options);
|
|
2929
|
+
const twClassesDir = path9__default.join(path9__default.dirname(safelistPath), "tw-classes");
|
|
2930
|
+
fs13__default.mkdirSync(twClassesDir, { recursive: true });
|
|
2931
|
+
const stateFilePath = path9__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
|
|
2932
|
+
if (result.rulesGenerated === 0) {
|
|
2933
|
+
try {
|
|
2934
|
+
fs13__default.writeFileSync(
|
|
2935
|
+
stateFilePath,
|
|
2936
|
+
"/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
|
|
2937
|
+
"utf-8"
|
|
2938
|
+
);
|
|
2939
|
+
} catch {
|
|
2940
|
+
}
|
|
2941
|
+
return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
|
|
2942
|
+
}
|
|
2943
|
+
try {
|
|
2944
|
+
fs13__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
|
|
2945
|
+
return [
|
|
2946
|
+
`[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
|
|
2947
|
+
` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
|
|
2948
|
+
` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
|
|
2949
|
+
` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
|
|
2950
|
+
].join("\n");
|
|
2951
|
+
} catch (writeErr) {
|
|
2952
|
+
const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
|
|
2953
|
+
return `[tw:static-state] gagal tulis state CSS: ${msg}`;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
|
|
2957
|
+
var init_staticStateExtractor = __esm({
|
|
2958
|
+
"packages/domain/shared/src/staticStateExtractor.ts"() {
|
|
2959
|
+
SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
|
|
2960
|
+
IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
|
|
2961
|
+
_native = null;
|
|
2962
|
+
TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
function getEnvLevel() {
|
|
2966
|
+
const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
|
|
2967
|
+
if (env && env in LEVELS) return env;
|
|
2968
|
+
return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
|
|
2969
|
+
}
|
|
2970
|
+
function setGlobalLogFile(filePath) {
|
|
2971
|
+
_globalLogFile = filePath;
|
|
2972
|
+
_logFileInitialized = false;
|
|
2973
|
+
try {
|
|
2974
|
+
fs13__default.mkdirSync(path9__default.dirname(filePath), { recursive: true });
|
|
2975
|
+
fs13__default.writeFileSync(
|
|
2976
|
+
filePath,
|
|
2977
|
+
`# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2978
|
+
`,
|
|
2979
|
+
"utf-8"
|
|
2980
|
+
);
|
|
2981
|
+
_logFileInitialized = true;
|
|
2982
|
+
} catch {
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
function writeToFile(line) {
|
|
2986
|
+
if (!_globalLogFile || !_logFileInitialized) return;
|
|
2987
|
+
try {
|
|
2988
|
+
fs13__default.appendFileSync(_globalLogFile, line);
|
|
2989
|
+
} catch {
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
function createLogger(prefix, level) {
|
|
2993
|
+
const loggerState = {
|
|
2994
|
+
currentLevel: getEnvLevel(),
|
|
2995
|
+
setLevel(l) {
|
|
2996
|
+
this.currentLevel = l;
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
const log7 = (msgLevel, stream, args) => {
|
|
3000
|
+
if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
|
|
3001
|
+
const line = `[${prefix}] ${args.map(String).join(" ")}
|
|
3002
|
+
`;
|
|
3003
|
+
process[stream].write(line);
|
|
3004
|
+
writeToFile(line);
|
|
3005
|
+
};
|
|
3006
|
+
return {
|
|
3007
|
+
error: (...a) => log7("error", "stderr", a),
|
|
3008
|
+
warn: (...a) => log7("warn", "stderr", a),
|
|
3009
|
+
info: (...a) => log7("info", "stdout", a),
|
|
3010
|
+
debug: (...a) => log7("debug", "stderr", a),
|
|
3011
|
+
setLevel: loggerState.setLevel,
|
|
3012
|
+
setLogFile: (filePath) => setGlobalLogFile(filePath)
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
var LEVELS, _globalLogFile, _logFileInitialized;
|
|
3016
|
+
var init_logger = __esm({
|
|
3017
|
+
"packages/domain/shared/src/logger.ts"() {
|
|
3018
|
+
LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
|
|
3019
|
+
_globalLogFile = null;
|
|
3020
|
+
_logFileInitialized = false;
|
|
3021
|
+
createLogger("tailwind-styled");
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
|
|
990
3025
|
// packages/domain/shared/src/index.ts
|
|
991
3026
|
var src_exports = {};
|
|
992
3027
|
__export(src_exports, {
|
|
@@ -1005,18 +3040,21 @@ __export(src_exports, {
|
|
|
1005
3040
|
RegistryPluginEntrySchema: () => RegistryPluginEntrySchema,
|
|
1006
3041
|
ScanCacheClassEntrySchema: () => ScanCacheClassEntrySchema,
|
|
1007
3042
|
ScanCacheSchema: () => ScanCacheSchema,
|
|
3043
|
+
TW_STATE_STATIC_FILENAME: () => TW_STATE_STATIC_FILENAME,
|
|
1008
3044
|
TailwindConfigSchema: () => TailwindConfigSchema,
|
|
1009
3045
|
TelemetryCollector: () => TelemetryCollector,
|
|
1010
3046
|
TwError: () => TwError,
|
|
3047
|
+
appendStaticStateCssToSafelist: () => appendStaticStateCssToSafelist,
|
|
1011
3048
|
assertTailwindV4: () => assertTailwindV4,
|
|
1012
3049
|
calculateHealth: () => calculateHealth,
|
|
1013
3050
|
createBuildTimer: () => createBuildTimer,
|
|
1014
3051
|
createDebugLogger: () => createDebugLogger,
|
|
1015
3052
|
createEsmRequire: () => createEsmRequire,
|
|
1016
|
-
createLogger: () =>
|
|
3053
|
+
createLogger: () => createLogger2,
|
|
1017
3054
|
createObservabilityClient: () => createObservabilityClient,
|
|
1018
3055
|
createTraceSnapshot: () => createTraceSnapshot,
|
|
1019
3056
|
detectTailwind: () => detectTailwind,
|
|
3057
|
+
extractStaticStateCss: () => extractStaticStateCss,
|
|
1020
3058
|
formatDuration: () => formatDuration,
|
|
1021
3059
|
formatErrorCode: () => formatErrorCode,
|
|
1022
3060
|
formatErrorMessage: () => formatErrorMessage,
|
|
@@ -1036,7 +3074,7 @@ __export(src_exports, {
|
|
|
1036
3074
|
getPipelinePercentages: () => getPipelinePercentages,
|
|
1037
3075
|
getSuggestion: () => getSuggestion,
|
|
1038
3076
|
getTailwindVersion: () => getTailwindVersion,
|
|
1039
|
-
hashContent: () =>
|
|
3077
|
+
hashContent: () => hashContent2,
|
|
1040
3078
|
isTailwindV4: () => isTailwindV4,
|
|
1041
3079
|
isTwError: () => isTwError,
|
|
1042
3080
|
loadNativeBinding: () => loadNativeBinding,
|
|
@@ -1052,10 +3090,11 @@ __export(src_exports, {
|
|
|
1052
3090
|
resolveRuntimeDir: () => resolveRuntimeDir,
|
|
1053
3091
|
resolveWorkerPath: () => resolveWorkerPath,
|
|
1054
3092
|
safeParseNative: () => safeParseNative,
|
|
3093
|
+
setGlobalLogFile: () => setGlobalLogFile,
|
|
1055
3094
|
tryRequire: () => tryRequire,
|
|
1056
3095
|
wrapUnknownError: () => wrapUnknownError
|
|
1057
3096
|
});
|
|
1058
|
-
function
|
|
3097
|
+
function createLogger2(namespace) {
|
|
1059
3098
|
const prefix = `[${namespace}]`;
|
|
1060
3099
|
return {
|
|
1061
3100
|
warn(...args) {
|
|
@@ -1084,9 +3123,9 @@ function createDebugLogger(namespace, label) {
|
|
|
1084
3123
|
}
|
|
1085
3124
|
};
|
|
1086
3125
|
}
|
|
1087
|
-
function formatIssuePath(
|
|
1088
|
-
if (!
|
|
1089
|
-
return
|
|
3126
|
+
function formatIssuePath(path16) {
|
|
3127
|
+
if (!path16 || path16.length === 0) return "(root)";
|
|
3128
|
+
return path16.map(
|
|
1090
3129
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1091
3130
|
).join(".");
|
|
1092
3131
|
}
|
|
@@ -1100,9 +3139,9 @@ function loadNativeBinding(options) {
|
|
|
1100
3139
|
const { runtimeDir, candidates, isValid } = options;
|
|
1101
3140
|
const loadErrors = [];
|
|
1102
3141
|
for (const candidate of candidates) {
|
|
1103
|
-
const candidatePath =
|
|
3142
|
+
const candidatePath = path9__default.resolve(runtimeDir, candidate);
|
|
1104
3143
|
try {
|
|
1105
|
-
if (!
|
|
3144
|
+
if (!fs13__default.existsSync(candidatePath) && !fs13__default.existsSync(candidatePath + ".node")) {
|
|
1106
3145
|
continue;
|
|
1107
3146
|
}
|
|
1108
3147
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1134,9 +3173,9 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1134
3173
|
}
|
|
1135
3174
|
}
|
|
1136
3175
|
if (!includeDefaultCandidates) return candidates;
|
|
1137
|
-
if (
|
|
3176
|
+
if (fs13__default.existsSync(runtimeDir)) {
|
|
1138
3177
|
try {
|
|
1139
|
-
for (const entry of
|
|
3178
|
+
for (const entry of fs13__default.readdirSync(runtimeDir)) {
|
|
1140
3179
|
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1141
3180
|
}
|
|
1142
3181
|
} catch {
|
|
@@ -1145,27 +3184,27 @@ function resolveNativeBindingCandidates(options) {
|
|
|
1145
3184
|
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
1146
3185
|
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
3186
|
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(
|
|
3187
|
+
candidates.push(path9__default.resolve(runtimeDir, `${bin}.node`));
|
|
3188
|
+
candidates.push(path9__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
3189
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
|
|
3190
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3191
|
+
candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
3192
|
+
candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
3193
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
3194
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
3195
|
+
candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1157
3196
|
}
|
|
1158
3197
|
return Array.from(new Set(candidates));
|
|
1159
3198
|
}
|
|
1160
3199
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
1161
|
-
if (dir) return
|
|
3200
|
+
if (dir) return path9__default.resolve(dir);
|
|
1162
3201
|
try {
|
|
1163
|
-
return
|
|
3202
|
+
return path9__default.dirname(fileURLToPath(importMetaUrl));
|
|
1164
3203
|
} catch {
|
|
1165
3204
|
return process.cwd();
|
|
1166
3205
|
}
|
|
1167
3206
|
}
|
|
1168
|
-
function
|
|
3207
|
+
function hashContent2(content, algorithm = "md5", length) {
|
|
1169
3208
|
const hash = createHash(algorithm).update(content).digest("hex");
|
|
1170
3209
|
return length ? hash.slice(0, length) : hash;
|
|
1171
3210
|
}
|
|
@@ -1188,6 +3227,8 @@ var init_src = __esm({
|
|
|
1188
3227
|
init_codegen();
|
|
1189
3228
|
init_native_resolution();
|
|
1190
3229
|
init_observability();
|
|
3230
|
+
init_staticStateExtractor();
|
|
3231
|
+
init_logger();
|
|
1191
3232
|
TwError = class _TwError extends Error {
|
|
1192
3233
|
/** @deprecated Gunakan source */
|
|
1193
3234
|
domain;
|
|
@@ -1221,8 +3262,8 @@ var init_src = __esm({
|
|
|
1221
3262
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
1222
3263
|
static fromZod(err) {
|
|
1223
3264
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
1224
|
-
const
|
|
1225
|
-
const message = first ? `${
|
|
3265
|
+
const path16 = formatIssuePath(first?.path);
|
|
3266
|
+
const message = first ? `${path16}: ${first.message}` : "Schema validation failed";
|
|
1226
3267
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
1227
3268
|
}
|
|
1228
3269
|
static wrap(source, code, err) {
|
|
@@ -1286,11 +3327,11 @@ var init_src = __esm({
|
|
|
1286
3327
|
});
|
|
1287
3328
|
|
|
1288
3329
|
// packages/domain/compiler/src/nativeBridge.ts
|
|
1289
|
-
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
3330
|
+
var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
|
|
1290
3331
|
var init_nativeBridge = __esm({
|
|
1291
3332
|
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
1292
3333
|
init_src();
|
|
1293
|
-
_loadNative = (
|
|
3334
|
+
_loadNative = (path16) => __require(path16);
|
|
1294
3335
|
log = (...args) => {
|
|
1295
3336
|
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
1296
3337
|
console.log("[compiler:native]", ...args);
|
|
@@ -1339,6 +3380,15 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
1339
3380
|
throw bridgeLoadError;
|
|
1340
3381
|
}
|
|
1341
3382
|
};
|
|
3383
|
+
adaptNativeResult = (raw) => {
|
|
3384
|
+
return {
|
|
3385
|
+
code: raw.code ?? "",
|
|
3386
|
+
classes: raw.classes ?? [],
|
|
3387
|
+
changed: raw.changed ?? false,
|
|
3388
|
+
rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
|
|
3389
|
+
metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
|
|
3390
|
+
};
|
|
3391
|
+
};
|
|
1342
3392
|
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
1343
3393
|
try {
|
|
1344
3394
|
getNativeBridge();
|
|
@@ -1347,110 +3397,377 @@ Tried paths: ${result.tried.join("\n")}`);
|
|
|
1347
3397
|
}
|
|
1348
3398
|
}
|
|
1349
3399
|
});
|
|
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 "";
|
|
3400
|
+
function _layoutClassesToCss(classes) {
|
|
1406
3401
|
const native = getNativeBridge();
|
|
1407
|
-
if (
|
|
1408
|
-
throw new Error("FATAL: Native binding '
|
|
3402
|
+
if (!native?.layoutClassesToCss) {
|
|
3403
|
+
throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
|
|
1409
3404
|
}
|
|
1410
|
-
|
|
1411
|
-
return result?.css ?? rawCss;
|
|
3405
|
+
return native.layoutClassesToCss(classes);
|
|
1412
3406
|
}
|
|
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);
|
|
3407
|
+
function _hashContainer(tag, containerJson, name) {
|
|
3408
|
+
const sortedKey = tag + (name ?? "") + containerJson;
|
|
1419
3409
|
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 };
|
|
3410
|
+
if (!native?.hashContent) {
|
|
3411
|
+
throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
|
|
3412
|
+
}
|
|
3413
|
+
return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
|
|
1431
3414
|
}
|
|
1432
|
-
function
|
|
3415
|
+
function extractContainerCssFromSource(source) {
|
|
1433
3416
|
const native = getNativeBridge();
|
|
1434
|
-
if (!native?.
|
|
1435
|
-
throw new Error("FATAL: Native binding '
|
|
3417
|
+
if (!native?.extractTwContainerConfigs) {
|
|
3418
|
+
throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
|
|
3419
|
+
}
|
|
3420
|
+
const configs = native.extractTwContainerConfigs(source);
|
|
3421
|
+
const rules = [];
|
|
3422
|
+
for (const cfg of configs) {
|
|
3423
|
+
const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
|
|
3424
|
+
for (const { key, classes } of cfg.breakpoints) {
|
|
3425
|
+
const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
|
|
3426
|
+
const css = _layoutClassesToCss(classes);
|
|
3427
|
+
if (!css) continue;
|
|
3428
|
+
const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
|
|
3429
|
+
rules.push(`${query}{.${id}{${css}}}`);
|
|
3430
|
+
}
|
|
1436
3431
|
}
|
|
1437
|
-
|
|
1438
|
-
return (result?.css ?? css).trim();
|
|
3432
|
+
return rules.join("\n");
|
|
1439
3433
|
}
|
|
1440
|
-
var
|
|
1441
|
-
var
|
|
1442
|
-
"packages/domain/compiler/src/
|
|
3434
|
+
var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
|
|
3435
|
+
var init_src2 = __esm({
|
|
3436
|
+
"packages/domain/compiler/src/index.ts"() {
|
|
1443
3437
|
init_nativeBridge();
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
3438
|
+
init_compiler();
|
|
3439
|
+
init_parser();
|
|
3440
|
+
init_analyzer();
|
|
3441
|
+
init_cache();
|
|
3442
|
+
init_redis();
|
|
3443
|
+
init_watch();
|
|
3444
|
+
transformSource = (source, opts) => {
|
|
3445
|
+
const native = getNativeBridge();
|
|
3446
|
+
if (!native?.transformSource) {
|
|
3447
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
3448
|
+
}
|
|
3449
|
+
const result = native.transformSource(source, opts);
|
|
3450
|
+
if (!result) {
|
|
3451
|
+
throw new Error("FATAL: transformSource returned null");
|
|
3452
|
+
}
|
|
3453
|
+
return result;
|
|
3454
|
+
};
|
|
3455
|
+
hasTwUsage = (source) => {
|
|
3456
|
+
const native = getNativeBridge();
|
|
3457
|
+
if (!native?.hasTwUsage) {
|
|
3458
|
+
throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
|
|
3459
|
+
}
|
|
3460
|
+
return native.hasTwUsage(source);
|
|
3461
|
+
};
|
|
3462
|
+
isAlreadyTransformed = (source) => {
|
|
3463
|
+
const native = getNativeBridge();
|
|
3464
|
+
if (!native?.isAlreadyTransformed) {
|
|
3465
|
+
throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
|
|
3466
|
+
}
|
|
3467
|
+
return native.isAlreadyTransformed(source);
|
|
3468
|
+
};
|
|
3469
|
+
shouldProcess = (source) => {
|
|
3470
|
+
return hasTwUsage(source) && !isAlreadyTransformed(source);
|
|
3471
|
+
};
|
|
3472
|
+
compileCssFromClasses = (classes, prefix) => {
|
|
3473
|
+
const native = getNativeBridge();
|
|
3474
|
+
if (!native?.transformSource) {
|
|
3475
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
3476
|
+
}
|
|
3477
|
+
const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
|
|
3478
|
+
if (!result) {
|
|
3479
|
+
throw new Error("FATAL: transformSource returned null");
|
|
3480
|
+
}
|
|
3481
|
+
return result;
|
|
3482
|
+
};
|
|
3483
|
+
buildStyleTag = (classes) => {
|
|
3484
|
+
const result = compileCssFromClasses(classes);
|
|
3485
|
+
return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
|
|
3486
|
+
};
|
|
3487
|
+
generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
|
|
3488
|
+
try {
|
|
3489
|
+
const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
|
|
3490
|
+
const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
|
|
3491
|
+
return result.css;
|
|
3492
|
+
} catch {
|
|
3493
|
+
const native = getNativeBridge();
|
|
3494
|
+
if (!native?.transformSource) {
|
|
3495
|
+
throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
|
|
3496
|
+
}
|
|
3497
|
+
const result = native.transformSource(classes.join(" "), {});
|
|
3498
|
+
return result?.code || "";
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
eliminateDeadCss = (css, deadClasses) => {
|
|
3502
|
+
const native = getNativeBridge();
|
|
3503
|
+
if (!native?.eliminateDeadCss) {
|
|
3504
|
+
throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
|
|
3505
|
+
}
|
|
3506
|
+
return native.eliminateDeadCss(css, Array.from(deadClasses));
|
|
3507
|
+
};
|
|
3508
|
+
findDeadVariants = (variantConfig, usage) => {
|
|
3509
|
+
const unused = [];
|
|
3510
|
+
const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
|
|
3511
|
+
for (const component of configs) {
|
|
3512
|
+
const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
|
|
3513
|
+
const variants = component.variants;
|
|
3514
|
+
for (const [key, values] of Object.entries(variants)) {
|
|
3515
|
+
for (const [value] of Object.entries(values)) {
|
|
3516
|
+
if (!componentUsage.has(`${key}:${value}`)) {
|
|
3517
|
+
unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
return { unusedCount: unused.length, unused };
|
|
3523
|
+
};
|
|
3524
|
+
runElimination = (css, scanResult) => {
|
|
3525
|
+
const native = getNativeBridge();
|
|
3526
|
+
if (!native?.detectDeadCode) {
|
|
3527
|
+
throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
|
|
3528
|
+
}
|
|
3529
|
+
const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
|
|
3530
|
+
return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
|
|
3531
|
+
};
|
|
3532
|
+
scanProjectUsage = (dirs, cwd) => {
|
|
3533
|
+
const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
|
|
3534
|
+
const files = dirs.map((dir) => path9__default.resolve(cwd, dir));
|
|
3535
|
+
const results = batchExtractClasses2(files) || [];
|
|
3536
|
+
const combined = {};
|
|
3537
|
+
for (const result of results) {
|
|
3538
|
+
if (result.ok && result.classes) {
|
|
3539
|
+
for (const cls of result.classes) {
|
|
3540
|
+
if (!combined[cls]) combined[cls] = {};
|
|
3541
|
+
combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
return combined;
|
|
3546
|
+
};
|
|
3547
|
+
generateSafelist = (scanDirs, outputPath, cwd) => {
|
|
3548
|
+
const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
|
|
3549
|
+
const allClasses = Object.keys(classes).sort();
|
|
3550
|
+
if (outputPath) {
|
|
3551
|
+
fs13__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
|
|
3552
|
+
}
|
|
3553
|
+
return allClasses;
|
|
3554
|
+
};
|
|
3555
|
+
loadSafelist = (safelistPath) => {
|
|
3556
|
+
try {
|
|
3557
|
+
const content = fs13__default.readFileSync(safelistPath, "utf-8");
|
|
3558
|
+
return JSON.parse(content);
|
|
3559
|
+
} catch {
|
|
3560
|
+
return [];
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
loadTailwindConfig = (cwd = process.cwd()) => {
|
|
3564
|
+
const configFiles = [
|
|
3565
|
+
"tailwind.config.ts",
|
|
3566
|
+
"tailwind.config.js",
|
|
3567
|
+
"tailwind.config.mjs",
|
|
3568
|
+
"tailwind.config.cjs"
|
|
3569
|
+
];
|
|
3570
|
+
for (const file of configFiles) {
|
|
3571
|
+
const fullPath = path9__default.join(cwd, file);
|
|
3572
|
+
if (fs13__default.existsSync(fullPath)) {
|
|
3573
|
+
const mod = __require(fullPath);
|
|
3574
|
+
return mod.default || mod;
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
return {};
|
|
3578
|
+
};
|
|
3579
|
+
getContentPaths = (cwd = process.cwd()) => {
|
|
3580
|
+
return {
|
|
3581
|
+
content: [
|
|
3582
|
+
path9__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
|
|
3583
|
+
path9__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
|
|
3584
|
+
path9__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
|
|
3585
|
+
]
|
|
3586
|
+
};
|
|
3587
|
+
};
|
|
3588
|
+
_CONTAINER_BREAKPOINTS = {
|
|
3589
|
+
xs: "240px",
|
|
3590
|
+
sm: "320px",
|
|
3591
|
+
md: "640px",
|
|
3592
|
+
lg: "1024px",
|
|
3593
|
+
xl: "1280px",
|
|
3594
|
+
"2xl": "1536px"
|
|
3595
|
+
};
|
|
3596
|
+
runLoaderTransform = (ctx) => {
|
|
3597
|
+
const { filepath, source, options } = ctx;
|
|
3598
|
+
const result = transformSource(source, { filename: filepath, ...options });
|
|
3599
|
+
let staticCss;
|
|
3600
|
+
try {
|
|
3601
|
+
const cssChunks = [];
|
|
3602
|
+
const stateRules = extractAndGenerateStateCss(source, filepath);
|
|
3603
|
+
if (stateRules.length > 0) {
|
|
3604
|
+
cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
|
|
3605
|
+
}
|
|
3606
|
+
const containerCss = extractContainerCssFromSource(source);
|
|
3607
|
+
if (containerCss) cssChunks.push(containerCss);
|
|
3608
|
+
const combined = cssChunks.join("\n").trim();
|
|
3609
|
+
if (combined) staticCss = combined;
|
|
3610
|
+
} catch (err) {
|
|
3611
|
+
console.debug("Static CSS extraction warning:", err);
|
|
3612
|
+
}
|
|
3613
|
+
return {
|
|
3614
|
+
code: result?.code || "",
|
|
3615
|
+
changed: result?.changed || false,
|
|
3616
|
+
classes: result?.classes || [],
|
|
3617
|
+
staticCss
|
|
3618
|
+
};
|
|
3619
|
+
};
|
|
3620
|
+
shouldSkipFile = (filepath) => {
|
|
3621
|
+
const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
|
|
3622
|
+
const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
|
|
3623
|
+
for (const p of SKIP_PATHS) {
|
|
3624
|
+
if (filepath.includes(p)) return true;
|
|
3625
|
+
}
|
|
3626
|
+
for (const ext of skipExtensions) {
|
|
3627
|
+
if (filepath.endsWith(ext)) return true;
|
|
3628
|
+
}
|
|
3629
|
+
return false;
|
|
3630
|
+
};
|
|
3631
|
+
fileToRoute = (filepath) => {
|
|
3632
|
+
const normalized = filepath.replace(/\\/g, "/");
|
|
3633
|
+
if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
|
|
3634
|
+
return "__global";
|
|
3635
|
+
}
|
|
3636
|
+
const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
|
|
3637
|
+
if (pageMatch) return `/${pageMatch[1]}`;
|
|
3638
|
+
const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
|
|
3639
|
+
if (rootPage) return "/";
|
|
3640
|
+
return null;
|
|
3641
|
+
};
|
|
3642
|
+
getAllRoutes = () => {
|
|
3643
|
+
const native = getNativeBridge();
|
|
3644
|
+
if (!native?.analyzeClasses) {
|
|
3645
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
3646
|
+
}
|
|
3647
|
+
return ["/", "__global"];
|
|
3648
|
+
};
|
|
3649
|
+
getRouteClasses = (_route) => /* @__PURE__ */ new Set();
|
|
3650
|
+
registerFileClasses = (_filepath, _classes) => {
|
|
3651
|
+
};
|
|
3652
|
+
registerGlobalClasses = (_classes) => {
|
|
3653
|
+
};
|
|
3654
|
+
_incrementalEngineInstance = null;
|
|
3655
|
+
getIncrementalEngine = () => {
|
|
3656
|
+
if (!_incrementalEngineInstance) {
|
|
3657
|
+
_incrementalEngineInstance = new IncrementalEngine();
|
|
3658
|
+
}
|
|
3659
|
+
return _incrementalEngineInstance;
|
|
3660
|
+
};
|
|
3661
|
+
resetIncrementalEngine = () => {
|
|
3662
|
+
_incrementalEngineInstance = null;
|
|
3663
|
+
};
|
|
3664
|
+
IncrementalEngine = class {
|
|
3665
|
+
compile(source) {
|
|
3666
|
+
return transformSource(source);
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
getBucketEngine = () => {
|
|
3670
|
+
const native = getNativeBridge();
|
|
3671
|
+
if (!native?.classifyAndSortClasses) {
|
|
3672
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
3673
|
+
}
|
|
3674
|
+
return {
|
|
3675
|
+
add: (className) => className,
|
|
3676
|
+
get: (_bucket) => []
|
|
3677
|
+
};
|
|
3678
|
+
};
|
|
3679
|
+
resetBucketEngine = () => {
|
|
3680
|
+
};
|
|
3681
|
+
classifyNode = (_node) => {
|
|
3682
|
+
const native = getNativeBridge();
|
|
3683
|
+
if (!native?.classifyAndSortClasses) {
|
|
3684
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
3685
|
+
}
|
|
3686
|
+
return "unknown";
|
|
3687
|
+
};
|
|
3688
|
+
detectConflicts = (_classes) => {
|
|
3689
|
+
const native = getNativeBridge();
|
|
3690
|
+
if (!native?.analyzeClassUsage) {
|
|
3691
|
+
throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
|
|
3692
|
+
}
|
|
3693
|
+
return [];
|
|
3694
|
+
};
|
|
3695
|
+
bucketSort = (classes) => {
|
|
3696
|
+
const native = getNativeBridge();
|
|
3697
|
+
if (!native?.classifyAndSortClasses) {
|
|
3698
|
+
throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
|
|
3699
|
+
}
|
|
3700
|
+
const sorted = native.classifyAndSortClasses(classes);
|
|
3701
|
+
return sorted.map((c) => c.raw ?? c);
|
|
3702
|
+
};
|
|
3703
|
+
analyzeFile = (source, filename) => {
|
|
3704
|
+
const native = getNativeBridge();
|
|
3705
|
+
if (!native?.analyzeRsc) {
|
|
3706
|
+
throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
|
|
3707
|
+
}
|
|
3708
|
+
const rsc = native.analyzeRsc(source, filename);
|
|
3709
|
+
return {
|
|
3710
|
+
isServer: rsc?.isServer ?? true,
|
|
3711
|
+
needsClientDirective: rsc?.needsClientDirective ?? false,
|
|
3712
|
+
clientReasons: rsc?.clientReasons ?? [],
|
|
3713
|
+
interactiveClasses: [],
|
|
3714
|
+
canStaticResolveVariants: true
|
|
3715
|
+
};
|
|
3716
|
+
};
|
|
3717
|
+
analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
|
|
3718
|
+
return { resolved: {}, dynamic: [] };
|
|
3719
|
+
};
|
|
3720
|
+
injectClientDirective = (source) => {
|
|
3721
|
+
if (!source.includes('"use client"') && !source.includes("'use client'")) {
|
|
3722
|
+
return '"use client";\n' + source;
|
|
3723
|
+
}
|
|
3724
|
+
return source;
|
|
3725
|
+
};
|
|
3726
|
+
injectServerOnlyComment = (source) => {
|
|
3727
|
+
return `/* @server-only */
|
|
3728
|
+
${source}`;
|
|
3729
|
+
};
|
|
3730
|
+
analyzeClasses = (filesJson, cwd, flags) => {
|
|
3731
|
+
const native = getNativeBridge();
|
|
3732
|
+
if (!native?.analyzeClasses) {
|
|
3733
|
+
throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
|
|
3734
|
+
}
|
|
3735
|
+
return native.analyzeClasses(filesJson, cwd, flags);
|
|
3736
|
+
};
|
|
3737
|
+
extractTwStateConfigs = (source, filename) => {
|
|
3738
|
+
const native = getNativeBridge();
|
|
3739
|
+
if (!native?.extractTwStateConfigs) {
|
|
3740
|
+
throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
|
|
3741
|
+
}
|
|
3742
|
+
return native.extractTwStateConfigs(source, filename);
|
|
3743
|
+
};
|
|
3744
|
+
generateStaticStateCss = (entries, _themeConfig) => {
|
|
3745
|
+
const rules = [];
|
|
3746
|
+
for (const entry of entries) {
|
|
3747
|
+
const stateConfig = JSON.parse(entry.statesJson);
|
|
3748
|
+
for (const [stateName, classes] of Object.entries(stateConfig)) {
|
|
3749
|
+
rules.push({
|
|
3750
|
+
selector: `.${entry.componentName}[data-state="${stateName}"]`,
|
|
3751
|
+
declarations: classes,
|
|
3752
|
+
cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
|
|
3753
|
+
componentName: entry.componentName,
|
|
3754
|
+
stateName
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
return rules;
|
|
3759
|
+
};
|
|
3760
|
+
extractAndGenerateStateCss = (source, filename) => {
|
|
3761
|
+
const entries = extractTwStateConfigs(source, filename);
|
|
3762
|
+
return generateStaticStateCss(entries);
|
|
3763
|
+
};
|
|
1447
3764
|
}
|
|
1448
3765
|
});
|
|
1449
3766
|
|
|
1450
3767
|
// packages/domain/scanner/src/native-bridge.ts
|
|
1451
3768
|
var native_bridge_exports = {};
|
|
1452
3769
|
__export(native_bridge_exports, {
|
|
1453
|
-
batchExtractClassesNative: () =>
|
|
3770
|
+
batchExtractClassesNative: () => batchExtractClassesNative2,
|
|
1454
3771
|
cachePriorityNative: () => cachePriorityNative,
|
|
1455
3772
|
cacheReadNative: () => cacheReadNative,
|
|
1456
3773
|
cacheWriteNative: () => cacheWriteNative,
|
|
@@ -1470,8 +3787,8 @@ __export(native_bridge_exports, {
|
|
|
1470
3787
|
scanCacheInvalidate: () => scanCacheInvalidate,
|
|
1471
3788
|
scanCachePut: () => scanCachePut,
|
|
1472
3789
|
scanCacheStats: () => scanCacheStats,
|
|
1473
|
-
scanFileNative: () =>
|
|
1474
|
-
scanFilesBatchNative: () =>
|
|
3790
|
+
scanFileNative: () => scanFileNative2,
|
|
3791
|
+
scanFilesBatchNative: () => scanFilesBatchNative2,
|
|
1475
3792
|
scanWorkspaceNative: () => scanWorkspaceNative,
|
|
1476
3793
|
startWatchNative: () => startWatchNative,
|
|
1477
3794
|
stopWatchNative: () => stopWatchNative
|
|
@@ -1481,7 +3798,7 @@ function getDirname2() {
|
|
|
1481
3798
|
return __dirname;
|
|
1482
3799
|
}
|
|
1483
3800
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
1484
|
-
return
|
|
3801
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
1485
3802
|
}
|
|
1486
3803
|
return process.cwd();
|
|
1487
3804
|
}
|
|
@@ -1562,7 +3879,7 @@ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHit
|
|
|
1562
3879
|
}
|
|
1563
3880
|
return result;
|
|
1564
3881
|
}
|
|
1565
|
-
function
|
|
3882
|
+
function batchExtractClassesNative2(filePaths) {
|
|
1566
3883
|
const binding = scannerGetBinding();
|
|
1567
3884
|
if (!binding.batchExtractClasses) {
|
|
1568
3885
|
throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
|
|
@@ -1597,7 +3914,7 @@ function scanCacheStats() {
|
|
|
1597
3914
|
}
|
|
1598
3915
|
return binding.scanCacheStats();
|
|
1599
3916
|
}
|
|
1600
|
-
function
|
|
3917
|
+
function scanFileNative2(filePath) {
|
|
1601
3918
|
const binding = scannerGetBinding();
|
|
1602
3919
|
if (!binding.scanFile) {
|
|
1603
3920
|
throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
|
|
@@ -1609,7 +3926,7 @@ function collectFilesNative(root, extensions, ignoreDirs) {
|
|
|
1609
3926
|
if (!binding.collectFiles) return null;
|
|
1610
3927
|
return binding.collectFiles(root, extensions, ignoreDirs);
|
|
1611
3928
|
}
|
|
1612
|
-
function
|
|
3929
|
+
function scanFilesBatchNative2(filePaths) {
|
|
1613
3930
|
const binding = scannerGetBinding();
|
|
1614
3931
|
if (!binding.scanFilesBatch) {
|
|
1615
3932
|
return filePaths.map((fp) => {
|
|
@@ -1770,12 +4087,12 @@ var init_native_bridge = __esm({
|
|
|
1770
4087
|
}
|
|
1771
4088
|
});
|
|
1772
4089
|
function defaultCachePath(rootDir, cacheDir) {
|
|
1773
|
-
const dir = cacheDir ?
|
|
1774
|
-
return
|
|
4090
|
+
const dir = cacheDir ? path9__default.resolve(rootDir, cacheDir) : path9__default.join(process.cwd(), ".cache", "tailwind-styled");
|
|
4091
|
+
return path9__default.join(dir, "scanner-cache.json");
|
|
1775
4092
|
}
|
|
1776
4093
|
function readCache(rootDir, cacheDir) {
|
|
1777
4094
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1778
|
-
|
|
4095
|
+
fs13__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
|
|
1779
4096
|
const result = cacheReadNative(cachePath);
|
|
1780
4097
|
if (!result) return [];
|
|
1781
4098
|
return result.entries.map((e) => ({
|
|
@@ -1790,7 +4107,7 @@ function readCache(rootDir, cacheDir) {
|
|
|
1790
4107
|
}
|
|
1791
4108
|
function writeCache(rootDir, entries, cacheDir) {
|
|
1792
4109
|
const cachePath = defaultCachePath(rootDir, cacheDir);
|
|
1793
|
-
|
|
4110
|
+
fs13__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
|
|
1794
4111
|
const success = cacheWriteNative(cachePath, entries);
|
|
1795
4112
|
if (!success) {
|
|
1796
4113
|
throw new Error(
|
|
@@ -1814,30 +4131,10 @@ var init_cache_native = __esm({
|
|
|
1814
4131
|
init_native_bridge();
|
|
1815
4132
|
}
|
|
1816
4133
|
});
|
|
1817
|
-
function
|
|
4134
|
+
function collectFiles2(rootDir, extensions, ignoreDirs) {
|
|
1818
4135
|
const native = collectFilesNative(rootDir, extensions, ignoreDirs);
|
|
1819
4136
|
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;
|
|
4137
|
+
throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
|
|
1841
4138
|
}
|
|
1842
4139
|
function mergeResults(batchResults) {
|
|
1843
4140
|
const files = batchResults.map((r) => ({
|
|
@@ -1847,8 +4144,7 @@ function mergeResults(batchResults) {
|
|
|
1847
4144
|
}));
|
|
1848
4145
|
const native = rebuildWorkspaceResultNative(files);
|
|
1849
4146
|
if (native) return native;
|
|
1850
|
-
|
|
1851
|
-
return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
|
|
4147
|
+
throw new Error("FATAL: Native binding 'rebuildWorkspaceResult' is required but not available.");
|
|
1852
4148
|
}
|
|
1853
4149
|
function runChunkInWorker(filePaths) {
|
|
1854
4150
|
return new Promise((resolve2, reject) => {
|
|
@@ -1875,9 +4171,9 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1875
4171
|
maxWorkers = Math.max(1, availableParallelism() - 1),
|
|
1876
4172
|
chunkSize = DEFAULT_CHUNK_SIZE
|
|
1877
4173
|
} = options;
|
|
1878
|
-
const files =
|
|
4174
|
+
const files = collectFiles2(path9__default.resolve(rootDir), extensions, ignoreDirs);
|
|
1879
4175
|
if (files.length < PARALLEL_THRESHOLD) {
|
|
1880
|
-
return mergeResults(
|
|
4176
|
+
return mergeResults(batchExtractClassesNative2(files));
|
|
1881
4177
|
}
|
|
1882
4178
|
const chunks = [];
|
|
1883
4179
|
for (let i = 0; i < files.length; i += chunkSize) {
|
|
@@ -1894,14 +4190,14 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
|
|
|
1894
4190
|
var PARALLEL_THRESHOLD, DEFAULT_CHUNK_SIZE, _workerFilename;
|
|
1895
4191
|
var init_parallel_scanner = __esm({
|
|
1896
4192
|
"packages/domain/scanner/src/parallel-scanner.ts"() {
|
|
1897
|
-
|
|
4193
|
+
init_src3();
|
|
1898
4194
|
init_native_bridge();
|
|
1899
4195
|
PARALLEL_THRESHOLD = 50;
|
|
1900
4196
|
DEFAULT_CHUNK_SIZE = 150;
|
|
1901
4197
|
if (!isMainThread && parentPort) {
|
|
1902
4198
|
const { filePaths } = workerData;
|
|
1903
4199
|
try {
|
|
1904
|
-
const results =
|
|
4200
|
+
const results = batchExtractClassesNative2(filePaths);
|
|
1905
4201
|
const msg = { ok: true, results };
|
|
1906
4202
|
parentPort.postMessage(msg);
|
|
1907
4203
|
} catch (error) {
|
|
@@ -1919,12 +4215,12 @@ var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, S
|
|
|
1919
4215
|
var init_schemas = __esm({
|
|
1920
4216
|
"packages/domain/scanner/src/schemas.ts"() {
|
|
1921
4217
|
init_src();
|
|
1922
|
-
formatIssuePath2 = (
|
|
4218
|
+
formatIssuePath2 = (path16) => path16.length > 0 ? path16.map(
|
|
1923
4219
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1924
4220
|
).join(".") : "<root>";
|
|
1925
4221
|
formatIssues = (error) => error.issues.map((issue) => {
|
|
1926
|
-
const
|
|
1927
|
-
return `${
|
|
4222
|
+
const path16 = formatIssuePath2(issue.path);
|
|
4223
|
+
return `${path16}: ${issue.message}`;
|
|
1928
4224
|
}).join("; ");
|
|
1929
4225
|
parseWithSchema = (schema, data, label) => {
|
|
1930
4226
|
const parsed = schema.safeParse(data);
|
|
@@ -1985,15 +4281,15 @@ var src_exports2 = {};
|
|
|
1985
4281
|
__export(src_exports2, {
|
|
1986
4282
|
DEFAULT_EXTENSIONS: () => DEFAULT_EXTENSIONS,
|
|
1987
4283
|
DEFAULT_IGNORES: () => DEFAULT_IGNORES,
|
|
1988
|
-
batchExtractClassesNative: () =>
|
|
4284
|
+
batchExtractClassesNative: () => batchExtractClassesNative2,
|
|
1989
4285
|
extractClassesNative: () => extractClassesNative,
|
|
1990
|
-
isScannableFile: () =>
|
|
4286
|
+
isScannableFile: () => isScannableFile2,
|
|
1991
4287
|
parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
|
|
1992
4288
|
parseScanWorkspaceResult: () => parseScanWorkspaceResult,
|
|
1993
4289
|
parseScannerWorkerMessage: () => parseScannerWorkerMessage,
|
|
1994
|
-
scanFile: () =>
|
|
4290
|
+
scanFile: () => scanFile2,
|
|
1995
4291
|
scanSource: () => scanSource,
|
|
1996
|
-
scanWorkspace: () =>
|
|
4292
|
+
scanWorkspace: () => scanWorkspace2,
|
|
1997
4293
|
scanWorkspaceAsync: () => scanWorkspaceAsync
|
|
1998
4294
|
});
|
|
1999
4295
|
function getRuntimeDir() {
|
|
@@ -2001,7 +4297,7 @@ function getRuntimeDir() {
|
|
|
2001
4297
|
return __dirname;
|
|
2002
4298
|
}
|
|
2003
4299
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
2004
|
-
return
|
|
4300
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
2005
4301
|
}
|
|
2006
4302
|
return process.cwd();
|
|
2007
4303
|
}
|
|
@@ -2011,17 +4307,17 @@ function resolveScannerWorkerModulePath() {
|
|
|
2011
4307
|
return __dirname;
|
|
2012
4308
|
}
|
|
2013
4309
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
2014
|
-
return
|
|
4310
|
+
return path9__default.dirname(fileURLToPath(import.meta.url));
|
|
2015
4311
|
}
|
|
2016
4312
|
return process.cwd();
|
|
2017
4313
|
})();
|
|
2018
4314
|
const candidates = [
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
4315
|
+
path9__default.resolve(runtimeDir, "worker.cjs"),
|
|
4316
|
+
path9__default.resolve(runtimeDir, "worker.js"),
|
|
4317
|
+
path9__default.resolve(runtimeDir, "worker.ts")
|
|
2022
4318
|
];
|
|
2023
4319
|
for (const candidate of candidates) {
|
|
2024
|
-
if (
|
|
4320
|
+
if (fs13__default.existsSync(candidate)) return candidate;
|
|
2025
4321
|
}
|
|
2026
4322
|
return null;
|
|
2027
4323
|
}
|
|
@@ -2078,19 +4374,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
|
|
|
2078
4374
|
if (!currentDir) continue;
|
|
2079
4375
|
const entries = (() => {
|
|
2080
4376
|
try {
|
|
2081
|
-
return
|
|
4377
|
+
return fs13__default.readdirSync(currentDir, { withFileTypes: true });
|
|
2082
4378
|
} catch {
|
|
2083
4379
|
return [];
|
|
2084
4380
|
}
|
|
2085
4381
|
})();
|
|
2086
4382
|
for (const entry of entries) {
|
|
2087
|
-
const fullPath =
|
|
4383
|
+
const fullPath = path9__default.join(currentDir, entry.name);
|
|
2088
4384
|
if (entry.isDirectory()) {
|
|
2089
4385
|
if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
|
|
2090
4386
|
continue;
|
|
2091
4387
|
}
|
|
2092
4388
|
if (!entry.isFile()) continue;
|
|
2093
|
-
if (!extensionSet.has(
|
|
4389
|
+
if (!extensionSet.has(path9__default.extname(entry.name))) continue;
|
|
2094
4390
|
candidates.push(fullPath);
|
|
2095
4391
|
}
|
|
2096
4392
|
}
|
|
@@ -2116,12 +4412,12 @@ function scanSource(source) {
|
|
|
2116
4412
|
"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
4413
|
);
|
|
2118
4414
|
}
|
|
2119
|
-
function
|
|
2120
|
-
return includeExtensions.includes(
|
|
4415
|
+
function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
|
|
4416
|
+
return includeExtensions.includes(path9__default.extname(filePath));
|
|
2121
4417
|
}
|
|
2122
|
-
function
|
|
2123
|
-
const { scanFileNative:
|
|
2124
|
-
const result =
|
|
4418
|
+
function scanFile2(filePath) {
|
|
4419
|
+
const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
|
|
4420
|
+
const result = scanFileNative3(filePath);
|
|
2125
4421
|
if (!result.ok) {
|
|
2126
4422
|
throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
|
|
2127
4423
|
}
|
|
@@ -2131,7 +4427,7 @@ function scanFile(filePath) {
|
|
|
2131
4427
|
...result.hash ? { hash: result.hash } : {}
|
|
2132
4428
|
};
|
|
2133
4429
|
}
|
|
2134
|
-
function
|
|
4430
|
+
function scanWorkspace2(rootDir, options = {}) {
|
|
2135
4431
|
const normalizedOptions = parseScanWorkspaceOptions(options);
|
|
2136
4432
|
const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
|
|
2137
4433
|
const extensionSet = buildExtensionSet(includeExtensions);
|
|
@@ -2177,7 +4473,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2177
4473
|
for (const filePath of candidates) {
|
|
2178
4474
|
const stat = (() => {
|
|
2179
4475
|
try {
|
|
2180
|
-
return
|
|
4476
|
+
return fs13__default.statSync(filePath);
|
|
2181
4477
|
} catch {
|
|
2182
4478
|
return null;
|
|
2183
4479
|
}
|
|
@@ -2203,7 +4499,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2203
4499
|
for (const { filePath, stat, size, cached } of ranked) {
|
|
2204
4500
|
const content = (() => {
|
|
2205
4501
|
try {
|
|
2206
|
-
return
|
|
4502
|
+
return fs13__default.readFileSync(filePath, "utf8");
|
|
2207
4503
|
} catch {
|
|
2208
4504
|
return null;
|
|
2209
4505
|
}
|
|
@@ -2254,7 +4550,7 @@ function scanWorkspace(rootDir, options = {}) {
|
|
|
2254
4550
|
}
|
|
2255
4551
|
} else {
|
|
2256
4552
|
for (const filePath of candidates) {
|
|
2257
|
-
processResult(
|
|
4553
|
+
processResult(scanFile2(filePath));
|
|
2258
4554
|
}
|
|
2259
4555
|
}
|
|
2260
4556
|
return parseScanWorkspaceResult({
|
|
@@ -2281,11 +4577,11 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
|
|
|
2281
4577
|
log3.debug(
|
|
2282
4578
|
`worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
|
|
2283
4579
|
);
|
|
2284
|
-
return
|
|
4580
|
+
return scanWorkspace2(rootDir, normalizedOptions);
|
|
2285
4581
|
}
|
|
2286
4582
|
}
|
|
2287
4583
|
var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
|
|
2288
|
-
var
|
|
4584
|
+
var init_src3 = __esm({
|
|
2289
4585
|
"packages/domain/scanner/src/index.ts"() {
|
|
2290
4586
|
init_src();
|
|
2291
4587
|
init_cache_native();
|
|
@@ -2294,7 +4590,7 @@ var init_src2 = __esm({
|
|
|
2294
4590
|
init_schemas();
|
|
2295
4591
|
init_schemas();
|
|
2296
4592
|
init_native_bridge();
|
|
2297
|
-
log3 =
|
|
4593
|
+
log3 = createLogger2("scanner");
|
|
2298
4594
|
SCAN_WORKER_TIMEOUT_MS = 12e4;
|
|
2299
4595
|
createNativeParserLoader = () => {
|
|
2300
4596
|
const _state = {
|
|
@@ -2307,7 +4603,7 @@ var init_src2 = __esm({
|
|
|
2307
4603
|
const loadNativeParserBinding = () => {
|
|
2308
4604
|
if (_state.binding !== void 0) return _state.binding;
|
|
2309
4605
|
const runtimeDir = getRuntimeDir();
|
|
2310
|
-
const req = createRequire(
|
|
4606
|
+
const req = createRequire(path9__default.join(runtimeDir, "noop.cjs"));
|
|
2311
4607
|
const _platform = process.platform;
|
|
2312
4608
|
const _arch = process.arch;
|
|
2313
4609
|
const _platformArch = `${_platform}-${_arch}`;
|
|
@@ -2315,27 +4611,27 @@ var init_src2 = __esm({
|
|
|
2315
4611
|
const candidates = [
|
|
2316
4612
|
// ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
|
|
2317
4613
|
// cwd = repo root saat run dari root, atau package dir saat workspaces
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
4614
|
+
path9__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
|
|
4615
|
+
path9__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
4616
|
+
path9__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2321
4617
|
// runtimeDir = dist/ → naik 1 level ke package root (npm install case)
|
|
2322
4618
|
// e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
4619
|
+
path9__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
|
|
4620
|
+
path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
|
|
4621
|
+
path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2326
4622
|
// runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
|
|
2327
|
-
|
|
2328
|
-
|
|
4623
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4624
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2329
4625
|
// 3 level fallback (jika package di-nest lebih dangkal)
|
|
2330
|
-
|
|
2331
|
-
|
|
4626
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
|
|
4627
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
|
|
2332
4628
|
// ── binaryName lama: tailwind_styled_parser (backward compat) ──
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
4629
|
+
path9__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
|
|
4630
|
+
path9__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
|
|
4631
|
+
path9__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
|
|
4632
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
4633
|
+
path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
4634
|
+
path9__default.resolve(
|
|
2339
4635
|
runtimeDir,
|
|
2340
4636
|
"..",
|
|
2341
4637
|
"..",
|
|
@@ -2347,7 +4643,7 @@ var init_src2 = __esm({
|
|
|
2347
4643
|
)
|
|
2348
4644
|
];
|
|
2349
4645
|
for (const fullPath of candidates) {
|
|
2350
|
-
if (!
|
|
4646
|
+
if (!fs13__default.existsSync(fullPath)) continue;
|
|
2351
4647
|
try {
|
|
2352
4648
|
const required = req(fullPath);
|
|
2353
4649
|
if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
|
|
@@ -2472,48 +4768,11 @@ var init_native_bridge2 = __esm({
|
|
|
2472
4768
|
}
|
|
2473
4769
|
});
|
|
2474
4770
|
|
|
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
|
-
};
|
|
4771
|
+
// packages/presentation/vite/src/plugin.ts
|
|
4772
|
+
init_src2();
|
|
2514
4773
|
|
|
2515
4774
|
// packages/domain/analyzer/src/analyzeWorkspace.ts
|
|
2516
|
-
|
|
4775
|
+
init_src3();
|
|
2517
4776
|
|
|
2518
4777
|
// packages/domain/analyzer/src/binding.ts
|
|
2519
4778
|
init_src();
|
|
@@ -2533,7 +4792,7 @@ function isRecord(value) {
|
|
|
2533
4792
|
}
|
|
2534
4793
|
async function pathExists(filePath) {
|
|
2535
4794
|
try {
|
|
2536
|
-
await
|
|
4795
|
+
await fs13__default.promises.access(filePath, fs13__default.constants.F_OK);
|
|
2537
4796
|
return true;
|
|
2538
4797
|
} catch {
|
|
2539
4798
|
return false;
|
|
@@ -2632,7 +4891,7 @@ async function requireNativeBinding() {
|
|
|
2632
4891
|
|
|
2633
4892
|
// packages/domain/analyzer/src/schemas.ts
|
|
2634
4893
|
init_src();
|
|
2635
|
-
var formatIssuePath3 = (
|
|
4894
|
+
var formatIssuePath3 = (path16) => path16.length > 0 ? path16.map(
|
|
2636
4895
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
2637
4896
|
).join(".") : "<root>";
|
|
2638
4897
|
var isPlainObject = (value) => {
|
|
@@ -2641,8 +4900,8 @@ var isPlainObject = (value) => {
|
|
|
2641
4900
|
return proto === Object.prototype || proto === null;
|
|
2642
4901
|
};
|
|
2643
4902
|
var formatIssues2 = (error) => error.issues.map((issue) => {
|
|
2644
|
-
const
|
|
2645
|
-
return `${
|
|
4903
|
+
const path16 = formatIssuePath3(issue.path);
|
|
4904
|
+
return `${path16}: ${issue.message}`;
|
|
2646
4905
|
}).join("; ");
|
|
2647
4906
|
var parseWithSchema2 = (schema, data, label) => {
|
|
2648
4907
|
const parsed = schema.safeParse(data);
|
|
@@ -2732,7 +4991,7 @@ var parseAnalyzerOptions = (options) => parseWithSchema2(AnalyzerOptionsSchema,
|
|
|
2732
4991
|
var parseNativeReport = (report) => parseWithSchema2(NativeReportSchema, report, "Native analyzer report is invalid");
|
|
2733
4992
|
var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
|
|
2734
4993
|
var tailwindConfigCache = /* @__PURE__ */ new Map();
|
|
2735
|
-
var
|
|
4994
|
+
var detectConflicts2 = async (usages) => {
|
|
2736
4995
|
const native = await getNativeBinding();
|
|
2737
4996
|
if (!native?.detectClassConflicts) {
|
|
2738
4997
|
throw new Error("FATAL: Native binding 'detectClassConflicts' is required but not available.");
|
|
@@ -2749,11 +5008,11 @@ var detectConflicts = async (usages) => {
|
|
|
2749
5008
|
};
|
|
2750
5009
|
};
|
|
2751
5010
|
var isSupportedTailwindConfigPath = (configPath) => {
|
|
2752
|
-
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(
|
|
5011
|
+
return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path9__default.extname(configPath).toLowerCase());
|
|
2753
5012
|
};
|
|
2754
5013
|
var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
2755
5014
|
if (explicitPath) {
|
|
2756
|
-
const resolved =
|
|
5015
|
+
const resolved = path9__default.resolve(root, explicitPath);
|
|
2757
5016
|
if (!await pathExists(resolved)) return null;
|
|
2758
5017
|
return resolved;
|
|
2759
5018
|
}
|
|
@@ -2764,7 +5023,7 @@ var resolveTailwindConfigPath = async (root, explicitPath) => {
|
|
|
2764
5023
|
"tailwind.config.mjs"
|
|
2765
5024
|
];
|
|
2766
5025
|
for (const candidate of candidates) {
|
|
2767
|
-
const fullPath =
|
|
5026
|
+
const fullPath = path9__default.resolve(root, candidate);
|
|
2768
5027
|
if (await pathExists(fullPath)) return fullPath;
|
|
2769
5028
|
}
|
|
2770
5029
|
return null;
|
|
@@ -2818,8 +5077,8 @@ var collectCustomUtilities = (config) => {
|
|
|
2818
5077
|
return out;
|
|
2819
5078
|
};
|
|
2820
5079
|
var collectSafelistFromSource = async (configPath) => {
|
|
2821
|
-
const source = await
|
|
2822
|
-
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (
|
|
5080
|
+
const source = await fs13__default.promises.readFile(configPath, "utf8");
|
|
5081
|
+
const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src3(), src_exports2));
|
|
2823
5082
|
const allTokens = extractClassesNative2(source);
|
|
2824
5083
|
const hasSafelist = source.includes("safelist");
|
|
2825
5084
|
if (!hasSafelist) return [];
|
|
@@ -2832,7 +5091,7 @@ var collectSafelistFromSource = async (configPath) => {
|
|
|
2832
5091
|
}
|
|
2833
5092
|
return allTokens.filter((t) => safelistSet.has(t));
|
|
2834
5093
|
};
|
|
2835
|
-
var
|
|
5094
|
+
var loadTailwindConfig2 = async (root, semanticOption) => {
|
|
2836
5095
|
const startMs = Date.now();
|
|
2837
5096
|
const configPath = await resolveTailwindConfigPath(root, semanticOption?.tailwindConfigPath);
|
|
2838
5097
|
if (!configPath) return null;
|
|
@@ -2845,7 +5104,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2845
5104
|
customUtilities: /* @__PURE__ */ new Set()
|
|
2846
5105
|
};
|
|
2847
5106
|
}
|
|
2848
|
-
const configStat = await
|
|
5107
|
+
const configStat = await fs13__default.promises.stat(configPath).catch(() => null);
|
|
2849
5108
|
if (configStat) {
|
|
2850
5109
|
const cached = tailwindConfigCache.get(configPath);
|
|
2851
5110
|
if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
|
|
@@ -2913,7 +5172,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
|
|
|
2913
5172
|
return loaded;
|
|
2914
5173
|
};
|
|
2915
5174
|
var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
2916
|
-
const loadedConfig = await
|
|
5175
|
+
const loadedConfig = await loadTailwindConfig2(root, semanticOption);
|
|
2917
5176
|
const safelist = loadedConfig?.safelist ?? /* @__PURE__ */ new Set();
|
|
2918
5177
|
const customUtilities = loadedConfig?.customUtilities ?? /* @__PURE__ */ new Set();
|
|
2919
5178
|
const usageNames = new Set(usages.map((usage) => usage.name));
|
|
@@ -2932,7 +5191,7 @@ var buildSemanticReport = async (usages, root, semanticOption) => {
|
|
|
2932
5191
|
results.filter((r) => !r.isKnown).map((r) => r.className)
|
|
2933
5192
|
);
|
|
2934
5193
|
const unknownClasses = usages.filter((usage) => unknownSet.has(usage.name)).map((usage) => ({ ...usage, isUnused: true }));
|
|
2935
|
-
const { conflicts } = await
|
|
5194
|
+
const { conflicts } = await detectConflicts2(usages);
|
|
2936
5195
|
return {
|
|
2937
5196
|
unusedClasses,
|
|
2938
5197
|
unknownClasses,
|
|
@@ -3004,7 +5263,7 @@ async function buildDistribution(usages, native) {
|
|
|
3004
5263
|
}
|
|
3005
5264
|
async function analyzeWorkspace(root, options = {}) {
|
|
3006
5265
|
const startedAtMs = Date.now();
|
|
3007
|
-
const resolvedRoot =
|
|
5266
|
+
const resolvedRoot = path9__default.resolve(root);
|
|
3008
5267
|
const normalizedOptions = parseAnalyzerOptions(options);
|
|
3009
5268
|
const scan = await (async () => {
|
|
3010
5269
|
const scanStartedAtMs = Date.now();
|
|
@@ -3107,16 +5366,17 @@ async function analyzeWorkspace(root, options = {}) {
|
|
|
3107
5366
|
}
|
|
3108
5367
|
|
|
3109
5368
|
// packages/domain/engine/src/index.ts
|
|
3110
|
-
|
|
5369
|
+
init_internal();
|
|
5370
|
+
init_src3();
|
|
3111
5371
|
init_src();
|
|
3112
5372
|
|
|
3113
5373
|
// packages/domain/engine/src/incremental.ts
|
|
3114
|
-
|
|
5374
|
+
init_src3();
|
|
3115
5375
|
init_src();
|
|
3116
5376
|
init_native_bridge2();
|
|
3117
5377
|
var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
3118
|
-
var log5 =
|
|
3119
|
-
function
|
|
5378
|
+
var log5 = createLogger2("engine:incremental");
|
|
5379
|
+
function rebuildWorkspaceResult2(byFile) {
|
|
3120
5380
|
const files = Array.from(byFile.values());
|
|
3121
5381
|
const native = getNativeEngineBinding();
|
|
3122
5382
|
if (native?.rebuildWorkspaceResult) {
|
|
@@ -3145,9 +5405,9 @@ function areClassSetsEqual(a, b) {
|
|
|
3145
5405
|
}
|
|
3146
5406
|
function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
3147
5407
|
const includeExtensions = scanner?.includeExtensions ?? DEFAULT_EXTENSIONS2;
|
|
3148
|
-
if (!
|
|
3149
|
-
const byFile = new Map(previous.files.map((f) => [
|
|
3150
|
-
const normalizedPath =
|
|
5408
|
+
if (!isScannableFile2(filePath, includeExtensions)) return previous;
|
|
5409
|
+
const byFile = new Map(previous.files.map((f) => [path9__default.resolve(f.file), f]));
|
|
5410
|
+
const normalizedPath = path9__default.resolve(filePath);
|
|
3151
5411
|
const native = getNativeEngineBinding();
|
|
3152
5412
|
if (!native?.processFileChange) {
|
|
3153
5413
|
throw new Error(
|
|
@@ -3159,11 +5419,11 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3159
5419
|
log5.debug(`native unlink ${normalizedPath}`);
|
|
3160
5420
|
native.processFileChange(normalizedPath, existing2?.classes ?? [], null);
|
|
3161
5421
|
byFile.delete(normalizedPath);
|
|
3162
|
-
return
|
|
5422
|
+
return rebuildWorkspaceResult2(byFile);
|
|
3163
5423
|
}
|
|
3164
5424
|
log5.debug(`native change ${normalizedPath}`);
|
|
3165
|
-
const scanned =
|
|
3166
|
-
const content =
|
|
5425
|
+
const scanned = scanFile2(normalizedPath);
|
|
5426
|
+
const content = fs13__default.readFileSync(normalizedPath, "utf8");
|
|
3167
5427
|
const diff = native.processFileChange(normalizedPath, scanned.classes, content);
|
|
3168
5428
|
const existing = byFile.get(normalizedPath);
|
|
3169
5429
|
if (diff && existing) {
|
|
@@ -3175,7 +5435,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
|
|
|
3175
5435
|
log5.debug(`native diff cold-sync ${normalizedPath}`);
|
|
3176
5436
|
byFile.set(normalizedPath, { file: normalizedPath, classes: scanned.classes });
|
|
3177
5437
|
}
|
|
3178
|
-
return
|
|
5438
|
+
return rebuildWorkspaceResult2(byFile);
|
|
3179
5439
|
}
|
|
3180
5440
|
|
|
3181
5441
|
// packages/domain/engine/src/metrics.ts
|
|
@@ -3232,8 +5492,8 @@ var METRICS_FILE_NAME = "metrics.json";
|
|
|
3232
5492
|
var CACHE_DIR = ".tw-cache";
|
|
3233
5493
|
function writeMetrics(metrics, cwd = process.cwd()) {
|
|
3234
5494
|
try {
|
|
3235
|
-
const cacheDir =
|
|
3236
|
-
|
|
5495
|
+
const cacheDir = path9__default.join(cwd, CACHE_DIR);
|
|
5496
|
+
fs13__default.mkdirSync(cacheDir, { recursive: true });
|
|
3237
5497
|
const mem = process.memoryUsage();
|
|
3238
5498
|
const data = {
|
|
3239
5499
|
...metrics,
|
|
@@ -3244,7 +5504,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
|
|
|
3244
5504
|
},
|
|
3245
5505
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3246
5506
|
};
|
|
3247
|
-
|
|
5507
|
+
fs13__default.writeFileSync(path9__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
|
|
3248
5508
|
} catch {
|
|
3249
5509
|
}
|
|
3250
5510
|
}
|
|
@@ -3351,19 +5611,19 @@ var parseEngineOptions = (options) => parseWithSchema3(EngineOptionsSchema, opti
|
|
|
3351
5611
|
var parseEngineWatchOptions = (options) => parseWithSchema3(EngineWatchOptionsSchema, options ?? {}, "engine watch options are invalid");
|
|
3352
5612
|
|
|
3353
5613
|
// packages/domain/engine/src/watch.ts
|
|
3354
|
-
var
|
|
5614
|
+
var _native2 = null;
|
|
3355
5615
|
function getNativeWatcher() {
|
|
3356
|
-
if (
|
|
5616
|
+
if (_native2 !== null) return _native2;
|
|
3357
5617
|
try {
|
|
3358
5618
|
const { resolveNativeBinary: resolveNativeBinary2 } = (init_src(), __toCommonJS(src_exports));
|
|
3359
5619
|
const { path: binPath } = resolveNativeBinary2(__dirname);
|
|
3360
5620
|
if (binPath) {
|
|
3361
|
-
|
|
5621
|
+
_native2 = __require(binPath);
|
|
3362
5622
|
}
|
|
3363
5623
|
} catch {
|
|
3364
|
-
|
|
5624
|
+
_native2 = {};
|
|
3365
5625
|
}
|
|
3366
|
-
return
|
|
5626
|
+
return _native2;
|
|
3367
5627
|
}
|
|
3368
5628
|
function watchWorkspaceNative(rootDir, onEvent, options) {
|
|
3369
5629
|
const native = getNativeWatcher();
|
|
@@ -3440,11 +5700,11 @@ var configState = {
|
|
|
3440
5700
|
return this.tailwindConfigLoaded;
|
|
3441
5701
|
}
|
|
3442
5702
|
};
|
|
3443
|
-
var log6 =
|
|
5703
|
+
var log6 = createLogger2("engine");
|
|
3444
5704
|
async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
|
|
3445
5705
|
if (!tailwindConfigPath) return void 0;
|
|
3446
|
-
const configPath =
|
|
3447
|
-
if (!
|
|
5706
|
+
const configPath = path9__default.resolve(root, tailwindConfigPath);
|
|
5707
|
+
if (!fs13__default.existsSync(configPath)) {
|
|
3448
5708
|
throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
|
|
3449
5709
|
}
|
|
3450
5710
|
const imported = await import(pathToFileURL(configPath).href);
|
|
@@ -3510,13 +5770,14 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
|
|
|
3510
5770
|
};
|
|
3511
5771
|
}
|
|
3512
5772
|
function countWorkspacePackages(root) {
|
|
3513
|
-
const packagesDir =
|
|
3514
|
-
if (!
|
|
5773
|
+
const packagesDir = path9__default.join(root, "packages");
|
|
5774
|
+
if (!fs13__default.existsSync(packagesDir)) return 0;
|
|
3515
5775
|
try {
|
|
3516
|
-
return
|
|
3517
|
-
(entry) => entry.isDirectory() &&
|
|
5776
|
+
return fs13__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
|
|
5777
|
+
(entry) => entry.isDirectory() && fs13__default.existsSync(path9__default.join(packagesDir, entry.name, "package.json"))
|
|
3518
5778
|
).length;
|
|
3519
|
-
} catch {
|
|
5779
|
+
} catch (err) {
|
|
5780
|
+
log6.debug(`countWorkspacePackages: ${err instanceof Error ? err.message : String(err)}`);
|
|
3520
5781
|
return 0;
|
|
3521
5782
|
}
|
|
3522
5783
|
}
|
|
@@ -3550,7 +5811,7 @@ function writeDashboardMetrics(root, mode, result, metrics) {
|
|
|
3550
5811
|
async function createEngine(rawOptions = {}) {
|
|
3551
5812
|
const options = parseEngineOptions(rawOptions);
|
|
3552
5813
|
const root = options.root ?? process.cwd();
|
|
3553
|
-
const resolvedRoot =
|
|
5814
|
+
const resolvedRoot = path9__default.resolve(root);
|
|
3554
5815
|
const plugins = rawOptions.plugins ?? [];
|
|
3555
5816
|
const getTailwindConfig = async () => {
|
|
3556
5817
|
if (configState.isLoaded()) return configState.getConfig();
|
|
@@ -3697,12 +5958,13 @@ async function createEngine(rawOptions = {}) {
|
|
|
3697
5958
|
const shouldForceFullRescan = (event) => {
|
|
3698
5959
|
if (event.type === "unlink") return false;
|
|
3699
5960
|
try {
|
|
3700
|
-
const stat =
|
|
5961
|
+
const stat = fs13__default.statSync(event.filePath);
|
|
3701
5962
|
if (stat.size > largeFileThreshold) {
|
|
3702
5963
|
metrics.markSkippedLargeFile();
|
|
3703
5964
|
return true;
|
|
3704
5965
|
}
|
|
3705
|
-
} catch {
|
|
5966
|
+
} catch (statErr) {
|
|
5967
|
+
log6.debug(`stat failed for ${event.filePath}: ${statErr instanceof Error ? statErr.message : String(statErr)}`);
|
|
3706
5968
|
return false;
|
|
3707
5969
|
}
|
|
3708
5970
|
return false;
|
|
@@ -3816,7 +6078,7 @@ async function createEngine(rawOptions = {}) {
|
|
|
3816
6078
|
|
|
3817
6079
|
// packages/presentation/vite/src/schemas.ts
|
|
3818
6080
|
init_src();
|
|
3819
|
-
var formatIssuePath4 = (
|
|
6081
|
+
var formatIssuePath4 = (path16) => path16.length > 0 ? path16.map(
|
|
3820
6082
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
3821
6083
|
).join(".") : "<root>";
|
|
3822
6084
|
var formatIssues4 = (error) => error.issues.map((issue) => {
|
|
@@ -3862,14 +6124,14 @@ function warnDeprecated(options, key, message) {
|
|
|
3862
6124
|
}
|
|
3863
6125
|
}
|
|
3864
6126
|
function isInsideDirectory(filePath, directory) {
|
|
3865
|
-
const relative =
|
|
3866
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
6127
|
+
const relative = path9__default.relative(directory, filePath);
|
|
6128
|
+
return relative === "" || !relative.startsWith("..") && !path9__default.isAbsolute(relative);
|
|
3867
6129
|
}
|
|
3868
6130
|
function filterScanToDirs(scan, root, scanDirs) {
|
|
3869
|
-
const resolvedDirs = scanDirs.map((dir) =>
|
|
6131
|
+
const resolvedDirs = scanDirs.map((dir) => path9__default.resolve(root, dir));
|
|
3870
6132
|
if (resolvedDirs.length === 0) return scan;
|
|
3871
6133
|
const files = scan.files.filter((file) => {
|
|
3872
|
-
const absoluteFile =
|
|
6134
|
+
const absoluteFile = path9__default.resolve(file.file);
|
|
3873
6135
|
return resolvedDirs.some((directory) => isInsideDirectory(absoluteFile, directory));
|
|
3874
6136
|
});
|
|
3875
6137
|
const uniqueClasses = Array.from(new Set(files.flatMap((file) => file.classes))).sort();
|
|
@@ -3880,9 +6142,9 @@ function filterScanToDirs(scan, root, scanDirs) {
|
|
|
3880
6142
|
};
|
|
3881
6143
|
}
|
|
3882
6144
|
function writeJsonArtifact(root, relativePath, value) {
|
|
3883
|
-
const outputPath =
|
|
3884
|
-
|
|
3885
|
-
|
|
6145
|
+
const outputPath = path9__default.resolve(root, relativePath);
|
|
6146
|
+
fs13__default.mkdirSync(path9__default.dirname(outputPath), { recursive: true });
|
|
6147
|
+
fs13__default.writeFileSync(outputPath, `${JSON.stringify(value, null, 2)}
|
|
3886
6148
|
`);
|
|
3887
6149
|
}
|
|
3888
6150
|
function tailwindStyledPlugin(opts = {}) {
|
|
@@ -3909,12 +6171,77 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3909
6171
|
const transformRunner = rawOptions.__internalTransformRunner ?? runLoaderTransform;
|
|
3910
6172
|
const engineFactory = rawOptions.__internalCreateEngine ?? createEngine;
|
|
3911
6173
|
const pluginState = { root: process.cwd(), isDev: true };
|
|
6174
|
+
const staticCssPerFile = /* @__PURE__ */ new Map();
|
|
6175
|
+
function deduplicateStaticCss(css) {
|
|
6176
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6177
|
+
const rules = [];
|
|
6178
|
+
for (const chunk of css.split(/(?<=\})\s*/)) {
|
|
6179
|
+
const rule = chunk.trim();
|
|
6180
|
+
if (rule && !seen.has(rule)) {
|
|
6181
|
+
seen.add(rule);
|
|
6182
|
+
rules.push(rule);
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
return rules.join("\n");
|
|
6186
|
+
}
|
|
6187
|
+
function getStaticCssOutputPath(root, safelistOutputPath) {
|
|
6188
|
+
return path9__default.resolve(root, path9__default.dirname(safelistOutputPath), "_tw-state-static.css");
|
|
6189
|
+
}
|
|
6190
|
+
function flushStaticCss(root) {
|
|
6191
|
+
if (staticCssPerFile.size === 0) return;
|
|
6192
|
+
const combined = Array.from(staticCssPerFile.values()).join("\n");
|
|
6193
|
+
const deduped = deduplicateStaticCss(combined);
|
|
6194
|
+
if (!deduped.trim()) return;
|
|
6195
|
+
const outPath = getStaticCssOutputPath(root, safelistOutput);
|
|
6196
|
+
try {
|
|
6197
|
+
fs13__default.mkdirSync(path9__default.dirname(outPath), { recursive: true });
|
|
6198
|
+
fs13__default.writeFileSync(
|
|
6199
|
+
outPath,
|
|
6200
|
+
`/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
|
|
6201
|
+
* Import this in globals.css: @import "./_tw-state-static.css";
|
|
6202
|
+
* Contains: state CSS (.tw-s-*[data-*="true"]) + container queries (@container .tw-cq-*).
|
|
6203
|
+
*/
|
|
6204
|
+
|
|
6205
|
+
${deduped}
|
|
6206
|
+
`
|
|
6207
|
+
);
|
|
6208
|
+
} catch (e) {
|
|
6209
|
+
console.warn("[tailwind-styled-v4] Could not write _tw-state-static.css:", e);
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
3912
6212
|
return {
|
|
3913
6213
|
name: "tailwind-styled-v4",
|
|
3914
6214
|
enforce: "pre",
|
|
3915
6215
|
configResolved(config) {
|
|
3916
6216
|
pluginState.root = config.root;
|
|
3917
6217
|
pluginState.isDev = config.command === "serve";
|
|
6218
|
+
try {
|
|
6219
|
+
const outPath = getStaticCssOutputPath(config.root, safelistOutput);
|
|
6220
|
+
const CSS_CANDIDATES = [
|
|
6221
|
+
"src/index.css",
|
|
6222
|
+
"src/main.css",
|
|
6223
|
+
"src/App.css",
|
|
6224
|
+
"src/styles/index.css",
|
|
6225
|
+
"src/styles/main.css",
|
|
6226
|
+
"src/globals.css",
|
|
6227
|
+
"src/style.css"
|
|
6228
|
+
];
|
|
6229
|
+
for (const candidate of CSS_CANDIDATES) {
|
|
6230
|
+
const candidatePath = path9__default.resolve(config.root, candidate);
|
|
6231
|
+
if (!fs13__default.existsSync(candidatePath)) continue;
|
|
6232
|
+
const content = fs13__default.readFileSync(candidatePath, "utf-8");
|
|
6233
|
+
if (content.includes("_tw-state-static.css")) break;
|
|
6234
|
+
const rel = path9__default.relative(path9__default.dirname(candidatePath), outPath).replace(/\\/g, "/");
|
|
6235
|
+
const importLine = `@import "./${rel}";`;
|
|
6236
|
+
const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
|
|
6237
|
+
const updated = tailwindImportRe.test(content) ? content.replace(tailwindImportRe, `$1${importLine}
|
|
6238
|
+
`) : `${importLine}
|
|
6239
|
+
${content}`;
|
|
6240
|
+
fs13__default.writeFileSync(candidatePath, updated, "utf-8");
|
|
6241
|
+
break;
|
|
6242
|
+
}
|
|
6243
|
+
} catch {
|
|
6244
|
+
}
|
|
3918
6245
|
},
|
|
3919
6246
|
transform(source, id) {
|
|
3920
6247
|
const filepath = id.split("?")[0];
|
|
@@ -3940,6 +6267,12 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3940
6267
|
return null;
|
|
3941
6268
|
}
|
|
3942
6269
|
if (!output.changed) return null;
|
|
6270
|
+
if (output.staticCss) {
|
|
6271
|
+
staticCssPerFile.set(filepath, output.staticCss);
|
|
6272
|
+
if (pluginState.isDev) {
|
|
6273
|
+
flushStaticCss(pluginState.root);
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
3943
6276
|
return { code: output.code, map: null };
|
|
3944
6277
|
},
|
|
3945
6278
|
async buildEnd() {
|
|
@@ -3957,6 +6290,10 @@ function tailwindStyledPlugin(opts = {}) {
|
|
|
3957
6290
|
if (doSafelist) {
|
|
3958
6291
|
writeJsonArtifact(pluginState.root, safelistOutput, scan.uniqueClasses);
|
|
3959
6292
|
}
|
|
6293
|
+
flushStaticCss(pluginState.root);
|
|
6294
|
+
console.log(
|
|
6295
|
+
`[tailwind-styled-v4] Static CSS: ${staticCssPerFile.size} files \u2192 _tw-state-static.css`
|
|
6296
|
+
);
|
|
3960
6297
|
writeJsonArtifact(pluginState.root, scanReportOutput, {
|
|
3961
6298
|
root: pluginState.root,
|
|
3962
6299
|
totalFiles: scan.totalFiles,
|