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/next.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var module$1 = require('module');
4
- var fs5 = require('fs');
5
- var path5 = require('path');
4
+ var fs9 = require('fs');
5
+ var path10 = require('path');
6
6
  require('crypto');
7
7
  var url = require('url');
8
8
  var zod = require('zod');
@@ -27,8 +27,8 @@ function _interopNamespace(e) {
27
27
  return Object.freeze(n);
28
28
  }
29
29
 
30
- var fs5__namespace = /*#__PURE__*/_interopNamespace(fs5);
31
- var path5__namespace = /*#__PURE__*/_interopNamespace(path5);
30
+ var fs9__namespace = /*#__PURE__*/_interopNamespace(fs9);
31
+ var path10__namespace = /*#__PURE__*/_interopNamespace(path10);
32
32
 
33
33
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
34
34
  var __defProp = Object.defineProperty;
@@ -84,11 +84,11 @@ function resolvePath(...segments) {
84
84
  return segments.join("/").replace(/\/+/g, "/");
85
85
  }
86
86
  }
87
- function existsSync(path7) {
87
+ function existsSync(path11) {
88
88
  if (isBrowser) return false;
89
89
  try {
90
90
  const nodeFs = __require(NODE_FS);
91
- return nodeFs.existsSync(path7);
91
+ return nodeFs.existsSync(path11);
92
92
  } catch {
93
93
  return false;
94
94
  }
@@ -157,12 +157,12 @@ function resolveNativeBinary(runtimeDir) {
157
157
  if (isBrowser2) {
158
158
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
159
159
  }
160
- if (process.env.TWS_DISABLE_NATIVE === "1") {
160
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
161
161
  return { path: null, source: "not-found", platform, tried: [] };
162
162
  }
163
163
  const envPath = process.env.TW_NATIVE_PATH?.trim();
164
164
  if (envPath) {
165
- if (fs5__namespace.existsSync(envPath)) {
165
+ if (fs9__namespace.existsSync(envPath)) {
166
166
  return { path: envPath, source: "env", platform, tried };
167
167
  }
168
168
  tried.push(`env:${envPath} (not found)`);
@@ -171,7 +171,7 @@ function resolveNativeBinary(runtimeDir) {
171
171
  for (const pkg of prebuiltPkgs) {
172
172
  try {
173
173
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
174
- if (fs5__namespace.existsSync(candidate)) {
174
+ if (fs9__namespace.existsSync(candidate)) {
175
175
  return { path: candidate, source: "prebuilt", platform, tried };
176
176
  }
177
177
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -182,13 +182,13 @@ function resolveNativeBinary(runtimeDir) {
182
182
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
183
183
  const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
184
184
  if (runtimeDir) {
185
- for (const depth of ["..", path5__namespace.join("..", ".."), path5__namespace.join("..", "..", "..")]) {
186
- const pkgRoot = path5__namespace.resolve(runtimeDir, depth);
185
+ for (const depth of ["..", path10__namespace.join("..", ".."), path10__namespace.join("..", "..", "..")]) {
186
+ const pkgRoot = path10__namespace.resolve(runtimeDir, depth);
187
187
  for (const bin of BINARY_NAMES_SELF) {
188
188
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
189
- const candidate = path5__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
189
+ const candidate = path10__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
190
190
  tried.push(`self-bundled:${candidate}`);
191
- if (fs5__namespace.existsSync(candidate)) {
191
+ if (fs9__namespace.existsSync(candidate)) {
192
192
  return { path: candidate, source: "prebuilt", platform, tried };
193
193
  }
194
194
  }
@@ -200,29 +200,29 @@ function resolveNativeBinary(runtimeDir) {
200
200
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
201
201
  const localCandidates = [];
202
202
  for (const bin of BINARY_NAMES) {
203
- localCandidates.push(path5__namespace.resolve(base, `${bin}.node`));
204
- localCandidates.push(path5__namespace.resolve(base, "..", `${bin}.node`));
205
- localCandidates.push(path5__namespace.resolve(base, `${bin}.${platform}.node`));
206
- localCandidates.push(path5__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
203
+ localCandidates.push(path10__namespace.resolve(base, `${bin}.node`));
204
+ localCandidates.push(path10__namespace.resolve(base, "..", `${bin}.node`));
205
+ localCandidates.push(path10__namespace.resolve(base, `${bin}.${platform}.node`));
206
+ localCandidates.push(path10__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
207
207
  }
208
208
  for (const startDir of [cwd, base]) {
209
209
  let dir = startDir;
210
210
  for (let i = 0; i < 6; i++) {
211
- const nativeDir = path5__namespace.resolve(dir, "native");
211
+ const nativeDir = path10__namespace.resolve(dir, "native");
212
212
  for (const bin of BINARY_NAMES) {
213
- localCandidates.push(path5__namespace.resolve(nativeDir, `${bin}.node`));
214
- localCandidates.push(path5__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
215
- localCandidates.push(path5__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
216
- localCandidates.push(path5__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
213
+ localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.node`));
214
+ localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
215
+ localCandidates.push(path10__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
216
+ localCandidates.push(path10__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
217
217
  }
218
- const parent = path5__namespace.resolve(dir, "..");
218
+ const parent = path10__namespace.resolve(dir, "..");
219
219
  if (parent === dir) break;
220
220
  dir = parent;
221
221
  }
222
222
  }
223
223
  for (const candidate of localCandidates) {
224
224
  tried.push(`local:${candidate}`);
225
- if (fs5__namespace.existsSync(candidate)) {
225
+ if (fs9__namespace.existsSync(candidate)) {
226
226
  return { path: candidate, source: "local", platform, tried };
227
227
  }
228
228
  }
@@ -243,648 +243,723 @@ var init_native_resolution = __esm({
243
243
  };
244
244
  }
245
245
  });
246
- function createLogger(namespace) {
247
- const prefix = `[${namespace}]`;
248
- return {
249
- warn(...args) {
250
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
251
- `);
252
- },
253
- debug(...args) {
254
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
255
- `);
256
- },
257
- error(...args) {
258
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
259
- `);
260
- },
261
- log(...args) {
262
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
263
- `);
264
- }
265
- };
266
- }
267
- function createDebugLogger(namespace, label) {
268
- const prefix = `[${namespace}]`;
269
- return (msg) => {
270
- if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
271
- console.debug(prefix, msg);
272
- }
273
- };
274
- }
275
- function formatIssuePath(path7) {
276
- if (!path7 || path7.length === 0) return "(root)";
277
- return path7.map(
278
- (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
279
- ).join(".");
280
- }
281
- function loadNativeBinding(options) {
282
- const { runtimeDir, candidates, isValid } = options;
283
- const loadErrors = [];
284
- for (const candidate of candidates) {
285
- const candidatePath = path5__namespace.default.resolve(runtimeDir, candidate);
286
- try {
287
- if (!fs5__namespace.default.existsSync(candidatePath) && !fs5__namespace.default.existsSync(candidatePath + ".node")) {
288
- continue;
246
+
247
+ // packages/domain/compiler/src/nativeBridge.ts
248
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, resetNativeBridgeCache, adaptNativeResult;
249
+ var init_nativeBridge = __esm({
250
+ "packages/domain/compiler/src/nativeBridge.ts"() {
251
+ init_src2();
252
+ _loadNative = (path11) => __require(path11);
253
+ log = (...args) => {
254
+ if (process.env.DEBUG?.includes("compiler:native")) {
255
+ console.log("[compiler:native]", ...args);
289
256
  }
290
- const mod = requireNativeModule(candidatePath);
291
- if (mod && isValid(mod)) {
292
- return { binding: mod, loadErrors, loadedPath: candidatePath };
257
+ };
258
+ NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
259
+ nativeBridge = null;
260
+ bridgeLoadAttempted = false;
261
+ bridgeLoadError = null;
262
+ isValidNativeBridge = (mod) => {
263
+ const m = mod;
264
+ return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
265
+ };
266
+ getNativeBridge = () => {
267
+ if (nativeBridge) {
268
+ return nativeBridge;
269
+ }
270
+ if (bridgeLoadAttempted) {
271
+ if (bridgeLoadError) {
272
+ throw bridgeLoadError;
273
+ }
274
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
275
+ }
276
+ bridgeLoadAttempted = true;
277
+ try {
278
+ const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
279
+ const result = resolveNativeBinary(runtimeDir);
280
+ if (result.path && result.path.endsWith(".node")) {
281
+ try {
282
+ const binding = _loadNative(result.path);
283
+ if (isValidNativeBridge(binding)) {
284
+ nativeBridge = binding;
285
+ log("Native bridge loaded successfully from:", result.path);
286
+ return nativeBridge;
287
+ }
288
+ } catch (e) {
289
+ log("Failed to require native binding:", e);
290
+ }
291
+ }
292
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
293
+
294
+ Tried paths: ${result.tried.join("\n")}`);
295
+ } catch (err) {
296
+ bridgeLoadError = err instanceof Error ? err : new Error(String(err));
297
+ log("Failed to load native bridge:", bridgeLoadError.message);
298
+ throw bridgeLoadError;
299
+ }
300
+ };
301
+ resetNativeBridgeCache = () => {
302
+ nativeBridge = null;
303
+ bridgeLoadAttempted = false;
304
+ bridgeLoadError = null;
305
+ log("Native bridge cache reset");
306
+ };
307
+ adaptNativeResult = (raw) => {
308
+ return {
309
+ code: raw.code ?? "",
310
+ classes: raw.classes ?? [],
311
+ changed: raw.changed ?? false,
312
+ rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
313
+ metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
314
+ };
315
+ };
316
+ if (typeof process !== "undefined" && !bridgeLoadAttempted) {
317
+ try {
318
+ getNativeBridge();
319
+ } catch {
293
320
  }
294
- loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
295
- } catch (e) {
296
- loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
297
321
  }
298
322
  }
299
- return { binding: null, loadErrors };
300
- }
301
- function requireNativeModule(p) {
302
- return _require2(p);
303
- }
304
- function resolveNativeBindingCandidates(options) {
305
- const {
306
- envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
307
- includeDefaultCandidates = true,
308
- enforceNodeExtensionForEnvPath = false
309
- } = options;
310
- const runtimeDir = options.runtimeDir || process.cwd();
311
- const candidates = [];
312
- for (const envVar of envVarNames) {
313
- const envPath = process.env[envVar];
314
- if (envPath) {
315
- candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
316
- }
323
+ });
324
+
325
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
326
+ async function generateCssNative(classes, options) {
327
+ const { theme } = options;
328
+ const native = getNativeBridge();
329
+ if (!native?.generateCssNative) {
330
+ throw new Error(
331
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
332
+ );
317
333
  }
318
- if (!includeDefaultCandidates) return candidates;
319
- if (fs5__namespace.default.existsSync(runtimeDir)) {
320
- try {
321
- for (const entry of fs5__namespace.default.readdirSync(runtimeDir)) {
322
- if (entry.endsWith(".node")) candidates.push(entry);
323
- }
324
- } catch {
334
+ const themeJson = JSON.stringify(theme);
335
+ const css = native.generateCssNative(classes, themeJson);
336
+ return css;
337
+ }
338
+ function getCacheStats() {
339
+ try {
340
+ const native = getNativeBridge();
341
+ if (!native?.getCacheStats) {
342
+ return null;
325
343
  }
344
+ const [hits, misses] = native.getCacheStats();
345
+ return { hits, misses };
346
+ } catch {
347
+ return null;
326
348
  }
327
- const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
328
- const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
329
- for (const bin of BINARY_NAMES) {
330
- candidates.push(path5__namespace.default.resolve(runtimeDir, `${bin}.node`));
331
- candidates.push(path5__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
332
- candidates.push(path5__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
333
- candidates.push(path5__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
334
- candidates.push(path5__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
335
- candidates.push(path5__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
336
- candidates.push(path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
337
- candidates.push(path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
338
- candidates.push(path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
339
- }
340
- return Array.from(new Set(candidates));
341
349
  }
342
- function resolveRuntimeDir(dir, importMetaUrl) {
350
+ function clearThemeCache() {
343
351
  try {
344
- return path5__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
352
+ const native = getNativeBridge();
353
+ if (!native?.clearThemeCache) {
354
+ return;
355
+ }
356
+ native.clearThemeCache();
345
357
  } catch {
346
- return process.cwd();
347
358
  }
348
359
  }
349
- var TwError, _require2;
350
- var init_src = __esm({
351
- "packages/domain/shared/src/index.ts"() {
352
- init_workerResolver();
353
- init_native_resolution();
354
- TwError = class _TwError extends Error {
355
- /** @deprecated Gunakan source */
356
- domain;
357
- source;
358
- code;
359
- originalCause;
360
- constructor(domainOrSource, code, message, cause) {
361
- super(message);
362
- this.name = "TwError";
363
- this.domain = domainOrSource;
364
- this.source = domainOrSource;
365
- this.code = code;
366
- this.originalCause = cause;
367
- if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
368
- }
369
- static fromIo(code, message) {
370
- return new _TwError("io", code, message);
371
- }
372
- static fromCompile(code, message) {
373
- return new _TwError("compile", code, message);
374
- }
375
- static fromRust(err) {
376
- if (err instanceof _TwError) return err;
377
- if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
378
- if (err && typeof err === "object") {
379
- const e = err;
380
- return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
381
- }
382
- return new _TwError("rust", "RUST_ERROR", String(err), err);
383
- }
384
- /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
385
- static fromZod(err) {
386
- const first = err.issues?.[0] ?? err.errors?.[0];
387
- const path7 = formatIssuePath(first?.path);
388
- const message = first ? `${path7}: ${first.message}` : "Schema validation failed";
389
- return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
390
- }
391
- static wrap(source, code, err) {
392
- if (err instanceof _TwError) return err;
393
- if (err instanceof Error) return new _TwError(source, code, err.message, err);
394
- return new _TwError(source, code, String(err), err);
395
- }
396
- toString() {
397
- return `TwError [${this.source}:${this.code}] ${this.message}`;
398
- }
399
- toJSON() {
400
- return { name: this.name, source: this.source, code: this.code, message: this.message };
401
- }
402
- toCliMessage() {
403
- return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
404
- }
405
- };
406
- _require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
360
+ var init_cssGeneratorNative = __esm({
361
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
362
+ init_nativeBridge();
407
363
  }
408
364
  });
409
365
 
410
- // packages/domain/scanner/src/native-bridge.ts
411
- var native_bridge_exports = {};
412
- __export(native_bridge_exports, {
413
- batchExtractClassesNative: () => batchExtractClassesNative,
414
- cachePriorityNative: () => cachePriorityNative,
415
- cacheReadNative: () => cacheReadNative,
416
- cacheWriteNative: () => cacheWriteNative,
417
- collectFilesNative: () => collectFilesNative,
418
- computeCacheStatsNative: () => computeCacheStatsNative,
419
- extractClassesNative: () => extractClassesNative,
420
- generateSubComponentTypesNative: () => generateSubComponentTypesNative,
421
- hasNativeScannerBinding: () => hasNativeScannerBinding,
422
- hasNativeWatchBinding: () => hasNativeWatchBinding,
423
- hashContentNative: () => hashContentNative,
424
- isRustCacheAvailable: () => isRustCacheAvailable,
425
- pollWatchEventsNative: () => pollWatchEventsNative,
426
- pruneStaleEntriesNative: () => pruneStaleEntriesNative,
427
- rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
428
- resetScannerBridgeCache: () => resetScannerBridgeCache,
429
- scanCacheGet: () => scanCacheGet,
430
- scanCacheInvalidate: () => scanCacheInvalidate,
431
- scanCachePut: () => scanCachePut,
432
- scanCacheStats: () => scanCacheStats,
433
- scanFileNative: () => scanFileNative,
434
- scanFilesBatchNative: () => scanFilesBatchNative,
435
- scanWorkspaceNative: () => scanWorkspaceNative,
436
- startWatchNative: () => startWatchNative,
437
- stopWatchNative: () => stopWatchNative
438
- });
439
- function getDirname() {
440
- if (typeof __dirname !== "undefined") {
441
- return __dirname;
442
- }
443
- if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))) {
444
- return path5__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
445
- }
446
- return process.cwd();
366
+ // packages/domain/compiler/src/compiler/compilationNative.ts
367
+ function compileCssNative2(classes, prefix) {
368
+ const native = getNativeBridge();
369
+ if (!native?.compileCss) throw new Error("compileCss not available");
370
+ return native.compileCss(classes, prefix);
447
371
  }
448
- function scanWorkspaceNative(root, extensions) {
449
- return scannerGetBinding().scanWorkspace(root, extensions ?? null);
372
+ function compileCssLightning(classes) {
373
+ const native = getNativeBridge();
374
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
375
+ return native.compileCssLightning(classes);
450
376
  }
451
- function extractClassesNative(source) {
452
- const result = scannerGetBinding().extractClassesFromSource?.(source);
453
- if (result === null || result === void 0) {
454
- throw new TwError(
455
- "rust",
456
- "SCANNER_EXTRACT_FAILED",
457
- "Native extractClassesFromSource returned null/undefined"
458
- );
459
- }
460
- return result;
377
+ function extractTwStateConfigsNative(source, filename) {
378
+ const native = getNativeBridge();
379
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
380
+ return native.extractTwStateConfigs(source, filename);
461
381
  }
462
- function hashContentNative(content) {
463
- const result = scannerGetBinding().hashFileContent?.(content);
464
- if (result === null || result === void 0) {
465
- throw new TwError(
466
- "rust",
467
- "SCANNER_HASH_FAILED",
468
- "Native hashFileContent returned null/undefined"
469
- );
470
- }
471
- return result;
382
+ function generateStaticStateCssNative(inputs, resolvedCss) {
383
+ const native = getNativeBridge();
384
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
385
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
472
386
  }
473
- function isRustCacheAvailable() {
474
- return true;
387
+ function extractAndGenerateStateCssNative(source, filename) {
388
+ const native = getNativeBridge();
389
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
390
+ return native.extractAndGenerateStateCss(source, filename);
475
391
  }
476
- function hasNativeScannerBinding() {
392
+ function layoutClassesToCss(classes) {
393
+ const native = getNativeBridge();
394
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
395
+ return native.layoutClassesToCss(classes);
396
+ }
397
+ function hashContent(input, algorithm = "sha256", length = 8) {
398
+ const native = getNativeBridge();
399
+ if (!native?.hashContent) throw new Error("hashContent not available");
400
+ return native.hashContent(input, algorithm, length);
401
+ }
402
+ function extractTwContainerConfigs(source) {
403
+ const native = getNativeBridge();
404
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
405
+ return native.extractTwContainerConfigs(source);
406
+ }
407
+ function parseAtomicClass(twClass) {
408
+ const native = getNativeBridge();
409
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
410
+ return native.parseAtomicClass(twClass);
411
+ }
412
+ function generateAtomicCss(rulesJson) {
413
+ const native = getNativeBridge();
414
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
415
+ return native.generateAtomicCss(rulesJson);
416
+ }
417
+ function toAtomicClasses(twClasses) {
418
+ const native = getNativeBridge();
419
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
420
+ return native.toAtomicClasses(twClasses);
421
+ }
422
+ function clearAtomicRegistry() {
423
+ const native = getNativeBridge();
424
+ if (!native?.clearAtomicRegistry) return;
425
+ native.clearAtomicRegistry();
426
+ }
427
+ function atomicRegistrySize() {
428
+ const native = getNativeBridge();
429
+ if (!native?.atomicRegistrySize) return 0;
430
+ return native.atomicRegistrySize();
431
+ }
432
+ var init_compilationNative = __esm({
433
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
434
+ init_nativeBridge();
435
+ }
436
+ });
437
+
438
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
439
+ function compileClass(input) {
440
+ const native = getNativeBridge();
441
+ if (!native?.compile_class) throw new Error("compile_class not available");
442
+ const resultJson = native.compile_class(input);
477
443
  try {
478
- scannerBridgeLoader.get();
479
- return true;
444
+ return JSON.parse(resultJson);
480
445
  } catch {
481
- return false;
446
+ return {
447
+ selector: "",
448
+ declarations: "",
449
+ properties: [],
450
+ specificity: 0
451
+ };
482
452
  }
483
453
  }
484
- function cacheReadNative(cachePath) {
485
- const result = scannerGetBinding().cacheRead?.(cachePath);
486
- if (result === null || result === void 0) {
487
- throw new TwError(
488
- "rust",
489
- "SCANNER_CACHE_READ_FAILED",
490
- "Native cacheRead returned null/undefined"
491
- );
454
+ function compileClasses(inputs) {
455
+ const native = getNativeBridge();
456
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
457
+ const resultJson = native.compile_classes(inputs);
458
+ try {
459
+ return JSON.parse(resultJson);
460
+ } catch {
461
+ return {
462
+ css: "",
463
+ resolved_classes: [],
464
+ unknown_classes: [],
465
+ size_bytes: 0,
466
+ duration_ms: 0
467
+ };
492
468
  }
493
- return result;
494
469
  }
495
- function cacheWriteNative(cachePath, entries) {
496
- const result = scannerGetBinding().cacheWrite?.(cachePath, entries);
497
- if (result === null || result === void 0) {
498
- throw new TwError(
499
- "rust",
500
- "SCANNER_CACHE_WRITE_FAILED",
501
- "Native cacheWrite returned null/undefined"
502
- );
503
- }
504
- return result;
470
+ function compileToCss(input, minify) {
471
+ const native = getNativeBridge();
472
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
473
+ return native.compile_to_css(input, minify ?? false);
505
474
  }
506
- function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHitCount, cachedLastSeenMs, nowMs = Date.now()) {
507
- const result = scannerGetBinding().cachePriority?.(
508
- mtimeMs,
509
- size,
510
- cachedMtimeMs,
511
- cachedSize,
512
- cachedHitCount,
513
- cachedLastSeenMs,
514
- nowMs
515
- );
516
- if (result === null || result === void 0) {
517
- throw new TwError(
518
- "rust",
519
- "SCANNER_CACHE_PRIORITY_FAILED",
520
- "Native cachePriority returned null/undefined"
521
- );
522
- }
523
- return result;
475
+ function compileToCssBatch(inputs, minify) {
476
+ const native = getNativeBridge();
477
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
478
+ return native.compile_to_css_batch(inputs, minify ?? false);
524
479
  }
525
- function batchExtractClassesNative(filePaths) {
526
- const binding = scannerGetBinding();
527
- if (!binding.batchExtractClasses) {
528
- throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
529
- }
530
- return binding.batchExtractClasses(filePaths) ?? [];
480
+ function minifyCss(css) {
481
+ const native = getNativeBridge();
482
+ if (!native?.minify_css) throw new Error("minify_css not available");
483
+ return native.minify_css(css);
531
484
  }
532
- function scanCacheGet(filePath, contentHash) {
533
- const binding = scannerGetBinding();
534
- if (!binding.scanCacheGet) {
535
- throw new Error("FATAL: Native binding 'scanCacheGet' is required but not available.");
485
+ function compileAnimation(animationName, from, to) {
486
+ const native = getNativeBridge();
487
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
488
+ const resultJson = native.compile_animation(animationName, from, to);
489
+ try {
490
+ return JSON.parse(resultJson);
491
+ } catch {
492
+ return {
493
+ animation_id: "",
494
+ keyframes_css: "",
495
+ animation_rule: "",
496
+ duration_ms: 0
497
+ };
536
498
  }
537
- return binding.scanCacheGet(filePath, contentHash) ?? null;
538
499
  }
539
- function scanCachePut(filePath, contentHash, classes, mtimeMs, size) {
540
- const binding = scannerGetBinding();
541
- if (!binding.scanCachePut) {
542
- throw new Error("FATAL: Native binding 'scanCachePut' is required but not available.");
500
+ function compileKeyframes(name, stopsJson) {
501
+ const native = getNativeBridge();
502
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
503
+ const resultJson = native.compile_keyframes(name, stopsJson);
504
+ try {
505
+ return JSON.parse(resultJson);
506
+ } catch {
507
+ return {
508
+ animation_id: "",
509
+ keyframes_css: "",
510
+ animation_rule: "",
511
+ duration_ms: 0
512
+ };
543
513
  }
544
- binding.scanCachePut(filePath, contentHash, classes, mtimeMs, size);
545
514
  }
546
- function scanCacheInvalidate(filePath) {
547
- const binding = scannerGetBinding();
548
- if (!binding.scanCacheInvalidate) {
549
- throw new Error("FATAL: Native binding 'scanCacheInvalidate' is required but not available.");
515
+ function compileTheme(tokensJson, themeName, prefix) {
516
+ const native = getNativeBridge();
517
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
518
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
519
+ try {
520
+ return JSON.parse(resultJson);
521
+ } catch {
522
+ return {
523
+ selector: ":root",
524
+ variables: [],
525
+ variables_css: "",
526
+ theme_name: themeName
527
+ };
550
528
  }
551
- binding.scanCacheInvalidate(filePath);
552
529
  }
553
- function scanCacheStats() {
554
- const binding = scannerGetBinding();
555
- if (!binding.scanCacheStats) {
556
- throw new Error("FATAL: Native binding 'scanCacheStats' is required but not available.");
557
- }
558
- return binding.scanCacheStats();
530
+ function twMerge(classString) {
531
+ const native = getNativeBridge();
532
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
533
+ return native.tw_merge(classString);
559
534
  }
560
- function scanFileNative(filePath) {
561
- const binding = scannerGetBinding();
562
- if (!binding.scanFile) {
563
- throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
564
- }
565
- return binding.scanFile(filePath);
535
+ function twMergeMany(classStrings) {
536
+ const native = getNativeBridge();
537
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
538
+ return native.tw_merge_many(classStrings);
566
539
  }
567
- function collectFilesNative(root, extensions, ignoreDirs) {
568
- const binding = scannerGetBinding();
569
- if (!binding.collectFiles) return null;
570
- return binding.collectFiles(root, extensions, ignoreDirs);
540
+ function twMergeWithSeparator(classString, options) {
541
+ const native = getNativeBridge();
542
+ if (!native?.tw_merge_with_separator)
543
+ throw new Error("tw_merge_with_separator not available");
544
+ const opts = {
545
+ separator: options.separator,
546
+ debug: options.debug
547
+ };
548
+ return native.tw_merge_with_separator(classString, opts);
571
549
  }
572
- function scanFilesBatchNative(filePaths) {
573
- const binding = scannerGetBinding();
574
- if (!binding.scanFilesBatch) {
575
- return filePaths.map((fp) => {
576
- try {
577
- const r = binding.scanFile?.(fp);
578
- return r ? { file: r.file, classes: r.classes, hash: r.hash ?? "" } : { file: fp, classes: [], hash: "" };
579
- } catch {
580
- return { file: fp, classes: [], hash: "" };
581
- }
582
- });
550
+ function twMergeManyWithSeparator(classStrings, options) {
551
+ const native = getNativeBridge();
552
+ if (!native?.tw_merge_many_with_separator)
553
+ throw new Error("tw_merge_many_with_separator not available");
554
+ const opts = {
555
+ separator: options.separator,
556
+ debug: options.debug
557
+ };
558
+ return native.tw_merge_many_with_separator(classStrings, opts);
559
+ }
560
+ function twMergeRaw(classLists) {
561
+ const native = getNativeBridge();
562
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
563
+ return native.tw_merge_raw(classLists);
564
+ }
565
+ var init_cssCompilationNative = __esm({
566
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
567
+ init_nativeBridge();
583
568
  }
584
- return binding.scanFilesBatch(filePaths);
569
+ });
570
+
571
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
572
+ function idRegistryCreate() {
573
+ const native = getNativeBridge();
574
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
575
+ return native.id_registry_create();
585
576
  }
586
- function generateSubComponentTypesNative(root, outputPath) {
587
- const binding = scannerGetBinding();
588
- if (!binding.generateSubComponentTypes) return null;
589
- return binding.generateSubComponentTypes(root, outputPath ?? null);
577
+ function idRegistryGenerate(handle, name) {
578
+ const native = getNativeBridge();
579
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
580
+ return native.id_registry_generate(handle, name);
590
581
  }
591
- function pruneStaleEntriesNative(entries, maxAgeMs, checkExists) {
592
- const binding = scannerGetBinding();
593
- if (!binding.pruneStaleEntries) return null;
594
- return binding.pruneStaleEntries(
595
- entries.map((e) => ({ file: e.file, lastSeenMs: e.lastSeenMs ?? 0 })),
596
- maxAgeMs ?? null,
597
- checkExists ?? null
598
- );
582
+ function idRegistryLookup(handle, name) {
583
+ const native = getNativeBridge();
584
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
585
+ return native.id_registry_lookup(handle, name);
599
586
  }
600
- function rebuildWorkspaceResultNative(files) {
601
- const binding = scannerBridgeLoader.get();
602
- if (!binding?.rebuildWorkspaceResult) return null;
587
+ function idRegistryNext(handle) {
588
+ const native = getNativeBridge();
589
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
590
+ return native.id_registry_next(handle);
591
+ }
592
+ function idRegistryDestroy(handle) {
593
+ const native = getNativeBridge();
594
+ if (!native?.id_registry_destroy) return;
595
+ native.id_registry_destroy(handle);
596
+ }
597
+ function idRegistryReset(handle) {
598
+ const native = getNativeBridge();
599
+ if (!native?.id_registry_reset) return;
600
+ native.id_registry_reset(handle);
601
+ }
602
+ function idRegistrySnapshot(handle) {
603
+ const native = getNativeBridge();
604
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
605
+ const snapshotJson = native.id_registry_snapshot(handle);
603
606
  try {
604
- return binding.rebuildWorkspaceResult(files);
607
+ return JSON.parse(snapshotJson);
605
608
  } catch {
606
- return null;
609
+ return {
610
+ handle,
611
+ next_id: 0,
612
+ entries: [],
613
+ total_entries: 0
614
+ };
607
615
  }
608
616
  }
609
- function computeCacheStatsNative(filesClasses, sizes, top) {
610
- const binding = scannerGetBinding();
611
- if (!binding.computeCacheStats) return null;
612
- return binding.computeCacheStats(filesClasses, sizes, top ?? null);
617
+ function idRegistryActiveCount() {
618
+ const native = getNativeBridge();
619
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
620
+ return native.id_registry_active_count();
613
621
  }
614
- function startWatchNative(rootDir) {
622
+ function registerPropertyName(propertyName) {
623
+ const native = getNativeBridge();
624
+ if (!native?.register_property_name)
625
+ throw new Error("register_property_name not available");
626
+ return native.register_property_name(propertyName);
627
+ }
628
+ function registerValueName(valueName) {
629
+ const native = getNativeBridge();
630
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
631
+ return native.register_value_name(valueName);
632
+ }
633
+ function propertyIdToString(propertyId) {
634
+ const native = getNativeBridge();
635
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
636
+ return native.property_id_to_string(propertyId);
637
+ }
638
+ function valueIdToString(valueId) {
639
+ const native = getNativeBridge();
640
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
641
+ return native.value_id_to_string(valueId);
642
+ }
643
+ function reverseLookupProperty(propertyId) {
644
+ const native = getNativeBridge();
645
+ if (!native?.reverse_lookup_property)
646
+ throw new Error("reverse_lookup_property not available");
647
+ return native.reverse_lookup_property(propertyId);
648
+ }
649
+ function reverseLookupValue(valueId) {
650
+ const native = getNativeBridge();
651
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
652
+ return native.reverse_lookup_value(valueId);
653
+ }
654
+ function idRegistryExport(handle) {
655
+ const native = getNativeBridge();
656
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
657
+ return native.id_registry_export(handle);
658
+ }
659
+ function idRegistryImport(importedData) {
660
+ const native = getNativeBridge();
661
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
662
+ return native.id_registry_import(importedData);
663
+ }
664
+ var init_idRegistryNative = __esm({
665
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
666
+ init_nativeBridge();
667
+ }
668
+ });
669
+
670
+ // packages/domain/compiler/src/compiler/streamingNative.ts
671
+ function processFileChange(fileChangeJson) {
672
+ const native = getNativeBridge();
673
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
674
+ const resultJson = native.process_file_change(fileChangeJson);
615
675
  try {
616
- const binding = scannerGetBinding();
617
- if (!binding.startWatch) return null;
618
- return binding.startWatch(rootDir);
676
+ return JSON.parse(resultJson);
619
677
  } catch {
620
- return null;
678
+ return {
679
+ file_path: "",
680
+ status: "error",
681
+ old_classes: [],
682
+ new_classes: [],
683
+ added_classes: [],
684
+ removed_classes: [],
685
+ changed: false,
686
+ fingerprint: "",
687
+ error: "Failed to parse result"
688
+ };
621
689
  }
622
690
  }
623
- function pollWatchEventsNative(handleId) {
691
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
692
+ const native = getNativeBridge();
693
+ if (!native?.compute_incremental_diff)
694
+ throw new Error("compute_incremental_diff not available");
695
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
624
696
  try {
625
- const binding = scannerGetBinding();
626
- if (!binding.pollWatchEvents) return [];
627
- return binding.pollWatchEvents(handleId);
697
+ return JSON.parse(resultJson);
628
698
  } catch {
629
- return [];
699
+ return {
700
+ is_changed: false,
701
+ changes_count: 0,
702
+ diff: {
703
+ added_files: [],
704
+ removed_files: [],
705
+ modified_files: [],
706
+ added_classes: [],
707
+ removed_classes: [],
708
+ total_changes: 0
709
+ },
710
+ processing_time_ms: 0
711
+ };
630
712
  }
631
713
  }
632
- function stopWatchNative(handleId) {
714
+ function createFingerprint(filePath, fileContent) {
715
+ const native = getNativeBridge();
716
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
717
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
633
718
  try {
634
- const binding = scannerGetBinding();
635
- if (!binding.stopWatch) return false;
636
- return binding.stopWatch(handleId);
719
+ return JSON.parse(fingerprintJson);
637
720
  } catch {
638
- return false;
721
+ return {
722
+ file_path: filePath,
723
+ content_hash: "",
724
+ size_bytes: fileContent.length,
725
+ mtime_ms: Date.now(),
726
+ class_hash: "",
727
+ signature: ""
728
+ };
639
729
  }
640
730
  }
641
- function hasNativeWatchBinding() {
731
+ function injectStateHash(css, stateHash) {
732
+ const native = getNativeBridge();
733
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
734
+ const resultJson = native.inject_state_hash(css, stateHash);
642
735
  try {
643
- const binding = scannerGetBinding();
644
- return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
736
+ return JSON.parse(resultJson);
645
737
  } catch {
646
- return false;
738
+ return {
739
+ injected: false,
740
+ state_hash: stateHash,
741
+ affected_files: 0,
742
+ total_injected_bytes: 0
743
+ };
647
744
  }
648
745
  }
649
- var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
650
- var init_native_bridge = __esm({
651
- "packages/domain/scanner/src/native-bridge.ts"() {
652
- init_src();
653
- log = createDebugLogger("scanner:native");
654
- isValidScannerBinding = (module) => {
655
- const candidate = module;
656
- return !!(candidate && (candidate.scanWorkspace || candidate.extractClassesFromSource || candidate.hashFileContent || candidate.cacheRead || candidate.cacheWrite));
657
- };
658
- createScannerBridgeLoader = () => {
659
- const _state = {
660
- binding: void 0,
661
- loadError: null,
662
- candidatePaths: []
663
- };
664
- const throwNativeBindingError = () => {
665
- const lines = [
666
- "FATAL: Native scanner binding not found.",
667
- "",
668
- "This package requires the Rust native binding 'tailwind_styled_parser.node'.",
669
- "The binding was not found in any of these paths:",
670
- ..._state.candidatePaths.map((p) => ` - ${p}`),
671
- ""
672
- ];
673
- if (_state.loadError) {
674
- lines.push("Load error:", ` ${_state.loadError}`, "");
675
- }
676
- lines.push(
677
- "To fix this, run:",
678
- " npm run build:rust",
679
- "",
680
- "This will build the native Rust module from the 'native/' directory.",
681
- "If you're using this package in a CI/CD environment, ensure Rust toolchain is installed",
682
- "and 'npm run build:rust' is executed before running tests or building."
683
- );
684
- throw new TwError("rust", "SCANNER_NATIVE_BINDING_NOT_FOUND", lines.join("\n"));
685
- };
686
- const scannerGetBinding2 = () => {
687
- const cachedBinding = _state.binding;
688
- if (cachedBinding !== void 0) {
689
- if (cachedBinding !== null) {
690
- return cachedBinding;
691
- }
692
- return throwNativeBindingError();
693
- }
694
- const runtimeDir = getDirname();
695
- const candidates = resolveNativeBindingCandidates({
696
- runtimeDir,
697
- includeDefaultCandidates: true
698
- });
699
- _state.candidatePaths = candidates;
700
- const { binding, loadErrors } = loadNativeBinding({
701
- runtimeDir,
702
- candidates,
703
- isValid: isValidScannerBinding,
704
- invalidExportMessage: "Module loaded but missing expected scanner binding functions"
705
- });
706
- if (binding) {
707
- log(`scanner native binding loaded successfully`);
708
- _state.binding = binding;
709
- return _state.binding;
710
- }
711
- if (loadErrors.length > 0) {
712
- _state.loadError = loadErrors.map((e) => `${e.path}: ${e.message}`).join("; ");
713
- }
714
- _state.binding = null;
715
- return throwNativeBindingError();
716
- };
717
- return {
718
- get: scannerGetBinding2,
719
- scannerGetBinding: scannerGetBinding2,
720
- reset: () => {
721
- _state.binding = void 0;
722
- _state.loadError = null;
723
- _state.candidatePaths = [];
724
- }
725
- };
746
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
747
+ const native = getNativeBridge();
748
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
749
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
750
+ try {
751
+ return JSON.parse(resultJson);
752
+ } catch {
753
+ return {
754
+ entries_before: 0,
755
+ entries_after: 0,
756
+ entries_removed: 0,
757
+ freed_bytes: 0
726
758
  };
727
- scannerBridgeLoader = createScannerBridgeLoader();
728
- scannerGetBinding = scannerBridgeLoader.get;
729
- resetScannerBridgeCache = scannerBridgeLoader.reset;
730
759
  }
731
- });
732
-
733
- // packages/domain/compiler/src/nativeBridge.ts
734
- var _loadNative, log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, resetNativeBridgeCache, adaptNativeResult;
735
- var init_nativeBridge = __esm({
736
- "packages/domain/compiler/src/nativeBridge.ts"() {
737
- init_src();
738
- _loadNative = (path7) => __require(path7);
739
- log3 = (...args) => {
740
- if (process.env.DEBUG?.includes("compiler:native")) {
741
- console.log("[compiler:native]", ...args);
742
- }
743
- };
744
- NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
745
- nativeBridge = null;
746
- bridgeLoadAttempted = false;
747
- bridgeLoadError = null;
748
- isValidNativeBridge = (mod) => {
749
- const m = mod;
750
- return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
751
- };
752
- getNativeBridge = () => {
753
- if (nativeBridge) {
754
- return nativeBridge;
755
- }
756
- if (bridgeLoadAttempted) {
757
- if (bridgeLoadError) {
758
- throw bridgeLoadError;
759
- }
760
- throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
761
- }
762
- bridgeLoadAttempted = true;
763
- try {
764
- const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
765
- const result = resolveNativeBinary(runtimeDir);
766
- if (result.path && result.path.endsWith(".node")) {
767
- try {
768
- const binding = _loadNative(result.path);
769
- if (isValidNativeBridge(binding)) {
770
- nativeBridge = binding;
771
- log3("Native bridge loaded successfully from:", result.path);
772
- return nativeBridge;
773
- }
774
- } catch (e) {
775
- log3("Failed to require native binding:", e);
776
- }
777
- }
778
- throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
779
-
780
- Tried paths: ${result.tried.join("\n")}`);
781
- } catch (err) {
782
- bridgeLoadError = err instanceof Error ? err : new Error(String(err));
783
- log3("Failed to load native bridge:", bridgeLoadError.message);
784
- throw bridgeLoadError;
785
- }
786
- };
787
- resetNativeBridgeCache = () => {
788
- nativeBridge = null;
789
- bridgeLoadAttempted = false;
790
- bridgeLoadError = null;
791
- log3("Native bridge cache reset");
760
+ }
761
+ function rebuildWorkspaceResult(rootDir, extensions) {
762
+ const native = getNativeBridge();
763
+ if (!native?.rebuild_workspace_result)
764
+ throw new Error("rebuild_workspace_result not available");
765
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
766
+ try {
767
+ return JSON.parse(resultJson);
768
+ } catch {
769
+ return {
770
+ total_files_scanned: 0,
771
+ total_classes_found: 0,
772
+ unique_classes: 0,
773
+ build_time_ms: 0,
774
+ files_with_changes: 0
792
775
  };
793
- adaptNativeResult = (raw) => {
794
- return {
795
- code: raw.code ?? "",
796
- classes: raw.classes ?? [],
797
- changed: raw.changed ?? false,
798
- rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
799
- metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
800
- };
776
+ }
777
+ }
778
+ function scanFileNative(filePath, fileContent) {
779
+ const native = getNativeBridge();
780
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
781
+ const resultJson = native.scan_file_native(filePath, fileContent);
782
+ try {
783
+ return JSON.parse(resultJson);
784
+ } catch {
785
+ return {
786
+ file: filePath,
787
+ classes: [],
788
+ added_classes: [],
789
+ removed_classes: [],
790
+ changed: false
801
791
  };
802
- if (typeof process !== "undefined" && !bridgeLoadAttempted) {
803
- try {
804
- getNativeBridge();
805
- } catch {
806
- }
807
- }
792
+ }
793
+ }
794
+ function scanFilesBatchNative(filesJson) {
795
+ const native = getNativeBridge();
796
+ if (!native?.scan_files_batch_native)
797
+ throw new Error("scan_files_batch_native not available");
798
+ const resultJson = native.scan_files_batch_native(filesJson);
799
+ try {
800
+ return JSON.parse(resultJson);
801
+ } catch {
802
+ return [];
803
+ }
804
+ }
805
+ var init_streamingNative = __esm({
806
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
807
+ init_nativeBridge();
808
808
  }
809
809
  });
810
810
 
811
- // packages/domain/compiler/src/tailwindEngine.ts
811
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
812
812
  var tailwindEngine_exports = {};
813
813
  __export(tailwindEngine_exports, {
814
- generateRawCss: () => generateRawCss,
814
+ clearCache: () => clearCache,
815
+ getCacheStats: () => getCacheStats2,
815
816
  processTailwindCssWithTargets: () => processTailwindCssWithTargets,
816
817
  runCssPipeline: () => runCssPipeline,
817
818
  runCssPipelineSync: () => runCssPipelineSync
818
819
  });
819
- function loadTailwindEngine() {
820
- if (_twEngine) return _twEngine;
821
- if (_twEngineError) throw _twEngineError;
822
- try {
823
- const tw = require2("tailwindcss");
824
- if (typeof tw.compile !== "function") {
825
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
820
+ function _getCacheKey(classes, minify, cssEntry, root) {
821
+ const sorted = [...classes].sort().join(",");
822
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
823
+ return `${sorted}|${flags}`;
824
+ }
825
+ function _evictOldestIfNeeded() {
826
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
827
+ const firstKey = _cssCache.keys().next().value;
828
+ if (firstKey !== void 0) {
829
+ _cssCache.delete(firstKey);
826
830
  }
827
- _twEngine = tw;
828
- return _twEngine;
829
- } catch (e) {
830
- _twEngineError = e instanceof Error ? e : new Error(String(e));
831
- throw _twEngineError;
832
- }
833
- }
834
- async function generateRawCss(classes, cssEntryContent, root) {
835
- if (classes.length === 0) return "";
836
- const tw = loadTailwindEngine();
837
- const input = cssEntryContent ?? "@import 'tailwindcss';";
838
- const { readFileSync, existsSync: existsSync3 } = await import('fs');
839
- const { dirname, resolve: resolve2 } = await import('path');
840
- const projectRoot = root ?? process.cwd();
841
- const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
842
- const loadStylesheet = async (id, base) => {
843
- try {
844
- 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;
845
- const pkgPath = req.resolve(cssId);
846
- return {
847
- content: readFileSync(pkgPath, "utf-8"),
848
- base: dirname(pkgPath)
849
- };
850
- } catch {
851
- try {
852
- const absPath = resolve2(base, id);
853
- if (existsSync3(absPath)) {
854
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
855
- }
856
- } catch {
831
+ }
832
+ }
833
+ function getCacheStats2() {
834
+ const total = _cacheHits + _cacheMisses;
835
+ return {
836
+ hits: _cacheHits,
837
+ misses: _cacheMisses,
838
+ hitRate: total > 0 ? _cacheHits / total : 0,
839
+ size: _cssCache.size,
840
+ maxSize: MAX_CACHE_SIZE
841
+ };
842
+ }
843
+ function clearCache() {
844
+ _cssCache.clear();
845
+ _cacheHits = 0;
846
+ _cacheMisses = 0;
847
+ }
848
+ function getThemeConfig() {
849
+ return {
850
+ colors: {
851
+ slate: {
852
+ "50": "#f8fafc",
853
+ "100": "#f1f5f9",
854
+ "200": "#e2e8f0",
855
+ "300": "#cbd5e1",
856
+ "400": "#94a3b8",
857
+ "500": "#64748b",
858
+ "600": "#475569",
859
+ "700": "#334155",
860
+ "800": "#1e293b",
861
+ "900": "#0f172a"
862
+ },
863
+ gray: {
864
+ "50": "#f9fafb",
865
+ "100": "#f3f4f6",
866
+ "200": "#e5e7eb",
867
+ "300": "#d1d5db",
868
+ "400": "#9ca3af",
869
+ "500": "#6b7280",
870
+ "600": "#4b5563",
871
+ "700": "#374151",
872
+ "800": "#1f2937",
873
+ "900": "#111827"
874
+ },
875
+ white: "#ffffff",
876
+ black: "#000000",
877
+ red: {
878
+ "500": "#ef4444",
879
+ "600": "#dc2626"
880
+ },
881
+ blue: {
882
+ "500": "#3b82f6",
883
+ "600": "#1e40af"
857
884
  }
858
- return { content: "", base };
885
+ },
886
+ spacing: {
887
+ "0": "0px",
888
+ "1": "0.25rem",
889
+ "2": "0.5rem",
890
+ "3": "0.75rem",
891
+ "4": "1rem",
892
+ "5": "1.25rem",
893
+ "6": "1.5rem",
894
+ "8": "2rem",
895
+ "10": "2.5rem",
896
+ "12": "3rem",
897
+ "16": "4rem",
898
+ "20": "5rem",
899
+ "24": "6rem"
900
+ },
901
+ breakpoints: {
902
+ "sm": "640px",
903
+ "md": "768px",
904
+ "lg": "1024px",
905
+ "xl": "1280px",
906
+ "2xl": "1536px"
859
907
  }
860
908
  };
861
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
862
- return compiler.build(classes);
863
909
  }
864
910
  function postProcessWithLightning(rawCss) {
865
911
  if (!rawCss) return "";
866
912
  const native = getNativeBridge();
867
- if (typeof native.processTailwindCssLightning !== "function") {
913
+ if (!native?.processTailwindCssLightning) {
868
914
  throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
869
915
  }
870
916
  const result = native.processTailwindCssLightning(rawCss);
871
- return result?.css ?? rawCss;
917
+ if (!result?.css) {
918
+ throw new Error("FATAL: processTailwindCssLightning returned null");
919
+ }
920
+ return result.css;
872
921
  }
873
922
  async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
874
- const unique = [...new Set(classes.filter(Boolean))];
923
+ const filtered = classes.filter(Boolean);
924
+ const uniqueMap = /* @__PURE__ */ new Map();
925
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
926
+ const unique = Array.from(uniqueMap.values());
875
927
  if (unique.length === 0) {
876
928
  return { css: "", classes: [], sizeBytes: 0, optimized: false };
877
929
  }
878
- const rawCss = await generateRawCss(unique, cssEntryContent, root);
879
- const native = getNativeBridge();
880
- const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
881
- const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
882
- return {
930
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
931
+ const cached = _cssCache.get(cacheKey);
932
+ if (cached) {
933
+ _cacheHits++;
934
+ if (process.env.DEBUG?.includes("compiler")) {
935
+ console.log(
936
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats2().hitRate * 100).toFixed(1)}%)`
937
+ );
938
+ }
939
+ return cached;
940
+ }
941
+ _cacheMisses++;
942
+ let rawCss;
943
+ let usedRustCompiler = false;
944
+ const theme = getThemeConfig();
945
+ rawCss = await generateCssNative(unique, { theme });
946
+ usedRustCompiler = true;
947
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
948
+ if (process.env.DEBUG?.includes("compiler")) {
949
+ console.log(
950
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
951
+ `Size: ${finalCss.length} bytes`
952
+ );
953
+ }
954
+ const result = {
883
955
  css: finalCss,
884
956
  classes: unique,
885
957
  sizeBytes: finalCss.length,
886
- optimized: hasLightning
958
+ optimized: minify
887
959
  };
960
+ _evictOldestIfNeeded();
961
+ _cssCache.set(cacheKey, result);
962
+ return result;
888
963
  }
889
964
  function runCssPipelineSync(_classes) {
890
965
  return { css: "", classes: [], sizeBytes: 0, optimized: false };
@@ -895,137 +970,63 @@ function processTailwindCssWithTargets(css, targets) {
895
970
  throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
896
971
  }
897
972
  const result = native.processTailwindCssWithTargets(css, targets ?? null);
898
- return (result?.css ?? css).trim();
973
+ if (!result?.css) {
974
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
975
+ }
976
+ return result.css;
899
977
  }
900
- var require2, _twEngine, _twEngineError;
978
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
901
979
  var init_tailwindEngine = __esm({
902
- "packages/domain/compiler/src/tailwindEngine.ts"() {
980
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
903
981
  init_nativeBridge();
904
- require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
905
- _twEngine = null;
906
- _twEngineError = null;
982
+ init_cssGeneratorNative();
983
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
984
+ _cssCache = /* @__PURE__ */ new Map();
985
+ _cacheHits = 0;
986
+ _cacheMisses = 0;
987
+ MAX_CACHE_SIZE = 100;
907
988
  }
908
989
  });
909
990
 
910
- // packages/domain/compiler/src/index.ts
911
- var src_exports = {};
912
- __export(src_exports, {
913
- BucketEngine: () => BucketEngine,
914
- IncrementalEngine: () => IncrementalEngine,
915
- adaptNativeResult: () => adaptNativeResult,
916
- analyzeClassUsage: () => analyzeClassUsage,
917
- analyzeClasses: () => analyzeClasses,
918
- analyzeFile: () => analyzeFile,
919
- analyzeRsc: () => analyzeRsc,
920
- analyzeVariantUsage: () => analyzeVariantUsage,
991
+ // packages/domain/compiler/src/compiler/index.ts
992
+ var init_compiler = __esm({
993
+ "packages/domain/compiler/src/compiler/index.ts"() {
994
+ init_cssGeneratorNative();
995
+ init_compilationNative();
996
+ init_cssCompilationNative();
997
+ init_idRegistryNative();
998
+ init_streamingNative();
999
+ init_tailwindEngine();
1000
+ }
1001
+ });
1002
+
1003
+ // packages/domain/compiler/src/parser/index.ts
1004
+ var parser_exports = {};
1005
+ __export(parser_exports, {
921
1006
  astExtractClasses: () => astExtractClasses,
922
1007
  batchExtractClasses: () => batchExtractClasses,
923
- bucketSort: () => bucketSort,
924
- buildStyleTag: () => buildStyleTag,
925
1008
  checkAgainstSafelist: () => checkAgainstSafelist,
926
- classifyAndSortClasses: () => classifyAndSortClasses,
927
- classifyNode: () => classifyNode,
928
- compileCssFromClasses: () => compileCssFromClasses,
929
- compileCssNative: () => compileCssNative,
930
- compileVariantTable: () => compileVariantTable,
931
- compileVariants: () => compileVariants,
932
- detectConflicts: () => detectConflicts,
933
1009
  diffClassLists: () => diffClassLists,
934
- eliminateDeadCss: () => eliminateDeadCss,
935
1010
  extractAllClasses: () => extractAllClasses,
936
1011
  extractClassesFromSource: () => extractClassesFromSource,
937
1012
  extractComponentUsage: () => extractComponentUsage,
938
- fileToRoute: () => fileToRoute,
939
- findDeadVariants: () => findDeadVariants,
940
- generateCssForClasses: () => generateCssForClasses,
941
- generateSafelist: () => generateSafelist,
942
- getAllRoutes: () => getAllRoutes,
943
- getBucketEngine: () => getBucketEngine,
944
- getContentPaths: () => getContentPaths,
945
- getIncrementalEngine: () => getIncrementalEngine,
946
- getNativeBridge: () => getNativeBridge,
947
- getRouteClasses: () => getRouteClasses,
948
- hasTwUsage: () => hasTwUsage,
949
- hoistComponents: () => hoistComponents,
950
- injectClientDirective: () => injectClientDirective,
951
- injectServerOnlyComment: () => injectServerOnlyComment,
952
- isAlreadyTransformed: () => isAlreadyTransformed,
953
- loadSafelist: () => loadSafelist,
954
- loadTailwindConfig: () => loadTailwindConfig,
955
1013
  mergeClassesStatic: () => mergeClassesStatic,
956
- mergeCssDeclarations: () => mergeCssDeclarations,
957
1014
  normalizeAndDedupClasses: () => normalizeAndDedupClasses,
958
1015
  normalizeClasses: () => normalizeClasses,
959
- optimizeCss: () => optimizeCss,
960
- parseClasses: () => parseClasses,
961
- registerFileClasses: () => registerFileClasses,
962
- registerGlobalClasses: () => registerGlobalClasses,
963
- resetBucketEngine: () => resetBucketEngine,
964
- resetIncrementalEngine: () => resetIncrementalEngine,
965
- resetNativeBridgeCache: () => resetNativeBridgeCache,
966
- runElimination: () => runElimination,
967
- runLoaderTransform: () => runLoaderTransform,
968
- scanProjectUsage: () => scanProjectUsage,
969
- shouldProcess: () => shouldProcess,
970
- shouldSkipFile: () => shouldSkipFile,
971
- transformSource: () => transformSource
1016
+ parseClasses: () => parseClasses
972
1017
  });
973
- 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, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort;
974
- var init_src2 = __esm({
975
- "packages/domain/compiler/src/index.ts"() {
1018
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1019
+ var init_parser = __esm({
1020
+ "packages/domain/compiler/src/parser/index.ts"() {
976
1021
  init_nativeBridge();
977
- transformSource = (source, opts) => {
1022
+ parseClasses = (raw) => {
978
1023
  const native = getNativeBridge();
979
- if (!native?.transformSource) {
980
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
981
- }
982
- const result = native.transformSource(source, opts);
983
- if (!result) {
984
- throw new Error("FATAL: transformSource returned null");
1024
+ if (!native?.parseClasses) {
1025
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
985
1026
  }
986
- return result;
1027
+ return native.parseClasses(raw) || [];
987
1028
  };
988
- hasTwUsage = (source) => {
989
- const native = getNativeBridge();
990
- if (!native?.hasTwUsage) {
991
- throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
992
- }
993
- return native.hasTwUsage(source);
994
- };
995
- isAlreadyTransformed = (source) => {
996
- const native = getNativeBridge();
997
- if (!native?.isAlreadyTransformed) {
998
- throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
999
- }
1000
- return native.isAlreadyTransformed(source);
1001
- };
1002
- shouldProcess = (source) => {
1003
- return hasTwUsage(source) && !isAlreadyTransformed(source);
1004
- };
1005
- compileCssFromClasses = (classes, prefix) => {
1006
- const native = getNativeBridge();
1007
- if (!native?.transformSource) {
1008
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1009
- }
1010
- const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
1011
- if (!result) {
1012
- throw new Error("FATAL: transformSource returned null");
1013
- }
1014
- return result;
1015
- };
1016
- buildStyleTag = (classes) => {
1017
- const result = compileCssFromClasses(classes);
1018
- return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
1019
- };
1020
- compileCssNative = (classes, prefix = null) => {
1021
- return compileCssFromClasses(classes, prefix);
1022
- };
1023
- generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1024
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
1025
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1026
- return result.css;
1027
- };
1028
- extractAllClasses = (source) => {
1029
+ extractAllClasses = (source) => {
1029
1030
  const native = getNativeBridge();
1030
1031
  if (!native?.extractAllClasses) {
1031
1032
  throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
@@ -1040,20 +1041,13 @@ var init_src2 = __esm({
1040
1041
  const result = native.extractClassesFromSource(source);
1041
1042
  return Array.isArray(result) ? result.join(" ") : String(result || "");
1042
1043
  };
1043
- astExtractClasses = (source, filename) => {
1044
+ astExtractClasses = (source, _filename) => {
1044
1045
  const native = getNativeBridge();
1045
1046
  if (!native?.extractClassesFromSource) {
1046
1047
  throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1047
1048
  }
1048
1049
  return native.extractClassesFromSource(source) || [];
1049
1050
  };
1050
- parseClasses = (raw) => {
1051
- const native = getNativeBridge();
1052
- if (!native?.parseClasses) {
1053
- throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1054
- }
1055
- return native.parseClasses(raw) || [];
1056
- };
1057
1051
  normalizeClasses = (raw) => {
1058
1052
  const result = normalizeAndDedupClasses(raw);
1059
1053
  return result?.normalized || "";
@@ -1070,85 +1064,6 @@ var init_src2 = __esm({
1070
1064
  const result = native.normalizeAndDedupClasses(raw);
1071
1065
  return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1072
1066
  };
1073
- eliminateDeadCss = (css, deadClasses) => {
1074
- const native = getNativeBridge();
1075
- if (!native?.processTailwindCssLightning) {
1076
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1077
- }
1078
- const deadSet = deadClasses;
1079
- const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
1080
- const m = rule.match(/\.([a-zA-Z0-9_-]+)/);
1081
- return !m || !deadSet.has(m[1]);
1082
- }).join("\n");
1083
- const compiled = native.processTailwindCssLightning(pruned);
1084
- return (compiled?.css ?? pruned).trim();
1085
- };
1086
- findDeadVariants = (variantConfig, usage) => {
1087
- const unused = [];
1088
- const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
1089
- for (const component of configs) {
1090
- const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
1091
- const variants = component.variants;
1092
- for (const [key, values] of Object.entries(variants)) {
1093
- for (const [value] of Object.entries(values)) {
1094
- if (!componentUsage.has(`${key}:${value}`)) {
1095
- unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
1096
- }
1097
- }
1098
- }
1099
- }
1100
- return {
1101
- unusedCount: unused.length,
1102
- unused
1103
- };
1104
- };
1105
- runElimination = (css, scanResult) => {
1106
- const native = getNativeBridge();
1107
- if (!native?.detectDeadCode) {
1108
- throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
1109
- }
1110
- const dead = native.detectDeadCode(
1111
- JSON.stringify(scanResult),
1112
- css
1113
- );
1114
- return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
1115
- };
1116
- optimizeCss = (css) => {
1117
- const native = getNativeBridge();
1118
- if (!native?.detectDeadCode) {
1119
- throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
1120
- }
1121
- const deadResult = native.detectDeadCode(
1122
- JSON.stringify({ uniqueClasses: [] }),
1123
- css
1124
- );
1125
- if (!native?.processTailwindCssLightning) {
1126
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1127
- }
1128
- const deadSet = new Set(deadResult.deadInCss ?? []);
1129
- const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
1130
- const selectorMatch = rule.match(/\.([a-zA-Z0-9_-]+)/);
1131
- if (!selectorMatch) return true;
1132
- return !deadSet.has(selectorMatch[1]);
1133
- }).join("\n");
1134
- const compiled = native.processTailwindCssLightning(pruned);
1135
- return (compiled?.css ?? pruned).trim();
1136
- };
1137
- scanProjectUsage = (dirs, cwd) => {
1138
- const path7 = __require("path");
1139
- const files = dirs.map((dir) => path7.resolve(cwd, dir));
1140
- const results = batchExtractClasses(files) || [];
1141
- const combined = {};
1142
- for (const result of results) {
1143
- if (result.ok && result.classes) {
1144
- for (const cls of result.classes) {
1145
- if (!combined[cls]) combined[cls] = {};
1146
- combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
1147
- }
1148
- }
1149
- }
1150
- return combined;
1151
- };
1152
1067
  extractComponentUsage = (source) => {
1153
1068
  const native = getNativeBridge();
1154
1069
  if (!native?.extractComponentUsage) {
@@ -1156,13 +1071,6 @@ var init_src2 = __esm({
1156
1071
  }
1157
1072
  return native.extractComponentUsage(source) || [];
1158
1073
  };
1159
- diffClassLists = (previous, current) => {
1160
- const native = getNativeBridge();
1161
- if (!native?.diffClassLists) {
1162
- throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1163
- }
1164
- return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1165
- };
1166
1074
  batchExtractClasses = (filePaths) => {
1167
1075
  const native = getNativeBridge();
1168
1076
  if (!native?.batchExtractClasses) {
@@ -1177,225 +1085,2356 @@ var init_src2 = __esm({
1177
1085
  }
1178
1086
  return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1179
1087
  };
1180
- hoistComponents = (source) => {
1088
+ diffClassLists = (previous, current) => {
1181
1089
  const native = getNativeBridge();
1182
- if (!native?.hoistComponents) {
1183
- throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
1090
+ if (!native?.diffClassLists) {
1091
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1184
1092
  }
1185
- return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
1093
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1186
1094
  };
1187
- compileVariantTable = (configJson) => {
1188
- const native = getNativeBridge();
1189
- if (!native?.compileVariantTable) {
1190
- throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
1191
- }
1192
- return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
1095
+ }
1096
+ });
1097
+
1098
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1099
+ function detectDeadCode(scanResultJson, css) {
1100
+ const native = getNativeBridge();
1101
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1102
+ return native.detectDeadCode(scanResultJson, css);
1103
+ }
1104
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1105
+ const native = getNativeBridge();
1106
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1107
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1108
+ }
1109
+ function analyzeClassesNative(filesJson, cwd, flags) {
1110
+ const native = getNativeBridge();
1111
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1112
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1113
+ }
1114
+ function analyzeRscNative(source, filename) {
1115
+ const native = getNativeBridge();
1116
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1117
+ return native.analyzeRsc(source, filename);
1118
+ }
1119
+ function optimizeCssNative(css) {
1120
+ const native = getNativeBridge();
1121
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1122
+ const result = native.processTailwindCssLightning(css);
1123
+ return {
1124
+ css: result.css,
1125
+ originalSize: css.length,
1126
+ optimizedSize: result.size_bytes,
1127
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1128
+ };
1129
+ }
1130
+ function processTailwindCssLightning(css) {
1131
+ const native = getNativeBridge();
1132
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1133
+ return native.processTailwindCssLightning(css);
1134
+ }
1135
+ function eliminateDeadCssNative(css, deadClasses) {
1136
+ const native = getNativeBridge();
1137
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1138
+ return native.eliminateDeadCss(css, deadClasses);
1139
+ }
1140
+ function hoistComponentsNative(source) {
1141
+ const native = getNativeBridge();
1142
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1143
+ return native.hoistComponents(source);
1144
+ }
1145
+ function compileVariantTableNative(configJson) {
1146
+ const native = getNativeBridge();
1147
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1148
+ return native.compileVariantTable(configJson);
1149
+ }
1150
+ function classifyAndSortClassesNative(classes) {
1151
+ const native = getNativeBridge();
1152
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1153
+ return native.classifyAndSortClasses(classes);
1154
+ }
1155
+ function mergeCssDeclarationsNative(cssChunks) {
1156
+ const native = getNativeBridge();
1157
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1158
+ return native.mergeCssDeclarations(cssChunks);
1159
+ }
1160
+ var init_analyzerNative = __esm({
1161
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1162
+ init_nativeBridge();
1163
+ }
1164
+ });
1165
+
1166
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1167
+ function resolveVariants(configJson) {
1168
+ const native = getNativeBridge();
1169
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1170
+ const resultJson = native.resolve_variants(configJson);
1171
+ try {
1172
+ return JSON.parse(resultJson);
1173
+ } catch {
1174
+ return {
1175
+ variants: [],
1176
+ supported: [],
1177
+ deprecated: [],
1178
+ conflicting: []
1193
1179
  };
1194
- compileVariants = (componentId, config) => {
1195
- return compileVariantTable(JSON.stringify({ componentId, ...config }));
1180
+ }
1181
+ }
1182
+ function validateThemeConfig(configJson) {
1183
+ const native = getNativeBridge();
1184
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1185
+ const resultJson = native.validate_variant_config(configJson);
1186
+ try {
1187
+ return JSON.parse(resultJson);
1188
+ } catch {
1189
+ return {
1190
+ is_valid: false,
1191
+ errors: ["Unable to parse configuration"],
1192
+ warnings: [],
1193
+ suggestions: []
1196
1194
  };
1197
- classifyAndSortClasses = (classes) => {
1198
- const native = getNativeBridge();
1199
- if (!native?.classifyAndSortClasses) {
1200
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1201
- }
1202
- return native.classifyAndSortClasses(classes) || [];
1195
+ }
1196
+ }
1197
+ function resolveCascade(baseThemeJson, overridesJson) {
1198
+ const native = getNativeBridge();
1199
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1200
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1201
+ try {
1202
+ return JSON.parse(resultJson);
1203
+ } catch {
1204
+ return {
1205
+ base_theme: {},
1206
+ user_overrides: {},
1207
+ merged_theme: {},
1208
+ conflict_resolutions: []
1203
1209
  };
1204
- mergeCssDeclarations = (cssChunks) => {
1205
- const native = getNativeBridge();
1206
- if (!native?.mergeCssDeclarations) {
1207
- throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
1208
- }
1209
- return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
1210
+ }
1211
+ }
1212
+ function resolveClassNames(classNames, themeJson) {
1213
+ const native = getNativeBridge();
1214
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1215
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1216
+ try {
1217
+ return JSON.parse(resultJson);
1218
+ } catch {
1219
+ return [];
1220
+ }
1221
+ }
1222
+ function resolveConflictGroup(groupName, themeJson) {
1223
+ const native = getNativeBridge();
1224
+ if (!native?.resolve_conflict_group)
1225
+ throw new Error("resolve_conflict_group not available");
1226
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1227
+ try {
1228
+ return JSON.parse(resultJson);
1229
+ } catch {
1230
+ return {
1231
+ group_name: groupName,
1232
+ conflicting_classes: [],
1233
+ description: "",
1234
+ resolution_strategy: "last-wins"
1210
1235
  };
1211
- analyzeClassUsage = (classes, scanResultJson, css) => {
1212
- const native = getNativeBridge();
1213
- if (!native?.analyzeClassUsage) {
1214
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
1215
- }
1216
- return native.analyzeClassUsage(classes, scanResultJson, css) || [];
1236
+ }
1237
+ }
1238
+ function resolveThemeValue(keyPath, themeJson) {
1239
+ const native = getNativeBridge();
1240
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1241
+ return native.resolve_theme_value(keyPath, themeJson);
1242
+ }
1243
+ function resolveSimpleVariants(configJson) {
1244
+ const native = getNativeBridge();
1245
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1246
+ const resultJson = native.resolve_simple_variants(configJson);
1247
+ try {
1248
+ return JSON.parse(resultJson);
1249
+ } catch {
1250
+ return [];
1251
+ }
1252
+ }
1253
+ var init_themeResolutionNative = __esm({
1254
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1255
+ init_nativeBridge();
1256
+ }
1257
+ });
1258
+
1259
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1260
+ function scanWorkspace(root, extensions) {
1261
+ const native = getNativeBridge();
1262
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1263
+ return native.scan_workspace(root, extensions);
1264
+ }
1265
+ function extractClassesFromSourceNative(source) {
1266
+ const native = getNativeBridge();
1267
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1268
+ return native.extract_classes_from_source(source);
1269
+ }
1270
+ function batchExtractClassesNative(filePaths) {
1271
+ const native = getNativeBridge();
1272
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1273
+ return native.batch_extract_classes(filePaths);
1274
+ }
1275
+ function checkAgainstSafelistNative(classes, safelist) {
1276
+ const native = getNativeBridge();
1277
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1278
+ return native.check_against_safelist(classes, safelist);
1279
+ }
1280
+ function scanFile(filePath) {
1281
+ const native = getNativeBridge();
1282
+ if (!native?.scan_file) throw new Error("scan_file not available");
1283
+ return native.scan_file(filePath);
1284
+ }
1285
+ function collectFiles(root, extensions) {
1286
+ const native = getNativeBridge();
1287
+ if (!native?.collect_files) throw new Error("collect_files not available");
1288
+ return native.collect_files(root, extensions);
1289
+ }
1290
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1291
+ const native = getNativeBridge();
1292
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1293
+ return native.walk_and_prefilter_source_files(root, extensions);
1294
+ }
1295
+ function generateSubComponentTypes(root, outputPath) {
1296
+ const native = getNativeBridge();
1297
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1298
+ return native.generate_sub_component_types(root, outputPath);
1299
+ }
1300
+ var init_scannerNative = __esm({
1301
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1302
+ init_nativeBridge();
1303
+ }
1304
+ });
1305
+
1306
+ // packages/domain/compiler/src/analyzer/index.ts
1307
+ var init_analyzer = __esm({
1308
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1309
+ init_analyzerNative();
1310
+ init_themeResolutionNative();
1311
+ init_scannerNative();
1312
+ }
1313
+ });
1314
+
1315
+ // packages/domain/compiler/src/cache/cacheNative.ts
1316
+ function getCacheStatistics() {
1317
+ const native = getNativeBridge();
1318
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1319
+ const statsJson = native.get_cache_statistics();
1320
+ try {
1321
+ return JSON.parse(statsJson);
1322
+ } catch {
1323
+ return {
1324
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1325
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
1326
+ compile_cache: { hits: 0, misses: 0, size: 0 },
1327
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
1328
+ overall_hit_rate: 0,
1329
+ total_memory_bytes: 0
1217
1330
  };
1218
- analyzeRsc = (source, filename) => {
1219
- const native = getNativeBridge();
1220
- if (!native?.analyzeRsc) {
1221
- throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
1222
- }
1223
- return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
1331
+ }
1332
+ }
1333
+ function clearAllCaches() {
1334
+ const native = getNativeBridge();
1335
+ if (!native?.clear_all_caches) return;
1336
+ try {
1337
+ native.clear_all_caches();
1338
+ } catch {
1339
+ }
1340
+ }
1341
+ function clearParseCache() {
1342
+ const native = getNativeBridge();
1343
+ if (!native?.clear_parse_cache) return;
1344
+ try {
1345
+ native.clear_parse_cache();
1346
+ } catch {
1347
+ }
1348
+ }
1349
+ function clearResolveCache() {
1350
+ const native = getNativeBridge();
1351
+ if (!native?.clear_resolve_cache) return;
1352
+ try {
1353
+ native.clear_resolve_cache();
1354
+ } catch {
1355
+ }
1356
+ }
1357
+ function clearCompileCache() {
1358
+ const native = getNativeBridge();
1359
+ if (!native?.clear_compile_cache) return;
1360
+ try {
1361
+ native.clear_compile_cache();
1362
+ } catch {
1363
+ }
1364
+ }
1365
+ function clearCssGenCache() {
1366
+ const native = getNativeBridge();
1367
+ if (!native?.clear_css_gen_cache) return;
1368
+ try {
1369
+ native.clear_css_gen_cache();
1370
+ } catch {
1371
+ }
1372
+ }
1373
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
1374
+ const native = getNativeBridge();
1375
+ if (!native?.get_cache_optimization_hints)
1376
+ throw new Error("get_cache_optimization_hints not available");
1377
+ const hintsJson = native.get_cache_optimization_hints(
1378
+ Math.min(100, Math.max(0, hitRatePercent)),
1379
+ Math.max(1, memoryUsedMb)
1380
+ );
1381
+ try {
1382
+ return JSON.parse(hintsJson);
1383
+ } catch {
1384
+ return {
1385
+ current_strategy: "unknown",
1386
+ recommended_strategy: "increase_size",
1387
+ estimated_improvement_percent: 0,
1388
+ suggested_memory_mb: 256,
1389
+ notes: ["Unable to analyze cache statistics"]
1224
1390
  };
1225
- analyzeFile = (source, filename) => {
1226
- const rsc = analyzeRsc(source, filename);
1227
- return {
1228
- isServer: rsc?.isServer ?? true,
1229
- needsClientDirective: rsc?.needsClientDirective ?? false,
1230
- clientReasons: rsc?.clientReasons ?? [],
1231
- interactiveClasses: [],
1232
- canStaticResolveVariants: true
1233
- };
1391
+ }
1392
+ }
1393
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
1394
+ const native = getNativeBridge();
1395
+ if (!native?.estimate_optimal_cache_config_native)
1396
+ throw new Error("estimate_optimal_cache_config_native not available");
1397
+ const configJson = native.estimate_optimal_cache_config_native(
1398
+ Math.max(64, totalBudgetMb),
1399
+ workloadType
1400
+ );
1401
+ try {
1402
+ return JSON.parse(configJson);
1403
+ } catch {
1404
+ return {
1405
+ parse_cache_size: 128,
1406
+ resolve_cache_size: 64,
1407
+ compile_cache_size: 256,
1408
+ css_gen_cache_size: 128,
1409
+ recommended_eviction_policy: "lru",
1410
+ ttl_seconds: 3600,
1411
+ expected_hit_rate_percent: 75
1412
+ };
1413
+ }
1414
+ }
1415
+ function cacheRead(cachePath) {
1416
+ const native = getNativeBridge();
1417
+ if (!native?.cache_read) throw new Error("cache_read not available");
1418
+ const result = native.cache_read(cachePath);
1419
+ try {
1420
+ return JSON.parse(result.entries_json || "[]");
1421
+ } catch {
1422
+ return [];
1423
+ }
1424
+ }
1425
+ function cacheWrite(cachePath, entries) {
1426
+ const native = getNativeBridge();
1427
+ if (!native?.cache_write) throw new Error("cache_write not available");
1428
+ try {
1429
+ const result = native.cache_write(
1430
+ cachePath,
1431
+ entries.map((e) => ({
1432
+ file: e.file,
1433
+ content_hash: e.contentHash,
1434
+ classes: e.classes,
1435
+ mtime_ms: e.mtimeMs,
1436
+ size_bytes: e.sizeBytes
1437
+ }))
1438
+ );
1439
+ return typeof result === "boolean" ? result : result === true;
1440
+ } catch {
1441
+ return false;
1442
+ }
1443
+ }
1444
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
1445
+ const native = getNativeBridge();
1446
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
1447
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
1448
+ }
1449
+ var init_cacheNative = __esm({
1450
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
1451
+ init_nativeBridge();
1452
+ }
1453
+ });
1454
+
1455
+ // packages/domain/compiler/src/cache/index.ts
1456
+ var init_cache = __esm({
1457
+ "packages/domain/compiler/src/cache/index.ts"() {
1458
+ init_cacheNative();
1459
+ }
1460
+ });
1461
+
1462
+ // packages/domain/compiler/src/redis/redisNative.ts
1463
+ function redisPing() {
1464
+ const native = getNativeBridge();
1465
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
1466
+ return native.redis_ping();
1467
+ }
1468
+ function redisGet(key) {
1469
+ const native = getNativeBridge();
1470
+ if (!native?.redis_get) throw new Error("redis_get not available");
1471
+ const result = native.redis_get(key);
1472
+ return result === "nil" ? null : result;
1473
+ }
1474
+ function redisSet(key, value, ttl_seconds) {
1475
+ const native = getNativeBridge();
1476
+ if (!native?.redis_set) throw new Error("redis_set not available");
1477
+ return native.redis_set(key, value, ttl_seconds);
1478
+ }
1479
+ function redisDelete(key) {
1480
+ const native = getNativeBridge();
1481
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
1482
+ return native.redis_delete(key);
1483
+ }
1484
+ function redisExists(key) {
1485
+ const native = getNativeBridge();
1486
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
1487
+ return native.redis_exists(key);
1488
+ }
1489
+ function redisMget(keys) {
1490
+ const native = getNativeBridge();
1491
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
1492
+ const result = native.redis_mget(keys);
1493
+ try {
1494
+ return JSON.parse(result);
1495
+ } catch {
1496
+ return keys.map(() => null);
1497
+ }
1498
+ }
1499
+ function redisMset(pairs) {
1500
+ const native = getNativeBridge();
1501
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
1502
+ return native.redis_mset(pairs);
1503
+ }
1504
+ function redisFlushDb() {
1505
+ const native = getNativeBridge();
1506
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
1507
+ return native.redis_flush_db();
1508
+ }
1509
+ function redisFlushAll() {
1510
+ const native = getNativeBridge();
1511
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
1512
+ return native.redis_flush_all();
1513
+ }
1514
+ function redisPoolConnect(host, port, pool_size) {
1515
+ const native = getNativeBridge();
1516
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
1517
+ return native.redis_pool_connect(host, port, pool_size);
1518
+ }
1519
+ function redisPoolStats() {
1520
+ const native = getNativeBridge();
1521
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
1522
+ const result = native.redis_pool_stats();
1523
+ try {
1524
+ return JSON.parse(result);
1525
+ } catch {
1526
+ return {
1527
+ connected_count: 0,
1528
+ idle_count: 0,
1529
+ waiting_count: 0,
1530
+ total_requests: 0,
1531
+ total_errors: 0
1532
+ };
1533
+ }
1534
+ }
1535
+ function redisPoolReconnect() {
1536
+ const native = getNativeBridge();
1537
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
1538
+ return native.redis_pool_reconnect();
1539
+ }
1540
+ function redisEnableCluster(initial_nodes) {
1541
+ const native = getNativeBridge();
1542
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
1543
+ const result = native.redis_enable_cluster(initial_nodes);
1544
+ try {
1545
+ return JSON.parse(result);
1546
+ } catch {
1547
+ return {
1548
+ enabled: false,
1549
+ cluster_state: "error",
1550
+ nodes: [],
1551
+ slots_assigned: 0,
1552
+ slots_ok: 0,
1553
+ slots_fail: 0
1554
+ };
1555
+ }
1556
+ }
1557
+ function redisDisableCluster() {
1558
+ const native = getNativeBridge();
1559
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
1560
+ return native.redis_disable_cluster();
1561
+ }
1562
+ function redisClusterStatus() {
1563
+ const native = getNativeBridge();
1564
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
1565
+ const result = native.redis_cluster_status();
1566
+ try {
1567
+ return JSON.parse(result);
1568
+ } catch {
1569
+ return {
1570
+ enabled: false,
1571
+ cluster_state: "unknown",
1572
+ nodes: [],
1573
+ slots_assigned: 0,
1574
+ slots_ok: 0,
1575
+ slots_fail: 0
1576
+ };
1577
+ }
1578
+ }
1579
+ function redisSubscribe(channel) {
1580
+ const native = getNativeBridge();
1581
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
1582
+ return native.redis_subscribe(channel);
1583
+ }
1584
+ function redisPublish(channel, message) {
1585
+ const native = getNativeBridge();
1586
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
1587
+ return native.redis_publish(channel, message);
1588
+ }
1589
+ function redisExpirationSet(key, ttl_seconds) {
1590
+ const native = getNativeBridge();
1591
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
1592
+ return native.redis_expiration_set(key, ttl_seconds);
1593
+ }
1594
+ function redisExpirationGet(key) {
1595
+ const native = getNativeBridge();
1596
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
1597
+ const result = native.redis_expiration_get(key);
1598
+ try {
1599
+ return JSON.parse(result);
1600
+ } catch {
1601
+ return {
1602
+ key,
1603
+ ttl_seconds: -1,
1604
+ expiration_timestamp: 0,
1605
+ is_persistent: true
1606
+ };
1607
+ }
1608
+ }
1609
+ function redisInfo() {
1610
+ const native = getNativeBridge();
1611
+ if (!native?.redis_info) throw new Error("redis_info not available");
1612
+ return native.redis_info();
1613
+ }
1614
+ function redisMonitor() {
1615
+ const native = getNativeBridge();
1616
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
1617
+ return native.redis_monitor();
1618
+ }
1619
+ function redisCacheSize() {
1620
+ const native = getNativeBridge();
1621
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
1622
+ return native.redis_cache_size();
1623
+ }
1624
+ function redisCacheKeyCount() {
1625
+ const native = getNativeBridge();
1626
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
1627
+ return native.redis_cache_key_count();
1628
+ }
1629
+ function redisCacheClear() {
1630
+ const native = getNativeBridge();
1631
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
1632
+ return native.redis_cache_clear();
1633
+ }
1634
+ function redisCacheHitRate() {
1635
+ const native = getNativeBridge();
1636
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
1637
+ return native.redis_cache_hit_rate();
1638
+ }
1639
+ function redisEnablePersistence(mode) {
1640
+ const native = getNativeBridge();
1641
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
1642
+ return native.redis_enable_persistence(mode);
1643
+ }
1644
+ function redisDisablePersistence() {
1645
+ const native = getNativeBridge();
1646
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
1647
+ return native.redis_disable_persistence();
1648
+ }
1649
+ function redisSnapshot() {
1650
+ const native = getNativeBridge();
1651
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
1652
+ return native.redis_snapshot();
1653
+ }
1654
+ function redisMemoryStats() {
1655
+ const native = getNativeBridge();
1656
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
1657
+ return native.redis_memory_stats();
1658
+ }
1659
+ function redisOptimizeMemory() {
1660
+ const native = getNativeBridge();
1661
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
1662
+ return native.redis_optimize_memory();
1663
+ }
1664
+ function redisSetEvictionPolicy(policy) {
1665
+ const native = getNativeBridge();
1666
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
1667
+ return native.redis_set_eviction_policy(policy);
1668
+ }
1669
+ function redisGetEvictionPolicy() {
1670
+ const native = getNativeBridge();
1671
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
1672
+ return native.redis_get_eviction_policy();
1673
+ }
1674
+ function redisReplicate(target_host, target_port) {
1675
+ const native = getNativeBridge();
1676
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
1677
+ return native.redis_replicate(target_host, target_port);
1678
+ }
1679
+ function redisReplicationStatus() {
1680
+ const native = getNativeBridge();
1681
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
1682
+ return native.redis_replication_status();
1683
+ }
1684
+ function redisCacheSync(peers) {
1685
+ const native = getNativeBridge();
1686
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
1687
+ return native.redis_cache_sync(peers);
1688
+ }
1689
+ function redisEnableCacheWarming(key_pattern) {
1690
+ const native = getNativeBridge();
1691
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
1692
+ return native.redis_enable_cache_warming(key_pattern);
1693
+ }
1694
+ function redisDisableCacheWarming() {
1695
+ const native = getNativeBridge();
1696
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
1697
+ return native.redis_disable_cache_warming();
1698
+ }
1699
+ function redisDiagnose() {
1700
+ const native = getNativeBridge();
1701
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
1702
+ return native.redis_diagnose();
1703
+ }
1704
+ var init_redisNative = __esm({
1705
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
1706
+ init_nativeBridge();
1707
+ }
1708
+ });
1709
+
1710
+ // packages/domain/compiler/src/redis/index.ts
1711
+ var init_redis = __esm({
1712
+ "packages/domain/compiler/src/redis/index.ts"() {
1713
+ init_redisNative();
1714
+ }
1715
+ });
1716
+
1717
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
1718
+ function startWatch(root_path, patterns) {
1719
+ const native = getNativeBridge();
1720
+ if (!native?.start_watch) throw new Error("start_watch not available");
1721
+ return native.start_watch(root_path, patterns);
1722
+ }
1723
+ function pollWatchEvents(handle, timeout_ms) {
1724
+ const native = getNativeBridge();
1725
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
1726
+ const result = native.poll_watch_events(handle, timeout_ms);
1727
+ try {
1728
+ return JSON.parse(result);
1729
+ } catch {
1730
+ return [];
1731
+ }
1732
+ }
1733
+ function stopWatch(handle) {
1734
+ const native = getNativeBridge();
1735
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
1736
+ return native.stop_watch(handle);
1737
+ }
1738
+ function watchAddPattern(handle, pattern) {
1739
+ const native = getNativeBridge();
1740
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
1741
+ return native.watch_add_pattern(handle, pattern);
1742
+ }
1743
+ function watchRemovePattern(handle, pattern) {
1744
+ const native = getNativeBridge();
1745
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
1746
+ return native.watch_remove_pattern(handle, pattern);
1747
+ }
1748
+ function watchGetActiveHandles() {
1749
+ const native = getNativeBridge();
1750
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
1751
+ const result = native.watch_get_active_handles();
1752
+ try {
1753
+ return JSON.parse(result);
1754
+ } catch {
1755
+ return [];
1756
+ }
1757
+ }
1758
+ function watchClearAll() {
1759
+ const native = getNativeBridge();
1760
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
1761
+ return native.watch_clear_all();
1762
+ }
1763
+ function watchEventTypeToString(event_type_code) {
1764
+ const native = getNativeBridge();
1765
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
1766
+ return native.watch_event_type_to_string(event_type_code);
1767
+ }
1768
+ function isWatchRunning(handle) {
1769
+ const native = getNativeBridge();
1770
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
1771
+ return native.is_watch_running(handle);
1772
+ }
1773
+ function getWatchStats() {
1774
+ const native = getNativeBridge();
1775
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
1776
+ const result = native.get_watch_stats();
1777
+ try {
1778
+ return JSON.parse(result);
1779
+ } catch {
1780
+ return {
1781
+ active_watchers: 0,
1782
+ total_events: 0,
1783
+ events_this_second: 0,
1784
+ average_latency_ms: 0,
1785
+ largest_batch_size: 0
1786
+ };
1787
+ }
1788
+ }
1789
+ function watchPause(handle) {
1790
+ const native = getNativeBridge();
1791
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
1792
+ return native.watch_pause(handle);
1793
+ }
1794
+ function watchResume(handle) {
1795
+ const native = getNativeBridge();
1796
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
1797
+ return native.watch_resume(handle);
1798
+ }
1799
+ function scanCacheOptimizations() {
1800
+ const native = getNativeBridge();
1801
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
1802
+ return native.scan_cache_optimizations();
1803
+ }
1804
+ function getPluginHooks() {
1805
+ const native = getNativeBridge();
1806
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
1807
+ const result = native.get_plugin_hooks();
1808
+ try {
1809
+ return JSON.parse(result);
1810
+ } catch {
1811
+ return [];
1812
+ }
1813
+ }
1814
+ function registerPluginHook(hook_name, handler_id) {
1815
+ const native = getNativeBridge();
1816
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
1817
+ return native.register_plugin_hook(hook_name, handler_id);
1818
+ }
1819
+ function unregisterPluginHook(hook_name, handler_id) {
1820
+ const native = getNativeBridge();
1821
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
1822
+ return native.unregister_plugin_hook(hook_name, handler_id);
1823
+ }
1824
+ function emitPluginHook(hook_name, data_json) {
1825
+ const native = getNativeBridge();
1826
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
1827
+ return native.emit_plugin_hook(hook_name, data_json);
1828
+ }
1829
+ function getCompilationMetrics() {
1830
+ const native = getNativeBridge();
1831
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
1832
+ return native.get_compilation_metrics();
1833
+ }
1834
+ function resetCompilationMetrics() {
1835
+ const native = getNativeBridge();
1836
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
1837
+ return native.reset_compilation_metrics();
1838
+ }
1839
+ function validateCssOutput(css) {
1840
+ const native = getNativeBridge();
1841
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
1842
+ return native.validate_css_output(css);
1843
+ }
1844
+ function getCompilerDiagnostics() {
1845
+ const native = getNativeBridge();
1846
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
1847
+ return native.get_compiler_diagnostics();
1848
+ }
1849
+ var init_watchSystemNative = __esm({
1850
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1851
+ init_nativeBridge();
1852
+ }
1853
+ });
1854
+
1855
+ // packages/domain/compiler/src/watch/index.ts
1856
+ var init_watch = __esm({
1857
+ "packages/domain/compiler/src/watch/index.ts"() {
1858
+ init_watchSystemNative();
1859
+ }
1860
+ });
1861
+
1862
+ // packages/domain/compiler/src/index.ts
1863
+ var src_exports = {};
1864
+ __export(src_exports, {
1865
+ BucketEngine: () => BucketEngine,
1866
+ IncrementalEngine: () => IncrementalEngine,
1867
+ adaptNativeResult: () => adaptNativeResult,
1868
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
1869
+ analyzeClasses: () => analyzeClasses,
1870
+ analyzeClassesNative: () => analyzeClassesNative,
1871
+ analyzeFile: () => analyzeFile,
1872
+ analyzeRscNative: () => analyzeRscNative,
1873
+ analyzeVariantUsage: () => analyzeVariantUsage,
1874
+ astExtractClasses: () => astExtractClasses,
1875
+ atomicRegistrySize: () => atomicRegistrySize,
1876
+ batchExtractClasses: () => batchExtractClasses,
1877
+ batchExtractClassesNative: () => batchExtractClassesNative,
1878
+ bucketSort: () => bucketSort,
1879
+ buildStyleTag: () => buildStyleTag,
1880
+ cachePriority: () => cachePriority,
1881
+ cacheRead: () => cacheRead,
1882
+ cacheWrite: () => cacheWrite,
1883
+ checkAgainstSafelist: () => checkAgainstSafelist,
1884
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
1885
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
1886
+ classifyNode: () => classifyNode,
1887
+ clearAllCaches: () => clearAllCaches,
1888
+ clearAtomicRegistry: () => clearAtomicRegistry,
1889
+ clearCompileCache: () => clearCompileCache,
1890
+ clearCssGenCache: () => clearCssGenCache,
1891
+ clearParseCache: () => clearParseCache,
1892
+ clearResolveCache: () => clearResolveCache,
1893
+ clearThemeCache: () => clearThemeCache,
1894
+ collectFiles: () => collectFiles,
1895
+ compileAnimation: () => compileAnimation,
1896
+ compileClass: () => compileClass,
1897
+ compileClasses: () => compileClasses,
1898
+ compileCssFromClasses: () => compileCssFromClasses,
1899
+ compileCssLightning: () => compileCssLightning,
1900
+ compileCssNative2: () => compileCssNative2,
1901
+ compileKeyframes: () => compileKeyframes,
1902
+ compileTheme: () => compileTheme,
1903
+ compileToCss: () => compileToCss,
1904
+ compileToCssBatch: () => compileToCssBatch,
1905
+ compileVariantTableNative: () => compileVariantTableNative,
1906
+ computeIncrementalDiff: () => computeIncrementalDiff,
1907
+ createFingerprint: () => createFingerprint,
1908
+ detectConflicts: () => detectConflicts,
1909
+ detectDeadCode: () => detectDeadCode,
1910
+ diffClassLists: () => diffClassLists,
1911
+ eliminateDeadCss: () => eliminateDeadCss,
1912
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
1913
+ emitPluginHook: () => emitPluginHook,
1914
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
1915
+ extractAllClasses: () => extractAllClasses,
1916
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
1917
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
1918
+ extractClassesFromSource: () => extractClassesFromSource,
1919
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
1920
+ extractComponentUsage: () => extractComponentUsage,
1921
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
1922
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
1923
+ extractTwStateConfigs: () => extractTwStateConfigs,
1924
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
1925
+ fileToRoute: () => fileToRoute,
1926
+ findDeadVariants: () => findDeadVariants,
1927
+ generateAtomicCss: () => generateAtomicCss,
1928
+ generateCssForClasses: () => generateCssForClasses,
1929
+ generateCssNative: () => generateCssNative,
1930
+ generateSafelist: () => generateSafelist,
1931
+ generateStaticStateCss: () => generateStaticStateCss,
1932
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
1933
+ generateSubComponentTypes: () => generateSubComponentTypes,
1934
+ getAllRoutes: () => getAllRoutes,
1935
+ getBucketEngine: () => getBucketEngine,
1936
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
1937
+ getCacheStatistics: () => getCacheStatistics,
1938
+ getCacheStats: () => getCacheStats,
1939
+ getCompilationMetrics: () => getCompilationMetrics,
1940
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
1941
+ getContentPaths: () => getContentPaths,
1942
+ getIncrementalEngine: () => getIncrementalEngine,
1943
+ getNativeBridge: () => getNativeBridge,
1944
+ getPluginHooks: () => getPluginHooks,
1945
+ getRouteClasses: () => getRouteClasses,
1946
+ getWatchStats: () => getWatchStats,
1947
+ hasTwUsage: () => hasTwUsage,
1948
+ hashContent: () => hashContent,
1949
+ hoistComponentsNative: () => hoistComponentsNative,
1950
+ idRegistryActiveCount: () => idRegistryActiveCount,
1951
+ idRegistryCreate: () => idRegistryCreate,
1952
+ idRegistryDestroy: () => idRegistryDestroy,
1953
+ idRegistryExport: () => idRegistryExport,
1954
+ idRegistryGenerate: () => idRegistryGenerate,
1955
+ idRegistryImport: () => idRegistryImport,
1956
+ idRegistryLookup: () => idRegistryLookup,
1957
+ idRegistryNext: () => idRegistryNext,
1958
+ idRegistryReset: () => idRegistryReset,
1959
+ idRegistrySnapshot: () => idRegistrySnapshot,
1960
+ injectClientDirective: () => injectClientDirective,
1961
+ injectServerOnlyComment: () => injectServerOnlyComment,
1962
+ injectStateHash: () => injectStateHash,
1963
+ isAlreadyTransformed: () => isAlreadyTransformed,
1964
+ isWatchRunning: () => isWatchRunning,
1965
+ layoutClassesToCss: () => layoutClassesToCss,
1966
+ loadSafelist: () => loadSafelist,
1967
+ loadTailwindConfig: () => loadTailwindConfig,
1968
+ mergeClassesStatic: () => mergeClassesStatic,
1969
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
1970
+ minifyCss: () => minifyCss,
1971
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1972
+ normalizeClasses: () => normalizeClasses,
1973
+ optimizeCssNative: () => optimizeCssNative,
1974
+ parseAtomicClass: () => parseAtomicClass,
1975
+ parseClasses: () => parseClasses,
1976
+ pollWatchEvents: () => pollWatchEvents,
1977
+ processFileChange: () => processFileChange,
1978
+ processTailwindCssLightning: () => processTailwindCssLightning,
1979
+ propertyIdToString: () => propertyIdToString,
1980
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
1981
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
1982
+ redisCacheClear: () => redisCacheClear,
1983
+ redisCacheHitRate: () => redisCacheHitRate,
1984
+ redisCacheKeyCount: () => redisCacheKeyCount,
1985
+ redisCacheSize: () => redisCacheSize,
1986
+ redisCacheSync: () => redisCacheSync,
1987
+ redisClusterStatus: () => redisClusterStatus,
1988
+ redisDelete: () => redisDelete,
1989
+ redisDiagnose: () => redisDiagnose,
1990
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
1991
+ redisDisableCluster: () => redisDisableCluster,
1992
+ redisDisablePersistence: () => redisDisablePersistence,
1993
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
1994
+ redisEnableCluster: () => redisEnableCluster,
1995
+ redisEnablePersistence: () => redisEnablePersistence,
1996
+ redisExists: () => redisExists,
1997
+ redisExpirationGet: () => redisExpirationGet,
1998
+ redisExpirationSet: () => redisExpirationSet,
1999
+ redisFlushAll: () => redisFlushAll,
2000
+ redisFlushDb: () => redisFlushDb,
2001
+ redisGet: () => redisGet,
2002
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2003
+ redisInfo: () => redisInfo,
2004
+ redisMemoryStats: () => redisMemoryStats,
2005
+ redisMget: () => redisMget,
2006
+ redisMonitor: () => redisMonitor,
2007
+ redisMset: () => redisMset,
2008
+ redisOptimizeMemory: () => redisOptimizeMemory,
2009
+ redisPing: () => redisPing,
2010
+ redisPoolConnect: () => redisPoolConnect,
2011
+ redisPoolReconnect: () => redisPoolReconnect,
2012
+ redisPoolStats: () => redisPoolStats,
2013
+ redisPublish: () => redisPublish,
2014
+ redisReplicate: () => redisReplicate,
2015
+ redisReplicationStatus: () => redisReplicationStatus,
2016
+ redisSet: () => redisSet,
2017
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2018
+ redisSnapshot: () => redisSnapshot,
2019
+ redisSubscribe: () => redisSubscribe,
2020
+ registerFileClasses: () => registerFileClasses,
2021
+ registerGlobalClasses: () => registerGlobalClasses,
2022
+ registerPluginHook: () => registerPluginHook,
2023
+ registerPropertyName: () => registerPropertyName,
2024
+ registerValueName: () => registerValueName,
2025
+ resetBucketEngine: () => resetBucketEngine,
2026
+ resetCompilationMetrics: () => resetCompilationMetrics,
2027
+ resetIncrementalEngine: () => resetIncrementalEngine,
2028
+ resetNativeBridgeCache: () => resetNativeBridgeCache,
2029
+ resolveCascade: () => resolveCascade,
2030
+ resolveClassNames: () => resolveClassNames,
2031
+ resolveConflictGroup: () => resolveConflictGroup,
2032
+ resolveSimpleVariants: () => resolveSimpleVariants,
2033
+ resolveThemeValue: () => resolveThemeValue,
2034
+ resolveVariants: () => resolveVariants,
2035
+ reverseLookupProperty: () => reverseLookupProperty,
2036
+ reverseLookupValue: () => reverseLookupValue,
2037
+ runCssPipeline: () => runCssPipeline,
2038
+ runElimination: () => runElimination,
2039
+ runLoaderTransform: () => runLoaderTransform,
2040
+ scanCacheOptimizations: () => scanCacheOptimizations,
2041
+ scanFile: () => scanFile,
2042
+ scanFileNative: () => scanFileNative,
2043
+ scanFilesBatchNative: () => scanFilesBatchNative,
2044
+ scanProjectUsage: () => scanProjectUsage,
2045
+ scanWorkspace: () => scanWorkspace,
2046
+ shouldProcess: () => shouldProcess,
2047
+ shouldSkipFile: () => shouldSkipFile,
2048
+ startWatch: () => startWatch,
2049
+ stopWatch: () => stopWatch,
2050
+ toAtomicClasses: () => toAtomicClasses,
2051
+ transformSource: () => transformSource,
2052
+ twMerge: () => twMerge,
2053
+ twMergeMany: () => twMergeMany,
2054
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2055
+ twMergeRaw: () => twMergeRaw,
2056
+ twMergeWithSeparator: () => twMergeWithSeparator,
2057
+ unregisterPluginHook: () => unregisterPluginHook,
2058
+ validateCssOutput: () => validateCssOutput,
2059
+ validateThemeConfig: () => validateThemeConfig,
2060
+ valueIdToString: () => valueIdToString,
2061
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2062
+ watchAddPattern: () => watchAddPattern,
2063
+ watchClearAll: () => watchClearAll,
2064
+ watchEventTypeToString: () => watchEventTypeToString,
2065
+ watchGetActiveHandles: () => watchGetActiveHandles,
2066
+ watchPause: () => watchPause,
2067
+ watchRemovePattern: () => watchRemovePattern,
2068
+ watchResume: () => watchResume
2069
+ });
2070
+ function _layoutClassesToCss(classes) {
2071
+ const native = getNativeBridge();
2072
+ if (!native?.layoutClassesToCss) {
2073
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
2074
+ }
2075
+ return native.layoutClassesToCss(classes);
2076
+ }
2077
+ function _hashContainer(tag, containerJson, name) {
2078
+ const sortedKey = tag + (name ?? "") + containerJson;
2079
+ const native = getNativeBridge();
2080
+ if (!native?.hashContent) {
2081
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
2082
+ }
2083
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
2084
+ }
2085
+ function extractContainerCssFromSource(source) {
2086
+ const native = getNativeBridge();
2087
+ if (!native?.extractTwContainerConfigs) {
2088
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
2089
+ }
2090
+ const configs = native.extractTwContainerConfigs(source);
2091
+ const rules = [];
2092
+ for (const cfg of configs) {
2093
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
2094
+ for (const { key, classes } of cfg.breakpoints) {
2095
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
2096
+ const css = _layoutClassesToCss(classes);
2097
+ if (!css) continue;
2098
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
2099
+ rules.push(`${query}{.${id}{${css}}}`);
2100
+ }
2101
+ }
2102
+ return rules.join("\n");
2103
+ }
2104
+ 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, BucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
2105
+ var init_src = __esm({
2106
+ "packages/domain/compiler/src/index.ts"() {
2107
+ init_nativeBridge();
2108
+ init_compiler();
2109
+ init_parser();
2110
+ init_analyzer();
2111
+ init_cache();
2112
+ init_redis();
2113
+ init_watch();
2114
+ transformSource = (source, opts) => {
2115
+ const native = getNativeBridge();
2116
+ if (!native?.transformSource) {
2117
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2118
+ }
2119
+ const result = native.transformSource(source, opts);
2120
+ if (!result) {
2121
+ throw new Error("FATAL: transformSource returned null");
2122
+ }
2123
+ return result;
2124
+ };
2125
+ hasTwUsage = (source) => {
2126
+ const native = getNativeBridge();
2127
+ if (!native?.hasTwUsage) {
2128
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
2129
+ }
2130
+ return native.hasTwUsage(source);
2131
+ };
2132
+ isAlreadyTransformed = (source) => {
2133
+ const native = getNativeBridge();
2134
+ if (!native?.isAlreadyTransformed) {
2135
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
2136
+ }
2137
+ return native.isAlreadyTransformed(source);
2138
+ };
2139
+ shouldProcess = (source) => {
2140
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
2141
+ };
2142
+ compileCssFromClasses = (classes, prefix) => {
2143
+ const native = getNativeBridge();
2144
+ if (!native?.transformSource) {
2145
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2146
+ }
2147
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
2148
+ if (!result) {
2149
+ throw new Error("FATAL: transformSource returned null");
2150
+ }
2151
+ return result;
2152
+ };
2153
+ buildStyleTag = (classes) => {
2154
+ const result = compileCssFromClasses(classes);
2155
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2156
+ };
2157
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2158
+ try {
2159
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2160
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2161
+ return result.css;
2162
+ } catch {
2163
+ const native = getNativeBridge();
2164
+ if (!native?.transformSource) {
2165
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2166
+ }
2167
+ const result = native.transformSource(classes.join(" "), {});
2168
+ return result?.code || "";
2169
+ }
2170
+ };
2171
+ eliminateDeadCss = (css, deadClasses) => {
2172
+ const native = getNativeBridge();
2173
+ if (!native?.eliminateDeadCss) {
2174
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
2175
+ }
2176
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
2177
+ };
2178
+ findDeadVariants = (variantConfig, usage) => {
2179
+ const unused = [];
2180
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
2181
+ for (const component of configs) {
2182
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
2183
+ const variants = component.variants;
2184
+ for (const [key, values] of Object.entries(variants)) {
2185
+ for (const [value] of Object.entries(values)) {
2186
+ if (!componentUsage.has(`${key}:${value}`)) {
2187
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
2188
+ }
2189
+ }
2190
+ }
2191
+ }
2192
+ return { unusedCount: unused.length, unused };
2193
+ };
2194
+ runElimination = (css, scanResult) => {
2195
+ const native = getNativeBridge();
2196
+ if (!native?.detectDeadCode) {
2197
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
2198
+ }
2199
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2200
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2201
+ };
2202
+ scanProjectUsage = (dirs, cwd) => {
2203
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2204
+ const files = dirs.map((dir) => path10__namespace.default.resolve(cwd, dir));
2205
+ const results = batchExtractClasses2(files) || [];
2206
+ const combined = {};
2207
+ for (const result of results) {
2208
+ if (result.ok && result.classes) {
2209
+ for (const cls of result.classes) {
2210
+ if (!combined[cls]) combined[cls] = {};
2211
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
2212
+ }
2213
+ }
2214
+ }
2215
+ return combined;
2216
+ };
2217
+ generateSafelist = (scanDirs, outputPath, cwd) => {
2218
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2219
+ const allClasses = Object.keys(classes).sort();
2220
+ if (outputPath) {
2221
+ fs9__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2222
+ }
2223
+ return allClasses;
2224
+ };
2225
+ loadSafelist = (safelistPath) => {
2226
+ try {
2227
+ const content = fs9__namespace.default.readFileSync(safelistPath, "utf-8");
2228
+ return JSON.parse(content);
2229
+ } catch {
2230
+ return [];
2231
+ }
2232
+ };
2233
+ loadTailwindConfig = (cwd = process.cwd()) => {
2234
+ const configFiles = [
2235
+ "tailwind.config.ts",
2236
+ "tailwind.config.js",
2237
+ "tailwind.config.mjs",
2238
+ "tailwind.config.cjs"
2239
+ ];
2240
+ for (const file of configFiles) {
2241
+ const fullPath = path10__namespace.default.join(cwd, file);
2242
+ if (fs9__namespace.default.existsSync(fullPath)) {
2243
+ const mod = __require(fullPath);
2244
+ return mod.default || mod;
2245
+ }
2246
+ }
2247
+ return {};
2248
+ };
2249
+ getContentPaths = (cwd = process.cwd()) => {
2250
+ return {
2251
+ content: [
2252
+ path10__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2253
+ path10__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2254
+ path10__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2255
+ ]
2256
+ };
2257
+ };
2258
+ _CONTAINER_BREAKPOINTS = {
2259
+ xs: "240px",
2260
+ sm: "320px",
2261
+ md: "640px",
2262
+ lg: "1024px",
2263
+ xl: "1280px",
2264
+ "2xl": "1536px"
2265
+ };
2266
+ runLoaderTransform = (ctx) => {
2267
+ const { filepath, source, options } = ctx;
2268
+ const result = transformSource(source, { filename: filepath, ...options });
2269
+ let staticCss;
2270
+ try {
2271
+ const cssChunks = [];
2272
+ const stateRules = extractAndGenerateStateCss(source, filepath);
2273
+ if (stateRules.length > 0) {
2274
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
2275
+ }
2276
+ const containerCss = extractContainerCssFromSource(source);
2277
+ if (containerCss) cssChunks.push(containerCss);
2278
+ const combined = cssChunks.join("\n").trim();
2279
+ if (combined) staticCss = combined;
2280
+ } catch (err) {
2281
+ console.debug("Static CSS extraction warning:", err);
2282
+ }
2283
+ return {
2284
+ code: result?.code || "",
2285
+ changed: result?.changed || false,
2286
+ classes: result?.classes || [],
2287
+ staticCss
2288
+ };
2289
+ };
2290
+ shouldSkipFile = (filepath) => {
2291
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
2292
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
2293
+ for (const p of SKIP_PATHS) {
2294
+ if (filepath.includes(p)) return true;
2295
+ }
2296
+ for (const ext of skipExtensions) {
2297
+ if (filepath.endsWith(ext)) return true;
2298
+ }
2299
+ return false;
2300
+ };
2301
+ fileToRoute = (filepath) => {
2302
+ const normalized = filepath.replace(/\\/g, "/");
2303
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
2304
+ return "__global";
2305
+ }
2306
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
2307
+ if (pageMatch) return `/${pageMatch[1]}`;
2308
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
2309
+ if (rootPage) return "/";
2310
+ return null;
2311
+ };
2312
+ getAllRoutes = () => {
2313
+ const native = getNativeBridge();
2314
+ if (!native?.analyzeClasses) {
2315
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2316
+ }
2317
+ return ["/", "__global"];
2318
+ };
2319
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
2320
+ registerFileClasses = (_filepath, _classes) => {
2321
+ };
2322
+ registerGlobalClasses = (_classes) => {
2323
+ };
2324
+ _incrementalEngineInstance = null;
2325
+ getIncrementalEngine = () => {
2326
+ if (!_incrementalEngineInstance) {
2327
+ _incrementalEngineInstance = new IncrementalEngine();
2328
+ }
2329
+ return _incrementalEngineInstance;
2330
+ };
2331
+ resetIncrementalEngine = () => {
2332
+ _incrementalEngineInstance = null;
2333
+ };
2334
+ IncrementalEngine = class {
2335
+ compile(source) {
2336
+ return transformSource(source);
2337
+ }
2338
+ };
2339
+ getBucketEngine = () => {
2340
+ const native = getNativeBridge();
2341
+ if (!native?.classifyAndSortClasses) {
2342
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2343
+ }
2344
+ return {
2345
+ add: (className) => className,
2346
+ get: (_bucket) => []
2347
+ };
2348
+ };
2349
+ resetBucketEngine = () => {
2350
+ };
2351
+ BucketEngine = class {
2352
+ add(className) {
2353
+ return className;
2354
+ }
2355
+ };
2356
+ classifyNode = (_node) => {
2357
+ const native = getNativeBridge();
2358
+ if (!native?.classifyAndSortClasses) {
2359
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2360
+ }
2361
+ return "unknown";
2362
+ };
2363
+ detectConflicts = (_classes) => {
2364
+ const native = getNativeBridge();
2365
+ if (!native?.analyzeClassUsage) {
2366
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2367
+ }
2368
+ return [];
2369
+ };
2370
+ bucketSort = (classes) => {
2371
+ const native = getNativeBridge();
2372
+ if (!native?.classifyAndSortClasses) {
2373
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2374
+ }
2375
+ const sorted = native.classifyAndSortClasses(classes);
2376
+ return sorted.map((c) => c.raw ?? c);
2377
+ };
2378
+ analyzeFile = (source, filename) => {
2379
+ const native = getNativeBridge();
2380
+ if (!native?.analyzeRsc) {
2381
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2382
+ }
2383
+ const rsc = native.analyzeRsc(source, filename);
2384
+ return {
2385
+ isServer: rsc?.isServer ?? true,
2386
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2387
+ clientReasons: rsc?.clientReasons ?? [],
2388
+ interactiveClasses: [],
2389
+ canStaticResolveVariants: true
2390
+ };
2391
+ };
2392
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2393
+ return { resolved: {}, dynamic: [] };
2394
+ };
2395
+ injectClientDirective = (source) => {
2396
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2397
+ return '"use client";\n' + source;
2398
+ }
2399
+ return source;
2400
+ };
2401
+ injectServerOnlyComment = (source) => {
2402
+ return `/* @server-only */
2403
+ ${source}`;
2404
+ };
2405
+ analyzeClasses = (filesJson, cwd, flags) => {
2406
+ const native = getNativeBridge();
2407
+ if (!native?.analyzeClasses) {
2408
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2409
+ }
2410
+ return native.analyzeClasses(filesJson, cwd, flags);
2411
+ };
2412
+ extractTwStateConfigs = (source, filename) => {
2413
+ const native = getNativeBridge();
2414
+ if (!native?.extractTwStateConfigs) {
2415
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
2416
+ }
2417
+ return native.extractTwStateConfigs(source, filename);
2418
+ };
2419
+ generateStaticStateCss = (entries, _themeConfig) => {
2420
+ const rules = [];
2421
+ for (const entry of entries) {
2422
+ const stateConfig = JSON.parse(entry.statesJson);
2423
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2424
+ rules.push({
2425
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2426
+ declarations: classes,
2427
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2428
+ componentName: entry.componentName,
2429
+ stateName
2430
+ });
2431
+ }
2432
+ }
2433
+ return rules;
2434
+ };
2435
+ extractAndGenerateStateCss = (source, filename) => {
2436
+ const entries = extractTwStateConfigs(source, filename);
2437
+ return generateStaticStateCss(entries);
2438
+ };
2439
+ }
2440
+ });
2441
+
2442
+ // packages/domain/compiler/src/internal.ts
2443
+ var internal_exports = {};
2444
+ __export(internal_exports, {
2445
+ adaptNativeResult: () => adaptNativeResult,
2446
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
2447
+ analyzeClasses: () => analyzeClasses,
2448
+ analyzeClassesNative: () => analyzeClassesNative,
2449
+ analyzeFile: () => analyzeFile,
2450
+ analyzeRscNative: () => analyzeRscNative,
2451
+ analyzeVariantUsage: () => analyzeVariantUsage,
2452
+ astExtractClasses: () => astExtractClasses,
2453
+ atomicRegistrySize: () => atomicRegistrySize,
2454
+ batchExtractClasses: () => batchExtractClasses,
2455
+ batchExtractClassesNative: () => batchExtractClassesNative,
2456
+ bucketSort: () => bucketSort,
2457
+ buildStyleTag: () => buildStyleTag,
2458
+ cachePriority: () => cachePriority,
2459
+ cacheRead: () => cacheRead,
2460
+ cacheWrite: () => cacheWrite,
2461
+ checkAgainstSafelist: () => checkAgainstSafelist,
2462
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2463
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
2464
+ classifyNode: () => classifyNode,
2465
+ clearAllCaches: () => clearAllCaches,
2466
+ clearAtomicRegistry: () => clearAtomicRegistry,
2467
+ clearCache: () => clearCache,
2468
+ clearCompileCache: () => clearCompileCache,
2469
+ clearCssGenCache: () => clearCssGenCache,
2470
+ clearParseCache: () => clearParseCache,
2471
+ clearResolveCache: () => clearResolveCache,
2472
+ clearThemeCache: () => clearThemeCache,
2473
+ collectFiles: () => collectFiles,
2474
+ compileAnimation: () => compileAnimation,
2475
+ compileClass: () => compileClass,
2476
+ compileClasses: () => compileClasses,
2477
+ compileCssFromClasses: () => compileCssFromClasses,
2478
+ compileCssLightning: () => compileCssLightning,
2479
+ compileCssNative2: () => compileCssNative2,
2480
+ compileKeyframes: () => compileKeyframes,
2481
+ compileTheme: () => compileTheme,
2482
+ compileToCss: () => compileToCss,
2483
+ compileToCssBatch: () => compileToCssBatch,
2484
+ compileVariantTableNative: () => compileVariantTableNative,
2485
+ computeIncrementalDiff: () => computeIncrementalDiff,
2486
+ createFingerprint: () => createFingerprint,
2487
+ detectConflicts: () => detectConflicts,
2488
+ detectDeadCode: () => detectDeadCode,
2489
+ diffClassLists: () => diffClassLists,
2490
+ eliminateDeadCss: () => eliminateDeadCss,
2491
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
2492
+ emitPluginHook: () => emitPluginHook,
2493
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
2494
+ extractAllClasses: () => extractAllClasses,
2495
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
2496
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
2497
+ extractClassesFromSource: () => extractClassesFromSource,
2498
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
2499
+ extractComponentUsage: () => extractComponentUsage,
2500
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
2501
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
2502
+ extractTwStateConfigs: () => extractTwStateConfigs,
2503
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
2504
+ fileToRoute: () => fileToRoute,
2505
+ findDeadVariants: () => findDeadVariants,
2506
+ generateAtomicCss: () => generateAtomicCss,
2507
+ generateCssForClasses: () => generateCssForClasses,
2508
+ generateCssNative: () => generateCssNative,
2509
+ generateSafelist: () => generateSafelist,
2510
+ generateStaticStateCss: () => generateStaticStateCss,
2511
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
2512
+ generateSubComponentTypes: () => generateSubComponentTypes,
2513
+ getAllRoutes: () => getAllRoutes,
2514
+ getBucketEngine: () => getBucketEngine,
2515
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
2516
+ getCacheStatistics: () => getCacheStatistics,
2517
+ getCacheStats: () => getCacheStats2,
2518
+ getCompilationMetrics: () => getCompilationMetrics,
2519
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
2520
+ getContentPaths: () => getContentPaths,
2521
+ getIncrementalEngine: () => getIncrementalEngine,
2522
+ getNativeBridge: () => getNativeBridge,
2523
+ getPluginHooks: () => getPluginHooks,
2524
+ getRouteClasses: () => getRouteClasses,
2525
+ getWatchStats: () => getWatchStats,
2526
+ hasTwUsage: () => hasTwUsage,
2527
+ hashContent: () => hashContent,
2528
+ hoistComponentsNative: () => hoistComponentsNative,
2529
+ idRegistryActiveCount: () => idRegistryActiveCount,
2530
+ idRegistryCreate: () => idRegistryCreate,
2531
+ idRegistryDestroy: () => idRegistryDestroy,
2532
+ idRegistryExport: () => idRegistryExport,
2533
+ idRegistryGenerate: () => idRegistryGenerate,
2534
+ idRegistryImport: () => idRegistryImport,
2535
+ idRegistryLookup: () => idRegistryLookup,
2536
+ idRegistryNext: () => idRegistryNext,
2537
+ idRegistryReset: () => idRegistryReset,
2538
+ idRegistrySnapshot: () => idRegistrySnapshot,
2539
+ injectClientDirective: () => injectClientDirective,
2540
+ injectServerOnlyComment: () => injectServerOnlyComment,
2541
+ injectStateHash: () => injectStateHash,
2542
+ isAlreadyTransformed: () => isAlreadyTransformed,
2543
+ isWatchRunning: () => isWatchRunning,
2544
+ layoutClassesToCss: () => layoutClassesToCss,
2545
+ loadSafelist: () => loadSafelist,
2546
+ loadTailwindConfig: () => loadTailwindConfig,
2547
+ mergeClassesStatic: () => mergeClassesStatic,
2548
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
2549
+ minifyCss: () => minifyCss,
2550
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
2551
+ normalizeClasses: () => normalizeClasses,
2552
+ optimizeCssNative: () => optimizeCssNative,
2553
+ parseAtomicClass: () => parseAtomicClass,
2554
+ parseClasses: () => parseClasses,
2555
+ pollWatchEvents: () => pollWatchEvents,
2556
+ processFileChange: () => processFileChange,
2557
+ processTailwindCssLightning: () => processTailwindCssLightning,
2558
+ propertyIdToString: () => propertyIdToString,
2559
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
2560
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
2561
+ redisCacheClear: () => redisCacheClear,
2562
+ redisCacheHitRate: () => redisCacheHitRate,
2563
+ redisCacheKeyCount: () => redisCacheKeyCount,
2564
+ redisCacheSize: () => redisCacheSize,
2565
+ redisCacheSync: () => redisCacheSync,
2566
+ redisClusterStatus: () => redisClusterStatus,
2567
+ redisDelete: () => redisDelete,
2568
+ redisDiagnose: () => redisDiagnose,
2569
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
2570
+ redisDisableCluster: () => redisDisableCluster,
2571
+ redisDisablePersistence: () => redisDisablePersistence,
2572
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
2573
+ redisEnableCluster: () => redisEnableCluster,
2574
+ redisEnablePersistence: () => redisEnablePersistence,
2575
+ redisExists: () => redisExists,
2576
+ redisExpirationGet: () => redisExpirationGet,
2577
+ redisExpirationSet: () => redisExpirationSet,
2578
+ redisFlushAll: () => redisFlushAll,
2579
+ redisFlushDb: () => redisFlushDb,
2580
+ redisGet: () => redisGet,
2581
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2582
+ redisInfo: () => redisInfo,
2583
+ redisMemoryStats: () => redisMemoryStats,
2584
+ redisMget: () => redisMget,
2585
+ redisMonitor: () => redisMonitor,
2586
+ redisMset: () => redisMset,
2587
+ redisOptimizeMemory: () => redisOptimizeMemory,
2588
+ redisPing: () => redisPing,
2589
+ redisPoolConnect: () => redisPoolConnect,
2590
+ redisPoolReconnect: () => redisPoolReconnect,
2591
+ redisPoolStats: () => redisPoolStats,
2592
+ redisPublish: () => redisPublish,
2593
+ redisReplicate: () => redisReplicate,
2594
+ redisReplicationStatus: () => redisReplicationStatus,
2595
+ redisSet: () => redisSet,
2596
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2597
+ redisSnapshot: () => redisSnapshot,
2598
+ redisSubscribe: () => redisSubscribe,
2599
+ registerFileClasses: () => registerFileClasses,
2600
+ registerGlobalClasses: () => registerGlobalClasses,
2601
+ registerPluginHook: () => registerPluginHook,
2602
+ registerPropertyName: () => registerPropertyName,
2603
+ registerValueName: () => registerValueName,
2604
+ resetBucketEngine: () => resetBucketEngine,
2605
+ resetCompilationMetrics: () => resetCompilationMetrics,
2606
+ resetIncrementalEngine: () => resetIncrementalEngine,
2607
+ resolveCascade: () => resolveCascade,
2608
+ resolveClassNames: () => resolveClassNames,
2609
+ resolveConflictGroup: () => resolveConflictGroup,
2610
+ resolveSimpleVariants: () => resolveSimpleVariants,
2611
+ resolveThemeValue: () => resolveThemeValue,
2612
+ resolveVariants: () => resolveVariants,
2613
+ reverseLookupProperty: () => reverseLookupProperty,
2614
+ reverseLookupValue: () => reverseLookupValue,
2615
+ runCssPipeline: () => runCssPipeline,
2616
+ runCssPipelineSync: () => runCssPipelineSync,
2617
+ runElimination: () => runElimination,
2618
+ runLoaderTransform: () => runLoaderTransform,
2619
+ scanCacheOptimizations: () => scanCacheOptimizations,
2620
+ scanFile: () => scanFile,
2621
+ scanFileNative: () => scanFileNative,
2622
+ scanFilesBatchNative: () => scanFilesBatchNative,
2623
+ scanProjectUsage: () => scanProjectUsage,
2624
+ scanWorkspace: () => scanWorkspace,
2625
+ shouldProcess: () => shouldProcess,
2626
+ shouldSkipFile: () => shouldSkipFile,
2627
+ startWatch: () => startWatch,
2628
+ stopWatch: () => stopWatch,
2629
+ toAtomicClasses: () => toAtomicClasses,
2630
+ transformSource: () => transformSource,
2631
+ twMerge: () => twMerge,
2632
+ twMergeMany: () => twMergeMany,
2633
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2634
+ twMergeRaw: () => twMergeRaw,
2635
+ twMergeWithSeparator: () => twMergeWithSeparator,
2636
+ unregisterPluginHook: () => unregisterPluginHook,
2637
+ validateCssOutput: () => validateCssOutput,
2638
+ validateThemeConfig: () => validateThemeConfig,
2639
+ valueIdToString: () => valueIdToString,
2640
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2641
+ watchAddPattern: () => watchAddPattern,
2642
+ watchClearAll: () => watchClearAll,
2643
+ watchEventTypeToString: () => watchEventTypeToString,
2644
+ watchGetActiveHandles: () => watchGetActiveHandles,
2645
+ watchPause: () => watchPause,
2646
+ watchRemovePattern: () => watchRemovePattern,
2647
+ watchResume: () => watchResume
2648
+ });
2649
+ var init_internal = __esm({
2650
+ "packages/domain/compiler/src/internal.ts"() {
2651
+ init_src();
2652
+ init_tailwindEngine();
2653
+ init_compiler();
2654
+ init_parser();
2655
+ init_analyzer();
2656
+ init_cache();
2657
+ init_redis();
2658
+ init_watch();
2659
+ }
2660
+ });
2661
+ function getNative() {
2662
+ if (_native) return _native;
2663
+ try {
2664
+ const mod = (init_internal(), __toCommonJS(internal_exports));
2665
+ if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
2666
+ return null;
2667
+ }
2668
+ _native = {
2669
+ extractTwStateConfigs: mod.extractTwStateConfigs,
2670
+ generateStaticStateCss: mod.generateStaticStateCss,
2671
+ extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
2672
+ ((source, filename) => {
2673
+ const configs = mod.extractTwStateConfigs(source, filename);
2674
+ if (configs.length === 0) return [];
2675
+ return mod.generateStaticStateCss(configs.map((c) => ({
2676
+ tag: c.tag,
2677
+ componentName: c.componentName,
2678
+ statesJson: c.statesJson
2679
+ })));
2680
+ })
2681
+ };
2682
+ return _native;
2683
+ } catch {
2684
+ return null;
2685
+ }
2686
+ }
2687
+ function* walkSourceFiles(dir) {
2688
+ let entries;
2689
+ try {
2690
+ entries = fs9__namespace.default.readdirSync(dir, { withFileTypes: true });
2691
+ } catch {
2692
+ return;
2693
+ }
2694
+ for (const entry of entries) {
2695
+ const fullPath = path10__namespace.default.join(dir, entry.name);
2696
+ if (entry.isDirectory()) {
2697
+ if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
2698
+ yield* walkSourceFiles(fullPath);
2699
+ } else if (entry.isFile()) {
2700
+ const ext = path10__namespace.default.extname(entry.name);
2701
+ if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
2702
+ }
2703
+ }
2704
+ }
2705
+ function buildCssHeader(result) {
2706
+ return [
2707
+ "/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
2708
+ " * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
2709
+ " * DO NOT EDIT. Re-generated on each build.",
2710
+ " *",
2711
+ ` * Files scanned: ${result.filesScanned}`,
2712
+ ` * Files with states: ${result.filesWithStates}`,
2713
+ ` * Components found: ${result.componentsFound}`,
2714
+ ` * Rules generated: ${result.rulesGenerated}`,
2715
+ ` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
2716
+ " *",
2717
+ ' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
2718
+ " * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
2719
+ " * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */",
2720
+ ""
2721
+ ].join("\n");
2722
+ }
2723
+ function extractStaticStateCss(srcDir, options = {}) {
2724
+ const { verbose = false, maxFiles = Infinity } = options;
2725
+ const native = getNative();
2726
+ if (!native) {
2727
+ if (verbose) {
2728
+ process.stderr.write(
2729
+ "[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
2730
+ );
2731
+ }
2732
+ return {
2733
+ filesScanned: 0,
2734
+ filesWithStates: 0,
2735
+ componentsFound: 0,
2736
+ rulesGenerated: 0,
2737
+ rulesSkipped: 0,
2738
+ generatedCss: "",
2739
+ rules: []
2740
+ };
2741
+ }
2742
+ const allConfigs = [];
2743
+ let filesScanned = 0;
2744
+ let filesWithStates = 0;
2745
+ if (native.walkAndPrefilterSourceFiles) {
2746
+ const prefiltered = native.walkAndPrefilterSourceFiles(
2747
+ srcDir,
2748
+ [".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
2749
+ ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
2750
+ // Required substrings — AND logic, identik dengan JS pre-filter di bawah
2751
+ ["states:", "tw."],
2752
+ maxFiles === Infinity ? null : maxFiles,
2753
+ null
2754
+ // sequential — parallel mode opsional untuk large monorepo
2755
+ );
2756
+ for (const { path: filePath, content: source } of prefiltered) {
2757
+ filesScanned++;
2758
+ const configs = native.extractTwStateConfigs(source, filePath);
2759
+ if (configs.length > 0) {
2760
+ filesWithStates++;
2761
+ allConfigs.push(...configs);
2762
+ if (verbose) {
2763
+ process.stderr.write(
2764
+ `[tw:static-state] ${path10__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
2765
+ `
2766
+ );
2767
+ }
2768
+ }
2769
+ }
2770
+ } else {
2771
+ for (const filePath of walkSourceFiles(srcDir)) {
2772
+ if (filesScanned >= maxFiles) break;
2773
+ let source;
2774
+ try {
2775
+ source = fs9__namespace.default.readFileSync(filePath, "utf-8");
2776
+ } catch {
2777
+ continue;
2778
+ }
2779
+ filesScanned++;
2780
+ if (!source.includes("states:") && !source.includes("states :")) continue;
2781
+ if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
2782
+ const configs = native.extractTwStateConfigs(source, filePath);
2783
+ if (configs.length > 0) {
2784
+ filesWithStates++;
2785
+ allConfigs.push(...configs);
2786
+ if (verbose) {
2787
+ process.stderr.write(
2788
+ `[tw:static-state] ${path10__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
2789
+ `
2790
+ );
2791
+ }
2792
+ }
2793
+ }
2794
+ }
2795
+ if (allConfigs.length === 0) {
2796
+ return {
2797
+ filesScanned,
2798
+ filesWithStates: 0,
2799
+ componentsFound: 0,
2800
+ rulesGenerated: 0,
2801
+ rulesSkipped: 0,
2802
+ generatedCss: "",
2803
+ rules: []
2804
+ };
2805
+ }
2806
+ const seen = /* @__PURE__ */ new Set();
2807
+ const uniqueConfigs = [];
2808
+ for (const config of allConfigs) {
2809
+ const key = `${config.tag}::${config.statesJson}`;
2810
+ if (!seen.has(key)) {
2811
+ seen.add(key);
2812
+ uniqueConfigs.push({
2813
+ tag: config.tag,
2814
+ componentName: config.componentName,
2815
+ statesJson: config.statesJson
2816
+ });
2817
+ }
2818
+ }
2819
+ const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
2820
+ const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
2821
+ try {
2822
+ const stateMap = JSON.parse(cfg.statesJson);
2823
+ return total + Object.keys(stateMap).length;
2824
+ } catch {
2825
+ return total;
2826
+ }
2827
+ }, 0) - allRules.length;
2828
+ const byComponent = /* @__PURE__ */ new Map();
2829
+ for (const rule of allRules) {
2830
+ const existing = byComponent.get(rule.componentName) ?? [];
2831
+ existing.push(rule);
2832
+ byComponent.set(rule.componentName, existing);
2833
+ }
2834
+ const cssBlocks = [];
2835
+ for (const [componentName, rules] of byComponent) {
2836
+ cssBlocks.push(`/* ${componentName} */`);
2837
+ for (const rule of rules) {
2838
+ cssBlocks.push(`/* state: ${rule.stateName} */`);
2839
+ cssBlocks.push(rule.cssRule);
2840
+ }
2841
+ cssBlocks.push("");
2842
+ }
2843
+ const result = {
2844
+ filesScanned,
2845
+ filesWithStates,
2846
+ componentsFound: allConfigs.length,
2847
+ rulesGenerated: allRules.length,
2848
+ rulesSkipped: Math.max(0, rulesSkipped),
2849
+ generatedCss: cssBlocks.join("\n"),
2850
+ rules: allRules
2851
+ };
2852
+ result.generatedCss = buildCssHeader(result) + result.generatedCss;
2853
+ return result;
2854
+ }
2855
+ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
2856
+ const result = extractStaticStateCss(srcDir, options);
2857
+ const twClassesDir = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "tw-classes");
2858
+ fs9__namespace.default.mkdirSync(twClassesDir, { recursive: true });
2859
+ const stateFilePath = path10__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
2860
+ if (result.rulesGenerated === 0) {
2861
+ try {
2862
+ fs9__namespace.default.writeFileSync(
2863
+ stateFilePath,
2864
+ "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
2865
+ "utf-8"
2866
+ );
2867
+ } catch {
2868
+ }
2869
+ return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
2870
+ }
2871
+ try {
2872
+ fs9__namespace.default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
2873
+ return [
2874
+ `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
2875
+ ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
2876
+ ` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
2877
+ ` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
2878
+ ].join("\n");
2879
+ } catch (writeErr) {
2880
+ const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
2881
+ return `[tw:static-state] gagal tulis state CSS: ${msg}`;
2882
+ }
2883
+ }
2884
+ var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
2885
+ var init_staticStateExtractor = __esm({
2886
+ "packages/domain/shared/src/staticStateExtractor.ts"() {
2887
+ SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
2888
+ IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
2889
+ _native = null;
2890
+ TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
2891
+ }
2892
+ });
2893
+ function getEnvLevel() {
2894
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
2895
+ if (env && env in LEVELS) return env;
2896
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
2897
+ }
2898
+ function setGlobalLogFile(filePath) {
2899
+ _globalLogFile = filePath;
2900
+ _logFileInitialized = false;
2901
+ try {
2902
+ fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(filePath), { recursive: true });
2903
+ fs9__namespace.default.writeFileSync(
2904
+ filePath,
2905
+ `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
2906
+ `,
2907
+ "utf-8"
2908
+ );
2909
+ _logFileInitialized = true;
2910
+ } catch {
2911
+ }
2912
+ }
2913
+ function writeToFile(line) {
2914
+ if (!_globalLogFile || !_logFileInitialized) return;
2915
+ try {
2916
+ fs9__namespace.default.appendFileSync(_globalLogFile, line);
2917
+ } catch {
2918
+ }
2919
+ }
2920
+ function createLogger(prefix, level) {
2921
+ const loggerState = {
2922
+ currentLevel: getEnvLevel(),
2923
+ setLevel(l) {
2924
+ this.currentLevel = l;
2925
+ }
2926
+ };
2927
+ const log4 = (msgLevel, stream, args) => {
2928
+ if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
2929
+ const line = `[${prefix}] ${args.map(String).join(" ")}
2930
+ `;
2931
+ process[stream].write(line);
2932
+ writeToFile(line);
2933
+ };
2934
+ return {
2935
+ error: (...a) => log4("error", "stderr", a),
2936
+ warn: (...a) => log4("warn", "stderr", a),
2937
+ info: (...a) => log4("info", "stdout", a),
2938
+ debug: (...a) => log4("debug", "stderr", a),
2939
+ setLevel: loggerState.setLevel,
2940
+ setLogFile: (filePath) => setGlobalLogFile(filePath)
2941
+ };
2942
+ }
2943
+ var LEVELS, _globalLogFile, _logFileInitialized;
2944
+ var init_logger = __esm({
2945
+ "packages/domain/shared/src/logger.ts"() {
2946
+ LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
2947
+ _globalLogFile = null;
2948
+ _logFileInitialized = false;
2949
+ createLogger("tailwind-styled");
2950
+ }
2951
+ });
2952
+ function createLogger2(namespace) {
2953
+ const prefix = `[${namespace}]`;
2954
+ return {
2955
+ warn(...args) {
2956
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
2957
+ `);
2958
+ },
2959
+ debug(...args) {
2960
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
2961
+ `);
2962
+ },
2963
+ error(...args) {
2964
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
2965
+ `);
2966
+ },
2967
+ log(...args) {
2968
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
2969
+ `);
2970
+ }
2971
+ };
2972
+ }
2973
+ function createDebugLogger(namespace, label) {
2974
+ const prefix = `[${namespace}]`;
2975
+ return (msg) => {
2976
+ if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
2977
+ console.debug(prefix, msg);
2978
+ }
2979
+ };
2980
+ }
2981
+ function formatIssuePath(path11) {
2982
+ if (!path11 || path11.length === 0) return "(root)";
2983
+ return path11.map(
2984
+ (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
2985
+ ).join(".");
2986
+ }
2987
+ function loadNativeBinding(options) {
2988
+ const { runtimeDir, candidates, isValid } = options;
2989
+ const loadErrors = [];
2990
+ for (const candidate of candidates) {
2991
+ const candidatePath = path10__namespace.default.resolve(runtimeDir, candidate);
2992
+ try {
2993
+ if (!fs9__namespace.default.existsSync(candidatePath) && !fs9__namespace.default.existsSync(candidatePath + ".node")) {
2994
+ continue;
2995
+ }
2996
+ const mod = requireNativeModule(candidatePath);
2997
+ if (mod && isValid(mod)) {
2998
+ return { binding: mod, loadErrors, loadedPath: candidatePath };
2999
+ }
3000
+ loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
3001
+ } catch (e) {
3002
+ loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
3003
+ }
3004
+ }
3005
+ return { binding: null, loadErrors };
3006
+ }
3007
+ function requireNativeModule(p) {
3008
+ return _require2(p);
3009
+ }
3010
+ function resolveNativeBindingCandidates(options) {
3011
+ const {
3012
+ envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
3013
+ includeDefaultCandidates = true,
3014
+ enforceNodeExtensionForEnvPath = false
3015
+ } = options;
3016
+ const runtimeDir = options.runtimeDir || process.cwd();
3017
+ const candidates = [];
3018
+ for (const envVar of envVarNames) {
3019
+ const envPath = process.env[envVar];
3020
+ if (envPath) {
3021
+ candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
3022
+ }
3023
+ }
3024
+ if (!includeDefaultCandidates) return candidates;
3025
+ if (fs9__namespace.default.existsSync(runtimeDir)) {
3026
+ try {
3027
+ for (const entry of fs9__namespace.default.readdirSync(runtimeDir)) {
3028
+ if (entry.endsWith(".node")) candidates.push(entry);
3029
+ }
3030
+ } catch {
3031
+ }
3032
+ }
3033
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
3034
+ const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
3035
+ for (const bin of BINARY_NAMES) {
3036
+ candidates.push(path10__namespace.default.resolve(runtimeDir, `${bin}.node`));
3037
+ candidates.push(path10__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3038
+ candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3039
+ candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3040
+ candidates.push(path10__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
3041
+ candidates.push(path10__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3042
+ candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3043
+ candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3044
+ candidates.push(path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3045
+ }
3046
+ return Array.from(new Set(candidates));
3047
+ }
3048
+ function resolveRuntimeDir(dir, importMetaUrl) {
3049
+ try {
3050
+ return path10__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
3051
+ } catch {
3052
+ return process.cwd();
3053
+ }
3054
+ }
3055
+ var TwError, _require2;
3056
+ var init_src2 = __esm({
3057
+ "packages/domain/shared/src/index.ts"() {
3058
+ init_workerResolver();
3059
+ init_native_resolution();
3060
+ init_staticStateExtractor();
3061
+ init_logger();
3062
+ TwError = class _TwError extends Error {
3063
+ /** @deprecated Gunakan source */
3064
+ domain;
3065
+ source;
3066
+ code;
3067
+ originalCause;
3068
+ constructor(domainOrSource, code, message, cause) {
3069
+ super(message);
3070
+ this.name = "TwError";
3071
+ this.domain = domainOrSource;
3072
+ this.source = domainOrSource;
3073
+ this.code = code;
3074
+ this.originalCause = cause;
3075
+ if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
3076
+ }
3077
+ static fromIo(code, message) {
3078
+ return new _TwError("io", code, message);
3079
+ }
3080
+ static fromCompile(code, message) {
3081
+ return new _TwError("compile", code, message);
3082
+ }
3083
+ static fromRust(err) {
3084
+ if (err instanceof _TwError) return err;
3085
+ if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
3086
+ if (err && typeof err === "object") {
3087
+ const e = err;
3088
+ return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
3089
+ }
3090
+ return new _TwError("rust", "RUST_ERROR", String(err), err);
3091
+ }
3092
+ /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3093
+ static fromZod(err) {
3094
+ const first = err.issues?.[0] ?? err.errors?.[0];
3095
+ const path11 = formatIssuePath(first?.path);
3096
+ const message = first ? `${path11}: ${first.message}` : "Schema validation failed";
3097
+ return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3098
+ }
3099
+ static wrap(source, code, err) {
3100
+ if (err instanceof _TwError) return err;
3101
+ if (err instanceof Error) return new _TwError(source, code, err.message, err);
3102
+ return new _TwError(source, code, String(err), err);
3103
+ }
3104
+ toString() {
3105
+ return `TwError [${this.source}:${this.code}] ${this.message}`;
3106
+ }
3107
+ toJSON() {
3108
+ return { name: this.name, source: this.source, code: this.code, message: this.message };
3109
+ }
3110
+ toCliMessage() {
3111
+ return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
3112
+ }
3113
+ };
3114
+ _require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
3115
+ }
3116
+ });
3117
+
3118
+ // packages/domain/scanner/src/native-bridge.ts
3119
+ var native_bridge_exports = {};
3120
+ __export(native_bridge_exports, {
3121
+ batchExtractClassesNative: () => batchExtractClassesNative2,
3122
+ cachePriorityNative: () => cachePriorityNative,
3123
+ cacheReadNative: () => cacheReadNative,
3124
+ cacheWriteNative: () => cacheWriteNative,
3125
+ collectFilesNative: () => collectFilesNative,
3126
+ computeCacheStatsNative: () => computeCacheStatsNative,
3127
+ extractClassesNative: () => extractClassesNative,
3128
+ generateSubComponentTypesNative: () => generateSubComponentTypesNative,
3129
+ hasNativeScannerBinding: () => hasNativeScannerBinding,
3130
+ hasNativeWatchBinding: () => hasNativeWatchBinding,
3131
+ hashContentNative: () => hashContentNative,
3132
+ isRustCacheAvailable: () => isRustCacheAvailable,
3133
+ pollWatchEventsNative: () => pollWatchEventsNative,
3134
+ pruneStaleEntriesNative: () => pruneStaleEntriesNative,
3135
+ rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
3136
+ resetScannerBridgeCache: () => resetScannerBridgeCache,
3137
+ scanCacheGet: () => scanCacheGet,
3138
+ scanCacheInvalidate: () => scanCacheInvalidate,
3139
+ scanCachePut: () => scanCachePut,
3140
+ scanCacheStats: () => scanCacheStats,
3141
+ scanFileNative: () => scanFileNative2,
3142
+ scanFilesBatchNative: () => scanFilesBatchNative2,
3143
+ scanWorkspaceNative: () => scanWorkspaceNative,
3144
+ startWatchNative: () => startWatchNative,
3145
+ stopWatchNative: () => stopWatchNative
3146
+ });
3147
+ function getDirname() {
3148
+ if (typeof __dirname !== "undefined") {
3149
+ return __dirname;
3150
+ }
3151
+ if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))) {
3152
+ return path10__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3153
+ }
3154
+ return process.cwd();
3155
+ }
3156
+ function scanWorkspaceNative(root, extensions) {
3157
+ return scannerGetBinding().scanWorkspace(root, extensions ?? null);
3158
+ }
3159
+ function extractClassesNative(source) {
3160
+ const result = scannerGetBinding().extractClassesFromSource?.(source);
3161
+ if (result === null || result === void 0) {
3162
+ throw new TwError(
3163
+ "rust",
3164
+ "SCANNER_EXTRACT_FAILED",
3165
+ "Native extractClassesFromSource returned null/undefined"
3166
+ );
3167
+ }
3168
+ return result;
3169
+ }
3170
+ function hashContentNative(content) {
3171
+ const result = scannerGetBinding().hashFileContent?.(content);
3172
+ if (result === null || result === void 0) {
3173
+ throw new TwError(
3174
+ "rust",
3175
+ "SCANNER_HASH_FAILED",
3176
+ "Native hashFileContent returned null/undefined"
3177
+ );
3178
+ }
3179
+ return result;
3180
+ }
3181
+ function isRustCacheAvailable() {
3182
+ return true;
3183
+ }
3184
+ function hasNativeScannerBinding() {
3185
+ try {
3186
+ scannerBridgeLoader.get();
3187
+ return true;
3188
+ } catch {
3189
+ return false;
3190
+ }
3191
+ }
3192
+ function cacheReadNative(cachePath) {
3193
+ const result = scannerGetBinding().cacheRead?.(cachePath);
3194
+ if (result === null || result === void 0) {
3195
+ throw new TwError(
3196
+ "rust",
3197
+ "SCANNER_CACHE_READ_FAILED",
3198
+ "Native cacheRead returned null/undefined"
3199
+ );
3200
+ }
3201
+ return result;
3202
+ }
3203
+ function cacheWriteNative(cachePath, entries) {
3204
+ const result = scannerGetBinding().cacheWrite?.(cachePath, entries);
3205
+ if (result === null || result === void 0) {
3206
+ throw new TwError(
3207
+ "rust",
3208
+ "SCANNER_CACHE_WRITE_FAILED",
3209
+ "Native cacheWrite returned null/undefined"
3210
+ );
3211
+ }
3212
+ return result;
3213
+ }
3214
+ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHitCount, cachedLastSeenMs, nowMs = Date.now()) {
3215
+ const result = scannerGetBinding().cachePriority?.(
3216
+ mtimeMs,
3217
+ size,
3218
+ cachedMtimeMs,
3219
+ cachedSize,
3220
+ cachedHitCount,
3221
+ cachedLastSeenMs,
3222
+ nowMs
3223
+ );
3224
+ if (result === null || result === void 0) {
3225
+ throw new TwError(
3226
+ "rust",
3227
+ "SCANNER_CACHE_PRIORITY_FAILED",
3228
+ "Native cachePriority returned null/undefined"
3229
+ );
3230
+ }
3231
+ return result;
3232
+ }
3233
+ function batchExtractClassesNative2(filePaths) {
3234
+ const binding = scannerGetBinding();
3235
+ if (!binding.batchExtractClasses) {
3236
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
3237
+ }
3238
+ return binding.batchExtractClasses(filePaths) ?? [];
3239
+ }
3240
+ function scanCacheGet(filePath, contentHash) {
3241
+ const binding = scannerGetBinding();
3242
+ if (!binding.scanCacheGet) {
3243
+ throw new Error("FATAL: Native binding 'scanCacheGet' is required but not available.");
3244
+ }
3245
+ return binding.scanCacheGet(filePath, contentHash) ?? null;
3246
+ }
3247
+ function scanCachePut(filePath, contentHash, classes, mtimeMs, size) {
3248
+ const binding = scannerGetBinding();
3249
+ if (!binding.scanCachePut) {
3250
+ throw new Error("FATAL: Native binding 'scanCachePut' is required but not available.");
3251
+ }
3252
+ binding.scanCachePut(filePath, contentHash, classes, mtimeMs, size);
3253
+ }
3254
+ function scanCacheInvalidate(filePath) {
3255
+ const binding = scannerGetBinding();
3256
+ if (!binding.scanCacheInvalidate) {
3257
+ throw new Error("FATAL: Native binding 'scanCacheInvalidate' is required but not available.");
3258
+ }
3259
+ binding.scanCacheInvalidate(filePath);
3260
+ }
3261
+ function scanCacheStats() {
3262
+ const binding = scannerGetBinding();
3263
+ if (!binding.scanCacheStats) {
3264
+ throw new Error("FATAL: Native binding 'scanCacheStats' is required but not available.");
3265
+ }
3266
+ return binding.scanCacheStats();
3267
+ }
3268
+ function scanFileNative2(filePath) {
3269
+ const binding = scannerGetBinding();
3270
+ if (!binding.scanFile) {
3271
+ throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
3272
+ }
3273
+ return binding.scanFile(filePath);
3274
+ }
3275
+ function collectFilesNative(root, extensions, ignoreDirs) {
3276
+ const binding = scannerGetBinding();
3277
+ if (!binding.collectFiles) return null;
3278
+ return binding.collectFiles(root, extensions, ignoreDirs);
3279
+ }
3280
+ function scanFilesBatchNative2(filePaths) {
3281
+ const binding = scannerGetBinding();
3282
+ if (!binding.scanFilesBatch) {
3283
+ return filePaths.map((fp) => {
3284
+ try {
3285
+ const r = binding.scanFile?.(fp);
3286
+ return r ? { file: r.file, classes: r.classes, hash: r.hash ?? "" } : { file: fp, classes: [], hash: "" };
3287
+ } catch {
3288
+ return { file: fp, classes: [], hash: "" };
3289
+ }
3290
+ });
3291
+ }
3292
+ return binding.scanFilesBatch(filePaths);
3293
+ }
3294
+ function generateSubComponentTypesNative(root, outputPath) {
3295
+ const binding = scannerGetBinding();
3296
+ if (!binding.generateSubComponentTypes) return null;
3297
+ return binding.generateSubComponentTypes(root, outputPath ?? null);
3298
+ }
3299
+ function pruneStaleEntriesNative(entries, maxAgeMs, checkExists) {
3300
+ const binding = scannerGetBinding();
3301
+ if (!binding.pruneStaleEntries) return null;
3302
+ return binding.pruneStaleEntries(
3303
+ entries.map((e) => ({ file: e.file, lastSeenMs: e.lastSeenMs ?? 0 })),
3304
+ maxAgeMs ?? null,
3305
+ checkExists ?? null
3306
+ );
3307
+ }
3308
+ function rebuildWorkspaceResultNative(files) {
3309
+ const binding = scannerBridgeLoader.get();
3310
+ if (!binding?.rebuildWorkspaceResult) return null;
3311
+ try {
3312
+ return binding.rebuildWorkspaceResult(files);
3313
+ } catch {
3314
+ return null;
3315
+ }
3316
+ }
3317
+ function computeCacheStatsNative(filesClasses, sizes, top) {
3318
+ const binding = scannerGetBinding();
3319
+ if (!binding.computeCacheStats) return null;
3320
+ return binding.computeCacheStats(filesClasses, sizes, top ?? null);
3321
+ }
3322
+ function startWatchNative(rootDir) {
3323
+ try {
3324
+ const binding = scannerGetBinding();
3325
+ if (!binding.startWatch) return null;
3326
+ return binding.startWatch(rootDir);
3327
+ } catch {
3328
+ return null;
3329
+ }
3330
+ }
3331
+ function pollWatchEventsNative(handleId) {
3332
+ try {
3333
+ const binding = scannerGetBinding();
3334
+ if (!binding.pollWatchEvents) return [];
3335
+ return binding.pollWatchEvents(handleId);
3336
+ } catch {
3337
+ return [];
3338
+ }
3339
+ }
3340
+ function stopWatchNative(handleId) {
3341
+ try {
3342
+ const binding = scannerGetBinding();
3343
+ if (!binding.stopWatch) return false;
3344
+ return binding.stopWatch(handleId);
3345
+ } catch {
3346
+ return false;
3347
+ }
3348
+ }
3349
+ function hasNativeWatchBinding() {
3350
+ try {
3351
+ const binding = scannerGetBinding();
3352
+ return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
3353
+ } catch {
3354
+ return false;
3355
+ }
3356
+ }
3357
+ var log2, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
3358
+ var init_native_bridge = __esm({
3359
+ "packages/domain/scanner/src/native-bridge.ts"() {
3360
+ init_src2();
3361
+ log2 = createDebugLogger("scanner:native");
3362
+ isValidScannerBinding = (module) => {
3363
+ const candidate = module;
3364
+ return !!(candidate && (candidate.scanWorkspace || candidate.extractClassesFromSource || candidate.hashFileContent || candidate.cacheRead || candidate.cacheWrite));
1234
3365
  };
1235
- analyzeVariantUsage = (source, componentName, variantKeys) => {
1236
- analyzeRsc(source, componentName);
1237
- return {
1238
- resolved: {},
1239
- dynamic: []
3366
+ createScannerBridgeLoader = () => {
3367
+ const _state = {
3368
+ binding: void 0,
3369
+ loadError: null,
3370
+ candidatePaths: []
1240
3371
  };
1241
- };
1242
- injectClientDirective = (source) => {
1243
- if (!source.includes('"use client"') && !source.includes("'use client'")) {
1244
- return '"use client";\n' + source;
1245
- }
1246
- return source;
1247
- };
1248
- injectServerOnlyComment = (source) => {
1249
- return `/* @server-only */
1250
- ${source}`;
1251
- };
1252
- analyzeClasses = (filesJson, cwd, flags) => {
1253
- const native = getNativeBridge();
1254
- if (!native?.analyzeClasses) {
1255
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
1256
- }
1257
- return native.analyzeClasses(filesJson, cwd, flags);
1258
- };
1259
- generateSafelist = (scanDirs, outputPath, cwd) => {
1260
- const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
1261
- const allClasses = Object.keys(classes).sort();
1262
- if (outputPath) {
1263
- const fs6 = __require("fs");
1264
- fs6.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
1265
- }
1266
- return allClasses;
1267
- };
1268
- loadSafelist = (safelistPath) => {
1269
- const fs6 = __require("fs");
1270
- try {
1271
- const content = fs6.readFileSync(safelistPath, "utf-8");
1272
- return JSON.parse(content);
1273
- } catch {
1274
- return [];
1275
- }
1276
- };
1277
- loadTailwindConfig = (cwd = process.cwd()) => {
1278
- const fs6 = __require("fs");
1279
- const path7 = __require("path");
1280
- const configFiles = [
1281
- "tailwind.config.ts",
1282
- "tailwind.config.js",
1283
- "tailwind.config.mjs",
1284
- "tailwind.config.cjs"
1285
- ];
1286
- for (const file of configFiles) {
1287
- const fullPath = path7.join(cwd, file);
1288
- if (fs6.existsSync(fullPath)) {
1289
- const mod = __require(fullPath);
1290
- return mod.default || mod;
3372
+ const throwNativeBindingError = () => {
3373
+ const lines = [
3374
+ "FATAL: Native scanner binding not found.",
3375
+ "",
3376
+ "This package requires the Rust native binding 'tailwind_styled_parser.node'.",
3377
+ "The binding was not found in any of these paths:",
3378
+ ..._state.candidatePaths.map((p) => ` - ${p}`),
3379
+ ""
3380
+ ];
3381
+ if (_state.loadError) {
3382
+ lines.push("Load error:", ` ${_state.loadError}`, "");
1291
3383
  }
1292
- }
1293
- return {};
1294
- };
1295
- getContentPaths = (cwd = process.cwd()) => {
1296
- const path7 = __require("path");
1297
- return {
1298
- content: [
1299
- path7.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
1300
- path7.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
1301
- path7.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
1302
- ]
3384
+ lines.push(
3385
+ "To fix this, run:",
3386
+ " npm run build:rust",
3387
+ "",
3388
+ "This will build the native Rust module from the 'native/' directory.",
3389
+ "If you're using this package in a CI/CD environment, ensure Rust toolchain is installed",
3390
+ "and 'npm run build:rust' is executed before running tests or building."
3391
+ );
3392
+ throw new TwError("rust", "SCANNER_NATIVE_BINDING_NOT_FOUND", lines.join("\n"));
1303
3393
  };
1304
- };
1305
- runLoaderTransform = (ctx) => {
1306
- const { filepath, source, options } = ctx;
1307
- const result = transformSource(source, { filename: filepath, ...options });
1308
- return {
1309
- code: result?.code || "",
1310
- changed: result?.changed || false,
1311
- classes: result?.classes || []
3394
+ const scannerGetBinding2 = () => {
3395
+ const cachedBinding = _state.binding;
3396
+ if (cachedBinding !== void 0) {
3397
+ if (cachedBinding !== null) {
3398
+ return cachedBinding;
3399
+ }
3400
+ return throwNativeBindingError();
3401
+ }
3402
+ const runtimeDir = getDirname();
3403
+ const candidates = resolveNativeBindingCandidates({
3404
+ runtimeDir,
3405
+ includeDefaultCandidates: true
3406
+ });
3407
+ _state.candidatePaths = candidates;
3408
+ const { binding, loadErrors } = loadNativeBinding({
3409
+ runtimeDir,
3410
+ candidates,
3411
+ isValid: isValidScannerBinding,
3412
+ invalidExportMessage: "Module loaded but missing expected scanner binding functions"
3413
+ });
3414
+ if (binding) {
3415
+ log2(`scanner native binding loaded successfully`);
3416
+ _state.binding = binding;
3417
+ return _state.binding;
3418
+ }
3419
+ if (loadErrors.length > 0) {
3420
+ _state.loadError = loadErrors.map((e) => `${e.path}: ${e.message}`).join("; ");
3421
+ }
3422
+ _state.binding = null;
3423
+ return throwNativeBindingError();
1312
3424
  };
1313
- };
1314
- shouldSkipFile = (filepath) => {
1315
- const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
1316
- const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
1317
- for (const p of SKIP_PATHS) {
1318
- if (filepath.includes(p)) return true;
1319
- }
1320
- for (const ext of skipExtensions) {
1321
- if (filepath.endsWith(ext)) return true;
1322
- }
1323
- return false;
1324
- };
1325
- fileToRoute = (filepath) => {
1326
- const normalized = filepath.replace(/\\/g, "/");
1327
- if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
1328
- return "__global";
1329
- }
1330
- const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
1331
- if (pageMatch) return `/${pageMatch[1]}`;
1332
- const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
1333
- if (rootPage) return "/";
1334
- return null;
1335
- };
1336
- getAllRoutes = () => {
1337
- const native = getNativeBridge();
1338
- if (!native?.analyzeClasses) {
1339
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
1340
- }
1341
- return ["/", "__global"];
1342
- };
1343
- getRouteClasses = (_route) => {
1344
- return /* @__PURE__ */ new Set();
1345
- };
1346
- registerFileClasses = (_filepath, _classes) => {
1347
- };
1348
- registerGlobalClasses = (_classes) => {
1349
- };
1350
- _incrementalEngineInstance = null;
1351
- getIncrementalEngine = () => {
1352
- if (!_incrementalEngineInstance) {
1353
- _incrementalEngineInstance = new IncrementalEngine();
1354
- }
1355
- return _incrementalEngineInstance;
1356
- };
1357
- resetIncrementalEngine = () => {
1358
- _incrementalEngineInstance = null;
1359
- };
1360
- IncrementalEngine = class {
1361
- compile(source) {
1362
- return transformSource(source);
1363
- }
1364
- };
1365
- getBucketEngine = () => {
1366
- const native = getNativeBridge();
1367
- if (!native?.classifyAndSortClasses) {
1368
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1369
- }
1370
3425
  return {
1371
- add: (className) => className,
1372
- get: (_bucket) => []
3426
+ get: scannerGetBinding2,
3427
+ scannerGetBinding: scannerGetBinding2,
3428
+ reset: () => {
3429
+ _state.binding = void 0;
3430
+ _state.loadError = null;
3431
+ _state.candidatePaths = [];
3432
+ }
1373
3433
  };
1374
3434
  };
1375
- resetBucketEngine = () => {
1376
- };
1377
- BucketEngine = class {
1378
- add(className) {
1379
- return className;
1380
- }
1381
- };
1382
- classifyNode = (_node) => {
1383
- const native = getNativeBridge();
1384
- if (!native?.classifyAndSortClasses) {
1385
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1386
- }
1387
- return "unknown";
1388
- };
1389
- detectConflicts = (classes) => {
1390
- const native = getNativeBridge();
1391
- if (!native?.analyzeClassUsage) {
1392
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
1393
- }
1394
- return [];
1395
- };
1396
- bucketSort = (classes) => {
1397
- return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
1398
- };
3435
+ scannerBridgeLoader = createScannerBridgeLoader();
3436
+ scannerGetBinding = scannerBridgeLoader.get;
3437
+ resetScannerBridgeCache = scannerBridgeLoader.reset;
1399
3438
  }
1400
3439
  });
1401
3440
  var formatIssues = (error) => error.issues.map((issue) => {
@@ -1421,20 +3460,20 @@ var NextAdapterOptionsSchema = zod.z.object({
1421
3460
  var parseNextAdapterOptions = (options) => parseWithSchema(NextAdapterOptionsSchema, options ?? {}, "next adapter options are invalid");
1422
3461
 
1423
3462
  // packages/presentation/next/src/withTailwindStyled.ts
1424
- init_src();
3463
+ init_src2();
1425
3464
 
1426
3465
  // packages/domain/scanner/src/index.ts
1427
- init_src();
3466
+ init_src2();
1428
3467
 
1429
3468
  // packages/domain/scanner/src/cache-native.ts
1430
3469
  init_native_bridge();
1431
3470
  function defaultCachePath(rootDir, cacheDir) {
1432
- const dir = cacheDir ? path5__namespace.default.resolve(rootDir, cacheDir) : path5__namespace.default.join(process.cwd(), ".cache", "tailwind-styled");
1433
- return path5__namespace.default.join(dir, "scanner-cache.json");
3471
+ const dir = cacheDir ? path10__namespace.default.resolve(rootDir, cacheDir) : path10__namespace.default.join(process.cwd(), ".cache", "tailwind-styled");
3472
+ return path10__namespace.default.join(dir, "scanner-cache.json");
1434
3473
  }
1435
3474
  function readCache(rootDir, cacheDir) {
1436
3475
  const cachePath = defaultCachePath(rootDir, cacheDir);
1437
- fs5__namespace.default.mkdirSync(path5__namespace.default.dirname(cachePath), { recursive: true });
3476
+ fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(cachePath), { recursive: true });
1438
3477
  const result = cacheReadNative(cachePath);
1439
3478
  if (!result) return [];
1440
3479
  return result.entries.map((e) => ({
@@ -1449,7 +3488,7 @@ function readCache(rootDir, cacheDir) {
1449
3488
  }
1450
3489
  function writeCache(rootDir, entries, cacheDir) {
1451
3490
  const cachePath = defaultCachePath(rootDir, cacheDir);
1452
- fs5__namespace.default.mkdirSync(path5__namespace.default.dirname(cachePath), { recursive: true });
3491
+ fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(cachePath), { recursive: true });
1453
3492
  const success = cacheWriteNative(cachePath, entries);
1454
3493
  if (!success) {
1455
3494
  throw new Error(
@@ -1473,13 +3512,13 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
1473
3512
  init_native_bridge();
1474
3513
 
1475
3514
  // packages/domain/scanner/src/schemas.ts
1476
- init_src();
1477
- var formatIssuePath2 = (path7) => path7.length > 0 ? path7.map(
3515
+ init_src2();
3516
+ var formatIssuePath2 = (path11) => path11.length > 0 ? path11.map(
1478
3517
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
1479
3518
  ).join(".") : "<root>";
1480
3519
  var formatIssues2 = (error) => error.issues.map((issue) => {
1481
- const path7 = formatIssuePath2(issue.path);
1482
- return `${path7}: ${issue.message}`;
3520
+ const path11 = formatIssuePath2(issue.path);
3521
+ return `${path11}: ${issue.message}`;
1483
3522
  }).join("; ");
1484
3523
  var parseWithSchema2 = (schema, data, label) => {
1485
3524
  const parsed = schema.safeParse(data);
@@ -1533,13 +3572,13 @@ var parseScanWorkspaceOptions = (options) => parseWithSchema2(ScanWorkspaceOptio
1533
3572
  var parseScanWorkspaceResult = (result) => parseWithSchema2(ScanWorkspaceResultSchema, result, "scanner workspace result is invalid");
1534
3573
 
1535
3574
  // packages/domain/scanner/src/index.ts
1536
- var log2 = createLogger("scanner");
3575
+ var log3 = createLogger2("scanner");
1537
3576
  function getRuntimeDir() {
1538
3577
  if (typeof __dirname !== "undefined" && __dirname.length > 0) {
1539
3578
  return __dirname;
1540
3579
  }
1541
3580
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))) {
1542
- return path5__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
3581
+ return path10__namespace.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href))));
1543
3582
  }
1544
3583
  return process.cwd();
1545
3584
  }
@@ -1549,12 +3588,12 @@ var createNativeParserLoader = () => {
1549
3588
  initError: null
1550
3589
  };
1551
3590
  const debugNative = (message) => {
1552
- log2.debug(`[native] ${message}`);
3591
+ log3.debug(`[native] ${message}`);
1553
3592
  };
1554
3593
  const loadNativeParserBinding = () => {
1555
3594
  if (_state.binding !== void 0) return _state.binding;
1556
3595
  const runtimeDir = getRuntimeDir();
1557
- const req = module$1.createRequire(path5__namespace.default.join(runtimeDir, "noop.cjs"));
3596
+ const req = module$1.createRequire(path10__namespace.default.join(runtimeDir, "noop.cjs"));
1558
3597
  const _platform = process.platform;
1559
3598
  const _arch = process.arch;
1560
3599
  const _platformArch = `${_platform}-${_arch}`;
@@ -1562,27 +3601,27 @@ var createNativeParserLoader = () => {
1562
3601
  const candidates = [
1563
3602
  // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
1564
3603
  // cwd = repo root saat run dari root, atau package dir saat workspaces
1565
- path5__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
1566
- path5__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
1567
- path5__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3604
+ path10__namespace.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
3605
+ path10__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
3606
+ path10__namespace.default.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1568
3607
  // runtimeDir = dist/ → naik 1 level ke package root (npm install case)
1569
3608
  // e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
1570
- path5__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
1571
- path5__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
1572
- path5__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3609
+ path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
3610
+ path10__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
3611
+ path10__namespace.default.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1573
3612
  // runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
1574
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
1575
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3613
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
3614
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1576
3615
  // 3 level fallback (jika package di-nest lebih dangkal)
1577
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
1578
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
3616
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
3617
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1579
3618
  // ── binaryName lama: tailwind_styled_parser (backward compat) ──
1580
- path5__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
1581
- path5__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
1582
- path5__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
1583
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
1584
- path5__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
1585
- path5__namespace.default.resolve(
3619
+ path10__namespace.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
3620
+ path10__namespace.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
3621
+ path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
3622
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
3623
+ path10__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
3624
+ path10__namespace.default.resolve(
1586
3625
  runtimeDir,
1587
3626
  "..",
1588
3627
  "..",
@@ -1594,7 +3633,7 @@ var createNativeParserLoader = () => {
1594
3633
  )
1595
3634
  ];
1596
3635
  for (const fullPath of candidates) {
1597
- if (!fs5__namespace.default.existsSync(fullPath)) continue;
3636
+ if (!fs9__namespace.default.existsSync(fullPath)) continue;
1598
3637
  try {
1599
3638
  const required = req(fullPath);
1600
3639
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -1635,19 +3674,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
1635
3674
  if (!currentDir) continue;
1636
3675
  const entries = (() => {
1637
3676
  try {
1638
- return fs5__namespace.default.readdirSync(currentDir, { withFileTypes: true });
3677
+ return fs9__namespace.default.readdirSync(currentDir, { withFileTypes: true });
1639
3678
  } catch {
1640
3679
  return [];
1641
3680
  }
1642
3681
  })();
1643
3682
  for (const entry of entries) {
1644
- const fullPath = path5__namespace.default.join(currentDir, entry.name);
3683
+ const fullPath = path10__namespace.default.join(currentDir, entry.name);
1645
3684
  if (entry.isDirectory()) {
1646
3685
  if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
1647
3686
  continue;
1648
3687
  }
1649
3688
  if (!entry.isFile()) continue;
1650
- if (!extensionSet.has(path5__namespace.default.extname(entry.name))) continue;
3689
+ if (!extensionSet.has(path10__namespace.default.extname(entry.name))) continue;
1651
3690
  candidates.push(fullPath);
1652
3691
  }
1653
3692
  }
@@ -1673,9 +3712,9 @@ function scanSource(source) {
1673
3712
  "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"
1674
3713
  );
1675
3714
  }
1676
- function scanFile(filePath) {
1677
- const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
1678
- const result = scanFileNative2(filePath);
3715
+ function scanFile2(filePath) {
3716
+ const { scanFileNative: scanFileNative3 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
3717
+ const result = scanFileNative3(filePath);
1679
3718
  if (!result.ok) {
1680
3719
  throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
1681
3720
  }
@@ -1685,7 +3724,7 @@ function scanFile(filePath) {
1685
3724
  ...result.hash ? { hash: result.hash } : {}
1686
3725
  };
1687
3726
  }
1688
- function scanWorkspace(rootDir, options = {}) {
3727
+ function scanWorkspace2(rootDir, options = {}) {
1689
3728
  const normalizedOptions = parseScanWorkspaceOptions(options);
1690
3729
  const includeExtensions = normalizedOptions.includeExtensions ?? DEFAULT_EXTENSIONS;
1691
3730
  const extensionSet = buildExtensionSet(includeExtensions);
@@ -1719,7 +3758,7 @@ function scanWorkspace(rootDir, options = {}) {
1719
3758
  try {
1720
3759
  return readCache(rootDir, normalizedOptions.cacheDir);
1721
3760
  } catch (error) {
1722
- log2.debug(
3761
+ log3.debug(
1723
3762
  `cache read failed, continuing without persisted cache: ${error instanceof Error ? error.message : String(error)}`
1724
3763
  );
1725
3764
  return [];
@@ -1731,7 +3770,7 @@ function scanWorkspace(rootDir, options = {}) {
1731
3770
  for (const filePath of candidates) {
1732
3771
  const stat = (() => {
1733
3772
  try {
1734
- return fs5__namespace.default.statSync(filePath);
3773
+ return fs9__namespace.default.statSync(filePath);
1735
3774
  } catch {
1736
3775
  return null;
1737
3776
  }
@@ -1757,7 +3796,7 @@ function scanWorkspace(rootDir, options = {}) {
1757
3796
  for (const { filePath, stat, size, cached } of ranked) {
1758
3797
  const content = (() => {
1759
3798
  try {
1760
- return fs5__namespace.default.readFileSync(filePath, "utf8");
3799
+ return fs9__namespace.default.readFileSync(filePath, "utf8");
1761
3800
  } catch {
1762
3801
  return null;
1763
3802
  }
@@ -1765,7 +3804,7 @@ function scanWorkspace(rootDir, options = {}) {
1765
3804
  if (!content) continue;
1766
3805
  const hash = hashContentNative(content);
1767
3806
  if (cached && cached.hash === hash && cached.mtimeMs === stat.mtimeMs && cached.size === size) {
1768
- log2.debug(`cache HIT ${filePath}`);
3807
+ log3.debug(`cache HIT ${filePath}`);
1769
3808
  processResult({ file: filePath, classes: cached.classes });
1770
3809
  updatedEntries.push({
1771
3810
  file: filePath,
@@ -1777,7 +3816,7 @@ function scanWorkspace(rootDir, options = {}) {
1777
3816
  });
1778
3817
  continue;
1779
3818
  }
1780
- log2.debug(`cache MISS ${filePath}`);
3819
+ log3.debug(`cache MISS ${filePath}`);
1781
3820
  const classes = scanSource(content);
1782
3821
  processResult({ file: filePath, classes });
1783
3822
  updatedEntries.push({
@@ -1792,7 +3831,7 @@ function scanWorkspace(rootDir, options = {}) {
1792
3831
  try {
1793
3832
  writeCache(rootDir, updatedEntries, normalizedOptions.cacheDir);
1794
3833
  } catch (error) {
1795
- log2.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
3834
+ log3.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
1796
3835
  }
1797
3836
  return parseScanWorkspaceResult({
1798
3837
  files,
@@ -1808,7 +3847,7 @@ function scanWorkspace(rootDir, options = {}) {
1808
3847
  }
1809
3848
  } else {
1810
3849
  for (const filePath of candidates) {
1811
- processResult(scanFile(filePath));
3850
+ processResult(scanFile2(filePath));
1812
3851
  }
1813
3852
  }
1814
3853
  return parseScanWorkspaceResult({
@@ -1818,6 +3857,60 @@ function scanWorkspace(rootDir, options = {}) {
1818
3857
  });
1819
3858
  }
1820
3859
 
3860
+ // packages/presentation/next/src/withTailwindStyled.ts
3861
+ init_src2();
3862
+ var _fileStaticCssMap = /* @__PURE__ */ new Map();
3863
+ function setFileStaticCss(filepath, css) {
3864
+ if (css && css.trim()) {
3865
+ _fileStaticCssMap.set(filepath, css.trim());
3866
+ } else {
3867
+ _fileStaticCssMap.delete(filepath);
3868
+ }
3869
+ }
3870
+ function buildContent(map) {
3871
+ const seen = /* @__PURE__ */ new Set();
3872
+ const rules = [];
3873
+ for (const css of map.values()) {
3874
+ for (const chunk of css.split(/(?<=\})\s*/)) {
3875
+ const rule = chunk.trim();
3876
+ if (rule && !seen.has(rule)) {
3877
+ seen.add(rule);
3878
+ rules.push(rule);
3879
+ }
3880
+ }
3881
+ }
3882
+ return rules.join("\n");
3883
+ }
3884
+ var HEADER = `/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
3885
+ * Import di globals.css: @import "./_tw-state-static.css";
3886
+ * Berisi: state CSS (.tw-s-*[data-*="true"]) + container queries (@container .tw-cq-*).
3887
+ * Di-rebuild penuh setiap webpack compilation selesai \u2014 tidak ada stale rules.
3888
+ */
3889
+
3890
+ `;
3891
+ var StaticCssWebpackPlugin = class _StaticCssWebpackPlugin {
3892
+ static PLUGIN_NAME = "TailwindStyledStaticCss";
3893
+ outPath;
3894
+ constructor(safelistPath) {
3895
+ this.outPath = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "_tw-state-static.css");
3896
+ }
3897
+ apply(compiler) {
3898
+ compiler.hooks.done.tap(_StaticCssWebpackPlugin.PLUGIN_NAME, () => {
3899
+ try {
3900
+ const content = buildContent(_fileStaticCssMap);
3901
+ fs9__namespace.default.mkdirSync(path10__namespace.default.dirname(this.outPath), { recursive: true });
3902
+ fs9__namespace.default.writeFileSync(
3903
+ this.outPath,
3904
+ HEADER + (content || "/* no static rules yet */") + "\n",
3905
+ "utf-8"
3906
+ );
3907
+ } catch (e) {
3908
+ console.warn("[tailwind-styled] Could not write _tw-state-static.css:", e);
3909
+ }
3910
+ });
3911
+ }
3912
+ };
3913
+
1821
3914
  // packages/presentation/next/src/withTailwindStyled.ts
1822
3915
  function getDirnameFromUrl2(importMetaUrl) {
1823
3916
  if (typeof importMetaUrl !== "string") return "";
@@ -1840,12 +3933,12 @@ var resolveLoaderPath2 = (basename) => {
1840
3933
  } catch {
1841
3934
  const runtimeDir = resolveRuntimeDir2();
1842
3935
  const candidates = [
1843
- path5__namespace.default.resolve(runtimeDir, `${basename}.mjs`),
1844
- path5__namespace.default.resolve(runtimeDir, `${basename}.js`),
1845
- path5__namespace.default.resolve(runtimeDir, `${basename}.cjs`)
3936
+ path10__namespace.default.resolve(runtimeDir, `${basename}.mjs`),
3937
+ path10__namespace.default.resolve(runtimeDir, `${basename}.js`),
3938
+ path10__namespace.default.resolve(runtimeDir, `${basename}.cjs`)
1846
3939
  ];
1847
3940
  for (const candidate of candidates) {
1848
- if (fs5__namespace.default.existsSync(candidate)) {
3941
+ if (fs9__namespace.default.existsSync(candidate)) {
1849
3942
  return candidate;
1850
3943
  }
1851
3944
  }
@@ -1869,7 +3962,7 @@ function checkNextVersion() {
1869
3962
  }
1870
3963
  var DEFAULT_INCLUDE = /\.[jt]sx?$/;
1871
3964
  var DEFAULT_EXCLUDE = /node_modules/;
1872
- var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
3965
+ var NEXT_RSC_ENTRIES = /(?:^|[\\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
1873
3966
  var buildExcludePattern = (userExclude) => {
1874
3967
  if (!userExclude) return new RegExp(`(?:${DEFAULT_EXCLUDE.source})|(?:${NEXT_RSC_ENTRIES.source})`);
1875
3968
  return new RegExp(`(?:${userExclude.source})|(?:${NEXT_RSC_ENTRIES.source})`);
@@ -1883,7 +3976,7 @@ var createLoaderOptions = (options) => {
1883
3976
  preserveImports: true
1884
3977
  };
1885
3978
  if (options.verbose !== void 0) opts.verbose = options.verbose;
1886
- opts.safelistPath = options.safelistPath ?? path5__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
3979
+ opts.safelistPath = options.safelistPath ?? path10__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
1887
3980
  return Object.freeze(opts);
1888
3981
  };
1889
3982
  var buildTurbopackRules = (loaderPath, loaderOptions) => {
@@ -1896,7 +3989,7 @@ var buildTurbopackRules = (loaderPath, loaderOptions) => {
1896
3989
  ])
1897
3990
  );
1898
3991
  };
1899
- var normalizeLoaderPath = (loaderPath) => path5__namespace.default.resolve(loaderPath);
3992
+ var normalizeLoaderPath = (loaderPath) => path10__namespace.default.resolve(loaderPath);
1900
3993
  var applyWebpackRule = (config, options, loaderPath) => {
1901
3994
  const loaderOptions = createLoaderOptions(options);
1902
3995
  const rules = config.module?.rules ?? [];
@@ -1909,16 +4002,20 @@ var applyWebpackRule = (config, options, loaderPath) => {
1909
4002
  if (alreadyRegistered) return config;
1910
4003
  const tailwindStyledRule = {
1911
4004
  test: options.include ?? DEFAULT_INCLUDE,
1912
- // Selalu kecualikan Next.js RSC entry files (layout, page, dll) bahkan jika
1913
- // user menyuplai exclude pattern sendiri — lihat buildExcludePattern.
1914
4005
  exclude: buildExcludePattern(options.exclude),
1915
4006
  enforce: "pre",
1916
4007
  use: [{ loader: loaderPath, options: loaderOptions }]
1917
4008
  };
4009
+ const safelistPath = loaderOptions.safelistPath ?? path10__namespace.default.join(process.cwd(), ".next", "tailwind-styled-safelist.css");
4010
+ const pluginAlreadyRegistered = (config.plugins ?? []).some(
4011
+ (p) => p?.constructor?.name === StaticCssWebpackPlugin.PLUGIN_NAME
4012
+ );
4013
+ const plugins = pluginAlreadyRegistered ? config.plugins ?? [] : [...config.plugins ?? [], new StaticCssWebpackPlugin(safelistPath)];
1918
4014
  config.module = {
1919
4015
  ...config.module ?? {},
1920
4016
  rules: [...rules, tailwindStyledRule]
1921
4017
  };
4018
+ config.plugins = plugins;
1922
4019
  const externalPackages = [
1923
4020
  "tailwind-styled-v4",
1924
4021
  "@tailwind-styled/shared",
@@ -2009,36 +4106,85 @@ function withTailwindStyled(options = {}) {
2009
4106
  return fullCss.slice(startIdx, endIdx + 1);
2010
4107
  };
2011
4108
  var extractUtilitiesLayer = extractUtilitiesLayer2;
2012
- const twClassesDir = path5__namespace.default.join(path5__namespace.default.dirname(safelistPath), "tw-classes");
2013
- fs5__namespace.default.mkdirSync(twClassesDir, { recursive: true });
2014
- fs5__namespace.default.writeFileSync(
2015
- path5__namespace.default.join(twClassesDir, "_start.txt"),
4109
+ const twClassesDir = path10__namespace.default.join(path10__namespace.default.dirname(safelistPath), "tw-classes");
4110
+ fs9__namespace.default.mkdirSync(twClassesDir, { recursive: true });
4111
+ setGlobalLogFile(path10__namespace.default.join(twClassesDir, "_tw-build.log"));
4112
+ fs9__namespace.default.writeFileSync(
4113
+ path10__namespace.default.join(twClassesDir, "_start.txt"),
2016
4114
  String(Date.now()),
2017
4115
  "utf-8"
2018
4116
  );
4117
+ const stateStaticPath = path10__namespace.default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
4118
+ if (!fs9__namespace.default.existsSync(stateStaticPath)) {
4119
+ fs9__namespace.default.writeFileSync(
4120
+ stateStaticPath,
4121
+ "/* tw-state-static.css \u2014 placeholder, akan di-generate setelah scan */\n",
4122
+ "utf-8"
4123
+ );
4124
+ }
4125
+ try {
4126
+ const CSS_CANDIDATES = [
4127
+ "src/app/globals.css",
4128
+ "src/globals.css",
4129
+ "src/styles/globals.css",
4130
+ "src/tailwind.css",
4131
+ "src/index.css",
4132
+ "styles/globals.css"
4133
+ ];
4134
+ const safelistDir = path10__namespace.default.dirname(safelistPath);
4135
+ for (const candidate of CSS_CANDIDATES) {
4136
+ const candidatePath = path10__namespace.default.join(process.cwd(), candidate);
4137
+ if (!fs9__namespace.default.existsSync(candidatePath)) continue;
4138
+ const content = fs9__namespace.default.readFileSync(candidatePath, "utf-8");
4139
+ if (content.includes("_tw-state-static.css")) break;
4140
+ const globalsDir = path10__namespace.default.dirname(candidatePath);
4141
+ const rel = path10__namespace.default.relative(globalsDir, stateStaticPath).replace(/\\/g, "/");
4142
+ const importLine = `@import "./${rel}";`;
4143
+ const tailwindImportRe = /(@import\s+["']tailwindcss["']\s*;[^\n]*\n?)/;
4144
+ let updated;
4145
+ if (tailwindImportRe.test(content)) {
4146
+ updated = content.replace(
4147
+ tailwindImportRe,
4148
+ `$1${importLine}
4149
+ `
4150
+ );
4151
+ } else {
4152
+ updated = `${importLine}
4153
+ ${content}`;
4154
+ }
4155
+ fs9__namespace.default.writeFileSync(candidatePath, updated, "utf-8");
4156
+ if (options.verbose) {
4157
+ console.log(
4158
+ `[tailwind-styled] Auto-injected "${importLine}" into ${candidate}`
4159
+ );
4160
+ }
4161
+ break;
4162
+ }
4163
+ } catch {
4164
+ }
2019
4165
  if (!process.env.TW_NATIVE_PATH) {
2020
4166
  const runtimeDir = resolveRuntimeDir2();
2021
- const nativePath = path5__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
2022
- if (fs5__namespace.default.existsSync(nativePath)) {
4167
+ const nativePath = path10__namespace.default.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node");
4168
+ if (fs9__namespace.default.existsSync(nativePath)) {
2023
4169
  process.env.TW_NATIVE_PATH = nativePath;
2024
4170
  }
2025
4171
  }
2026
- const srcDir = path5__namespace.default.join(process.cwd(), "src");
2027
- if (fs5__namespace.default.existsSync(srcDir)) {
4172
+ const srcDir = path10__namespace.default.join(process.cwd(), "src");
4173
+ if (fs9__namespace.default.existsSync(srcDir)) {
2028
4174
  try {
2029
- const result = scanWorkspace(srcDir);
4175
+ const result = scanWorkspace2(srcDir);
2030
4176
  if (result.uniqueClasses.length > 0) {
2031
4177
  let atomicWriteFile2 = function(filePath, content) {
2032
4178
  const tmpPath = `${filePath}.tmp`;
2033
4179
  try {
2034
- fs5__namespace.default.writeFileSync(tmpPath, content, "utf-8");
2035
- fs5__namespace.default.renameSync(tmpPath, filePath);
4180
+ fs9__namespace.default.writeFileSync(tmpPath, content, "utf-8");
4181
+ fs9__namespace.default.renameSync(tmpPath, filePath);
2036
4182
  } catch {
2037
4183
  try {
2038
- fs5__namespace.default.unlinkSync(tmpPath);
4184
+ fs9__namespace.default.unlinkSync(tmpPath);
2039
4185
  } catch {
2040
4186
  }
2041
- fs5__namespace.default.writeFileSync(filePath, content, "utf-8");
4187
+ fs9__namespace.default.writeFileSync(filePath, content, "utf-8");
2042
4188
  }
2043
4189
  };
2044
4190
  var atomicWriteFile = atomicWriteFile2;
@@ -2101,14 +4247,14 @@ function withTailwindStyled(options = {}) {
2101
4247
  "styles/globals.css"
2102
4248
  ];
2103
4249
  try {
2104
- const twConfigPath = path5__namespace.default.join(process.cwd(), "tailwind-styled.config.json");
2105
- if (fs5__namespace.default.existsSync(twConfigPath)) {
2106
- const twConfig = JSON.parse(fs5__namespace.default.readFileSync(twConfigPath, "utf-8"));
4250
+ const twConfigPath = path10__namespace.default.join(process.cwd(), "tailwind-styled.config.json");
4251
+ if (fs9__namespace.default.existsSync(twConfigPath)) {
4252
+ const twConfig = JSON.parse(fs9__namespace.default.readFileSync(twConfigPath, "utf-8"));
2107
4253
  const cssEntry = twConfig.css?.entry;
2108
4254
  if (cssEntry) {
2109
- const cssEntryPath = path5__namespace.default.join(process.cwd(), cssEntry);
2110
- if (fs5__namespace.default.existsSync(cssEntryPath)) {
2111
- cssEntryContent = fs5__namespace.default.readFileSync(cssEntryPath, "utf-8");
4255
+ const cssEntryPath = path10__namespace.default.join(process.cwd(), cssEntry);
4256
+ if (fs9__namespace.default.existsSync(cssEntryPath)) {
4257
+ cssEntryContent = fs9__namespace.default.readFileSync(cssEntryPath, "utf-8");
2112
4258
  }
2113
4259
  }
2114
4260
  }
@@ -2116,9 +4262,9 @@ function withTailwindStyled(options = {}) {
2116
4262
  }
2117
4263
  if (!cssEntryContent) {
2118
4264
  for (const candidate of CSS_CANDIDATES) {
2119
- const candidatePath = path5__namespace.default.join(process.cwd(), candidate);
2120
- if (fs5__namespace.default.existsSync(candidatePath)) {
2121
- cssEntryContent = fs5__namespace.default.readFileSync(candidatePath, "utf-8");
4265
+ const candidatePath = path10__namespace.default.join(process.cwd(), candidate);
4266
+ if (fs9__namespace.default.existsSync(candidatePath)) {
4267
+ cssEntryContent = fs9__namespace.default.readFileSync(candidatePath, "utf-8");
2122
4268
  break;
2123
4269
  }
2124
4270
  }
@@ -2126,8 +4272,8 @@ function withTailwindStyled(options = {}) {
2126
4272
  if (cssEntryContent) {
2127
4273
  cssEntryContent = cssEntryContent.replace(/@source\s+["'][^"']+["']\s*;?\s*/g, "").replace(/←[^\n]*/g, "").trim();
2128
4274
  }
2129
- const initialScanPath = path5__namespace.default.join(twClassesDir, "_initial-scan.css");
2130
- if (!fs5__namespace.default.existsSync(initialScanPath)) {
4275
+ const initialScanPath = path10__namespace.default.join(twClassesDir, "_initial-scan.css");
4276
+ if (!fs9__namespace.default.existsSync(initialScanPath)) {
2131
4277
  atomicWriteFile2(
2132
4278
  initialScanPath,
2133
4279
  "/* tw-classes: initial scan \u2014 generating... */\n@layer utilities {}\n"
@@ -2135,7 +4281,7 @@ function withTailwindStyled(options = {}) {
2135
4281
  }
2136
4282
  void (async () => {
2137
4283
  try {
2138
- const compiler = await Promise.resolve().then(() => (init_src2(), src_exports));
4284
+ const compiler = await Promise.resolve().then(() => (init_src(), src_exports));
2139
4285
  const generateCssForClasses2 = compiler.generateCssForClasses;
2140
4286
  const css = await generateCssForClasses2(
2141
4287
  filteredClasses,
@@ -2152,25 +4298,36 @@ function withTailwindStyled(options = {}) {
2152
4298
  `/* tw-classes: initial scan \u2014 auto-generated by withTailwindStyled */
2153
4299
  ${utilitiesOnly}`
2154
4300
  );
4301
+ const summary = appendStaticStateCssToSafelist(srcDir, safelistPath, {
4302
+ verbose: options.verbose ?? false,
4303
+ resolvedCss: css
4304
+ });
4305
+ if (options.verbose) console.log(summary);
2155
4306
  }
2156
4307
  } catch (err) {
2157
- console.warn("[tailwind-styled] generateCssForClasses gagal, fallback ke empty rules:", err.message?.split("\n")[0]);
2158
- const css = [
2159
- "/* tw-safelist: initial scan \u2014 auto-generated by withTailwindStyled (fallback) */",
2160
- "@layer utilities {",
2161
- filteredClasses.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
2162
- "}"
2163
- ].join("\n");
2164
- atomicWriteFile2(initialScanPath, css);
4308
+ throw new Error(
4309
+ `[tailwind-styled] generateCssForClasses gagal \u2014 build-time CSS generation wajib berhasil.
4310
+ ${err.message}`,
4311
+ { cause: err }
4312
+ );
2165
4313
  }
2166
4314
  })();
2167
4315
  }
2168
4316
  } catch (e) {
2169
- console.warn("[tailwind-styled] Initial scan skipped:", e.message?.split("\n")[0]);
4317
+ throw new Error(
4318
+ `[tailwind-styled] Scanner gagal \u2014 Rust native binary tidak tersedia. Build tidak bisa dilanjutkan.
4319
+ ${e.message}`,
4320
+ { cause: e }
4321
+ );
2170
4322
  }
2171
4323
  }
2172
4324
  }
2173
- } catch {
4325
+ } catch (err) {
4326
+ throw new Error(
4327
+ `[tailwind-styled] Build-time CSS generation gagal.
4328
+ ${err.message}`,
4329
+ { cause: err }
4330
+ );
2174
4331
  }
2175
4332
  return {
2176
4333
  ...nextConfig,
@@ -2238,7 +4395,9 @@ ${utilitiesOnly}`
2238
4395
  }
2239
4396
 
2240
4397
  exports.NextAdapterOptionsSchema = NextAdapterOptionsSchema;
4398
+ exports.StaticCssWebpackPlugin = StaticCssWebpackPlugin;
2241
4399
  exports.parseNextAdapterOptions = parseNextAdapterOptions;
4400
+ exports.setFileStaticCss = setFileStaticCss;
2242
4401
  exports.withTailwindStyled = withTailwindStyled;
2243
4402
  //# sourceMappingURL=next.js.map
2244
4403
  //# sourceMappingURL=next.js.map