tailwind-styled-v4 5.0.12 → 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 (60) hide show
  1. package/README.md +100 -4
  2. package/dist/animate.d.mts +4 -0
  3. package/dist/animate.d.ts +4 -0
  4. package/dist/animate.js +22 -0
  5. package/dist/animate.js.map +1 -1
  6. package/dist/animate.mjs +22 -0
  7. package/dist/animate.mjs.map +1 -1
  8. package/dist/atomic.js +42 -0
  9. package/dist/atomic.js.map +1 -1
  10. package/dist/atomic.mjs +42 -0
  11. package/dist/atomic.mjs.map +1 -1
  12. package/dist/cli.js +142 -0
  13. package/dist/cli.js.map +1 -1
  14. package/dist/cli.mjs +142 -0
  15. package/dist/cli.mjs.map +1 -1
  16. package/dist/compiler.d.mts +1045 -991
  17. package/dist/compiler.d.ts +1045 -991
  18. package/dist/compiler.js +888 -922
  19. package/dist/compiler.js.map +1 -1
  20. package/dist/compiler.mjs +873 -908
  21. package/dist/compiler.mjs.map +1 -1
  22. package/dist/engine.js +1637 -340
  23. package/dist/engine.js.map +1 -1
  24. package/dist/engine.mjs +1636 -339
  25. package/dist/engine.mjs.map +1 -1
  26. package/dist/index.js +1636 -339
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +1636 -339
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/next.js +1060 -970
  31. package/dist/next.js.map +1 -1
  32. package/dist/next.mjs +1060 -970
  33. package/dist/next.mjs.map +1 -1
  34. package/dist/shared.js +1607 -310
  35. package/dist/shared.js.map +1 -1
  36. package/dist/shared.mjs +1607 -310
  37. package/dist/shared.mjs.map +1 -1
  38. package/dist/svelte.js.map +1 -1
  39. package/dist/svelte.mjs.map +1 -1
  40. package/dist/turbopackLoader.js +1610 -313
  41. package/dist/turbopackLoader.js.map +1 -1
  42. package/dist/turbopackLoader.mjs +1610 -313
  43. package/dist/turbopackLoader.mjs.map +1 -1
  44. package/dist/tw.js +142 -0
  45. package/dist/tw.js.map +1 -1
  46. package/dist/tw.mjs +142 -0
  47. package/dist/tw.mjs.map +1 -1
  48. package/dist/vite.js +1622 -325
  49. package/dist/vite.js.map +1 -1
  50. package/dist/vite.mjs +1622 -325
  51. package/dist/vite.mjs.map +1 -1
  52. package/dist/vue.js.map +1 -1
  53. package/dist/vue.mjs.map +1 -1
  54. package/dist/webpackLoader.js +66 -15
  55. package/dist/webpackLoader.js.map +1 -1
  56. package/dist/webpackLoader.mjs +66 -15
  57. package/dist/webpackLoader.mjs.map +1 -1
  58. package/native/tailwind-styled-native.node +0 -0
  59. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  60. package/package.json +1 -1
package/dist/vite.js CHANGED
@@ -1009,46 +1009,39 @@ var init_observability = __esm({
1009
1009
  }
1010
1010
  });
1011
1011
 
1012
- // packages/domain/compiler/src/cssGeneratorNative.ts
1012
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
1013
1013
  async function generateCssNative(classes, options) {
1014
- const {
1015
- theme,
1016
- fallbackToJs = true,
1017
- logFallback = false
1018
- } = options;
1014
+ const { theme } = options;
1015
+ const native = getNativeBridge();
1016
+ if (!native?.generateCssNative) {
1017
+ throw new Error(
1018
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
1019
+ );
1020
+ }
1021
+ const themeJson = JSON.stringify(theme);
1022
+ const css = native.generateCssNative(classes, themeJson);
1023
+ return css;
1024
+ }
1025
+ function clearThemeCache() {
1019
1026
  try {
1020
1027
  const native = getNativeBridge();
1021
- if (!native?.generateCssNative) {
1022
- throw new Error("generateCssNative not available in native binding");
1023
- }
1024
- const themeJson = JSON.stringify(theme);
1025
- const css = native.generateCssNative(classes, themeJson);
1026
- return css;
1027
- } catch (error) {
1028
- if (!fallbackToJs) {
1029
- throw error;
1030
- }
1031
- if (logFallback) {
1032
- console.warn(
1033
- "[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
1034
- error instanceof Error ? error.message : String(error)
1035
- );
1028
+ if (!native?.clearThemeCache) {
1029
+ return;
1036
1030
  }
1037
- return generateRawCss(classes);
1031
+ native.clearThemeCache();
1032
+ } catch {
1038
1033
  }
1039
1034
  }
1040
1035
  var init_cssGeneratorNative = __esm({
1041
- "packages/domain/compiler/src/cssGeneratorNative.ts"() {
1036
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
1042
1037
  init_nativeBridge();
1043
- init_tailwindEngine();
1044
1038
  }
1045
1039
  });
1046
1040
 
1047
- // packages/domain/compiler/src/tailwindEngine.ts
1041
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
1048
1042
  var tailwindEngine_exports = {};
1049
1043
  __export(tailwindEngine_exports, {
1050
1044
  clearCache: () => clearCache,
1051
- generateRawCss: () => generateRawCss,
1052
1045
  getCacheStats: () => getCacheStats,
1053
1046
  processTailwindCssWithTargets: () => processTailwindCssWithTargets,
1054
1047
  runCssPipeline: () => runCssPipeline,
@@ -1082,48 +1075,6 @@ function clearCache() {
1082
1075
  _cacheHits = 0;
1083
1076
  _cacheMisses = 0;
1084
1077
  }
1085
- function loadTailwindEngine() {
1086
- if (_twEngine) return _twEngine;
1087
- if (_twEngineError) throw _twEngineError;
1088
- try {
1089
- const tw = require2("tailwindcss");
1090
- if (typeof tw.compile !== "function") {
1091
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1092
- }
1093
- _twEngine = tw;
1094
- return _twEngine;
1095
- } catch (e) {
1096
- _twEngineError = e instanceof Error ? e : new Error(String(e));
1097
- throw _twEngineError;
1098
- }
1099
- }
1100
- async function generateRawCss(classes, cssEntryContent, root) {
1101
- if (classes.length === 0) return "";
1102
- const tw = loadTailwindEngine();
1103
- const input = cssEntryContent ?? "@import 'tailwindcss';";
1104
- const { readFileSync, existsSync: existsSync3 } = await import('fs');
1105
- const { dirname, resolve: resolve2 } = await import('path');
1106
- const projectRoot = root ?? process.cwd();
1107
- const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
1108
- const loadStylesheet = async (id, base) => {
1109
- try {
1110
- 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;
1111
- const pkgPath = req.resolve(cssId);
1112
- return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1113
- } catch {
1114
- try {
1115
- const absPath = resolve2(base, id);
1116
- if (existsSync3(absPath)) {
1117
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1118
- }
1119
- } catch {
1120
- }
1121
- return { content: "", base };
1122
- }
1123
- };
1124
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1125
- return compiler.build(classes);
1126
- }
1127
1078
  function getThemeConfig() {
1128
1079
  return {
1129
1080
  colors: {
@@ -1220,20 +1171,9 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1220
1171
  _cacheMisses++;
1221
1172
  let rawCss;
1222
1173
  let usedRustCompiler = false;
1223
- try {
1224
- const theme = getThemeConfig();
1225
- rawCss = await generateCssNative(unique, {
1226
- theme,
1227
- fallbackToJs: true,
1228
- logFallback: process.env.DEBUG?.includes("compiler") === true
1229
- });
1230
- usedRustCompiler = true;
1231
- } catch (error) {
1232
- if (process.env.DEBUG?.includes("compiler")) {
1233
- console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
1234
- }
1235
- rawCss = await generateRawCss(unique, cssEntryContent, root);
1236
- }
1174
+ const theme = getThemeConfig();
1175
+ rawCss = await generateCssNative(unique, { theme });
1176
+ usedRustCompiler = true;
1237
1177
  const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
1238
1178
  if (process.env.DEBUG?.includes("compiler")) {
1239
1179
  console.log(
@@ -1241,42 +1181,1355 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1241
1181
  `Size: ${finalCss.length} bytes`
1242
1182
  );
1243
1183
  }
1244
- const result = {
1245
- css: finalCss,
1246
- classes: unique,
1247
- sizeBytes: finalCss.length,
1248
- optimized: minify
1249
- };
1250
- _evictOldestIfNeeded();
1251
- _cssCache.set(cacheKey, result);
1252
- return result;
1184
+ const result = {
1185
+ css: finalCss,
1186
+ classes: unique,
1187
+ sizeBytes: finalCss.length,
1188
+ optimized: minify
1189
+ };
1190
+ _evictOldestIfNeeded();
1191
+ _cssCache.set(cacheKey, result);
1192
+ return result;
1193
+ }
1194
+ function runCssPipelineSync(_classes) {
1195
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1196
+ }
1197
+ function processTailwindCssWithTargets(css, targets) {
1198
+ const native = getNativeBridge();
1199
+ if (!native?.processTailwindCssWithTargets) {
1200
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
1201
+ }
1202
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
1203
+ if (!result?.css) {
1204
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
1205
+ }
1206
+ return result.css;
1207
+ }
1208
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1209
+ var init_tailwindEngine = __esm({
1210
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1211
+ init_nativeBridge();
1212
+ init_cssGeneratorNative();
1213
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
1214
+ _cssCache = /* @__PURE__ */ new Map();
1215
+ _cacheHits = 0;
1216
+ _cacheMisses = 0;
1217
+ MAX_CACHE_SIZE = 100;
1218
+ }
1219
+ });
1220
+
1221
+ // packages/domain/compiler/src/compiler/compilationNative.ts
1222
+ function compileCssNative2(classes, prefix) {
1223
+ const native = getNativeBridge();
1224
+ if (!native?.compileCss) throw new Error("compileCss not available");
1225
+ return native.compileCss(classes, prefix);
1226
+ }
1227
+ function compileCssLightning(classes) {
1228
+ const native = getNativeBridge();
1229
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
1230
+ return native.compileCssLightning(classes);
1231
+ }
1232
+ function extractTwStateConfigsNative(source, filename) {
1233
+ const native = getNativeBridge();
1234
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
1235
+ return native.extractTwStateConfigs(source, filename);
1236
+ }
1237
+ function generateStaticStateCssNative(inputs, resolvedCss) {
1238
+ const native = getNativeBridge();
1239
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
1240
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
1241
+ }
1242
+ function extractAndGenerateStateCssNative(source, filename) {
1243
+ const native = getNativeBridge();
1244
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
1245
+ return native.extractAndGenerateStateCss(source, filename);
1246
+ }
1247
+ function layoutClassesToCss(classes) {
1248
+ const native = getNativeBridge();
1249
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
1250
+ return native.layoutClassesToCss(classes);
1251
+ }
1252
+ function hashContent(input, algorithm = "sha256", length = 8) {
1253
+ const native = getNativeBridge();
1254
+ if (!native?.hashContent) throw new Error("hashContent not available");
1255
+ return native.hashContent(input, algorithm, length);
1256
+ }
1257
+ function extractTwContainerConfigs(source) {
1258
+ const native = getNativeBridge();
1259
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
1260
+ return native.extractTwContainerConfigs(source);
1261
+ }
1262
+ function parseAtomicClass(twClass) {
1263
+ const native = getNativeBridge();
1264
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
1265
+ return native.parseAtomicClass(twClass);
1266
+ }
1267
+ function generateAtomicCss(rulesJson) {
1268
+ const native = getNativeBridge();
1269
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
1270
+ return native.generateAtomicCss(rulesJson);
1271
+ }
1272
+ function toAtomicClasses(twClasses) {
1273
+ const native = getNativeBridge();
1274
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
1275
+ return native.toAtomicClasses(twClasses);
1276
+ }
1277
+ function clearAtomicRegistry() {
1278
+ const native = getNativeBridge();
1279
+ if (!native?.clearAtomicRegistry) return;
1280
+ native.clearAtomicRegistry();
1281
+ }
1282
+ function atomicRegistrySize() {
1283
+ const native = getNativeBridge();
1284
+ if (!native?.atomicRegistrySize) return 0;
1285
+ return native.atomicRegistrySize();
1286
+ }
1287
+ var init_compilationNative = __esm({
1288
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
1289
+ init_nativeBridge();
1290
+ }
1291
+ });
1292
+
1293
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
1294
+ function compileClass(input) {
1295
+ const native = getNativeBridge();
1296
+ if (!native?.compile_class) throw new Error("compile_class not available");
1297
+ const resultJson = native.compile_class(input);
1298
+ try {
1299
+ return JSON.parse(resultJson);
1300
+ } catch {
1301
+ return {
1302
+ selector: "",
1303
+ declarations: "",
1304
+ properties: [],
1305
+ specificity: 0
1306
+ };
1307
+ }
1308
+ }
1309
+ function compileClasses(inputs) {
1310
+ const native = getNativeBridge();
1311
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
1312
+ const resultJson = native.compile_classes(inputs);
1313
+ try {
1314
+ return JSON.parse(resultJson);
1315
+ } catch {
1316
+ return {
1317
+ css: "",
1318
+ resolved_classes: [],
1319
+ unknown_classes: [],
1320
+ size_bytes: 0,
1321
+ duration_ms: 0
1322
+ };
1323
+ }
1324
+ }
1325
+ function compileToCss(input, minify) {
1326
+ const native = getNativeBridge();
1327
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
1328
+ return native.compile_to_css(input, minify ?? false);
1329
+ }
1330
+ function compileToCssBatch(inputs, minify) {
1331
+ const native = getNativeBridge();
1332
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
1333
+ return native.compile_to_css_batch(inputs, minify ?? false);
1334
+ }
1335
+ function minifyCss(css) {
1336
+ const native = getNativeBridge();
1337
+ if (!native?.minify_css) throw new Error("minify_css not available");
1338
+ return native.minify_css(css);
1339
+ }
1340
+ function compileAnimation(animationName, from, to) {
1341
+ const native = getNativeBridge();
1342
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
1343
+ const resultJson = native.compile_animation(animationName, from, to);
1344
+ try {
1345
+ return JSON.parse(resultJson);
1346
+ } catch {
1347
+ return {
1348
+ animation_id: "",
1349
+ keyframes_css: "",
1350
+ animation_rule: "",
1351
+ duration_ms: 0
1352
+ };
1353
+ }
1354
+ }
1355
+ function compileKeyframes(name, stopsJson) {
1356
+ const native = getNativeBridge();
1357
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
1358
+ const resultJson = native.compile_keyframes(name, stopsJson);
1359
+ try {
1360
+ return JSON.parse(resultJson);
1361
+ } catch {
1362
+ return {
1363
+ animation_id: "",
1364
+ keyframes_css: "",
1365
+ animation_rule: "",
1366
+ duration_ms: 0
1367
+ };
1368
+ }
1369
+ }
1370
+ function compileTheme(tokensJson, themeName, prefix) {
1371
+ const native = getNativeBridge();
1372
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
1373
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
1374
+ try {
1375
+ return JSON.parse(resultJson);
1376
+ } catch {
1377
+ return {
1378
+ selector: ":root",
1379
+ variables: [],
1380
+ variables_css: "",
1381
+ theme_name: themeName
1382
+ };
1383
+ }
1384
+ }
1385
+ function twMerge(classString) {
1386
+ const native = getNativeBridge();
1387
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
1388
+ return native.tw_merge(classString);
1389
+ }
1390
+ function twMergeMany(classStrings) {
1391
+ const native = getNativeBridge();
1392
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
1393
+ return native.tw_merge_many(classStrings);
1394
+ }
1395
+ function twMergeWithSeparator(classString, options) {
1396
+ const native = getNativeBridge();
1397
+ if (!native?.tw_merge_with_separator)
1398
+ throw new Error("tw_merge_with_separator not available");
1399
+ const opts = {
1400
+ separator: options.separator,
1401
+ debug: options.debug
1402
+ };
1403
+ return native.tw_merge_with_separator(classString, opts);
1404
+ }
1405
+ function twMergeManyWithSeparator(classStrings, options) {
1406
+ const native = getNativeBridge();
1407
+ if (!native?.tw_merge_many_with_separator)
1408
+ throw new Error("tw_merge_many_with_separator not available");
1409
+ const opts = {
1410
+ separator: options.separator,
1411
+ debug: options.debug
1412
+ };
1413
+ return native.tw_merge_many_with_separator(classStrings, opts);
1414
+ }
1415
+ function twMergeRaw(classLists) {
1416
+ const native = getNativeBridge();
1417
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
1418
+ return native.tw_merge_raw(classLists);
1419
+ }
1420
+ var init_cssCompilationNative = __esm({
1421
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
1422
+ init_nativeBridge();
1423
+ }
1424
+ });
1425
+
1426
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
1427
+ function idRegistryCreate() {
1428
+ const native = getNativeBridge();
1429
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
1430
+ return native.id_registry_create();
1431
+ }
1432
+ function idRegistryGenerate(handle, name) {
1433
+ const native = getNativeBridge();
1434
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
1435
+ return native.id_registry_generate(handle, name);
1436
+ }
1437
+ function idRegistryLookup(handle, name) {
1438
+ const native = getNativeBridge();
1439
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
1440
+ return native.id_registry_lookup(handle, name);
1441
+ }
1442
+ function idRegistryNext(handle) {
1443
+ const native = getNativeBridge();
1444
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
1445
+ return native.id_registry_next(handle);
1446
+ }
1447
+ function idRegistryDestroy(handle) {
1448
+ const native = getNativeBridge();
1449
+ if (!native?.id_registry_destroy) return;
1450
+ native.id_registry_destroy(handle);
1451
+ }
1452
+ function idRegistryReset(handle) {
1453
+ const native = getNativeBridge();
1454
+ if (!native?.id_registry_reset) return;
1455
+ native.id_registry_reset(handle);
1456
+ }
1457
+ function idRegistrySnapshot(handle) {
1458
+ const native = getNativeBridge();
1459
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
1460
+ const snapshotJson = native.id_registry_snapshot(handle);
1461
+ try {
1462
+ return JSON.parse(snapshotJson);
1463
+ } catch {
1464
+ return {
1465
+ handle,
1466
+ next_id: 0,
1467
+ entries: [],
1468
+ total_entries: 0
1469
+ };
1470
+ }
1471
+ }
1472
+ function idRegistryActiveCount() {
1473
+ const native = getNativeBridge();
1474
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
1475
+ return native.id_registry_active_count();
1476
+ }
1477
+ function registerPropertyName(propertyName) {
1478
+ const native = getNativeBridge();
1479
+ if (!native?.register_property_name)
1480
+ throw new Error("register_property_name not available");
1481
+ return native.register_property_name(propertyName);
1482
+ }
1483
+ function registerValueName(valueName) {
1484
+ const native = getNativeBridge();
1485
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
1486
+ return native.register_value_name(valueName);
1487
+ }
1488
+ function propertyIdToString(propertyId) {
1489
+ const native = getNativeBridge();
1490
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
1491
+ return native.property_id_to_string(propertyId);
1492
+ }
1493
+ function valueIdToString(valueId) {
1494
+ const native = getNativeBridge();
1495
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
1496
+ return native.value_id_to_string(valueId);
1497
+ }
1498
+ function reverseLookupProperty(propertyId) {
1499
+ const native = getNativeBridge();
1500
+ if (!native?.reverse_lookup_property)
1501
+ throw new Error("reverse_lookup_property not available");
1502
+ return native.reverse_lookup_property(propertyId);
1503
+ }
1504
+ function reverseLookupValue(valueId) {
1505
+ const native = getNativeBridge();
1506
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
1507
+ return native.reverse_lookup_value(valueId);
1508
+ }
1509
+ function idRegistryExport(handle) {
1510
+ const native = getNativeBridge();
1511
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
1512
+ return native.id_registry_export(handle);
1513
+ }
1514
+ function idRegistryImport(importedData) {
1515
+ const native = getNativeBridge();
1516
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
1517
+ return native.id_registry_import(importedData);
1518
+ }
1519
+ var init_idRegistryNative = __esm({
1520
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
1521
+ init_nativeBridge();
1522
+ }
1523
+ });
1524
+
1525
+ // packages/domain/compiler/src/compiler/streamingNative.ts
1526
+ function processFileChange(fileChangeJson) {
1527
+ const native = getNativeBridge();
1528
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
1529
+ const resultJson = native.process_file_change(fileChangeJson);
1530
+ try {
1531
+ return JSON.parse(resultJson);
1532
+ } catch {
1533
+ return {
1534
+ file_path: "",
1535
+ status: "error",
1536
+ old_classes: [],
1537
+ new_classes: [],
1538
+ added_classes: [],
1539
+ removed_classes: [],
1540
+ changed: false,
1541
+ fingerprint: "",
1542
+ error: "Failed to parse result"
1543
+ };
1544
+ }
1545
+ }
1546
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
1547
+ const native = getNativeBridge();
1548
+ if (!native?.compute_incremental_diff)
1549
+ throw new Error("compute_incremental_diff not available");
1550
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
1551
+ try {
1552
+ return JSON.parse(resultJson);
1553
+ } catch {
1554
+ return {
1555
+ is_changed: false,
1556
+ changes_count: 0,
1557
+ diff: {
1558
+ added_files: [],
1559
+ removed_files: [],
1560
+ modified_files: [],
1561
+ added_classes: [],
1562
+ removed_classes: [],
1563
+ total_changes: 0
1564
+ },
1565
+ processing_time_ms: 0
1566
+ };
1567
+ }
1568
+ }
1569
+ function createFingerprint(filePath, fileContent) {
1570
+ const native = getNativeBridge();
1571
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
1572
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
1573
+ try {
1574
+ return JSON.parse(fingerprintJson);
1575
+ } catch {
1576
+ return {
1577
+ file_path: filePath,
1578
+ content_hash: "",
1579
+ size_bytes: fileContent.length,
1580
+ mtime_ms: Date.now(),
1581
+ class_hash: "",
1582
+ signature: ""
1583
+ };
1584
+ }
1585
+ }
1586
+ function injectStateHash(css, stateHash) {
1587
+ const native = getNativeBridge();
1588
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
1589
+ const resultJson = native.inject_state_hash(css, stateHash);
1590
+ try {
1591
+ return JSON.parse(resultJson);
1592
+ } catch {
1593
+ return {
1594
+ injected: false,
1595
+ state_hash: stateHash,
1596
+ affected_files: 0,
1597
+ total_injected_bytes: 0
1598
+ };
1599
+ }
1600
+ }
1601
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
1602
+ const native = getNativeBridge();
1603
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
1604
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
1605
+ try {
1606
+ return JSON.parse(resultJson);
1607
+ } catch {
1608
+ return {
1609
+ entries_before: 0,
1610
+ entries_after: 0,
1611
+ entries_removed: 0,
1612
+ freed_bytes: 0
1613
+ };
1614
+ }
1615
+ }
1616
+ function rebuildWorkspaceResult(rootDir, extensions) {
1617
+ const native = getNativeBridge();
1618
+ if (!native?.rebuild_workspace_result)
1619
+ throw new Error("rebuild_workspace_result not available");
1620
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
1621
+ try {
1622
+ return JSON.parse(resultJson);
1623
+ } catch {
1624
+ return {
1625
+ total_files_scanned: 0,
1626
+ total_classes_found: 0,
1627
+ unique_classes: 0,
1628
+ build_time_ms: 0,
1629
+ files_with_changes: 0
1630
+ };
1631
+ }
1632
+ }
1633
+ function scanFileNative(filePath, fileContent) {
1634
+ const native = getNativeBridge();
1635
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
1636
+ const resultJson = native.scan_file_native(filePath, fileContent);
1637
+ try {
1638
+ return JSON.parse(resultJson);
1639
+ } catch {
1640
+ return {
1641
+ file: filePath,
1642
+ classes: [],
1643
+ added_classes: [],
1644
+ removed_classes: [],
1645
+ changed: false
1646
+ };
1647
+ }
1648
+ }
1649
+ function scanFilesBatchNative(filesJson) {
1650
+ const native = getNativeBridge();
1651
+ if (!native?.scan_files_batch_native)
1652
+ throw new Error("scan_files_batch_native not available");
1653
+ const resultJson = native.scan_files_batch_native(filesJson);
1654
+ try {
1655
+ return JSON.parse(resultJson);
1656
+ } catch {
1657
+ return [];
1658
+ }
1659
+ }
1660
+ var init_streamingNative = __esm({
1661
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
1662
+ init_nativeBridge();
1663
+ }
1664
+ });
1665
+
1666
+ // packages/domain/compiler/src/compiler/index.ts
1667
+ var init_compiler = __esm({
1668
+ "packages/domain/compiler/src/compiler/index.ts"() {
1669
+ init_cssGeneratorNative();
1670
+ init_compilationNative();
1671
+ init_cssCompilationNative();
1672
+ init_idRegistryNative();
1673
+ init_streamingNative();
1674
+ }
1675
+ });
1676
+
1677
+ // packages/domain/compiler/src/parser/index.ts
1678
+ var parser_exports = {};
1679
+ __export(parser_exports, {
1680
+ astExtractClasses: () => astExtractClasses,
1681
+ batchExtractClasses: () => batchExtractClasses,
1682
+ checkAgainstSafelist: () => checkAgainstSafelist,
1683
+ diffClassLists: () => diffClassLists,
1684
+ extractAllClasses: () => extractAllClasses,
1685
+ extractClassesFromSource: () => extractClassesFromSource,
1686
+ extractComponentUsage: () => extractComponentUsage,
1687
+ mergeClassesStatic: () => mergeClassesStatic,
1688
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1689
+ normalizeClasses: () => normalizeClasses,
1690
+ parseClasses: () => parseClasses
1691
+ });
1692
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1693
+ var init_parser = __esm({
1694
+ "packages/domain/compiler/src/parser/index.ts"() {
1695
+ init_nativeBridge();
1696
+ parseClasses = (raw) => {
1697
+ const native = getNativeBridge();
1698
+ if (!native?.parseClasses) {
1699
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1700
+ }
1701
+ return native.parseClasses(raw) || [];
1702
+ };
1703
+ extractAllClasses = (source) => {
1704
+ const native = getNativeBridge();
1705
+ if (!native?.extractAllClasses) {
1706
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1707
+ }
1708
+ return native.extractAllClasses(source) || [];
1709
+ };
1710
+ extractClassesFromSource = (source) => {
1711
+ const native = getNativeBridge();
1712
+ if (!native?.extractClassesFromSource) {
1713
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1714
+ }
1715
+ const result = native.extractClassesFromSource(source);
1716
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1717
+ };
1718
+ astExtractClasses = (source, _filename) => {
1719
+ const native = getNativeBridge();
1720
+ if (!native?.extractClassesFromSource) {
1721
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1722
+ }
1723
+ return native.extractClassesFromSource(source) || [];
1724
+ };
1725
+ normalizeClasses = (raw) => {
1726
+ const result = normalizeAndDedupClasses(raw);
1727
+ return result?.normalized || "";
1728
+ };
1729
+ mergeClassesStatic = (classes) => {
1730
+ const result = normalizeAndDedupClasses(classes);
1731
+ return result?.normalized || "";
1732
+ };
1733
+ normalizeAndDedupClasses = (raw) => {
1734
+ const native = getNativeBridge();
1735
+ if (!native?.normalizeAndDedupClasses) {
1736
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1737
+ }
1738
+ const result = native.normalizeAndDedupClasses(raw);
1739
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1740
+ };
1741
+ extractComponentUsage = (source) => {
1742
+ const native = getNativeBridge();
1743
+ if (!native?.extractComponentUsage) {
1744
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1745
+ }
1746
+ return native.extractComponentUsage(source) || [];
1747
+ };
1748
+ batchExtractClasses = (filePaths) => {
1749
+ const native = getNativeBridge();
1750
+ if (!native?.batchExtractClasses) {
1751
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1752
+ }
1753
+ return native.batchExtractClasses(filePaths) || [];
1754
+ };
1755
+ checkAgainstSafelist = (classes, safelist) => {
1756
+ const native = getNativeBridge();
1757
+ if (!native?.checkAgainstSafelist) {
1758
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1759
+ }
1760
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1761
+ };
1762
+ diffClassLists = (previous, current) => {
1763
+ const native = getNativeBridge();
1764
+ if (!native?.diffClassLists) {
1765
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1766
+ }
1767
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1768
+ };
1769
+ }
1770
+ });
1771
+
1772
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1773
+ function detectDeadCode(scanResultJson, css) {
1774
+ const native = getNativeBridge();
1775
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1776
+ return native.detectDeadCode(scanResultJson, css);
1777
+ }
1778
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1779
+ const native = getNativeBridge();
1780
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1781
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1782
+ }
1783
+ function analyzeClassesNative(filesJson, cwd, flags) {
1784
+ const native = getNativeBridge();
1785
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1786
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1787
+ }
1788
+ function analyzeRscNative(source, filename) {
1789
+ const native = getNativeBridge();
1790
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1791
+ return native.analyzeRsc(source, filename);
1792
+ }
1793
+ function optimizeCssNative(css) {
1794
+ const native = getNativeBridge();
1795
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1796
+ const result = native.processTailwindCssLightning(css);
1797
+ return {
1798
+ css: result.css,
1799
+ originalSize: css.length,
1800
+ optimizedSize: result.size_bytes,
1801
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1802
+ };
1803
+ }
1804
+ function processTailwindCssLightning(css) {
1805
+ const native = getNativeBridge();
1806
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1807
+ return native.processTailwindCssLightning(css);
1808
+ }
1809
+ function eliminateDeadCssNative(css, deadClasses) {
1810
+ const native = getNativeBridge();
1811
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1812
+ return native.eliminateDeadCss(css, deadClasses);
1813
+ }
1814
+ function hoistComponentsNative(source) {
1815
+ const native = getNativeBridge();
1816
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1817
+ return native.hoistComponents(source);
1818
+ }
1819
+ function compileVariantTableNative(configJson) {
1820
+ const native = getNativeBridge();
1821
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1822
+ return native.compileVariantTable(configJson);
1823
+ }
1824
+ function classifyAndSortClassesNative(classes) {
1825
+ const native = getNativeBridge();
1826
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1827
+ return native.classifyAndSortClasses(classes);
1828
+ }
1829
+ function mergeCssDeclarationsNative(cssChunks) {
1830
+ const native = getNativeBridge();
1831
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1832
+ return native.mergeCssDeclarations(cssChunks);
1833
+ }
1834
+ var init_analyzerNative = __esm({
1835
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1836
+ init_nativeBridge();
1837
+ }
1838
+ });
1839
+
1840
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1841
+ function resolveVariants(configJson) {
1842
+ const native = getNativeBridge();
1843
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1844
+ const resultJson = native.resolve_variants(configJson);
1845
+ try {
1846
+ return JSON.parse(resultJson);
1847
+ } catch {
1848
+ return {
1849
+ variants: [],
1850
+ supported: [],
1851
+ deprecated: [],
1852
+ conflicting: []
1853
+ };
1854
+ }
1855
+ }
1856
+ function validateThemeConfig(configJson) {
1857
+ const native = getNativeBridge();
1858
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1859
+ const resultJson = native.validate_variant_config(configJson);
1860
+ try {
1861
+ return JSON.parse(resultJson);
1862
+ } catch {
1863
+ return {
1864
+ is_valid: false,
1865
+ errors: ["Unable to parse configuration"],
1866
+ warnings: [],
1867
+ suggestions: []
1868
+ };
1869
+ }
1870
+ }
1871
+ function resolveCascade(baseThemeJson, overridesJson) {
1872
+ const native = getNativeBridge();
1873
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1874
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1875
+ try {
1876
+ return JSON.parse(resultJson);
1877
+ } catch {
1878
+ return {
1879
+ base_theme: {},
1880
+ user_overrides: {},
1881
+ merged_theme: {},
1882
+ conflict_resolutions: []
1883
+ };
1884
+ }
1885
+ }
1886
+ function resolveClassNames(classNames, themeJson) {
1887
+ const native = getNativeBridge();
1888
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1889
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1890
+ try {
1891
+ return JSON.parse(resultJson);
1892
+ } catch {
1893
+ return [];
1894
+ }
1895
+ }
1896
+ function resolveConflictGroup(groupName, themeJson) {
1897
+ const native = getNativeBridge();
1898
+ if (!native?.resolve_conflict_group)
1899
+ throw new Error("resolve_conflict_group not available");
1900
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1901
+ try {
1902
+ return JSON.parse(resultJson);
1903
+ } catch {
1904
+ return {
1905
+ group_name: groupName,
1906
+ conflicting_classes: [],
1907
+ description: "",
1908
+ resolution_strategy: "last-wins"
1909
+ };
1910
+ }
1911
+ }
1912
+ function resolveThemeValue(keyPath, themeJson) {
1913
+ const native = getNativeBridge();
1914
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1915
+ return native.resolve_theme_value(keyPath, themeJson);
1916
+ }
1917
+ function resolveSimpleVariants(configJson) {
1918
+ const native = getNativeBridge();
1919
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1920
+ const resultJson = native.resolve_simple_variants(configJson);
1921
+ try {
1922
+ return JSON.parse(resultJson);
1923
+ } catch {
1924
+ return [];
1925
+ }
1926
+ }
1927
+ var init_themeResolutionNative = __esm({
1928
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1929
+ init_nativeBridge();
1930
+ }
1931
+ });
1932
+
1933
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1934
+ function scanWorkspace(root, extensions) {
1935
+ const native = getNativeBridge();
1936
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1937
+ return native.scan_workspace(root, extensions);
1938
+ }
1939
+ function extractClassesFromSourceNative(source) {
1940
+ const native = getNativeBridge();
1941
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1942
+ return native.extract_classes_from_source(source);
1943
+ }
1944
+ function batchExtractClassesNative(filePaths) {
1945
+ const native = getNativeBridge();
1946
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1947
+ return native.batch_extract_classes(filePaths);
1948
+ }
1949
+ function checkAgainstSafelistNative(classes, safelist) {
1950
+ const native = getNativeBridge();
1951
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1952
+ return native.check_against_safelist(classes, safelist);
1953
+ }
1954
+ function scanFile(filePath) {
1955
+ const native = getNativeBridge();
1956
+ if (!native?.scan_file) throw new Error("scan_file not available");
1957
+ return native.scan_file(filePath);
1958
+ }
1959
+ function collectFiles(root, extensions) {
1960
+ const native = getNativeBridge();
1961
+ if (!native?.collect_files) throw new Error("collect_files not available");
1962
+ return native.collect_files(root, extensions);
1963
+ }
1964
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1965
+ const native = getNativeBridge();
1966
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1967
+ return native.walk_and_prefilter_source_files(root, extensions);
1968
+ }
1969
+ function generateSubComponentTypes(root, outputPath) {
1970
+ const native = getNativeBridge();
1971
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1972
+ return native.generate_sub_component_types(root, outputPath);
1973
+ }
1974
+ var init_scannerNative = __esm({
1975
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1976
+ init_nativeBridge();
1977
+ }
1978
+ });
1979
+
1980
+ // packages/domain/compiler/src/analyzer/index.ts
1981
+ var init_analyzer = __esm({
1982
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1983
+ init_analyzerNative();
1984
+ init_themeResolutionNative();
1985
+ init_scannerNative();
1986
+ }
1987
+ });
1988
+
1989
+ // packages/domain/compiler/src/cache/cacheNative.ts
1990
+ function getCacheStatistics() {
1991
+ const native = getNativeBridge();
1992
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1993
+ const statsJson = native.get_cache_statistics();
1994
+ try {
1995
+ return JSON.parse(statsJson);
1996
+ } catch {
1997
+ return {
1998
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1999
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
2000
+ compile_cache: { hits: 0, misses: 0, size: 0 },
2001
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
2002
+ overall_hit_rate: 0,
2003
+ total_memory_bytes: 0
2004
+ };
2005
+ }
2006
+ }
2007
+ function clearAllCaches() {
2008
+ const native = getNativeBridge();
2009
+ if (!native?.clear_all_caches) return;
2010
+ try {
2011
+ native.clear_all_caches();
2012
+ } catch {
2013
+ }
2014
+ }
2015
+ function clearParseCache() {
2016
+ const native = getNativeBridge();
2017
+ if (!native?.clear_parse_cache) return;
2018
+ try {
2019
+ native.clear_parse_cache();
2020
+ } catch {
2021
+ }
2022
+ }
2023
+ function clearResolveCache() {
2024
+ const native = getNativeBridge();
2025
+ if (!native?.clear_resolve_cache) return;
2026
+ try {
2027
+ native.clear_resolve_cache();
2028
+ } catch {
2029
+ }
2030
+ }
2031
+ function clearCompileCache() {
2032
+ const native = getNativeBridge();
2033
+ if (!native?.clear_compile_cache) return;
2034
+ try {
2035
+ native.clear_compile_cache();
2036
+ } catch {
2037
+ }
2038
+ }
2039
+ function clearCssGenCache() {
2040
+ const native = getNativeBridge();
2041
+ if (!native?.clear_css_gen_cache) return;
2042
+ try {
2043
+ native.clear_css_gen_cache();
2044
+ } catch {
2045
+ }
2046
+ }
2047
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
2048
+ const native = getNativeBridge();
2049
+ if (!native?.get_cache_optimization_hints)
2050
+ throw new Error("get_cache_optimization_hints not available");
2051
+ const hintsJson = native.get_cache_optimization_hints(
2052
+ Math.min(100, Math.max(0, hitRatePercent)),
2053
+ Math.max(1, memoryUsedMb)
2054
+ );
2055
+ try {
2056
+ return JSON.parse(hintsJson);
2057
+ } catch {
2058
+ return {
2059
+ current_strategy: "unknown",
2060
+ recommended_strategy: "increase_size",
2061
+ estimated_improvement_percent: 0,
2062
+ suggested_memory_mb: 256,
2063
+ notes: ["Unable to analyze cache statistics"]
2064
+ };
2065
+ }
2066
+ }
2067
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
2068
+ const native = getNativeBridge();
2069
+ if (!native?.estimate_optimal_cache_config_native)
2070
+ throw new Error("estimate_optimal_cache_config_native not available");
2071
+ const configJson = native.estimate_optimal_cache_config_native(
2072
+ Math.max(64, totalBudgetMb),
2073
+ workloadType
2074
+ );
2075
+ try {
2076
+ return JSON.parse(configJson);
2077
+ } catch {
2078
+ return {
2079
+ parse_cache_size: 128,
2080
+ resolve_cache_size: 64,
2081
+ compile_cache_size: 256,
2082
+ css_gen_cache_size: 128,
2083
+ recommended_eviction_policy: "lru",
2084
+ ttl_seconds: 3600,
2085
+ expected_hit_rate_percent: 75
2086
+ };
2087
+ }
2088
+ }
2089
+ function cacheRead(cachePath) {
2090
+ const native = getNativeBridge();
2091
+ if (!native?.cache_read) throw new Error("cache_read not available");
2092
+ const result = native.cache_read(cachePath);
2093
+ try {
2094
+ return JSON.parse(result.entries_json || "[]");
2095
+ } catch {
2096
+ return [];
2097
+ }
2098
+ }
2099
+ function cacheWrite(cachePath, entries) {
2100
+ const native = getNativeBridge();
2101
+ if (!native?.cache_write) throw new Error("cache_write not available");
2102
+ try {
2103
+ const result = native.cache_write(
2104
+ cachePath,
2105
+ entries.map((e) => ({
2106
+ file: e.file,
2107
+ content_hash: e.contentHash,
2108
+ classes: e.classes,
2109
+ mtime_ms: e.mtimeMs,
2110
+ size_bytes: e.sizeBytes
2111
+ }))
2112
+ );
2113
+ return typeof result === "boolean" ? result : result === true;
2114
+ } catch {
2115
+ return false;
2116
+ }
2117
+ }
2118
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
2119
+ const native = getNativeBridge();
2120
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
2121
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
2122
+ }
2123
+ var init_cacheNative = __esm({
2124
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
2125
+ init_nativeBridge();
2126
+ }
2127
+ });
2128
+
2129
+ // packages/domain/compiler/src/cache/index.ts
2130
+ var init_cache = __esm({
2131
+ "packages/domain/compiler/src/cache/index.ts"() {
2132
+ init_cacheNative();
2133
+ }
2134
+ });
2135
+
2136
+ // packages/domain/compiler/src/redis/redisNative.ts
2137
+ function redisPing() {
2138
+ const native = getNativeBridge();
2139
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
2140
+ return native.redis_ping();
2141
+ }
2142
+ function redisGet(key) {
2143
+ const native = getNativeBridge();
2144
+ if (!native?.redis_get) throw new Error("redis_get not available");
2145
+ const result = native.redis_get(key);
2146
+ return result === "nil" ? null : result;
2147
+ }
2148
+ function redisSet(key, value, ttl_seconds) {
2149
+ const native = getNativeBridge();
2150
+ if (!native?.redis_set) throw new Error("redis_set not available");
2151
+ return native.redis_set(key, value, ttl_seconds);
2152
+ }
2153
+ function redisDelete(key) {
2154
+ const native = getNativeBridge();
2155
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
2156
+ return native.redis_delete(key);
2157
+ }
2158
+ function redisExists(key) {
2159
+ const native = getNativeBridge();
2160
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
2161
+ return native.redis_exists(key);
2162
+ }
2163
+ function redisMget(keys) {
2164
+ const native = getNativeBridge();
2165
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
2166
+ const result = native.redis_mget(keys);
2167
+ try {
2168
+ return JSON.parse(result);
2169
+ } catch {
2170
+ return keys.map(() => null);
2171
+ }
2172
+ }
2173
+ function redisMset(pairs) {
2174
+ const native = getNativeBridge();
2175
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
2176
+ return native.redis_mset(pairs);
2177
+ }
2178
+ function redisFlushDb() {
2179
+ const native = getNativeBridge();
2180
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
2181
+ return native.redis_flush_db();
2182
+ }
2183
+ function redisFlushAll() {
2184
+ const native = getNativeBridge();
2185
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
2186
+ return native.redis_flush_all();
2187
+ }
2188
+ function redisPoolConnect(host, port, pool_size) {
2189
+ const native = getNativeBridge();
2190
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
2191
+ return native.redis_pool_connect(host, port, pool_size);
2192
+ }
2193
+ function redisPoolStats() {
2194
+ const native = getNativeBridge();
2195
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
2196
+ const result = native.redis_pool_stats();
2197
+ try {
2198
+ return JSON.parse(result);
2199
+ } catch {
2200
+ return {
2201
+ connected_count: 0,
2202
+ idle_count: 0,
2203
+ waiting_count: 0,
2204
+ total_requests: 0,
2205
+ total_errors: 0
2206
+ };
2207
+ }
2208
+ }
2209
+ function redisPoolReconnect() {
2210
+ const native = getNativeBridge();
2211
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
2212
+ return native.redis_pool_reconnect();
2213
+ }
2214
+ function redisEnableCluster(initial_nodes) {
2215
+ const native = getNativeBridge();
2216
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
2217
+ const result = native.redis_enable_cluster(initial_nodes);
2218
+ try {
2219
+ return JSON.parse(result);
2220
+ } catch {
2221
+ return {
2222
+ enabled: false,
2223
+ cluster_state: "error",
2224
+ nodes: [],
2225
+ slots_assigned: 0,
2226
+ slots_ok: 0,
2227
+ slots_fail: 0
2228
+ };
2229
+ }
2230
+ }
2231
+ function redisDisableCluster() {
2232
+ const native = getNativeBridge();
2233
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
2234
+ return native.redis_disable_cluster();
2235
+ }
2236
+ function redisClusterStatus() {
2237
+ const native = getNativeBridge();
2238
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
2239
+ const result = native.redis_cluster_status();
2240
+ try {
2241
+ return JSON.parse(result);
2242
+ } catch {
2243
+ return {
2244
+ enabled: false,
2245
+ cluster_state: "unknown",
2246
+ nodes: [],
2247
+ slots_assigned: 0,
2248
+ slots_ok: 0,
2249
+ slots_fail: 0
2250
+ };
2251
+ }
2252
+ }
2253
+ function redisSubscribe(channel) {
2254
+ const native = getNativeBridge();
2255
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
2256
+ return native.redis_subscribe(channel);
2257
+ }
2258
+ function redisPublish(channel, message) {
2259
+ const native = getNativeBridge();
2260
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
2261
+ return native.redis_publish(channel, message);
2262
+ }
2263
+ function redisExpirationSet(key, ttl_seconds) {
2264
+ const native = getNativeBridge();
2265
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
2266
+ return native.redis_expiration_set(key, ttl_seconds);
2267
+ }
2268
+ function redisExpirationGet(key) {
2269
+ const native = getNativeBridge();
2270
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
2271
+ const result = native.redis_expiration_get(key);
2272
+ try {
2273
+ return JSON.parse(result);
2274
+ } catch {
2275
+ return {
2276
+ key,
2277
+ ttl_seconds: -1,
2278
+ expiration_timestamp: 0,
2279
+ is_persistent: true
2280
+ };
2281
+ }
2282
+ }
2283
+ function redisInfo() {
2284
+ const native = getNativeBridge();
2285
+ if (!native?.redis_info) throw new Error("redis_info not available");
2286
+ return native.redis_info();
2287
+ }
2288
+ function redisMonitor() {
2289
+ const native = getNativeBridge();
2290
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
2291
+ return native.redis_monitor();
2292
+ }
2293
+ function redisCacheSize() {
2294
+ const native = getNativeBridge();
2295
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
2296
+ return native.redis_cache_size();
2297
+ }
2298
+ function redisCacheKeyCount() {
2299
+ const native = getNativeBridge();
2300
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
2301
+ return native.redis_cache_key_count();
2302
+ }
2303
+ function redisCacheClear() {
2304
+ const native = getNativeBridge();
2305
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
2306
+ return native.redis_cache_clear();
2307
+ }
2308
+ function redisCacheHitRate() {
2309
+ const native = getNativeBridge();
2310
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
2311
+ return native.redis_cache_hit_rate();
2312
+ }
2313
+ function redisEnablePersistence(mode) {
2314
+ const native = getNativeBridge();
2315
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
2316
+ return native.redis_enable_persistence(mode);
2317
+ }
2318
+ function redisDisablePersistence() {
2319
+ const native = getNativeBridge();
2320
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
2321
+ return native.redis_disable_persistence();
2322
+ }
2323
+ function redisSnapshot() {
2324
+ const native = getNativeBridge();
2325
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
2326
+ return native.redis_snapshot();
2327
+ }
2328
+ function redisMemoryStats() {
2329
+ const native = getNativeBridge();
2330
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
2331
+ return native.redis_memory_stats();
2332
+ }
2333
+ function redisOptimizeMemory() {
2334
+ const native = getNativeBridge();
2335
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
2336
+ return native.redis_optimize_memory();
2337
+ }
2338
+ function redisSetEvictionPolicy(policy) {
2339
+ const native = getNativeBridge();
2340
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
2341
+ return native.redis_set_eviction_policy(policy);
2342
+ }
2343
+ function redisGetEvictionPolicy() {
2344
+ const native = getNativeBridge();
2345
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
2346
+ return native.redis_get_eviction_policy();
2347
+ }
2348
+ function redisReplicate(target_host, target_port) {
2349
+ const native = getNativeBridge();
2350
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
2351
+ return native.redis_replicate(target_host, target_port);
2352
+ }
2353
+ function redisReplicationStatus() {
2354
+ const native = getNativeBridge();
2355
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
2356
+ return native.redis_replication_status();
2357
+ }
2358
+ function redisCacheSync(peers) {
2359
+ const native = getNativeBridge();
2360
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
2361
+ return native.redis_cache_sync(peers);
2362
+ }
2363
+ function redisEnableCacheWarming(key_pattern) {
2364
+ const native = getNativeBridge();
2365
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
2366
+ return native.redis_enable_cache_warming(key_pattern);
2367
+ }
2368
+ function redisDisableCacheWarming() {
2369
+ const native = getNativeBridge();
2370
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
2371
+ return native.redis_disable_cache_warming();
2372
+ }
2373
+ function redisDiagnose() {
2374
+ const native = getNativeBridge();
2375
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
2376
+ return native.redis_diagnose();
2377
+ }
2378
+ var init_redisNative = __esm({
2379
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
2380
+ init_nativeBridge();
2381
+ }
2382
+ });
2383
+
2384
+ // packages/domain/compiler/src/redis/index.ts
2385
+ var init_redis = __esm({
2386
+ "packages/domain/compiler/src/redis/index.ts"() {
2387
+ init_redisNative();
2388
+ }
2389
+ });
2390
+
2391
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
2392
+ function startWatch(root_path, patterns) {
2393
+ const native = getNativeBridge();
2394
+ if (!native?.start_watch) throw new Error("start_watch not available");
2395
+ return native.start_watch(root_path, patterns);
2396
+ }
2397
+ function pollWatchEvents(handle, timeout_ms) {
2398
+ const native = getNativeBridge();
2399
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
2400
+ const result = native.poll_watch_events(handle, timeout_ms);
2401
+ try {
2402
+ return JSON.parse(result);
2403
+ } catch {
2404
+ return [];
2405
+ }
2406
+ }
2407
+ function stopWatch(handle) {
2408
+ const native = getNativeBridge();
2409
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
2410
+ return native.stop_watch(handle);
2411
+ }
2412
+ function watchAddPattern(handle, pattern) {
2413
+ const native = getNativeBridge();
2414
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
2415
+ return native.watch_add_pattern(handle, pattern);
2416
+ }
2417
+ function watchRemovePattern(handle, pattern) {
2418
+ const native = getNativeBridge();
2419
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
2420
+ return native.watch_remove_pattern(handle, pattern);
2421
+ }
2422
+ function watchGetActiveHandles() {
2423
+ const native = getNativeBridge();
2424
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
2425
+ const result = native.watch_get_active_handles();
2426
+ try {
2427
+ return JSON.parse(result);
2428
+ } catch {
2429
+ return [];
2430
+ }
1253
2431
  }
1254
- function runCssPipelineSync(_classes) {
1255
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
2432
+ function watchClearAll() {
2433
+ const native = getNativeBridge();
2434
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
2435
+ return native.watch_clear_all();
1256
2436
  }
1257
- function processTailwindCssWithTargets(css, targets) {
2437
+ function watchEventTypeToString(event_type_code) {
1258
2438
  const native = getNativeBridge();
1259
- if (!native?.processTailwindCssWithTargets) {
1260
- throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
2439
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
2440
+ return native.watch_event_type_to_string(event_type_code);
2441
+ }
2442
+ function isWatchRunning(handle) {
2443
+ const native = getNativeBridge();
2444
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
2445
+ return native.is_watch_running(handle);
2446
+ }
2447
+ function getWatchStats() {
2448
+ const native = getNativeBridge();
2449
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
2450
+ const result = native.get_watch_stats();
2451
+ try {
2452
+ return JSON.parse(result);
2453
+ } catch {
2454
+ return {
2455
+ active_watchers: 0,
2456
+ total_events: 0,
2457
+ events_this_second: 0,
2458
+ average_latency_ms: 0,
2459
+ largest_batch_size: 0
2460
+ };
1261
2461
  }
1262
- const result = native.processTailwindCssWithTargets(css, targets ?? null);
1263
- if (!result?.css) {
1264
- throw new Error("FATAL: processTailwindCssWithTargets returned null");
2462
+ }
2463
+ function watchPause(handle) {
2464
+ const native = getNativeBridge();
2465
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
2466
+ return native.watch_pause(handle);
2467
+ }
2468
+ function watchResume(handle) {
2469
+ const native = getNativeBridge();
2470
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
2471
+ return native.watch_resume(handle);
2472
+ }
2473
+ function scanCacheOptimizations() {
2474
+ const native = getNativeBridge();
2475
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
2476
+ return native.scan_cache_optimizations();
2477
+ }
2478
+ function getPluginHooks() {
2479
+ const native = getNativeBridge();
2480
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
2481
+ const result = native.get_plugin_hooks();
2482
+ try {
2483
+ return JSON.parse(result);
2484
+ } catch {
2485
+ return [];
1265
2486
  }
1266
- return result.css;
1267
2487
  }
1268
- var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
1269
- var init_tailwindEngine = __esm({
1270
- "packages/domain/compiler/src/tailwindEngine.ts"() {
2488
+ function registerPluginHook(hook_name, handler_id) {
2489
+ const native = getNativeBridge();
2490
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
2491
+ return native.register_plugin_hook(hook_name, handler_id);
2492
+ }
2493
+ function unregisterPluginHook(hook_name, handler_id) {
2494
+ const native = getNativeBridge();
2495
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
2496
+ return native.unregister_plugin_hook(hook_name, handler_id);
2497
+ }
2498
+ function emitPluginHook(hook_name, data_json) {
2499
+ const native = getNativeBridge();
2500
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
2501
+ return native.emit_plugin_hook(hook_name, data_json);
2502
+ }
2503
+ function getCompilationMetrics() {
2504
+ const native = getNativeBridge();
2505
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
2506
+ return native.get_compilation_metrics();
2507
+ }
2508
+ function resetCompilationMetrics() {
2509
+ const native = getNativeBridge();
2510
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
2511
+ return native.reset_compilation_metrics();
2512
+ }
2513
+ function validateCssOutput(css) {
2514
+ const native = getNativeBridge();
2515
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
2516
+ return native.validate_css_output(css);
2517
+ }
2518
+ function getCompilerDiagnostics() {
2519
+ const native = getNativeBridge();
2520
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
2521
+ return native.get_compiler_diagnostics();
2522
+ }
2523
+ var init_watchSystemNative = __esm({
2524
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1271
2525
  init_nativeBridge();
1272
- init_cssGeneratorNative();
1273
- require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite.js', document.baseURI).href)));
1274
- _cssCache = /* @__PURE__ */ new Map();
1275
- _cacheHits = 0;
1276
- _cacheMisses = 0;
1277
- MAX_CACHE_SIZE = 100;
1278
- _twEngine = null;
1279
- _twEngineError = null;
2526
+ }
2527
+ });
2528
+
2529
+ // packages/domain/compiler/src/watch/index.ts
2530
+ var init_watch = __esm({
2531
+ "packages/domain/compiler/src/watch/index.ts"() {
2532
+ init_watchSystemNative();
1280
2533
  }
1281
2534
  });
1282
2535
 
@@ -1284,75 +2537,219 @@ var init_tailwindEngine = __esm({
1284
2537
  var internal_exports = {};
1285
2538
  __export(internal_exports, {
1286
2539
  adaptNativeResult: () => adaptNativeResult,
1287
- analyzeClassUsage: () => analyzeClassUsage,
2540
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
1288
2541
  analyzeClasses: () => analyzeClasses,
2542
+ analyzeClassesNative: () => analyzeClassesNative,
1289
2543
  analyzeFile: () => analyzeFile,
1290
- analyzeRsc: () => analyzeRsc,
2544
+ analyzeRscNative: () => analyzeRscNative,
1291
2545
  analyzeVariantUsage: () => analyzeVariantUsage,
1292
2546
  astExtractClasses: () => astExtractClasses,
2547
+ atomicRegistrySize: () => atomicRegistrySize,
1293
2548
  batchExtractClasses: () => batchExtractClasses,
2549
+ batchExtractClassesNative: () => batchExtractClassesNative,
1294
2550
  bucketSort: () => bucketSort,
1295
2551
  buildStyleTag: () => buildStyleTag,
2552
+ cachePriority: () => cachePriority,
2553
+ cacheRead: () => cacheRead,
2554
+ cacheWrite: () => cacheWrite,
1296
2555
  checkAgainstSafelist: () => checkAgainstSafelist,
1297
- classifyAndSortClasses: () => classifyAndSortClasses,
2556
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2557
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
1298
2558
  classifyNode: () => classifyNode,
2559
+ clearAllCaches: () => clearAllCaches,
2560
+ clearAtomicRegistry: () => clearAtomicRegistry,
1299
2561
  clearCache: () => clearCache,
2562
+ clearCompileCache: () => clearCompileCache,
2563
+ clearCssGenCache: () => clearCssGenCache,
2564
+ clearParseCache: () => clearParseCache,
2565
+ clearResolveCache: () => clearResolveCache,
2566
+ clearThemeCache: () => clearThemeCache,
2567
+ collectFiles: () => collectFiles,
2568
+ compileAnimation: () => compileAnimation,
2569
+ compileClass: () => compileClass,
2570
+ compileClasses: () => compileClasses,
1300
2571
  compileCssFromClasses: () => compileCssFromClasses,
1301
- compileCssNative: () => compileCssNative,
1302
- compileVariantTable: () => compileVariantTable,
1303
- compileVariants: () => compileVariants,
2572
+ compileCssLightning: () => compileCssLightning,
2573
+ compileCssNative2: () => compileCssNative2,
2574
+ compileKeyframes: () => compileKeyframes,
2575
+ compileTheme: () => compileTheme,
2576
+ compileToCss: () => compileToCss,
2577
+ compileToCssBatch: () => compileToCssBatch,
2578
+ compileVariantTableNative: () => compileVariantTableNative,
2579
+ computeIncrementalDiff: () => computeIncrementalDiff,
2580
+ createFingerprint: () => createFingerprint,
1304
2581
  detectConflicts: () => detectConflicts,
2582
+ detectDeadCode: () => detectDeadCode,
1305
2583
  diffClassLists: () => diffClassLists,
1306
2584
  eliminateDeadCss: () => eliminateDeadCss,
2585
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
2586
+ emitPluginHook: () => emitPluginHook,
2587
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
1307
2588
  extractAllClasses: () => extractAllClasses,
1308
2589
  extractAndGenerateStateCss: () => extractAndGenerateStateCss,
2590
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
1309
2591
  extractClassesFromSource: () => extractClassesFromSource,
2592
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
1310
2593
  extractComponentUsage: () => extractComponentUsage,
1311
2594
  extractContainerCssFromSource: () => extractContainerCssFromSource,
2595
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
1312
2596
  extractTwStateConfigs: () => extractTwStateConfigs,
2597
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
1313
2598
  fileToRoute: () => fileToRoute,
1314
2599
  findDeadVariants: () => findDeadVariants,
2600
+ generateAtomicCss: () => generateAtomicCss,
1315
2601
  generateCssForClasses: () => generateCssForClasses,
1316
- generateRawCss: () => generateRawCss,
2602
+ generateCssNative: () => generateCssNative,
1317
2603
  generateSafelist: () => generateSafelist,
1318
2604
  generateStaticStateCss: () => generateStaticStateCss,
2605
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
2606
+ generateSubComponentTypes: () => generateSubComponentTypes,
1319
2607
  getAllRoutes: () => getAllRoutes,
1320
2608
  getBucketEngine: () => getBucketEngine,
2609
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
2610
+ getCacheStatistics: () => getCacheStatistics,
1321
2611
  getCacheStats: () => getCacheStats,
2612
+ getCompilationMetrics: () => getCompilationMetrics,
2613
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
1322
2614
  getContentPaths: () => getContentPaths,
1323
2615
  getIncrementalEngine: () => getIncrementalEngine,
1324
2616
  getNativeBridge: () => getNativeBridge,
2617
+ getPluginHooks: () => getPluginHooks,
1325
2618
  getRouteClasses: () => getRouteClasses,
2619
+ getWatchStats: () => getWatchStats,
1326
2620
  hasTwUsage: () => hasTwUsage,
1327
- hoistComponents: () => hoistComponents,
2621
+ hashContent: () => hashContent,
2622
+ hoistComponentsNative: () => hoistComponentsNative,
2623
+ idRegistryActiveCount: () => idRegistryActiveCount,
2624
+ idRegistryCreate: () => idRegistryCreate,
2625
+ idRegistryDestroy: () => idRegistryDestroy,
2626
+ idRegistryExport: () => idRegistryExport,
2627
+ idRegistryGenerate: () => idRegistryGenerate,
2628
+ idRegistryImport: () => idRegistryImport,
2629
+ idRegistryLookup: () => idRegistryLookup,
2630
+ idRegistryNext: () => idRegistryNext,
2631
+ idRegistryReset: () => idRegistryReset,
2632
+ idRegistrySnapshot: () => idRegistrySnapshot,
1328
2633
  injectClientDirective: () => injectClientDirective,
1329
2634
  injectServerOnlyComment: () => injectServerOnlyComment,
2635
+ injectStateHash: () => injectStateHash,
1330
2636
  isAlreadyTransformed: () => isAlreadyTransformed,
2637
+ isWatchRunning: () => isWatchRunning,
2638
+ layoutClassesToCss: () => layoutClassesToCss,
1331
2639
  loadSafelist: () => loadSafelist,
1332
2640
  loadTailwindConfig: () => loadTailwindConfig,
1333
2641
  mergeClassesStatic: () => mergeClassesStatic,
1334
- mergeCssDeclarations: () => mergeCssDeclarations,
2642
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
2643
+ minifyCss: () => minifyCss,
1335
2644
  normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1336
2645
  normalizeClasses: () => normalizeClasses,
1337
- optimizeCss: () => optimizeCss,
2646
+ optimizeCssNative: () => optimizeCssNative,
2647
+ parseAtomicClass: () => parseAtomicClass,
1338
2648
  parseClasses: () => parseClasses,
2649
+ pollWatchEvents: () => pollWatchEvents,
2650
+ processFileChange: () => processFileChange,
2651
+ processTailwindCssLightning: () => processTailwindCssLightning,
2652
+ propertyIdToString: () => propertyIdToString,
2653
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
2654
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
2655
+ redisCacheClear: () => redisCacheClear,
2656
+ redisCacheHitRate: () => redisCacheHitRate,
2657
+ redisCacheKeyCount: () => redisCacheKeyCount,
2658
+ redisCacheSize: () => redisCacheSize,
2659
+ redisCacheSync: () => redisCacheSync,
2660
+ redisClusterStatus: () => redisClusterStatus,
2661
+ redisDelete: () => redisDelete,
2662
+ redisDiagnose: () => redisDiagnose,
2663
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
2664
+ redisDisableCluster: () => redisDisableCluster,
2665
+ redisDisablePersistence: () => redisDisablePersistence,
2666
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
2667
+ redisEnableCluster: () => redisEnableCluster,
2668
+ redisEnablePersistence: () => redisEnablePersistence,
2669
+ redisExists: () => redisExists,
2670
+ redisExpirationGet: () => redisExpirationGet,
2671
+ redisExpirationSet: () => redisExpirationSet,
2672
+ redisFlushAll: () => redisFlushAll,
2673
+ redisFlushDb: () => redisFlushDb,
2674
+ redisGet: () => redisGet,
2675
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2676
+ redisInfo: () => redisInfo,
2677
+ redisMemoryStats: () => redisMemoryStats,
2678
+ redisMget: () => redisMget,
2679
+ redisMonitor: () => redisMonitor,
2680
+ redisMset: () => redisMset,
2681
+ redisOptimizeMemory: () => redisOptimizeMemory,
2682
+ redisPing: () => redisPing,
2683
+ redisPoolConnect: () => redisPoolConnect,
2684
+ redisPoolReconnect: () => redisPoolReconnect,
2685
+ redisPoolStats: () => redisPoolStats,
2686
+ redisPublish: () => redisPublish,
2687
+ redisReplicate: () => redisReplicate,
2688
+ redisReplicationStatus: () => redisReplicationStatus,
2689
+ redisSet: () => redisSet,
2690
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2691
+ redisSnapshot: () => redisSnapshot,
2692
+ redisSubscribe: () => redisSubscribe,
1339
2693
  registerFileClasses: () => registerFileClasses,
1340
2694
  registerGlobalClasses: () => registerGlobalClasses,
2695
+ registerPluginHook: () => registerPluginHook,
2696
+ registerPropertyName: () => registerPropertyName,
2697
+ registerValueName: () => registerValueName,
1341
2698
  resetBucketEngine: () => resetBucketEngine,
2699
+ resetCompilationMetrics: () => resetCompilationMetrics,
1342
2700
  resetIncrementalEngine: () => resetIncrementalEngine,
2701
+ resolveCascade: () => resolveCascade,
2702
+ resolveClassNames: () => resolveClassNames,
2703
+ resolveConflictGroup: () => resolveConflictGroup,
2704
+ resolveSimpleVariants: () => resolveSimpleVariants,
2705
+ resolveThemeValue: () => resolveThemeValue,
2706
+ resolveVariants: () => resolveVariants,
2707
+ reverseLookupProperty: () => reverseLookupProperty,
2708
+ reverseLookupValue: () => reverseLookupValue,
1343
2709
  runCssPipeline: () => runCssPipeline,
1344
2710
  runCssPipelineSync: () => runCssPipelineSync,
1345
2711
  runElimination: () => runElimination,
1346
2712
  runLoaderTransform: () => runLoaderTransform,
2713
+ scanCacheOptimizations: () => scanCacheOptimizations,
2714
+ scanFile: () => scanFile,
2715
+ scanFileNative: () => scanFileNative,
2716
+ scanFilesBatchNative: () => scanFilesBatchNative,
1347
2717
  scanProjectUsage: () => scanProjectUsage,
2718
+ scanWorkspace: () => scanWorkspace,
1348
2719
  shouldProcess: () => shouldProcess,
1349
2720
  shouldSkipFile: () => shouldSkipFile,
1350
- transformSource: () => transformSource
2721
+ startWatch: () => startWatch,
2722
+ stopWatch: () => stopWatch,
2723
+ toAtomicClasses: () => toAtomicClasses,
2724
+ transformSource: () => transformSource,
2725
+ twMerge: () => twMerge,
2726
+ twMergeMany: () => twMergeMany,
2727
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2728
+ twMergeRaw: () => twMergeRaw,
2729
+ twMergeWithSeparator: () => twMergeWithSeparator,
2730
+ unregisterPluginHook: () => unregisterPluginHook,
2731
+ validateCssOutput: () => validateCssOutput,
2732
+ validateThemeConfig: () => validateThemeConfig,
2733
+ valueIdToString: () => valueIdToString,
2734
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2735
+ watchAddPattern: () => watchAddPattern,
2736
+ watchClearAll: () => watchClearAll,
2737
+ watchEventTypeToString: () => watchEventTypeToString,
2738
+ watchGetActiveHandles: () => watchGetActiveHandles,
2739
+ watchPause: () => watchPause,
2740
+ watchRemovePattern: () => watchRemovePattern,
2741
+ watchResume: () => watchResume
1351
2742
  });
1352
2743
  var init_internal = __esm({
1353
2744
  "packages/domain/compiler/src/internal.ts"() {
1354
2745
  init_src2();
1355
2746
  init_tailwindEngine();
2747
+ init_compiler();
2748
+ init_parser();
2749
+ init_analyzer();
2750
+ init_cache();
2751
+ init_redis();
2752
+ init_watch();
1356
2753
  }
1357
2754
  });
1358
2755
  function getNative() {
@@ -1699,7 +3096,7 @@ __export(src_exports, {
1699
3096
  getPipelinePercentages: () => getPipelinePercentages,
1700
3097
  getSuggestion: () => getSuggestion,
1701
3098
  getTailwindVersion: () => getTailwindVersion,
1702
- hashContent: () => hashContent,
3099
+ hashContent: () => hashContent2,
1703
3100
  isTailwindV4: () => isTailwindV4,
1704
3101
  isTwError: () => isTwError,
1705
3102
  loadNativeBinding: () => loadNativeBinding,
@@ -1829,7 +3226,7 @@ function resolveRuntimeDir(dir, importMetaUrl) {
1829
3226
  return process.cwd();
1830
3227
  }
1831
3228
  }
1832
- function hashContent(content, algorithm = "md5", length) {
3229
+ function hashContent2(content, algorithm = "md5", length) {
1833
3230
  const hash = crypto.createHash(algorithm).update(content).digest("hex");
1834
3231
  return length ? hash.slice(0, length) : hash;
1835
3232
  }
@@ -2056,10 +3453,16 @@ function extractContainerCssFromSource(source) {
2056
3453
  }
2057
3454
  return rules.join("\n");
2058
3455
  }
2059
- var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
3456
+ 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;
2060
3457
  var init_src2 = __esm({
2061
3458
  "packages/domain/compiler/src/index.ts"() {
2062
3459
  init_nativeBridge();
3460
+ init_compiler();
3461
+ init_parser();
3462
+ init_analyzer();
3463
+ init_cache();
3464
+ init_redis();
3465
+ init_watch();
2063
3466
  transformSource = (source, opts) => {
2064
3467
  const native = getNativeBridge();
2065
3468
  if (!native?.transformSource) {
@@ -2103,58 +3506,19 @@ var init_src2 = __esm({
2103
3506
  const result = compileCssFromClasses(classes);
2104
3507
  return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2105
3508
  };
2106
- compileCssNative = (classes, prefix = null) => {
2107
- return compileCssFromClasses(classes, prefix);
2108
- };
2109
3509
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2110
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2111
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2112
- return result.css;
2113
- };
2114
- extractAllClasses = (source) => {
2115
- const native = getNativeBridge();
2116
- if (!native?.extractAllClasses) {
2117
- throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
2118
- }
2119
- return native.extractAllClasses(source) || [];
2120
- };
2121
- extractClassesFromSource = (source) => {
2122
- const native = getNativeBridge();
2123
- if (!native?.extractClassesFromSource) {
2124
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2125
- }
2126
- const result = native.extractClassesFromSource(source);
2127
- return Array.isArray(result) ? result.join(" ") : String(result || "");
2128
- };
2129
- astExtractClasses = (source, _filename) => {
2130
- const native = getNativeBridge();
2131
- if (!native?.extractClassesFromSource) {
2132
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2133
- }
2134
- return native.extractClassesFromSource(source) || [];
2135
- };
2136
- parseClasses = (raw) => {
2137
- const native = getNativeBridge();
2138
- if (!native?.parseClasses) {
2139
- throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
2140
- }
2141
- return native.parseClasses(raw) || [];
2142
- };
2143
- normalizeClasses = (raw) => {
2144
- const result = normalizeAndDedupClasses(raw);
2145
- return result?.normalized || "";
2146
- };
2147
- mergeClassesStatic = (classes) => {
2148
- const result = normalizeAndDedupClasses(classes);
2149
- return result?.normalized || "";
2150
- };
2151
- normalizeAndDedupClasses = (raw) => {
2152
- const native = getNativeBridge();
2153
- if (!native?.normalizeAndDedupClasses) {
2154
- throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
3510
+ try {
3511
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
3512
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
3513
+ return result.css;
3514
+ } catch {
3515
+ const native = getNativeBridge();
3516
+ if (!native?.transformSource) {
3517
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
3518
+ }
3519
+ const result = native.transformSource(classes.join(" "), {});
3520
+ return result?.code || "";
2155
3521
  }
2156
- const result = native.normalizeAndDedupClasses(raw);
2157
- return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
2158
3522
  };
2159
3523
  eliminateDeadCss = (css, deadClasses) => {
2160
3524
  const native = getNativeBridge();
@@ -2187,16 +3551,10 @@ var init_src2 = __esm({
2187
3551
  const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2188
3552
  return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2189
3553
  };
2190
- optimizeCss = (css) => {
2191
- const native = getNativeBridge();
2192
- if (!native?.optimizeCss) {
2193
- throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
2194
- }
2195
- return native.optimizeCss(css);
2196
- };
2197
3554
  scanProjectUsage = (dirs, cwd) => {
3555
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2198
3556
  const files = dirs.map((dir) => path9__namespace.default.resolve(cwd, dir));
2199
- const results = batchExtractClasses(files) || [];
3557
+ const results = batchExtractClasses2(files) || [];
2200
3558
  const combined = {};
2201
3559
  for (const result of results) {
2202
3560
  if (result.ok && result.classes) {
@@ -2208,109 +3566,6 @@ var init_src2 = __esm({
2208
3566
  }
2209
3567
  return combined;
2210
3568
  };
2211
- extractComponentUsage = (source) => {
2212
- const native = getNativeBridge();
2213
- if (!native?.extractComponentUsage) {
2214
- throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
2215
- }
2216
- return native.extractComponentUsage(source) || [];
2217
- };
2218
- diffClassLists = (previous, current) => {
2219
- const native = getNativeBridge();
2220
- if (!native?.diffClassLists) {
2221
- throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
2222
- }
2223
- return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
2224
- };
2225
- batchExtractClasses = (filePaths) => {
2226
- const native = getNativeBridge();
2227
- if (!native?.batchExtractClasses) {
2228
- throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
2229
- }
2230
- return native.batchExtractClasses(filePaths) || [];
2231
- };
2232
- checkAgainstSafelist = (classes, safelist) => {
2233
- const native = getNativeBridge();
2234
- if (!native?.checkAgainstSafelist) {
2235
- throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
2236
- }
2237
- return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
2238
- };
2239
- hoistComponents = (source) => {
2240
- const native = getNativeBridge();
2241
- if (!native?.hoistComponents) {
2242
- throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
2243
- }
2244
- return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
2245
- };
2246
- compileVariantTable = (configJson) => {
2247
- const native = getNativeBridge();
2248
- if (!native?.compileVariantTable) {
2249
- throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
2250
- }
2251
- return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
2252
- };
2253
- compileVariants = (componentId, config) => {
2254
- return compileVariantTable(JSON.stringify({ componentId, ...config }));
2255
- };
2256
- classifyAndSortClasses = (classes) => {
2257
- const native = getNativeBridge();
2258
- if (!native?.classifyAndSortClasses) {
2259
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2260
- }
2261
- return native.classifyAndSortClasses(classes) || [];
2262
- };
2263
- mergeCssDeclarations = (cssChunks) => {
2264
- const native = getNativeBridge();
2265
- if (!native?.mergeCssDeclarations) {
2266
- throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
2267
- }
2268
- return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
2269
- };
2270
- analyzeClassUsage = (classes, scanResultJson, css) => {
2271
- const native = getNativeBridge();
2272
- if (!native?.analyzeClassUsage) {
2273
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2274
- }
2275
- return native.analyzeClassUsage(classes, scanResultJson, css) || [];
2276
- };
2277
- analyzeRsc = (source, filename) => {
2278
- const native = getNativeBridge();
2279
- if (!native?.analyzeRsc) {
2280
- throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2281
- }
2282
- return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
2283
- };
2284
- analyzeFile = (source, filename) => {
2285
- const rsc = analyzeRsc(source, filename);
2286
- return {
2287
- isServer: rsc?.isServer ?? true,
2288
- needsClientDirective: rsc?.needsClientDirective ?? false,
2289
- clientReasons: rsc?.clientReasons ?? [],
2290
- interactiveClasses: [],
2291
- canStaticResolveVariants: true
2292
- };
2293
- };
2294
- analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2295
- return { resolved: {}, dynamic: [] };
2296
- };
2297
- injectClientDirective = (source) => {
2298
- if (!source.includes('"use client"') && !source.includes("'use client'")) {
2299
- return '"use client";\n' + source;
2300
- }
2301
- return source;
2302
- };
2303
- injectServerOnlyComment = (source) => {
2304
- return `/* @server-only */
2305
- ${source}`;
2306
- };
2307
- analyzeClasses = (filesJson, cwd, flags) => {
2308
- const native = getNativeBridge();
2309
- if (!native?.analyzeClasses) {
2310
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2311
- }
2312
- return native.analyzeClasses(filesJson, cwd, flags);
2313
- };
2314
3569
  generateSafelist = (scanDirs, outputPath, cwd) => {
2315
3570
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2316
3571
  const allClasses = Object.keys(classes).sort();
@@ -2374,7 +3629,8 @@ ${source}`;
2374
3629
  if (containerCss) cssChunks.push(containerCss);
2375
3630
  const combined = cssChunks.join("\n").trim();
2376
3631
  if (combined) staticCss = combined;
2377
- } catch {
3632
+ } catch (err) {
3633
+ console.debug("Static CSS extraction warning:", err);
2378
3634
  }
2379
3635
  return {
2380
3636
  code: result?.code || "",
@@ -2459,7 +3715,46 @@ ${source}`;
2459
3715
  return [];
2460
3716
  };
2461
3717
  bucketSort = (classes) => {
2462
- return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
3718
+ const native = getNativeBridge();
3719
+ if (!native?.classifyAndSortClasses) {
3720
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
3721
+ }
3722
+ const sorted = native.classifyAndSortClasses(classes);
3723
+ return sorted.map((c) => c.raw ?? c);
3724
+ };
3725
+ analyzeFile = (source, filename) => {
3726
+ const native = getNativeBridge();
3727
+ if (!native?.analyzeRsc) {
3728
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
3729
+ }
3730
+ const rsc = native.analyzeRsc(source, filename);
3731
+ return {
3732
+ isServer: rsc?.isServer ?? true,
3733
+ needsClientDirective: rsc?.needsClientDirective ?? false,
3734
+ clientReasons: rsc?.clientReasons ?? [],
3735
+ interactiveClasses: [],
3736
+ canStaticResolveVariants: true
3737
+ };
3738
+ };
3739
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
3740
+ return { resolved: {}, dynamic: [] };
3741
+ };
3742
+ injectClientDirective = (source) => {
3743
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
3744
+ return '"use client";\n' + source;
3745
+ }
3746
+ return source;
3747
+ };
3748
+ injectServerOnlyComment = (source) => {
3749
+ return `/* @server-only */
3750
+ ${source}`;
3751
+ };
3752
+ analyzeClasses = (filesJson, cwd, flags) => {
3753
+ const native = getNativeBridge();
3754
+ if (!native?.analyzeClasses) {
3755
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
3756
+ }
3757
+ return native.analyzeClasses(filesJson, cwd, flags);
2463
3758
  };
2464
3759
  extractTwStateConfigs = (source, filename) => {
2465
3760
  const native = getNativeBridge();
@@ -2468,23 +3763,25 @@ ${source}`;
2468
3763
  }
2469
3764
  return native.extractTwStateConfigs(source, filename);
2470
3765
  };
2471
- generateStaticStateCss = (inputs, resolvedCss = null) => {
2472
- const native = getNativeBridge();
2473
- if (!native?.generateStaticStateCss) {
2474
- throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
3766
+ generateStaticStateCss = (entries, _themeConfig) => {
3767
+ const rules = [];
3768
+ for (const entry of entries) {
3769
+ const stateConfig = JSON.parse(entry.statesJson);
3770
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
3771
+ rules.push({
3772
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
3773
+ declarations: classes,
3774
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
3775
+ componentName: entry.componentName,
3776
+ stateName
3777
+ });
3778
+ }
2475
3779
  }
2476
- return native.generateStaticStateCss(inputs, resolvedCss);
3780
+ return rules;
2477
3781
  };
2478
3782
  extractAndGenerateStateCss = (source, filename) => {
2479
- const native = getNativeBridge();
2480
- if (!native?.extractAndGenerateStateCss) {
2481
- const configs = extractTwStateConfigs(source, filename);
2482
- if (configs.length === 0) return [];
2483
- return generateStaticStateCss(
2484
- configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
2485
- );
2486
- }
2487
- return native.extractAndGenerateStateCss(source, filename);
3783
+ const entries = extractTwStateConfigs(source, filename);
3784
+ return generateStaticStateCss(entries);
2488
3785
  };
2489
3786
  }
2490
3787
  });
@@ -2492,7 +3789,7 @@ ${source}`;
2492
3789
  // packages/domain/scanner/src/native-bridge.ts
2493
3790
  var native_bridge_exports = {};
2494
3791
  __export(native_bridge_exports, {
2495
- batchExtractClassesNative: () => batchExtractClassesNative,
3792
+ batchExtractClassesNative: () => batchExtractClassesNative2,
2496
3793
  cachePriorityNative: () => cachePriorityNative,
2497
3794
  cacheReadNative: () => cacheReadNative,
2498
3795
  cacheWriteNative: () => cacheWriteNative,
@@ -2512,8 +3809,8 @@ __export(native_bridge_exports, {
2512
3809
  scanCacheInvalidate: () => scanCacheInvalidate,
2513
3810
  scanCachePut: () => scanCachePut,
2514
3811
  scanCacheStats: () => scanCacheStats,
2515
- scanFileNative: () => scanFileNative,
2516
- scanFilesBatchNative: () => scanFilesBatchNative,
3812
+ scanFileNative: () => scanFileNative2,
3813
+ scanFilesBatchNative: () => scanFilesBatchNative2,
2517
3814
  scanWorkspaceNative: () => scanWorkspaceNative,
2518
3815
  startWatchNative: () => startWatchNative,
2519
3816
  stopWatchNative: () => stopWatchNative
@@ -2604,7 +3901,7 @@ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHit
2604
3901
  }
2605
3902
  return result;
2606
3903
  }
2607
- function batchExtractClassesNative(filePaths) {
3904
+ function batchExtractClassesNative2(filePaths) {
2608
3905
  const binding = scannerGetBinding();
2609
3906
  if (!binding.batchExtractClasses) {
2610
3907
  throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
@@ -2639,7 +3936,7 @@ function scanCacheStats() {
2639
3936
  }
2640
3937
  return binding.scanCacheStats();
2641
3938
  }
2642
- function scanFileNative(filePath) {
3939
+ function scanFileNative2(filePath) {
2643
3940
  const binding = scannerGetBinding();
2644
3941
  if (!binding.scanFile) {
2645
3942
  throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
@@ -2651,7 +3948,7 @@ function collectFilesNative(root, extensions, ignoreDirs) {
2651
3948
  if (!binding.collectFiles) return null;
2652
3949
  return binding.collectFiles(root, extensions, ignoreDirs);
2653
3950
  }
2654
- function scanFilesBatchNative(filePaths) {
3951
+ function scanFilesBatchNative2(filePaths) {
2655
3952
  const binding = scannerGetBinding();
2656
3953
  if (!binding.scanFilesBatch) {
2657
3954
  return filePaths.map((fp) => {
@@ -2856,7 +4153,7 @@ var init_cache_native = __esm({
2856
4153
  init_native_bridge();
2857
4154
  }
2858
4155
  });
2859
- function collectFiles(rootDir, extensions, ignoreDirs) {
4156
+ function collectFiles2(rootDir, extensions, ignoreDirs) {
2860
4157
  const native = collectFilesNative(rootDir, extensions, ignoreDirs);
2861
4158
  if (native !== null) return native;
2862
4159
  throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
@@ -2896,9 +4193,9 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
2896
4193
  maxWorkers = Math.max(1, os.availableParallelism() - 1),
2897
4194
  chunkSize = DEFAULT_CHUNK_SIZE
2898
4195
  } = options;
2899
- const files = collectFiles(path9__namespace.default.resolve(rootDir), extensions, ignoreDirs);
4196
+ const files = collectFiles2(path9__namespace.default.resolve(rootDir), extensions, ignoreDirs);
2900
4197
  if (files.length < PARALLEL_THRESHOLD) {
2901
- return mergeResults(batchExtractClassesNative(files));
4198
+ return mergeResults(batchExtractClassesNative2(files));
2902
4199
  }
2903
4200
  const chunks = [];
2904
4201
  for (let i = 0; i < files.length; i += chunkSize) {
@@ -2922,7 +4219,7 @@ var init_parallel_scanner = __esm({
2922
4219
  if (!worker_threads.isMainThread && worker_threads.parentPort) {
2923
4220
  const { filePaths } = worker_threads.workerData;
2924
4221
  try {
2925
- const results = batchExtractClassesNative(filePaths);
4222
+ const results = batchExtractClassesNative2(filePaths);
2926
4223
  const msg = { ok: true, results };
2927
4224
  worker_threads.parentPort.postMessage(msg);
2928
4225
  } catch (error) {
@@ -3006,15 +4303,15 @@ var src_exports2 = {};
3006
4303
  __export(src_exports2, {
3007
4304
  DEFAULT_EXTENSIONS: () => DEFAULT_EXTENSIONS,
3008
4305
  DEFAULT_IGNORES: () => DEFAULT_IGNORES,
3009
- batchExtractClassesNative: () => batchExtractClassesNative,
4306
+ batchExtractClassesNative: () => batchExtractClassesNative2,
3010
4307
  extractClassesNative: () => extractClassesNative,
3011
4308
  isScannableFile: () => isScannableFile2,
3012
4309
  parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
3013
4310
  parseScanWorkspaceResult: () => parseScanWorkspaceResult,
3014
4311
  parseScannerWorkerMessage: () => parseScannerWorkerMessage,
3015
- scanFile: () => scanFile,
4312
+ scanFile: () => scanFile2,
3016
4313
  scanSource: () => scanSource,
3017
- scanWorkspace: () => scanWorkspace,
4314
+ scanWorkspace: () => scanWorkspace2,
3018
4315
  scanWorkspaceAsync: () => scanWorkspaceAsync
3019
4316
  });
3020
4317
  function getRuntimeDir() {
@@ -3140,9 +4437,9 @@ function scanSource(source) {
3140
4437
  function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
3141
4438
  return includeExtensions.includes(path9__namespace.default.extname(filePath));
3142
4439
  }
3143
- function scanFile(filePath) {
3144
- const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
3145
- const result = scanFileNative2(filePath);
4440
+ function scanFile2(filePath) {
4441
+ const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
4442
+ const result = scanFileNative3(filePath);
3146
4443
  if (!result.ok) {
3147
4444
  throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
3148
4445
  }
@@ -3152,7 +4449,7 @@ function scanFile(filePath) {
3152
4449
  ...result.hash ? { hash: result.hash } : {}
3153
4450
  };
3154
4451
  }
3155
- function scanWorkspace(rootDir, options = {}) {
4452
+ function scanWorkspace2(rootDir, options = {}) {
3156
4453
  const normalizedOptions = parseScanWorkspaceOptions(options);
3157
4454
  const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
3158
4455
  const extensionSet = buildExtensionSet(includeExtensions);
@@ -3275,7 +4572,7 @@ function scanWorkspace(rootDir, options = {}) {
3275
4572
  }
3276
4573
  } else {
3277
4574
  for (const filePath of candidates) {
3278
- processResult(scanFile(filePath));
4575
+ processResult(scanFile2(filePath));
3279
4576
  }
3280
4577
  }
3281
4578
  return parseScanWorkspaceResult({
@@ -3302,7 +4599,7 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
3302
4599
  log3.debug(
3303
4600
  `worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
3304
4601
  );
3305
- return scanWorkspace(rootDir, normalizedOptions);
4602
+ return scanWorkspace2(rootDir, normalizedOptions);
3306
4603
  }
3307
4604
  }
3308
4605
  var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
@@ -4101,7 +5398,7 @@ init_src();
4101
5398
  init_native_bridge2();
4102
5399
  var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
4103
5400
  var log5 = createLogger2("engine:incremental");
4104
- function rebuildWorkspaceResult(byFile) {
5401
+ function rebuildWorkspaceResult2(byFile) {
4105
5402
  const files = Array.from(byFile.values());
4106
5403
  const native = getNativeEngineBinding();
4107
5404
  if (native?.rebuildWorkspaceResult) {
@@ -4144,10 +5441,10 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
4144
5441
  log5.debug(`native unlink ${normalizedPath}`);
4145
5442
  native.processFileChange(normalizedPath, existing2?.classes ?? [], null);
4146
5443
  byFile.delete(normalizedPath);
4147
- return rebuildWorkspaceResult(byFile);
5444
+ return rebuildWorkspaceResult2(byFile);
4148
5445
  }
4149
5446
  log5.debug(`native change ${normalizedPath}`);
4150
- const scanned = scanFile(normalizedPath);
5447
+ const scanned = scanFile2(normalizedPath);
4151
5448
  const content = fs13__namespace.default.readFileSync(normalizedPath, "utf8");
4152
5449
  const diff = native.processFileChange(normalizedPath, scanned.classes, content);
4153
5450
  const existing = byFile.get(normalizedPath);
@@ -4160,7 +5457,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
4160
5457
  log5.debug(`native diff cold-sync ${normalizedPath}`);
4161
5458
  byFile.set(normalizedPath, { file: normalizedPath, classes: scanned.classes });
4162
5459
  }
4163
- return rebuildWorkspaceResult(byFile);
5460
+ return rebuildWorkspaceResult2(byFile);
4164
5461
  }
4165
5462
 
4166
5463
  // packages/domain/engine/src/metrics.ts