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.
Files changed (110) hide show
  1. package/README.md +100 -4
  2. package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
  3. package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
  4. package/dist/analyzer.d.mts +4 -4
  5. package/dist/analyzer.d.ts +4 -4
  6. package/dist/analyzer.js +34 -69
  7. package/dist/analyzer.js.map +1 -1
  8. package/dist/analyzer.mjs +33 -68
  9. package/dist/analyzer.mjs.map +1 -1
  10. package/dist/animate.d.mts +4 -0
  11. package/dist/animate.d.ts +4 -0
  12. package/dist/animate.js +33 -11
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +33 -11
  15. package/dist/animate.mjs.map +1 -1
  16. package/dist/atomic.js +57 -6
  17. package/dist/atomic.js.map +1 -1
  18. package/dist/atomic.mjs +57 -6
  19. package/dist/atomic.mjs.map +1 -1
  20. package/dist/cli.js +404 -190
  21. package/dist/cli.js.map +1 -1
  22. package/dist/cli.mjs +401 -187
  23. package/dist/cli.mjs.map +1 -1
  24. package/dist/compiler.d.mts +2700 -212
  25. package/dist/compiler.d.ts +2700 -212
  26. package/dist/compiler.js +1996 -503
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/compiler.mjs +1847 -448
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/devtools.js +17 -4
  31. package/dist/devtools.js.map +1 -1
  32. package/dist/devtools.mjs +17 -4
  33. package/dist/devtools.mjs.map +1 -1
  34. package/dist/engine.d.mts +11 -470
  35. package/dist/engine.d.ts +11 -470
  36. package/dist/engine.js +2777 -455
  37. package/dist/engine.js.map +1 -1
  38. package/dist/engine.mjs +2776 -454
  39. package/dist/engine.mjs.map +1 -1
  40. package/dist/index-BDQw13kn.d.ts +464 -0
  41. package/dist/index-DJv28Uzq.d.mts +464 -0
  42. package/dist/index.browser.mjs +143 -255
  43. package/dist/index.browser.mjs.map +1 -1
  44. package/dist/index.d.mts +23 -39
  45. package/dist/index.d.ts +23 -39
  46. package/dist/index.js +7234 -1400
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +7234 -1400
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/next.d.mts +44 -1
  51. package/dist/next.d.ts +44 -1
  52. package/dist/next.js +3224 -1065
  53. package/dist/next.js.map +1 -1
  54. package/dist/next.mjs +3223 -1066
  55. package/dist/next.mjs.map +1 -1
  56. package/dist/rspack.d.mts +9 -0
  57. package/dist/rspack.d.ts +9 -0
  58. package/dist/rspack.js +99 -61
  59. package/dist/rspack.js.map +1 -1
  60. package/dist/rspack.mjs +99 -61
  61. package/dist/rspack.mjs.map +1 -1
  62. package/dist/runtime-css.d.mts +8 -0
  63. package/dist/runtime-css.d.ts +8 -0
  64. package/dist/runtime-css.js +23 -7
  65. package/dist/runtime-css.js.map +1 -1
  66. package/dist/runtime-css.mjs +23 -7
  67. package/dist/runtime-css.mjs.map +1 -1
  68. package/dist/scanner.js +16 -37
  69. package/dist/scanner.js.map +1 -1
  70. package/dist/scanner.mjs +15 -36
  71. package/dist/scanner.mjs.map +1 -1
  72. package/dist/shared.d.mts +107 -1
  73. package/dist/shared.d.ts +107 -1
  74. package/dist/shared.js +3014 -466
  75. package/dist/shared.js.map +1 -1
  76. package/dist/shared.mjs +3008 -445
  77. package/dist/shared.mjs.map +1 -1
  78. package/dist/svelte.js +39 -35
  79. package/dist/svelte.js.map +1 -1
  80. package/dist/svelte.mjs +38 -34
  81. package/dist/svelte.mjs.map +1 -1
  82. package/dist/theme.js +85 -76
  83. package/dist/theme.js.map +1 -1
  84. package/dist/theme.mjs +83 -74
  85. package/dist/theme.mjs.map +1 -1
  86. package/dist/turbopackLoader.js +2351 -187
  87. package/dist/turbopackLoader.js.map +1 -1
  88. package/dist/turbopackLoader.mjs +2351 -187
  89. package/dist/turbopackLoader.mjs.map +1 -1
  90. package/dist/tw.js +404 -190
  91. package/dist/tw.js.map +1 -1
  92. package/dist/tw.mjs +401 -187
  93. package/dist/tw.mjs.map +1 -1
  94. package/dist/vite.js +2657 -320
  95. package/dist/vite.js.map +1 -1
  96. package/dist/vite.mjs +2657 -320
  97. package/dist/vite.mjs.map +1 -1
  98. package/dist/vue.js +39 -35
  99. package/dist/vue.js.map +1 -1
  100. package/dist/vue.mjs +38 -34
  101. package/dist/vue.mjs.map +1 -1
  102. package/dist/webpackLoader.js +190 -33
  103. package/dist/webpackLoader.js.map +1 -1
  104. package/dist/webpackLoader.mjs +190 -33
  105. package/dist/webpackLoader.mjs.map +1 -1
  106. package/native/index.node +0 -0
  107. package/native/tailwind-styled-native.node +0 -0
  108. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  109. package/package.json +9 -4
  110. package/CHANGELOG.md +0 -285
package/dist/engine.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  import { createRequire } from 'module';
3
- import * as fs5 from 'fs';
4
- import fs5__default from 'fs';
5
- import * as path6 from 'path';
6
- import path6__default from 'path';
3
+ import * as fs3 from 'fs';
4
+ import fs3__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 path13 = first?.path?.join(".") ?? "(root)";
223
+ const path16 = first?.path?.join(".") ?? "(root)";
224
224
  throw new Error(
225
- `[${context}] Native binding returned unexpected data: ${path13}: ${first?.message ?? "validation failed"}`
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(path13) {
618
+ function existsSync(path16) {
619
619
  if (isBrowser2) return false;
620
620
  try {
621
621
  const nodeFs = __require(NODE_FS);
622
- return nodeFs.existsSync(path13);
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 (fs5.existsSync(envPath)) {
857
+ if (fs3.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 (fs5.existsSync(candidate)) {
866
+ if (fs3.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 ["..", path6.join("..", ".."), path6.join("..", "..", "..")]) {
878
- const pkgRoot = path6.resolve(runtimeDir, depth);
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 = path6.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
881
+ const candidate = path9.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
882
882
  tried.push(`self-bundled:${candidate}`);
883
- if (fs5.existsSync(candidate)) {
883
+ if (fs3.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(path6.resolve(base, `${bin}.node`));
896
- localCandidates.push(path6.resolve(base, "..", `${bin}.node`));
897
- localCandidates.push(path6.resolve(base, `${bin}.${platform}.node`));
898
- localCandidates.push(path6.resolve(base, `${bin}.${napiPlatform}.node`));
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 = path6.resolve(dir, "native");
903
+ const nativeDir = path9.resolve(dir, "native");
904
904
  for (const bin of BINARY_NAMES) {
905
- localCandidates.push(path6.resolve(nativeDir, `${bin}.node`));
906
- localCandidates.push(path6.resolve(nativeDir, `${bin}.${platform}.node`));
907
- localCandidates.push(path6.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
908
- localCandidates.push(path6.resolve(nativeDir, "target", "release", `${bin}.node`));
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 = path6.resolve(dir, "..");
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 (fs5.existsSync(candidate)) {
917
+ if (fs3.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(path13) {
956
+ async function fetchJson(path16) {
957
957
  try {
958
- const res = await fetch(`${baseUrl}${path13}`, {
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,2479 @@ var init_observability = __esm({
987
987
  }
988
988
  });
989
989
 
990
+ // packages/domain/compiler/src/nativeBridge.ts
991
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
992
+ var init_nativeBridge = __esm({
993
+ "packages/domain/compiler/src/nativeBridge.ts"() {
994
+ init_src2();
995
+ _loadNative = (path16) => __require(path16);
996
+ log = (...args) => {
997
+ if (process.env.DEBUG?.includes("compiler:native")) {
998
+ console.log("[compiler:native]", ...args);
999
+ }
1000
+ };
1001
+ NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
1002
+ nativeBridge = null;
1003
+ bridgeLoadAttempted = false;
1004
+ bridgeLoadError = null;
1005
+ isValidNativeBridge = (mod) => {
1006
+ const m = mod;
1007
+ return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
1008
+ };
1009
+ getNativeBridge = () => {
1010
+ if (nativeBridge) {
1011
+ return nativeBridge;
1012
+ }
1013
+ if (bridgeLoadAttempted) {
1014
+ if (bridgeLoadError) {
1015
+ throw bridgeLoadError;
1016
+ }
1017
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
1018
+ }
1019
+ bridgeLoadAttempted = true;
1020
+ try {
1021
+ const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
1022
+ const result = resolveNativeBinary(runtimeDir);
1023
+ if (result.path && result.path.endsWith(".node")) {
1024
+ try {
1025
+ const binding = _loadNative(result.path);
1026
+ if (isValidNativeBridge(binding)) {
1027
+ nativeBridge = binding;
1028
+ log("Native bridge loaded successfully from:", result.path);
1029
+ return nativeBridge;
1030
+ }
1031
+ } catch (e) {
1032
+ log("Failed to require native binding:", e);
1033
+ }
1034
+ }
1035
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
1036
+
1037
+ Tried paths: ${result.tried.join("\n")}`);
1038
+ } catch (err) {
1039
+ bridgeLoadError = err instanceof Error ? err : new Error(String(err));
1040
+ log("Failed to load native bridge:", bridgeLoadError.message);
1041
+ throw bridgeLoadError;
1042
+ }
1043
+ };
1044
+ adaptNativeResult = (raw) => {
1045
+ return {
1046
+ code: raw.code ?? "",
1047
+ classes: raw.classes ?? [],
1048
+ changed: raw.changed ?? false,
1049
+ rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
1050
+ metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
1051
+ };
1052
+ };
1053
+ if (typeof process !== "undefined" && !bridgeLoadAttempted) {
1054
+ try {
1055
+ getNativeBridge();
1056
+ } catch {
1057
+ }
1058
+ }
1059
+ }
1060
+ });
1061
+
1062
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
1063
+ async function generateCssNative(classes, options) {
1064
+ const { theme } = options;
1065
+ const native = getNativeBridge();
1066
+ if (!native?.generateCssNative) {
1067
+ throw new Error(
1068
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
1069
+ );
1070
+ }
1071
+ const themeJson = JSON.stringify(theme);
1072
+ const css = native.generateCssNative(classes, themeJson);
1073
+ return css;
1074
+ }
1075
+ function clearThemeCache() {
1076
+ try {
1077
+ const native = getNativeBridge();
1078
+ if (!native?.clearThemeCache) {
1079
+ return;
1080
+ }
1081
+ native.clearThemeCache();
1082
+ } catch {
1083
+ }
1084
+ }
1085
+ var init_cssGeneratorNative = __esm({
1086
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
1087
+ init_nativeBridge();
1088
+ }
1089
+ });
1090
+
1091
+ // packages/domain/compiler/src/compiler/compilationNative.ts
1092
+ function compileCssNative2(classes, prefix) {
1093
+ const native = getNativeBridge();
1094
+ if (!native?.compileCss) throw new Error("compileCss not available");
1095
+ return native.compileCss(classes, prefix);
1096
+ }
1097
+ function compileCssLightning(classes) {
1098
+ const native = getNativeBridge();
1099
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
1100
+ return native.compileCssLightning(classes);
1101
+ }
1102
+ function extractTwStateConfigsNative(source, filename) {
1103
+ const native = getNativeBridge();
1104
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
1105
+ return native.extractTwStateConfigs(source, filename);
1106
+ }
1107
+ function generateStaticStateCssNative(inputs, resolvedCss) {
1108
+ const native = getNativeBridge();
1109
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
1110
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
1111
+ }
1112
+ function extractAndGenerateStateCssNative(source, filename) {
1113
+ const native = getNativeBridge();
1114
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
1115
+ return native.extractAndGenerateStateCss(source, filename);
1116
+ }
1117
+ function layoutClassesToCss(classes) {
1118
+ const native = getNativeBridge();
1119
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
1120
+ return native.layoutClassesToCss(classes);
1121
+ }
1122
+ function hashContent(input, algorithm = "sha256", length = 8) {
1123
+ const native = getNativeBridge();
1124
+ if (!native?.hashContent) throw new Error("hashContent not available");
1125
+ return native.hashContent(input, algorithm, length);
1126
+ }
1127
+ function extractTwContainerConfigs(source) {
1128
+ const native = getNativeBridge();
1129
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
1130
+ return native.extractTwContainerConfigs(source);
1131
+ }
1132
+ function parseAtomicClass(twClass) {
1133
+ const native = getNativeBridge();
1134
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
1135
+ return native.parseAtomicClass(twClass);
1136
+ }
1137
+ function generateAtomicCss(rulesJson) {
1138
+ const native = getNativeBridge();
1139
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
1140
+ return native.generateAtomicCss(rulesJson);
1141
+ }
1142
+ function toAtomicClasses(twClasses) {
1143
+ const native = getNativeBridge();
1144
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
1145
+ return native.toAtomicClasses(twClasses);
1146
+ }
1147
+ function clearAtomicRegistry() {
1148
+ const native = getNativeBridge();
1149
+ if (!native?.clearAtomicRegistry) return;
1150
+ native.clearAtomicRegistry();
1151
+ }
1152
+ function atomicRegistrySize() {
1153
+ const native = getNativeBridge();
1154
+ if (!native?.atomicRegistrySize) return 0;
1155
+ return native.atomicRegistrySize();
1156
+ }
1157
+ var init_compilationNative = __esm({
1158
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
1159
+ init_nativeBridge();
1160
+ }
1161
+ });
1162
+
1163
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
1164
+ function compileClass(input) {
1165
+ const native = getNativeBridge();
1166
+ if (!native?.compile_class) throw new Error("compile_class not available");
1167
+ const resultJson = native.compile_class(input);
1168
+ try {
1169
+ return JSON.parse(resultJson);
1170
+ } catch {
1171
+ return {
1172
+ selector: "",
1173
+ declarations: "",
1174
+ properties: [],
1175
+ specificity: 0
1176
+ };
1177
+ }
1178
+ }
1179
+ function compileClasses(inputs) {
1180
+ const native = getNativeBridge();
1181
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
1182
+ const resultJson = native.compile_classes(inputs);
1183
+ try {
1184
+ return JSON.parse(resultJson);
1185
+ } catch {
1186
+ return {
1187
+ css: "",
1188
+ resolved_classes: [],
1189
+ unknown_classes: [],
1190
+ size_bytes: 0,
1191
+ duration_ms: 0
1192
+ };
1193
+ }
1194
+ }
1195
+ function compileToCss(input, minify) {
1196
+ const native = getNativeBridge();
1197
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
1198
+ return native.compile_to_css(input, minify ?? false);
1199
+ }
1200
+ function compileToCssBatch(inputs, minify) {
1201
+ const native = getNativeBridge();
1202
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
1203
+ return native.compile_to_css_batch(inputs, minify ?? false);
1204
+ }
1205
+ function minifyCss(css) {
1206
+ const native = getNativeBridge();
1207
+ if (!native?.minify_css) throw new Error("minify_css not available");
1208
+ return native.minify_css(css);
1209
+ }
1210
+ function compileAnimation(animationName, from, to) {
1211
+ const native = getNativeBridge();
1212
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
1213
+ const resultJson = native.compile_animation(animationName, from, to);
1214
+ try {
1215
+ return JSON.parse(resultJson);
1216
+ } catch {
1217
+ return {
1218
+ animation_id: "",
1219
+ keyframes_css: "",
1220
+ animation_rule: "",
1221
+ duration_ms: 0
1222
+ };
1223
+ }
1224
+ }
1225
+ function compileKeyframes(name, stopsJson) {
1226
+ const native = getNativeBridge();
1227
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
1228
+ const resultJson = native.compile_keyframes(name, stopsJson);
1229
+ try {
1230
+ return JSON.parse(resultJson);
1231
+ } catch {
1232
+ return {
1233
+ animation_id: "",
1234
+ keyframes_css: "",
1235
+ animation_rule: "",
1236
+ duration_ms: 0
1237
+ };
1238
+ }
1239
+ }
1240
+ function compileTheme(tokensJson, themeName, prefix) {
1241
+ const native = getNativeBridge();
1242
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
1243
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
1244
+ try {
1245
+ return JSON.parse(resultJson);
1246
+ } catch {
1247
+ return {
1248
+ selector: ":root",
1249
+ variables: [],
1250
+ variables_css: "",
1251
+ theme_name: themeName
1252
+ };
1253
+ }
1254
+ }
1255
+ function twMerge(classString) {
1256
+ const native = getNativeBridge();
1257
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
1258
+ return native.tw_merge(classString);
1259
+ }
1260
+ function twMergeMany(classStrings) {
1261
+ const native = getNativeBridge();
1262
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
1263
+ return native.tw_merge_many(classStrings);
1264
+ }
1265
+ function twMergeWithSeparator(classString, options) {
1266
+ const native = getNativeBridge();
1267
+ if (!native?.tw_merge_with_separator)
1268
+ throw new Error("tw_merge_with_separator not available");
1269
+ const opts = {
1270
+ separator: options.separator,
1271
+ debug: options.debug
1272
+ };
1273
+ return native.tw_merge_with_separator(classString, opts);
1274
+ }
1275
+ function twMergeManyWithSeparator(classStrings, options) {
1276
+ const native = getNativeBridge();
1277
+ if (!native?.tw_merge_many_with_separator)
1278
+ throw new Error("tw_merge_many_with_separator not available");
1279
+ const opts = {
1280
+ separator: options.separator,
1281
+ debug: options.debug
1282
+ };
1283
+ return native.tw_merge_many_with_separator(classStrings, opts);
1284
+ }
1285
+ function twMergeRaw(classLists) {
1286
+ const native = getNativeBridge();
1287
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
1288
+ return native.tw_merge_raw(classLists);
1289
+ }
1290
+ var init_cssCompilationNative = __esm({
1291
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
1292
+ init_nativeBridge();
1293
+ }
1294
+ });
1295
+
1296
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
1297
+ function idRegistryCreate() {
1298
+ const native = getNativeBridge();
1299
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
1300
+ return native.id_registry_create();
1301
+ }
1302
+ function idRegistryGenerate(handle, name) {
1303
+ const native = getNativeBridge();
1304
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
1305
+ return native.id_registry_generate(handle, name);
1306
+ }
1307
+ function idRegistryLookup(handle, name) {
1308
+ const native = getNativeBridge();
1309
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
1310
+ return native.id_registry_lookup(handle, name);
1311
+ }
1312
+ function idRegistryNext(handle) {
1313
+ const native = getNativeBridge();
1314
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
1315
+ return native.id_registry_next(handle);
1316
+ }
1317
+ function idRegistryDestroy(handle) {
1318
+ const native = getNativeBridge();
1319
+ if (!native?.id_registry_destroy) return;
1320
+ native.id_registry_destroy(handle);
1321
+ }
1322
+ function idRegistryReset(handle) {
1323
+ const native = getNativeBridge();
1324
+ if (!native?.id_registry_reset) return;
1325
+ native.id_registry_reset(handle);
1326
+ }
1327
+ function idRegistrySnapshot(handle) {
1328
+ const native = getNativeBridge();
1329
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
1330
+ const snapshotJson = native.id_registry_snapshot(handle);
1331
+ try {
1332
+ return JSON.parse(snapshotJson);
1333
+ } catch {
1334
+ return {
1335
+ handle,
1336
+ next_id: 0,
1337
+ entries: [],
1338
+ total_entries: 0
1339
+ };
1340
+ }
1341
+ }
1342
+ function idRegistryActiveCount() {
1343
+ const native = getNativeBridge();
1344
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
1345
+ return native.id_registry_active_count();
1346
+ }
1347
+ function registerPropertyName(propertyName) {
1348
+ const native = getNativeBridge();
1349
+ if (!native?.register_property_name)
1350
+ throw new Error("register_property_name not available");
1351
+ return native.register_property_name(propertyName);
1352
+ }
1353
+ function registerValueName(valueName) {
1354
+ const native = getNativeBridge();
1355
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
1356
+ return native.register_value_name(valueName);
1357
+ }
1358
+ function propertyIdToString(propertyId) {
1359
+ const native = getNativeBridge();
1360
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
1361
+ return native.property_id_to_string(propertyId);
1362
+ }
1363
+ function valueIdToString(valueId) {
1364
+ const native = getNativeBridge();
1365
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
1366
+ return native.value_id_to_string(valueId);
1367
+ }
1368
+ function reverseLookupProperty(propertyId) {
1369
+ const native = getNativeBridge();
1370
+ if (!native?.reverse_lookup_property)
1371
+ throw new Error("reverse_lookup_property not available");
1372
+ return native.reverse_lookup_property(propertyId);
1373
+ }
1374
+ function reverseLookupValue(valueId) {
1375
+ const native = getNativeBridge();
1376
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
1377
+ return native.reverse_lookup_value(valueId);
1378
+ }
1379
+ function idRegistryExport(handle) {
1380
+ const native = getNativeBridge();
1381
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
1382
+ return native.id_registry_export(handle);
1383
+ }
1384
+ function idRegistryImport(importedData) {
1385
+ const native = getNativeBridge();
1386
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
1387
+ return native.id_registry_import(importedData);
1388
+ }
1389
+ var init_idRegistryNative = __esm({
1390
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
1391
+ init_nativeBridge();
1392
+ }
1393
+ });
1394
+
1395
+ // packages/domain/compiler/src/compiler/streamingNative.ts
1396
+ function processFileChange(fileChangeJson) {
1397
+ const native = getNativeBridge();
1398
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
1399
+ const resultJson = native.process_file_change(fileChangeJson);
1400
+ try {
1401
+ return JSON.parse(resultJson);
1402
+ } catch {
1403
+ return {
1404
+ file_path: "",
1405
+ status: "error",
1406
+ old_classes: [],
1407
+ new_classes: [],
1408
+ added_classes: [],
1409
+ removed_classes: [],
1410
+ changed: false,
1411
+ fingerprint: "",
1412
+ error: "Failed to parse result"
1413
+ };
1414
+ }
1415
+ }
1416
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
1417
+ const native = getNativeBridge();
1418
+ if (!native?.compute_incremental_diff)
1419
+ throw new Error("compute_incremental_diff not available");
1420
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
1421
+ try {
1422
+ return JSON.parse(resultJson);
1423
+ } catch {
1424
+ return {
1425
+ is_changed: false,
1426
+ changes_count: 0,
1427
+ diff: {
1428
+ added_files: [],
1429
+ removed_files: [],
1430
+ modified_files: [],
1431
+ added_classes: [],
1432
+ removed_classes: [],
1433
+ total_changes: 0
1434
+ },
1435
+ processing_time_ms: 0
1436
+ };
1437
+ }
1438
+ }
1439
+ function createFingerprint(filePath, fileContent) {
1440
+ const native = getNativeBridge();
1441
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
1442
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
1443
+ try {
1444
+ return JSON.parse(fingerprintJson);
1445
+ } catch {
1446
+ return {
1447
+ file_path: filePath,
1448
+ content_hash: "",
1449
+ size_bytes: fileContent.length,
1450
+ mtime_ms: Date.now(),
1451
+ class_hash: "",
1452
+ signature: ""
1453
+ };
1454
+ }
1455
+ }
1456
+ function injectStateHash(css, stateHash) {
1457
+ const native = getNativeBridge();
1458
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
1459
+ const resultJson = native.inject_state_hash(css, stateHash);
1460
+ try {
1461
+ return JSON.parse(resultJson);
1462
+ } catch {
1463
+ return {
1464
+ injected: false,
1465
+ state_hash: stateHash,
1466
+ affected_files: 0,
1467
+ total_injected_bytes: 0
1468
+ };
1469
+ }
1470
+ }
1471
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
1472
+ const native = getNativeBridge();
1473
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
1474
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
1475
+ try {
1476
+ return JSON.parse(resultJson);
1477
+ } catch {
1478
+ return {
1479
+ entries_before: 0,
1480
+ entries_after: 0,
1481
+ entries_removed: 0,
1482
+ freed_bytes: 0
1483
+ };
1484
+ }
1485
+ }
1486
+ function rebuildWorkspaceResult(rootDir, extensions) {
1487
+ const native = getNativeBridge();
1488
+ if (!native?.rebuild_workspace_result)
1489
+ throw new Error("rebuild_workspace_result not available");
1490
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
1491
+ try {
1492
+ return JSON.parse(resultJson);
1493
+ } catch {
1494
+ return {
1495
+ total_files_scanned: 0,
1496
+ total_classes_found: 0,
1497
+ unique_classes: 0,
1498
+ build_time_ms: 0,
1499
+ files_with_changes: 0
1500
+ };
1501
+ }
1502
+ }
1503
+ function scanFileNative(filePath, fileContent) {
1504
+ const native = getNativeBridge();
1505
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
1506
+ const resultJson = native.scan_file_native(filePath, fileContent);
1507
+ try {
1508
+ return JSON.parse(resultJson);
1509
+ } catch {
1510
+ return {
1511
+ file: filePath,
1512
+ classes: [],
1513
+ added_classes: [],
1514
+ removed_classes: [],
1515
+ changed: false
1516
+ };
1517
+ }
1518
+ }
1519
+ function scanFilesBatchNative(filesJson) {
1520
+ const native = getNativeBridge();
1521
+ if (!native?.scan_files_batch_native)
1522
+ throw new Error("scan_files_batch_native not available");
1523
+ const resultJson = native.scan_files_batch_native(filesJson);
1524
+ try {
1525
+ return JSON.parse(resultJson);
1526
+ } catch {
1527
+ return [];
1528
+ }
1529
+ }
1530
+ var init_streamingNative = __esm({
1531
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
1532
+ init_nativeBridge();
1533
+ }
1534
+ });
1535
+
1536
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
1537
+ var tailwindEngine_exports = {};
1538
+ __export(tailwindEngine_exports, {
1539
+ clearCache: () => clearCache,
1540
+ getCacheStats: () => getCacheStats,
1541
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
1542
+ runCssPipeline: () => runCssPipeline,
1543
+ runCssPipelineSync: () => runCssPipelineSync
1544
+ });
1545
+ function _getCacheKey(classes, minify, cssEntry, root) {
1546
+ const sorted = [...classes].sort().join(",");
1547
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
1548
+ return `${sorted}|${flags}`;
1549
+ }
1550
+ function _evictOldestIfNeeded() {
1551
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
1552
+ const firstKey = _cssCache.keys().next().value;
1553
+ if (firstKey !== void 0) {
1554
+ _cssCache.delete(firstKey);
1555
+ }
1556
+ }
1557
+ }
1558
+ function getCacheStats() {
1559
+ const total = _cacheHits + _cacheMisses;
1560
+ return {
1561
+ hits: _cacheHits,
1562
+ misses: _cacheMisses,
1563
+ hitRate: total > 0 ? _cacheHits / total : 0,
1564
+ size: _cssCache.size,
1565
+ maxSize: MAX_CACHE_SIZE
1566
+ };
1567
+ }
1568
+ function clearCache() {
1569
+ _cssCache.clear();
1570
+ _cacheHits = 0;
1571
+ _cacheMisses = 0;
1572
+ }
1573
+ function getThemeConfig() {
1574
+ return {
1575
+ colors: {
1576
+ slate: {
1577
+ "50": "#f8fafc",
1578
+ "100": "#f1f5f9",
1579
+ "200": "#e2e8f0",
1580
+ "300": "#cbd5e1",
1581
+ "400": "#94a3b8",
1582
+ "500": "#64748b",
1583
+ "600": "#475569",
1584
+ "700": "#334155",
1585
+ "800": "#1e293b",
1586
+ "900": "#0f172a"
1587
+ },
1588
+ gray: {
1589
+ "50": "#f9fafb",
1590
+ "100": "#f3f4f6",
1591
+ "200": "#e5e7eb",
1592
+ "300": "#d1d5db",
1593
+ "400": "#9ca3af",
1594
+ "500": "#6b7280",
1595
+ "600": "#4b5563",
1596
+ "700": "#374151",
1597
+ "800": "#1f2937",
1598
+ "900": "#111827"
1599
+ },
1600
+ white: "#ffffff",
1601
+ black: "#000000",
1602
+ red: {
1603
+ "500": "#ef4444",
1604
+ "600": "#dc2626"
1605
+ },
1606
+ blue: {
1607
+ "500": "#3b82f6",
1608
+ "600": "#1e40af"
1609
+ }
1610
+ },
1611
+ spacing: {
1612
+ "0": "0px",
1613
+ "1": "0.25rem",
1614
+ "2": "0.5rem",
1615
+ "3": "0.75rem",
1616
+ "4": "1rem",
1617
+ "5": "1.25rem",
1618
+ "6": "1.5rem",
1619
+ "8": "2rem",
1620
+ "10": "2.5rem",
1621
+ "12": "3rem",
1622
+ "16": "4rem",
1623
+ "20": "5rem",
1624
+ "24": "6rem"
1625
+ },
1626
+ breakpoints: {
1627
+ "sm": "640px",
1628
+ "md": "768px",
1629
+ "lg": "1024px",
1630
+ "xl": "1280px",
1631
+ "2xl": "1536px"
1632
+ }
1633
+ };
1634
+ }
1635
+ function postProcessWithLightning(rawCss) {
1636
+ if (!rawCss) return "";
1637
+ const native = getNativeBridge();
1638
+ if (!native?.processTailwindCssLightning) {
1639
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1640
+ }
1641
+ const result = native.processTailwindCssLightning(rawCss);
1642
+ if (!result?.css) {
1643
+ throw new Error("FATAL: processTailwindCssLightning returned null");
1644
+ }
1645
+ return result.css;
1646
+ }
1647
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1648
+ const filtered = classes.filter(Boolean);
1649
+ const uniqueMap = /* @__PURE__ */ new Map();
1650
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
1651
+ const unique = Array.from(uniqueMap.values());
1652
+ if (unique.length === 0) {
1653
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1654
+ }
1655
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
1656
+ const cached = _cssCache.get(cacheKey);
1657
+ if (cached) {
1658
+ _cacheHits++;
1659
+ if (process.env.DEBUG?.includes("compiler")) {
1660
+ console.log(
1661
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
1662
+ );
1663
+ }
1664
+ return cached;
1665
+ }
1666
+ _cacheMisses++;
1667
+ let rawCss;
1668
+ let usedRustCompiler = false;
1669
+ const theme = getThemeConfig();
1670
+ rawCss = await generateCssNative(unique, { theme });
1671
+ usedRustCompiler = true;
1672
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
1673
+ if (process.env.DEBUG?.includes("compiler")) {
1674
+ console.log(
1675
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1676
+ `Size: ${finalCss.length} bytes`
1677
+ );
1678
+ }
1679
+ const result = {
1680
+ css: finalCss,
1681
+ classes: unique,
1682
+ sizeBytes: finalCss.length,
1683
+ optimized: minify
1684
+ };
1685
+ _evictOldestIfNeeded();
1686
+ _cssCache.set(cacheKey, result);
1687
+ return result;
1688
+ }
1689
+ function runCssPipelineSync(_classes) {
1690
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1691
+ }
1692
+ function processTailwindCssWithTargets(css, targets) {
1693
+ const native = getNativeBridge();
1694
+ if (!native?.processTailwindCssWithTargets) {
1695
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
1696
+ }
1697
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
1698
+ if (!result?.css) {
1699
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
1700
+ }
1701
+ return result.css;
1702
+ }
1703
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1704
+ var init_tailwindEngine = __esm({
1705
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1706
+ init_nativeBridge();
1707
+ init_cssGeneratorNative();
1708
+ createRequire(import.meta.url);
1709
+ _cssCache = /* @__PURE__ */ new Map();
1710
+ _cacheHits = 0;
1711
+ _cacheMisses = 0;
1712
+ MAX_CACHE_SIZE = 100;
1713
+ }
1714
+ });
1715
+
1716
+ // packages/domain/compiler/src/compiler/index.ts
1717
+ var init_compiler = __esm({
1718
+ "packages/domain/compiler/src/compiler/index.ts"() {
1719
+ init_cssGeneratorNative();
1720
+ init_compilationNative();
1721
+ init_cssCompilationNative();
1722
+ init_idRegistryNative();
1723
+ init_streamingNative();
1724
+ }
1725
+ });
1726
+
1727
+ // packages/domain/compiler/src/parser/index.ts
1728
+ var parser_exports = {};
1729
+ __export(parser_exports, {
1730
+ astExtractClasses: () => astExtractClasses,
1731
+ batchExtractClasses: () => batchExtractClasses,
1732
+ checkAgainstSafelist: () => checkAgainstSafelist,
1733
+ diffClassLists: () => diffClassLists,
1734
+ extractAllClasses: () => extractAllClasses,
1735
+ extractClassesFromSource: () => extractClassesFromSource,
1736
+ extractComponentUsage: () => extractComponentUsage,
1737
+ mergeClassesStatic: () => mergeClassesStatic,
1738
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1739
+ normalizeClasses: () => normalizeClasses,
1740
+ parseClasses: () => parseClasses
1741
+ });
1742
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1743
+ var init_parser = __esm({
1744
+ "packages/domain/compiler/src/parser/index.ts"() {
1745
+ init_nativeBridge();
1746
+ parseClasses = (raw) => {
1747
+ const native = getNativeBridge();
1748
+ if (!native?.parseClasses) {
1749
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1750
+ }
1751
+ return native.parseClasses(raw) || [];
1752
+ };
1753
+ extractAllClasses = (source) => {
1754
+ const native = getNativeBridge();
1755
+ if (!native?.extractAllClasses) {
1756
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1757
+ }
1758
+ return native.extractAllClasses(source) || [];
1759
+ };
1760
+ extractClassesFromSource = (source) => {
1761
+ const native = getNativeBridge();
1762
+ if (!native?.extractClassesFromSource) {
1763
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1764
+ }
1765
+ const result = native.extractClassesFromSource(source);
1766
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1767
+ };
1768
+ astExtractClasses = (source, _filename) => {
1769
+ const native = getNativeBridge();
1770
+ if (!native?.extractClassesFromSource) {
1771
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1772
+ }
1773
+ return native.extractClassesFromSource(source) || [];
1774
+ };
1775
+ normalizeClasses = (raw) => {
1776
+ const result = normalizeAndDedupClasses(raw);
1777
+ return result?.normalized || "";
1778
+ };
1779
+ mergeClassesStatic = (classes) => {
1780
+ const result = normalizeAndDedupClasses(classes);
1781
+ return result?.normalized || "";
1782
+ };
1783
+ normalizeAndDedupClasses = (raw) => {
1784
+ const native = getNativeBridge();
1785
+ if (!native?.normalizeAndDedupClasses) {
1786
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1787
+ }
1788
+ const result = native.normalizeAndDedupClasses(raw);
1789
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1790
+ };
1791
+ extractComponentUsage = (source) => {
1792
+ const native = getNativeBridge();
1793
+ if (!native?.extractComponentUsage) {
1794
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1795
+ }
1796
+ return native.extractComponentUsage(source) || [];
1797
+ };
1798
+ batchExtractClasses = (filePaths) => {
1799
+ const native = getNativeBridge();
1800
+ if (!native?.batchExtractClasses) {
1801
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1802
+ }
1803
+ return native.batchExtractClasses(filePaths) || [];
1804
+ };
1805
+ checkAgainstSafelist = (classes, safelist) => {
1806
+ const native = getNativeBridge();
1807
+ if (!native?.checkAgainstSafelist) {
1808
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1809
+ }
1810
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1811
+ };
1812
+ diffClassLists = (previous, current) => {
1813
+ const native = getNativeBridge();
1814
+ if (!native?.diffClassLists) {
1815
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1816
+ }
1817
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1818
+ };
1819
+ }
1820
+ });
1821
+
1822
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1823
+ function detectDeadCode(scanResultJson, css) {
1824
+ const native = getNativeBridge();
1825
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1826
+ return native.detectDeadCode(scanResultJson, css);
1827
+ }
1828
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1829
+ const native = getNativeBridge();
1830
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1831
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1832
+ }
1833
+ function analyzeClassesNative(filesJson, cwd, flags) {
1834
+ const native = getNativeBridge();
1835
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1836
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1837
+ }
1838
+ function analyzeRscNative(source, filename) {
1839
+ const native = getNativeBridge();
1840
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1841
+ return native.analyzeRsc(source, filename);
1842
+ }
1843
+ function optimizeCssNative(css) {
1844
+ const native = getNativeBridge();
1845
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1846
+ const result = native.processTailwindCssLightning(css);
1847
+ return {
1848
+ css: result.css,
1849
+ originalSize: css.length,
1850
+ optimizedSize: result.size_bytes,
1851
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1852
+ };
1853
+ }
1854
+ function processTailwindCssLightning(css) {
1855
+ const native = getNativeBridge();
1856
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1857
+ return native.processTailwindCssLightning(css);
1858
+ }
1859
+ function eliminateDeadCssNative(css, deadClasses) {
1860
+ const native = getNativeBridge();
1861
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1862
+ return native.eliminateDeadCss(css, deadClasses);
1863
+ }
1864
+ function hoistComponentsNative(source) {
1865
+ const native = getNativeBridge();
1866
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1867
+ return native.hoistComponents(source);
1868
+ }
1869
+ function compileVariantTableNative(configJson) {
1870
+ const native = getNativeBridge();
1871
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1872
+ return native.compileVariantTable(configJson);
1873
+ }
1874
+ function classifyAndSortClassesNative(classes) {
1875
+ const native = getNativeBridge();
1876
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1877
+ return native.classifyAndSortClasses(classes);
1878
+ }
1879
+ function mergeCssDeclarationsNative(cssChunks) {
1880
+ const native = getNativeBridge();
1881
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1882
+ return native.mergeCssDeclarations(cssChunks);
1883
+ }
1884
+ var init_analyzerNative = __esm({
1885
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1886
+ init_nativeBridge();
1887
+ }
1888
+ });
1889
+
1890
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1891
+ function resolveVariants(configJson) {
1892
+ const native = getNativeBridge();
1893
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1894
+ const resultJson = native.resolve_variants(configJson);
1895
+ try {
1896
+ return JSON.parse(resultJson);
1897
+ } catch {
1898
+ return {
1899
+ variants: [],
1900
+ supported: [],
1901
+ deprecated: [],
1902
+ conflicting: []
1903
+ };
1904
+ }
1905
+ }
1906
+ function validateThemeConfig(configJson) {
1907
+ const native = getNativeBridge();
1908
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1909
+ const resultJson = native.validate_variant_config(configJson);
1910
+ try {
1911
+ return JSON.parse(resultJson);
1912
+ } catch {
1913
+ return {
1914
+ is_valid: false,
1915
+ errors: ["Unable to parse configuration"],
1916
+ warnings: [],
1917
+ suggestions: []
1918
+ };
1919
+ }
1920
+ }
1921
+ function resolveCascade(baseThemeJson, overridesJson) {
1922
+ const native = getNativeBridge();
1923
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1924
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1925
+ try {
1926
+ return JSON.parse(resultJson);
1927
+ } catch {
1928
+ return {
1929
+ base_theme: {},
1930
+ user_overrides: {},
1931
+ merged_theme: {},
1932
+ conflict_resolutions: []
1933
+ };
1934
+ }
1935
+ }
1936
+ function resolveClassNames(classNames, themeJson) {
1937
+ const native = getNativeBridge();
1938
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1939
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1940
+ try {
1941
+ return JSON.parse(resultJson);
1942
+ } catch {
1943
+ return [];
1944
+ }
1945
+ }
1946
+ function resolveConflictGroup(groupName, themeJson) {
1947
+ const native = getNativeBridge();
1948
+ if (!native?.resolve_conflict_group)
1949
+ throw new Error("resolve_conflict_group not available");
1950
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1951
+ try {
1952
+ return JSON.parse(resultJson);
1953
+ } catch {
1954
+ return {
1955
+ group_name: groupName,
1956
+ conflicting_classes: [],
1957
+ description: "",
1958
+ resolution_strategy: "last-wins"
1959
+ };
1960
+ }
1961
+ }
1962
+ function resolveThemeValue(keyPath, themeJson) {
1963
+ const native = getNativeBridge();
1964
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1965
+ return native.resolve_theme_value(keyPath, themeJson);
1966
+ }
1967
+ function resolveSimpleVariants(configJson) {
1968
+ const native = getNativeBridge();
1969
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1970
+ const resultJson = native.resolve_simple_variants(configJson);
1971
+ try {
1972
+ return JSON.parse(resultJson);
1973
+ } catch {
1974
+ return [];
1975
+ }
1976
+ }
1977
+ var init_themeResolutionNative = __esm({
1978
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1979
+ init_nativeBridge();
1980
+ }
1981
+ });
1982
+
1983
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1984
+ function scanWorkspace(root, extensions) {
1985
+ const native = getNativeBridge();
1986
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1987
+ return native.scan_workspace(root, extensions);
1988
+ }
1989
+ function extractClassesFromSourceNative(source) {
1990
+ const native = getNativeBridge();
1991
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1992
+ return native.extract_classes_from_source(source);
1993
+ }
1994
+ function batchExtractClassesNative(filePaths) {
1995
+ const native = getNativeBridge();
1996
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1997
+ return native.batch_extract_classes(filePaths);
1998
+ }
1999
+ function checkAgainstSafelistNative(classes, safelist) {
2000
+ const native = getNativeBridge();
2001
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
2002
+ return native.check_against_safelist(classes, safelist);
2003
+ }
2004
+ function scanFile(filePath) {
2005
+ const native = getNativeBridge();
2006
+ if (!native?.scan_file) throw new Error("scan_file not available");
2007
+ return native.scan_file(filePath);
2008
+ }
2009
+ function collectFiles(root, extensions) {
2010
+ const native = getNativeBridge();
2011
+ if (!native?.collect_files) throw new Error("collect_files not available");
2012
+ return native.collect_files(root, extensions);
2013
+ }
2014
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
2015
+ const native = getNativeBridge();
2016
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
2017
+ return native.walk_and_prefilter_source_files(root, extensions);
2018
+ }
2019
+ function generateSubComponentTypes(root, outputPath) {
2020
+ const native = getNativeBridge();
2021
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
2022
+ return native.generate_sub_component_types(root, outputPath);
2023
+ }
2024
+ var init_scannerNative = __esm({
2025
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
2026
+ init_nativeBridge();
2027
+ }
2028
+ });
2029
+
2030
+ // packages/domain/compiler/src/analyzer/index.ts
2031
+ var init_analyzer = __esm({
2032
+ "packages/domain/compiler/src/analyzer/index.ts"() {
2033
+ init_analyzerNative();
2034
+ init_themeResolutionNative();
2035
+ init_scannerNative();
2036
+ }
2037
+ });
2038
+
2039
+ // packages/domain/compiler/src/cache/cacheNative.ts
2040
+ function getCacheStatistics() {
2041
+ const native = getNativeBridge();
2042
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
2043
+ const statsJson = native.get_cache_statistics();
2044
+ try {
2045
+ return JSON.parse(statsJson);
2046
+ } catch {
2047
+ return {
2048
+ parse_cache: { hits: 0, misses: 0, size: 0 },
2049
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
2050
+ compile_cache: { hits: 0, misses: 0, size: 0 },
2051
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
2052
+ overall_hit_rate: 0,
2053
+ total_memory_bytes: 0
2054
+ };
2055
+ }
2056
+ }
2057
+ function clearAllCaches() {
2058
+ const native = getNativeBridge();
2059
+ if (!native?.clear_all_caches) return;
2060
+ try {
2061
+ native.clear_all_caches();
2062
+ } catch {
2063
+ }
2064
+ }
2065
+ function clearParseCache() {
2066
+ const native = getNativeBridge();
2067
+ if (!native?.clear_parse_cache) return;
2068
+ try {
2069
+ native.clear_parse_cache();
2070
+ } catch {
2071
+ }
2072
+ }
2073
+ function clearResolveCache() {
2074
+ const native = getNativeBridge();
2075
+ if (!native?.clear_resolve_cache) return;
2076
+ try {
2077
+ native.clear_resolve_cache();
2078
+ } catch {
2079
+ }
2080
+ }
2081
+ function clearCompileCache() {
2082
+ const native = getNativeBridge();
2083
+ if (!native?.clear_compile_cache) return;
2084
+ try {
2085
+ native.clear_compile_cache();
2086
+ } catch {
2087
+ }
2088
+ }
2089
+ function clearCssGenCache() {
2090
+ const native = getNativeBridge();
2091
+ if (!native?.clear_css_gen_cache) return;
2092
+ try {
2093
+ native.clear_css_gen_cache();
2094
+ } catch {
2095
+ }
2096
+ }
2097
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
2098
+ const native = getNativeBridge();
2099
+ if (!native?.get_cache_optimization_hints)
2100
+ throw new Error("get_cache_optimization_hints not available");
2101
+ const hintsJson = native.get_cache_optimization_hints(
2102
+ Math.min(100, Math.max(0, hitRatePercent)),
2103
+ Math.max(1, memoryUsedMb)
2104
+ );
2105
+ try {
2106
+ return JSON.parse(hintsJson);
2107
+ } catch {
2108
+ return {
2109
+ current_strategy: "unknown",
2110
+ recommended_strategy: "increase_size",
2111
+ estimated_improvement_percent: 0,
2112
+ suggested_memory_mb: 256,
2113
+ notes: ["Unable to analyze cache statistics"]
2114
+ };
2115
+ }
2116
+ }
2117
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
2118
+ const native = getNativeBridge();
2119
+ if (!native?.estimate_optimal_cache_config_native)
2120
+ throw new Error("estimate_optimal_cache_config_native not available");
2121
+ const configJson = native.estimate_optimal_cache_config_native(
2122
+ Math.max(64, totalBudgetMb),
2123
+ workloadType
2124
+ );
2125
+ try {
2126
+ return JSON.parse(configJson);
2127
+ } catch {
2128
+ return {
2129
+ parse_cache_size: 128,
2130
+ resolve_cache_size: 64,
2131
+ compile_cache_size: 256,
2132
+ css_gen_cache_size: 128,
2133
+ recommended_eviction_policy: "lru",
2134
+ ttl_seconds: 3600,
2135
+ expected_hit_rate_percent: 75
2136
+ };
2137
+ }
2138
+ }
2139
+ function cacheRead(cachePath) {
2140
+ const native = getNativeBridge();
2141
+ if (!native?.cache_read) throw new Error("cache_read not available");
2142
+ const result = native.cache_read(cachePath);
2143
+ try {
2144
+ return JSON.parse(result.entries_json || "[]");
2145
+ } catch {
2146
+ return [];
2147
+ }
2148
+ }
2149
+ function cacheWrite(cachePath, entries) {
2150
+ const native = getNativeBridge();
2151
+ if (!native?.cache_write) throw new Error("cache_write not available");
2152
+ try {
2153
+ const result = native.cache_write(
2154
+ cachePath,
2155
+ entries.map((e) => ({
2156
+ file: e.file,
2157
+ content_hash: e.contentHash,
2158
+ classes: e.classes,
2159
+ mtime_ms: e.mtimeMs,
2160
+ size_bytes: e.sizeBytes
2161
+ }))
2162
+ );
2163
+ return typeof result === "boolean" ? result : result === true;
2164
+ } catch {
2165
+ return false;
2166
+ }
2167
+ }
2168
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
2169
+ const native = getNativeBridge();
2170
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
2171
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
2172
+ }
2173
+ var init_cacheNative = __esm({
2174
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
2175
+ init_nativeBridge();
2176
+ }
2177
+ });
2178
+
2179
+ // packages/domain/compiler/src/cache/index.ts
2180
+ var init_cache = __esm({
2181
+ "packages/domain/compiler/src/cache/index.ts"() {
2182
+ init_cacheNative();
2183
+ }
2184
+ });
2185
+
2186
+ // packages/domain/compiler/src/redis/redisNative.ts
2187
+ function redisPing() {
2188
+ const native = getNativeBridge();
2189
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
2190
+ return native.redis_ping();
2191
+ }
2192
+ function redisGet(key) {
2193
+ const native = getNativeBridge();
2194
+ if (!native?.redis_get) throw new Error("redis_get not available");
2195
+ const result = native.redis_get(key);
2196
+ return result === "nil" ? null : result;
2197
+ }
2198
+ function redisSet(key, value, ttl_seconds) {
2199
+ const native = getNativeBridge();
2200
+ if (!native?.redis_set) throw new Error("redis_set not available");
2201
+ return native.redis_set(key, value, ttl_seconds);
2202
+ }
2203
+ function redisDelete(key) {
2204
+ const native = getNativeBridge();
2205
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
2206
+ return native.redis_delete(key);
2207
+ }
2208
+ function redisExists(key) {
2209
+ const native = getNativeBridge();
2210
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
2211
+ return native.redis_exists(key);
2212
+ }
2213
+ function redisMget(keys) {
2214
+ const native = getNativeBridge();
2215
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
2216
+ const result = native.redis_mget(keys);
2217
+ try {
2218
+ return JSON.parse(result);
2219
+ } catch {
2220
+ return keys.map(() => null);
2221
+ }
2222
+ }
2223
+ function redisMset(pairs) {
2224
+ const native = getNativeBridge();
2225
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
2226
+ return native.redis_mset(pairs);
2227
+ }
2228
+ function redisFlushDb() {
2229
+ const native = getNativeBridge();
2230
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
2231
+ return native.redis_flush_db();
2232
+ }
2233
+ function redisFlushAll() {
2234
+ const native = getNativeBridge();
2235
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
2236
+ return native.redis_flush_all();
2237
+ }
2238
+ function redisPoolConnect(host, port, pool_size) {
2239
+ const native = getNativeBridge();
2240
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
2241
+ return native.redis_pool_connect(host, port, pool_size);
2242
+ }
2243
+ function redisPoolStats() {
2244
+ const native = getNativeBridge();
2245
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
2246
+ const result = native.redis_pool_stats();
2247
+ try {
2248
+ return JSON.parse(result);
2249
+ } catch {
2250
+ return {
2251
+ connected_count: 0,
2252
+ idle_count: 0,
2253
+ waiting_count: 0,
2254
+ total_requests: 0,
2255
+ total_errors: 0
2256
+ };
2257
+ }
2258
+ }
2259
+ function redisPoolReconnect() {
2260
+ const native = getNativeBridge();
2261
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
2262
+ return native.redis_pool_reconnect();
2263
+ }
2264
+ function redisEnableCluster(initial_nodes) {
2265
+ const native = getNativeBridge();
2266
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
2267
+ const result = native.redis_enable_cluster(initial_nodes);
2268
+ try {
2269
+ return JSON.parse(result);
2270
+ } catch {
2271
+ return {
2272
+ enabled: false,
2273
+ cluster_state: "error",
2274
+ nodes: [],
2275
+ slots_assigned: 0,
2276
+ slots_ok: 0,
2277
+ slots_fail: 0
2278
+ };
2279
+ }
2280
+ }
2281
+ function redisDisableCluster() {
2282
+ const native = getNativeBridge();
2283
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
2284
+ return native.redis_disable_cluster();
2285
+ }
2286
+ function redisClusterStatus() {
2287
+ const native = getNativeBridge();
2288
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
2289
+ const result = native.redis_cluster_status();
2290
+ try {
2291
+ return JSON.parse(result);
2292
+ } catch {
2293
+ return {
2294
+ enabled: false,
2295
+ cluster_state: "unknown",
2296
+ nodes: [],
2297
+ slots_assigned: 0,
2298
+ slots_ok: 0,
2299
+ slots_fail: 0
2300
+ };
2301
+ }
2302
+ }
2303
+ function redisSubscribe(channel) {
2304
+ const native = getNativeBridge();
2305
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
2306
+ return native.redis_subscribe(channel);
2307
+ }
2308
+ function redisPublish(channel, message) {
2309
+ const native = getNativeBridge();
2310
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
2311
+ return native.redis_publish(channel, message);
2312
+ }
2313
+ function redisExpirationSet(key, ttl_seconds) {
2314
+ const native = getNativeBridge();
2315
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
2316
+ return native.redis_expiration_set(key, ttl_seconds);
2317
+ }
2318
+ function redisExpirationGet(key) {
2319
+ const native = getNativeBridge();
2320
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
2321
+ const result = native.redis_expiration_get(key);
2322
+ try {
2323
+ return JSON.parse(result);
2324
+ } catch {
2325
+ return {
2326
+ key,
2327
+ ttl_seconds: -1,
2328
+ expiration_timestamp: 0,
2329
+ is_persistent: true
2330
+ };
2331
+ }
2332
+ }
2333
+ function redisInfo() {
2334
+ const native = getNativeBridge();
2335
+ if (!native?.redis_info) throw new Error("redis_info not available");
2336
+ return native.redis_info();
2337
+ }
2338
+ function redisMonitor() {
2339
+ const native = getNativeBridge();
2340
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
2341
+ return native.redis_monitor();
2342
+ }
2343
+ function redisCacheSize() {
2344
+ const native = getNativeBridge();
2345
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
2346
+ return native.redis_cache_size();
2347
+ }
2348
+ function redisCacheKeyCount() {
2349
+ const native = getNativeBridge();
2350
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
2351
+ return native.redis_cache_key_count();
2352
+ }
2353
+ function redisCacheClear() {
2354
+ const native = getNativeBridge();
2355
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
2356
+ return native.redis_cache_clear();
2357
+ }
2358
+ function redisCacheHitRate() {
2359
+ const native = getNativeBridge();
2360
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
2361
+ return native.redis_cache_hit_rate();
2362
+ }
2363
+ function redisEnablePersistence(mode) {
2364
+ const native = getNativeBridge();
2365
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
2366
+ return native.redis_enable_persistence(mode);
2367
+ }
2368
+ function redisDisablePersistence() {
2369
+ const native = getNativeBridge();
2370
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
2371
+ return native.redis_disable_persistence();
2372
+ }
2373
+ function redisSnapshot() {
2374
+ const native = getNativeBridge();
2375
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
2376
+ return native.redis_snapshot();
2377
+ }
2378
+ function redisMemoryStats() {
2379
+ const native = getNativeBridge();
2380
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
2381
+ return native.redis_memory_stats();
2382
+ }
2383
+ function redisOptimizeMemory() {
2384
+ const native = getNativeBridge();
2385
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
2386
+ return native.redis_optimize_memory();
2387
+ }
2388
+ function redisSetEvictionPolicy(policy) {
2389
+ const native = getNativeBridge();
2390
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
2391
+ return native.redis_set_eviction_policy(policy);
2392
+ }
2393
+ function redisGetEvictionPolicy() {
2394
+ const native = getNativeBridge();
2395
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
2396
+ return native.redis_get_eviction_policy();
2397
+ }
2398
+ function redisReplicate(target_host, target_port) {
2399
+ const native = getNativeBridge();
2400
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
2401
+ return native.redis_replicate(target_host, target_port);
2402
+ }
2403
+ function redisReplicationStatus() {
2404
+ const native = getNativeBridge();
2405
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
2406
+ return native.redis_replication_status();
2407
+ }
2408
+ function redisCacheSync(peers) {
2409
+ const native = getNativeBridge();
2410
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
2411
+ return native.redis_cache_sync(peers);
2412
+ }
2413
+ function redisEnableCacheWarming(key_pattern) {
2414
+ const native = getNativeBridge();
2415
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
2416
+ return native.redis_enable_cache_warming(key_pattern);
2417
+ }
2418
+ function redisDisableCacheWarming() {
2419
+ const native = getNativeBridge();
2420
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
2421
+ return native.redis_disable_cache_warming();
2422
+ }
2423
+ function redisDiagnose() {
2424
+ const native = getNativeBridge();
2425
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
2426
+ return native.redis_diagnose();
2427
+ }
2428
+ var init_redisNative = __esm({
2429
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
2430
+ init_nativeBridge();
2431
+ }
2432
+ });
2433
+
2434
+ // packages/domain/compiler/src/redis/index.ts
2435
+ var init_redis = __esm({
2436
+ "packages/domain/compiler/src/redis/index.ts"() {
2437
+ init_redisNative();
2438
+ }
2439
+ });
2440
+
2441
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
2442
+ function startWatch(root_path, patterns) {
2443
+ const native = getNativeBridge();
2444
+ if (!native?.start_watch) throw new Error("start_watch not available");
2445
+ return native.start_watch(root_path, patterns);
2446
+ }
2447
+ function pollWatchEvents(handle, timeout_ms) {
2448
+ const native = getNativeBridge();
2449
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
2450
+ const result = native.poll_watch_events(handle, timeout_ms);
2451
+ try {
2452
+ return JSON.parse(result);
2453
+ } catch {
2454
+ return [];
2455
+ }
2456
+ }
2457
+ function stopWatch(handle) {
2458
+ const native = getNativeBridge();
2459
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
2460
+ return native.stop_watch(handle);
2461
+ }
2462
+ function watchAddPattern(handle, pattern) {
2463
+ const native = getNativeBridge();
2464
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
2465
+ return native.watch_add_pattern(handle, pattern);
2466
+ }
2467
+ function watchRemovePattern(handle, pattern) {
2468
+ const native = getNativeBridge();
2469
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
2470
+ return native.watch_remove_pattern(handle, pattern);
2471
+ }
2472
+ function watchGetActiveHandles() {
2473
+ const native = getNativeBridge();
2474
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
2475
+ const result = native.watch_get_active_handles();
2476
+ try {
2477
+ return JSON.parse(result);
2478
+ } catch {
2479
+ return [];
2480
+ }
2481
+ }
2482
+ function watchClearAll() {
2483
+ const native = getNativeBridge();
2484
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
2485
+ return native.watch_clear_all();
2486
+ }
2487
+ function watchEventTypeToString(event_type_code) {
2488
+ const native = getNativeBridge();
2489
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
2490
+ return native.watch_event_type_to_string(event_type_code);
2491
+ }
2492
+ function isWatchRunning(handle) {
2493
+ const native = getNativeBridge();
2494
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
2495
+ return native.is_watch_running(handle);
2496
+ }
2497
+ function getWatchStats() {
2498
+ const native = getNativeBridge();
2499
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
2500
+ const result = native.get_watch_stats();
2501
+ try {
2502
+ return JSON.parse(result);
2503
+ } catch {
2504
+ return {
2505
+ active_watchers: 0,
2506
+ total_events: 0,
2507
+ events_this_second: 0,
2508
+ average_latency_ms: 0,
2509
+ largest_batch_size: 0
2510
+ };
2511
+ }
2512
+ }
2513
+ function watchPause(handle) {
2514
+ const native = getNativeBridge();
2515
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
2516
+ return native.watch_pause(handle);
2517
+ }
2518
+ function watchResume(handle) {
2519
+ const native = getNativeBridge();
2520
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
2521
+ return native.watch_resume(handle);
2522
+ }
2523
+ function scanCacheOptimizations() {
2524
+ const native = getNativeBridge();
2525
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
2526
+ return native.scan_cache_optimizations();
2527
+ }
2528
+ function getPluginHooks() {
2529
+ const native = getNativeBridge();
2530
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
2531
+ const result = native.get_plugin_hooks();
2532
+ try {
2533
+ return JSON.parse(result);
2534
+ } catch {
2535
+ return [];
2536
+ }
2537
+ }
2538
+ function registerPluginHook(hook_name, handler_id) {
2539
+ const native = getNativeBridge();
2540
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
2541
+ return native.register_plugin_hook(hook_name, handler_id);
2542
+ }
2543
+ function unregisterPluginHook(hook_name, handler_id) {
2544
+ const native = getNativeBridge();
2545
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
2546
+ return native.unregister_plugin_hook(hook_name, handler_id);
2547
+ }
2548
+ function emitPluginHook(hook_name, data_json) {
2549
+ const native = getNativeBridge();
2550
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
2551
+ return native.emit_plugin_hook(hook_name, data_json);
2552
+ }
2553
+ function getCompilationMetrics() {
2554
+ const native = getNativeBridge();
2555
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
2556
+ return native.get_compilation_metrics();
2557
+ }
2558
+ function resetCompilationMetrics() {
2559
+ const native = getNativeBridge();
2560
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
2561
+ return native.reset_compilation_metrics();
2562
+ }
2563
+ function validateCssOutput(css) {
2564
+ const native = getNativeBridge();
2565
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
2566
+ return native.validate_css_output(css);
2567
+ }
2568
+ function getCompilerDiagnostics() {
2569
+ const native = getNativeBridge();
2570
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
2571
+ return native.get_compiler_diagnostics();
2572
+ }
2573
+ var init_watchSystemNative = __esm({
2574
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
2575
+ init_nativeBridge();
2576
+ }
2577
+ });
2578
+
2579
+ // packages/domain/compiler/src/watch/index.ts
2580
+ var init_watch = __esm({
2581
+ "packages/domain/compiler/src/watch/index.ts"() {
2582
+ init_watchSystemNative();
2583
+ }
2584
+ });
2585
+ function _layoutClassesToCss(classes) {
2586
+ const native = getNativeBridge();
2587
+ if (!native?.layoutClassesToCss) {
2588
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
2589
+ }
2590
+ return native.layoutClassesToCss(classes);
2591
+ }
2592
+ function _hashContainer(tag, containerJson, name) {
2593
+ const sortedKey = tag + (name ?? "") + containerJson;
2594
+ const native = getNativeBridge();
2595
+ if (!native?.hashContent) {
2596
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
2597
+ }
2598
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
2599
+ }
2600
+ function extractContainerCssFromSource(source) {
2601
+ const native = getNativeBridge();
2602
+ if (!native?.extractTwContainerConfigs) {
2603
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
2604
+ }
2605
+ const configs = native.extractTwContainerConfigs(source);
2606
+ const rules = [];
2607
+ for (const cfg of configs) {
2608
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
2609
+ for (const { key, classes } of cfg.breakpoints) {
2610
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
2611
+ const css = _layoutClassesToCss(classes);
2612
+ if (!css) continue;
2613
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
2614
+ rules.push(`${query}{.${id}{${css}}}`);
2615
+ }
2616
+ }
2617
+ return rules.join("\n");
2618
+ }
2619
+ 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;
2620
+ var init_src = __esm({
2621
+ "packages/domain/compiler/src/index.ts"() {
2622
+ init_nativeBridge();
2623
+ init_compiler();
2624
+ init_parser();
2625
+ init_analyzer();
2626
+ init_cache();
2627
+ init_redis();
2628
+ init_watch();
2629
+ transformSource = (source, opts) => {
2630
+ const native = getNativeBridge();
2631
+ if (!native?.transformSource) {
2632
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2633
+ }
2634
+ const result = native.transformSource(source, opts);
2635
+ if (!result) {
2636
+ throw new Error("FATAL: transformSource returned null");
2637
+ }
2638
+ return result;
2639
+ };
2640
+ hasTwUsage = (source) => {
2641
+ const native = getNativeBridge();
2642
+ if (!native?.hasTwUsage) {
2643
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
2644
+ }
2645
+ return native.hasTwUsage(source);
2646
+ };
2647
+ isAlreadyTransformed = (source) => {
2648
+ const native = getNativeBridge();
2649
+ if (!native?.isAlreadyTransformed) {
2650
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
2651
+ }
2652
+ return native.isAlreadyTransformed(source);
2653
+ };
2654
+ shouldProcess = (source) => {
2655
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
2656
+ };
2657
+ compileCssFromClasses = (classes, prefix) => {
2658
+ const native = getNativeBridge();
2659
+ if (!native?.transformSource) {
2660
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2661
+ }
2662
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
2663
+ if (!result) {
2664
+ throw new Error("FATAL: transformSource returned null");
2665
+ }
2666
+ return result;
2667
+ };
2668
+ buildStyleTag = (classes) => {
2669
+ const result = compileCssFromClasses(classes);
2670
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2671
+ };
2672
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2673
+ try {
2674
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2675
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2676
+ return result.css;
2677
+ } catch {
2678
+ const native = getNativeBridge();
2679
+ if (!native?.transformSource) {
2680
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2681
+ }
2682
+ const result = native.transformSource(classes.join(" "), {});
2683
+ return result?.code || "";
2684
+ }
2685
+ };
2686
+ eliminateDeadCss = (css, deadClasses) => {
2687
+ const native = getNativeBridge();
2688
+ if (!native?.eliminateDeadCss) {
2689
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
2690
+ }
2691
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
2692
+ };
2693
+ findDeadVariants = (variantConfig, usage) => {
2694
+ const unused = [];
2695
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
2696
+ for (const component of configs) {
2697
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
2698
+ const variants = component.variants;
2699
+ for (const [key, values] of Object.entries(variants)) {
2700
+ for (const [value] of Object.entries(values)) {
2701
+ if (!componentUsage.has(`${key}:${value}`)) {
2702
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
2703
+ }
2704
+ }
2705
+ }
2706
+ }
2707
+ return { unusedCount: unused.length, unused };
2708
+ };
2709
+ runElimination = (css, scanResult) => {
2710
+ const native = getNativeBridge();
2711
+ if (!native?.detectDeadCode) {
2712
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
2713
+ }
2714
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2715
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2716
+ };
2717
+ scanProjectUsage = (dirs, cwd) => {
2718
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2719
+ const files = dirs.map((dir) => path9__default.resolve(cwd, dir));
2720
+ const results = batchExtractClasses2(files) || [];
2721
+ const combined = {};
2722
+ for (const result of results) {
2723
+ if (result.ok && result.classes) {
2724
+ for (const cls of result.classes) {
2725
+ if (!combined[cls]) combined[cls] = {};
2726
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
2727
+ }
2728
+ }
2729
+ }
2730
+ return combined;
2731
+ };
2732
+ generateSafelist = (scanDirs, outputPath, cwd) => {
2733
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2734
+ const allClasses = Object.keys(classes).sort();
2735
+ if (outputPath) {
2736
+ fs3__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2737
+ }
2738
+ return allClasses;
2739
+ };
2740
+ loadSafelist = (safelistPath) => {
2741
+ try {
2742
+ const content = fs3__default.readFileSync(safelistPath, "utf-8");
2743
+ return JSON.parse(content);
2744
+ } catch {
2745
+ return [];
2746
+ }
2747
+ };
2748
+ loadTailwindConfig = (cwd = process.cwd()) => {
2749
+ const configFiles = [
2750
+ "tailwind.config.ts",
2751
+ "tailwind.config.js",
2752
+ "tailwind.config.mjs",
2753
+ "tailwind.config.cjs"
2754
+ ];
2755
+ for (const file of configFiles) {
2756
+ const fullPath = path9__default.join(cwd, file);
2757
+ if (fs3__default.existsSync(fullPath)) {
2758
+ const mod = __require(fullPath);
2759
+ return mod.default || mod;
2760
+ }
2761
+ }
2762
+ return {};
2763
+ };
2764
+ getContentPaths = (cwd = process.cwd()) => {
2765
+ return {
2766
+ content: [
2767
+ path9__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2768
+ path9__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2769
+ path9__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2770
+ ]
2771
+ };
2772
+ };
2773
+ _CONTAINER_BREAKPOINTS = {
2774
+ xs: "240px",
2775
+ sm: "320px",
2776
+ md: "640px",
2777
+ lg: "1024px",
2778
+ xl: "1280px",
2779
+ "2xl": "1536px"
2780
+ };
2781
+ runLoaderTransform = (ctx) => {
2782
+ const { filepath, source, options } = ctx;
2783
+ const result = transformSource(source, { filename: filepath, ...options });
2784
+ let staticCss;
2785
+ try {
2786
+ const cssChunks = [];
2787
+ const stateRules = extractAndGenerateStateCss(source, filepath);
2788
+ if (stateRules.length > 0) {
2789
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
2790
+ }
2791
+ const containerCss = extractContainerCssFromSource(source);
2792
+ if (containerCss) cssChunks.push(containerCss);
2793
+ const combined = cssChunks.join("\n").trim();
2794
+ if (combined) staticCss = combined;
2795
+ } catch (err) {
2796
+ console.debug("Static CSS extraction warning:", err);
2797
+ }
2798
+ return {
2799
+ code: result?.code || "",
2800
+ changed: result?.changed || false,
2801
+ classes: result?.classes || [],
2802
+ staticCss
2803
+ };
2804
+ };
2805
+ shouldSkipFile = (filepath) => {
2806
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
2807
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
2808
+ for (const p of SKIP_PATHS) {
2809
+ if (filepath.includes(p)) return true;
2810
+ }
2811
+ for (const ext of skipExtensions) {
2812
+ if (filepath.endsWith(ext)) return true;
2813
+ }
2814
+ return false;
2815
+ };
2816
+ fileToRoute = (filepath) => {
2817
+ const normalized = filepath.replace(/\\/g, "/");
2818
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
2819
+ return "__global";
2820
+ }
2821
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
2822
+ if (pageMatch) return `/${pageMatch[1]}`;
2823
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
2824
+ if (rootPage) return "/";
2825
+ return null;
2826
+ };
2827
+ getAllRoutes = () => {
2828
+ const native = getNativeBridge();
2829
+ if (!native?.analyzeClasses) {
2830
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2831
+ }
2832
+ return ["/", "__global"];
2833
+ };
2834
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
2835
+ registerFileClasses = (_filepath, _classes) => {
2836
+ };
2837
+ registerGlobalClasses = (_classes) => {
2838
+ };
2839
+ _incrementalEngineInstance = null;
2840
+ getIncrementalEngine = () => {
2841
+ if (!_incrementalEngineInstance) {
2842
+ _incrementalEngineInstance = new IncrementalEngine();
2843
+ }
2844
+ return _incrementalEngineInstance;
2845
+ };
2846
+ resetIncrementalEngine = () => {
2847
+ _incrementalEngineInstance = null;
2848
+ };
2849
+ IncrementalEngine = class {
2850
+ compile(source) {
2851
+ return transformSource(source);
2852
+ }
2853
+ };
2854
+ getBucketEngine = () => {
2855
+ const native = getNativeBridge();
2856
+ if (!native?.classifyAndSortClasses) {
2857
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2858
+ }
2859
+ return {
2860
+ add: (className) => className,
2861
+ get: (_bucket) => []
2862
+ };
2863
+ };
2864
+ resetBucketEngine = () => {
2865
+ };
2866
+ classifyNode = (_node) => {
2867
+ const native = getNativeBridge();
2868
+ if (!native?.classifyAndSortClasses) {
2869
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2870
+ }
2871
+ return "unknown";
2872
+ };
2873
+ detectConflicts = (_classes) => {
2874
+ const native = getNativeBridge();
2875
+ if (!native?.analyzeClassUsage) {
2876
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2877
+ }
2878
+ return [];
2879
+ };
2880
+ bucketSort = (classes) => {
2881
+ const native = getNativeBridge();
2882
+ if (!native?.classifyAndSortClasses) {
2883
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2884
+ }
2885
+ const sorted = native.classifyAndSortClasses(classes);
2886
+ return sorted.map((c) => c.raw ?? c);
2887
+ };
2888
+ analyzeFile = (source, filename) => {
2889
+ const native = getNativeBridge();
2890
+ if (!native?.analyzeRsc) {
2891
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2892
+ }
2893
+ const rsc = native.analyzeRsc(source, filename);
2894
+ return {
2895
+ isServer: rsc?.isServer ?? true,
2896
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2897
+ clientReasons: rsc?.clientReasons ?? [],
2898
+ interactiveClasses: [],
2899
+ canStaticResolveVariants: true
2900
+ };
2901
+ };
2902
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2903
+ return { resolved: {}, dynamic: [] };
2904
+ };
2905
+ injectClientDirective = (source) => {
2906
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2907
+ return '"use client";\n' + source;
2908
+ }
2909
+ return source;
2910
+ };
2911
+ injectServerOnlyComment = (source) => {
2912
+ return `/* @server-only */
2913
+ ${source}`;
2914
+ };
2915
+ analyzeClasses = (filesJson, cwd, flags) => {
2916
+ const native = getNativeBridge();
2917
+ if (!native?.analyzeClasses) {
2918
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2919
+ }
2920
+ return native.analyzeClasses(filesJson, cwd, flags);
2921
+ };
2922
+ extractTwStateConfigs = (source, filename) => {
2923
+ const native = getNativeBridge();
2924
+ if (!native?.extractTwStateConfigs) {
2925
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
2926
+ }
2927
+ return native.extractTwStateConfigs(source, filename);
2928
+ };
2929
+ generateStaticStateCss = (entries, _themeConfig) => {
2930
+ const rules = [];
2931
+ for (const entry of entries) {
2932
+ const stateConfig = JSON.parse(entry.statesJson);
2933
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2934
+ rules.push({
2935
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2936
+ declarations: classes,
2937
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2938
+ componentName: entry.componentName,
2939
+ stateName
2940
+ });
2941
+ }
2942
+ }
2943
+ return rules;
2944
+ };
2945
+ extractAndGenerateStateCss = (source, filename) => {
2946
+ const entries = extractTwStateConfigs(source, filename);
2947
+ return generateStaticStateCss(entries);
2948
+ };
2949
+ }
2950
+ });
2951
+
2952
+ // packages/domain/compiler/src/internal.ts
2953
+ var internal_exports = {};
2954
+ __export(internal_exports, {
2955
+ adaptNativeResult: () => adaptNativeResult,
2956
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
2957
+ analyzeClasses: () => analyzeClasses,
2958
+ analyzeClassesNative: () => analyzeClassesNative,
2959
+ analyzeFile: () => analyzeFile,
2960
+ analyzeRscNative: () => analyzeRscNative,
2961
+ analyzeVariantUsage: () => analyzeVariantUsage,
2962
+ astExtractClasses: () => astExtractClasses,
2963
+ atomicRegistrySize: () => atomicRegistrySize,
2964
+ batchExtractClasses: () => batchExtractClasses,
2965
+ batchExtractClassesNative: () => batchExtractClassesNative,
2966
+ bucketSort: () => bucketSort,
2967
+ buildStyleTag: () => buildStyleTag,
2968
+ cachePriority: () => cachePriority,
2969
+ cacheRead: () => cacheRead,
2970
+ cacheWrite: () => cacheWrite,
2971
+ checkAgainstSafelist: () => checkAgainstSafelist,
2972
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2973
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
2974
+ classifyNode: () => classifyNode,
2975
+ clearAllCaches: () => clearAllCaches,
2976
+ clearAtomicRegistry: () => clearAtomicRegistry,
2977
+ clearCache: () => clearCache,
2978
+ clearCompileCache: () => clearCompileCache,
2979
+ clearCssGenCache: () => clearCssGenCache,
2980
+ clearParseCache: () => clearParseCache,
2981
+ clearResolveCache: () => clearResolveCache,
2982
+ clearThemeCache: () => clearThemeCache,
2983
+ collectFiles: () => collectFiles,
2984
+ compileAnimation: () => compileAnimation,
2985
+ compileClass: () => compileClass,
2986
+ compileClasses: () => compileClasses,
2987
+ compileCssFromClasses: () => compileCssFromClasses,
2988
+ compileCssLightning: () => compileCssLightning,
2989
+ compileCssNative2: () => compileCssNative2,
2990
+ compileKeyframes: () => compileKeyframes,
2991
+ compileTheme: () => compileTheme,
2992
+ compileToCss: () => compileToCss,
2993
+ compileToCssBatch: () => compileToCssBatch,
2994
+ compileVariantTableNative: () => compileVariantTableNative,
2995
+ computeIncrementalDiff: () => computeIncrementalDiff,
2996
+ createFingerprint: () => createFingerprint,
2997
+ detectConflicts: () => detectConflicts,
2998
+ detectDeadCode: () => detectDeadCode,
2999
+ diffClassLists: () => diffClassLists,
3000
+ eliminateDeadCss: () => eliminateDeadCss,
3001
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
3002
+ emitPluginHook: () => emitPluginHook,
3003
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
3004
+ extractAllClasses: () => extractAllClasses,
3005
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
3006
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
3007
+ extractClassesFromSource: () => extractClassesFromSource,
3008
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
3009
+ extractComponentUsage: () => extractComponentUsage,
3010
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
3011
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
3012
+ extractTwStateConfigs: () => extractTwStateConfigs,
3013
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
3014
+ fileToRoute: () => fileToRoute,
3015
+ findDeadVariants: () => findDeadVariants,
3016
+ generateAtomicCss: () => generateAtomicCss,
3017
+ generateCssForClasses: () => generateCssForClasses,
3018
+ generateCssNative: () => generateCssNative,
3019
+ generateSafelist: () => generateSafelist,
3020
+ generateStaticStateCss: () => generateStaticStateCss,
3021
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
3022
+ generateSubComponentTypes: () => generateSubComponentTypes,
3023
+ getAllRoutes: () => getAllRoutes,
3024
+ getBucketEngine: () => getBucketEngine,
3025
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
3026
+ getCacheStatistics: () => getCacheStatistics,
3027
+ getCacheStats: () => getCacheStats,
3028
+ getCompilationMetrics: () => getCompilationMetrics,
3029
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
3030
+ getContentPaths: () => getContentPaths,
3031
+ getIncrementalEngine: () => getIncrementalEngine,
3032
+ getNativeBridge: () => getNativeBridge,
3033
+ getPluginHooks: () => getPluginHooks,
3034
+ getRouteClasses: () => getRouteClasses,
3035
+ getWatchStats: () => getWatchStats,
3036
+ hasTwUsage: () => hasTwUsage,
3037
+ hashContent: () => hashContent,
3038
+ hoistComponentsNative: () => hoistComponentsNative,
3039
+ idRegistryActiveCount: () => idRegistryActiveCount,
3040
+ idRegistryCreate: () => idRegistryCreate,
3041
+ idRegistryDestroy: () => idRegistryDestroy,
3042
+ idRegistryExport: () => idRegistryExport,
3043
+ idRegistryGenerate: () => idRegistryGenerate,
3044
+ idRegistryImport: () => idRegistryImport,
3045
+ idRegistryLookup: () => idRegistryLookup,
3046
+ idRegistryNext: () => idRegistryNext,
3047
+ idRegistryReset: () => idRegistryReset,
3048
+ idRegistrySnapshot: () => idRegistrySnapshot,
3049
+ injectClientDirective: () => injectClientDirective,
3050
+ injectServerOnlyComment: () => injectServerOnlyComment,
3051
+ injectStateHash: () => injectStateHash,
3052
+ isAlreadyTransformed: () => isAlreadyTransformed,
3053
+ isWatchRunning: () => isWatchRunning,
3054
+ layoutClassesToCss: () => layoutClassesToCss,
3055
+ loadSafelist: () => loadSafelist,
3056
+ loadTailwindConfig: () => loadTailwindConfig,
3057
+ mergeClassesStatic: () => mergeClassesStatic,
3058
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
3059
+ minifyCss: () => minifyCss,
3060
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
3061
+ normalizeClasses: () => normalizeClasses,
3062
+ optimizeCssNative: () => optimizeCssNative,
3063
+ parseAtomicClass: () => parseAtomicClass,
3064
+ parseClasses: () => parseClasses,
3065
+ pollWatchEvents: () => pollWatchEvents,
3066
+ processFileChange: () => processFileChange,
3067
+ processTailwindCssLightning: () => processTailwindCssLightning,
3068
+ propertyIdToString: () => propertyIdToString,
3069
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
3070
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
3071
+ redisCacheClear: () => redisCacheClear,
3072
+ redisCacheHitRate: () => redisCacheHitRate,
3073
+ redisCacheKeyCount: () => redisCacheKeyCount,
3074
+ redisCacheSize: () => redisCacheSize,
3075
+ redisCacheSync: () => redisCacheSync,
3076
+ redisClusterStatus: () => redisClusterStatus,
3077
+ redisDelete: () => redisDelete,
3078
+ redisDiagnose: () => redisDiagnose,
3079
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
3080
+ redisDisableCluster: () => redisDisableCluster,
3081
+ redisDisablePersistence: () => redisDisablePersistence,
3082
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
3083
+ redisEnableCluster: () => redisEnableCluster,
3084
+ redisEnablePersistence: () => redisEnablePersistence,
3085
+ redisExists: () => redisExists,
3086
+ redisExpirationGet: () => redisExpirationGet,
3087
+ redisExpirationSet: () => redisExpirationSet,
3088
+ redisFlushAll: () => redisFlushAll,
3089
+ redisFlushDb: () => redisFlushDb,
3090
+ redisGet: () => redisGet,
3091
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
3092
+ redisInfo: () => redisInfo,
3093
+ redisMemoryStats: () => redisMemoryStats,
3094
+ redisMget: () => redisMget,
3095
+ redisMonitor: () => redisMonitor,
3096
+ redisMset: () => redisMset,
3097
+ redisOptimizeMemory: () => redisOptimizeMemory,
3098
+ redisPing: () => redisPing,
3099
+ redisPoolConnect: () => redisPoolConnect,
3100
+ redisPoolReconnect: () => redisPoolReconnect,
3101
+ redisPoolStats: () => redisPoolStats,
3102
+ redisPublish: () => redisPublish,
3103
+ redisReplicate: () => redisReplicate,
3104
+ redisReplicationStatus: () => redisReplicationStatus,
3105
+ redisSet: () => redisSet,
3106
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
3107
+ redisSnapshot: () => redisSnapshot,
3108
+ redisSubscribe: () => redisSubscribe,
3109
+ registerFileClasses: () => registerFileClasses,
3110
+ registerGlobalClasses: () => registerGlobalClasses,
3111
+ registerPluginHook: () => registerPluginHook,
3112
+ registerPropertyName: () => registerPropertyName,
3113
+ registerValueName: () => registerValueName,
3114
+ resetBucketEngine: () => resetBucketEngine,
3115
+ resetCompilationMetrics: () => resetCompilationMetrics,
3116
+ resetIncrementalEngine: () => resetIncrementalEngine,
3117
+ resolveCascade: () => resolveCascade,
3118
+ resolveClassNames: () => resolveClassNames,
3119
+ resolveConflictGroup: () => resolveConflictGroup,
3120
+ resolveSimpleVariants: () => resolveSimpleVariants,
3121
+ resolveThemeValue: () => resolveThemeValue,
3122
+ resolveVariants: () => resolveVariants,
3123
+ reverseLookupProperty: () => reverseLookupProperty,
3124
+ reverseLookupValue: () => reverseLookupValue,
3125
+ runCssPipeline: () => runCssPipeline,
3126
+ runCssPipelineSync: () => runCssPipelineSync,
3127
+ runElimination: () => runElimination,
3128
+ runLoaderTransform: () => runLoaderTransform,
3129
+ scanCacheOptimizations: () => scanCacheOptimizations,
3130
+ scanFile: () => scanFile,
3131
+ scanFileNative: () => scanFileNative,
3132
+ scanFilesBatchNative: () => scanFilesBatchNative,
3133
+ scanProjectUsage: () => scanProjectUsage,
3134
+ scanWorkspace: () => scanWorkspace,
3135
+ shouldProcess: () => shouldProcess,
3136
+ shouldSkipFile: () => shouldSkipFile,
3137
+ startWatch: () => startWatch,
3138
+ stopWatch: () => stopWatch,
3139
+ toAtomicClasses: () => toAtomicClasses,
3140
+ transformSource: () => transformSource,
3141
+ twMerge: () => twMerge,
3142
+ twMergeMany: () => twMergeMany,
3143
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
3144
+ twMergeRaw: () => twMergeRaw,
3145
+ twMergeWithSeparator: () => twMergeWithSeparator,
3146
+ unregisterPluginHook: () => unregisterPluginHook,
3147
+ validateCssOutput: () => validateCssOutput,
3148
+ validateThemeConfig: () => validateThemeConfig,
3149
+ valueIdToString: () => valueIdToString,
3150
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
3151
+ watchAddPattern: () => watchAddPattern,
3152
+ watchClearAll: () => watchClearAll,
3153
+ watchEventTypeToString: () => watchEventTypeToString,
3154
+ watchGetActiveHandles: () => watchGetActiveHandles,
3155
+ watchPause: () => watchPause,
3156
+ watchRemovePattern: () => watchRemovePattern,
3157
+ watchResume: () => watchResume
3158
+ });
3159
+ var init_internal = __esm({
3160
+ "packages/domain/compiler/src/internal.ts"() {
3161
+ init_src();
3162
+ init_tailwindEngine();
3163
+ init_compiler();
3164
+ init_parser();
3165
+ init_analyzer();
3166
+ init_cache();
3167
+ init_redis();
3168
+ init_watch();
3169
+ }
3170
+ });
3171
+ function getNative() {
3172
+ if (_native) return _native;
3173
+ try {
3174
+ const mod = (init_internal(), __toCommonJS(internal_exports));
3175
+ if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
3176
+ return null;
3177
+ }
3178
+ _native = {
3179
+ extractTwStateConfigs: mod.extractTwStateConfigs,
3180
+ generateStaticStateCss: mod.generateStaticStateCss,
3181
+ extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
3182
+ ((source, filename) => {
3183
+ const configs = mod.extractTwStateConfigs(source, filename);
3184
+ if (configs.length === 0) return [];
3185
+ return mod.generateStaticStateCss(configs.map((c) => ({
3186
+ tag: c.tag,
3187
+ componentName: c.componentName,
3188
+ statesJson: c.statesJson
3189
+ })));
3190
+ })
3191
+ };
3192
+ return _native;
3193
+ } catch {
3194
+ return null;
3195
+ }
3196
+ }
3197
+ function* walkSourceFiles(dir) {
3198
+ let entries;
3199
+ try {
3200
+ entries = fs3__default.readdirSync(dir, { withFileTypes: true });
3201
+ } catch {
3202
+ return;
3203
+ }
3204
+ for (const entry of entries) {
3205
+ const fullPath = path9__default.join(dir, entry.name);
3206
+ if (entry.isDirectory()) {
3207
+ if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
3208
+ yield* walkSourceFiles(fullPath);
3209
+ } else if (entry.isFile()) {
3210
+ const ext = path9__default.extname(entry.name);
3211
+ if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
3212
+ }
3213
+ }
3214
+ }
3215
+ function buildCssHeader(result) {
3216
+ return [
3217
+ "/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
3218
+ " * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
3219
+ " * DO NOT EDIT. Re-generated on each build.",
3220
+ " *",
3221
+ ` * Files scanned: ${result.filesScanned}`,
3222
+ ` * Files with states: ${result.filesWithStates}`,
3223
+ ` * Components found: ${result.componentsFound}`,
3224
+ ` * Rules generated: ${result.rulesGenerated}`,
3225
+ ` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
3226
+ " *",
3227
+ ' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
3228
+ " * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
3229
+ " * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */",
3230
+ ""
3231
+ ].join("\n");
3232
+ }
3233
+ function extractStaticStateCss(srcDir, options = {}) {
3234
+ const { verbose = false, maxFiles = Infinity } = options;
3235
+ const native = getNative();
3236
+ if (!native) {
3237
+ if (verbose) {
3238
+ process.stderr.write(
3239
+ "[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
3240
+ );
3241
+ }
3242
+ return {
3243
+ filesScanned: 0,
3244
+ filesWithStates: 0,
3245
+ componentsFound: 0,
3246
+ rulesGenerated: 0,
3247
+ rulesSkipped: 0,
3248
+ generatedCss: "",
3249
+ rules: []
3250
+ };
3251
+ }
3252
+ const allConfigs = [];
3253
+ let filesScanned = 0;
3254
+ let filesWithStates = 0;
3255
+ if (native.walkAndPrefilterSourceFiles) {
3256
+ const prefiltered = native.walkAndPrefilterSourceFiles(
3257
+ srcDir,
3258
+ [".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
3259
+ ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
3260
+ // Required substrings — AND logic, identik dengan JS pre-filter di bawah
3261
+ ["states:", "tw."],
3262
+ maxFiles === Infinity ? null : maxFiles,
3263
+ null
3264
+ // sequential — parallel mode opsional untuk large monorepo
3265
+ );
3266
+ for (const { path: filePath, content: source } of prefiltered) {
3267
+ filesScanned++;
3268
+ const configs = native.extractTwStateConfigs(source, filePath);
3269
+ if (configs.length > 0) {
3270
+ filesWithStates++;
3271
+ allConfigs.push(...configs);
3272
+ if (verbose) {
3273
+ process.stderr.write(
3274
+ `[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
3275
+ `
3276
+ );
3277
+ }
3278
+ }
3279
+ }
3280
+ } else {
3281
+ for (const filePath of walkSourceFiles(srcDir)) {
3282
+ if (filesScanned >= maxFiles) break;
3283
+ let source;
3284
+ try {
3285
+ source = fs3__default.readFileSync(filePath, "utf-8");
3286
+ } catch {
3287
+ continue;
3288
+ }
3289
+ filesScanned++;
3290
+ if (!source.includes("states:") && !source.includes("states :")) continue;
3291
+ if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
3292
+ const configs = native.extractTwStateConfigs(source, filePath);
3293
+ if (configs.length > 0) {
3294
+ filesWithStates++;
3295
+ allConfigs.push(...configs);
3296
+ if (verbose) {
3297
+ process.stderr.write(
3298
+ `[tw:static-state] ${path9__default.relative(srcDir, filePath)}: ${configs.length} komponen
3299
+ `
3300
+ );
3301
+ }
3302
+ }
3303
+ }
3304
+ }
3305
+ if (allConfigs.length === 0) {
3306
+ return {
3307
+ filesScanned,
3308
+ filesWithStates: 0,
3309
+ componentsFound: 0,
3310
+ rulesGenerated: 0,
3311
+ rulesSkipped: 0,
3312
+ generatedCss: "",
3313
+ rules: []
3314
+ };
3315
+ }
3316
+ const seen = /* @__PURE__ */ new Set();
3317
+ const uniqueConfigs = [];
3318
+ for (const config of allConfigs) {
3319
+ const key = `${config.tag}::${config.statesJson}`;
3320
+ if (!seen.has(key)) {
3321
+ seen.add(key);
3322
+ uniqueConfigs.push({
3323
+ tag: config.tag,
3324
+ componentName: config.componentName,
3325
+ statesJson: config.statesJson
3326
+ });
3327
+ }
3328
+ }
3329
+ const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
3330
+ const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
3331
+ try {
3332
+ const stateMap = JSON.parse(cfg.statesJson);
3333
+ return total + Object.keys(stateMap).length;
3334
+ } catch {
3335
+ return total;
3336
+ }
3337
+ }, 0) - allRules.length;
3338
+ const byComponent = /* @__PURE__ */ new Map();
3339
+ for (const rule of allRules) {
3340
+ const existing = byComponent.get(rule.componentName) ?? [];
3341
+ existing.push(rule);
3342
+ byComponent.set(rule.componentName, existing);
3343
+ }
3344
+ const cssBlocks = [];
3345
+ for (const [componentName, rules] of byComponent) {
3346
+ cssBlocks.push(`/* ${componentName} */`);
3347
+ for (const rule of rules) {
3348
+ cssBlocks.push(`/* state: ${rule.stateName} */`);
3349
+ cssBlocks.push(rule.cssRule);
3350
+ }
3351
+ cssBlocks.push("");
3352
+ }
3353
+ const result = {
3354
+ filesScanned,
3355
+ filesWithStates,
3356
+ componentsFound: allConfigs.length,
3357
+ rulesGenerated: allRules.length,
3358
+ rulesSkipped: Math.max(0, rulesSkipped),
3359
+ generatedCss: cssBlocks.join("\n"),
3360
+ rules: allRules
3361
+ };
3362
+ result.generatedCss = buildCssHeader(result) + result.generatedCss;
3363
+ return result;
3364
+ }
3365
+ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3366
+ const result = extractStaticStateCss(srcDir, options);
3367
+ const twClassesDir = path9__default.join(path9__default.dirname(safelistPath), "tw-classes");
3368
+ fs3__default.mkdirSync(twClassesDir, { recursive: true });
3369
+ const stateFilePath = path9__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
3370
+ if (result.rulesGenerated === 0) {
3371
+ try {
3372
+ fs3__default.writeFileSync(
3373
+ stateFilePath,
3374
+ "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
3375
+ "utf-8"
3376
+ );
3377
+ } catch {
3378
+ }
3379
+ return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
3380
+ }
3381
+ try {
3382
+ fs3__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3383
+ return [
3384
+ `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
3385
+ ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
3386
+ ` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
3387
+ ` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
3388
+ ].join("\n");
3389
+ } catch (writeErr) {
3390
+ const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
3391
+ return `[tw:static-state] gagal tulis state CSS: ${msg}`;
3392
+ }
3393
+ }
3394
+ var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
3395
+ var init_staticStateExtractor = __esm({
3396
+ "packages/domain/shared/src/staticStateExtractor.ts"() {
3397
+ SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
3398
+ IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
3399
+ _native = null;
3400
+ TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
3401
+ }
3402
+ });
3403
+ function getEnvLevel() {
3404
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
3405
+ if (env && env in LEVELS) return env;
3406
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
3407
+ }
3408
+ function setGlobalLogFile(filePath) {
3409
+ _globalLogFile = filePath;
3410
+ _logFileInitialized = false;
3411
+ try {
3412
+ fs3__default.mkdirSync(path9__default.dirname(filePath), { recursive: true });
3413
+ fs3__default.writeFileSync(
3414
+ filePath,
3415
+ `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
3416
+ `,
3417
+ "utf-8"
3418
+ );
3419
+ _logFileInitialized = true;
3420
+ } catch {
3421
+ }
3422
+ }
3423
+ function writeToFile(line) {
3424
+ if (!_globalLogFile || !_logFileInitialized) return;
3425
+ try {
3426
+ fs3__default.appendFileSync(_globalLogFile, line);
3427
+ } catch {
3428
+ }
3429
+ }
3430
+ function createLogger(prefix, level) {
3431
+ const loggerState = {
3432
+ currentLevel: getEnvLevel(),
3433
+ setLevel(l) {
3434
+ this.currentLevel = l;
3435
+ }
3436
+ };
3437
+ const log8 = (msgLevel, stream, args) => {
3438
+ if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
3439
+ const line = `[${prefix}] ${args.map(String).join(" ")}
3440
+ `;
3441
+ process[stream].write(line);
3442
+ writeToFile(line);
3443
+ };
3444
+ return {
3445
+ error: (...a) => log8("error", "stderr", a),
3446
+ warn: (...a) => log8("warn", "stderr", a),
3447
+ info: (...a) => log8("info", "stdout", a),
3448
+ debug: (...a) => log8("debug", "stderr", a),
3449
+ setLevel: loggerState.setLevel,
3450
+ setLogFile: (filePath) => setGlobalLogFile(filePath)
3451
+ };
3452
+ }
3453
+ var LEVELS, _globalLogFile, _logFileInitialized;
3454
+ var init_logger = __esm({
3455
+ "packages/domain/shared/src/logger.ts"() {
3456
+ LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
3457
+ _globalLogFile = null;
3458
+ _logFileInitialized = false;
3459
+ createLogger("tailwind-styled");
3460
+ }
3461
+ });
3462
+
990
3463
  // packages/domain/shared/src/index.ts
991
3464
  var src_exports = {};
992
3465
  __export(src_exports, {
@@ -1005,18 +3478,21 @@ __export(src_exports, {
1005
3478
  RegistryPluginEntrySchema: () => RegistryPluginEntrySchema,
1006
3479
  ScanCacheClassEntrySchema: () => ScanCacheClassEntrySchema,
1007
3480
  ScanCacheSchema: () => ScanCacheSchema,
3481
+ TW_STATE_STATIC_FILENAME: () => TW_STATE_STATIC_FILENAME,
1008
3482
  TailwindConfigSchema: () => TailwindConfigSchema,
1009
3483
  TelemetryCollector: () => TelemetryCollector,
1010
3484
  TwError: () => TwError,
3485
+ appendStaticStateCssToSafelist: () => appendStaticStateCssToSafelist,
1011
3486
  assertTailwindV4: () => assertTailwindV4,
1012
3487
  calculateHealth: () => calculateHealth,
1013
3488
  createBuildTimer: () => createBuildTimer,
1014
3489
  createDebugLogger: () => createDebugLogger,
1015
3490
  createEsmRequire: () => createEsmRequire,
1016
- createLogger: () => createLogger,
3491
+ createLogger: () => createLogger2,
1017
3492
  createObservabilityClient: () => createObservabilityClient,
1018
3493
  createTraceSnapshot: () => createTraceSnapshot,
1019
3494
  detectTailwind: () => detectTailwind,
3495
+ extractStaticStateCss: () => extractStaticStateCss,
1020
3496
  formatDuration: () => formatDuration,
1021
3497
  formatErrorCode: () => formatErrorCode,
1022
3498
  formatErrorMessage: () => formatErrorMessage,
@@ -1036,7 +3512,7 @@ __export(src_exports, {
1036
3512
  getPipelinePercentages: () => getPipelinePercentages,
1037
3513
  getSuggestion: () => getSuggestion,
1038
3514
  getTailwindVersion: () => getTailwindVersion,
1039
- hashContent: () => hashContent,
3515
+ hashContent: () => hashContent2,
1040
3516
  isTailwindV4: () => isTailwindV4,
1041
3517
  isTwError: () => isTwError,
1042
3518
  loadNativeBinding: () => loadNativeBinding,
@@ -1052,10 +3528,11 @@ __export(src_exports, {
1052
3528
  resolveRuntimeDir: () => resolveRuntimeDir,
1053
3529
  resolveWorkerPath: () => resolveWorkerPath,
1054
3530
  safeParseNative: () => safeParseNative,
3531
+ setGlobalLogFile: () => setGlobalLogFile,
1055
3532
  tryRequire: () => tryRequire,
1056
3533
  wrapUnknownError: () => wrapUnknownError
1057
3534
  });
1058
- function createLogger(namespace) {
3535
+ function createLogger2(namespace) {
1059
3536
  const prefix = `[${namespace}]`;
1060
3537
  return {
1061
3538
  warn(...args) {
@@ -1084,9 +3561,9 @@ function createDebugLogger(namespace, label) {
1084
3561
  }
1085
3562
  };
1086
3563
  }
1087
- function formatIssuePath(path13) {
1088
- if (!path13 || path13.length === 0) return "(root)";
1089
- return path13.map(
3564
+ function formatIssuePath(path16) {
3565
+ if (!path16 || path16.length === 0) return "(root)";
3566
+ return path16.map(
1090
3567
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
1091
3568
  ).join(".");
1092
3569
  }
@@ -1100,9 +3577,9 @@ function loadNativeBinding(options) {
1100
3577
  const { runtimeDir, candidates, isValid } = options;
1101
3578
  const loadErrors = [];
1102
3579
  for (const candidate of candidates) {
1103
- const candidatePath = path6__default.resolve(runtimeDir, candidate);
3580
+ const candidatePath = path9__default.resolve(runtimeDir, candidate);
1104
3581
  try {
1105
- if (!fs5__default.existsSync(candidatePath) && !fs5__default.existsSync(candidatePath + ".node")) {
3582
+ if (!fs3__default.existsSync(candidatePath) && !fs3__default.existsSync(candidatePath + ".node")) {
1106
3583
  continue;
1107
3584
  }
1108
3585
  const mod = requireNativeModule(candidatePath);
@@ -1134,9 +3611,9 @@ function resolveNativeBindingCandidates(options) {
1134
3611
  }
1135
3612
  }
1136
3613
  if (!includeDefaultCandidates) return candidates;
1137
- if (fs5__default.existsSync(runtimeDir)) {
3614
+ if (fs3__default.existsSync(runtimeDir)) {
1138
3615
  try {
1139
- for (const entry of fs5__default.readdirSync(runtimeDir)) {
3616
+ for (const entry of fs3__default.readdirSync(runtimeDir)) {
1140
3617
  if (entry.endsWith(".node")) candidates.push(entry);
1141
3618
  }
1142
3619
  } catch {
@@ -1145,27 +3622,27 @@ function resolveNativeBindingCandidates(options) {
1145
3622
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
1146
3623
  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
3624
  for (const bin of BINARY_NAMES) {
1148
- candidates.push(path6__default.resolve(runtimeDir, `${bin}.node`));
1149
- candidates.push(path6__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
1150
- candidates.push(path6__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
1151
- candidates.push(path6__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
1152
- candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.node`));
1153
- candidates.push(path6__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
1154
- candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
1155
- candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
1156
- candidates.push(path6__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3625
+ candidates.push(path9__default.resolve(runtimeDir, `${bin}.node`));
3626
+ candidates.push(path9__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3627
+ candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3628
+ candidates.push(path9__default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3629
+ candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.node`));
3630
+ candidates.push(path9__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3631
+ candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3632
+ candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3633
+ candidates.push(path9__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
1157
3634
  }
1158
3635
  return Array.from(new Set(candidates));
1159
3636
  }
1160
3637
  function resolveRuntimeDir(dir, importMetaUrl) {
1161
- if (dir) return path6__default.resolve(dir);
3638
+ if (dir) return path9__default.resolve(dir);
1162
3639
  try {
1163
- return path6__default.dirname(fileURLToPath(importMetaUrl));
3640
+ return path9__default.dirname(fileURLToPath(importMetaUrl));
1164
3641
  } catch {
1165
3642
  return process.cwd();
1166
3643
  }
1167
3644
  }
1168
- function hashContent(content, algorithm = "md5", length) {
3645
+ function hashContent2(content, algorithm = "md5", length) {
1169
3646
  const hash = createHash(algorithm).update(content).digest("hex");
1170
3647
  return length ? hash.slice(0, length) : hash;
1171
3648
  }
@@ -1175,7 +3652,7 @@ function formatErrorMessage(error) {
1175
3652
  return String(error);
1176
3653
  }
1177
3654
  var TwError, _require2, LRUCache;
1178
- var init_src = __esm({
3655
+ var init_src2 = __esm({
1179
3656
  "packages/domain/shared/src/index.ts"() {
1180
3657
  init_trace();
1181
3658
  init_error_codes();
@@ -1188,6 +3665,8 @@ var init_src = __esm({
1188
3665
  init_codegen();
1189
3666
  init_native_resolution();
1190
3667
  init_observability();
3668
+ init_staticStateExtractor();
3669
+ init_logger();
1191
3670
  TwError = class _TwError extends Error {
1192
3671
  /** @deprecated Gunakan source */
1193
3672
  domain;
@@ -1221,8 +3700,8 @@ var init_src = __esm({
1221
3700
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
1222
3701
  static fromZod(err) {
1223
3702
  const first = err.issues?.[0] ?? err.errors?.[0];
1224
- const path13 = formatIssuePath(first?.path);
1225
- const message = first ? `${path13}: ${first.message}` : "Schema validation failed";
3703
+ const path16 = formatIssuePath(first?.path);
3704
+ const message = first ? `${path16}: ${first.message}` : "Schema validation failed";
1226
3705
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
1227
3706
  }
1228
3707
  static wrap(source, code, err) {
@@ -1288,7 +3767,7 @@ var init_src = __esm({
1288
3767
  // packages/domain/scanner/src/native-bridge.ts
1289
3768
  var native_bridge_exports = {};
1290
3769
  __export(native_bridge_exports, {
1291
- batchExtractClassesNative: () => batchExtractClassesNative,
3770
+ batchExtractClassesNative: () => batchExtractClassesNative2,
1292
3771
  cachePriorityNative: () => cachePriorityNative,
1293
3772
  cacheReadNative: () => cacheReadNative,
1294
3773
  cacheWriteNative: () => cacheWriteNative,
@@ -1308,8 +3787,8 @@ __export(native_bridge_exports, {
1308
3787
  scanCacheInvalidate: () => scanCacheInvalidate,
1309
3788
  scanCachePut: () => scanCachePut,
1310
3789
  scanCacheStats: () => scanCacheStats,
1311
- scanFileNative: () => scanFileNative,
1312
- scanFilesBatchNative: () => scanFilesBatchNative,
3790
+ scanFileNative: () => scanFileNative2,
3791
+ scanFilesBatchNative: () => scanFilesBatchNative2,
1313
3792
  scanWorkspaceNative: () => scanWorkspaceNative,
1314
3793
  startWatchNative: () => startWatchNative,
1315
3794
  stopWatchNative: () => stopWatchNative
@@ -1319,7 +3798,7 @@ function getDirname2() {
1319
3798
  return __dirname;
1320
3799
  }
1321
3800
  if (typeof import.meta !== "undefined" && import.meta.url) {
1322
- return path6__default.dirname(fileURLToPath(import.meta.url));
3801
+ return path9__default.dirname(fileURLToPath(import.meta.url));
1323
3802
  }
1324
3803
  return process.cwd();
1325
3804
  }
@@ -1400,7 +3879,7 @@ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHit
1400
3879
  }
1401
3880
  return result;
1402
3881
  }
1403
- function batchExtractClassesNative(filePaths) {
3882
+ function batchExtractClassesNative2(filePaths) {
1404
3883
  const binding = scannerGetBinding();
1405
3884
  if (!binding.batchExtractClasses) {
1406
3885
  throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
@@ -1435,7 +3914,7 @@ function scanCacheStats() {
1435
3914
  }
1436
3915
  return binding.scanCacheStats();
1437
3916
  }
1438
- function scanFileNative(filePath) {
3917
+ function scanFileNative2(filePath) {
1439
3918
  const binding = scannerGetBinding();
1440
3919
  if (!binding.scanFile) {
1441
3920
  throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
@@ -1447,7 +3926,7 @@ function collectFilesNative(root, extensions, ignoreDirs) {
1447
3926
  if (!binding.collectFiles) return null;
1448
3927
  return binding.collectFiles(root, extensions, ignoreDirs);
1449
3928
  }
1450
- function scanFilesBatchNative(filePaths) {
3929
+ function scanFilesBatchNative2(filePaths) {
1451
3930
  const binding = scannerGetBinding();
1452
3931
  if (!binding.scanFilesBatch) {
1453
3932
  return filePaths.map((fp) => {
@@ -1524,11 +4003,11 @@ function hasNativeWatchBinding() {
1524
4003
  return false;
1525
4004
  }
1526
4005
  }
1527
- var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
4006
+ var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
1528
4007
  var init_native_bridge = __esm({
1529
4008
  "packages/domain/scanner/src/native-bridge.ts"() {
1530
- init_src();
1531
- log = createDebugLogger("scanner:native");
4009
+ init_src2();
4010
+ log2 = createDebugLogger("scanner:native");
1532
4011
  isValidScannerBinding = (module) => {
1533
4012
  const candidate = module;
1534
4013
  return !!(candidate && (candidate.scanWorkspace || candidate.extractClassesFromSource || candidate.hashFileContent || candidate.cacheRead || candidate.cacheWrite));
@@ -1582,7 +4061,7 @@ var init_native_bridge = __esm({
1582
4061
  invalidExportMessage: "Module loaded but missing expected scanner binding functions"
1583
4062
  });
1584
4063
  if (binding) {
1585
- log(`scanner native binding loaded successfully`);
4064
+ log2(`scanner native binding loaded successfully`);
1586
4065
  _state.binding = binding;
1587
4066
  return _state.binding;
1588
4067
  }
@@ -1608,12 +4087,12 @@ var init_native_bridge = __esm({
1608
4087
  }
1609
4088
  });
1610
4089
  function defaultCachePath(rootDir, cacheDir) {
1611
- const dir = cacheDir ? path6__default.resolve(rootDir, cacheDir) : path6__default.join(process.cwd(), ".cache", "tailwind-styled");
1612
- return path6__default.join(dir, "scanner-cache.json");
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");
1613
4092
  }
1614
4093
  function readCache(rootDir, cacheDir) {
1615
4094
  const cachePath = defaultCachePath(rootDir, cacheDir);
1616
- fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
4095
+ fs3__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
1617
4096
  const result = cacheReadNative(cachePath);
1618
4097
  if (!result) return [];
1619
4098
  return result.entries.map((e) => ({
@@ -1628,7 +4107,7 @@ function readCache(rootDir, cacheDir) {
1628
4107
  }
1629
4108
  function writeCache(rootDir, entries, cacheDir) {
1630
4109
  const cachePath = defaultCachePath(rootDir, cacheDir);
1631
- fs5__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
4110
+ fs3__default.mkdirSync(path9__default.dirname(cachePath), { recursive: true });
1632
4111
  const success = cacheWriteNative(cachePath, entries);
1633
4112
  if (!success) {
1634
4113
  throw new Error(
@@ -1652,30 +4131,10 @@ var init_cache_native = __esm({
1652
4131
  init_native_bridge();
1653
4132
  }
1654
4133
  });
1655
- function collectFiles(rootDir, extensions, ignoreDirs) {
4134
+ function collectFiles2(rootDir, extensions, ignoreDirs) {
1656
4135
  const native = collectFilesNative(rootDir, extensions, ignoreDirs);
1657
4136
  if (native !== null) return native;
1658
- const files = [];
1659
- function walk(dir) {
1660
- let entries;
1661
- try {
1662
- entries = fs5__default.readdirSync(dir, { withFileTypes: true });
1663
- } catch {
1664
- return;
1665
- }
1666
- for (const entry of entries) {
1667
- const fullPath = path6__default.join(dir, entry.name);
1668
- const rel = path6__default.relative(rootDir, fullPath);
1669
- if (entry.isDirectory()) {
1670
- const ignored = ignoreDirs.some((d) => entry.name === d || rel.startsWith(d + path6__default.sep));
1671
- if (!ignored) walk(fullPath);
1672
- } else if (isScannableFile(entry.name, extensions)) {
1673
- files.push(fullPath);
1674
- }
1675
- }
1676
- }
1677
- walk(rootDir);
1678
- return files;
4137
+ throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
1679
4138
  }
1680
4139
  function mergeResults(batchResults) {
1681
4140
  const files = batchResults.map((r) => ({
@@ -1685,8 +4144,7 @@ function mergeResults(batchResults) {
1685
4144
  }));
1686
4145
  const native = rebuildWorkspaceResultNative(files);
1687
4146
  if (native) return native;
1688
- const unique = new Set(files.flatMap((f) => f.classes));
1689
- return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
4147
+ throw new Error("FATAL: Native binding 'rebuildWorkspaceResult' is required but not available.");
1690
4148
  }
1691
4149
  function runChunkInWorker(filePaths) {
1692
4150
  return new Promise((resolve2, reject) => {
@@ -1713,9 +4171,9 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
1713
4171
  maxWorkers = Math.max(1, availableParallelism() - 1),
1714
4172
  chunkSize = DEFAULT_CHUNK_SIZE
1715
4173
  } = options;
1716
- const files = collectFiles(path6__default.resolve(rootDir), extensions, ignoreDirs);
4174
+ const files = collectFiles2(path9__default.resolve(rootDir), extensions, ignoreDirs);
1717
4175
  if (files.length < PARALLEL_THRESHOLD) {
1718
- return mergeResults(batchExtractClassesNative(files));
4176
+ return mergeResults(batchExtractClassesNative2(files));
1719
4177
  }
1720
4178
  const chunks = [];
1721
4179
  for (let i = 0; i < files.length; i += chunkSize) {
@@ -1732,14 +4190,14 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
1732
4190
  var PARALLEL_THRESHOLD, DEFAULT_CHUNK_SIZE, _workerFilename;
1733
4191
  var init_parallel_scanner = __esm({
1734
4192
  "packages/domain/scanner/src/parallel-scanner.ts"() {
1735
- init_src2();
4193
+ init_src3();
1736
4194
  init_native_bridge();
1737
4195
  PARALLEL_THRESHOLD = 50;
1738
4196
  DEFAULT_CHUNK_SIZE = 150;
1739
4197
  if (!isMainThread && parentPort) {
1740
4198
  const { filePaths } = workerData;
1741
4199
  try {
1742
- const results = batchExtractClassesNative(filePaths);
4200
+ const results = batchExtractClassesNative2(filePaths);
1743
4201
  const msg = { ok: true, results };
1744
4202
  parentPort.postMessage(msg);
1745
4203
  } catch (error) {
@@ -1756,13 +4214,13 @@ var init_parallel_scanner = __esm({
1756
4214
  var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, ScanWorkspaceOptionsSchema, ScanFileResultSchema, ScanWorkspaceResultSchema, ScannerWorkerSuccessMessageSchema, ScannerWorkerErrorMessageSchema, ScannerWorkerMessageSchema, parseScanWorkspaceOptions, parseScanWorkspaceResult, parseScannerWorkerMessage;
1757
4215
  var init_schemas = __esm({
1758
4216
  "packages/domain/scanner/src/schemas.ts"() {
1759
- init_src();
1760
- formatIssuePath2 = (path13) => path13.length > 0 ? path13.map(
4217
+ init_src2();
4218
+ formatIssuePath2 = (path16) => path16.length > 0 ? path16.map(
1761
4219
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
1762
4220
  ).join(".") : "<root>";
1763
4221
  formatIssues = (error) => error.issues.map((issue) => {
1764
- const path13 = formatIssuePath2(issue.path);
1765
- return `${path13}: ${issue.message}`;
4222
+ const path16 = formatIssuePath2(issue.path);
4223
+ return `${path16}: ${issue.message}`;
1766
4224
  }).join("; ");
1767
4225
  parseWithSchema = (schema, data, label) => {
1768
4226
  const parsed = schema.safeParse(data);
@@ -1823,15 +4281,15 @@ var src_exports2 = {};
1823
4281
  __export(src_exports2, {
1824
4282
  DEFAULT_EXTENSIONS: () => DEFAULT_EXTENSIONS,
1825
4283
  DEFAULT_IGNORES: () => DEFAULT_IGNORES,
1826
- batchExtractClassesNative: () => batchExtractClassesNative,
4284
+ batchExtractClassesNative: () => batchExtractClassesNative2,
1827
4285
  extractClassesNative: () => extractClassesNative,
1828
- isScannableFile: () => isScannableFile,
4286
+ isScannableFile: () => isScannableFile2,
1829
4287
  parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
1830
4288
  parseScanWorkspaceResult: () => parseScanWorkspaceResult,
1831
4289
  parseScannerWorkerMessage: () => parseScannerWorkerMessage,
1832
- scanFile: () => scanFile,
4290
+ scanFile: () => scanFile2,
1833
4291
  scanSource: () => scanSource,
1834
- scanWorkspace: () => scanWorkspace,
4292
+ scanWorkspace: () => scanWorkspace2,
1835
4293
  scanWorkspaceAsync: () => scanWorkspaceAsync
1836
4294
  });
1837
4295
  function getRuntimeDir() {
@@ -1839,7 +4297,7 @@ function getRuntimeDir() {
1839
4297
  return __dirname;
1840
4298
  }
1841
4299
  if (typeof import.meta !== "undefined" && import.meta.url) {
1842
- return path6__default.dirname(fileURLToPath(import.meta.url));
4300
+ return path9__default.dirname(fileURLToPath(import.meta.url));
1843
4301
  }
1844
4302
  return process.cwd();
1845
4303
  }
@@ -1849,17 +4307,17 @@ function resolveScannerWorkerModulePath() {
1849
4307
  return __dirname;
1850
4308
  }
1851
4309
  if (typeof import.meta !== "undefined" && import.meta.url) {
1852
- return path6__default.dirname(fileURLToPath(import.meta.url));
4310
+ return path9__default.dirname(fileURLToPath(import.meta.url));
1853
4311
  }
1854
4312
  return process.cwd();
1855
4313
  })();
1856
4314
  const candidates = [
1857
- path6__default.resolve(runtimeDir, "worker.cjs"),
1858
- path6__default.resolve(runtimeDir, "worker.js"),
1859
- path6__default.resolve(runtimeDir, "worker.ts")
4315
+ path9__default.resolve(runtimeDir, "worker.cjs"),
4316
+ path9__default.resolve(runtimeDir, "worker.js"),
4317
+ path9__default.resolve(runtimeDir, "worker.ts")
1860
4318
  ];
1861
4319
  for (const candidate of candidates) {
1862
- if (fs5__default.existsSync(candidate)) return candidate;
4320
+ if (fs3__default.existsSync(candidate)) return candidate;
1863
4321
  }
1864
4322
  return null;
1865
4323
  }
@@ -1916,19 +4374,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
1916
4374
  if (!currentDir) continue;
1917
4375
  const entries = (() => {
1918
4376
  try {
1919
- return fs5__default.readdirSync(currentDir, { withFileTypes: true });
4377
+ return fs3__default.readdirSync(currentDir, { withFileTypes: true });
1920
4378
  } catch {
1921
4379
  return [];
1922
4380
  }
1923
4381
  })();
1924
4382
  for (const entry of entries) {
1925
- const fullPath = path6__default.join(currentDir, entry.name);
4383
+ const fullPath = path9__default.join(currentDir, entry.name);
1926
4384
  if (entry.isDirectory()) {
1927
4385
  if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
1928
4386
  continue;
1929
4387
  }
1930
4388
  if (!entry.isFile()) continue;
1931
- if (!extensionSet.has(path6__default.extname(entry.name))) continue;
4389
+ if (!extensionSet.has(path9__default.extname(entry.name))) continue;
1932
4390
  candidates.push(fullPath);
1933
4391
  }
1934
4392
  }
@@ -1954,12 +4412,12 @@ function scanSource(source) {
1954
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"
1955
4413
  );
1956
4414
  }
1957
- function isScannableFile(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
1958
- return includeExtensions.includes(path6__default.extname(filePath));
4415
+ function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
4416
+ return includeExtensions.includes(path9__default.extname(filePath));
1959
4417
  }
1960
- function scanFile(filePath) {
1961
- const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
1962
- const result = scanFileNative2(filePath);
4418
+ function scanFile2(filePath) {
4419
+ const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
4420
+ const result = scanFileNative3(filePath);
1963
4421
  if (!result.ok) {
1964
4422
  throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
1965
4423
  }
@@ -1969,7 +4427,7 @@ function scanFile(filePath) {
1969
4427
  ...result.hash ? { hash: result.hash } : {}
1970
4428
  };
1971
4429
  }
1972
- function scanWorkspace(rootDir, options = {}) {
4430
+ function scanWorkspace2(rootDir, options = {}) {
1973
4431
  const normalizedOptions = parseScanWorkspaceOptions(options);
1974
4432
  const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
1975
4433
  const extensionSet = buildExtensionSet(includeExtensions);
@@ -2003,7 +4461,7 @@ function scanWorkspace(rootDir, options = {}) {
2003
4461
  try {
2004
4462
  return readCache(rootDir, normalizedOptions.cacheDir);
2005
4463
  } catch (error) {
2006
- log2.debug(
4464
+ log3.debug(
2007
4465
  `cache read failed, continuing without persisted cache: ${error instanceof Error ? error.message : String(error)}`
2008
4466
  );
2009
4467
  return [];
@@ -2015,7 +4473,7 @@ function scanWorkspace(rootDir, options = {}) {
2015
4473
  for (const filePath of candidates) {
2016
4474
  const stat = (() => {
2017
4475
  try {
2018
- return fs5__default.statSync(filePath);
4476
+ return fs3__default.statSync(filePath);
2019
4477
  } catch {
2020
4478
  return null;
2021
4479
  }
@@ -2041,7 +4499,7 @@ function scanWorkspace(rootDir, options = {}) {
2041
4499
  for (const { filePath, stat, size, cached } of ranked) {
2042
4500
  const content = (() => {
2043
4501
  try {
2044
- return fs5__default.readFileSync(filePath, "utf8");
4502
+ return fs3__default.readFileSync(filePath, "utf8");
2045
4503
  } catch {
2046
4504
  return null;
2047
4505
  }
@@ -2049,7 +4507,7 @@ function scanWorkspace(rootDir, options = {}) {
2049
4507
  if (!content) continue;
2050
4508
  const hash = hashContentNative(content);
2051
4509
  if (cached && cached.hash === hash && cached.mtimeMs === stat.mtimeMs && cached.size === size) {
2052
- log2.debug(`cache HIT ${filePath}`);
4510
+ log3.debug(`cache HIT ${filePath}`);
2053
4511
  processResult({ file: filePath, classes: cached.classes });
2054
4512
  updatedEntries.push({
2055
4513
  file: filePath,
@@ -2061,7 +4519,7 @@ function scanWorkspace(rootDir, options = {}) {
2061
4519
  });
2062
4520
  continue;
2063
4521
  }
2064
- log2.debug(`cache MISS ${filePath}`);
4522
+ log3.debug(`cache MISS ${filePath}`);
2065
4523
  const classes = scanSource(content);
2066
4524
  processResult({ file: filePath, classes });
2067
4525
  updatedEntries.push({
@@ -2076,7 +4534,7 @@ function scanWorkspace(rootDir, options = {}) {
2076
4534
  try {
2077
4535
  writeCache(rootDir, updatedEntries, normalizedOptions.cacheDir);
2078
4536
  } catch (error) {
2079
- log2.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
4537
+ log3.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
2080
4538
  }
2081
4539
  return parseScanWorkspaceResult({
2082
4540
  files,
@@ -2092,7 +4550,7 @@ function scanWorkspace(rootDir, options = {}) {
2092
4550
  }
2093
4551
  } else {
2094
4552
  for (const filePath of candidates) {
2095
- processResult(scanFile(filePath));
4553
+ processResult(scanFile2(filePath));
2096
4554
  }
2097
4555
  }
2098
4556
  return parseScanWorkspaceResult({
@@ -2109,30 +4567,30 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
2109
4567
  ignoreDirs: normalizedOptions.ignoreDirectories
2110
4568
  });
2111
4569
  } catch (parallelError) {
2112
- log2.debug(
4570
+ log3.debug(
2113
4571
  `parallel scan failed, retrying with single worker: ${parallelError instanceof Error ? parallelError.message : String(parallelError)}`
2114
4572
  );
2115
4573
  }
2116
4574
  try {
2117
4575
  return await scanWorkspaceInWorker(rootDir, normalizedOptions);
2118
4576
  } catch (error) {
2119
- log2.debug(
4577
+ log3.debug(
2120
4578
  `worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
2121
4579
  );
2122
- return scanWorkspace(rootDir, normalizedOptions);
4580
+ return scanWorkspace2(rootDir, normalizedOptions);
2123
4581
  }
2124
4582
  }
2125
- var log2, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
2126
- var init_src2 = __esm({
4583
+ var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
4584
+ var init_src3 = __esm({
2127
4585
  "packages/domain/scanner/src/index.ts"() {
2128
- init_src();
4586
+ init_src2();
2129
4587
  init_cache_native();
2130
4588
  init_native_bridge();
2131
4589
  init_parallel_scanner();
2132
4590
  init_schemas();
2133
4591
  init_schemas();
2134
4592
  init_native_bridge();
2135
- log2 = createLogger("scanner");
4593
+ log3 = createLogger2("scanner");
2136
4594
  SCAN_WORKER_TIMEOUT_MS = 12e4;
2137
4595
  createNativeParserLoader = () => {
2138
4596
  const _state = {
@@ -2140,12 +4598,12 @@ var init_src2 = __esm({
2140
4598
  initError: null
2141
4599
  };
2142
4600
  const debugNative = (message) => {
2143
- log2.debug(`[native] ${message}`);
4601
+ log3.debug(`[native] ${message}`);
2144
4602
  };
2145
4603
  const loadNativeParserBinding = () => {
2146
4604
  if (_state.binding !== void 0) return _state.binding;
2147
4605
  const runtimeDir = getRuntimeDir();
2148
- const req = createRequire(path6__default.join(runtimeDir, "noop.cjs"));
4606
+ const req = createRequire(path9__default.join(runtimeDir, "noop.cjs"));
2149
4607
  const _platform = process.platform;
2150
4608
  const _arch = process.arch;
2151
4609
  const _platformArch = `${_platform}-${_arch}`;
@@ -2153,27 +4611,27 @@ var init_src2 = __esm({
2153
4611
  const candidates = [
2154
4612
  // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
2155
4613
  // cwd = repo root saat run dari root, atau package dir saat workspaces
2156
- path6__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
2157
- path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
2158
- path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
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`),
2159
4617
  // runtimeDir = dist/ → naik 1 level ke package root (npm install case)
2160
4618
  // e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
2161
- path6__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
2162
- path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
2163
- path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
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`),
2164
4622
  // runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
2165
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
2166
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
4623
+ path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
4624
+ path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
2167
4625
  // 3 level fallback (jika package di-nest lebih dangkal)
2168
- path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
2169
- path6__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
4626
+ path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
4627
+ path9__default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
2170
4628
  // ── binaryName lama: tailwind_styled_parser (backward compat) ──
2171
- path6__default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
2172
- path6__default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
2173
- path6__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
2174
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
2175
- path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
2176
- path6__default.resolve(
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(
2177
4635
  runtimeDir,
2178
4636
  "..",
2179
4637
  "..",
@@ -2185,7 +4643,7 @@ var init_src2 = __esm({
2185
4643
  )
2186
4644
  ];
2187
4645
  for (const fullPath of candidates) {
2188
- if (!fs5__default.existsSync(fullPath)) continue;
4646
+ if (!fs3__default.existsSync(fullPath)) continue;
2189
4647
  try {
2190
4648
  const required = req(fullPath);
2191
4649
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -2218,168 +4676,6 @@ var init_src2 = __esm({
2218
4676
  }
2219
4677
  });
2220
4678
 
2221
- // packages/domain/compiler/src/nativeBridge.ts
2222
- var _loadNative, log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
2223
- var init_nativeBridge = __esm({
2224
- "packages/domain/compiler/src/nativeBridge.ts"() {
2225
- init_src();
2226
- _loadNative = (path13) => __require(path13);
2227
- log3 = (...args) => {
2228
- if (process.env.DEBUG?.includes("compiler:native")) {
2229
- console.log("[compiler:native]", ...args);
2230
- }
2231
- };
2232
- NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
2233
- nativeBridge = null;
2234
- bridgeLoadAttempted = false;
2235
- bridgeLoadError = null;
2236
- isValidNativeBridge = (mod) => {
2237
- const m = mod;
2238
- return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
2239
- };
2240
- getNativeBridge = () => {
2241
- if (nativeBridge) {
2242
- return nativeBridge;
2243
- }
2244
- if (bridgeLoadAttempted) {
2245
- if (bridgeLoadError) {
2246
- throw bridgeLoadError;
2247
- }
2248
- throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
2249
- }
2250
- bridgeLoadAttempted = true;
2251
- try {
2252
- const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
2253
- const result = resolveNativeBinary(runtimeDir);
2254
- if (result.path && result.path.endsWith(".node")) {
2255
- try {
2256
- const binding = _loadNative(result.path);
2257
- if (isValidNativeBridge(binding)) {
2258
- nativeBridge = binding;
2259
- log3("Native bridge loaded successfully from:", result.path);
2260
- return nativeBridge;
2261
- }
2262
- } catch (e) {
2263
- log3("Failed to require native binding:", e);
2264
- }
2265
- }
2266
- throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
2267
-
2268
- Tried paths: ${result.tried.join("\n")}`);
2269
- } catch (err) {
2270
- bridgeLoadError = err instanceof Error ? err : new Error(String(err));
2271
- log3("Failed to load native bridge:", bridgeLoadError.message);
2272
- throw bridgeLoadError;
2273
- }
2274
- };
2275
- if (typeof process !== "undefined" && !bridgeLoadAttempted) {
2276
- try {
2277
- getNativeBridge();
2278
- } catch {
2279
- }
2280
- }
2281
- }
2282
- });
2283
-
2284
- // packages/domain/compiler/src/tailwindEngine.ts
2285
- var tailwindEngine_exports = {};
2286
- __export(tailwindEngine_exports, {
2287
- generateRawCss: () => generateRawCss,
2288
- processTailwindCssWithTargets: () => processTailwindCssWithTargets,
2289
- runCssPipeline: () => runCssPipeline,
2290
- runCssPipelineSync: () => runCssPipelineSync
2291
- });
2292
- function loadTailwindEngine() {
2293
- if (_twEngine) return _twEngine;
2294
- if (_twEngineError) throw _twEngineError;
2295
- try {
2296
- const tw = require2("tailwindcss");
2297
- if (typeof tw.compile !== "function") {
2298
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
2299
- }
2300
- _twEngine = tw;
2301
- return _twEngine;
2302
- } catch (e) {
2303
- _twEngineError = e instanceof Error ? e : new Error(String(e));
2304
- throw _twEngineError;
2305
- }
2306
- }
2307
- async function generateRawCss(classes, cssEntryContent, root) {
2308
- if (classes.length === 0) return "";
2309
- const tw = loadTailwindEngine();
2310
- const input = cssEntryContent ?? "@import 'tailwindcss';";
2311
- const { readFileSync, existsSync: existsSync3 } = await import('fs');
2312
- const { dirname, resolve: resolve2 } = await import('path');
2313
- const projectRoot = root ?? process.cwd();
2314
- const req = createRequire(resolve2(projectRoot, "package.json"));
2315
- const loadStylesheet = async (id, base) => {
2316
- try {
2317
- const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
2318
- const pkgPath = req.resolve(cssId);
2319
- return {
2320
- content: readFileSync(pkgPath, "utf-8"),
2321
- base: dirname(pkgPath)
2322
- };
2323
- } catch {
2324
- try {
2325
- const absPath = resolve2(base, id);
2326
- if (existsSync3(absPath)) {
2327
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
2328
- }
2329
- } catch {
2330
- }
2331
- return { content: "", base };
2332
- }
2333
- };
2334
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
2335
- return compiler.build(classes);
2336
- }
2337
- function postProcessWithLightning(rawCss) {
2338
- if (!rawCss) return "";
2339
- const native = getNativeBridge();
2340
- if (typeof native.processTailwindCssLightning !== "function") {
2341
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
2342
- }
2343
- const result = native.processTailwindCssLightning(rawCss);
2344
- return result?.css ?? rawCss;
2345
- }
2346
- async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
2347
- const unique = [...new Set(classes.filter(Boolean))];
2348
- if (unique.length === 0) {
2349
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
2350
- }
2351
- const rawCss = await generateRawCss(unique, cssEntryContent, root);
2352
- const native = getNativeBridge();
2353
- const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
2354
- const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
2355
- return {
2356
- css: finalCss,
2357
- classes: unique,
2358
- sizeBytes: finalCss.length,
2359
- optimized: hasLightning
2360
- };
2361
- }
2362
- function runCssPipelineSync(_classes) {
2363
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
2364
- }
2365
- function processTailwindCssWithTargets(css, targets) {
2366
- const native = getNativeBridge();
2367
- if (!native?.processTailwindCssWithTargets) {
2368
- throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
2369
- }
2370
- const result = native.processTailwindCssWithTargets(css, targets ?? null);
2371
- return (result?.css ?? css).trim();
2372
- }
2373
- var require2, _twEngine, _twEngineError;
2374
- var init_tailwindEngine = __esm({
2375
- "packages/domain/compiler/src/tailwindEngine.ts"() {
2376
- init_nativeBridge();
2377
- require2 = createRequire(import.meta.url);
2378
- _twEngine = null;
2379
- _twEngineError = null;
2380
- }
2381
- });
2382
-
2383
4679
  // packages/domain/engine/src/native-bridge.ts
2384
4680
  function getDirname3() {
2385
4681
  if (typeof __dirname !== "undefined") return __dirname;
@@ -2394,7 +4690,7 @@ function getNativeEngineBinding() {
2394
4690
  var log4, isValidEngineBinding, createEngineBindingLoader, engineBindingLoader;
2395
4691
  var init_native_bridge2 = __esm({
2396
4692
  "packages/domain/engine/src/native-bridge.ts"() {
2397
- init_src();
4693
+ init_src2();
2398
4694
  log4 = createDebugLogger("engine:native");
2399
4695
  isValidEngineBinding = (module) => {
2400
4696
  const candidate = module;
@@ -2473,49 +4769,40 @@ var init_native_bridge2 = __esm({
2473
4769
  });
2474
4770
 
2475
4771
  // packages/domain/engine/src/ir.ts
2476
- function registerPropertyName(id, name) {
4772
+ function registerPropertyName2(id, name) {
2477
4773
  const native = getNativeEngineBinding();
2478
- if (native?.registerPropertyName) {
2479
- native.registerPropertyName(id.value, name);
2480
- return;
4774
+ if (!native?.registerPropertyName) {
4775
+ throw new Error("FATAL: Native binding 'registerPropertyName' is required but not available.");
2481
4776
  }
2482
- _propertyNamesFallback.set(id.value, name);
4777
+ native.registerPropertyName(id.value, name);
2483
4778
  }
2484
- function registerValueName(id, name) {
4779
+ function registerValueName2(id, name) {
2485
4780
  const native = getNativeEngineBinding();
2486
- if (native?.registerValueName) {
2487
- native.registerValueName(id.value, name);
2488
- return;
4781
+ if (!native?.registerValueName) {
4782
+ throw new Error("FATAL: Native binding 'registerValueName' is required but not available.");
2489
4783
  }
2490
- _valueNamesFallback.set(id.value, name);
4784
+ native.registerValueName(id.value, name);
2491
4785
  }
2492
- function propertyIdToString(id) {
4786
+ function propertyIdToString2(id) {
2493
4787
  const native = getNativeEngineBinding();
2494
- if (native?.propertyIdToString) {
2495
- return native.propertyIdToString(id.value);
4788
+ if (!native?.propertyIdToString) {
4789
+ throw new Error("FATAL: Native binding 'propertyIdToString' is required but not available.");
2496
4790
  }
2497
- return _propertyNamesFallback.get(id.value) ?? `P${id.value}`;
4791
+ return native.propertyIdToString(id.value);
2498
4792
  }
2499
- function valueIdToString(id) {
4793
+ function valueIdToString2(id) {
2500
4794
  const native = getNativeEngineBinding();
2501
- if (native?.valueIdToString) {
2502
- return native.valueIdToString(id.value);
4795
+ if (!native?.valueIdToString) {
4796
+ throw new Error("FATAL: Native binding 'valueIdToString' is required but not available.");
2503
4797
  }
2504
- return _valueNamesFallback.get(id.value) ?? `V${id.value}`;
4798
+ return native.valueIdToString(id.value);
2505
4799
  }
2506
- function createFingerprintFallback(parts) {
2507
- const hash = parts.reduce(
2508
- (acc, part) => part.split("").reduce((h, char) => (h << 5) - h + char.charCodeAt(0) & h, acc),
2509
- 0
2510
- );
2511
- return Math.abs(hash).toString(36);
2512
- }
2513
- function createFingerprint(parts) {
4800
+ function createFingerprint2(parts) {
2514
4801
  const native = getNativeEngineBinding();
2515
- if (native?.createFingerprint) {
2516
- return native.createFingerprint(parts);
4802
+ if (!native?.createFingerprint) {
4803
+ throw new Error("FATAL: Native binding 'createFingerprint' is required but not available.");
2517
4804
  }
2518
- return createFingerprintFallback(parts);
4805
+ return native.createFingerprint(parts);
2519
4806
  }
2520
4807
  function createResolutionReason(causes, finalDecision) {
2521
4808
  return {
@@ -2523,7 +4810,7 @@ function createResolutionReason(causes, finalDecision) {
2523
4810
  finalDecision
2524
4811
  };
2525
4812
  }
2526
- var RuleId, SelectorId, VariantChainId, PropertyId, ValueId, LayerId, ConditionId, CascadeResolutionId, _propertyNamesFallback, _valueNamesFallback, Origin, Importance, ConditionResult, CascadeStage;
4813
+ var RuleId, SelectorId, VariantChainId, PropertyId, ValueId, LayerId, ConditionId, CascadeResolutionId, Origin, Importance, ConditionResult, CascadeStage;
2527
4814
  var init_ir = __esm({
2528
4815
  "packages/domain/engine/src/ir.ts"() {
2529
4816
  init_native_bridge2();
@@ -2566,7 +4853,7 @@ var init_ir = __esm({
2566
4853
  if (typeof name === "string" && name.length > 0) {
2567
4854
  return name;
2568
4855
  }
2569
- return propertyIdToString(this);
4856
+ return propertyIdToString2(this);
2570
4857
  }
2571
4858
  };
2572
4859
  ValueId = class {
@@ -2581,7 +4868,7 @@ var init_ir = __esm({
2581
4868
  if (typeof name === "string" && name.length > 0) {
2582
4869
  return name;
2583
4870
  }
2584
- return valueIdToString(this);
4871
+ return valueIdToString2(this);
2585
4872
  }
2586
4873
  };
2587
4874
  LayerId = class {
@@ -2611,8 +4898,6 @@ var init_ir = __esm({
2611
4898
  return `R${this.value}`;
2612
4899
  }
2613
4900
  };
2614
- _propertyNamesFallback = /* @__PURE__ */ new Map();
2615
- _valueNamesFallback = /* @__PURE__ */ new Map();
2616
4901
  Origin = /* @__PURE__ */ ((Origin2) => {
2617
4902
  Origin2[Origin2["UserAgent"] = 0] = "UserAgent";
2618
4903
  Origin2[Origin2["UserNormal"] = 1] = "UserNormal";
@@ -2791,12 +5076,12 @@ function createIdGenerator() {
2791
5076
  generateSelectorId: () => new SelectorId(state.selectorIdCounter++),
2792
5077
  generatePropertyId: (name) => {
2793
5078
  const id = new PropertyId(state.propertyIdCounter++);
2794
- registerPropertyName(id, name);
5079
+ registerPropertyName2(id, name);
2795
5080
  return id;
2796
5081
  },
2797
5082
  generateValueId: (name) => {
2798
5083
  const id = new ValueId(state.valueIdCounter++);
2799
- registerValueName(id, name);
5084
+ registerValueName2(id, name);
2800
5085
  return id;
2801
5086
  },
2802
5087
  generateLayerId: () => new LayerId(state.layerIdCounter++),
@@ -2826,14 +5111,68 @@ function detectLayerFromClassName(className) {
2826
5111
  return null;
2827
5112
  }
2828
5113
  function parseCssToIr(css, options = {}) {
2829
- resetIdGenerator();
5114
+ const native = getNativeEngineBinding();
5115
+ const prefix = options.prefix ?? "";
5116
+ if (native?.assembleCssIr) {
5117
+ return _parseCssToIrFast(native.assembleCssIr(css, prefix || null));
5118
+ }
5119
+ return _parseCssToIrFallback(css, prefix, native);
5120
+ }
5121
+ function _parseCssToIrFast(assembled) {
5122
+ const native = getNativeEngineBinding();
2830
5123
  layerMap.clear();
2831
5124
  layerOrderMap.clear();
2832
- const native = getNativeEngineBinding();
5125
+ for (const le of assembled.layers) {
5126
+ const lid = new LayerId(le.layerId);
5127
+ layerMap.set(le.name, lid);
5128
+ layerOrderMap.set(le.name, le.order);
5129
+ }
5130
+ const rules = assembled.rules.map((r) => {
5131
+ const propertyId = new PropertyId(r.propertyId);
5132
+ const valueId = new ValueId(r.valueId);
5133
+ if (native?.registerPropertyName) {
5134
+ native.registerPropertyName(r.propertyId, r.propertyName);
5135
+ } else {
5136
+ registerPropertyName2(propertyId, r.propertyName);
5137
+ }
5138
+ if (native?.registerValueName) {
5139
+ native.registerValueName(r.valueId, r.valueName);
5140
+ } else {
5141
+ registerValueName2(valueId, r.valueName);
5142
+ }
5143
+ return {
5144
+ id: new RuleId(r.ruleId),
5145
+ selector: new SelectorId(r.selectorId),
5146
+ variantChain: new VariantChainId(0),
5147
+ property: propertyId,
5148
+ value: valueId,
5149
+ origin: r.origin,
5150
+ importance: r.importance,
5151
+ layer: r.layerId >= 0 ? new LayerId(r.layerId) : null,
5152
+ layerOrder: r.layerOrder,
5153
+ specificity: r.specificity,
5154
+ condition: r.conditionId >= 0 ? new ConditionId(r.conditionId) : null,
5155
+ conditionResult: r.conditionResult,
5156
+ insertionOrder: r.insertionOrder,
5157
+ fingerprint: r.fingerprint,
5158
+ source: { file: "", line: 1, column: 1 }
5159
+ };
5160
+ });
5161
+ const classToRuleIds = new Map(
5162
+ assembled.classToRuleIds.map((m) => [
5163
+ m.className,
5164
+ m.ruleIds.map((id) => new RuleId(id))
5165
+ ])
5166
+ );
5167
+ return { rules, classToRuleIds };
5168
+ }
5169
+ function _parseCssToIrFallback(css, prefix, native) {
2833
5170
  if (!native?.parseCssRules) {
2834
5171
  throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
2835
5172
  }
2836
- const prefix = options.prefix ?? "";
5173
+ resetIdGenerator();
5174
+ layerMap.clear();
5175
+ layerOrderMap.clear();
2837
5176
  const rules = [];
2838
5177
  const classToRuleIds = /* @__PURE__ */ new Map();
2839
5178
  const parsed = native.parseCssRules(css);
@@ -2848,9 +5187,9 @@ function parseCssToIr(css, options = {}) {
2848
5187
  const valueId = generateValueId(r.value);
2849
5188
  const hasMedia = r.variants.some((v) => v.startsWith("@") || v === "dark" || v === "print");
2850
5189
  const conditionId = hasMedia ? generateConditionId() : null;
2851
- const conditionResult = hasMedia ? 2 /* Unknown */ : 2 /* Unknown */;
5190
+ const conditionResult = 2 /* Unknown */;
2852
5191
  const ruleId = generateRuleId();
2853
- const fingerprint = createFingerprint([className, r.property, r.value]);
5192
+ const fingerprint = createFingerprint2([className, r.property, r.value]);
2854
5193
  const rule = {
2855
5194
  id: ruleId,
2856
5195
  selector: selectorId,
@@ -2862,7 +5201,6 @@ function parseCssToIr(css, options = {}) {
2862
5201
  layer,
2863
5202
  layerOrder,
2864
5203
  specificity: r.specificity,
2865
- // from native — no JS recalculation
2866
5204
  condition: conditionId,
2867
5205
  conditionResult,
2868
5206
  insertionOrder: getNextInsertionOrder(),
@@ -3016,13 +5354,13 @@ var init_trace2 = __esm({
3016
5354
  });
3017
5355
 
3018
5356
  // packages/domain/analyzer/src/analyzeWorkspace.ts
3019
- init_src2();
5357
+ init_src3();
3020
5358
 
3021
5359
  // packages/domain/analyzer/src/binding.ts
3022
- init_src();
5360
+ init_src2();
3023
5361
 
3024
5362
  // packages/domain/analyzer/src/utils.ts
3025
- init_src();
5363
+ init_src2();
3026
5364
  var DEFAULT_TOP_LIMIT = 10;
3027
5365
  var DEFAULT_FREQUENT_THRESHOLD = 2;
3028
5366
  var DEBUG_NAMESPACE = "tailwind-styled:analyzer";
@@ -3036,7 +5374,7 @@ function isRecord(value) {
3036
5374
  }
3037
5375
  async function pathExists(filePath) {
3038
5376
  try {
3039
- await fs5__default.promises.access(filePath, fs5__default.constants.F_OK);
5377
+ await fs3__default.promises.access(filePath, fs3__default.constants.F_OK);
3040
5378
  return true;
3041
5379
  } catch {
3042
5380
  return false;
@@ -3134,8 +5472,8 @@ async function requireNativeBinding() {
3134
5472
  }
3135
5473
 
3136
5474
  // packages/domain/analyzer/src/schemas.ts
3137
- init_src();
3138
- var formatIssuePath3 = (path13) => path13.length > 0 ? path13.map(
5475
+ init_src2();
5476
+ var formatIssuePath3 = (path16) => path16.length > 0 ? path16.map(
3139
5477
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3140
5478
  ).join(".") : "<root>";
3141
5479
  var isPlainObject = (value) => {
@@ -3144,8 +5482,8 @@ var isPlainObject = (value) => {
3144
5482
  return proto === Object.prototype || proto === null;
3145
5483
  };
3146
5484
  var formatIssues2 = (error) => error.issues.map((issue) => {
3147
- const path13 = formatIssuePath3(issue.path);
3148
- return `${path13}: ${issue.message}`;
5485
+ const path16 = formatIssuePath3(issue.path);
5486
+ return `${path16}: ${issue.message}`;
3149
5487
  }).join("; ");
3150
5488
  var parseWithSchema2 = (schema, data, label) => {
3151
5489
  const parsed = schema.safeParse(data);
@@ -3235,7 +5573,7 @@ var parseAnalyzerOptions = (options) => parseWithSchema2(AnalyzerOptionsSchema,
3235
5573
  var parseNativeReport = (report) => parseWithSchema2(NativeReportSchema, report, "Native analyzer report is invalid");
3236
5574
  var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
3237
5575
  var tailwindConfigCache = /* @__PURE__ */ new Map();
3238
- var detectConflicts = async (usages) => {
5576
+ var detectConflicts2 = async (usages) => {
3239
5577
  const native = await getNativeBinding();
3240
5578
  if (!native?.detectClassConflicts) {
3241
5579
  throw new Error("FATAL: Native binding 'detectClassConflicts' is required but not available.");
@@ -3252,11 +5590,11 @@ var detectConflicts = async (usages) => {
3252
5590
  };
3253
5591
  };
3254
5592
  var isSupportedTailwindConfigPath = (configPath) => {
3255
- return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path6__default.extname(configPath).toLowerCase());
5593
+ return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path9__default.extname(configPath).toLowerCase());
3256
5594
  };
3257
5595
  var resolveTailwindConfigPath = async (root, explicitPath) => {
3258
5596
  if (explicitPath) {
3259
- const resolved = path6__default.resolve(root, explicitPath);
5597
+ const resolved = path9__default.resolve(root, explicitPath);
3260
5598
  if (!await pathExists(resolved)) return null;
3261
5599
  return resolved;
3262
5600
  }
@@ -3267,7 +5605,7 @@ var resolveTailwindConfigPath = async (root, explicitPath) => {
3267
5605
  "tailwind.config.mjs"
3268
5606
  ];
3269
5607
  for (const candidate of candidates) {
3270
- const fullPath = path6__default.resolve(root, candidate);
5608
+ const fullPath = path9__default.resolve(root, candidate);
3271
5609
  if (await pathExists(fullPath)) return fullPath;
3272
5610
  }
3273
5611
  return null;
@@ -3321,8 +5659,8 @@ var collectCustomUtilities = (config) => {
3321
5659
  return out;
3322
5660
  };
3323
5661
  var collectSafelistFromSource = async (configPath) => {
3324
- const source = await fs5__default.promises.readFile(configPath, "utf8");
3325
- const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
5662
+ const source = await fs3__default.promises.readFile(configPath, "utf8");
5663
+ const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src3(), src_exports2));
3326
5664
  const allTokens = extractClassesNative2(source);
3327
5665
  const hasSafelist = source.includes("safelist");
3328
5666
  if (!hasSafelist) return [];
@@ -3335,7 +5673,7 @@ var collectSafelistFromSource = async (configPath) => {
3335
5673
  }
3336
5674
  return allTokens.filter((t) => safelistSet.has(t));
3337
5675
  };
3338
- var loadTailwindConfig = async (root, semanticOption) => {
5676
+ var loadTailwindConfig2 = async (root, semanticOption) => {
3339
5677
  const startMs = Date.now();
3340
5678
  const configPath = await resolveTailwindConfigPath(root, semanticOption?.tailwindConfigPath);
3341
5679
  if (!configPath) return null;
@@ -3348,7 +5686,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
3348
5686
  customUtilities: /* @__PURE__ */ new Set()
3349
5687
  };
3350
5688
  }
3351
- const configStat = await fs5__default.promises.stat(configPath).catch(() => null);
5689
+ const configStat = await fs3__default.promises.stat(configPath).catch(() => null);
3352
5690
  if (configStat) {
3353
5691
  const cached = tailwindConfigCache.get(configPath);
3354
5692
  if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
@@ -3416,7 +5754,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
3416
5754
  return loaded;
3417
5755
  };
3418
5756
  var buildSemanticReport = async (usages, root, semanticOption) => {
3419
- const loadedConfig = await loadTailwindConfig(root, semanticOption);
5757
+ const loadedConfig = await loadTailwindConfig2(root, semanticOption);
3420
5758
  const safelist = loadedConfig?.safelist ?? /* @__PURE__ */ new Set();
3421
5759
  const customUtilities = loadedConfig?.customUtilities ?? /* @__PURE__ */ new Set();
3422
5760
  const usageNames = new Set(usages.map((usage) => usage.name));
@@ -3435,7 +5773,7 @@ var buildSemanticReport = async (usages, root, semanticOption) => {
3435
5773
  results.filter((r) => !r.isKnown).map((r) => r.className)
3436
5774
  );
3437
5775
  const unknownClasses = usages.filter((usage) => unknownSet.has(usage.name)).map((usage) => ({ ...usage, isUnused: true }));
3438
- const { conflicts } = await detectConflicts(usages);
5776
+ const { conflicts } = await detectConflicts2(usages);
3439
5777
  return {
3440
5778
  unusedClasses,
3441
5779
  unknownClasses,
@@ -3507,7 +5845,7 @@ async function buildDistribution(usages, native) {
3507
5845
  }
3508
5846
  async function analyzeWorkspace(root, options = {}) {
3509
5847
  const startedAtMs = Date.now();
3510
- const resolvedRoot = path6__default.resolve(root);
5848
+ const resolvedRoot = path9__default.resolve(root);
3511
5849
  const normalizedOptions = parseAnalyzerOptions(options);
3512
5850
  const scan = await (async () => {
3513
5851
  const scanStartedAtMs = Date.now();
@@ -3609,37 +5947,18 @@ async function analyzeWorkspace(root, options = {}) {
3609
5947
  };
3610
5948
  }
3611
5949
 
3612
- // packages/domain/compiler/src/index.ts
3613
- init_nativeBridge();
3614
- var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
3615
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
3616
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
3617
- return result.css;
3618
- };
3619
- var mergeClassesStatic = (classes) => {
3620
- const result = normalizeAndDedupClasses(classes);
3621
- return result?.normalized || "";
3622
- };
3623
- var normalizeAndDedupClasses = (raw) => {
3624
- const native = getNativeBridge();
3625
- if (!native?.normalizeAndDedupClasses) {
3626
- throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
3627
- }
3628
- const result = native.normalizeAndDedupClasses(raw);
3629
- return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
3630
- };
3631
-
3632
5950
  // packages/domain/engine/src/index.ts
5951
+ init_internal();
5952
+ init_src3();
3633
5953
  init_src2();
3634
- init_src();
3635
5954
 
3636
5955
  // packages/domain/engine/src/incremental.ts
5956
+ init_src3();
3637
5957
  init_src2();
3638
- init_src();
3639
5958
  init_native_bridge2();
3640
5959
  var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
3641
- var log5 = createLogger("engine:incremental");
3642
- function rebuildWorkspaceResult(byFile) {
5960
+ var log5 = createLogger2("engine:incremental");
5961
+ function rebuildWorkspaceResult2(byFile) {
3643
5962
  const files = Array.from(byFile.values());
3644
5963
  const native = getNativeEngineBinding();
3645
5964
  if (native?.rebuildWorkspaceResult) {
@@ -3668,9 +5987,9 @@ function areClassSetsEqual(a, b) {
3668
5987
  }
3669
5988
  function applyIncrementalChange(previous, filePath, type, scanner) {
3670
5989
  const includeExtensions = scanner?.includeExtensions ?? DEFAULT_EXTENSIONS2;
3671
- if (!isScannableFile(filePath, includeExtensions)) return previous;
3672
- const byFile = new Map(previous.files.map((f) => [path6__default.resolve(f.file), f]));
3673
- const normalizedPath = path6__default.resolve(filePath);
5990
+ if (!isScannableFile2(filePath, includeExtensions)) return previous;
5991
+ const byFile = new Map(previous.files.map((f) => [path9__default.resolve(f.file), f]));
5992
+ const normalizedPath = path9__default.resolve(filePath);
3674
5993
  const native = getNativeEngineBinding();
3675
5994
  if (!native?.processFileChange) {
3676
5995
  throw new Error(
@@ -3682,11 +6001,11 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
3682
6001
  log5.debug(`native unlink ${normalizedPath}`);
3683
6002
  native.processFileChange(normalizedPath, existing2?.classes ?? [], null);
3684
6003
  byFile.delete(normalizedPath);
3685
- return rebuildWorkspaceResult(byFile);
6004
+ return rebuildWorkspaceResult2(byFile);
3686
6005
  }
3687
6006
  log5.debug(`native change ${normalizedPath}`);
3688
- const scanned = scanFile(normalizedPath);
3689
- const content = fs5__default.readFileSync(normalizedPath, "utf8");
6007
+ const scanned = scanFile2(normalizedPath);
6008
+ const content = fs3__default.readFileSync(normalizedPath, "utf8");
3690
6009
  const diff = native.processFileChange(normalizedPath, scanned.classes, content);
3691
6010
  const existing = byFile.get(normalizedPath);
3692
6011
  if (diff && existing) {
@@ -3698,7 +6017,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
3698
6017
  log5.debug(`native diff cold-sync ${normalizedPath}`);
3699
6018
  byFile.set(normalizedPath, { file: normalizedPath, classes: scanned.classes });
3700
6019
  }
3701
- return rebuildWorkspaceResult(byFile);
6020
+ return rebuildWorkspaceResult2(byFile);
3702
6021
  }
3703
6022
 
3704
6023
  // packages/domain/engine/src/impactTracker.ts
@@ -4031,13 +6350,13 @@ var EngineMetricsCollector = class {
4031
6350
  };
4032
6351
 
4033
6352
  // packages/domain/engine/src/metricsWriter.ts
4034
- init_src();
6353
+ init_src2();
4035
6354
  var METRICS_FILE_NAME = "metrics.json";
4036
6355
  var CACHE_DIR = ".tw-cache";
4037
6356
  function writeMetrics(metrics, cwd = process.cwd()) {
4038
6357
  try {
4039
- const cacheDir = path6__default.join(cwd, CACHE_DIR);
4040
- fs5__default.mkdirSync(cacheDir, { recursive: true });
6358
+ const cacheDir = path9__default.join(cwd, CACHE_DIR);
6359
+ fs3__default.mkdirSync(cacheDir, { recursive: true });
4041
6360
  const mem = process.memoryUsage();
4042
6361
  const data = {
4043
6362
  ...metrics,
@@ -4048,7 +6367,7 @@ function writeMetrics(metrics, cwd = process.cwd()) {
4048
6367
  },
4049
6368
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
4050
6369
  };
4051
- fs5__default.writeFileSync(path6__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
6370
+ fs3__default.writeFileSync(path9__default.join(cacheDir, METRICS_FILE_NAME), JSON.stringify(data, null, 2));
4052
6371
  } catch {
4053
6372
  }
4054
6373
  }
@@ -4155,19 +6474,19 @@ var parseEngineOptions = (options) => parseWithSchema3(EngineOptionsSchema, opti
4155
6474
  var parseEngineWatchOptions = (options) => parseWithSchema3(EngineWatchOptionsSchema, options ?? {}, "engine watch options are invalid");
4156
6475
 
4157
6476
  // packages/domain/engine/src/watch.ts
4158
- var _native = null;
6477
+ var _native2 = null;
4159
6478
  function getNativeWatcher() {
4160
- if (_native !== null) return _native;
6479
+ if (_native2 !== null) return _native2;
4161
6480
  try {
4162
- const { resolveNativeBinary: resolveNativeBinary2 } = (init_src(), __toCommonJS(src_exports));
6481
+ const { resolveNativeBinary: resolveNativeBinary2 } = (init_src2(), __toCommonJS(src_exports));
4163
6482
  const { path: binPath } = resolveNativeBinary2(__dirname);
4164
6483
  if (binPath) {
4165
- _native = __require(binPath);
6484
+ _native2 = __require(binPath);
4166
6485
  }
4167
6486
  } catch {
4168
- _native = {};
6487
+ _native2 = {};
4169
6488
  }
4170
- return _native;
6489
+ return _native2;
4171
6490
  }
4172
6491
  function watchWorkspaceNative(rootDir, onEvent, options) {
4173
6492
  const native = getNativeWatcher();
@@ -4231,7 +6550,7 @@ init_ir();
4231
6550
 
4232
6551
  // packages/domain/engine/src/reverseLookup.ts
4233
6552
  init_native_bridge2();
4234
- function getNative() {
6553
+ function getNative2() {
4235
6554
  const native = getNativeEngineBinding();
4236
6555
  if (!native?.reverseLookupFromCss || !native?.reverseLookupByProperty || !native?.reverseLookupFindDependents) {
4237
6556
  throw new Error(
@@ -4256,15 +6575,15 @@ function normaliseNativeResults(raw) {
4256
6575
  var ReverseLookup = class {
4257
6576
  fromCSS(cssProperty, cssValue, css) {
4258
6577
  if (!css || !cssProperty) return [];
4259
- return normaliseNativeResults(getNative().reverseLookupFromCss(css, cssProperty, cssValue));
6578
+ return normaliseNativeResults(getNative2().reverseLookupFromCss(css, cssProperty, cssValue));
4260
6579
  }
4261
6580
  findByProperty(property, css) {
4262
6581
  if (!css || !property) return [];
4263
- return normaliseNativeResults(getNative().reverseLookupByProperty(css, property));
6582
+ return normaliseNativeResults(getNative2().reverseLookupByProperty(css, property));
4264
6583
  }
4265
6584
  findDependents(className, css) {
4266
6585
  if (!css || !className) return [];
4267
- return getNative().reverseLookupFindDependents(css, className);
6586
+ return getNative2().reverseLookupFindDependents(css, className);
4268
6587
  }
4269
6588
  fromBundle(className, css) {
4270
6589
  if (!css || !className) return [];
@@ -4309,7 +6628,7 @@ init_resolver();
4309
6628
  init_cssToIr();
4310
6629
 
4311
6630
  // packages/domain/engine/src/watch-native.ts
4312
- init_src();
6631
+ init_src2();
4313
6632
  var watchBindingState = {
4314
6633
  binding: void 0
4315
6634
  };
@@ -4328,22 +6647,22 @@ var getBinding = () => {
4328
6647
  const _paGnu = _pa === "linux-x64" ? "linux-x64-gnu" : _pa === "linux-arm64" ? "linux-arm64-gnu" : _pa;
4329
6648
  const candidates = [
4330
6649
  // new binary name: tailwind-styled-native
4331
- path6__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
4332
- path6__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_pa}.node`),
6650
+ path9__default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
6651
+ path9__default.resolve(process.cwd(), "native", `tailwind-styled-native.${_pa}.node`),
4333
6652
  // npm install case: dist/../native/
4334
- path6__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
4335
- path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_pa}.node`),
4336
- path6__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_paGnu}.node`),
6653
+ path9__default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
6654
+ path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_pa}.node`),
6655
+ path9__default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_paGnu}.node`),
4337
6656
  // monorepo dev: 4-level up
4338
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
4339
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_paGnu}.node`),
6657
+ path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
6658
+ path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_paGnu}.node`),
4340
6659
  // 3-level fallback
4341
- path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
6660
+ path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
4342
6661
  // backward compat: tailwind_styled_parser
4343
- path6__default.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
4344
- path6__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
4345
- path6__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
4346
- path6__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node")
6662
+ path9__default.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
6663
+ path9__default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
6664
+ path9__default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
6665
+ path9__default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node")
4347
6666
  ];
4348
6667
  for (const c of candidates) {
4349
6668
  try {
@@ -4360,11 +6679,11 @@ var getBinding = () => {
4360
6679
  "FATAL: Native watch binding not found in any candidate path.\nThis package requires native Rust bindings.\n\nCandidates checked:\n" + candidates.map((p) => ` - ${p}`).join("\n") + "\n\nResolution steps:\n1. Build the native Rust module: npm run build:rust"
4361
6680
  );
4362
6681
  };
4363
- var log6 = createLogger("engine:watch-native");
6682
+ var log6 = createLogger2("engine:watch-native");
4364
6683
  function watchWorkspace2(rootDir, callback, options = {}) {
4365
6684
  const binding = getBinding();
4366
6685
  const pollMs = options.pollIntervalMs ?? 500;
4367
- const resolvedRoot = path6__default.resolve(rootDir);
6686
+ const resolvedRoot = path9__default.resolve(rootDir);
4368
6687
  const result = (() => {
4369
6688
  try {
4370
6689
  return binding.startWatch(resolvedRoot);
@@ -4401,7 +6720,7 @@ This package requires native Rust bindings.`
4401
6720
  const deduped = /* @__PURE__ */ new Set();
4402
6721
  const events = [];
4403
6722
  for (const e of raw) {
4404
- const absPath = path6__default.isAbsolute(e.path) ? path6__default.normalize(e.path) : path6__default.resolve(resolvedRoot, e.path);
6723
+ const absPath = path9__default.isAbsolute(e.path) ? path9__default.normalize(e.path) : path9__default.resolve(resolvedRoot, e.path);
4405
6724
  const kind = e.kind;
4406
6725
  const key = `${kind}:${absPath}`;
4407
6726
  if (deduped.has(key)) continue;
@@ -4438,11 +6757,11 @@ var configState = {
4438
6757
  return this.tailwindConfigLoaded;
4439
6758
  }
4440
6759
  };
4441
- var log7 = createLogger("engine");
6760
+ var log7 = createLogger2("engine");
4442
6761
  async function loadTailwindConfigFromPath(root, tailwindConfigPath) {
4443
6762
  if (!tailwindConfigPath) return void 0;
4444
- const configPath = path6__default.resolve(root, tailwindConfigPath);
4445
- if (!fs5__default.existsSync(configPath)) {
6763
+ const configPath = path9__default.resolve(root, tailwindConfigPath);
6764
+ if (!fs3__default.existsSync(configPath)) {
4446
6765
  throw TwError.fromIo("CONFIG_NOT_FOUND", `tailwindConfigPath not found: ${configPath}`);
4447
6766
  }
4448
6767
  const imported = await import(pathToFileURL(configPath).href);
@@ -4508,13 +6827,14 @@ async function buildFromScan(scan, root, options, tailwindConfig) {
4508
6827
  };
4509
6828
  }
4510
6829
  function countWorkspacePackages(root) {
4511
- const packagesDir = path6__default.join(root, "packages");
4512
- if (!fs5__default.existsSync(packagesDir)) return 0;
6830
+ const packagesDir = path9__default.join(root, "packages");
6831
+ if (!fs3__default.existsSync(packagesDir)) return 0;
4513
6832
  try {
4514
- return fs5__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
4515
- (entry) => entry.isDirectory() && fs5__default.existsSync(path6__default.join(packagesDir, entry.name, "package.json"))
6833
+ return fs3__default.readdirSync(packagesDir, { withFileTypes: true }).filter(
6834
+ (entry) => entry.isDirectory() && fs3__default.existsSync(path9__default.join(packagesDir, entry.name, "package.json"))
4516
6835
  ).length;
4517
- } catch {
6836
+ } catch (err) {
6837
+ log7.debug(`countWorkspacePackages: ${err instanceof Error ? err.message : String(err)}`);
4518
6838
  return 0;
4519
6839
  }
4520
6840
  }
@@ -4548,7 +6868,7 @@ function writeDashboardMetrics(root, mode, result, metrics) {
4548
6868
  async function createEngine(rawOptions = {}) {
4549
6869
  const options = parseEngineOptions(rawOptions);
4550
6870
  const root = options.root ?? process.cwd();
4551
- const resolvedRoot = path6__default.resolve(root);
6871
+ const resolvedRoot = path9__default.resolve(root);
4552
6872
  const plugins = rawOptions.plugins ?? [];
4553
6873
  const getTailwindConfig = async () => {
4554
6874
  if (configState.isLoaded()) return configState.getConfig();
@@ -4695,12 +7015,13 @@ async function createEngine(rawOptions = {}) {
4695
7015
  const shouldForceFullRescan = (event) => {
4696
7016
  if (event.type === "unlink") return false;
4697
7017
  try {
4698
- const stat = fs5__default.statSync(event.filePath);
7018
+ const stat = fs3__default.statSync(event.filePath);
4699
7019
  if (stat.size > largeFileThreshold) {
4700
7020
  metrics.markSkippedLargeFile();
4701
7021
  return true;
4702
7022
  }
4703
- } catch {
7023
+ } catch (statErr) {
7024
+ log7.debug(`stat failed for ${event.filePath}: ${statErr instanceof Error ? statErr.message : String(statErr)}`);
4704
7025
  return false;
4705
7026
  }
4706
7027
  return false;
@@ -4811,21 +7132,21 @@ async function createEngine(rawOptions = {}) {
4811
7132
  }
4812
7133
  };
4813
7134
  }
4814
- async function scanWorkspace2(opts = {}) {
4815
- const root = path6__default.resolve(opts.root ?? process.cwd());
7135
+ async function scanWorkspace3(opts = {}) {
7136
+ const root = path9__default.resolve(opts.root ?? process.cwd());
4816
7137
  return scanWorkspaceAsync(root, {
4817
7138
  includeExtensions: opts.extensions,
4818
7139
  ignoreDirectories: opts.ignoreDirectories
4819
7140
  });
4820
7141
  }
4821
7142
  async function analyzeWorkspace2(opts = {}) {
4822
- const root = path6__default.resolve(opts.root ?? process.cwd());
7143
+ const root = path9__default.resolve(opts.root ?? process.cwd());
4823
7144
  return analyzeWorkspace(root, {
4824
7145
  classStats: { top: opts.top ?? 20 }
4825
7146
  });
4826
7147
  }
4827
7148
  async function generateSafelist2(opts = {}) {
4828
- const scan = await scanWorkspace2(opts);
7149
+ const scan = await scanWorkspace3(opts);
4829
7150
  return scan.uniqueClasses;
4830
7151
  }
4831
7152
  async function build(opts = {}) {
@@ -4850,7 +7171,8 @@ async function traceClass(className, scanResult, css) {
4850
7171
  resolver.registerClass(registeredClassName, ruleIds);
4851
7172
  }
4852
7173
  return trace2(className, resolver);
4853
- } catch {
7174
+ } catch (traceErr) {
7175
+ log7.debug(`traceClass("${className}"): ${traceErr instanceof Error ? traceErr.message : String(traceErr)}`);
4854
7176
  return null;
4855
7177
  }
4856
7178
  }
@@ -4891,6 +7213,6 @@ async function inspectClass(className, scanResult, css = "") {
4891
7213
  };
4892
7214
  }
4893
7215
 
4894
- export { BuildResultSchema, BundleAnalyzer, CascadeResolutionId, CascadeResolver, CascadeStage, ConditionId, ConditionResult, EngineMetricsCollector, EngineOptionsSchema, EngineWatchOptionsSchema, ImpactTracker, Importance, LayerId, Origin, PropertyId, ReverseLookup, RuleId, SelectorId, ValueId, VariantChainId, analyzeWorkspace2 as analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain, createEngine, createFingerprint, createResolutionReason, generateSafelist2 as generateSafelist, inspectClass, parseCssToIr, parseEngineOptions, parseEngineWatchOptions, runAfterBuild, runAfterScan, runAfterWatch, runBeforeBuild, runBeforeScan, runBeforeWatch, runOnError, runTransformClasses, scanWorkspace2 as scanWorkspace, trace, traceClass, traceClasses, watchWorkspace as watchWorkspaceLegacy, watchWorkspace2 as watchWorkspaceNative };
7216
+ export { BuildResultSchema, BundleAnalyzer, CascadeResolutionId, CascadeResolver, CascadeStage, ConditionId, ConditionResult, EngineMetricsCollector, EngineOptionsSchema, EngineWatchOptionsSchema, ImpactTracker, Importance, LayerId, Origin, PropertyId, ReverseLookup, RuleId, SelectorId, ValueId, VariantChainId, analyzeWorkspace2 as analyzeWorkspace, applyIncrementalChange, build, buildProvenanceChain, createEngine, createFingerprint2 as createFingerprint, createResolutionReason, generateSafelist2 as generateSafelist, inspectClass, parseCssToIr, parseEngineOptions, parseEngineWatchOptions, runAfterBuild, runAfterScan, runAfterWatch, runBeforeBuild, runBeforeScan, runBeforeWatch, runOnError, runTransformClasses, scanWorkspace3 as scanWorkspace, trace, traceClass, traceClasses, watchWorkspace as watchWorkspaceLegacy, watchWorkspace2 as watchWorkspaceNative };
4895
7217
  //# sourceMappingURL=engine.mjs.map
4896
7218
  //# sourceMappingURL=engine.mjs.map