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.mjs CHANGED
@@ -987,46 +987,39 @@ var init_observability = __esm({
987
987
  }
988
988
  });
989
989
 
990
- // packages/domain/compiler/src/cssGeneratorNative.ts
990
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
991
991
  async function generateCssNative(classes, options) {
992
- const {
993
- theme,
994
- fallbackToJs = true,
995
- logFallback = false
996
- } = options;
992
+ const { theme } = options;
993
+ const native = getNativeBridge();
994
+ if (!native?.generateCssNative) {
995
+ throw new Error(
996
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
997
+ );
998
+ }
999
+ const themeJson = JSON.stringify(theme);
1000
+ const css = native.generateCssNative(classes, themeJson);
1001
+ return css;
1002
+ }
1003
+ function clearThemeCache() {
997
1004
  try {
998
1005
  const native = getNativeBridge();
999
- if (!native?.generateCssNative) {
1000
- throw new Error("generateCssNative not available in native binding");
1001
- }
1002
- const themeJson = JSON.stringify(theme);
1003
- const css = native.generateCssNative(classes, themeJson);
1004
- return css;
1005
- } catch (error) {
1006
- if (!fallbackToJs) {
1007
- throw error;
1008
- }
1009
- if (logFallback) {
1010
- console.warn(
1011
- "[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
1012
- error instanceof Error ? error.message : String(error)
1013
- );
1006
+ if (!native?.clearThemeCache) {
1007
+ return;
1014
1008
  }
1015
- return generateRawCss(classes);
1009
+ native.clearThemeCache();
1010
+ } catch {
1016
1011
  }
1017
1012
  }
1018
1013
  var init_cssGeneratorNative = __esm({
1019
- "packages/domain/compiler/src/cssGeneratorNative.ts"() {
1014
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
1020
1015
  init_nativeBridge();
1021
- init_tailwindEngine();
1022
1016
  }
1023
1017
  });
1024
1018
 
1025
- // packages/domain/compiler/src/tailwindEngine.ts
1019
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
1026
1020
  var tailwindEngine_exports = {};
1027
1021
  __export(tailwindEngine_exports, {
1028
1022
  clearCache: () => clearCache,
1029
- generateRawCss: () => generateRawCss,
1030
1023
  getCacheStats: () => getCacheStats,
1031
1024
  processTailwindCssWithTargets: () => processTailwindCssWithTargets,
1032
1025
  runCssPipeline: () => runCssPipeline,
@@ -1060,48 +1053,6 @@ function clearCache() {
1060
1053
  _cacheHits = 0;
1061
1054
  _cacheMisses = 0;
1062
1055
  }
1063
- function loadTailwindEngine() {
1064
- if (_twEngine) return _twEngine;
1065
- if (_twEngineError) throw _twEngineError;
1066
- try {
1067
- const tw = require2("tailwindcss");
1068
- if (typeof tw.compile !== "function") {
1069
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1070
- }
1071
- _twEngine = tw;
1072
- return _twEngine;
1073
- } catch (e) {
1074
- _twEngineError = e instanceof Error ? e : new Error(String(e));
1075
- throw _twEngineError;
1076
- }
1077
- }
1078
- async function generateRawCss(classes, cssEntryContent, root) {
1079
- if (classes.length === 0) return "";
1080
- const tw = loadTailwindEngine();
1081
- const input = cssEntryContent ?? "@import 'tailwindcss';";
1082
- const { readFileSync, existsSync: existsSync3 } = await import('fs');
1083
- const { dirname, resolve: resolve2 } = await import('path');
1084
- const projectRoot = root ?? process.cwd();
1085
- const req = createRequire(resolve2(projectRoot, "package.json"));
1086
- const loadStylesheet = async (id, base) => {
1087
- try {
1088
- const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
1089
- const pkgPath = req.resolve(cssId);
1090
- return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1091
- } catch {
1092
- try {
1093
- const absPath = resolve2(base, id);
1094
- if (existsSync3(absPath)) {
1095
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1096
- }
1097
- } catch {
1098
- }
1099
- return { content: "", base };
1100
- }
1101
- };
1102
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1103
- return compiler.build(classes);
1104
- }
1105
1056
  function getThemeConfig() {
1106
1057
  return {
1107
1058
  colors: {
@@ -1198,20 +1149,9 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1198
1149
  _cacheMisses++;
1199
1150
  let rawCss;
1200
1151
  let usedRustCompiler = false;
1201
- try {
1202
- const theme = getThemeConfig();
1203
- rawCss = await generateCssNative(unique, {
1204
- theme,
1205
- fallbackToJs: true,
1206
- logFallback: process.env.DEBUG?.includes("compiler") === true
1207
- });
1208
- usedRustCompiler = true;
1209
- } catch (error) {
1210
- if (process.env.DEBUG?.includes("compiler")) {
1211
- console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
1212
- }
1213
- rawCss = await generateRawCss(unique, cssEntryContent, root);
1214
- }
1152
+ const theme = getThemeConfig();
1153
+ rawCss = await generateCssNative(unique, { theme });
1154
+ usedRustCompiler = true;
1215
1155
  const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
1216
1156
  if (process.env.DEBUG?.includes("compiler")) {
1217
1157
  console.log(
@@ -1219,42 +1159,1355 @@ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1219
1159
  `Size: ${finalCss.length} bytes`
1220
1160
  );
1221
1161
  }
1222
- const result = {
1223
- css: finalCss,
1224
- classes: unique,
1225
- sizeBytes: finalCss.length,
1226
- optimized: minify
1227
- };
1228
- _evictOldestIfNeeded();
1229
- _cssCache.set(cacheKey, result);
1230
- return result;
1162
+ const result = {
1163
+ css: finalCss,
1164
+ classes: unique,
1165
+ sizeBytes: finalCss.length,
1166
+ optimized: minify
1167
+ };
1168
+ _evictOldestIfNeeded();
1169
+ _cssCache.set(cacheKey, result);
1170
+ return result;
1171
+ }
1172
+ function runCssPipelineSync(_classes) {
1173
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1174
+ }
1175
+ function processTailwindCssWithTargets(css, targets) {
1176
+ const native = getNativeBridge();
1177
+ if (!native?.processTailwindCssWithTargets) {
1178
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
1179
+ }
1180
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
1181
+ if (!result?.css) {
1182
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
1183
+ }
1184
+ return result.css;
1185
+ }
1186
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1187
+ var init_tailwindEngine = __esm({
1188
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1189
+ init_nativeBridge();
1190
+ init_cssGeneratorNative();
1191
+ createRequire(import.meta.url);
1192
+ _cssCache = /* @__PURE__ */ new Map();
1193
+ _cacheHits = 0;
1194
+ _cacheMisses = 0;
1195
+ MAX_CACHE_SIZE = 100;
1196
+ }
1197
+ });
1198
+
1199
+ // packages/domain/compiler/src/compiler/compilationNative.ts
1200
+ function compileCssNative2(classes, prefix) {
1201
+ const native = getNativeBridge();
1202
+ if (!native?.compileCss) throw new Error("compileCss not available");
1203
+ return native.compileCss(classes, prefix);
1204
+ }
1205
+ function compileCssLightning(classes) {
1206
+ const native = getNativeBridge();
1207
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
1208
+ return native.compileCssLightning(classes);
1209
+ }
1210
+ function extractTwStateConfigsNative(source, filename) {
1211
+ const native = getNativeBridge();
1212
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
1213
+ return native.extractTwStateConfigs(source, filename);
1214
+ }
1215
+ function generateStaticStateCssNative(inputs, resolvedCss) {
1216
+ const native = getNativeBridge();
1217
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
1218
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
1219
+ }
1220
+ function extractAndGenerateStateCssNative(source, filename) {
1221
+ const native = getNativeBridge();
1222
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
1223
+ return native.extractAndGenerateStateCss(source, filename);
1224
+ }
1225
+ function layoutClassesToCss(classes) {
1226
+ const native = getNativeBridge();
1227
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
1228
+ return native.layoutClassesToCss(classes);
1229
+ }
1230
+ function hashContent(input, algorithm = "sha256", length = 8) {
1231
+ const native = getNativeBridge();
1232
+ if (!native?.hashContent) throw new Error("hashContent not available");
1233
+ return native.hashContent(input, algorithm, length);
1234
+ }
1235
+ function extractTwContainerConfigs(source) {
1236
+ const native = getNativeBridge();
1237
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
1238
+ return native.extractTwContainerConfigs(source);
1239
+ }
1240
+ function parseAtomicClass(twClass) {
1241
+ const native = getNativeBridge();
1242
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
1243
+ return native.parseAtomicClass(twClass);
1244
+ }
1245
+ function generateAtomicCss(rulesJson) {
1246
+ const native = getNativeBridge();
1247
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
1248
+ return native.generateAtomicCss(rulesJson);
1249
+ }
1250
+ function toAtomicClasses(twClasses) {
1251
+ const native = getNativeBridge();
1252
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
1253
+ return native.toAtomicClasses(twClasses);
1254
+ }
1255
+ function clearAtomicRegistry() {
1256
+ const native = getNativeBridge();
1257
+ if (!native?.clearAtomicRegistry) return;
1258
+ native.clearAtomicRegistry();
1259
+ }
1260
+ function atomicRegistrySize() {
1261
+ const native = getNativeBridge();
1262
+ if (!native?.atomicRegistrySize) return 0;
1263
+ return native.atomicRegistrySize();
1264
+ }
1265
+ var init_compilationNative = __esm({
1266
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
1267
+ init_nativeBridge();
1268
+ }
1269
+ });
1270
+
1271
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
1272
+ function compileClass(input) {
1273
+ const native = getNativeBridge();
1274
+ if (!native?.compile_class) throw new Error("compile_class not available");
1275
+ const resultJson = native.compile_class(input);
1276
+ try {
1277
+ return JSON.parse(resultJson);
1278
+ } catch {
1279
+ return {
1280
+ selector: "",
1281
+ declarations: "",
1282
+ properties: [],
1283
+ specificity: 0
1284
+ };
1285
+ }
1286
+ }
1287
+ function compileClasses(inputs) {
1288
+ const native = getNativeBridge();
1289
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
1290
+ const resultJson = native.compile_classes(inputs);
1291
+ try {
1292
+ return JSON.parse(resultJson);
1293
+ } catch {
1294
+ return {
1295
+ css: "",
1296
+ resolved_classes: [],
1297
+ unknown_classes: [],
1298
+ size_bytes: 0,
1299
+ duration_ms: 0
1300
+ };
1301
+ }
1302
+ }
1303
+ function compileToCss(input, minify) {
1304
+ const native = getNativeBridge();
1305
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
1306
+ return native.compile_to_css(input, minify ?? false);
1307
+ }
1308
+ function compileToCssBatch(inputs, minify) {
1309
+ const native = getNativeBridge();
1310
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
1311
+ return native.compile_to_css_batch(inputs, minify ?? false);
1312
+ }
1313
+ function minifyCss(css) {
1314
+ const native = getNativeBridge();
1315
+ if (!native?.minify_css) throw new Error("minify_css not available");
1316
+ return native.minify_css(css);
1317
+ }
1318
+ function compileAnimation(animationName, from, to) {
1319
+ const native = getNativeBridge();
1320
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
1321
+ const resultJson = native.compile_animation(animationName, from, to);
1322
+ try {
1323
+ return JSON.parse(resultJson);
1324
+ } catch {
1325
+ return {
1326
+ animation_id: "",
1327
+ keyframes_css: "",
1328
+ animation_rule: "",
1329
+ duration_ms: 0
1330
+ };
1331
+ }
1332
+ }
1333
+ function compileKeyframes(name, stopsJson) {
1334
+ const native = getNativeBridge();
1335
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
1336
+ const resultJson = native.compile_keyframes(name, stopsJson);
1337
+ try {
1338
+ return JSON.parse(resultJson);
1339
+ } catch {
1340
+ return {
1341
+ animation_id: "",
1342
+ keyframes_css: "",
1343
+ animation_rule: "",
1344
+ duration_ms: 0
1345
+ };
1346
+ }
1347
+ }
1348
+ function compileTheme(tokensJson, themeName, prefix) {
1349
+ const native = getNativeBridge();
1350
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
1351
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
1352
+ try {
1353
+ return JSON.parse(resultJson);
1354
+ } catch {
1355
+ return {
1356
+ selector: ":root",
1357
+ variables: [],
1358
+ variables_css: "",
1359
+ theme_name: themeName
1360
+ };
1361
+ }
1362
+ }
1363
+ function twMerge(classString) {
1364
+ const native = getNativeBridge();
1365
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
1366
+ return native.tw_merge(classString);
1367
+ }
1368
+ function twMergeMany(classStrings) {
1369
+ const native = getNativeBridge();
1370
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
1371
+ return native.tw_merge_many(classStrings);
1372
+ }
1373
+ function twMergeWithSeparator(classString, options) {
1374
+ const native = getNativeBridge();
1375
+ if (!native?.tw_merge_with_separator)
1376
+ throw new Error("tw_merge_with_separator not available");
1377
+ const opts = {
1378
+ separator: options.separator,
1379
+ debug: options.debug
1380
+ };
1381
+ return native.tw_merge_with_separator(classString, opts);
1382
+ }
1383
+ function twMergeManyWithSeparator(classStrings, options) {
1384
+ const native = getNativeBridge();
1385
+ if (!native?.tw_merge_many_with_separator)
1386
+ throw new Error("tw_merge_many_with_separator not available");
1387
+ const opts = {
1388
+ separator: options.separator,
1389
+ debug: options.debug
1390
+ };
1391
+ return native.tw_merge_many_with_separator(classStrings, opts);
1392
+ }
1393
+ function twMergeRaw(classLists) {
1394
+ const native = getNativeBridge();
1395
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
1396
+ return native.tw_merge_raw(classLists);
1397
+ }
1398
+ var init_cssCompilationNative = __esm({
1399
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
1400
+ init_nativeBridge();
1401
+ }
1402
+ });
1403
+
1404
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
1405
+ function idRegistryCreate() {
1406
+ const native = getNativeBridge();
1407
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
1408
+ return native.id_registry_create();
1409
+ }
1410
+ function idRegistryGenerate(handle, name) {
1411
+ const native = getNativeBridge();
1412
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
1413
+ return native.id_registry_generate(handle, name);
1414
+ }
1415
+ function idRegistryLookup(handle, name) {
1416
+ const native = getNativeBridge();
1417
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
1418
+ return native.id_registry_lookup(handle, name);
1419
+ }
1420
+ function idRegistryNext(handle) {
1421
+ const native = getNativeBridge();
1422
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
1423
+ return native.id_registry_next(handle);
1424
+ }
1425
+ function idRegistryDestroy(handle) {
1426
+ const native = getNativeBridge();
1427
+ if (!native?.id_registry_destroy) return;
1428
+ native.id_registry_destroy(handle);
1429
+ }
1430
+ function idRegistryReset(handle) {
1431
+ const native = getNativeBridge();
1432
+ if (!native?.id_registry_reset) return;
1433
+ native.id_registry_reset(handle);
1434
+ }
1435
+ function idRegistrySnapshot(handle) {
1436
+ const native = getNativeBridge();
1437
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
1438
+ const snapshotJson = native.id_registry_snapshot(handle);
1439
+ try {
1440
+ return JSON.parse(snapshotJson);
1441
+ } catch {
1442
+ return {
1443
+ handle,
1444
+ next_id: 0,
1445
+ entries: [],
1446
+ total_entries: 0
1447
+ };
1448
+ }
1449
+ }
1450
+ function idRegistryActiveCount() {
1451
+ const native = getNativeBridge();
1452
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
1453
+ return native.id_registry_active_count();
1454
+ }
1455
+ function registerPropertyName(propertyName) {
1456
+ const native = getNativeBridge();
1457
+ if (!native?.register_property_name)
1458
+ throw new Error("register_property_name not available");
1459
+ return native.register_property_name(propertyName);
1460
+ }
1461
+ function registerValueName(valueName) {
1462
+ const native = getNativeBridge();
1463
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
1464
+ return native.register_value_name(valueName);
1465
+ }
1466
+ function propertyIdToString(propertyId) {
1467
+ const native = getNativeBridge();
1468
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
1469
+ return native.property_id_to_string(propertyId);
1470
+ }
1471
+ function valueIdToString(valueId) {
1472
+ const native = getNativeBridge();
1473
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
1474
+ return native.value_id_to_string(valueId);
1475
+ }
1476
+ function reverseLookupProperty(propertyId) {
1477
+ const native = getNativeBridge();
1478
+ if (!native?.reverse_lookup_property)
1479
+ throw new Error("reverse_lookup_property not available");
1480
+ return native.reverse_lookup_property(propertyId);
1481
+ }
1482
+ function reverseLookupValue(valueId) {
1483
+ const native = getNativeBridge();
1484
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
1485
+ return native.reverse_lookup_value(valueId);
1486
+ }
1487
+ function idRegistryExport(handle) {
1488
+ const native = getNativeBridge();
1489
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
1490
+ return native.id_registry_export(handle);
1491
+ }
1492
+ function idRegistryImport(importedData) {
1493
+ const native = getNativeBridge();
1494
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
1495
+ return native.id_registry_import(importedData);
1496
+ }
1497
+ var init_idRegistryNative = __esm({
1498
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
1499
+ init_nativeBridge();
1500
+ }
1501
+ });
1502
+
1503
+ // packages/domain/compiler/src/compiler/streamingNative.ts
1504
+ function processFileChange(fileChangeJson) {
1505
+ const native = getNativeBridge();
1506
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
1507
+ const resultJson = native.process_file_change(fileChangeJson);
1508
+ try {
1509
+ return JSON.parse(resultJson);
1510
+ } catch {
1511
+ return {
1512
+ file_path: "",
1513
+ status: "error",
1514
+ old_classes: [],
1515
+ new_classes: [],
1516
+ added_classes: [],
1517
+ removed_classes: [],
1518
+ changed: false,
1519
+ fingerprint: "",
1520
+ error: "Failed to parse result"
1521
+ };
1522
+ }
1523
+ }
1524
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
1525
+ const native = getNativeBridge();
1526
+ if (!native?.compute_incremental_diff)
1527
+ throw new Error("compute_incremental_diff not available");
1528
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
1529
+ try {
1530
+ return JSON.parse(resultJson);
1531
+ } catch {
1532
+ return {
1533
+ is_changed: false,
1534
+ changes_count: 0,
1535
+ diff: {
1536
+ added_files: [],
1537
+ removed_files: [],
1538
+ modified_files: [],
1539
+ added_classes: [],
1540
+ removed_classes: [],
1541
+ total_changes: 0
1542
+ },
1543
+ processing_time_ms: 0
1544
+ };
1545
+ }
1546
+ }
1547
+ function createFingerprint(filePath, fileContent) {
1548
+ const native = getNativeBridge();
1549
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
1550
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
1551
+ try {
1552
+ return JSON.parse(fingerprintJson);
1553
+ } catch {
1554
+ return {
1555
+ file_path: filePath,
1556
+ content_hash: "",
1557
+ size_bytes: fileContent.length,
1558
+ mtime_ms: Date.now(),
1559
+ class_hash: "",
1560
+ signature: ""
1561
+ };
1562
+ }
1563
+ }
1564
+ function injectStateHash(css, stateHash) {
1565
+ const native = getNativeBridge();
1566
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
1567
+ const resultJson = native.inject_state_hash(css, stateHash);
1568
+ try {
1569
+ return JSON.parse(resultJson);
1570
+ } catch {
1571
+ return {
1572
+ injected: false,
1573
+ state_hash: stateHash,
1574
+ affected_files: 0,
1575
+ total_injected_bytes: 0
1576
+ };
1577
+ }
1578
+ }
1579
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
1580
+ const native = getNativeBridge();
1581
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
1582
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
1583
+ try {
1584
+ return JSON.parse(resultJson);
1585
+ } catch {
1586
+ return {
1587
+ entries_before: 0,
1588
+ entries_after: 0,
1589
+ entries_removed: 0,
1590
+ freed_bytes: 0
1591
+ };
1592
+ }
1593
+ }
1594
+ function rebuildWorkspaceResult(rootDir, extensions) {
1595
+ const native = getNativeBridge();
1596
+ if (!native?.rebuild_workspace_result)
1597
+ throw new Error("rebuild_workspace_result not available");
1598
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
1599
+ try {
1600
+ return JSON.parse(resultJson);
1601
+ } catch {
1602
+ return {
1603
+ total_files_scanned: 0,
1604
+ total_classes_found: 0,
1605
+ unique_classes: 0,
1606
+ build_time_ms: 0,
1607
+ files_with_changes: 0
1608
+ };
1609
+ }
1610
+ }
1611
+ function scanFileNative(filePath, fileContent) {
1612
+ const native = getNativeBridge();
1613
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
1614
+ const resultJson = native.scan_file_native(filePath, fileContent);
1615
+ try {
1616
+ return JSON.parse(resultJson);
1617
+ } catch {
1618
+ return {
1619
+ file: filePath,
1620
+ classes: [],
1621
+ added_classes: [],
1622
+ removed_classes: [],
1623
+ changed: false
1624
+ };
1625
+ }
1626
+ }
1627
+ function scanFilesBatchNative(filesJson) {
1628
+ const native = getNativeBridge();
1629
+ if (!native?.scan_files_batch_native)
1630
+ throw new Error("scan_files_batch_native not available");
1631
+ const resultJson = native.scan_files_batch_native(filesJson);
1632
+ try {
1633
+ return JSON.parse(resultJson);
1634
+ } catch {
1635
+ return [];
1636
+ }
1637
+ }
1638
+ var init_streamingNative = __esm({
1639
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
1640
+ init_nativeBridge();
1641
+ }
1642
+ });
1643
+
1644
+ // packages/domain/compiler/src/compiler/index.ts
1645
+ var init_compiler = __esm({
1646
+ "packages/domain/compiler/src/compiler/index.ts"() {
1647
+ init_cssGeneratorNative();
1648
+ init_compilationNative();
1649
+ init_cssCompilationNative();
1650
+ init_idRegistryNative();
1651
+ init_streamingNative();
1652
+ }
1653
+ });
1654
+
1655
+ // packages/domain/compiler/src/parser/index.ts
1656
+ var parser_exports = {};
1657
+ __export(parser_exports, {
1658
+ astExtractClasses: () => astExtractClasses,
1659
+ batchExtractClasses: () => batchExtractClasses,
1660
+ checkAgainstSafelist: () => checkAgainstSafelist,
1661
+ diffClassLists: () => diffClassLists,
1662
+ extractAllClasses: () => extractAllClasses,
1663
+ extractClassesFromSource: () => extractClassesFromSource,
1664
+ extractComponentUsage: () => extractComponentUsage,
1665
+ mergeClassesStatic: () => mergeClassesStatic,
1666
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1667
+ normalizeClasses: () => normalizeClasses,
1668
+ parseClasses: () => parseClasses
1669
+ });
1670
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1671
+ var init_parser = __esm({
1672
+ "packages/domain/compiler/src/parser/index.ts"() {
1673
+ init_nativeBridge();
1674
+ parseClasses = (raw) => {
1675
+ const native = getNativeBridge();
1676
+ if (!native?.parseClasses) {
1677
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1678
+ }
1679
+ return native.parseClasses(raw) || [];
1680
+ };
1681
+ extractAllClasses = (source) => {
1682
+ const native = getNativeBridge();
1683
+ if (!native?.extractAllClasses) {
1684
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1685
+ }
1686
+ return native.extractAllClasses(source) || [];
1687
+ };
1688
+ extractClassesFromSource = (source) => {
1689
+ const native = getNativeBridge();
1690
+ if (!native?.extractClassesFromSource) {
1691
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1692
+ }
1693
+ const result = native.extractClassesFromSource(source);
1694
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1695
+ };
1696
+ astExtractClasses = (source, _filename) => {
1697
+ const native = getNativeBridge();
1698
+ if (!native?.extractClassesFromSource) {
1699
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1700
+ }
1701
+ return native.extractClassesFromSource(source) || [];
1702
+ };
1703
+ normalizeClasses = (raw) => {
1704
+ const result = normalizeAndDedupClasses(raw);
1705
+ return result?.normalized || "";
1706
+ };
1707
+ mergeClassesStatic = (classes) => {
1708
+ const result = normalizeAndDedupClasses(classes);
1709
+ return result?.normalized || "";
1710
+ };
1711
+ normalizeAndDedupClasses = (raw) => {
1712
+ const native = getNativeBridge();
1713
+ if (!native?.normalizeAndDedupClasses) {
1714
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1715
+ }
1716
+ const result = native.normalizeAndDedupClasses(raw);
1717
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1718
+ };
1719
+ extractComponentUsage = (source) => {
1720
+ const native = getNativeBridge();
1721
+ if (!native?.extractComponentUsage) {
1722
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1723
+ }
1724
+ return native.extractComponentUsage(source) || [];
1725
+ };
1726
+ batchExtractClasses = (filePaths) => {
1727
+ const native = getNativeBridge();
1728
+ if (!native?.batchExtractClasses) {
1729
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1730
+ }
1731
+ return native.batchExtractClasses(filePaths) || [];
1732
+ };
1733
+ checkAgainstSafelist = (classes, safelist) => {
1734
+ const native = getNativeBridge();
1735
+ if (!native?.checkAgainstSafelist) {
1736
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1737
+ }
1738
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1739
+ };
1740
+ diffClassLists = (previous, current) => {
1741
+ const native = getNativeBridge();
1742
+ if (!native?.diffClassLists) {
1743
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1744
+ }
1745
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1746
+ };
1747
+ }
1748
+ });
1749
+
1750
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1751
+ function detectDeadCode(scanResultJson, css) {
1752
+ const native = getNativeBridge();
1753
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1754
+ return native.detectDeadCode(scanResultJson, css);
1755
+ }
1756
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1757
+ const native = getNativeBridge();
1758
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1759
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1760
+ }
1761
+ function analyzeClassesNative(filesJson, cwd, flags) {
1762
+ const native = getNativeBridge();
1763
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1764
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1765
+ }
1766
+ function analyzeRscNative(source, filename) {
1767
+ const native = getNativeBridge();
1768
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1769
+ return native.analyzeRsc(source, filename);
1770
+ }
1771
+ function optimizeCssNative(css) {
1772
+ const native = getNativeBridge();
1773
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1774
+ const result = native.processTailwindCssLightning(css);
1775
+ return {
1776
+ css: result.css,
1777
+ originalSize: css.length,
1778
+ optimizedSize: result.size_bytes,
1779
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1780
+ };
1781
+ }
1782
+ function processTailwindCssLightning(css) {
1783
+ const native = getNativeBridge();
1784
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1785
+ return native.processTailwindCssLightning(css);
1786
+ }
1787
+ function eliminateDeadCssNative(css, deadClasses) {
1788
+ const native = getNativeBridge();
1789
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1790
+ return native.eliminateDeadCss(css, deadClasses);
1791
+ }
1792
+ function hoistComponentsNative(source) {
1793
+ const native = getNativeBridge();
1794
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1795
+ return native.hoistComponents(source);
1796
+ }
1797
+ function compileVariantTableNative(configJson) {
1798
+ const native = getNativeBridge();
1799
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1800
+ return native.compileVariantTable(configJson);
1801
+ }
1802
+ function classifyAndSortClassesNative(classes) {
1803
+ const native = getNativeBridge();
1804
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1805
+ return native.classifyAndSortClasses(classes);
1806
+ }
1807
+ function mergeCssDeclarationsNative(cssChunks) {
1808
+ const native = getNativeBridge();
1809
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1810
+ return native.mergeCssDeclarations(cssChunks);
1811
+ }
1812
+ var init_analyzerNative = __esm({
1813
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1814
+ init_nativeBridge();
1815
+ }
1816
+ });
1817
+
1818
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1819
+ function resolveVariants(configJson) {
1820
+ const native = getNativeBridge();
1821
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1822
+ const resultJson = native.resolve_variants(configJson);
1823
+ try {
1824
+ return JSON.parse(resultJson);
1825
+ } catch {
1826
+ return {
1827
+ variants: [],
1828
+ supported: [],
1829
+ deprecated: [],
1830
+ conflicting: []
1831
+ };
1832
+ }
1833
+ }
1834
+ function validateThemeConfig(configJson) {
1835
+ const native = getNativeBridge();
1836
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1837
+ const resultJson = native.validate_variant_config(configJson);
1838
+ try {
1839
+ return JSON.parse(resultJson);
1840
+ } catch {
1841
+ return {
1842
+ is_valid: false,
1843
+ errors: ["Unable to parse configuration"],
1844
+ warnings: [],
1845
+ suggestions: []
1846
+ };
1847
+ }
1848
+ }
1849
+ function resolveCascade(baseThemeJson, overridesJson) {
1850
+ const native = getNativeBridge();
1851
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1852
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1853
+ try {
1854
+ return JSON.parse(resultJson);
1855
+ } catch {
1856
+ return {
1857
+ base_theme: {},
1858
+ user_overrides: {},
1859
+ merged_theme: {},
1860
+ conflict_resolutions: []
1861
+ };
1862
+ }
1863
+ }
1864
+ function resolveClassNames(classNames, themeJson) {
1865
+ const native = getNativeBridge();
1866
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1867
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1868
+ try {
1869
+ return JSON.parse(resultJson);
1870
+ } catch {
1871
+ return [];
1872
+ }
1873
+ }
1874
+ function resolveConflictGroup(groupName, themeJson) {
1875
+ const native = getNativeBridge();
1876
+ if (!native?.resolve_conflict_group)
1877
+ throw new Error("resolve_conflict_group not available");
1878
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1879
+ try {
1880
+ return JSON.parse(resultJson);
1881
+ } catch {
1882
+ return {
1883
+ group_name: groupName,
1884
+ conflicting_classes: [],
1885
+ description: "",
1886
+ resolution_strategy: "last-wins"
1887
+ };
1888
+ }
1889
+ }
1890
+ function resolveThemeValue(keyPath, themeJson) {
1891
+ const native = getNativeBridge();
1892
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1893
+ return native.resolve_theme_value(keyPath, themeJson);
1894
+ }
1895
+ function resolveSimpleVariants(configJson) {
1896
+ const native = getNativeBridge();
1897
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1898
+ const resultJson = native.resolve_simple_variants(configJson);
1899
+ try {
1900
+ return JSON.parse(resultJson);
1901
+ } catch {
1902
+ return [];
1903
+ }
1904
+ }
1905
+ var init_themeResolutionNative = __esm({
1906
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1907
+ init_nativeBridge();
1908
+ }
1909
+ });
1910
+
1911
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1912
+ function scanWorkspace(root, extensions) {
1913
+ const native = getNativeBridge();
1914
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1915
+ return native.scan_workspace(root, extensions);
1916
+ }
1917
+ function extractClassesFromSourceNative(source) {
1918
+ const native = getNativeBridge();
1919
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1920
+ return native.extract_classes_from_source(source);
1921
+ }
1922
+ function batchExtractClassesNative(filePaths) {
1923
+ const native = getNativeBridge();
1924
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1925
+ return native.batch_extract_classes(filePaths);
1926
+ }
1927
+ function checkAgainstSafelistNative(classes, safelist) {
1928
+ const native = getNativeBridge();
1929
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1930
+ return native.check_against_safelist(classes, safelist);
1931
+ }
1932
+ function scanFile(filePath) {
1933
+ const native = getNativeBridge();
1934
+ if (!native?.scan_file) throw new Error("scan_file not available");
1935
+ return native.scan_file(filePath);
1936
+ }
1937
+ function collectFiles(root, extensions) {
1938
+ const native = getNativeBridge();
1939
+ if (!native?.collect_files) throw new Error("collect_files not available");
1940
+ return native.collect_files(root, extensions);
1941
+ }
1942
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1943
+ const native = getNativeBridge();
1944
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1945
+ return native.walk_and_prefilter_source_files(root, extensions);
1946
+ }
1947
+ function generateSubComponentTypes(root, outputPath) {
1948
+ const native = getNativeBridge();
1949
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1950
+ return native.generate_sub_component_types(root, outputPath);
1951
+ }
1952
+ var init_scannerNative = __esm({
1953
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1954
+ init_nativeBridge();
1955
+ }
1956
+ });
1957
+
1958
+ // packages/domain/compiler/src/analyzer/index.ts
1959
+ var init_analyzer = __esm({
1960
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1961
+ init_analyzerNative();
1962
+ init_themeResolutionNative();
1963
+ init_scannerNative();
1964
+ }
1965
+ });
1966
+
1967
+ // packages/domain/compiler/src/cache/cacheNative.ts
1968
+ function getCacheStatistics() {
1969
+ const native = getNativeBridge();
1970
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1971
+ const statsJson = native.get_cache_statistics();
1972
+ try {
1973
+ return JSON.parse(statsJson);
1974
+ } catch {
1975
+ return {
1976
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1977
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
1978
+ compile_cache: { hits: 0, misses: 0, size: 0 },
1979
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
1980
+ overall_hit_rate: 0,
1981
+ total_memory_bytes: 0
1982
+ };
1983
+ }
1984
+ }
1985
+ function clearAllCaches() {
1986
+ const native = getNativeBridge();
1987
+ if (!native?.clear_all_caches) return;
1988
+ try {
1989
+ native.clear_all_caches();
1990
+ } catch {
1991
+ }
1992
+ }
1993
+ function clearParseCache() {
1994
+ const native = getNativeBridge();
1995
+ if (!native?.clear_parse_cache) return;
1996
+ try {
1997
+ native.clear_parse_cache();
1998
+ } catch {
1999
+ }
2000
+ }
2001
+ function clearResolveCache() {
2002
+ const native = getNativeBridge();
2003
+ if (!native?.clear_resolve_cache) return;
2004
+ try {
2005
+ native.clear_resolve_cache();
2006
+ } catch {
2007
+ }
2008
+ }
2009
+ function clearCompileCache() {
2010
+ const native = getNativeBridge();
2011
+ if (!native?.clear_compile_cache) return;
2012
+ try {
2013
+ native.clear_compile_cache();
2014
+ } catch {
2015
+ }
2016
+ }
2017
+ function clearCssGenCache() {
2018
+ const native = getNativeBridge();
2019
+ if (!native?.clear_css_gen_cache) return;
2020
+ try {
2021
+ native.clear_css_gen_cache();
2022
+ } catch {
2023
+ }
2024
+ }
2025
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
2026
+ const native = getNativeBridge();
2027
+ if (!native?.get_cache_optimization_hints)
2028
+ throw new Error("get_cache_optimization_hints not available");
2029
+ const hintsJson = native.get_cache_optimization_hints(
2030
+ Math.min(100, Math.max(0, hitRatePercent)),
2031
+ Math.max(1, memoryUsedMb)
2032
+ );
2033
+ try {
2034
+ return JSON.parse(hintsJson);
2035
+ } catch {
2036
+ return {
2037
+ current_strategy: "unknown",
2038
+ recommended_strategy: "increase_size",
2039
+ estimated_improvement_percent: 0,
2040
+ suggested_memory_mb: 256,
2041
+ notes: ["Unable to analyze cache statistics"]
2042
+ };
2043
+ }
2044
+ }
2045
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
2046
+ const native = getNativeBridge();
2047
+ if (!native?.estimate_optimal_cache_config_native)
2048
+ throw new Error("estimate_optimal_cache_config_native not available");
2049
+ const configJson = native.estimate_optimal_cache_config_native(
2050
+ Math.max(64, totalBudgetMb),
2051
+ workloadType
2052
+ );
2053
+ try {
2054
+ return JSON.parse(configJson);
2055
+ } catch {
2056
+ return {
2057
+ parse_cache_size: 128,
2058
+ resolve_cache_size: 64,
2059
+ compile_cache_size: 256,
2060
+ css_gen_cache_size: 128,
2061
+ recommended_eviction_policy: "lru",
2062
+ ttl_seconds: 3600,
2063
+ expected_hit_rate_percent: 75
2064
+ };
2065
+ }
2066
+ }
2067
+ function cacheRead(cachePath) {
2068
+ const native = getNativeBridge();
2069
+ if (!native?.cache_read) throw new Error("cache_read not available");
2070
+ const result = native.cache_read(cachePath);
2071
+ try {
2072
+ return JSON.parse(result.entries_json || "[]");
2073
+ } catch {
2074
+ return [];
2075
+ }
2076
+ }
2077
+ function cacheWrite(cachePath, entries) {
2078
+ const native = getNativeBridge();
2079
+ if (!native?.cache_write) throw new Error("cache_write not available");
2080
+ try {
2081
+ const result = native.cache_write(
2082
+ cachePath,
2083
+ entries.map((e) => ({
2084
+ file: e.file,
2085
+ content_hash: e.contentHash,
2086
+ classes: e.classes,
2087
+ mtime_ms: e.mtimeMs,
2088
+ size_bytes: e.sizeBytes
2089
+ }))
2090
+ );
2091
+ return typeof result === "boolean" ? result : result === true;
2092
+ } catch {
2093
+ return false;
2094
+ }
2095
+ }
2096
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
2097
+ const native = getNativeBridge();
2098
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
2099
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
2100
+ }
2101
+ var init_cacheNative = __esm({
2102
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
2103
+ init_nativeBridge();
2104
+ }
2105
+ });
2106
+
2107
+ // packages/domain/compiler/src/cache/index.ts
2108
+ var init_cache = __esm({
2109
+ "packages/domain/compiler/src/cache/index.ts"() {
2110
+ init_cacheNative();
2111
+ }
2112
+ });
2113
+
2114
+ // packages/domain/compiler/src/redis/redisNative.ts
2115
+ function redisPing() {
2116
+ const native = getNativeBridge();
2117
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
2118
+ return native.redis_ping();
2119
+ }
2120
+ function redisGet(key) {
2121
+ const native = getNativeBridge();
2122
+ if (!native?.redis_get) throw new Error("redis_get not available");
2123
+ const result = native.redis_get(key);
2124
+ return result === "nil" ? null : result;
2125
+ }
2126
+ function redisSet(key, value, ttl_seconds) {
2127
+ const native = getNativeBridge();
2128
+ if (!native?.redis_set) throw new Error("redis_set not available");
2129
+ return native.redis_set(key, value, ttl_seconds);
2130
+ }
2131
+ function redisDelete(key) {
2132
+ const native = getNativeBridge();
2133
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
2134
+ return native.redis_delete(key);
2135
+ }
2136
+ function redisExists(key) {
2137
+ const native = getNativeBridge();
2138
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
2139
+ return native.redis_exists(key);
2140
+ }
2141
+ function redisMget(keys) {
2142
+ const native = getNativeBridge();
2143
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
2144
+ const result = native.redis_mget(keys);
2145
+ try {
2146
+ return JSON.parse(result);
2147
+ } catch {
2148
+ return keys.map(() => null);
2149
+ }
2150
+ }
2151
+ function redisMset(pairs) {
2152
+ const native = getNativeBridge();
2153
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
2154
+ return native.redis_mset(pairs);
2155
+ }
2156
+ function redisFlushDb() {
2157
+ const native = getNativeBridge();
2158
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
2159
+ return native.redis_flush_db();
2160
+ }
2161
+ function redisFlushAll() {
2162
+ const native = getNativeBridge();
2163
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
2164
+ return native.redis_flush_all();
2165
+ }
2166
+ function redisPoolConnect(host, port, pool_size) {
2167
+ const native = getNativeBridge();
2168
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
2169
+ return native.redis_pool_connect(host, port, pool_size);
2170
+ }
2171
+ function redisPoolStats() {
2172
+ const native = getNativeBridge();
2173
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
2174
+ const result = native.redis_pool_stats();
2175
+ try {
2176
+ return JSON.parse(result);
2177
+ } catch {
2178
+ return {
2179
+ connected_count: 0,
2180
+ idle_count: 0,
2181
+ waiting_count: 0,
2182
+ total_requests: 0,
2183
+ total_errors: 0
2184
+ };
2185
+ }
2186
+ }
2187
+ function redisPoolReconnect() {
2188
+ const native = getNativeBridge();
2189
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
2190
+ return native.redis_pool_reconnect();
2191
+ }
2192
+ function redisEnableCluster(initial_nodes) {
2193
+ const native = getNativeBridge();
2194
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
2195
+ const result = native.redis_enable_cluster(initial_nodes);
2196
+ try {
2197
+ return JSON.parse(result);
2198
+ } catch {
2199
+ return {
2200
+ enabled: false,
2201
+ cluster_state: "error",
2202
+ nodes: [],
2203
+ slots_assigned: 0,
2204
+ slots_ok: 0,
2205
+ slots_fail: 0
2206
+ };
2207
+ }
2208
+ }
2209
+ function redisDisableCluster() {
2210
+ const native = getNativeBridge();
2211
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
2212
+ return native.redis_disable_cluster();
2213
+ }
2214
+ function redisClusterStatus() {
2215
+ const native = getNativeBridge();
2216
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
2217
+ const result = native.redis_cluster_status();
2218
+ try {
2219
+ return JSON.parse(result);
2220
+ } catch {
2221
+ return {
2222
+ enabled: false,
2223
+ cluster_state: "unknown",
2224
+ nodes: [],
2225
+ slots_assigned: 0,
2226
+ slots_ok: 0,
2227
+ slots_fail: 0
2228
+ };
2229
+ }
2230
+ }
2231
+ function redisSubscribe(channel) {
2232
+ const native = getNativeBridge();
2233
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
2234
+ return native.redis_subscribe(channel);
2235
+ }
2236
+ function redisPublish(channel, message) {
2237
+ const native = getNativeBridge();
2238
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
2239
+ return native.redis_publish(channel, message);
2240
+ }
2241
+ function redisExpirationSet(key, ttl_seconds) {
2242
+ const native = getNativeBridge();
2243
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
2244
+ return native.redis_expiration_set(key, ttl_seconds);
2245
+ }
2246
+ function redisExpirationGet(key) {
2247
+ const native = getNativeBridge();
2248
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
2249
+ const result = native.redis_expiration_get(key);
2250
+ try {
2251
+ return JSON.parse(result);
2252
+ } catch {
2253
+ return {
2254
+ key,
2255
+ ttl_seconds: -1,
2256
+ expiration_timestamp: 0,
2257
+ is_persistent: true
2258
+ };
2259
+ }
2260
+ }
2261
+ function redisInfo() {
2262
+ const native = getNativeBridge();
2263
+ if (!native?.redis_info) throw new Error("redis_info not available");
2264
+ return native.redis_info();
2265
+ }
2266
+ function redisMonitor() {
2267
+ const native = getNativeBridge();
2268
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
2269
+ return native.redis_monitor();
2270
+ }
2271
+ function redisCacheSize() {
2272
+ const native = getNativeBridge();
2273
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
2274
+ return native.redis_cache_size();
2275
+ }
2276
+ function redisCacheKeyCount() {
2277
+ const native = getNativeBridge();
2278
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
2279
+ return native.redis_cache_key_count();
2280
+ }
2281
+ function redisCacheClear() {
2282
+ const native = getNativeBridge();
2283
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
2284
+ return native.redis_cache_clear();
2285
+ }
2286
+ function redisCacheHitRate() {
2287
+ const native = getNativeBridge();
2288
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
2289
+ return native.redis_cache_hit_rate();
2290
+ }
2291
+ function redisEnablePersistence(mode) {
2292
+ const native = getNativeBridge();
2293
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
2294
+ return native.redis_enable_persistence(mode);
2295
+ }
2296
+ function redisDisablePersistence() {
2297
+ const native = getNativeBridge();
2298
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
2299
+ return native.redis_disable_persistence();
2300
+ }
2301
+ function redisSnapshot() {
2302
+ const native = getNativeBridge();
2303
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
2304
+ return native.redis_snapshot();
2305
+ }
2306
+ function redisMemoryStats() {
2307
+ const native = getNativeBridge();
2308
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
2309
+ return native.redis_memory_stats();
2310
+ }
2311
+ function redisOptimizeMemory() {
2312
+ const native = getNativeBridge();
2313
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
2314
+ return native.redis_optimize_memory();
2315
+ }
2316
+ function redisSetEvictionPolicy(policy) {
2317
+ const native = getNativeBridge();
2318
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
2319
+ return native.redis_set_eviction_policy(policy);
2320
+ }
2321
+ function redisGetEvictionPolicy() {
2322
+ const native = getNativeBridge();
2323
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
2324
+ return native.redis_get_eviction_policy();
2325
+ }
2326
+ function redisReplicate(target_host, target_port) {
2327
+ const native = getNativeBridge();
2328
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
2329
+ return native.redis_replicate(target_host, target_port);
2330
+ }
2331
+ function redisReplicationStatus() {
2332
+ const native = getNativeBridge();
2333
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
2334
+ return native.redis_replication_status();
2335
+ }
2336
+ function redisCacheSync(peers) {
2337
+ const native = getNativeBridge();
2338
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
2339
+ return native.redis_cache_sync(peers);
2340
+ }
2341
+ function redisEnableCacheWarming(key_pattern) {
2342
+ const native = getNativeBridge();
2343
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
2344
+ return native.redis_enable_cache_warming(key_pattern);
2345
+ }
2346
+ function redisDisableCacheWarming() {
2347
+ const native = getNativeBridge();
2348
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
2349
+ return native.redis_disable_cache_warming();
2350
+ }
2351
+ function redisDiagnose() {
2352
+ const native = getNativeBridge();
2353
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
2354
+ return native.redis_diagnose();
2355
+ }
2356
+ var init_redisNative = __esm({
2357
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
2358
+ init_nativeBridge();
2359
+ }
2360
+ });
2361
+
2362
+ // packages/domain/compiler/src/redis/index.ts
2363
+ var init_redis = __esm({
2364
+ "packages/domain/compiler/src/redis/index.ts"() {
2365
+ init_redisNative();
2366
+ }
2367
+ });
2368
+
2369
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
2370
+ function startWatch(root_path, patterns) {
2371
+ const native = getNativeBridge();
2372
+ if (!native?.start_watch) throw new Error("start_watch not available");
2373
+ return native.start_watch(root_path, patterns);
2374
+ }
2375
+ function pollWatchEvents(handle, timeout_ms) {
2376
+ const native = getNativeBridge();
2377
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
2378
+ const result = native.poll_watch_events(handle, timeout_ms);
2379
+ try {
2380
+ return JSON.parse(result);
2381
+ } catch {
2382
+ return [];
2383
+ }
2384
+ }
2385
+ function stopWatch(handle) {
2386
+ const native = getNativeBridge();
2387
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
2388
+ return native.stop_watch(handle);
2389
+ }
2390
+ function watchAddPattern(handle, pattern) {
2391
+ const native = getNativeBridge();
2392
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
2393
+ return native.watch_add_pattern(handle, pattern);
2394
+ }
2395
+ function watchRemovePattern(handle, pattern) {
2396
+ const native = getNativeBridge();
2397
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
2398
+ return native.watch_remove_pattern(handle, pattern);
2399
+ }
2400
+ function watchGetActiveHandles() {
2401
+ const native = getNativeBridge();
2402
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
2403
+ const result = native.watch_get_active_handles();
2404
+ try {
2405
+ return JSON.parse(result);
2406
+ } catch {
2407
+ return [];
2408
+ }
1231
2409
  }
1232
- function runCssPipelineSync(_classes) {
1233
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
2410
+ function watchClearAll() {
2411
+ const native = getNativeBridge();
2412
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
2413
+ return native.watch_clear_all();
1234
2414
  }
1235
- function processTailwindCssWithTargets(css, targets) {
2415
+ function watchEventTypeToString(event_type_code) {
1236
2416
  const native = getNativeBridge();
1237
- if (!native?.processTailwindCssWithTargets) {
1238
- throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
2417
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
2418
+ return native.watch_event_type_to_string(event_type_code);
2419
+ }
2420
+ function isWatchRunning(handle) {
2421
+ const native = getNativeBridge();
2422
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
2423
+ return native.is_watch_running(handle);
2424
+ }
2425
+ function getWatchStats() {
2426
+ const native = getNativeBridge();
2427
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
2428
+ const result = native.get_watch_stats();
2429
+ try {
2430
+ return JSON.parse(result);
2431
+ } catch {
2432
+ return {
2433
+ active_watchers: 0,
2434
+ total_events: 0,
2435
+ events_this_second: 0,
2436
+ average_latency_ms: 0,
2437
+ largest_batch_size: 0
2438
+ };
1239
2439
  }
1240
- const result = native.processTailwindCssWithTargets(css, targets ?? null);
1241
- if (!result?.css) {
1242
- throw new Error("FATAL: processTailwindCssWithTargets returned null");
2440
+ }
2441
+ function watchPause(handle) {
2442
+ const native = getNativeBridge();
2443
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
2444
+ return native.watch_pause(handle);
2445
+ }
2446
+ function watchResume(handle) {
2447
+ const native = getNativeBridge();
2448
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
2449
+ return native.watch_resume(handle);
2450
+ }
2451
+ function scanCacheOptimizations() {
2452
+ const native = getNativeBridge();
2453
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
2454
+ return native.scan_cache_optimizations();
2455
+ }
2456
+ function getPluginHooks() {
2457
+ const native = getNativeBridge();
2458
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
2459
+ const result = native.get_plugin_hooks();
2460
+ try {
2461
+ return JSON.parse(result);
2462
+ } catch {
2463
+ return [];
1243
2464
  }
1244
- return result.css;
1245
2465
  }
1246
- var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
1247
- var init_tailwindEngine = __esm({
1248
- "packages/domain/compiler/src/tailwindEngine.ts"() {
2466
+ function registerPluginHook(hook_name, handler_id) {
2467
+ const native = getNativeBridge();
2468
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
2469
+ return native.register_plugin_hook(hook_name, handler_id);
2470
+ }
2471
+ function unregisterPluginHook(hook_name, handler_id) {
2472
+ const native = getNativeBridge();
2473
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
2474
+ return native.unregister_plugin_hook(hook_name, handler_id);
2475
+ }
2476
+ function emitPluginHook(hook_name, data_json) {
2477
+ const native = getNativeBridge();
2478
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
2479
+ return native.emit_plugin_hook(hook_name, data_json);
2480
+ }
2481
+ function getCompilationMetrics() {
2482
+ const native = getNativeBridge();
2483
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
2484
+ return native.get_compilation_metrics();
2485
+ }
2486
+ function resetCompilationMetrics() {
2487
+ const native = getNativeBridge();
2488
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
2489
+ return native.reset_compilation_metrics();
2490
+ }
2491
+ function validateCssOutput(css) {
2492
+ const native = getNativeBridge();
2493
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
2494
+ return native.validate_css_output(css);
2495
+ }
2496
+ function getCompilerDiagnostics() {
2497
+ const native = getNativeBridge();
2498
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
2499
+ return native.get_compiler_diagnostics();
2500
+ }
2501
+ var init_watchSystemNative = __esm({
2502
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1249
2503
  init_nativeBridge();
1250
- init_cssGeneratorNative();
1251
- require2 = createRequire(import.meta.url);
1252
- _cssCache = /* @__PURE__ */ new Map();
1253
- _cacheHits = 0;
1254
- _cacheMisses = 0;
1255
- MAX_CACHE_SIZE = 100;
1256
- _twEngine = null;
1257
- _twEngineError = null;
2504
+ }
2505
+ });
2506
+
2507
+ // packages/domain/compiler/src/watch/index.ts
2508
+ var init_watch = __esm({
2509
+ "packages/domain/compiler/src/watch/index.ts"() {
2510
+ init_watchSystemNative();
1258
2511
  }
1259
2512
  });
1260
2513
 
@@ -1262,75 +2515,219 @@ var init_tailwindEngine = __esm({
1262
2515
  var internal_exports = {};
1263
2516
  __export(internal_exports, {
1264
2517
  adaptNativeResult: () => adaptNativeResult,
1265
- analyzeClassUsage: () => analyzeClassUsage,
2518
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
1266
2519
  analyzeClasses: () => analyzeClasses,
2520
+ analyzeClassesNative: () => analyzeClassesNative,
1267
2521
  analyzeFile: () => analyzeFile,
1268
- analyzeRsc: () => analyzeRsc,
2522
+ analyzeRscNative: () => analyzeRscNative,
1269
2523
  analyzeVariantUsage: () => analyzeVariantUsage,
1270
2524
  astExtractClasses: () => astExtractClasses,
2525
+ atomicRegistrySize: () => atomicRegistrySize,
1271
2526
  batchExtractClasses: () => batchExtractClasses,
2527
+ batchExtractClassesNative: () => batchExtractClassesNative,
1272
2528
  bucketSort: () => bucketSort,
1273
2529
  buildStyleTag: () => buildStyleTag,
2530
+ cachePriority: () => cachePriority,
2531
+ cacheRead: () => cacheRead,
2532
+ cacheWrite: () => cacheWrite,
1274
2533
  checkAgainstSafelist: () => checkAgainstSafelist,
1275
- classifyAndSortClasses: () => classifyAndSortClasses,
2534
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2535
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
1276
2536
  classifyNode: () => classifyNode,
2537
+ clearAllCaches: () => clearAllCaches,
2538
+ clearAtomicRegistry: () => clearAtomicRegistry,
1277
2539
  clearCache: () => clearCache,
2540
+ clearCompileCache: () => clearCompileCache,
2541
+ clearCssGenCache: () => clearCssGenCache,
2542
+ clearParseCache: () => clearParseCache,
2543
+ clearResolveCache: () => clearResolveCache,
2544
+ clearThemeCache: () => clearThemeCache,
2545
+ collectFiles: () => collectFiles,
2546
+ compileAnimation: () => compileAnimation,
2547
+ compileClass: () => compileClass,
2548
+ compileClasses: () => compileClasses,
1278
2549
  compileCssFromClasses: () => compileCssFromClasses,
1279
- compileCssNative: () => compileCssNative,
1280
- compileVariantTable: () => compileVariantTable,
1281
- compileVariants: () => compileVariants,
2550
+ compileCssLightning: () => compileCssLightning,
2551
+ compileCssNative2: () => compileCssNative2,
2552
+ compileKeyframes: () => compileKeyframes,
2553
+ compileTheme: () => compileTheme,
2554
+ compileToCss: () => compileToCss,
2555
+ compileToCssBatch: () => compileToCssBatch,
2556
+ compileVariantTableNative: () => compileVariantTableNative,
2557
+ computeIncrementalDiff: () => computeIncrementalDiff,
2558
+ createFingerprint: () => createFingerprint,
1282
2559
  detectConflicts: () => detectConflicts,
2560
+ detectDeadCode: () => detectDeadCode,
1283
2561
  diffClassLists: () => diffClassLists,
1284
2562
  eliminateDeadCss: () => eliminateDeadCss,
2563
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
2564
+ emitPluginHook: () => emitPluginHook,
2565
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
1285
2566
  extractAllClasses: () => extractAllClasses,
1286
2567
  extractAndGenerateStateCss: () => extractAndGenerateStateCss,
2568
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
1287
2569
  extractClassesFromSource: () => extractClassesFromSource,
2570
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
1288
2571
  extractComponentUsage: () => extractComponentUsage,
1289
2572
  extractContainerCssFromSource: () => extractContainerCssFromSource,
2573
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
1290
2574
  extractTwStateConfigs: () => extractTwStateConfigs,
2575
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
1291
2576
  fileToRoute: () => fileToRoute,
1292
2577
  findDeadVariants: () => findDeadVariants,
2578
+ generateAtomicCss: () => generateAtomicCss,
1293
2579
  generateCssForClasses: () => generateCssForClasses,
1294
- generateRawCss: () => generateRawCss,
2580
+ generateCssNative: () => generateCssNative,
1295
2581
  generateSafelist: () => generateSafelist,
1296
2582
  generateStaticStateCss: () => generateStaticStateCss,
2583
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
2584
+ generateSubComponentTypes: () => generateSubComponentTypes,
1297
2585
  getAllRoutes: () => getAllRoutes,
1298
2586
  getBucketEngine: () => getBucketEngine,
2587
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
2588
+ getCacheStatistics: () => getCacheStatistics,
1299
2589
  getCacheStats: () => getCacheStats,
2590
+ getCompilationMetrics: () => getCompilationMetrics,
2591
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
1300
2592
  getContentPaths: () => getContentPaths,
1301
2593
  getIncrementalEngine: () => getIncrementalEngine,
1302
2594
  getNativeBridge: () => getNativeBridge,
2595
+ getPluginHooks: () => getPluginHooks,
1303
2596
  getRouteClasses: () => getRouteClasses,
2597
+ getWatchStats: () => getWatchStats,
1304
2598
  hasTwUsage: () => hasTwUsage,
1305
- hoistComponents: () => hoistComponents,
2599
+ hashContent: () => hashContent,
2600
+ hoistComponentsNative: () => hoistComponentsNative,
2601
+ idRegistryActiveCount: () => idRegistryActiveCount,
2602
+ idRegistryCreate: () => idRegistryCreate,
2603
+ idRegistryDestroy: () => idRegistryDestroy,
2604
+ idRegistryExport: () => idRegistryExport,
2605
+ idRegistryGenerate: () => idRegistryGenerate,
2606
+ idRegistryImport: () => idRegistryImport,
2607
+ idRegistryLookup: () => idRegistryLookup,
2608
+ idRegistryNext: () => idRegistryNext,
2609
+ idRegistryReset: () => idRegistryReset,
2610
+ idRegistrySnapshot: () => idRegistrySnapshot,
1306
2611
  injectClientDirective: () => injectClientDirective,
1307
2612
  injectServerOnlyComment: () => injectServerOnlyComment,
2613
+ injectStateHash: () => injectStateHash,
1308
2614
  isAlreadyTransformed: () => isAlreadyTransformed,
2615
+ isWatchRunning: () => isWatchRunning,
2616
+ layoutClassesToCss: () => layoutClassesToCss,
1309
2617
  loadSafelist: () => loadSafelist,
1310
2618
  loadTailwindConfig: () => loadTailwindConfig,
1311
2619
  mergeClassesStatic: () => mergeClassesStatic,
1312
- mergeCssDeclarations: () => mergeCssDeclarations,
2620
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
2621
+ minifyCss: () => minifyCss,
1313
2622
  normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1314
2623
  normalizeClasses: () => normalizeClasses,
1315
- optimizeCss: () => optimizeCss,
2624
+ optimizeCssNative: () => optimizeCssNative,
2625
+ parseAtomicClass: () => parseAtomicClass,
1316
2626
  parseClasses: () => parseClasses,
2627
+ pollWatchEvents: () => pollWatchEvents,
2628
+ processFileChange: () => processFileChange,
2629
+ processTailwindCssLightning: () => processTailwindCssLightning,
2630
+ propertyIdToString: () => propertyIdToString,
2631
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
2632
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
2633
+ redisCacheClear: () => redisCacheClear,
2634
+ redisCacheHitRate: () => redisCacheHitRate,
2635
+ redisCacheKeyCount: () => redisCacheKeyCount,
2636
+ redisCacheSize: () => redisCacheSize,
2637
+ redisCacheSync: () => redisCacheSync,
2638
+ redisClusterStatus: () => redisClusterStatus,
2639
+ redisDelete: () => redisDelete,
2640
+ redisDiagnose: () => redisDiagnose,
2641
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
2642
+ redisDisableCluster: () => redisDisableCluster,
2643
+ redisDisablePersistence: () => redisDisablePersistence,
2644
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
2645
+ redisEnableCluster: () => redisEnableCluster,
2646
+ redisEnablePersistence: () => redisEnablePersistence,
2647
+ redisExists: () => redisExists,
2648
+ redisExpirationGet: () => redisExpirationGet,
2649
+ redisExpirationSet: () => redisExpirationSet,
2650
+ redisFlushAll: () => redisFlushAll,
2651
+ redisFlushDb: () => redisFlushDb,
2652
+ redisGet: () => redisGet,
2653
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2654
+ redisInfo: () => redisInfo,
2655
+ redisMemoryStats: () => redisMemoryStats,
2656
+ redisMget: () => redisMget,
2657
+ redisMonitor: () => redisMonitor,
2658
+ redisMset: () => redisMset,
2659
+ redisOptimizeMemory: () => redisOptimizeMemory,
2660
+ redisPing: () => redisPing,
2661
+ redisPoolConnect: () => redisPoolConnect,
2662
+ redisPoolReconnect: () => redisPoolReconnect,
2663
+ redisPoolStats: () => redisPoolStats,
2664
+ redisPublish: () => redisPublish,
2665
+ redisReplicate: () => redisReplicate,
2666
+ redisReplicationStatus: () => redisReplicationStatus,
2667
+ redisSet: () => redisSet,
2668
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2669
+ redisSnapshot: () => redisSnapshot,
2670
+ redisSubscribe: () => redisSubscribe,
1317
2671
  registerFileClasses: () => registerFileClasses,
1318
2672
  registerGlobalClasses: () => registerGlobalClasses,
2673
+ registerPluginHook: () => registerPluginHook,
2674
+ registerPropertyName: () => registerPropertyName,
2675
+ registerValueName: () => registerValueName,
1319
2676
  resetBucketEngine: () => resetBucketEngine,
2677
+ resetCompilationMetrics: () => resetCompilationMetrics,
1320
2678
  resetIncrementalEngine: () => resetIncrementalEngine,
2679
+ resolveCascade: () => resolveCascade,
2680
+ resolveClassNames: () => resolveClassNames,
2681
+ resolveConflictGroup: () => resolveConflictGroup,
2682
+ resolveSimpleVariants: () => resolveSimpleVariants,
2683
+ resolveThemeValue: () => resolveThemeValue,
2684
+ resolveVariants: () => resolveVariants,
2685
+ reverseLookupProperty: () => reverseLookupProperty,
2686
+ reverseLookupValue: () => reverseLookupValue,
1321
2687
  runCssPipeline: () => runCssPipeline,
1322
2688
  runCssPipelineSync: () => runCssPipelineSync,
1323
2689
  runElimination: () => runElimination,
1324
2690
  runLoaderTransform: () => runLoaderTransform,
2691
+ scanCacheOptimizations: () => scanCacheOptimizations,
2692
+ scanFile: () => scanFile,
2693
+ scanFileNative: () => scanFileNative,
2694
+ scanFilesBatchNative: () => scanFilesBatchNative,
1325
2695
  scanProjectUsage: () => scanProjectUsage,
2696
+ scanWorkspace: () => scanWorkspace,
1326
2697
  shouldProcess: () => shouldProcess,
1327
2698
  shouldSkipFile: () => shouldSkipFile,
1328
- transformSource: () => transformSource
2699
+ startWatch: () => startWatch,
2700
+ stopWatch: () => stopWatch,
2701
+ toAtomicClasses: () => toAtomicClasses,
2702
+ transformSource: () => transformSource,
2703
+ twMerge: () => twMerge,
2704
+ twMergeMany: () => twMergeMany,
2705
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2706
+ twMergeRaw: () => twMergeRaw,
2707
+ twMergeWithSeparator: () => twMergeWithSeparator,
2708
+ unregisterPluginHook: () => unregisterPluginHook,
2709
+ validateCssOutput: () => validateCssOutput,
2710
+ validateThemeConfig: () => validateThemeConfig,
2711
+ valueIdToString: () => valueIdToString,
2712
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2713
+ watchAddPattern: () => watchAddPattern,
2714
+ watchClearAll: () => watchClearAll,
2715
+ watchEventTypeToString: () => watchEventTypeToString,
2716
+ watchGetActiveHandles: () => watchGetActiveHandles,
2717
+ watchPause: () => watchPause,
2718
+ watchRemovePattern: () => watchRemovePattern,
2719
+ watchResume: () => watchResume
1329
2720
  });
1330
2721
  var init_internal = __esm({
1331
2722
  "packages/domain/compiler/src/internal.ts"() {
1332
2723
  init_src2();
1333
2724
  init_tailwindEngine();
2725
+ init_compiler();
2726
+ init_parser();
2727
+ init_analyzer();
2728
+ init_cache();
2729
+ init_redis();
2730
+ init_watch();
1334
2731
  }
1335
2732
  });
1336
2733
  function getNative() {
@@ -1677,7 +3074,7 @@ __export(src_exports, {
1677
3074
  getPipelinePercentages: () => getPipelinePercentages,
1678
3075
  getSuggestion: () => getSuggestion,
1679
3076
  getTailwindVersion: () => getTailwindVersion,
1680
- hashContent: () => hashContent,
3077
+ hashContent: () => hashContent2,
1681
3078
  isTailwindV4: () => isTailwindV4,
1682
3079
  isTwError: () => isTwError,
1683
3080
  loadNativeBinding: () => loadNativeBinding,
@@ -1807,7 +3204,7 @@ function resolveRuntimeDir(dir, importMetaUrl) {
1807
3204
  return process.cwd();
1808
3205
  }
1809
3206
  }
1810
- function hashContent(content, algorithm = "md5", length) {
3207
+ function hashContent2(content, algorithm = "md5", length) {
1811
3208
  const hash = createHash(algorithm).update(content).digest("hex");
1812
3209
  return length ? hash.slice(0, length) : hash;
1813
3210
  }
@@ -2034,10 +3431,16 @@ function extractContainerCssFromSource(source) {
2034
3431
  }
2035
3432
  return rules.join("\n");
2036
3433
  }
2037
- var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
3434
+ var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
2038
3435
  var init_src2 = __esm({
2039
3436
  "packages/domain/compiler/src/index.ts"() {
2040
3437
  init_nativeBridge();
3438
+ init_compiler();
3439
+ init_parser();
3440
+ init_analyzer();
3441
+ init_cache();
3442
+ init_redis();
3443
+ init_watch();
2041
3444
  transformSource = (source, opts) => {
2042
3445
  const native = getNativeBridge();
2043
3446
  if (!native?.transformSource) {
@@ -2081,58 +3484,19 @@ var init_src2 = __esm({
2081
3484
  const result = compileCssFromClasses(classes);
2082
3485
  return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2083
3486
  };
2084
- compileCssNative = (classes, prefix = null) => {
2085
- return compileCssFromClasses(classes, prefix);
2086
- };
2087
3487
  generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2088
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2089
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2090
- return result.css;
2091
- };
2092
- extractAllClasses = (source) => {
2093
- const native = getNativeBridge();
2094
- if (!native?.extractAllClasses) {
2095
- throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
2096
- }
2097
- return native.extractAllClasses(source) || [];
2098
- };
2099
- extractClassesFromSource = (source) => {
2100
- const native = getNativeBridge();
2101
- if (!native?.extractClassesFromSource) {
2102
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2103
- }
2104
- const result = native.extractClassesFromSource(source);
2105
- return Array.isArray(result) ? result.join(" ") : String(result || "");
2106
- };
2107
- astExtractClasses = (source, _filename) => {
2108
- const native = getNativeBridge();
2109
- if (!native?.extractClassesFromSource) {
2110
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2111
- }
2112
- return native.extractClassesFromSource(source) || [];
2113
- };
2114
- parseClasses = (raw) => {
2115
- const native = getNativeBridge();
2116
- if (!native?.parseClasses) {
2117
- throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
2118
- }
2119
- return native.parseClasses(raw) || [];
2120
- };
2121
- normalizeClasses = (raw) => {
2122
- const result = normalizeAndDedupClasses(raw);
2123
- return result?.normalized || "";
2124
- };
2125
- mergeClassesStatic = (classes) => {
2126
- const result = normalizeAndDedupClasses(classes);
2127
- return result?.normalized || "";
2128
- };
2129
- normalizeAndDedupClasses = (raw) => {
2130
- const native = getNativeBridge();
2131
- if (!native?.normalizeAndDedupClasses) {
2132
- throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
3488
+ try {
3489
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
3490
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
3491
+ return result.css;
3492
+ } catch {
3493
+ const native = getNativeBridge();
3494
+ if (!native?.transformSource) {
3495
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
3496
+ }
3497
+ const result = native.transformSource(classes.join(" "), {});
3498
+ return result?.code || "";
2133
3499
  }
2134
- const result = native.normalizeAndDedupClasses(raw);
2135
- return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
2136
3500
  };
2137
3501
  eliminateDeadCss = (css, deadClasses) => {
2138
3502
  const native = getNativeBridge();
@@ -2165,16 +3529,10 @@ var init_src2 = __esm({
2165
3529
  const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2166
3530
  return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2167
3531
  };
2168
- optimizeCss = (css) => {
2169
- const native = getNativeBridge();
2170
- if (!native?.optimizeCss) {
2171
- throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
2172
- }
2173
- return native.optimizeCss(css);
2174
- };
2175
3532
  scanProjectUsage = (dirs, cwd) => {
3533
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2176
3534
  const files = dirs.map((dir) => path9__default.resolve(cwd, dir));
2177
- const results = batchExtractClasses(files) || [];
3535
+ const results = batchExtractClasses2(files) || [];
2178
3536
  const combined = {};
2179
3537
  for (const result of results) {
2180
3538
  if (result.ok && result.classes) {
@@ -2186,109 +3544,6 @@ var init_src2 = __esm({
2186
3544
  }
2187
3545
  return combined;
2188
3546
  };
2189
- extractComponentUsage = (source) => {
2190
- const native = getNativeBridge();
2191
- if (!native?.extractComponentUsage) {
2192
- throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
2193
- }
2194
- return native.extractComponentUsage(source) || [];
2195
- };
2196
- diffClassLists = (previous, current) => {
2197
- const native = getNativeBridge();
2198
- if (!native?.diffClassLists) {
2199
- throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
2200
- }
2201
- return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
2202
- };
2203
- batchExtractClasses = (filePaths) => {
2204
- const native = getNativeBridge();
2205
- if (!native?.batchExtractClasses) {
2206
- throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
2207
- }
2208
- return native.batchExtractClasses(filePaths) || [];
2209
- };
2210
- checkAgainstSafelist = (classes, safelist) => {
2211
- const native = getNativeBridge();
2212
- if (!native?.checkAgainstSafelist) {
2213
- throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
2214
- }
2215
- return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
2216
- };
2217
- hoistComponents = (source) => {
2218
- const native = getNativeBridge();
2219
- if (!native?.hoistComponents) {
2220
- throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
2221
- }
2222
- return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
2223
- };
2224
- compileVariantTable = (configJson) => {
2225
- const native = getNativeBridge();
2226
- if (!native?.compileVariantTable) {
2227
- throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
2228
- }
2229
- return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
2230
- };
2231
- compileVariants = (componentId, config) => {
2232
- return compileVariantTable(JSON.stringify({ componentId, ...config }));
2233
- };
2234
- classifyAndSortClasses = (classes) => {
2235
- const native = getNativeBridge();
2236
- if (!native?.classifyAndSortClasses) {
2237
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2238
- }
2239
- return native.classifyAndSortClasses(classes) || [];
2240
- };
2241
- mergeCssDeclarations = (cssChunks) => {
2242
- const native = getNativeBridge();
2243
- if (!native?.mergeCssDeclarations) {
2244
- throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
2245
- }
2246
- return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
2247
- };
2248
- analyzeClassUsage = (classes, scanResultJson, css) => {
2249
- const native = getNativeBridge();
2250
- if (!native?.analyzeClassUsage) {
2251
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2252
- }
2253
- return native.analyzeClassUsage(classes, scanResultJson, css) || [];
2254
- };
2255
- analyzeRsc = (source, filename) => {
2256
- const native = getNativeBridge();
2257
- if (!native?.analyzeRsc) {
2258
- throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2259
- }
2260
- return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
2261
- };
2262
- analyzeFile = (source, filename) => {
2263
- const rsc = analyzeRsc(source, filename);
2264
- return {
2265
- isServer: rsc?.isServer ?? true,
2266
- needsClientDirective: rsc?.needsClientDirective ?? false,
2267
- clientReasons: rsc?.clientReasons ?? [],
2268
- interactiveClasses: [],
2269
- canStaticResolveVariants: true
2270
- };
2271
- };
2272
- analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2273
- return { resolved: {}, dynamic: [] };
2274
- };
2275
- injectClientDirective = (source) => {
2276
- if (!source.includes('"use client"') && !source.includes("'use client'")) {
2277
- return '"use client";\n' + source;
2278
- }
2279
- return source;
2280
- };
2281
- injectServerOnlyComment = (source) => {
2282
- return `/* @server-only */
2283
- ${source}`;
2284
- };
2285
- analyzeClasses = (filesJson, cwd, flags) => {
2286
- const native = getNativeBridge();
2287
- if (!native?.analyzeClasses) {
2288
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2289
- }
2290
- return native.analyzeClasses(filesJson, cwd, flags);
2291
- };
2292
3547
  generateSafelist = (scanDirs, outputPath, cwd) => {
2293
3548
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2294
3549
  const allClasses = Object.keys(classes).sort();
@@ -2352,7 +3607,8 @@ ${source}`;
2352
3607
  if (containerCss) cssChunks.push(containerCss);
2353
3608
  const combined = cssChunks.join("\n").trim();
2354
3609
  if (combined) staticCss = combined;
2355
- } catch {
3610
+ } catch (err) {
3611
+ console.debug("Static CSS extraction warning:", err);
2356
3612
  }
2357
3613
  return {
2358
3614
  code: result?.code || "",
@@ -2437,7 +3693,46 @@ ${source}`;
2437
3693
  return [];
2438
3694
  };
2439
3695
  bucketSort = (classes) => {
2440
- return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
3696
+ const native = getNativeBridge();
3697
+ if (!native?.classifyAndSortClasses) {
3698
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
3699
+ }
3700
+ const sorted = native.classifyAndSortClasses(classes);
3701
+ return sorted.map((c) => c.raw ?? c);
3702
+ };
3703
+ analyzeFile = (source, filename) => {
3704
+ const native = getNativeBridge();
3705
+ if (!native?.analyzeRsc) {
3706
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
3707
+ }
3708
+ const rsc = native.analyzeRsc(source, filename);
3709
+ return {
3710
+ isServer: rsc?.isServer ?? true,
3711
+ needsClientDirective: rsc?.needsClientDirective ?? false,
3712
+ clientReasons: rsc?.clientReasons ?? [],
3713
+ interactiveClasses: [],
3714
+ canStaticResolveVariants: true
3715
+ };
3716
+ };
3717
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
3718
+ return { resolved: {}, dynamic: [] };
3719
+ };
3720
+ injectClientDirective = (source) => {
3721
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
3722
+ return '"use client";\n' + source;
3723
+ }
3724
+ return source;
3725
+ };
3726
+ injectServerOnlyComment = (source) => {
3727
+ return `/* @server-only */
3728
+ ${source}`;
3729
+ };
3730
+ analyzeClasses = (filesJson, cwd, flags) => {
3731
+ const native = getNativeBridge();
3732
+ if (!native?.analyzeClasses) {
3733
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
3734
+ }
3735
+ return native.analyzeClasses(filesJson, cwd, flags);
2441
3736
  };
2442
3737
  extractTwStateConfigs = (source, filename) => {
2443
3738
  const native = getNativeBridge();
@@ -2446,23 +3741,25 @@ ${source}`;
2446
3741
  }
2447
3742
  return native.extractTwStateConfigs(source, filename);
2448
3743
  };
2449
- generateStaticStateCss = (inputs, resolvedCss = null) => {
2450
- const native = getNativeBridge();
2451
- if (!native?.generateStaticStateCss) {
2452
- throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
3744
+ generateStaticStateCss = (entries, _themeConfig) => {
3745
+ const rules = [];
3746
+ for (const entry of entries) {
3747
+ const stateConfig = JSON.parse(entry.statesJson);
3748
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
3749
+ rules.push({
3750
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
3751
+ declarations: classes,
3752
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
3753
+ componentName: entry.componentName,
3754
+ stateName
3755
+ });
3756
+ }
2453
3757
  }
2454
- return native.generateStaticStateCss(inputs, resolvedCss);
3758
+ return rules;
2455
3759
  };
2456
3760
  extractAndGenerateStateCss = (source, filename) => {
2457
- const native = getNativeBridge();
2458
- if (!native?.extractAndGenerateStateCss) {
2459
- const configs = extractTwStateConfigs(source, filename);
2460
- if (configs.length === 0) return [];
2461
- return generateStaticStateCss(
2462
- configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
2463
- );
2464
- }
2465
- return native.extractAndGenerateStateCss(source, filename);
3761
+ const entries = extractTwStateConfigs(source, filename);
3762
+ return generateStaticStateCss(entries);
2466
3763
  };
2467
3764
  }
2468
3765
  });
@@ -2470,7 +3767,7 @@ ${source}`;
2470
3767
  // packages/domain/scanner/src/native-bridge.ts
2471
3768
  var native_bridge_exports = {};
2472
3769
  __export(native_bridge_exports, {
2473
- batchExtractClassesNative: () => batchExtractClassesNative,
3770
+ batchExtractClassesNative: () => batchExtractClassesNative2,
2474
3771
  cachePriorityNative: () => cachePriorityNative,
2475
3772
  cacheReadNative: () => cacheReadNative,
2476
3773
  cacheWriteNative: () => cacheWriteNative,
@@ -2490,8 +3787,8 @@ __export(native_bridge_exports, {
2490
3787
  scanCacheInvalidate: () => scanCacheInvalidate,
2491
3788
  scanCachePut: () => scanCachePut,
2492
3789
  scanCacheStats: () => scanCacheStats,
2493
- scanFileNative: () => scanFileNative,
2494
- scanFilesBatchNative: () => scanFilesBatchNative,
3790
+ scanFileNative: () => scanFileNative2,
3791
+ scanFilesBatchNative: () => scanFilesBatchNative2,
2495
3792
  scanWorkspaceNative: () => scanWorkspaceNative,
2496
3793
  startWatchNative: () => startWatchNative,
2497
3794
  stopWatchNative: () => stopWatchNative
@@ -2582,7 +3879,7 @@ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHit
2582
3879
  }
2583
3880
  return result;
2584
3881
  }
2585
- function batchExtractClassesNative(filePaths) {
3882
+ function batchExtractClassesNative2(filePaths) {
2586
3883
  const binding = scannerGetBinding();
2587
3884
  if (!binding.batchExtractClasses) {
2588
3885
  throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
@@ -2617,7 +3914,7 @@ function scanCacheStats() {
2617
3914
  }
2618
3915
  return binding.scanCacheStats();
2619
3916
  }
2620
- function scanFileNative(filePath) {
3917
+ function scanFileNative2(filePath) {
2621
3918
  const binding = scannerGetBinding();
2622
3919
  if (!binding.scanFile) {
2623
3920
  throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
@@ -2629,7 +3926,7 @@ function collectFilesNative(root, extensions, ignoreDirs) {
2629
3926
  if (!binding.collectFiles) return null;
2630
3927
  return binding.collectFiles(root, extensions, ignoreDirs);
2631
3928
  }
2632
- function scanFilesBatchNative(filePaths) {
3929
+ function scanFilesBatchNative2(filePaths) {
2633
3930
  const binding = scannerGetBinding();
2634
3931
  if (!binding.scanFilesBatch) {
2635
3932
  return filePaths.map((fp) => {
@@ -2834,7 +4131,7 @@ var init_cache_native = __esm({
2834
4131
  init_native_bridge();
2835
4132
  }
2836
4133
  });
2837
- function collectFiles(rootDir, extensions, ignoreDirs) {
4134
+ function collectFiles2(rootDir, extensions, ignoreDirs) {
2838
4135
  const native = collectFilesNative(rootDir, extensions, ignoreDirs);
2839
4136
  if (native !== null) return native;
2840
4137
  throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
@@ -2874,9 +4171,9 @@ async function scanWorkspaceParallel(rootDir, options = {}) {
2874
4171
  maxWorkers = Math.max(1, availableParallelism() - 1),
2875
4172
  chunkSize = DEFAULT_CHUNK_SIZE
2876
4173
  } = options;
2877
- const files = collectFiles(path9__default.resolve(rootDir), extensions, ignoreDirs);
4174
+ const files = collectFiles2(path9__default.resolve(rootDir), extensions, ignoreDirs);
2878
4175
  if (files.length < PARALLEL_THRESHOLD) {
2879
- return mergeResults(batchExtractClassesNative(files));
4176
+ return mergeResults(batchExtractClassesNative2(files));
2880
4177
  }
2881
4178
  const chunks = [];
2882
4179
  for (let i = 0; i < files.length; i += chunkSize) {
@@ -2900,7 +4197,7 @@ var init_parallel_scanner = __esm({
2900
4197
  if (!isMainThread && parentPort) {
2901
4198
  const { filePaths } = workerData;
2902
4199
  try {
2903
- const results = batchExtractClassesNative(filePaths);
4200
+ const results = batchExtractClassesNative2(filePaths);
2904
4201
  const msg = { ok: true, results };
2905
4202
  parentPort.postMessage(msg);
2906
4203
  } catch (error) {
@@ -2984,15 +4281,15 @@ var src_exports2 = {};
2984
4281
  __export(src_exports2, {
2985
4282
  DEFAULT_EXTENSIONS: () => DEFAULT_EXTENSIONS,
2986
4283
  DEFAULT_IGNORES: () => DEFAULT_IGNORES,
2987
- batchExtractClassesNative: () => batchExtractClassesNative,
4284
+ batchExtractClassesNative: () => batchExtractClassesNative2,
2988
4285
  extractClassesNative: () => extractClassesNative,
2989
4286
  isScannableFile: () => isScannableFile2,
2990
4287
  parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
2991
4288
  parseScanWorkspaceResult: () => parseScanWorkspaceResult,
2992
4289
  parseScannerWorkerMessage: () => parseScannerWorkerMessage,
2993
- scanFile: () => scanFile,
4290
+ scanFile: () => scanFile2,
2994
4291
  scanSource: () => scanSource,
2995
- scanWorkspace: () => scanWorkspace,
4292
+ scanWorkspace: () => scanWorkspace2,
2996
4293
  scanWorkspaceAsync: () => scanWorkspaceAsync
2997
4294
  });
2998
4295
  function getRuntimeDir() {
@@ -3118,9 +4415,9 @@ function scanSource(source) {
3118
4415
  function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
3119
4416
  return includeExtensions.includes(path9__default.extname(filePath));
3120
4417
  }
3121
- function scanFile(filePath) {
3122
- const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
3123
- const result = scanFileNative2(filePath);
4418
+ function scanFile2(filePath) {
4419
+ const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
4420
+ const result = scanFileNative3(filePath);
3124
4421
  if (!result.ok) {
3125
4422
  throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
3126
4423
  }
@@ -3130,7 +4427,7 @@ function scanFile(filePath) {
3130
4427
  ...result.hash ? { hash: result.hash } : {}
3131
4428
  };
3132
4429
  }
3133
- function scanWorkspace(rootDir, options = {}) {
4430
+ function scanWorkspace2(rootDir, options = {}) {
3134
4431
  const normalizedOptions = parseScanWorkspaceOptions(options);
3135
4432
  const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
3136
4433
  const extensionSet = buildExtensionSet(includeExtensions);
@@ -3253,7 +4550,7 @@ function scanWorkspace(rootDir, options = {}) {
3253
4550
  }
3254
4551
  } else {
3255
4552
  for (const filePath of candidates) {
3256
- processResult(scanFile(filePath));
4553
+ processResult(scanFile2(filePath));
3257
4554
  }
3258
4555
  }
3259
4556
  return parseScanWorkspaceResult({
@@ -3280,7 +4577,7 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
3280
4577
  log3.debug(
3281
4578
  `worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
3282
4579
  );
3283
- return scanWorkspace(rootDir, normalizedOptions);
4580
+ return scanWorkspace2(rootDir, normalizedOptions);
3284
4581
  }
3285
4582
  }
3286
4583
  var log3, SCAN_WORKER_TIMEOUT_MS, createNativeParserLoader, nativeParserLoader, DEFAULT_EXTENSIONS, DEFAULT_IGNORES;
@@ -4079,7 +5376,7 @@ init_src();
4079
5376
  init_native_bridge2();
4080
5377
  var DEFAULT_EXTENSIONS2 = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
4081
5378
  var log5 = createLogger2("engine:incremental");
4082
- function rebuildWorkspaceResult(byFile) {
5379
+ function rebuildWorkspaceResult2(byFile) {
4083
5380
  const files = Array.from(byFile.values());
4084
5381
  const native = getNativeEngineBinding();
4085
5382
  if (native?.rebuildWorkspaceResult) {
@@ -4122,10 +5419,10 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
4122
5419
  log5.debug(`native unlink ${normalizedPath}`);
4123
5420
  native.processFileChange(normalizedPath, existing2?.classes ?? [], null);
4124
5421
  byFile.delete(normalizedPath);
4125
- return rebuildWorkspaceResult(byFile);
5422
+ return rebuildWorkspaceResult2(byFile);
4126
5423
  }
4127
5424
  log5.debug(`native change ${normalizedPath}`);
4128
- const scanned = scanFile(normalizedPath);
5425
+ const scanned = scanFile2(normalizedPath);
4129
5426
  const content = fs13__default.readFileSync(normalizedPath, "utf8");
4130
5427
  const diff = native.processFileChange(normalizedPath, scanned.classes, content);
4131
5428
  const existing = byFile.get(normalizedPath);
@@ -4138,7 +5435,7 @@ function applyIncrementalChange(previous, filePath, type, scanner) {
4138
5435
  log5.debug(`native diff cold-sync ${normalizedPath}`);
4139
5436
  byFile.set(normalizedPath, { file: normalizedPath, classes: scanned.classes });
4140
5437
  }
4141
- return rebuildWorkspaceResult(byFile);
5438
+ return rebuildWorkspaceResult2(byFile);
4142
5439
  }
4143
5440
 
4144
5441
  // packages/domain/engine/src/metrics.ts