tailwind-styled-v4 5.0.11 → 5.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +100 -4
  2. package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
  3. package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
  4. package/dist/analyzer.d.mts +4 -4
  5. package/dist/analyzer.d.ts +4 -4
  6. package/dist/analyzer.js +34 -69
  7. package/dist/analyzer.js.map +1 -1
  8. package/dist/analyzer.mjs +33 -68
  9. package/dist/analyzer.mjs.map +1 -1
  10. package/dist/animate.d.mts +4 -0
  11. package/dist/animate.d.ts +4 -0
  12. package/dist/animate.js +33 -11
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +33 -11
  15. package/dist/animate.mjs.map +1 -1
  16. package/dist/atomic.js +57 -6
  17. package/dist/atomic.js.map +1 -1
  18. package/dist/atomic.mjs +57 -6
  19. package/dist/atomic.mjs.map +1 -1
  20. package/dist/cli.js +404 -190
  21. package/dist/cli.js.map +1 -1
  22. package/dist/cli.mjs +401 -187
  23. package/dist/cli.mjs.map +1 -1
  24. package/dist/compiler.d.mts +2700 -212
  25. package/dist/compiler.d.ts +2700 -212
  26. package/dist/compiler.js +1996 -503
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/compiler.mjs +1847 -448
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/devtools.js +17 -4
  31. package/dist/devtools.js.map +1 -1
  32. package/dist/devtools.mjs +17 -4
  33. package/dist/devtools.mjs.map +1 -1
  34. package/dist/engine.d.mts +11 -470
  35. package/dist/engine.d.ts +11 -470
  36. package/dist/engine.js +2777 -455
  37. package/dist/engine.js.map +1 -1
  38. package/dist/engine.mjs +2776 -454
  39. package/dist/engine.mjs.map +1 -1
  40. package/dist/index-BDQw13kn.d.ts +464 -0
  41. package/dist/index-DJv28Uzq.d.mts +464 -0
  42. package/dist/index.browser.mjs +143 -255
  43. package/dist/index.browser.mjs.map +1 -1
  44. package/dist/index.d.mts +23 -39
  45. package/dist/index.d.ts +23 -39
  46. package/dist/index.js +7234 -1400
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +7234 -1400
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/next.d.mts +44 -1
  51. package/dist/next.d.ts +44 -1
  52. package/dist/next.js +3224 -1065
  53. package/dist/next.js.map +1 -1
  54. package/dist/next.mjs +3223 -1066
  55. package/dist/next.mjs.map +1 -1
  56. package/dist/rspack.d.mts +9 -0
  57. package/dist/rspack.d.ts +9 -0
  58. package/dist/rspack.js +99 -61
  59. package/dist/rspack.js.map +1 -1
  60. package/dist/rspack.mjs +99 -61
  61. package/dist/rspack.mjs.map +1 -1
  62. package/dist/runtime-css.d.mts +8 -0
  63. package/dist/runtime-css.d.ts +8 -0
  64. package/dist/runtime-css.js +23 -7
  65. package/dist/runtime-css.js.map +1 -1
  66. package/dist/runtime-css.mjs +23 -7
  67. package/dist/runtime-css.mjs.map +1 -1
  68. package/dist/scanner.js +16 -37
  69. package/dist/scanner.js.map +1 -1
  70. package/dist/scanner.mjs +15 -36
  71. package/dist/scanner.mjs.map +1 -1
  72. package/dist/shared.d.mts +107 -1
  73. package/dist/shared.d.ts +107 -1
  74. package/dist/shared.js +3014 -466
  75. package/dist/shared.js.map +1 -1
  76. package/dist/shared.mjs +3008 -445
  77. package/dist/shared.mjs.map +1 -1
  78. package/dist/svelte.js +39 -35
  79. package/dist/svelte.js.map +1 -1
  80. package/dist/svelte.mjs +38 -34
  81. package/dist/svelte.mjs.map +1 -1
  82. package/dist/theme.js +85 -76
  83. package/dist/theme.js.map +1 -1
  84. package/dist/theme.mjs +83 -74
  85. package/dist/theme.mjs.map +1 -1
  86. package/dist/turbopackLoader.js +2351 -187
  87. package/dist/turbopackLoader.js.map +1 -1
  88. package/dist/turbopackLoader.mjs +2351 -187
  89. package/dist/turbopackLoader.mjs.map +1 -1
  90. package/dist/tw.js +404 -190
  91. package/dist/tw.js.map +1 -1
  92. package/dist/tw.mjs +401 -187
  93. package/dist/tw.mjs.map +1 -1
  94. package/dist/vite.js +2657 -320
  95. package/dist/vite.js.map +1 -1
  96. package/dist/vite.mjs +2657 -320
  97. package/dist/vite.mjs.map +1 -1
  98. package/dist/vue.js +39 -35
  99. package/dist/vue.js.map +1 -1
  100. package/dist/vue.mjs +38 -34
  101. package/dist/vue.mjs.map +1 -1
  102. package/dist/webpackLoader.js +190 -33
  103. package/dist/webpackLoader.js.map +1 -1
  104. package/dist/webpackLoader.mjs +190 -33
  105. package/dist/webpackLoader.mjs.map +1 -1
  106. package/native/index.node +0 -0
  107. package/native/tailwind-styled-native.node +0 -0
  108. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  109. package/package.json +9 -4
  110. package/CHANGELOG.md +0 -285
package/dist/tw.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import * as fs12 from 'fs';
4
- import fs12__default, { readFileSync, readdirSync } from 'fs';
3
+ import * as fs11 from 'fs';
4
+ import fs11__default, { readFileSync, readdirSync } from 'fs';
5
5
  import * as path6 from 'path';
6
6
  import path6__default, { join, extname } from 'path';
7
7
  import 'crypto';
@@ -9,7 +9,7 @@ import { fileURLToPath, pathToFileURL } from 'url';
9
9
  import { Worker, isMainThread, parentPort, workerData } from 'worker_threads';
10
10
  import { availableParallelism } from 'os';
11
11
  import { z } from 'zod';
12
- import fs8 from 'fs/promises';
12
+ import fs7 from 'fs/promises';
13
13
  import { isTTY, spinner, note, outro, intro, text, isCancel, select, confirm } from '@clack/prompts';
14
14
  import { parseArgs } from 'util';
15
15
  import { spawn } from 'child_process';
@@ -988,7 +988,7 @@ var require_command = __commonJS({
988
988
  "packages/infrastructure/cli/node_modules/commander/lib/command.js"(exports$1) {
989
989
  var EventEmitter = __require("events").EventEmitter;
990
990
  var childProcess = __require("child_process");
991
- var path29 = __require("path");
991
+ var path30 = __require("path");
992
992
  var fs16 = __require("fs");
993
993
  var process2 = __require("process");
994
994
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1920,9 +1920,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1920
1920
  let launchWithNode = false;
1921
1921
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1922
1922
  function findFile(baseDir, baseName) {
1923
- const localBin = path29.resolve(baseDir, baseName);
1923
+ const localBin = path30.resolve(baseDir, baseName);
1924
1924
  if (fs16.existsSync(localBin)) return localBin;
1925
- if (sourceExt.includes(path29.extname(baseName))) return void 0;
1925
+ if (sourceExt.includes(path30.extname(baseName))) return void 0;
1926
1926
  const foundExt = sourceExt.find(
1927
1927
  (ext) => fs16.existsSync(`${localBin}${ext}`)
1928
1928
  );
@@ -1940,17 +1940,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1940
1940
  } catch (err) {
1941
1941
  resolvedScriptPath = this._scriptPath;
1942
1942
  }
1943
- executableDir = path29.resolve(
1944
- path29.dirname(resolvedScriptPath),
1943
+ executableDir = path30.resolve(
1944
+ path30.dirname(resolvedScriptPath),
1945
1945
  executableDir
1946
1946
  );
1947
1947
  }
1948
1948
  if (executableDir) {
1949
1949
  let localFile = findFile(executableDir, executableFile);
1950
1950
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1951
- const legacyName = path29.basename(
1951
+ const legacyName = path30.basename(
1952
1952
  this._scriptPath,
1953
- path29.extname(this._scriptPath)
1953
+ path30.extname(this._scriptPath)
1954
1954
  );
1955
1955
  if (legacyName !== this._name) {
1956
1956
  localFile = findFile(
@@ -1961,7 +1961,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1961
1961
  }
1962
1962
  executableFile = localFile || executableFile;
1963
1963
  }
1964
- launchWithNode = sourceExt.includes(path29.extname(executableFile));
1964
+ launchWithNode = sourceExt.includes(path30.extname(executableFile));
1965
1965
  let proc;
1966
1966
  if (process2.platform !== "win32") {
1967
1967
  if (launchWithNode) {
@@ -2801,7 +2801,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2801
2801
  * @return {Command}
2802
2802
  */
2803
2803
  nameFromFilename(filename) {
2804
- this._name = path29.basename(filename, path29.extname(filename));
2804
+ this._name = path30.basename(filename, path30.extname(filename));
2805
2805
  return this;
2806
2806
  }
2807
2807
  /**
@@ -2815,9 +2815,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2815
2815
  * @param {string} [path]
2816
2816
  * @return {(string|null|Command)}
2817
2817
  */
2818
- executableDir(path30) {
2819
- if (path30 === void 0) return this._executableDir;
2820
- this._executableDir = path30;
2818
+ executableDir(path31) {
2819
+ if (path31 === void 0) return this._executableDir;
2820
+ this._executableDir = path31;
2821
2821
  return this;
2822
2822
  }
2823
2823
  /**
@@ -3167,12 +3167,12 @@ function resolveNativeBinary(runtimeDir) {
3167
3167
  if (isBrowser2) {
3168
3168
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
3169
3169
  }
3170
- if (process.env.TWS_DISABLE_NATIVE === "1") {
3170
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
3171
3171
  return { path: null, source: "not-found", platform, tried: [] };
3172
3172
  }
3173
3173
  const envPath = process.env.TW_NATIVE_PATH?.trim();
3174
3174
  if (envPath) {
3175
- if (fs12.existsSync(envPath)) {
3175
+ if (fs11.existsSync(envPath)) {
3176
3176
  return { path: envPath, source: "env", platform, tried };
3177
3177
  }
3178
3178
  tried.push(`env:${envPath} (not found)`);
@@ -3181,7 +3181,7 @@ function resolveNativeBinary(runtimeDir) {
3181
3181
  for (const pkg of prebuiltPkgs) {
3182
3182
  try {
3183
3183
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
3184
- if (fs12.existsSync(candidate)) {
3184
+ if (fs11.existsSync(candidate)) {
3185
3185
  return { path: candidate, source: "prebuilt", platform, tried };
3186
3186
  }
3187
3187
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -3198,7 +3198,7 @@ function resolveNativeBinary(runtimeDir) {
3198
3198
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
3199
3199
  const candidate = path6.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
3200
3200
  tried.push(`self-bundled:${candidate}`);
3201
- if (fs12.existsSync(candidate)) {
3201
+ if (fs11.existsSync(candidate)) {
3202
3202
  return { path: candidate, source: "prebuilt", platform, tried };
3203
3203
  }
3204
3204
  }
@@ -3232,7 +3232,7 @@ function resolveNativeBinary(runtimeDir) {
3232
3232
  }
3233
3233
  for (const candidate of localCandidates) {
3234
3234
  tried.push(`local:${candidate}`);
3235
- if (fs12.existsSync(candidate)) {
3235
+ if (fs11.existsSync(candidate)) {
3236
3236
  return { path: candidate, source: "local", platform, tried };
3237
3237
  }
3238
3238
  }
@@ -3282,9 +3282,9 @@ function createDebugLogger(namespace, label) {
3282
3282
  }
3283
3283
  };
3284
3284
  }
3285
- function formatIssuePath(path29) {
3286
- if (!path29 || path29.length === 0) return "(root)";
3287
- return path29.map(
3285
+ function formatIssuePath(path30) {
3286
+ if (!path30 || path30.length === 0) return "(root)";
3287
+ return path30.map(
3288
3288
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3289
3289
  ).join(".");
3290
3290
  }
@@ -3297,7 +3297,7 @@ function loadNativeBinding(options) {
3297
3297
  for (const candidate of candidates) {
3298
3298
  const candidatePath = path6__default.resolve(runtimeDir, candidate);
3299
3299
  try {
3300
- if (!fs12__default.existsSync(candidatePath) && !fs12__default.existsSync(candidatePath + ".node")) {
3300
+ if (!fs11__default.existsSync(candidatePath) && !fs11__default.existsSync(candidatePath + ".node")) {
3301
3301
  continue;
3302
3302
  }
3303
3303
  const mod = requireNativeModule(candidatePath);
@@ -3329,9 +3329,9 @@ function resolveNativeBindingCandidates(options) {
3329
3329
  }
3330
3330
  }
3331
3331
  if (!includeDefaultCandidates) return candidates;
3332
- if (fs12__default.existsSync(runtimeDir)) {
3332
+ if (fs11__default.existsSync(runtimeDir)) {
3333
3333
  try {
3334
- for (const entry of fs12__default.readdirSync(runtimeDir)) {
3334
+ for (const entry of fs11__default.readdirSync(runtimeDir)) {
3335
3335
  if (entry.endsWith(".node")) candidates.push(entry);
3336
3336
  }
3337
3337
  } catch {
@@ -3398,8 +3398,8 @@ var init_src = __esm({
3398
3398
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3399
3399
  static fromZod(err) {
3400
3400
  const first = err.issues?.[0] ?? err.errors?.[0];
3401
- const path29 = formatIssuePath(first?.path);
3402
- const message = first ? `${path29}: ${first.message}` : "Schema validation failed";
3401
+ const path30 = formatIssuePath(first?.path);
3402
+ const message = first ? `${path30}: ${first.message}` : "Schema validation failed";
3403
3403
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3404
3404
  }
3405
3405
  static wrap(source, code, err) {
@@ -3749,7 +3749,7 @@ function defaultCachePath(rootDir, cacheDir) {
3749
3749
  }
3750
3750
  function readCache(rootDir, cacheDir) {
3751
3751
  const cachePath = defaultCachePath(rootDir, cacheDir);
3752
- fs12__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
3752
+ fs11__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
3753
3753
  const result = cacheReadNative(cachePath);
3754
3754
  if (!result) return [];
3755
3755
  return result.entries.map((e) => ({
@@ -3764,7 +3764,7 @@ function readCache(rootDir, cacheDir) {
3764
3764
  }
3765
3765
  function writeCache(rootDir, entries, cacheDir) {
3766
3766
  const cachePath = defaultCachePath(rootDir, cacheDir);
3767
- fs12__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
3767
+ fs11__default.mkdirSync(path6__default.dirname(cachePath), { recursive: true });
3768
3768
  const success = cacheWriteNative(cachePath, entries);
3769
3769
  if (!success) {
3770
3770
  throw new Error(
@@ -3791,27 +3791,7 @@ var init_cache_native = __esm({
3791
3791
  function collectFiles(rootDir, extensions, ignoreDirs) {
3792
3792
  const native = collectFilesNative(rootDir, extensions, ignoreDirs);
3793
3793
  if (native !== null) return native;
3794
- const files = [];
3795
- function walk(dir) {
3796
- let entries;
3797
- try {
3798
- entries = fs12__default.readdirSync(dir, { withFileTypes: true });
3799
- } catch {
3800
- return;
3801
- }
3802
- for (const entry of entries) {
3803
- const fullPath = path6__default.join(dir, entry.name);
3804
- const rel = path6__default.relative(rootDir, fullPath);
3805
- if (entry.isDirectory()) {
3806
- const ignored = ignoreDirs.some((d) => entry.name === d || rel.startsWith(d + path6__default.sep));
3807
- if (!ignored) walk(fullPath);
3808
- } else if (isScannableFile(entry.name, extensions)) {
3809
- files.push(fullPath);
3810
- }
3811
- }
3812
- }
3813
- walk(rootDir);
3814
- return files;
3794
+ throw new Error("FATAL: Native binding 'collectFiles' is required but not available.");
3815
3795
  }
3816
3796
  function mergeResults(batchResults) {
3817
3797
  const files = batchResults.map((r) => ({
@@ -3821,8 +3801,7 @@ function mergeResults(batchResults) {
3821
3801
  }));
3822
3802
  const native = rebuildWorkspaceResultNative(files);
3823
3803
  if (native) return native;
3824
- const unique = new Set(files.flatMap((f) => f.classes));
3825
- return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
3804
+ throw new Error("FATAL: Native binding 'rebuildWorkspaceResult' is required but not available.");
3826
3805
  }
3827
3806
  function runChunkInWorker(filePaths) {
3828
3807
  return new Promise((resolve2, reject) => {
@@ -3893,12 +3872,12 @@ var formatIssuePath2, formatIssues, parseWithSchema, NonNegativeIntegerSchema, S
3893
3872
  var init_schemas = __esm({
3894
3873
  "packages/domain/scanner/src/schemas.ts"() {
3895
3874
  init_src();
3896
- formatIssuePath2 = (path29) => path29.length > 0 ? path29.map(
3875
+ formatIssuePath2 = (path30) => path30.length > 0 ? path30.map(
3897
3876
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3898
3877
  ).join(".") : "<root>";
3899
3878
  formatIssues = (error) => error.issues.map((issue) => {
3900
- const path29 = formatIssuePath2(issue.path);
3901
- return `${path29}: ${issue.message}`;
3879
+ const path30 = formatIssuePath2(issue.path);
3880
+ return `${path30}: ${issue.message}`;
3902
3881
  }).join("; ");
3903
3882
  parseWithSchema = (schema, data, label) => {
3904
3883
  const parsed = schema.safeParse(data);
@@ -3961,7 +3940,7 @@ __export(src_exports, {
3961
3940
  DEFAULT_IGNORES: () => DEFAULT_IGNORES,
3962
3941
  batchExtractClassesNative: () => batchExtractClassesNative,
3963
3942
  extractClassesNative: () => extractClassesNative,
3964
- isScannableFile: () => isScannableFile,
3943
+ isScannableFile: () => isScannableFile2,
3965
3944
  parseScanWorkspaceOptions: () => parseScanWorkspaceOptions,
3966
3945
  parseScanWorkspaceResult: () => parseScanWorkspaceResult,
3967
3946
  parseScannerWorkerMessage: () => parseScannerWorkerMessage,
@@ -3995,7 +3974,7 @@ function resolveScannerWorkerModulePath() {
3995
3974
  path6__default.resolve(runtimeDir, "worker.ts")
3996
3975
  ];
3997
3976
  for (const candidate of candidates) {
3998
- if (fs12__default.existsSync(candidate)) return candidate;
3977
+ if (fs11__default.existsSync(candidate)) return candidate;
3999
3978
  }
4000
3979
  return null;
4001
3980
  }
@@ -4052,7 +4031,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
4052
4031
  if (!currentDir) continue;
4053
4032
  const entries = (() => {
4054
4033
  try {
4055
- return fs12__default.readdirSync(currentDir, { withFileTypes: true });
4034
+ return fs11__default.readdirSync(currentDir, { withFileTypes: true });
4056
4035
  } catch {
4057
4036
  return [];
4058
4037
  }
@@ -4090,7 +4069,7 @@ function scanSource(source) {
4090
4069
  "FATAL: Native parser binding is required but not available.\nThis package requires native Rust bindings.\n\nResolution steps:\n1. Build the native Rust module: npm run build:rust"
4091
4070
  );
4092
4071
  }
4093
- function isScannableFile(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
4072
+ function isScannableFile2(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
4094
4073
  return includeExtensions.includes(path6__default.extname(filePath));
4095
4074
  }
4096
4075
  function scanFile(filePath) {
@@ -4151,7 +4130,7 @@ function scanWorkspace(rootDir, options = {}) {
4151
4130
  for (const filePath of candidates) {
4152
4131
  const stat = (() => {
4153
4132
  try {
4154
- return fs12__default.statSync(filePath);
4133
+ return fs11__default.statSync(filePath);
4155
4134
  } catch {
4156
4135
  return null;
4157
4136
  }
@@ -4177,7 +4156,7 @@ function scanWorkspace(rootDir, options = {}) {
4177
4156
  for (const { filePath, stat, size, cached } of ranked) {
4178
4157
  const content = (() => {
4179
4158
  try {
4180
- return fs12__default.readFileSync(filePath, "utf8");
4159
+ return fs11__default.readFileSync(filePath, "utf8");
4181
4160
  } catch {
4182
4161
  return null;
4183
4162
  }
@@ -4321,7 +4300,7 @@ var init_src2 = __esm({
4321
4300
  )
4322
4301
  ];
4323
4302
  for (const fullPath of candidates) {
4324
- if (!fs12__default.existsSync(fullPath)) continue;
4303
+ if (!fs11__default.existsSync(fullPath)) continue;
4325
4304
  try {
4326
4305
  const required = req(fullPath);
4327
4306
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -4363,7 +4342,7 @@ function isRecord(value) {
4363
4342
  }
4364
4343
  async function pathExists(filePath) {
4365
4344
  try {
4366
- await fs12__default.promises.access(filePath, fs12__default.constants.F_OK);
4345
+ await fs11__default.promises.access(filePath, fs11__default.constants.F_OK);
4367
4346
  return true;
4368
4347
  } catch {
4369
4348
  return false;
@@ -4484,7 +4463,7 @@ var formatIssuePath3, isPlainObject, formatIssues2, parseWithSchema2, CountSchem
4484
4463
  var init_schemas2 = __esm({
4485
4464
  "packages/domain/analyzer/src/schemas.ts"() {
4486
4465
  init_src();
4487
- formatIssuePath3 = (path29) => path29.length > 0 ? path29.map(
4466
+ formatIssuePath3 = (path30) => path30.length > 0 ? path30.map(
4488
4467
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
4489
4468
  ).join(".") : "<root>";
4490
4469
  isPlainObject = (value) => {
@@ -4493,8 +4472,8 @@ var init_schemas2 = __esm({
4493
4472
  return proto === Object.prototype || proto === null;
4494
4473
  };
4495
4474
  formatIssues2 = (error) => error.issues.map((issue) => {
4496
- const path29 = formatIssuePath3(issue.path);
4497
- return `${path29}: ${issue.message}`;
4475
+ const path30 = formatIssuePath3(issue.path);
4476
+ return `${path30}: ${issue.message}`;
4498
4477
  }).join("; ");
4499
4478
  parseWithSchema2 = (schema, data, label) => {
4500
4479
  const parsed = schema.safeParse(data);
@@ -4590,7 +4569,7 @@ var init_schemas2 = __esm({
4590
4569
  parseClassToCssOptions = (options) => parseWithSchema2(ClassToCssOptionsSchema, options ?? {}, "classToCss options are invalid");
4591
4570
  }
4592
4571
  });
4593
- var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS, tailwindConfigCache, splitVariantAndBase, isArbitraryUtility, resolveConflictGroup, detectConflicts, isSupportedTailwindConfigPath, resolveTailwindConfigPath, collectSafelistFromConfig, collectCustomUtilities, collectSafelistFromSource, loadTailwindConfig, utilityPrefix, buildSemanticReport;
4572
+ var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS, tailwindConfigCache, splitVariantAndBase, resolveConflictGroup, detectConflicts, isSupportedTailwindConfigPath, resolveTailwindConfigPath, collectSafelistFromConfig, collectCustomUtilities, collectSafelistFromSource, loadTailwindConfig, utilityPrefix, buildSemanticReport;
4594
4573
  var init_semantic = __esm({
4595
4574
  "packages/domain/analyzer/src/semantic.ts"() {
4596
4575
  init_binding();
@@ -4603,27 +4582,13 @@ var init_semantic = __esm({
4603
4582
  const base = parts.pop() ?? className;
4604
4583
  return { variantKey: parts.join(":"), base };
4605
4584
  };
4606
- isArbitraryUtility = (baseClass) => {
4607
- return baseClass.includes("[") && baseClass.includes("]");
4608
- };
4609
- resolveConflictGroup = (base) => {
4610
- if (isArbitraryUtility(base)) return null;
4611
- if (["block", "inline", "inline-block", "inline-flex", "flex", "grid", "hidden"].includes(base))
4612
- return "display";
4613
- if (base.startsWith("bg-")) return "bg";
4614
- if (base.startsWith("text-")) return "text";
4615
- if (base.startsWith("font-")) return "font";
4616
- if (base.startsWith("rounded")) return "rounded";
4617
- if (base.startsWith("shadow")) return "shadow";
4618
- if (base.startsWith("border-")) return "border";
4619
- if (base.startsWith("opacity-")) return "opacity";
4620
- if (base.startsWith("w-") || base.startsWith("min-w-") || base.startsWith("max-w-"))
4621
- return "width";
4622
- if (base.startsWith("h-") || base.startsWith("min-h-") || base.startsWith("max-h-"))
4623
- return "height";
4624
- if (base.startsWith("p-") || base.startsWith("px-") || base.startsWith("py-")) return "padding";
4625
- if (base.startsWith("m-") || base.startsWith("mx-") || base.startsWith("my-")) return "margin";
4626
- return null;
4585
+ resolveConflictGroup = async (base) => {
4586
+ const native = await getNativeBinding();
4587
+ if (!native?.resolveConflictGroup) {
4588
+ throw new Error("Native binding 'resolveConflictGroup' is required but not available.");
4589
+ }
4590
+ const result = native.resolveConflictGroup(base);
4591
+ return result.length > 0 ? result : null;
4627
4592
  };
4628
4593
  detectConflicts = async (usages) => {
4629
4594
  const native = await getNativeBinding();
@@ -4711,7 +4676,7 @@ var init_semantic = __esm({
4711
4676
  return out;
4712
4677
  };
4713
4678
  collectSafelistFromSource = async (configPath) => {
4714
- const source = await fs12__default.promises.readFile(configPath, "utf8");
4679
+ const source = await fs11__default.promises.readFile(configPath, "utf8");
4715
4680
  const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports));
4716
4681
  const allTokens = extractClassesNative2(source);
4717
4682
  const hasSafelist = source.includes("safelist");
@@ -4738,7 +4703,7 @@ var init_semantic = __esm({
4738
4703
  customUtilities: /* @__PURE__ */ new Set()
4739
4704
  };
4740
4705
  }
4741
- const configStat = await fs12__default.promises.stat(configPath).catch(() => null);
4706
+ const configStat = await fs11__default.promises.stat(configPath).catch(() => null);
4742
4707
  if (configStat) {
4743
4708
  const cached = tailwindConfigCache.get(configPath);
4744
4709
  if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
@@ -5034,12 +4999,12 @@ var init_classToCss = __esm({
5034
4999
  init_binding();
5035
5000
  init_schemas2();
5036
5001
  init_utils();
5037
- normalizeClassInput = (input, _binding) => {
5002
+ normalizeClassInput = (input, binding) => {
5038
5003
  if (typeof input === "string") {
5039
- if (_binding?.normalizeClassInput) {
5040
- return _binding.normalizeClassInput(input);
5004
+ if (!binding.normalizeClassInput) {
5005
+ throw new Error("FATAL: Native binding 'normalizeClassInput' is required but not available.");
5041
5006
  }
5042
- return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
5007
+ return binding.normalizeClassInput(input);
5043
5008
  }
5044
5009
  if (!Array.isArray(input)) {
5045
5010
  throw new TypeError("classToCss input must be a string or an array of strings.");
@@ -5071,11 +5036,11 @@ var init_classToCss = __esm({
5071
5036
  }
5072
5037
  };
5073
5038
  declarationMapToString = (declarationMap, binding) => {
5074
- const entries = Array.from(declarationMap.entries()).map(([property, value]) => ({ property, value }));
5075
- if (binding?.declarationMapToString) {
5076
- return binding.declarationMapToString(entries);
5039
+ if (!binding.declarationMapToString) {
5040
+ throw new Error("FATAL: Native binding 'declarationMapToString' is required but not available.");
5077
5041
  }
5078
- return entries.map(({ property, value }) => `${property}: ${value}`).join("; ");
5042
+ const entries = Array.from(declarationMap.entries()).map(([property, value]) => ({ property, value }));
5043
+ return binding.declarationMapToString(entries);
5079
5044
  };
5080
5045
  classToCss = async (input, options = {}) => {
5081
5046
  const binding = await requireNativeCssCompiler();
@@ -5171,7 +5136,7 @@ var init_src3 = __esm({
5171
5136
  });
5172
5137
  async function pathExists2(filePath) {
5173
5138
  try {
5174
- await fs8.access(filePath);
5139
+ await fs7.access(filePath);
5175
5140
  return true;
5176
5141
  } catch {
5177
5142
  return false;
@@ -5179,7 +5144,7 @@ async function pathExists2(filePath) {
5179
5144
  }
5180
5145
  async function readFileSafe(filePath) {
5181
5146
  try {
5182
- return await fs8.readFile(filePath, "utf8");
5147
+ return await fs7.readFile(filePath, "utf8");
5183
5148
  } catch {
5184
5149
  return null;
5185
5150
  }
@@ -5198,8 +5163,8 @@ async function writeFileSafe(filePath, content, options = {}) {
5198
5163
  options.onDryRun?.(`write ${filePath}`);
5199
5164
  return;
5200
5165
  }
5201
- await fs8.mkdir(path6__default.dirname(filePath), { recursive: true });
5202
- await fs8.writeFile(filePath, content, "utf8");
5166
+ await fs7.mkdir(path6__default.dirname(filePath), { recursive: true });
5167
+ await fs7.writeFile(filePath, content, "utf8");
5203
5168
  }
5204
5169
  async function ensureFileSafe(filePath, content, options = {}) {
5205
5170
  if (await pathExists2(filePath)) return "skipped";
@@ -6072,7 +6037,7 @@ var _loadNative, log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttem
6072
6037
  var init_nativeBridge = __esm({
6073
6038
  "packages/domain/compiler/src/nativeBridge.ts"() {
6074
6039
  init_src();
6075
- _loadNative = (path29) => __require(path29);
6040
+ _loadNative = (path30) => __require(path30);
6076
6041
  log3 = (...args) => {
6077
6042
  if (process.env.DEBUG?.includes("compiler:native")) {
6078
6043
  console.log("[compiler:native]", ...args);
@@ -6130,6 +6095,78 @@ Tried paths: ${result.tried.join("\n")}`);
6130
6095
  }
6131
6096
  });
6132
6097
 
6098
+ // packages/domain/compiler/src/compiler/index.ts
6099
+ var init_compiler = __esm({
6100
+ "packages/domain/compiler/src/compiler/index.ts"() {
6101
+ }
6102
+ });
6103
+
6104
+ // packages/domain/compiler/src/parser/index.ts
6105
+ var init_parser = __esm({
6106
+ "packages/domain/compiler/src/parser/index.ts"() {
6107
+ }
6108
+ });
6109
+
6110
+ // packages/domain/compiler/src/analyzer/index.ts
6111
+ var init_analyzer = __esm({
6112
+ "packages/domain/compiler/src/analyzer/index.ts"() {
6113
+ }
6114
+ });
6115
+
6116
+ // packages/domain/compiler/src/cache/index.ts
6117
+ var init_cache = __esm({
6118
+ "packages/domain/compiler/src/cache/index.ts"() {
6119
+ }
6120
+ });
6121
+
6122
+ // packages/domain/compiler/src/redis/index.ts
6123
+ var init_redis = __esm({
6124
+ "packages/domain/compiler/src/redis/index.ts"() {
6125
+ }
6126
+ });
6127
+
6128
+ // packages/domain/compiler/src/watch/index.ts
6129
+ var init_watch = __esm({
6130
+ "packages/domain/compiler/src/watch/index.ts"() {
6131
+ }
6132
+ });
6133
+ var compileCssFromClasses;
6134
+ var init_src4 = __esm({
6135
+ "packages/domain/compiler/src/index.ts"() {
6136
+ init_nativeBridge();
6137
+ init_compiler();
6138
+ init_parser();
6139
+ init_analyzer();
6140
+ init_cache();
6141
+ init_redis();
6142
+ init_watch();
6143
+ compileCssFromClasses = (classes, prefix) => {
6144
+ const native = getNativeBridge();
6145
+ if (!native?.transformSource) {
6146
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
6147
+ }
6148
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
6149
+ if (!result) {
6150
+ throw new Error("FATAL: transformSource returned null");
6151
+ }
6152
+ return result;
6153
+ };
6154
+ }
6155
+ });
6156
+
6157
+ // packages/domain/compiler/src/internal.ts
6158
+ var init_internal = __esm({
6159
+ "packages/domain/compiler/src/internal.ts"() {
6160
+ init_src4();
6161
+ init_compiler();
6162
+ init_parser();
6163
+ init_analyzer();
6164
+ init_cache();
6165
+ init_redis();
6166
+ init_watch();
6167
+ }
6168
+ });
6169
+
6133
6170
  // packages/infrastructure/cli/src/commands/program.ts
6134
6171
  init_esm();
6135
6172
 
@@ -6427,7 +6464,7 @@ async function findSourceFiles(dir) {
6427
6464
  const out = [];
6428
6465
  async function walk(currentDir) {
6429
6466
  if (!await pathExists2(currentDir)) return;
6430
- const entries = await fs8.readdir(currentDir, { withFileTypes: true });
6467
+ const entries = await fs7.readdir(currentDir, { withFileTypes: true });
6431
6468
  for (const entry of entries) {
6432
6469
  const fullPath = path6__default.join(currentDir, entry.name);
6433
6470
  if (entry.isDirectory()) {
@@ -6493,12 +6530,12 @@ async function runMigrateCli(rawArgs) {
6493
6530
  report.configWrites += await migrateConfig(root, dryRun);
6494
6531
  }
6495
6532
  for (const filePath of files) {
6496
- const source = await fs8.readFile(filePath, "utf8");
6533
+ const source = await fs7.readFile(filePath, "utf8");
6497
6534
  const migrated = migrateSource(source, { includeImports, includeClasses });
6498
6535
  if (migrated.output !== source) {
6499
6536
  report.updatedFiles++;
6500
6537
  if (!dryRun) {
6501
- await fs8.writeFile(filePath, migrated.output, "utf8");
6538
+ await fs7.writeFile(filePath, migrated.output, "utf8");
6502
6539
  }
6503
6540
  }
6504
6541
  report.classRenames += migrated.classRenames;
@@ -6564,8 +6601,8 @@ function buildClassNames(files, uniqueClasses) {
6564
6601
  function writeScanCache(root, cacheData) {
6565
6602
  const cacheDir = path6__default.join(root, ".tailwind-styled");
6566
6603
  const cachePath = path6__default.join(cacheDir, "scan-cache.json");
6567
- fs12__default.mkdirSync(cacheDir, { recursive: true });
6568
- fs12__default.writeFileSync(cachePath, JSON.stringify(cacheData, null, 2), "utf-8");
6604
+ fs11__default.mkdirSync(cacheDir, { recursive: true });
6605
+ fs11__default.writeFileSync(cachePath, JSON.stringify(cacheData, null, 2), "utf-8");
6569
6606
  return cachePath;
6570
6607
  }
6571
6608
  async function runScanCli(rawArgs) {
@@ -6739,26 +6776,62 @@ function computeSafelistSourcePath(cssFilePath, cwd2) {
6739
6776
  return `${ups}/.next/tw-classes/**`;
6740
6777
  }
6741
6778
  }
6779
+ function computeStateStaticImportPath(cssFilePath, cwd2) {
6780
+ try {
6781
+ const nodePath = __require("path");
6782
+ const cssAbs = nodePath.resolve(cwd2, cssFilePath);
6783
+ const cssDir = nodePath.dirname(cssAbs);
6784
+ const stateStaticAbs = nodePath.resolve(cwd2, ".next", "_tw-state-static.css");
6785
+ const rel = nodePath.relative(cssDir, stateStaticAbs).replace(/\\/g, "/");
6786
+ return rel.startsWith(".") ? rel : `./${rel}`;
6787
+ } catch {
6788
+ const depth = cssFilePath.split("/").length - 1;
6789
+ const ups = Array(depth).fill("..").join("/");
6790
+ return `${ups}/.next/_tw-state-static.css`;
6791
+ }
6792
+ }
6742
6793
  function patchTailwindCssImpl(src, bundler, cssFilePath, cwd2) {
6743
6794
  const hasTailwindImport = src.includes('@import "tailwindcss"') || src.includes("@import 'tailwindcss'");
6744
- const hasSafelistSource2 = src.includes("tailwind-styled-safelist.css");
6795
+ const hasSafelistSource2 = src.includes("tw-classes");
6796
+ const hasStateImport = src.includes("_tw-state-static.css");
6745
6797
  const needsSafelistSource = bundler === "next" && !hasSafelistSource2;
6746
- const safelistRelPath = needsSafelistSource && cssFilePath && cwd2 ? computeSafelistSourcePath(cssFilePath, cwd2) : "../.next/tailwind-styled-safelist.css";
6798
+ const needsStateImport = bundler === "next" && !hasStateImport;
6799
+ const safelistRelPath = needsSafelistSource && cssFilePath && cwd2 ? computeSafelistSourcePath(cssFilePath, cwd2) : "../.next/tw-classes/**";
6800
+ const stateImportRelPath = needsStateImport && cssFilePath && cwd2 ? computeStateStaticImportPath(cssFilePath, cwd2) : "../.next/_tw-state-static.css";
6747
6801
  const safelistSource = `@source "${safelistRelPath}";`;
6802
+ const stateImport = `@import "${stateImportRelPath}";`;
6748
6803
  if (hasTailwindImport) {
6749
- if (!needsSafelistSource) return null;
6750
- const patched = src.replace(
6751
- /(@import\s+['"]tailwindcss['"];?)/,
6752
- `$1
6804
+ if (!needsSafelistSource && !needsStateImport) return null;
6805
+ let patched = src;
6806
+ if (needsSafelistSource) {
6807
+ patched = patched.replace(
6808
+ /(@import\s+['"]tailwindcss['"];?)/,
6809
+ `$1
6753
6810
  ${safelistSource}`
6754
- );
6811
+ );
6812
+ }
6813
+ if (needsStateImport) {
6814
+ if (patched.includes("tw-classes")) {
6815
+ patched = patched.replace(
6816
+ /(@source\s+["'][^"']+["'];?)/,
6817
+ `$1
6818
+ ${stateImport}`
6819
+ );
6820
+ } else {
6821
+ patched = patched.replace(
6822
+ /(@import\s+['"]tailwindcss['"];?)/,
6823
+ `$1
6824
+ ${stateImport}`
6825
+ );
6826
+ }
6827
+ }
6755
6828
  return patched === src ? null : patched;
6756
6829
  }
6757
- const base = `@import "tailwindcss";
6758
- ${needsSafelistSource ? `${safelistSource}
6759
- ` : ""}
6760
- ${src}`;
6761
- return base;
6830
+ const lines = [`@import "tailwindcss";`];
6831
+ if (needsSafelistSource) lines.push(safelistSource);
6832
+ if (needsStateImport) lines.push(stateImport);
6833
+ lines.push("", src);
6834
+ return lines.join("\n");
6762
6835
  }
6763
6836
  function patchTsConfigImpl(src) {
6764
6837
  try {
@@ -7560,7 +7633,7 @@ async function loadRegistry(context) {
7560
7633
  if (!registryPath) {
7561
7634
  throw new CliUsageError("Plugin registry file not found.");
7562
7635
  }
7563
- const raw = await fs8.readFile(registryPath, "utf8");
7636
+ const raw = await fs7.readFile(registryPath, "utf8");
7564
7637
  const data = JSON.parse(raw);
7565
7638
  return [
7566
7639
  ...data.official.map((item) => ({ ...item, official: true })),
@@ -7695,8 +7768,8 @@ var deployCommand = {
7695
7768
  return;
7696
7769
  }
7697
7770
  const cacheDir = path6__default.join(process.cwd(), ".tw-cache");
7698
- await fs8.mkdir(cacheDir, { recursive: true });
7699
- await fs8.writeFile(
7771
+ await fs7.mkdir(cacheDir, { recursive: true });
7772
+ await fs7.writeFile(
7700
7773
  path6__default.join(cacheDir, "deploy-manifest.json"),
7701
7774
  JSON.stringify(manifest, null, 2)
7702
7775
  );
@@ -7797,22 +7870,27 @@ function addIssue(issues, severity, type, message, suggestion, location) {
7797
7870
  issues.push({ severity, type, message, suggestion, location });
7798
7871
  }
7799
7872
  function readJsonFile(filePath) {
7800
- if (!fs12__default.existsSync(filePath)) return null;
7873
+ if (!fs11__default.existsSync(filePath)) return null;
7801
7874
  try {
7802
- return JSON.parse(fs12__default.readFileSync(filePath, "utf8"));
7803
- } catch {
7875
+ return JSON.parse(fs11__default.readFileSync(filePath, "utf8"));
7876
+ } catch (parseErr) {
7877
+ if (process.env.TWS_DEBUG === "1") {
7878
+ const msg = parseErr instanceof Error ? parseErr.message : String(parseErr);
7879
+ process.stderr.write(`[tw:doctor] malformed JSON: ${filePath} \u2014 ${msg}
7880
+ `);
7881
+ }
7804
7882
  return null;
7805
7883
  }
7806
7884
  }
7807
7885
  function findWorkspacePackageJsonFiles(root) {
7808
7886
  const packagesDir = path6__default.join(root, "packages");
7809
- if (!fs12__default.existsSync(packagesDir)) return [];
7810
- return fs12__default.readdirSync(packagesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path6__default.join(packagesDir, entry.name, "package.json")).filter((filePath) => fs12__default.existsSync(filePath));
7887
+ if (!fs11__default.existsSync(packagesDir)) return [];
7888
+ return fs11__default.readdirSync(packagesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path6__default.join(packagesDir, entry.name, "package.json")).filter((filePath) => fs11__default.existsSync(filePath));
7811
7889
  }
7812
7890
  function findFiles(dir, ext) {
7813
7891
  const files = [];
7814
7892
  try {
7815
- const entries = fs12__default.readdirSync(dir, { withFileTypes: true });
7893
+ const entries = fs11__default.readdirSync(dir, { withFileTypes: true });
7816
7894
  for (const entry of entries) {
7817
7895
  const fullPath = path6__default.join(dir, entry.name);
7818
7896
  if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
@@ -7821,7 +7899,12 @@ function findFiles(dir, ext) {
7821
7899
  files.push(fullPath);
7822
7900
  }
7823
7901
  }
7824
- } catch {
7902
+ } catch (dirErr) {
7903
+ if (process.env.TWS_DEBUG === "1") {
7904
+ const msg = dirErr instanceof Error ? dirErr.message : String(dirErr);
7905
+ process.stderr.write(`[tw:doctor] findFiles error in ${dir}: ${msg}
7906
+ `);
7907
+ }
7825
7908
  return files;
7826
7909
  }
7827
7910
  return files;
@@ -7974,7 +8057,7 @@ function runTailwindProjectDiagnostics(root, issues, checks) {
7974
8057
  const cssFiles = findFiles(root, ".css");
7975
8058
  const hasTailwindImport = cssFiles.slice(0, 10).some((filePath) => {
7976
8059
  try {
7977
- const content = fs12__default.readFileSync(filePath, "utf8");
8060
+ const content = fs11__default.readFileSync(filePath, "utf8");
7978
8061
  return content.includes("@tailwind") || content.includes('@import "tailwindcss"');
7979
8062
  } catch {
7980
8063
  return false;
@@ -7998,7 +8081,7 @@ function runTailwindProjectDiagnostics(root, issues, checks) {
7998
8081
  );
7999
8082
  }
8000
8083
  const configFiles = ["tailwind.config.js", "tailwind.config.ts", "tailwind.config.mjs"];
8001
- const hasConfig = configFiles.some((name) => fs12__default.existsSync(path6__default.join(root, name)));
8084
+ const hasConfig = configFiles.some((name) => fs11__default.existsSync(path6__default.join(root, name)));
8002
8085
  addCheck(
8003
8086
  checks,
8004
8087
  "tailwind",
@@ -8658,6 +8741,7 @@ init_args();
8658
8741
  init_errors();
8659
8742
  init_fs();
8660
8743
  init_json();
8744
+ init_src4();
8661
8745
  var DEFAULT_TAILWIND_CSS2 = '@import "tailwindcss";\n';
8662
8746
  var DEFAULT_TW_CONFIG = `${JSON.stringify(
8663
8747
  {
@@ -8672,6 +8756,89 @@ var DEFAULT_TW_CONFIG = `${JSON.stringify(
8672
8756
  function pkgHasDep(pkg, name) {
8673
8757
  return Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name]);
8674
8758
  }
8759
+ async function validateThemeConfig(cwd2) {
8760
+ const results = [];
8761
+ try {
8762
+ const native = getNativeBridge();
8763
+ if (!native) {
8764
+ results.push({ type: "theme", valid: false, message: "Native binding not available" });
8765
+ return results;
8766
+ }
8767
+ const twConfigFiles = ["tailwind.config.ts", "tailwind.config.js", "tailwind.config.mjs"];
8768
+ let configPath = null;
8769
+ for (const file of twConfigFiles) {
8770
+ if (await pathExists2(path6__default.join(cwd2, file))) {
8771
+ configPath = path6__default.join(cwd2, file);
8772
+ break;
8773
+ }
8774
+ }
8775
+ if (!configPath) {
8776
+ results.push({ type: "theme-config-missing", valid: false, message: "No tailwind.config found" });
8777
+ return results;
8778
+ }
8779
+ try {
8780
+ const configUrl = pathToFileURL(configPath);
8781
+ const configModule = await import(configUrl.href);
8782
+ const config = configModule.default || configModule;
8783
+ const theme = config.theme || {};
8784
+ if (theme.colors && native.validateColorsNapi) {
8785
+ try {
8786
+ const colorsJson = JSON.stringify(theme.colors);
8787
+ const isValid = native.validateColorsNapi(colorsJson);
8788
+ results.push({
8789
+ type: "theme-colors",
8790
+ valid: isValid,
8791
+ message: isValid ? "Colors theme validated OK" : "Invalid colors in theme"
8792
+ });
8793
+ } catch (err) {
8794
+ results.push({
8795
+ type: "theme-colors",
8796
+ valid: false,
8797
+ message: `Color validation error: ${err instanceof Error ? err.message : String(err)}`
8798
+ });
8799
+ }
8800
+ }
8801
+ if (theme.screens && native.validateBreakpointsNapi) {
8802
+ try {
8803
+ const screensJson = JSON.stringify(theme.screens);
8804
+ const isValid = native.validateBreakpointsNapi(screensJson);
8805
+ results.push({
8806
+ type: "theme-breakpoints",
8807
+ valid: isValid,
8808
+ message: isValid ? "Breakpoints validated OK" : "Invalid breakpoints in theme"
8809
+ });
8810
+ } catch (err) {
8811
+ results.push({
8812
+ type: "theme-breakpoints",
8813
+ valid: false,
8814
+ message: `Breakpoints validation error: ${err instanceof Error ? err.message : String(err)}`
8815
+ });
8816
+ }
8817
+ }
8818
+ if (native.runHealthCheck) {
8819
+ try {
8820
+ native.runHealthCheck();
8821
+ results.push({ type: "theme-integrity", valid: true, message: "Theme integrity check passed" });
8822
+ } catch {
8823
+ results.push({ type: "theme-integrity", valid: false, message: "Theme integrity check failed" });
8824
+ }
8825
+ }
8826
+ } catch (err) {
8827
+ results.push({
8828
+ type: "theme-load",
8829
+ valid: false,
8830
+ message: `Failed to load theme config: ${err instanceof Error ? err.message : String(err)}`
8831
+ });
8832
+ }
8833
+ } catch (err) {
8834
+ results.push({
8835
+ type: "theme-validation",
8836
+ valid: false,
8837
+ message: `Theme validation failed: ${err instanceof Error ? err.message : String(err)}`
8838
+ });
8839
+ }
8840
+ return results;
8841
+ }
8675
8842
  function nodeVersion() {
8676
8843
  const full = process.version.replace("v", "");
8677
8844
  const major = parseInt(full.split(".")[0], 10);
@@ -8796,6 +8963,16 @@ async function runPreflightCli(rawArgs) {
8796
8963
  "Run: tw migrate --dry-run to see migration steps"
8797
8964
  );
8798
8965
  }
8966
+ const themeValidation = await validateThemeConfig(cwd2);
8967
+ for (const validation of themeValidation) {
8968
+ check(
8969
+ results,
8970
+ `theme-${validation.type}`,
8971
+ `Theme ${validation.type}`,
8972
+ validation.valid,
8973
+ validation.message
8974
+ );
8975
+ }
8799
8976
  const hasTsConfig = await pathExists2(path6__default.join(cwd2, "tsconfig.json"));
8800
8977
  check(
8801
8978
  results,
@@ -9283,19 +9460,8 @@ var syncCommand = {
9283
9460
  var import_picocolors5 = __toESM(require_picocolors());
9284
9461
  init_errors();
9285
9462
 
9286
- // packages/domain/compiler/src/index.ts
9287
- init_nativeBridge();
9288
- var compileCssFromClasses = (classes, prefix) => {
9289
- const native = getNativeBridge();
9290
- if (!native?.transformSource) {
9291
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
9292
- }
9293
- const result = native.transformSource(classes.join(" "), { prefix: prefix });
9294
- if (!result) {
9295
- throw new Error("FATAL: transformSource returned null");
9296
- }
9297
- return result;
9298
- };
9463
+ // packages/infrastructure/cli/src/utils/traceService.ts
9464
+ init_internal();
9299
9465
 
9300
9466
  // packages/domain/engine/src/native-bridge.ts
9301
9467
  init_src();
@@ -9746,37 +9912,33 @@ var CascadeResolutionId = class {
9746
9912
  return `R${this.value}`;
9747
9913
  }
9748
9914
  };
9749
- var _propertyNamesFallback = /* @__PURE__ */ new Map();
9750
- var _valueNamesFallback = /* @__PURE__ */ new Map();
9751
9915
  function registerPropertyName(id, name) {
9752
9916
  const native = getNativeEngineBinding();
9753
- if (native?.registerPropertyName) {
9754
- native.registerPropertyName(id.value, name);
9755
- return;
9917
+ if (!native?.registerPropertyName) {
9918
+ throw new Error("FATAL: Native binding 'registerPropertyName' is required but not available.");
9756
9919
  }
9757
- _propertyNamesFallback.set(id.value, name);
9920
+ native.registerPropertyName(id.value, name);
9758
9921
  }
9759
9922
  function registerValueName(id, name) {
9760
9923
  const native = getNativeEngineBinding();
9761
- if (native?.registerValueName) {
9762
- native.registerValueName(id.value, name);
9763
- return;
9924
+ if (!native?.registerValueName) {
9925
+ throw new Error("FATAL: Native binding 'registerValueName' is required but not available.");
9764
9926
  }
9765
- _valueNamesFallback.set(id.value, name);
9927
+ native.registerValueName(id.value, name);
9766
9928
  }
9767
9929
  function propertyIdToString(id) {
9768
9930
  const native = getNativeEngineBinding();
9769
- if (native?.propertyIdToString) {
9770
- return native.propertyIdToString(id.value);
9931
+ if (!native?.propertyIdToString) {
9932
+ throw new Error("FATAL: Native binding 'propertyIdToString' is required but not available.");
9771
9933
  }
9772
- return _propertyNamesFallback.get(id.value) ?? `P${id.value}`;
9934
+ return native.propertyIdToString(id.value);
9773
9935
  }
9774
9936
  function valueIdToString(id) {
9775
9937
  const native = getNativeEngineBinding();
9776
- if (native?.valueIdToString) {
9777
- return native.valueIdToString(id.value);
9938
+ if (!native?.valueIdToString) {
9939
+ throw new Error("FATAL: Native binding 'valueIdToString' is required but not available.");
9778
9940
  }
9779
- return _valueNamesFallback.get(id.value) ?? `V${id.value}`;
9941
+ return native.valueIdToString(id.value);
9780
9942
  }
9781
9943
  var CascadeStage = /* @__PURE__ */ ((CascadeStage2) => {
9782
9944
  CascadeStage2[CascadeStage2["Origin"] = 0] = "Origin";
@@ -9786,19 +9948,12 @@ var CascadeStage = /* @__PURE__ */ ((CascadeStage2) => {
9786
9948
  CascadeStage2[CascadeStage2["Order"] = 4] = "Order";
9787
9949
  return CascadeStage2;
9788
9950
  })(CascadeStage || {});
9789
- function createFingerprintFallback(parts) {
9790
- const hash = parts.reduce(
9791
- (acc, part) => part.split("").reduce((h, char) => (h << 5) - h + char.charCodeAt(0) & h, acc),
9792
- 0
9793
- );
9794
- return Math.abs(hash).toString(36);
9795
- }
9796
9951
  function createFingerprint(parts) {
9797
9952
  const native = getNativeEngineBinding();
9798
- if (native?.createFingerprint) {
9799
- return native.createFingerprint(parts);
9953
+ if (!native?.createFingerprint) {
9954
+ throw new Error("FATAL: Native binding 'createFingerprint' is required but not available.");
9800
9955
  }
9801
- return createFingerprintFallback(parts);
9956
+ return native.createFingerprint(parts);
9802
9957
  }
9803
9958
 
9804
9959
  // packages/domain/engine/src/reverseLookup.ts
@@ -10060,14 +10215,68 @@ function detectLayerFromClassName(className) {
10060
10215
  return null;
10061
10216
  }
10062
10217
  function parseCssToIr(css, options = {}) {
10063
- resetIdGenerator();
10218
+ const native = getNativeEngineBinding();
10219
+ const prefix = options.prefix ?? "";
10220
+ if (native?.assembleCssIr) {
10221
+ return _parseCssToIrFast(native.assembleCssIr(css, prefix || null));
10222
+ }
10223
+ return _parseCssToIrFallback(css, prefix, native);
10224
+ }
10225
+ function _parseCssToIrFast(assembled) {
10226
+ const native = getNativeEngineBinding();
10064
10227
  layerMap.clear();
10065
10228
  layerOrderMap.clear();
10066
- const native = getNativeEngineBinding();
10229
+ for (const le of assembled.layers) {
10230
+ const lid = new LayerId(le.layerId);
10231
+ layerMap.set(le.name, lid);
10232
+ layerOrderMap.set(le.name, le.order);
10233
+ }
10234
+ const rules = assembled.rules.map((r) => {
10235
+ const propertyId = new PropertyId(r.propertyId);
10236
+ const valueId = new ValueId(r.valueId);
10237
+ if (native?.registerPropertyName) {
10238
+ native.registerPropertyName(r.propertyId, r.propertyName);
10239
+ } else {
10240
+ registerPropertyName(propertyId, r.propertyName);
10241
+ }
10242
+ if (native?.registerValueName) {
10243
+ native.registerValueName(r.valueId, r.valueName);
10244
+ } else {
10245
+ registerValueName(valueId, r.valueName);
10246
+ }
10247
+ return {
10248
+ id: new RuleId(r.ruleId),
10249
+ selector: new SelectorId(r.selectorId),
10250
+ variantChain: new VariantChainId(0),
10251
+ property: propertyId,
10252
+ value: valueId,
10253
+ origin: r.origin,
10254
+ importance: r.importance,
10255
+ layer: r.layerId >= 0 ? new LayerId(r.layerId) : null,
10256
+ layerOrder: r.layerOrder,
10257
+ specificity: r.specificity,
10258
+ condition: r.conditionId >= 0 ? new ConditionId(r.conditionId) : null,
10259
+ conditionResult: r.conditionResult,
10260
+ insertionOrder: r.insertionOrder,
10261
+ fingerprint: r.fingerprint,
10262
+ source: { file: "", line: 1, column: 1 }
10263
+ };
10264
+ });
10265
+ const classToRuleIds = new Map(
10266
+ assembled.classToRuleIds.map((m) => [
10267
+ m.className,
10268
+ m.ruleIds.map((id) => new RuleId(id))
10269
+ ])
10270
+ );
10271
+ return { rules, classToRuleIds };
10272
+ }
10273
+ function _parseCssToIrFallback(css, prefix, native) {
10067
10274
  if (!native?.parseCssRules) {
10068
10275
  throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
10069
10276
  }
10070
- const prefix = options.prefix ?? "";
10277
+ resetIdGenerator();
10278
+ layerMap.clear();
10279
+ layerOrderMap.clear();
10071
10280
  const rules = [];
10072
10281
  const classToRuleIds = /* @__PURE__ */ new Map();
10073
10282
  const parsed = native.parseCssRules(css);
@@ -10082,7 +10291,7 @@ function parseCssToIr(css, options = {}) {
10082
10291
  const valueId = generateValueId(r.value);
10083
10292
  const hasMedia = r.variants.some((v) => v.startsWith("@") || v === "dark" || v === "print");
10084
10293
  const conditionId = hasMedia ? generateConditionId() : null;
10085
- const conditionResult = hasMedia ? 2 /* Unknown */ : 2 /* Unknown */;
10294
+ const conditionResult = 2 /* Unknown */;
10086
10295
  const ruleId = generateRuleId();
10087
10296
  const fingerprint = createFingerprint([className, r.property, r.value]);
10088
10297
  const rule = {
@@ -10096,7 +10305,6 @@ function parseCssToIr(css, options = {}) {
10096
10305
  layer,
10097
10306
  layerOrder,
10098
10307
  specificity: r.specificity,
10099
- // from native — no JS recalculation
10100
10308
  condition: conditionId,
10101
10309
  conditionResult,
10102
10310
  insertionOrder: getNextInsertionOrder(),
@@ -10322,6 +10530,9 @@ async function traceClass(className, options) {
10322
10530
  };
10323
10531
  return result;
10324
10532
  }
10533
+
10534
+ // packages/infrastructure/cli/src/utils/traceTargetService.ts
10535
+ init_internal();
10325
10536
  init_src2();
10326
10537
  function toRelativePath(root, value) {
10327
10538
  const relative = path6__default.relative(root, value);
@@ -10393,7 +10604,7 @@ function tryCompileClasses(classes) {
10393
10604
  }
10394
10605
  }
10395
10606
  function traceSingleFile(filePath, root) {
10396
- const source = fs12__default.readFileSync(filePath, "utf8");
10607
+ const source = fs11__default.readFileSync(filePath, "utf8");
10397
10608
  const classes = uniqueSorted(scanSource(source));
10398
10609
  const imports = extractImports(source);
10399
10610
  const compiled = tryCompileClasses(classes);
@@ -10423,8 +10634,8 @@ function traceDirectory(targetDir, root) {
10423
10634
  });
10424
10635
  const imports = [];
10425
10636
  const importKeys = /* @__PURE__ */ new Set();
10426
- const files = scanResult.files.filter((entry) => isScannableFile(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
10427
- const source = fs12__default.readFileSync(entry.file, "utf8");
10637
+ const files = scanResult.files.filter((entry) => isScannableFile2(entry.file, DEFAULT_EXTENSIONS)).map((entry) => {
10638
+ const source = fs11__default.readFileSync(entry.file, "utf8");
10428
10639
  const fileImports = extractImports(source);
10429
10640
  for (const fileImport of fileImports) {
10430
10641
  const key = `${fileImport.kind}:${fileImport.source}`;
@@ -10457,10 +10668,10 @@ function traceDirectory(targetDir, root) {
10457
10668
  async function traceTarget(target, options = {}) {
10458
10669
  const root = path6__default.resolve(options.root ?? process.cwd());
10459
10670
  const resolvedTarget = path6__default.resolve(root, target);
10460
- if (!fs12__default.existsSync(resolvedTarget)) {
10671
+ if (!fs11__default.existsSync(resolvedTarget)) {
10461
10672
  throw new Error(`Trace target not found: ${resolvedTarget}`);
10462
10673
  }
10463
- const stat = fs12__default.statSync(resolvedTarget);
10674
+ const stat = fs11__default.statSync(resolvedTarget);
10464
10675
  if (stat.isDirectory()) {
10465
10676
  return traceDirectory(resolvedTarget, root);
10466
10677
  }
@@ -10666,10 +10877,10 @@ async function runGenerateTypesCli(rawArgs) {
10666
10877
  output.writeText("");
10667
10878
  output.writeText(import_picocolors6.default.bold(" [2/2]") + import_picocolors6.default.cyan(" generate .d.ts"));
10668
10879
  const outDir = path6__default.dirname(outPath);
10669
- if (!fs12__default.existsSync(outDir)) {
10670
- fs12__default.mkdirSync(outDir, { recursive: true });
10880
+ if (!fs11__default.existsSync(outDir)) {
10881
+ fs11__default.mkdirSync(outDir, { recursive: true });
10671
10882
  }
10672
- fs12__default.writeFileSync(outPath, result.dtsContent, "utf-8");
10883
+ fs11__default.writeFileSync(outPath, result.dtsContent, "utf-8");
10673
10884
  logger.ok(path6__default.relative(cwd2, outPath));
10674
10885
  output.writeText("");
10675
10886
  output.writeText(import_picocolors6.default.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
@@ -10685,7 +10896,7 @@ async function loadNativeBinding2(cwd2) {
10685
10896
  path6__default.join(cwd2, "node_modules", "tailwind-styled-v4", "native", "tailwind-styled-native.node")
10686
10897
  ];
10687
10898
  for (const candidate of candidates) {
10688
- if (fs12__default.existsSync(candidate)) {
10899
+ if (fs11__default.existsSync(candidate)) {
10689
10900
  try {
10690
10901
  return __require(candidate);
10691
10902
  } catch {
@@ -10697,6 +10908,9 @@ async function loadNativeBinding2(cwd2) {
10697
10908
 
10698
10909
  // packages/infrastructure/cli/src/commands/why.ts
10699
10910
  init_errors();
10911
+
10912
+ // packages/infrastructure/cli/src/utils/whyService.ts
10913
+ init_internal();
10700
10914
  init_src2();
10701
10915
  function extractVariantChain(usage) {
10702
10916
  const segments = normalizeScannedClass(usage).split(":").filter(Boolean);
@@ -10744,7 +10958,7 @@ async function whyClass(className, options) {
10744
10958
  for (const file of scanResult.files) {
10745
10959
  const source = (() => {
10746
10960
  try {
10747
- return fs12__default.readFileSync(file.file, "utf8");
10961
+ return fs11__default.readFileSync(file.file, "utf8");
10748
10962
  } catch {
10749
10963
  return "";
10750
10964
  }