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
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var module$1 = require('module');
4
- var fs3 = require('fs');
5
- var path3 = require('path');
4
+ var fs4 = require('fs');
5
+ var path4 = require('path');
6
6
  require('crypto');
7
7
  var url = require('url');
8
8
 
@@ -25,11 +25,14 @@ function _interopNamespace(e) {
25
25
  return Object.freeze(n);
26
26
  }
27
27
 
28
- var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
29
- var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
28
+ var fs4__namespace = /*#__PURE__*/_interopNamespace(fs4);
29
+ var path4__namespace = /*#__PURE__*/_interopNamespace(path4);
30
30
 
31
31
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
32
+ var __defProp = Object.defineProperty;
33
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
32
34
  var __getOwnPropNames = Object.getOwnPropertyNames;
35
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
33
36
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
34
37
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
35
38
  }) : x)(function(x) {
@@ -39,6 +42,19 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
39
42
  var __esm = (fn, res) => function __init() {
40
43
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
41
44
  };
45
+ var __export = (target, all) => {
46
+ for (var name in all)
47
+ __defProp(target, name, { get: all[name], enumerable: true });
48
+ };
49
+ var __copyProps = (to, from, except, desc) => {
50
+ if (from && typeof from === "object" || typeof from === "function") {
51
+ for (let key of __getOwnPropNames(from))
52
+ if (!__hasOwnProp.call(to, key) && key !== except)
53
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
54
+ }
55
+ return to;
56
+ };
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
58
  function platformKey() {
43
59
  if (isBrowser) return "browser";
44
60
  return `${process.platform}-${process.arch}`;
@@ -49,12 +65,12 @@ function resolveNativeBinary(runtimeDir) {
49
65
  if (isBrowser) {
50
66
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
51
67
  }
52
- if (process.env.TWS_DISABLE_NATIVE === "1") {
68
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
53
69
  return { path: null, source: "not-found", platform, tried: [] };
54
70
  }
55
71
  const envPath = process.env.TW_NATIVE_PATH?.trim();
56
72
  if (envPath) {
57
- if (fs3__namespace.existsSync(envPath)) {
73
+ if (fs4__namespace.existsSync(envPath)) {
58
74
  return { path: envPath, source: "env", platform, tried };
59
75
  }
60
76
  tried.push(`env:${envPath} (not found)`);
@@ -63,7 +79,7 @@ function resolveNativeBinary(runtimeDir) {
63
79
  for (const pkg of prebuiltPkgs) {
64
80
  try {
65
81
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
66
- if (fs3__namespace.existsSync(candidate)) {
82
+ if (fs4__namespace.existsSync(candidate)) {
67
83
  return { path: candidate, source: "prebuilt", platform, tried };
68
84
  }
69
85
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -74,13 +90,13 @@ function resolveNativeBinary(runtimeDir) {
74
90
  const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
75
91
  const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
76
92
  if (runtimeDir) {
77
- for (const depth of ["..", path3__namespace.join("..", ".."), path3__namespace.join("..", "..", "..")]) {
78
- const pkgRoot = path3__namespace.resolve(runtimeDir, depth);
93
+ for (const depth of ["..", path4__namespace.join("..", ".."), path4__namespace.join("..", "..", "..")]) {
94
+ const pkgRoot = path4__namespace.resolve(runtimeDir, depth);
79
95
  for (const bin of BINARY_NAMES_SELF) {
80
96
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
81
- const candidate = path3__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
97
+ const candidate = path4__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
82
98
  tried.push(`self-bundled:${candidate}`);
83
- if (fs3__namespace.existsSync(candidate)) {
99
+ if (fs4__namespace.existsSync(candidate)) {
84
100
  return { path: candidate, source: "prebuilt", platform, tried };
85
101
  }
86
102
  }
@@ -92,29 +108,29 @@ function resolveNativeBinary(runtimeDir) {
92
108
  const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
93
109
  const localCandidates = [];
94
110
  for (const bin of BINARY_NAMES) {
95
- localCandidates.push(path3__namespace.resolve(base, `${bin}.node`));
96
- localCandidates.push(path3__namespace.resolve(base, "..", `${bin}.node`));
97
- localCandidates.push(path3__namespace.resolve(base, `${bin}.${platform}.node`));
98
- localCandidates.push(path3__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
111
+ localCandidates.push(path4__namespace.resolve(base, `${bin}.node`));
112
+ localCandidates.push(path4__namespace.resolve(base, "..", `${bin}.node`));
113
+ localCandidates.push(path4__namespace.resolve(base, `${bin}.${platform}.node`));
114
+ localCandidates.push(path4__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
99
115
  }
100
116
  for (const startDir of [cwd, base]) {
101
117
  let dir = startDir;
102
118
  for (let i = 0; i < 6; i++) {
103
- const nativeDir = path3__namespace.resolve(dir, "native");
119
+ const nativeDir = path4__namespace.resolve(dir, "native");
104
120
  for (const bin of BINARY_NAMES) {
105
- localCandidates.push(path3__namespace.resolve(nativeDir, `${bin}.node`));
106
- localCandidates.push(path3__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
107
- localCandidates.push(path3__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
108
- localCandidates.push(path3__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
121
+ localCandidates.push(path4__namespace.resolve(nativeDir, `${bin}.node`));
122
+ localCandidates.push(path4__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
123
+ localCandidates.push(path4__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
124
+ localCandidates.push(path4__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
109
125
  }
110
- const parent = path3__namespace.resolve(dir, "..");
126
+ const parent = path4__namespace.resolve(dir, "..");
111
127
  if (parent === dir) break;
112
128
  dir = parent;
113
129
  }
114
130
  }
115
131
  for (const candidate of localCandidates) {
116
132
  tried.push(`local:${candidate}`);
117
- if (fs3__namespace.existsSync(candidate)) {
133
+ if (fs4__namespace.existsSync(candidate)) {
118
134
  return { path: candidate, source: "local", platform, tried };
119
135
  }
120
136
  }
@@ -137,7 +153,7 @@ var init_native_resolution = __esm({
137
153
  });
138
154
  function resolveRuntimeDir(dir, importMetaUrl) {
139
155
  try {
140
- return path3__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
156
+ return path4__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
141
157
  } catch {
142
158
  return process.cwd();
143
159
  }
@@ -150,11 +166,11 @@ var init_src = __esm({
150
166
  });
151
167
 
152
168
  // packages/domain/compiler/src/nativeBridge.ts
153
- var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
169
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
154
170
  var init_nativeBridge = __esm({
155
171
  "packages/domain/compiler/src/nativeBridge.ts"() {
156
172
  init_src();
157
- _loadNative = (path4) => __require(path4);
173
+ _loadNative = (path5) => __require(path5);
158
174
  log = (...args) => {
159
175
  if (process.env.DEBUG?.includes("compiler:native")) {
160
176
  console.log("[compiler:native]", ...args);
@@ -203,6 +219,15 @@ Tried paths: ${result.tried.join("\n")}`);
203
219
  throw bridgeLoadError;
204
220
  }
205
221
  };
222
+ adaptNativeResult = (raw) => {
223
+ return {
224
+ code: raw.code ?? "",
225
+ classes: raw.classes ?? [],
226
+ changed: raw.changed ?? false,
227
+ rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
228
+ metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
229
+ };
230
+ };
206
231
  if (typeof process !== "undefined" && !bridgeLoadAttempted) {
207
232
  try {
208
233
  getNativeBridge();
@@ -212,193 +237,2332 @@ Tried paths: ${result.tried.join("\n")}`);
212
237
  }
213
238
  });
214
239
 
215
- // packages/domain/compiler/src/index.ts
216
- init_nativeBridge();
217
- var transformSource = (source, opts) => {
240
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
241
+ async function generateCssNative(classes, options) {
242
+ const { theme } = options;
218
243
  const native = getNativeBridge();
219
- if (!native?.transformSource) {
220
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
244
+ if (!native?.generateCssNative) {
245
+ throw new Error(
246
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
247
+ );
221
248
  }
222
- const result = native.transformSource(source, opts);
223
- if (!result) {
224
- throw new Error("FATAL: transformSource returned null");
249
+ const themeJson = JSON.stringify(theme);
250
+ const css = native.generateCssNative(classes, themeJson);
251
+ return css;
252
+ }
253
+ function clearThemeCache() {
254
+ try {
255
+ const native = getNativeBridge();
256
+ if (!native?.clearThemeCache) {
257
+ return;
258
+ }
259
+ native.clearThemeCache();
260
+ } catch {
225
261
  }
226
- return result;
227
- };
228
- var runLoaderTransform = (ctx) => {
229
- const { filepath, source, options } = ctx;
230
- const result = transformSource(source, { filename: filepath, ...options });
231
- return {
232
- code: result?.code || "",
233
- changed: result?.changed || false,
234
- classes: result?.classes || []
235
- };
236
- };
237
- var registerFileClasses = (_filepath, _classes) => {
238
- };
239
- function parseBool(val, fallback = false) {
240
- if (typeof val === "boolean") return val;
241
- if (typeof val === "string") return val === "true" || val === "1";
242
- return fallback;
243
262
  }
244
- function parseNum(val) {
245
- if (typeof val === "number") return val;
246
- if (typeof val === "string") return parseInt(val, 10) || void 0;
247
- return void 0;
263
+ var init_cssGeneratorNative = __esm({
264
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
265
+ init_nativeBridge();
266
+ }
267
+ });
268
+
269
+ // packages/domain/compiler/src/compiler/compilationNative.ts
270
+ function compileCssNative2(classes, prefix) {
271
+ const native = getNativeBridge();
272
+ if (!native?.compileCss) throw new Error("compileCss not available");
273
+ return native.compileCss(classes, prefix);
248
274
  }
249
- function detectRouter(resourcePath) {
250
- const normalized = resourcePath.replace(/\\/g, "/");
251
- if (/\/app\//.test(normalized)) return "app";
252
- if (/\/pages\//.test(normalized)) return "pages";
253
- return "unknown";
275
+ function compileCssLightning(classes) {
276
+ const native = getNativeBridge();
277
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
278
+ return native.compileCssLightning(classes);
254
279
  }
255
- var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
256
- function isSkippable(resourcePath) {
257
- const normalized = resourcePath.replace(/\\/g, "/");
258
- return normalized.includes("/node_modules/") || normalized.endsWith(".d.ts") || normalized.endsWith(".d.mts") || normalized.endsWith(".d.cts") || // Skip CSS/assets
259
- /\.(css|scss|sass|less|svg|png|jpg|jpeg|gif|webp|ico|woff|woff2|ttf|eot)$/.test(normalized) || // Skip Next.js RSC entry files — Turbopack tidak punya exclude di rule level,
260
- // jadi guard ini menggantikan NEXT_RSC_ENTRIES exclude yang ada di webpack path.
261
- NEXT_RSC_ENTRIES.test(normalized);
280
+ function extractTwStateConfigsNative(source, filename) {
281
+ const native = getNativeBridge();
282
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
283
+ return native.extractTwStateConfigs(source, filename);
262
284
  }
263
- function extractDirective(source) {
264
- const match = source.match(/^(\s*["'](use client|use server)["']\s*;?\s*\n?)/);
265
- if (!match) return { directive: "", stripped: source };
266
- const directive = match[1].trim().replace(/['"]/g, '"') + "\n";
267
- const stripped = source.slice(match[0].length);
268
- return { directive, stripped };
285
+ function generateStaticStateCssNative(inputs, resolvedCss) {
286
+ const native = getNativeBridge();
287
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
288
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
269
289
  }
270
- var CYCLE_SENTINEL = "_cycle.txt";
271
- var START_SENTINEL = "_start.txt";
272
- var _workerCache = /* @__PURE__ */ new Map();
273
- function getTwClassesDir(safelistPath) {
274
- return path3__namespace.default.join(path3__namespace.default.dirname(safelistPath), "tw-classes");
290
+ function extractAndGenerateStateCssNative(source, filename) {
291
+ const native = getNativeBridge();
292
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
293
+ return native.extractAndGenerateStateCss(source, filename);
275
294
  }
276
- function readSentinel(filePath) {
295
+ function layoutClassesToCss(classes) {
296
+ const native = getNativeBridge();
297
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
298
+ return native.layoutClassesToCss(classes);
299
+ }
300
+ function hashContent(input, algorithm = "sha256", length = 8) {
301
+ const native = getNativeBridge();
302
+ if (!native?.hashContent) throw new Error("hashContent not available");
303
+ return native.hashContent(input, algorithm, length);
304
+ }
305
+ function extractTwContainerConfigs(source) {
306
+ const native = getNativeBridge();
307
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
308
+ return native.extractTwContainerConfigs(source);
309
+ }
310
+ function parseAtomicClass(twClass) {
311
+ const native = getNativeBridge();
312
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
313
+ return native.parseAtomicClass(twClass);
314
+ }
315
+ function generateAtomicCss(rulesJson) {
316
+ const native = getNativeBridge();
317
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
318
+ return native.generateAtomicCss(rulesJson);
319
+ }
320
+ function toAtomicClasses(twClasses) {
321
+ const native = getNativeBridge();
322
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
323
+ return native.toAtomicClasses(twClasses);
324
+ }
325
+ function clearAtomicRegistry() {
326
+ const native = getNativeBridge();
327
+ if (!native?.clearAtomicRegistry) return;
328
+ native.clearAtomicRegistry();
329
+ }
330
+ function atomicRegistrySize() {
331
+ const native = getNativeBridge();
332
+ if (!native?.atomicRegistrySize) return 0;
333
+ return native.atomicRegistrySize();
334
+ }
335
+ var init_compilationNative = __esm({
336
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
337
+ init_nativeBridge();
338
+ }
339
+ });
340
+
341
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
342
+ function compileClass(input) {
343
+ const native = getNativeBridge();
344
+ if (!native?.compile_class) throw new Error("compile_class not available");
345
+ const resultJson = native.compile_class(input);
277
346
  try {
278
- return fs3__namespace.default.readFileSync(filePath, "utf-8").trim();
347
+ return JSON.parse(resultJson);
279
348
  } catch {
280
- return "";
349
+ return {
350
+ selector: "",
351
+ declarations: "",
352
+ properties: [],
353
+ specificity: 0
354
+ };
281
355
  }
282
356
  }
283
- var _clearLock = false;
284
- function clearAndMarkCycle(twClassesDir, startId) {
285
- if (_clearLock) return;
286
- _clearLock = true;
357
+ function compileClasses(inputs) {
358
+ const native = getNativeBridge();
359
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
360
+ const resultJson = native.compile_classes(inputs);
287
361
  try {
288
- if (fs3__namespace.default.existsSync(twClassesDir)) {
289
- const tempDir = `${twClassesDir}_clearing_${Date.now()}`;
290
- try {
291
- fs3__namespace.default.renameSync(twClassesDir, tempDir);
292
- fs3__namespace.default.mkdirSync(twClassesDir, { recursive: true });
293
- const startFile = path3__namespace.default.join(tempDir, START_SENTINEL);
294
- if (fs3__namespace.default.existsSync(startFile)) {
295
- fs3__namespace.default.copyFileSync(startFile, path3__namespace.default.join(twClassesDir, START_SENTINEL));
296
- }
297
- const mergedFile = path3__namespace.default.join(tempDir, "_webpack-merged.css");
298
- if (fs3__namespace.default.existsSync(mergedFile)) {
299
- fs3__namespace.default.copyFileSync(mergedFile, path3__namespace.default.join(twClassesDir, "_webpack-merged.css"));
300
- }
301
- fs3__namespace.default.writeFileSync(path3__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
302
- _workerCache.set(twClassesDir, startId);
303
- fs3__namespace.default.rmSync(tempDir, { recursive: true, force: true });
304
- } catch {
305
- for (const file of fs3__namespace.default.readdirSync(twClassesDir)) {
306
- if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
307
- try {
308
- fs3__namespace.default.unlinkSync(path3__namespace.default.join(twClassesDir, file));
309
- } catch {
310
- }
311
- }
312
- fs3__namespace.default.writeFileSync(path3__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
313
- _workerCache.set(twClassesDir, startId);
314
- }
315
- } else {
316
- fs3__namespace.default.mkdirSync(twClassesDir, { recursive: true });
317
- fs3__namespace.default.writeFileSync(path3__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
318
- _workerCache.set(twClassesDir, startId);
319
- }
362
+ return JSON.parse(resultJson);
320
363
  } catch {
321
- } finally {
322
- _clearLock = false;
364
+ return {
365
+ css: "",
366
+ resolved_classes: [],
367
+ unknown_classes: [],
368
+ size_bytes: 0,
369
+ duration_ms: 0
370
+ };
323
371
  }
324
372
  }
325
- function getPerFileSafelistPath(safelistDir, resourcePath) {
326
- const normalized = resourcePath.replace(/\\/g, "/");
327
- const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
328
- return path3__namespace.default.join(safelistDir, `${slug}.css`);
373
+ function compileToCss(input, minify) {
374
+ const native = getNativeBridge();
375
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
376
+ return native.compile_to_css(input, minify ?? false);
329
377
  }
330
- function writePerFileSafelist(safelistPath, resourcePath, classes) {
331
- if (!safelistPath || classes.length === 0) return;
378
+ function compileToCssBatch(inputs, minify) {
379
+ const native = getNativeBridge();
380
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
381
+ return native.compile_to_css_batch(inputs, minify ?? false);
382
+ }
383
+ function minifyCss(css) {
384
+ const native = getNativeBridge();
385
+ if (!native?.minify_css) throw new Error("minify_css not available");
386
+ return native.minify_css(css);
387
+ }
388
+ function compileAnimation(animationName, from, to) {
389
+ const native = getNativeBridge();
390
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
391
+ const resultJson = native.compile_animation(animationName, from, to);
332
392
  try {
333
- const twClassesDir = getTwClassesDir(safelistPath);
334
- const startId = readSentinel(path3__namespace.default.join(twClassesDir, START_SENTINEL));
335
- const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path3__namespace.default.join(twClassesDir, CYCLE_SENTINEL));
336
- if (startId && cachedCycle !== startId) {
337
- clearAndMarkCycle(twClassesDir, startId);
338
- } else if (!fs3__namespace.default.existsSync(twClassesDir)) {
339
- fs3__namespace.default.mkdirSync(twClassesDir, { recursive: true });
340
- }
341
- const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
342
- const sorted = [...new Set(classes)].sort();
343
- const css = [
344
- `/* tw-safelist: ${path3__namespace.default.basename(resourcePath)} \u2014 auto-generated */`,
345
- "@layer utilities {",
346
- sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
347
- "}"
348
- ].join("\n");
349
- try {
350
- if (fs3__namespace.default.readFileSync(outPath, "utf-8") === css) return;
351
- } catch {
352
- }
353
- const tmpPath = `${outPath}.tmp`;
354
- try {
355
- fs3__namespace.default.writeFileSync(tmpPath, css, "utf-8");
356
- fs3__namespace.default.renameSync(tmpPath, outPath);
357
- } catch {
358
- try {
359
- fs3__namespace.default.unlinkSync(tmpPath);
360
- } catch {
361
- }
362
- fs3__namespace.default.writeFileSync(outPath, css, "utf-8");
363
- }
393
+ return JSON.parse(resultJson);
364
394
  } catch {
395
+ return {
396
+ animation_id: "",
397
+ keyframes_css: "",
398
+ animation_rule: "",
399
+ duration_ms: 0
400
+ };
365
401
  }
366
402
  }
367
- function turbopackLoader(source, options = {}) {
368
- if (isSkippable(this.resourcePath)) return source;
369
- const router = detectRouter(this.resourcePath);
370
- const nextMajor = parseNum(options.nextMajor);
371
- const debug = parseBool(options.debug);
372
- const filename = path3__namespace.default.basename(this.resourcePath);
373
- const effective = {
374
- addDataAttr: parseBool(options.addDataAttr),
375
- // App Router: selalu auto-detect client boundary
376
- // Pages Router: opt-in via option
377
- autoClientBoundary: router === "app" ? true : parseBool(options.autoClientBoundary),
378
- // Hoist by default untuk semua contexts
379
- hoist: parseBool(options.hoist, true),
380
- // Pages Router: preserve imports (RSC tidak berlaku)
381
- preserveImports: router === "pages" ? true : parseBool(options.preserveImports, false)
403
+ function compileKeyframes(name, stopsJson) {
404
+ const native = getNativeBridge();
405
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
406
+ const resultJson = native.compile_keyframes(name, stopsJson);
407
+ try {
408
+ return JSON.parse(resultJson);
409
+ } catch {
410
+ return {
411
+ animation_id: "",
412
+ keyframes_css: "",
413
+ animation_rule: "",
414
+ duration_ms: 0
415
+ };
416
+ }
417
+ }
418
+ function compileTheme(tokensJson, themeName, prefix) {
419
+ const native = getNativeBridge();
420
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
421
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
422
+ try {
423
+ return JSON.parse(resultJson);
424
+ } catch {
425
+ return {
426
+ selector: ":root",
427
+ variables: [],
428
+ variables_css: "",
429
+ theme_name: themeName
430
+ };
431
+ }
432
+ }
433
+ function twMerge(classString) {
434
+ const native = getNativeBridge();
435
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
436
+ return native.tw_merge(classString);
437
+ }
438
+ function twMergeMany(classStrings) {
439
+ const native = getNativeBridge();
440
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
441
+ return native.tw_merge_many(classStrings);
442
+ }
443
+ function twMergeWithSeparator(classString, options) {
444
+ const native = getNativeBridge();
445
+ if (!native?.tw_merge_with_separator)
446
+ throw new Error("tw_merge_with_separator not available");
447
+ const opts = {
448
+ separator: options.separator,
449
+ debug: options.debug
382
450
  };
383
- if (debug) {
384
- console.debug(`[tw-loader] ${filename}: router=${router} nextMajor=${nextMajor ?? "unknown"}`);
451
+ return native.tw_merge_with_separator(classString, opts);
452
+ }
453
+ function twMergeManyWithSeparator(classStrings, options) {
454
+ const native = getNativeBridge();
455
+ if (!native?.tw_merge_many_with_separator)
456
+ throw new Error("tw_merge_many_with_separator not available");
457
+ const opts = {
458
+ separator: options.separator,
459
+ debug: options.debug
460
+ };
461
+ return native.tw_merge_many_with_separator(classStrings, opts);
462
+ }
463
+ function twMergeRaw(classLists) {
464
+ const native = getNativeBridge();
465
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
466
+ return native.tw_merge_raw(classLists);
467
+ }
468
+ var init_cssCompilationNative = __esm({
469
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
470
+ init_nativeBridge();
385
471
  }
386
- const { directive, stripped } = extractDirective(source);
472
+ });
473
+
474
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
475
+ function idRegistryCreate() {
476
+ const native = getNativeBridge();
477
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
478
+ return native.id_registry_create();
479
+ }
480
+ function idRegistryGenerate(handle, name) {
481
+ const native = getNativeBridge();
482
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
483
+ return native.id_registry_generate(handle, name);
484
+ }
485
+ function idRegistryLookup(handle, name) {
486
+ const native = getNativeBridge();
487
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
488
+ return native.id_registry_lookup(handle, name);
489
+ }
490
+ function idRegistryNext(handle) {
491
+ const native = getNativeBridge();
492
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
493
+ return native.id_registry_next(handle);
494
+ }
495
+ function idRegistryDestroy(handle) {
496
+ const native = getNativeBridge();
497
+ if (!native?.id_registry_destroy) return;
498
+ native.id_registry_destroy(handle);
499
+ }
500
+ function idRegistryReset(handle) {
501
+ const native = getNativeBridge();
502
+ if (!native?.id_registry_reset) return;
503
+ native.id_registry_reset(handle);
504
+ }
505
+ function idRegistrySnapshot(handle) {
506
+ const native = getNativeBridge();
507
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
508
+ const snapshotJson = native.id_registry_snapshot(handle);
387
509
  try {
388
- const output = runLoaderTransform({
389
- filepath: this.resourcePath,
390
- source: stripped,
391
- options: effective
392
- });
393
- if (!output.changed) {
394
- if (output.classes.length > 0) {
395
- writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
396
- }
397
- return source;
398
- }
399
- if (output.classes.length > 0) {
400
- registerFileClasses(this.resourcePath, output.classes);
401
- writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
510
+ return JSON.parse(snapshotJson);
511
+ } catch {
512
+ return {
513
+ handle,
514
+ next_id: 0,
515
+ entries: [],
516
+ total_entries: 0
517
+ };
518
+ }
519
+ }
520
+ function idRegistryActiveCount() {
521
+ const native = getNativeBridge();
522
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
523
+ return native.id_registry_active_count();
524
+ }
525
+ function registerPropertyName(propertyName) {
526
+ const native = getNativeBridge();
527
+ if (!native?.register_property_name)
528
+ throw new Error("register_property_name not available");
529
+ return native.register_property_name(propertyName);
530
+ }
531
+ function registerValueName(valueName) {
532
+ const native = getNativeBridge();
533
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
534
+ return native.register_value_name(valueName);
535
+ }
536
+ function propertyIdToString(propertyId) {
537
+ const native = getNativeBridge();
538
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
539
+ return native.property_id_to_string(propertyId);
540
+ }
541
+ function valueIdToString(valueId) {
542
+ const native = getNativeBridge();
543
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
544
+ return native.value_id_to_string(valueId);
545
+ }
546
+ function reverseLookupProperty(propertyId) {
547
+ const native = getNativeBridge();
548
+ if (!native?.reverse_lookup_property)
549
+ throw new Error("reverse_lookup_property not available");
550
+ return native.reverse_lookup_property(propertyId);
551
+ }
552
+ function reverseLookupValue(valueId) {
553
+ const native = getNativeBridge();
554
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
555
+ return native.reverse_lookup_value(valueId);
556
+ }
557
+ function idRegistryExport(handle) {
558
+ const native = getNativeBridge();
559
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
560
+ return native.id_registry_export(handle);
561
+ }
562
+ function idRegistryImport(importedData) {
563
+ const native = getNativeBridge();
564
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
565
+ return native.id_registry_import(importedData);
566
+ }
567
+ var init_idRegistryNative = __esm({
568
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
569
+ init_nativeBridge();
570
+ }
571
+ });
572
+
573
+ // packages/domain/compiler/src/compiler/streamingNative.ts
574
+ function processFileChange(fileChangeJson) {
575
+ const native = getNativeBridge();
576
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
577
+ const resultJson = native.process_file_change(fileChangeJson);
578
+ try {
579
+ return JSON.parse(resultJson);
580
+ } catch {
581
+ return {
582
+ file_path: "",
583
+ status: "error",
584
+ old_classes: [],
585
+ new_classes: [],
586
+ added_classes: [],
587
+ removed_classes: [],
588
+ changed: false,
589
+ fingerprint: "",
590
+ error: "Failed to parse result"
591
+ };
592
+ }
593
+ }
594
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
595
+ const native = getNativeBridge();
596
+ if (!native?.compute_incremental_diff)
597
+ throw new Error("compute_incremental_diff not available");
598
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
599
+ try {
600
+ return JSON.parse(resultJson);
601
+ } catch {
602
+ return {
603
+ is_changed: false,
604
+ changes_count: 0,
605
+ diff: {
606
+ added_files: [],
607
+ removed_files: [],
608
+ modified_files: [],
609
+ added_classes: [],
610
+ removed_classes: [],
611
+ total_changes: 0
612
+ },
613
+ processing_time_ms: 0
614
+ };
615
+ }
616
+ }
617
+ function createFingerprint(filePath, fileContent) {
618
+ const native = getNativeBridge();
619
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
620
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
621
+ try {
622
+ return JSON.parse(fingerprintJson);
623
+ } catch {
624
+ return {
625
+ file_path: filePath,
626
+ content_hash: "",
627
+ size_bytes: fileContent.length,
628
+ mtime_ms: Date.now(),
629
+ class_hash: "",
630
+ signature: ""
631
+ };
632
+ }
633
+ }
634
+ function injectStateHash(css, stateHash) {
635
+ const native = getNativeBridge();
636
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
637
+ const resultJson = native.inject_state_hash(css, stateHash);
638
+ try {
639
+ return JSON.parse(resultJson);
640
+ } catch {
641
+ return {
642
+ injected: false,
643
+ state_hash: stateHash,
644
+ affected_files: 0,
645
+ total_injected_bytes: 0
646
+ };
647
+ }
648
+ }
649
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
650
+ const native = getNativeBridge();
651
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
652
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
653
+ try {
654
+ return JSON.parse(resultJson);
655
+ } catch {
656
+ return {
657
+ entries_before: 0,
658
+ entries_after: 0,
659
+ entries_removed: 0,
660
+ freed_bytes: 0
661
+ };
662
+ }
663
+ }
664
+ function rebuildWorkspaceResult(rootDir, extensions) {
665
+ const native = getNativeBridge();
666
+ if (!native?.rebuild_workspace_result)
667
+ throw new Error("rebuild_workspace_result not available");
668
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
669
+ try {
670
+ return JSON.parse(resultJson);
671
+ } catch {
672
+ return {
673
+ total_files_scanned: 0,
674
+ total_classes_found: 0,
675
+ unique_classes: 0,
676
+ build_time_ms: 0,
677
+ files_with_changes: 0
678
+ };
679
+ }
680
+ }
681
+ function scanFileNative(filePath, fileContent) {
682
+ const native = getNativeBridge();
683
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
684
+ const resultJson = native.scan_file_native(filePath, fileContent);
685
+ try {
686
+ return JSON.parse(resultJson);
687
+ } catch {
688
+ return {
689
+ file: filePath,
690
+ classes: [],
691
+ added_classes: [],
692
+ removed_classes: [],
693
+ changed: false
694
+ };
695
+ }
696
+ }
697
+ function scanFilesBatchNative(filesJson) {
698
+ const native = getNativeBridge();
699
+ if (!native?.scan_files_batch_native)
700
+ throw new Error("scan_files_batch_native not available");
701
+ const resultJson = native.scan_files_batch_native(filesJson);
702
+ try {
703
+ return JSON.parse(resultJson);
704
+ } catch {
705
+ return [];
706
+ }
707
+ }
708
+ var init_streamingNative = __esm({
709
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
710
+ init_nativeBridge();
711
+ }
712
+ });
713
+
714
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
715
+ var tailwindEngine_exports = {};
716
+ __export(tailwindEngine_exports, {
717
+ clearCache: () => clearCache,
718
+ getCacheStats: () => getCacheStats,
719
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
720
+ runCssPipeline: () => runCssPipeline,
721
+ runCssPipelineSync: () => runCssPipelineSync
722
+ });
723
+ function _getCacheKey(classes, minify, cssEntry, root) {
724
+ const sorted = [...classes].sort().join(",");
725
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
726
+ return `${sorted}|${flags}`;
727
+ }
728
+ function _evictOldestIfNeeded() {
729
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
730
+ const firstKey = _cssCache.keys().next().value;
731
+ if (firstKey !== void 0) {
732
+ _cssCache.delete(firstKey);
733
+ }
734
+ }
735
+ }
736
+ function getCacheStats() {
737
+ const total = _cacheHits + _cacheMisses;
738
+ return {
739
+ hits: _cacheHits,
740
+ misses: _cacheMisses,
741
+ hitRate: total > 0 ? _cacheHits / total : 0,
742
+ size: _cssCache.size,
743
+ maxSize: MAX_CACHE_SIZE
744
+ };
745
+ }
746
+ function clearCache() {
747
+ _cssCache.clear();
748
+ _cacheHits = 0;
749
+ _cacheMisses = 0;
750
+ }
751
+ function getThemeConfig() {
752
+ return {
753
+ colors: {
754
+ slate: {
755
+ "50": "#f8fafc",
756
+ "100": "#f1f5f9",
757
+ "200": "#e2e8f0",
758
+ "300": "#cbd5e1",
759
+ "400": "#94a3b8",
760
+ "500": "#64748b",
761
+ "600": "#475569",
762
+ "700": "#334155",
763
+ "800": "#1e293b",
764
+ "900": "#0f172a"
765
+ },
766
+ gray: {
767
+ "50": "#f9fafb",
768
+ "100": "#f3f4f6",
769
+ "200": "#e5e7eb",
770
+ "300": "#d1d5db",
771
+ "400": "#9ca3af",
772
+ "500": "#6b7280",
773
+ "600": "#4b5563",
774
+ "700": "#374151",
775
+ "800": "#1f2937",
776
+ "900": "#111827"
777
+ },
778
+ white: "#ffffff",
779
+ black: "#000000",
780
+ red: {
781
+ "500": "#ef4444",
782
+ "600": "#dc2626"
783
+ },
784
+ blue: {
785
+ "500": "#3b82f6",
786
+ "600": "#1e40af"
787
+ }
788
+ },
789
+ spacing: {
790
+ "0": "0px",
791
+ "1": "0.25rem",
792
+ "2": "0.5rem",
793
+ "3": "0.75rem",
794
+ "4": "1rem",
795
+ "5": "1.25rem",
796
+ "6": "1.5rem",
797
+ "8": "2rem",
798
+ "10": "2.5rem",
799
+ "12": "3rem",
800
+ "16": "4rem",
801
+ "20": "5rem",
802
+ "24": "6rem"
803
+ },
804
+ breakpoints: {
805
+ "sm": "640px",
806
+ "md": "768px",
807
+ "lg": "1024px",
808
+ "xl": "1280px",
809
+ "2xl": "1536px"
810
+ }
811
+ };
812
+ }
813
+ function postProcessWithLightning(rawCss) {
814
+ if (!rawCss) return "";
815
+ const native = getNativeBridge();
816
+ if (!native?.processTailwindCssLightning) {
817
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
818
+ }
819
+ const result = native.processTailwindCssLightning(rawCss);
820
+ if (!result?.css) {
821
+ throw new Error("FATAL: processTailwindCssLightning returned null");
822
+ }
823
+ return result.css;
824
+ }
825
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
826
+ const filtered = classes.filter(Boolean);
827
+ const uniqueMap = /* @__PURE__ */ new Map();
828
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
829
+ const unique = Array.from(uniqueMap.values());
830
+ if (unique.length === 0) {
831
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
832
+ }
833
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
834
+ const cached = _cssCache.get(cacheKey);
835
+ if (cached) {
836
+ _cacheHits++;
837
+ if (process.env.DEBUG?.includes("compiler")) {
838
+ console.log(
839
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
840
+ );
841
+ }
842
+ return cached;
843
+ }
844
+ _cacheMisses++;
845
+ let rawCss;
846
+ let usedRustCompiler = false;
847
+ const theme = getThemeConfig();
848
+ rawCss = await generateCssNative(unique, { theme });
849
+ usedRustCompiler = true;
850
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
851
+ if (process.env.DEBUG?.includes("compiler")) {
852
+ console.log(
853
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
854
+ `Size: ${finalCss.length} bytes`
855
+ );
856
+ }
857
+ const result = {
858
+ css: finalCss,
859
+ classes: unique,
860
+ sizeBytes: finalCss.length,
861
+ optimized: minify
862
+ };
863
+ _evictOldestIfNeeded();
864
+ _cssCache.set(cacheKey, result);
865
+ return result;
866
+ }
867
+ function runCssPipelineSync(_classes) {
868
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
869
+ }
870
+ function processTailwindCssWithTargets(css, targets) {
871
+ const native = getNativeBridge();
872
+ if (!native?.processTailwindCssWithTargets) {
873
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
874
+ }
875
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
876
+ if (!result?.css) {
877
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
878
+ }
879
+ return result.css;
880
+ }
881
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
882
+ var init_tailwindEngine = __esm({
883
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
884
+ init_nativeBridge();
885
+ init_cssGeneratorNative();
886
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
887
+ _cssCache = /* @__PURE__ */ new Map();
888
+ _cacheHits = 0;
889
+ _cacheMisses = 0;
890
+ MAX_CACHE_SIZE = 100;
891
+ }
892
+ });
893
+
894
+ // packages/domain/compiler/src/compiler/index.ts
895
+ var init_compiler = __esm({
896
+ "packages/domain/compiler/src/compiler/index.ts"() {
897
+ init_cssGeneratorNative();
898
+ init_compilationNative();
899
+ init_cssCompilationNative();
900
+ init_idRegistryNative();
901
+ init_streamingNative();
902
+ }
903
+ });
904
+
905
+ // packages/domain/compiler/src/parser/index.ts
906
+ var parser_exports = {};
907
+ __export(parser_exports, {
908
+ astExtractClasses: () => astExtractClasses,
909
+ batchExtractClasses: () => batchExtractClasses,
910
+ checkAgainstSafelist: () => checkAgainstSafelist,
911
+ diffClassLists: () => diffClassLists,
912
+ extractAllClasses: () => extractAllClasses,
913
+ extractClassesFromSource: () => extractClassesFromSource,
914
+ extractComponentUsage: () => extractComponentUsage,
915
+ mergeClassesStatic: () => mergeClassesStatic,
916
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
917
+ normalizeClasses: () => normalizeClasses,
918
+ parseClasses: () => parseClasses
919
+ });
920
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
921
+ var init_parser = __esm({
922
+ "packages/domain/compiler/src/parser/index.ts"() {
923
+ init_nativeBridge();
924
+ parseClasses = (raw) => {
925
+ const native = getNativeBridge();
926
+ if (!native?.parseClasses) {
927
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
928
+ }
929
+ return native.parseClasses(raw) || [];
930
+ };
931
+ extractAllClasses = (source) => {
932
+ const native = getNativeBridge();
933
+ if (!native?.extractAllClasses) {
934
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
935
+ }
936
+ return native.extractAllClasses(source) || [];
937
+ };
938
+ extractClassesFromSource = (source) => {
939
+ const native = getNativeBridge();
940
+ if (!native?.extractClassesFromSource) {
941
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
942
+ }
943
+ const result = native.extractClassesFromSource(source);
944
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
945
+ };
946
+ astExtractClasses = (source, _filename) => {
947
+ const native = getNativeBridge();
948
+ if (!native?.extractClassesFromSource) {
949
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
950
+ }
951
+ return native.extractClassesFromSource(source) || [];
952
+ };
953
+ normalizeClasses = (raw) => {
954
+ const result = normalizeAndDedupClasses(raw);
955
+ return result?.normalized || "";
956
+ };
957
+ mergeClassesStatic = (classes) => {
958
+ const result = normalizeAndDedupClasses(classes);
959
+ return result?.normalized || "";
960
+ };
961
+ normalizeAndDedupClasses = (raw) => {
962
+ const native = getNativeBridge();
963
+ if (!native?.normalizeAndDedupClasses) {
964
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
965
+ }
966
+ const result = native.normalizeAndDedupClasses(raw);
967
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
968
+ };
969
+ extractComponentUsage = (source) => {
970
+ const native = getNativeBridge();
971
+ if (!native?.extractComponentUsage) {
972
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
973
+ }
974
+ return native.extractComponentUsage(source) || [];
975
+ };
976
+ batchExtractClasses = (filePaths) => {
977
+ const native = getNativeBridge();
978
+ if (!native?.batchExtractClasses) {
979
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
980
+ }
981
+ return native.batchExtractClasses(filePaths) || [];
982
+ };
983
+ checkAgainstSafelist = (classes, safelist) => {
984
+ const native = getNativeBridge();
985
+ if (!native?.checkAgainstSafelist) {
986
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
987
+ }
988
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
989
+ };
990
+ diffClassLists = (previous, current) => {
991
+ const native = getNativeBridge();
992
+ if (!native?.diffClassLists) {
993
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
994
+ }
995
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
996
+ };
997
+ }
998
+ });
999
+
1000
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1001
+ function detectDeadCode(scanResultJson, css) {
1002
+ const native = getNativeBridge();
1003
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1004
+ return native.detectDeadCode(scanResultJson, css);
1005
+ }
1006
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1007
+ const native = getNativeBridge();
1008
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1009
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1010
+ }
1011
+ function analyzeClassesNative(filesJson, cwd, flags) {
1012
+ const native = getNativeBridge();
1013
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1014
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1015
+ }
1016
+ function analyzeRscNative(source, filename) {
1017
+ const native = getNativeBridge();
1018
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1019
+ return native.analyzeRsc(source, filename);
1020
+ }
1021
+ function optimizeCssNative(css) {
1022
+ const native = getNativeBridge();
1023
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1024
+ const result = native.processTailwindCssLightning(css);
1025
+ return {
1026
+ css: result.css,
1027
+ originalSize: css.length,
1028
+ optimizedSize: result.size_bytes,
1029
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1030
+ };
1031
+ }
1032
+ function processTailwindCssLightning(css) {
1033
+ const native = getNativeBridge();
1034
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1035
+ return native.processTailwindCssLightning(css);
1036
+ }
1037
+ function eliminateDeadCssNative(css, deadClasses) {
1038
+ const native = getNativeBridge();
1039
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1040
+ return native.eliminateDeadCss(css, deadClasses);
1041
+ }
1042
+ function hoistComponentsNative(source) {
1043
+ const native = getNativeBridge();
1044
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1045
+ return native.hoistComponents(source);
1046
+ }
1047
+ function compileVariantTableNative(configJson) {
1048
+ const native = getNativeBridge();
1049
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1050
+ return native.compileVariantTable(configJson);
1051
+ }
1052
+ function classifyAndSortClassesNative(classes) {
1053
+ const native = getNativeBridge();
1054
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1055
+ return native.classifyAndSortClasses(classes);
1056
+ }
1057
+ function mergeCssDeclarationsNative(cssChunks) {
1058
+ const native = getNativeBridge();
1059
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1060
+ return native.mergeCssDeclarations(cssChunks);
1061
+ }
1062
+ var init_analyzerNative = __esm({
1063
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1064
+ init_nativeBridge();
1065
+ }
1066
+ });
1067
+
1068
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1069
+ function resolveVariants(configJson) {
1070
+ const native = getNativeBridge();
1071
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1072
+ const resultJson = native.resolve_variants(configJson);
1073
+ try {
1074
+ return JSON.parse(resultJson);
1075
+ } catch {
1076
+ return {
1077
+ variants: [],
1078
+ supported: [],
1079
+ deprecated: [],
1080
+ conflicting: []
1081
+ };
1082
+ }
1083
+ }
1084
+ function validateThemeConfig(configJson) {
1085
+ const native = getNativeBridge();
1086
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1087
+ const resultJson = native.validate_variant_config(configJson);
1088
+ try {
1089
+ return JSON.parse(resultJson);
1090
+ } catch {
1091
+ return {
1092
+ is_valid: false,
1093
+ errors: ["Unable to parse configuration"],
1094
+ warnings: [],
1095
+ suggestions: []
1096
+ };
1097
+ }
1098
+ }
1099
+ function resolveCascade(baseThemeJson, overridesJson) {
1100
+ const native = getNativeBridge();
1101
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1102
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1103
+ try {
1104
+ return JSON.parse(resultJson);
1105
+ } catch {
1106
+ return {
1107
+ base_theme: {},
1108
+ user_overrides: {},
1109
+ merged_theme: {},
1110
+ conflict_resolutions: []
1111
+ };
1112
+ }
1113
+ }
1114
+ function resolveClassNames(classNames, themeJson) {
1115
+ const native = getNativeBridge();
1116
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1117
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1118
+ try {
1119
+ return JSON.parse(resultJson);
1120
+ } catch {
1121
+ return [];
1122
+ }
1123
+ }
1124
+ function resolveConflictGroup(groupName, themeJson) {
1125
+ const native = getNativeBridge();
1126
+ if (!native?.resolve_conflict_group)
1127
+ throw new Error("resolve_conflict_group not available");
1128
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1129
+ try {
1130
+ return JSON.parse(resultJson);
1131
+ } catch {
1132
+ return {
1133
+ group_name: groupName,
1134
+ conflicting_classes: [],
1135
+ description: "",
1136
+ resolution_strategy: "last-wins"
1137
+ };
1138
+ }
1139
+ }
1140
+ function resolveThemeValue(keyPath, themeJson) {
1141
+ const native = getNativeBridge();
1142
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1143
+ return native.resolve_theme_value(keyPath, themeJson);
1144
+ }
1145
+ function resolveSimpleVariants(configJson) {
1146
+ const native = getNativeBridge();
1147
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1148
+ const resultJson = native.resolve_simple_variants(configJson);
1149
+ try {
1150
+ return JSON.parse(resultJson);
1151
+ } catch {
1152
+ return [];
1153
+ }
1154
+ }
1155
+ var init_themeResolutionNative = __esm({
1156
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1157
+ init_nativeBridge();
1158
+ }
1159
+ });
1160
+
1161
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1162
+ function scanWorkspace(root, extensions) {
1163
+ const native = getNativeBridge();
1164
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1165
+ return native.scan_workspace(root, extensions);
1166
+ }
1167
+ function extractClassesFromSourceNative(source) {
1168
+ const native = getNativeBridge();
1169
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1170
+ return native.extract_classes_from_source(source);
1171
+ }
1172
+ function batchExtractClassesNative(filePaths) {
1173
+ const native = getNativeBridge();
1174
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1175
+ return native.batch_extract_classes(filePaths);
1176
+ }
1177
+ function checkAgainstSafelistNative(classes, safelist) {
1178
+ const native = getNativeBridge();
1179
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1180
+ return native.check_against_safelist(classes, safelist);
1181
+ }
1182
+ function scanFile(filePath) {
1183
+ const native = getNativeBridge();
1184
+ if (!native?.scan_file) throw new Error("scan_file not available");
1185
+ return native.scan_file(filePath);
1186
+ }
1187
+ function collectFiles(root, extensions) {
1188
+ const native = getNativeBridge();
1189
+ if (!native?.collect_files) throw new Error("collect_files not available");
1190
+ return native.collect_files(root, extensions);
1191
+ }
1192
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1193
+ const native = getNativeBridge();
1194
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1195
+ return native.walk_and_prefilter_source_files(root, extensions);
1196
+ }
1197
+ function generateSubComponentTypes(root, outputPath) {
1198
+ const native = getNativeBridge();
1199
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1200
+ return native.generate_sub_component_types(root, outputPath);
1201
+ }
1202
+ var init_scannerNative = __esm({
1203
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1204
+ init_nativeBridge();
1205
+ }
1206
+ });
1207
+
1208
+ // packages/domain/compiler/src/analyzer/index.ts
1209
+ var init_analyzer = __esm({
1210
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1211
+ init_analyzerNative();
1212
+ init_themeResolutionNative();
1213
+ init_scannerNative();
1214
+ }
1215
+ });
1216
+
1217
+ // packages/domain/compiler/src/cache/cacheNative.ts
1218
+ function getCacheStatistics() {
1219
+ const native = getNativeBridge();
1220
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1221
+ const statsJson = native.get_cache_statistics();
1222
+ try {
1223
+ return JSON.parse(statsJson);
1224
+ } catch {
1225
+ return {
1226
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1227
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
1228
+ compile_cache: { hits: 0, misses: 0, size: 0 },
1229
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
1230
+ overall_hit_rate: 0,
1231
+ total_memory_bytes: 0
1232
+ };
1233
+ }
1234
+ }
1235
+ function clearAllCaches() {
1236
+ const native = getNativeBridge();
1237
+ if (!native?.clear_all_caches) return;
1238
+ try {
1239
+ native.clear_all_caches();
1240
+ } catch {
1241
+ }
1242
+ }
1243
+ function clearParseCache() {
1244
+ const native = getNativeBridge();
1245
+ if (!native?.clear_parse_cache) return;
1246
+ try {
1247
+ native.clear_parse_cache();
1248
+ } catch {
1249
+ }
1250
+ }
1251
+ function clearResolveCache() {
1252
+ const native = getNativeBridge();
1253
+ if (!native?.clear_resolve_cache) return;
1254
+ try {
1255
+ native.clear_resolve_cache();
1256
+ } catch {
1257
+ }
1258
+ }
1259
+ function clearCompileCache() {
1260
+ const native = getNativeBridge();
1261
+ if (!native?.clear_compile_cache) return;
1262
+ try {
1263
+ native.clear_compile_cache();
1264
+ } catch {
1265
+ }
1266
+ }
1267
+ function clearCssGenCache() {
1268
+ const native = getNativeBridge();
1269
+ if (!native?.clear_css_gen_cache) return;
1270
+ try {
1271
+ native.clear_css_gen_cache();
1272
+ } catch {
1273
+ }
1274
+ }
1275
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
1276
+ const native = getNativeBridge();
1277
+ if (!native?.get_cache_optimization_hints)
1278
+ throw new Error("get_cache_optimization_hints not available");
1279
+ const hintsJson = native.get_cache_optimization_hints(
1280
+ Math.min(100, Math.max(0, hitRatePercent)),
1281
+ Math.max(1, memoryUsedMb)
1282
+ );
1283
+ try {
1284
+ return JSON.parse(hintsJson);
1285
+ } catch {
1286
+ return {
1287
+ current_strategy: "unknown",
1288
+ recommended_strategy: "increase_size",
1289
+ estimated_improvement_percent: 0,
1290
+ suggested_memory_mb: 256,
1291
+ notes: ["Unable to analyze cache statistics"]
1292
+ };
1293
+ }
1294
+ }
1295
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
1296
+ const native = getNativeBridge();
1297
+ if (!native?.estimate_optimal_cache_config_native)
1298
+ throw new Error("estimate_optimal_cache_config_native not available");
1299
+ const configJson = native.estimate_optimal_cache_config_native(
1300
+ Math.max(64, totalBudgetMb),
1301
+ workloadType
1302
+ );
1303
+ try {
1304
+ return JSON.parse(configJson);
1305
+ } catch {
1306
+ return {
1307
+ parse_cache_size: 128,
1308
+ resolve_cache_size: 64,
1309
+ compile_cache_size: 256,
1310
+ css_gen_cache_size: 128,
1311
+ recommended_eviction_policy: "lru",
1312
+ ttl_seconds: 3600,
1313
+ expected_hit_rate_percent: 75
1314
+ };
1315
+ }
1316
+ }
1317
+ function cacheRead(cachePath) {
1318
+ const native = getNativeBridge();
1319
+ if (!native?.cache_read) throw new Error("cache_read not available");
1320
+ const result = native.cache_read(cachePath);
1321
+ try {
1322
+ return JSON.parse(result.entries_json || "[]");
1323
+ } catch {
1324
+ return [];
1325
+ }
1326
+ }
1327
+ function cacheWrite(cachePath, entries) {
1328
+ const native = getNativeBridge();
1329
+ if (!native?.cache_write) throw new Error("cache_write not available");
1330
+ try {
1331
+ const result = native.cache_write(
1332
+ cachePath,
1333
+ entries.map((e) => ({
1334
+ file: e.file,
1335
+ content_hash: e.contentHash,
1336
+ classes: e.classes,
1337
+ mtime_ms: e.mtimeMs,
1338
+ size_bytes: e.sizeBytes
1339
+ }))
1340
+ );
1341
+ return typeof result === "boolean" ? result : result === true;
1342
+ } catch {
1343
+ return false;
1344
+ }
1345
+ }
1346
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
1347
+ const native = getNativeBridge();
1348
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
1349
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
1350
+ }
1351
+ var init_cacheNative = __esm({
1352
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
1353
+ init_nativeBridge();
1354
+ }
1355
+ });
1356
+
1357
+ // packages/domain/compiler/src/cache/index.ts
1358
+ var init_cache = __esm({
1359
+ "packages/domain/compiler/src/cache/index.ts"() {
1360
+ init_cacheNative();
1361
+ }
1362
+ });
1363
+
1364
+ // packages/domain/compiler/src/redis/redisNative.ts
1365
+ function redisPing() {
1366
+ const native = getNativeBridge();
1367
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
1368
+ return native.redis_ping();
1369
+ }
1370
+ function redisGet(key) {
1371
+ const native = getNativeBridge();
1372
+ if (!native?.redis_get) throw new Error("redis_get not available");
1373
+ const result = native.redis_get(key);
1374
+ return result === "nil" ? null : result;
1375
+ }
1376
+ function redisSet(key, value, ttl_seconds) {
1377
+ const native = getNativeBridge();
1378
+ if (!native?.redis_set) throw new Error("redis_set not available");
1379
+ return native.redis_set(key, value, ttl_seconds);
1380
+ }
1381
+ function redisDelete(key) {
1382
+ const native = getNativeBridge();
1383
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
1384
+ return native.redis_delete(key);
1385
+ }
1386
+ function redisExists(key) {
1387
+ const native = getNativeBridge();
1388
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
1389
+ return native.redis_exists(key);
1390
+ }
1391
+ function redisMget(keys) {
1392
+ const native = getNativeBridge();
1393
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
1394
+ const result = native.redis_mget(keys);
1395
+ try {
1396
+ return JSON.parse(result);
1397
+ } catch {
1398
+ return keys.map(() => null);
1399
+ }
1400
+ }
1401
+ function redisMset(pairs) {
1402
+ const native = getNativeBridge();
1403
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
1404
+ return native.redis_mset(pairs);
1405
+ }
1406
+ function redisFlushDb() {
1407
+ const native = getNativeBridge();
1408
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
1409
+ return native.redis_flush_db();
1410
+ }
1411
+ function redisFlushAll() {
1412
+ const native = getNativeBridge();
1413
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
1414
+ return native.redis_flush_all();
1415
+ }
1416
+ function redisPoolConnect(host, port, pool_size) {
1417
+ const native = getNativeBridge();
1418
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
1419
+ return native.redis_pool_connect(host, port, pool_size);
1420
+ }
1421
+ function redisPoolStats() {
1422
+ const native = getNativeBridge();
1423
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
1424
+ const result = native.redis_pool_stats();
1425
+ try {
1426
+ return JSON.parse(result);
1427
+ } catch {
1428
+ return {
1429
+ connected_count: 0,
1430
+ idle_count: 0,
1431
+ waiting_count: 0,
1432
+ total_requests: 0,
1433
+ total_errors: 0
1434
+ };
1435
+ }
1436
+ }
1437
+ function redisPoolReconnect() {
1438
+ const native = getNativeBridge();
1439
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
1440
+ return native.redis_pool_reconnect();
1441
+ }
1442
+ function redisEnableCluster(initial_nodes) {
1443
+ const native = getNativeBridge();
1444
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
1445
+ const result = native.redis_enable_cluster(initial_nodes);
1446
+ try {
1447
+ return JSON.parse(result);
1448
+ } catch {
1449
+ return {
1450
+ enabled: false,
1451
+ cluster_state: "error",
1452
+ nodes: [],
1453
+ slots_assigned: 0,
1454
+ slots_ok: 0,
1455
+ slots_fail: 0
1456
+ };
1457
+ }
1458
+ }
1459
+ function redisDisableCluster() {
1460
+ const native = getNativeBridge();
1461
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
1462
+ return native.redis_disable_cluster();
1463
+ }
1464
+ function redisClusterStatus() {
1465
+ const native = getNativeBridge();
1466
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
1467
+ const result = native.redis_cluster_status();
1468
+ try {
1469
+ return JSON.parse(result);
1470
+ } catch {
1471
+ return {
1472
+ enabled: false,
1473
+ cluster_state: "unknown",
1474
+ nodes: [],
1475
+ slots_assigned: 0,
1476
+ slots_ok: 0,
1477
+ slots_fail: 0
1478
+ };
1479
+ }
1480
+ }
1481
+ function redisSubscribe(channel) {
1482
+ const native = getNativeBridge();
1483
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
1484
+ return native.redis_subscribe(channel);
1485
+ }
1486
+ function redisPublish(channel, message) {
1487
+ const native = getNativeBridge();
1488
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
1489
+ return native.redis_publish(channel, message);
1490
+ }
1491
+ function redisExpirationSet(key, ttl_seconds) {
1492
+ const native = getNativeBridge();
1493
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
1494
+ return native.redis_expiration_set(key, ttl_seconds);
1495
+ }
1496
+ function redisExpirationGet(key) {
1497
+ const native = getNativeBridge();
1498
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
1499
+ const result = native.redis_expiration_get(key);
1500
+ try {
1501
+ return JSON.parse(result);
1502
+ } catch {
1503
+ return {
1504
+ key,
1505
+ ttl_seconds: -1,
1506
+ expiration_timestamp: 0,
1507
+ is_persistent: true
1508
+ };
1509
+ }
1510
+ }
1511
+ function redisInfo() {
1512
+ const native = getNativeBridge();
1513
+ if (!native?.redis_info) throw new Error("redis_info not available");
1514
+ return native.redis_info();
1515
+ }
1516
+ function redisMonitor() {
1517
+ const native = getNativeBridge();
1518
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
1519
+ return native.redis_monitor();
1520
+ }
1521
+ function redisCacheSize() {
1522
+ const native = getNativeBridge();
1523
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
1524
+ return native.redis_cache_size();
1525
+ }
1526
+ function redisCacheKeyCount() {
1527
+ const native = getNativeBridge();
1528
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
1529
+ return native.redis_cache_key_count();
1530
+ }
1531
+ function redisCacheClear() {
1532
+ const native = getNativeBridge();
1533
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
1534
+ return native.redis_cache_clear();
1535
+ }
1536
+ function redisCacheHitRate() {
1537
+ const native = getNativeBridge();
1538
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
1539
+ return native.redis_cache_hit_rate();
1540
+ }
1541
+ function redisEnablePersistence(mode) {
1542
+ const native = getNativeBridge();
1543
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
1544
+ return native.redis_enable_persistence(mode);
1545
+ }
1546
+ function redisDisablePersistence() {
1547
+ const native = getNativeBridge();
1548
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
1549
+ return native.redis_disable_persistence();
1550
+ }
1551
+ function redisSnapshot() {
1552
+ const native = getNativeBridge();
1553
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
1554
+ return native.redis_snapshot();
1555
+ }
1556
+ function redisMemoryStats() {
1557
+ const native = getNativeBridge();
1558
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
1559
+ return native.redis_memory_stats();
1560
+ }
1561
+ function redisOptimizeMemory() {
1562
+ const native = getNativeBridge();
1563
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
1564
+ return native.redis_optimize_memory();
1565
+ }
1566
+ function redisSetEvictionPolicy(policy) {
1567
+ const native = getNativeBridge();
1568
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
1569
+ return native.redis_set_eviction_policy(policy);
1570
+ }
1571
+ function redisGetEvictionPolicy() {
1572
+ const native = getNativeBridge();
1573
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
1574
+ return native.redis_get_eviction_policy();
1575
+ }
1576
+ function redisReplicate(target_host, target_port) {
1577
+ const native = getNativeBridge();
1578
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
1579
+ return native.redis_replicate(target_host, target_port);
1580
+ }
1581
+ function redisReplicationStatus() {
1582
+ const native = getNativeBridge();
1583
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
1584
+ return native.redis_replication_status();
1585
+ }
1586
+ function redisCacheSync(peers) {
1587
+ const native = getNativeBridge();
1588
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
1589
+ return native.redis_cache_sync(peers);
1590
+ }
1591
+ function redisEnableCacheWarming(key_pattern) {
1592
+ const native = getNativeBridge();
1593
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
1594
+ return native.redis_enable_cache_warming(key_pattern);
1595
+ }
1596
+ function redisDisableCacheWarming() {
1597
+ const native = getNativeBridge();
1598
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
1599
+ return native.redis_disable_cache_warming();
1600
+ }
1601
+ function redisDiagnose() {
1602
+ const native = getNativeBridge();
1603
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
1604
+ return native.redis_diagnose();
1605
+ }
1606
+ var init_redisNative = __esm({
1607
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
1608
+ init_nativeBridge();
1609
+ }
1610
+ });
1611
+
1612
+ // packages/domain/compiler/src/redis/index.ts
1613
+ var init_redis = __esm({
1614
+ "packages/domain/compiler/src/redis/index.ts"() {
1615
+ init_redisNative();
1616
+ }
1617
+ });
1618
+
1619
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
1620
+ function startWatch(root_path, patterns) {
1621
+ const native = getNativeBridge();
1622
+ if (!native?.start_watch) throw new Error("start_watch not available");
1623
+ return native.start_watch(root_path, patterns);
1624
+ }
1625
+ function pollWatchEvents(handle, timeout_ms) {
1626
+ const native = getNativeBridge();
1627
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
1628
+ const result = native.poll_watch_events(handle, timeout_ms);
1629
+ try {
1630
+ return JSON.parse(result);
1631
+ } catch {
1632
+ return [];
1633
+ }
1634
+ }
1635
+ function stopWatch(handle) {
1636
+ const native = getNativeBridge();
1637
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
1638
+ return native.stop_watch(handle);
1639
+ }
1640
+ function watchAddPattern(handle, pattern) {
1641
+ const native = getNativeBridge();
1642
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
1643
+ return native.watch_add_pattern(handle, pattern);
1644
+ }
1645
+ function watchRemovePattern(handle, pattern) {
1646
+ const native = getNativeBridge();
1647
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
1648
+ return native.watch_remove_pattern(handle, pattern);
1649
+ }
1650
+ function watchGetActiveHandles() {
1651
+ const native = getNativeBridge();
1652
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
1653
+ const result = native.watch_get_active_handles();
1654
+ try {
1655
+ return JSON.parse(result);
1656
+ } catch {
1657
+ return [];
1658
+ }
1659
+ }
1660
+ function watchClearAll() {
1661
+ const native = getNativeBridge();
1662
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
1663
+ return native.watch_clear_all();
1664
+ }
1665
+ function watchEventTypeToString(event_type_code) {
1666
+ const native = getNativeBridge();
1667
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
1668
+ return native.watch_event_type_to_string(event_type_code);
1669
+ }
1670
+ function isWatchRunning(handle) {
1671
+ const native = getNativeBridge();
1672
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
1673
+ return native.is_watch_running(handle);
1674
+ }
1675
+ function getWatchStats() {
1676
+ const native = getNativeBridge();
1677
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
1678
+ const result = native.get_watch_stats();
1679
+ try {
1680
+ return JSON.parse(result);
1681
+ } catch {
1682
+ return {
1683
+ active_watchers: 0,
1684
+ total_events: 0,
1685
+ events_this_second: 0,
1686
+ average_latency_ms: 0,
1687
+ largest_batch_size: 0
1688
+ };
1689
+ }
1690
+ }
1691
+ function watchPause(handle) {
1692
+ const native = getNativeBridge();
1693
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
1694
+ return native.watch_pause(handle);
1695
+ }
1696
+ function watchResume(handle) {
1697
+ const native = getNativeBridge();
1698
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
1699
+ return native.watch_resume(handle);
1700
+ }
1701
+ function scanCacheOptimizations() {
1702
+ const native = getNativeBridge();
1703
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
1704
+ return native.scan_cache_optimizations();
1705
+ }
1706
+ function getPluginHooks() {
1707
+ const native = getNativeBridge();
1708
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
1709
+ const result = native.get_plugin_hooks();
1710
+ try {
1711
+ return JSON.parse(result);
1712
+ } catch {
1713
+ return [];
1714
+ }
1715
+ }
1716
+ function registerPluginHook(hook_name, handler_id) {
1717
+ const native = getNativeBridge();
1718
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
1719
+ return native.register_plugin_hook(hook_name, handler_id);
1720
+ }
1721
+ function unregisterPluginHook(hook_name, handler_id) {
1722
+ const native = getNativeBridge();
1723
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
1724
+ return native.unregister_plugin_hook(hook_name, handler_id);
1725
+ }
1726
+ function emitPluginHook(hook_name, data_json) {
1727
+ const native = getNativeBridge();
1728
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
1729
+ return native.emit_plugin_hook(hook_name, data_json);
1730
+ }
1731
+ function getCompilationMetrics() {
1732
+ const native = getNativeBridge();
1733
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
1734
+ return native.get_compilation_metrics();
1735
+ }
1736
+ function resetCompilationMetrics() {
1737
+ const native = getNativeBridge();
1738
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
1739
+ return native.reset_compilation_metrics();
1740
+ }
1741
+ function validateCssOutput(css) {
1742
+ const native = getNativeBridge();
1743
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
1744
+ return native.validate_css_output(css);
1745
+ }
1746
+ function getCompilerDiagnostics() {
1747
+ const native = getNativeBridge();
1748
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
1749
+ return native.get_compiler_diagnostics();
1750
+ }
1751
+ var init_watchSystemNative = __esm({
1752
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1753
+ init_nativeBridge();
1754
+ }
1755
+ });
1756
+
1757
+ // packages/domain/compiler/src/watch/index.ts
1758
+ var init_watch = __esm({
1759
+ "packages/domain/compiler/src/watch/index.ts"() {
1760
+ init_watchSystemNative();
1761
+ }
1762
+ });
1763
+ function _layoutClassesToCss(classes) {
1764
+ const native = getNativeBridge();
1765
+ if (!native?.layoutClassesToCss) {
1766
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
1767
+ }
1768
+ return native.layoutClassesToCss(classes);
1769
+ }
1770
+ function _hashContainer(tag, containerJson, name) {
1771
+ const sortedKey = tag + (name ?? "") + containerJson;
1772
+ const native = getNativeBridge();
1773
+ if (!native?.hashContent) {
1774
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
1775
+ }
1776
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
1777
+ }
1778
+ function extractContainerCssFromSource(source) {
1779
+ const native = getNativeBridge();
1780
+ if (!native?.extractTwContainerConfigs) {
1781
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
1782
+ }
1783
+ const configs = native.extractTwContainerConfigs(source);
1784
+ const rules = [];
1785
+ for (const cfg of configs) {
1786
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
1787
+ for (const { key, classes } of cfg.breakpoints) {
1788
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
1789
+ const css = _layoutClassesToCss(classes);
1790
+ if (!css) continue;
1791
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
1792
+ rules.push(`${query}{.${id}{${css}}}`);
1793
+ }
1794
+ }
1795
+ return rules.join("\n");
1796
+ }
1797
+ var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
1798
+ var init_src2 = __esm({
1799
+ "packages/domain/compiler/src/index.ts"() {
1800
+ init_nativeBridge();
1801
+ init_compiler();
1802
+ init_parser();
1803
+ init_analyzer();
1804
+ init_cache();
1805
+ init_redis();
1806
+ init_watch();
1807
+ transformSource = (source, opts) => {
1808
+ const native = getNativeBridge();
1809
+ if (!native?.transformSource) {
1810
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1811
+ }
1812
+ const result = native.transformSource(source, opts);
1813
+ if (!result) {
1814
+ throw new Error("FATAL: transformSource returned null");
1815
+ }
1816
+ return result;
1817
+ };
1818
+ hasTwUsage = (source) => {
1819
+ const native = getNativeBridge();
1820
+ if (!native?.hasTwUsage) {
1821
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
1822
+ }
1823
+ return native.hasTwUsage(source);
1824
+ };
1825
+ isAlreadyTransformed = (source) => {
1826
+ const native = getNativeBridge();
1827
+ if (!native?.isAlreadyTransformed) {
1828
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
1829
+ }
1830
+ return native.isAlreadyTransformed(source);
1831
+ };
1832
+ shouldProcess = (source) => {
1833
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
1834
+ };
1835
+ compileCssFromClasses = (classes, prefix) => {
1836
+ const native = getNativeBridge();
1837
+ if (!native?.transformSource) {
1838
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1839
+ }
1840
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
1841
+ if (!result) {
1842
+ throw new Error("FATAL: transformSource returned null");
1843
+ }
1844
+ return result;
1845
+ };
1846
+ buildStyleTag = (classes) => {
1847
+ const result = compileCssFromClasses(classes);
1848
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
1849
+ };
1850
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1851
+ try {
1852
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
1853
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1854
+ return result.css;
1855
+ } catch {
1856
+ const native = getNativeBridge();
1857
+ if (!native?.transformSource) {
1858
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1859
+ }
1860
+ const result = native.transformSource(classes.join(" "), {});
1861
+ return result?.code || "";
1862
+ }
1863
+ };
1864
+ eliminateDeadCss = (css, deadClasses) => {
1865
+ const native = getNativeBridge();
1866
+ if (!native?.eliminateDeadCss) {
1867
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
1868
+ }
1869
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
1870
+ };
1871
+ findDeadVariants = (variantConfig, usage) => {
1872
+ const unused = [];
1873
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
1874
+ for (const component of configs) {
1875
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
1876
+ const variants = component.variants;
1877
+ for (const [key, values] of Object.entries(variants)) {
1878
+ for (const [value] of Object.entries(values)) {
1879
+ if (!componentUsage.has(`${key}:${value}`)) {
1880
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
1881
+ }
1882
+ }
1883
+ }
1884
+ }
1885
+ return { unusedCount: unused.length, unused };
1886
+ };
1887
+ runElimination = (css, scanResult) => {
1888
+ const native = getNativeBridge();
1889
+ if (!native?.detectDeadCode) {
1890
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
1891
+ }
1892
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
1893
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
1894
+ };
1895
+ scanProjectUsage = (dirs, cwd) => {
1896
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
1897
+ const files = dirs.map((dir) => path4__namespace.default.resolve(cwd, dir));
1898
+ const results = batchExtractClasses2(files) || [];
1899
+ const combined = {};
1900
+ for (const result of results) {
1901
+ if (result.ok && result.classes) {
1902
+ for (const cls of result.classes) {
1903
+ if (!combined[cls]) combined[cls] = {};
1904
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
1905
+ }
1906
+ }
1907
+ }
1908
+ return combined;
1909
+ };
1910
+ generateSafelist = (scanDirs, outputPath, cwd) => {
1911
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
1912
+ const allClasses = Object.keys(classes).sort();
1913
+ if (outputPath) {
1914
+ fs4__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
1915
+ }
1916
+ return allClasses;
1917
+ };
1918
+ loadSafelist = (safelistPath) => {
1919
+ try {
1920
+ const content = fs4__namespace.default.readFileSync(safelistPath, "utf-8");
1921
+ return JSON.parse(content);
1922
+ } catch {
1923
+ return [];
1924
+ }
1925
+ };
1926
+ loadTailwindConfig = (cwd = process.cwd()) => {
1927
+ const configFiles = [
1928
+ "tailwind.config.ts",
1929
+ "tailwind.config.js",
1930
+ "tailwind.config.mjs",
1931
+ "tailwind.config.cjs"
1932
+ ];
1933
+ for (const file of configFiles) {
1934
+ const fullPath = path4__namespace.default.join(cwd, file);
1935
+ if (fs4__namespace.default.existsSync(fullPath)) {
1936
+ const mod = __require(fullPath);
1937
+ return mod.default || mod;
1938
+ }
1939
+ }
1940
+ return {};
1941
+ };
1942
+ getContentPaths = (cwd = process.cwd()) => {
1943
+ return {
1944
+ content: [
1945
+ path4__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
1946
+ path4__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
1947
+ path4__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
1948
+ ]
1949
+ };
1950
+ };
1951
+ _CONTAINER_BREAKPOINTS = {
1952
+ xs: "240px",
1953
+ sm: "320px",
1954
+ md: "640px",
1955
+ lg: "1024px",
1956
+ xl: "1280px",
1957
+ "2xl": "1536px"
1958
+ };
1959
+ runLoaderTransform = (ctx) => {
1960
+ const { filepath, source, options } = ctx;
1961
+ const result = transformSource(source, { filename: filepath, ...options });
1962
+ let staticCss;
1963
+ try {
1964
+ const cssChunks = [];
1965
+ const stateRules = extractAndGenerateStateCss(source, filepath);
1966
+ if (stateRules.length > 0) {
1967
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
1968
+ }
1969
+ const containerCss = extractContainerCssFromSource(source);
1970
+ if (containerCss) cssChunks.push(containerCss);
1971
+ const combined = cssChunks.join("\n").trim();
1972
+ if (combined) staticCss = combined;
1973
+ } catch (err) {
1974
+ console.debug("Static CSS extraction warning:", err);
1975
+ }
1976
+ return {
1977
+ code: result?.code || "",
1978
+ changed: result?.changed || false,
1979
+ classes: result?.classes || [],
1980
+ staticCss
1981
+ };
1982
+ };
1983
+ shouldSkipFile = (filepath) => {
1984
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
1985
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
1986
+ for (const p of SKIP_PATHS) {
1987
+ if (filepath.includes(p)) return true;
1988
+ }
1989
+ for (const ext of skipExtensions) {
1990
+ if (filepath.endsWith(ext)) return true;
1991
+ }
1992
+ return false;
1993
+ };
1994
+ fileToRoute = (filepath) => {
1995
+ const normalized = filepath.replace(/\\/g, "/");
1996
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
1997
+ return "__global";
1998
+ }
1999
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
2000
+ if (pageMatch) return `/${pageMatch[1]}`;
2001
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
2002
+ if (rootPage) return "/";
2003
+ return null;
2004
+ };
2005
+ getAllRoutes = () => {
2006
+ const native = getNativeBridge();
2007
+ if (!native?.analyzeClasses) {
2008
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2009
+ }
2010
+ return ["/", "__global"];
2011
+ };
2012
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
2013
+ registerFileClasses = (_filepath, _classes) => {
2014
+ };
2015
+ registerGlobalClasses = (_classes) => {
2016
+ };
2017
+ _incrementalEngineInstance = null;
2018
+ getIncrementalEngine = () => {
2019
+ if (!_incrementalEngineInstance) {
2020
+ _incrementalEngineInstance = new IncrementalEngine();
2021
+ }
2022
+ return _incrementalEngineInstance;
2023
+ };
2024
+ resetIncrementalEngine = () => {
2025
+ _incrementalEngineInstance = null;
2026
+ };
2027
+ IncrementalEngine = class {
2028
+ compile(source) {
2029
+ return transformSource(source);
2030
+ }
2031
+ };
2032
+ getBucketEngine = () => {
2033
+ const native = getNativeBridge();
2034
+ if (!native?.classifyAndSortClasses) {
2035
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2036
+ }
2037
+ return {
2038
+ add: (className) => className,
2039
+ get: (_bucket) => []
2040
+ };
2041
+ };
2042
+ resetBucketEngine = () => {
2043
+ };
2044
+ classifyNode = (_node) => {
2045
+ const native = getNativeBridge();
2046
+ if (!native?.classifyAndSortClasses) {
2047
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2048
+ }
2049
+ return "unknown";
2050
+ };
2051
+ detectConflicts = (_classes) => {
2052
+ const native = getNativeBridge();
2053
+ if (!native?.analyzeClassUsage) {
2054
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2055
+ }
2056
+ return [];
2057
+ };
2058
+ bucketSort = (classes) => {
2059
+ const native = getNativeBridge();
2060
+ if (!native?.classifyAndSortClasses) {
2061
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2062
+ }
2063
+ const sorted = native.classifyAndSortClasses(classes);
2064
+ return sorted.map((c) => c.raw ?? c);
2065
+ };
2066
+ analyzeFile = (source, filename) => {
2067
+ const native = getNativeBridge();
2068
+ if (!native?.analyzeRsc) {
2069
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2070
+ }
2071
+ const rsc = native.analyzeRsc(source, filename);
2072
+ return {
2073
+ isServer: rsc?.isServer ?? true,
2074
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2075
+ clientReasons: rsc?.clientReasons ?? [],
2076
+ interactiveClasses: [],
2077
+ canStaticResolveVariants: true
2078
+ };
2079
+ };
2080
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2081
+ return { resolved: {}, dynamic: [] };
2082
+ };
2083
+ injectClientDirective = (source) => {
2084
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2085
+ return '"use client";\n' + source;
2086
+ }
2087
+ return source;
2088
+ };
2089
+ injectServerOnlyComment = (source) => {
2090
+ return `/* @server-only */
2091
+ ${source}`;
2092
+ };
2093
+ analyzeClasses = (filesJson, cwd, flags) => {
2094
+ const native = getNativeBridge();
2095
+ if (!native?.analyzeClasses) {
2096
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2097
+ }
2098
+ return native.analyzeClasses(filesJson, cwd, flags);
2099
+ };
2100
+ extractTwStateConfigs = (source, filename) => {
2101
+ const native = getNativeBridge();
2102
+ if (!native?.extractTwStateConfigs) {
2103
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
2104
+ }
2105
+ return native.extractTwStateConfigs(source, filename);
2106
+ };
2107
+ generateStaticStateCss = (entries, _themeConfig) => {
2108
+ const rules = [];
2109
+ for (const entry of entries) {
2110
+ const stateConfig = JSON.parse(entry.statesJson);
2111
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2112
+ rules.push({
2113
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2114
+ declarations: classes,
2115
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2116
+ componentName: entry.componentName,
2117
+ stateName
2118
+ });
2119
+ }
2120
+ }
2121
+ return rules;
2122
+ };
2123
+ extractAndGenerateStateCss = (source, filename) => {
2124
+ const entries = extractTwStateConfigs(source, filename);
2125
+ return generateStaticStateCss(entries);
2126
+ };
2127
+ }
2128
+ });
2129
+
2130
+ // packages/domain/compiler/src/internal.ts
2131
+ var internal_exports = {};
2132
+ __export(internal_exports, {
2133
+ adaptNativeResult: () => adaptNativeResult,
2134
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
2135
+ analyzeClasses: () => analyzeClasses,
2136
+ analyzeClassesNative: () => analyzeClassesNative,
2137
+ analyzeFile: () => analyzeFile,
2138
+ analyzeRscNative: () => analyzeRscNative,
2139
+ analyzeVariantUsage: () => analyzeVariantUsage,
2140
+ astExtractClasses: () => astExtractClasses,
2141
+ atomicRegistrySize: () => atomicRegistrySize,
2142
+ batchExtractClasses: () => batchExtractClasses,
2143
+ batchExtractClassesNative: () => batchExtractClassesNative,
2144
+ bucketSort: () => bucketSort,
2145
+ buildStyleTag: () => buildStyleTag,
2146
+ cachePriority: () => cachePriority,
2147
+ cacheRead: () => cacheRead,
2148
+ cacheWrite: () => cacheWrite,
2149
+ checkAgainstSafelist: () => checkAgainstSafelist,
2150
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2151
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
2152
+ classifyNode: () => classifyNode,
2153
+ clearAllCaches: () => clearAllCaches,
2154
+ clearAtomicRegistry: () => clearAtomicRegistry,
2155
+ clearCache: () => clearCache,
2156
+ clearCompileCache: () => clearCompileCache,
2157
+ clearCssGenCache: () => clearCssGenCache,
2158
+ clearParseCache: () => clearParseCache,
2159
+ clearResolveCache: () => clearResolveCache,
2160
+ clearThemeCache: () => clearThemeCache,
2161
+ collectFiles: () => collectFiles,
2162
+ compileAnimation: () => compileAnimation,
2163
+ compileClass: () => compileClass,
2164
+ compileClasses: () => compileClasses,
2165
+ compileCssFromClasses: () => compileCssFromClasses,
2166
+ compileCssLightning: () => compileCssLightning,
2167
+ compileCssNative2: () => compileCssNative2,
2168
+ compileKeyframes: () => compileKeyframes,
2169
+ compileTheme: () => compileTheme,
2170
+ compileToCss: () => compileToCss,
2171
+ compileToCssBatch: () => compileToCssBatch,
2172
+ compileVariantTableNative: () => compileVariantTableNative,
2173
+ computeIncrementalDiff: () => computeIncrementalDiff,
2174
+ createFingerprint: () => createFingerprint,
2175
+ detectConflicts: () => detectConflicts,
2176
+ detectDeadCode: () => detectDeadCode,
2177
+ diffClassLists: () => diffClassLists,
2178
+ eliminateDeadCss: () => eliminateDeadCss,
2179
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
2180
+ emitPluginHook: () => emitPluginHook,
2181
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
2182
+ extractAllClasses: () => extractAllClasses,
2183
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
2184
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
2185
+ extractClassesFromSource: () => extractClassesFromSource,
2186
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
2187
+ extractComponentUsage: () => extractComponentUsage,
2188
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
2189
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
2190
+ extractTwStateConfigs: () => extractTwStateConfigs,
2191
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
2192
+ fileToRoute: () => fileToRoute,
2193
+ findDeadVariants: () => findDeadVariants,
2194
+ generateAtomicCss: () => generateAtomicCss,
2195
+ generateCssForClasses: () => generateCssForClasses,
2196
+ generateCssNative: () => generateCssNative,
2197
+ generateSafelist: () => generateSafelist,
2198
+ generateStaticStateCss: () => generateStaticStateCss,
2199
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
2200
+ generateSubComponentTypes: () => generateSubComponentTypes,
2201
+ getAllRoutes: () => getAllRoutes,
2202
+ getBucketEngine: () => getBucketEngine,
2203
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
2204
+ getCacheStatistics: () => getCacheStatistics,
2205
+ getCacheStats: () => getCacheStats,
2206
+ getCompilationMetrics: () => getCompilationMetrics,
2207
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
2208
+ getContentPaths: () => getContentPaths,
2209
+ getIncrementalEngine: () => getIncrementalEngine,
2210
+ getNativeBridge: () => getNativeBridge,
2211
+ getPluginHooks: () => getPluginHooks,
2212
+ getRouteClasses: () => getRouteClasses,
2213
+ getWatchStats: () => getWatchStats,
2214
+ hasTwUsage: () => hasTwUsage,
2215
+ hashContent: () => hashContent,
2216
+ hoistComponentsNative: () => hoistComponentsNative,
2217
+ idRegistryActiveCount: () => idRegistryActiveCount,
2218
+ idRegistryCreate: () => idRegistryCreate,
2219
+ idRegistryDestroy: () => idRegistryDestroy,
2220
+ idRegistryExport: () => idRegistryExport,
2221
+ idRegistryGenerate: () => idRegistryGenerate,
2222
+ idRegistryImport: () => idRegistryImport,
2223
+ idRegistryLookup: () => idRegistryLookup,
2224
+ idRegistryNext: () => idRegistryNext,
2225
+ idRegistryReset: () => idRegistryReset,
2226
+ idRegistrySnapshot: () => idRegistrySnapshot,
2227
+ injectClientDirective: () => injectClientDirective,
2228
+ injectServerOnlyComment: () => injectServerOnlyComment,
2229
+ injectStateHash: () => injectStateHash,
2230
+ isAlreadyTransformed: () => isAlreadyTransformed,
2231
+ isWatchRunning: () => isWatchRunning,
2232
+ layoutClassesToCss: () => layoutClassesToCss,
2233
+ loadSafelist: () => loadSafelist,
2234
+ loadTailwindConfig: () => loadTailwindConfig,
2235
+ mergeClassesStatic: () => mergeClassesStatic,
2236
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
2237
+ minifyCss: () => minifyCss,
2238
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
2239
+ normalizeClasses: () => normalizeClasses,
2240
+ optimizeCssNative: () => optimizeCssNative,
2241
+ parseAtomicClass: () => parseAtomicClass,
2242
+ parseClasses: () => parseClasses,
2243
+ pollWatchEvents: () => pollWatchEvents,
2244
+ processFileChange: () => processFileChange,
2245
+ processTailwindCssLightning: () => processTailwindCssLightning,
2246
+ propertyIdToString: () => propertyIdToString,
2247
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
2248
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
2249
+ redisCacheClear: () => redisCacheClear,
2250
+ redisCacheHitRate: () => redisCacheHitRate,
2251
+ redisCacheKeyCount: () => redisCacheKeyCount,
2252
+ redisCacheSize: () => redisCacheSize,
2253
+ redisCacheSync: () => redisCacheSync,
2254
+ redisClusterStatus: () => redisClusterStatus,
2255
+ redisDelete: () => redisDelete,
2256
+ redisDiagnose: () => redisDiagnose,
2257
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
2258
+ redisDisableCluster: () => redisDisableCluster,
2259
+ redisDisablePersistence: () => redisDisablePersistence,
2260
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
2261
+ redisEnableCluster: () => redisEnableCluster,
2262
+ redisEnablePersistence: () => redisEnablePersistence,
2263
+ redisExists: () => redisExists,
2264
+ redisExpirationGet: () => redisExpirationGet,
2265
+ redisExpirationSet: () => redisExpirationSet,
2266
+ redisFlushAll: () => redisFlushAll,
2267
+ redisFlushDb: () => redisFlushDb,
2268
+ redisGet: () => redisGet,
2269
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2270
+ redisInfo: () => redisInfo,
2271
+ redisMemoryStats: () => redisMemoryStats,
2272
+ redisMget: () => redisMget,
2273
+ redisMonitor: () => redisMonitor,
2274
+ redisMset: () => redisMset,
2275
+ redisOptimizeMemory: () => redisOptimizeMemory,
2276
+ redisPing: () => redisPing,
2277
+ redisPoolConnect: () => redisPoolConnect,
2278
+ redisPoolReconnect: () => redisPoolReconnect,
2279
+ redisPoolStats: () => redisPoolStats,
2280
+ redisPublish: () => redisPublish,
2281
+ redisReplicate: () => redisReplicate,
2282
+ redisReplicationStatus: () => redisReplicationStatus,
2283
+ redisSet: () => redisSet,
2284
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2285
+ redisSnapshot: () => redisSnapshot,
2286
+ redisSubscribe: () => redisSubscribe,
2287
+ registerFileClasses: () => registerFileClasses,
2288
+ registerGlobalClasses: () => registerGlobalClasses,
2289
+ registerPluginHook: () => registerPluginHook,
2290
+ registerPropertyName: () => registerPropertyName,
2291
+ registerValueName: () => registerValueName,
2292
+ resetBucketEngine: () => resetBucketEngine,
2293
+ resetCompilationMetrics: () => resetCompilationMetrics,
2294
+ resetIncrementalEngine: () => resetIncrementalEngine,
2295
+ resolveCascade: () => resolveCascade,
2296
+ resolveClassNames: () => resolveClassNames,
2297
+ resolveConflictGroup: () => resolveConflictGroup,
2298
+ resolveSimpleVariants: () => resolveSimpleVariants,
2299
+ resolveThemeValue: () => resolveThemeValue,
2300
+ resolveVariants: () => resolveVariants,
2301
+ reverseLookupProperty: () => reverseLookupProperty,
2302
+ reverseLookupValue: () => reverseLookupValue,
2303
+ runCssPipeline: () => runCssPipeline,
2304
+ runCssPipelineSync: () => runCssPipelineSync,
2305
+ runElimination: () => runElimination,
2306
+ runLoaderTransform: () => runLoaderTransform,
2307
+ scanCacheOptimizations: () => scanCacheOptimizations,
2308
+ scanFile: () => scanFile,
2309
+ scanFileNative: () => scanFileNative,
2310
+ scanFilesBatchNative: () => scanFilesBatchNative,
2311
+ scanProjectUsage: () => scanProjectUsage,
2312
+ scanWorkspace: () => scanWorkspace,
2313
+ shouldProcess: () => shouldProcess,
2314
+ shouldSkipFile: () => shouldSkipFile,
2315
+ startWatch: () => startWatch,
2316
+ stopWatch: () => stopWatch,
2317
+ toAtomicClasses: () => toAtomicClasses,
2318
+ transformSource: () => transformSource,
2319
+ twMerge: () => twMerge,
2320
+ twMergeMany: () => twMergeMany,
2321
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2322
+ twMergeRaw: () => twMergeRaw,
2323
+ twMergeWithSeparator: () => twMergeWithSeparator,
2324
+ unregisterPluginHook: () => unregisterPluginHook,
2325
+ validateCssOutput: () => validateCssOutput,
2326
+ validateThemeConfig: () => validateThemeConfig,
2327
+ valueIdToString: () => valueIdToString,
2328
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2329
+ watchAddPattern: () => watchAddPattern,
2330
+ watchClearAll: () => watchClearAll,
2331
+ watchEventTypeToString: () => watchEventTypeToString,
2332
+ watchGetActiveHandles: () => watchGetActiveHandles,
2333
+ watchPause: () => watchPause,
2334
+ watchRemovePattern: () => watchRemovePattern,
2335
+ watchResume: () => watchResume
2336
+ });
2337
+ var init_internal = __esm({
2338
+ "packages/domain/compiler/src/internal.ts"() {
2339
+ init_src2();
2340
+ init_tailwindEngine();
2341
+ init_compiler();
2342
+ init_parser();
2343
+ init_analyzer();
2344
+ init_cache();
2345
+ init_redis();
2346
+ init_watch();
2347
+ }
2348
+ });
2349
+
2350
+ // packages/presentation/next/src/turbopackLoader.ts
2351
+ init_internal();
2352
+ var _writtenRules = /* @__PURE__ */ new Set();
2353
+ function appendStaticCssToFile(staticCss, safelistPath) {
2354
+ if (!staticCss.trim() || !safelistPath) return;
2355
+ const stateFilePath = path4__namespace.default.join(path4__namespace.default.dirname(safelistPath), "_tw-state-static.css");
2356
+ const newRules = [];
2357
+ for (const chunk of staticCss.split(/(?<=\})\s*/)) {
2358
+ const rule = chunk.trim();
2359
+ if (rule && !_writtenRules.has(rule)) {
2360
+ _writtenRules.add(rule);
2361
+ newRules.push(rule);
2362
+ }
2363
+ }
2364
+ if (newRules.length === 0) return;
2365
+ try {
2366
+ fs4__namespace.default.mkdirSync(path4__namespace.default.dirname(stateFilePath), { recursive: true });
2367
+ if (!fs4__namespace.default.existsSync(stateFilePath)) {
2368
+ fs4__namespace.default.writeFileSync(
2369
+ stateFilePath,
2370
+ `/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
2371
+ * Import di globals.css: @import "./_tw-state-static.css";
2372
+ * Berisi: state CSS (.tw-s-*[data-*="true"]) + container queries (@container .tw-cq-*).
2373
+ */
2374
+
2375
+ `,
2376
+ "utf-8"
2377
+ );
2378
+ }
2379
+ fs4__namespace.default.appendFileSync(stateFilePath, newRules.join("\n") + "\n", "utf-8");
2380
+ } catch {
2381
+ }
2382
+ }
2383
+ function parseBool(val, fallback = false) {
2384
+ if (typeof val === "boolean") return val;
2385
+ if (typeof val === "string") return val === "true" || val === "1";
2386
+ return fallback;
2387
+ }
2388
+ function parseNum(val) {
2389
+ if (typeof val === "number") return val;
2390
+ if (typeof val === "string") return parseInt(val, 10) || void 0;
2391
+ return void 0;
2392
+ }
2393
+ function detectRouter(resourcePath) {
2394
+ const normalized = resourcePath.replace(/\\/g, "/");
2395
+ if (/\/app\//.test(normalized)) return "app";
2396
+ if (/\/pages\//.test(normalized)) return "pages";
2397
+ return "unknown";
2398
+ }
2399
+ var NEXT_RSC_ENTRIES = /(?:^|[\\/])(?:layout|page|loading|error|not-found|template|default)\.[jt]sx?$/;
2400
+ function isSkippable(resourcePath) {
2401
+ const normalized = resourcePath.replace(/\\/g, "/");
2402
+ return normalized.includes("/node_modules/") || normalized.endsWith(".d.ts") || normalized.endsWith(".d.mts") || normalized.endsWith(".d.cts") || // Skip CSS/assets
2403
+ /\.(css|scss|sass|less|svg|png|jpg|jpeg|gif|webp|ico|woff|woff2|ttf|eot)$/.test(normalized) || // Skip Next.js RSC entry files — Turbopack tidak punya exclude di rule level,
2404
+ // jadi guard ini menggantikan NEXT_RSC_ENTRIES exclude yang ada di webpack path.
2405
+ NEXT_RSC_ENTRIES.test(normalized);
2406
+ }
2407
+ function extractDirective(source) {
2408
+ const match = source.match(/^(\s*["'](use client|use server)["']\s*;?\s*\n?)/);
2409
+ if (!match) return { directive: "", stripped: source };
2410
+ const directive = match[1].trim().replace(/['"]/g, '"') + "\n";
2411
+ const stripped = source.slice(match[0].length);
2412
+ return { directive, stripped };
2413
+ }
2414
+ var CYCLE_SENTINEL = "_cycle.txt";
2415
+ var START_SENTINEL = "_start.txt";
2416
+ var _workerCache = /* @__PURE__ */ new Map();
2417
+ function getTwClassesDir(safelistPath) {
2418
+ return path4__namespace.default.join(path4__namespace.default.dirname(safelistPath), "tw-classes");
2419
+ }
2420
+ function readSentinel(filePath) {
2421
+ try {
2422
+ return fs4__namespace.default.readFileSync(filePath, "utf-8").trim();
2423
+ } catch {
2424
+ return "";
2425
+ }
2426
+ }
2427
+ var _clearLock = false;
2428
+ function clearAndMarkCycle(twClassesDir, startId) {
2429
+ if (_clearLock) return;
2430
+ _clearLock = true;
2431
+ try {
2432
+ if (fs4__namespace.default.existsSync(twClassesDir)) {
2433
+ const tempDir = `${twClassesDir}_clearing_${Date.now()}`;
2434
+ try {
2435
+ fs4__namespace.default.renameSync(twClassesDir, tempDir);
2436
+ fs4__namespace.default.mkdirSync(twClassesDir, { recursive: true });
2437
+ const startFile = path4__namespace.default.join(tempDir, START_SENTINEL);
2438
+ if (fs4__namespace.default.existsSync(startFile)) {
2439
+ fs4__namespace.default.copyFileSync(startFile, path4__namespace.default.join(twClassesDir, START_SENTINEL));
2440
+ }
2441
+ const mergedFile = path4__namespace.default.join(tempDir, "_webpack-merged.css");
2442
+ if (fs4__namespace.default.existsSync(mergedFile)) {
2443
+ fs4__namespace.default.copyFileSync(mergedFile, path4__namespace.default.join(twClassesDir, "_webpack-merged.css"));
2444
+ }
2445
+ fs4__namespace.default.writeFileSync(path4__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2446
+ _workerCache.set(twClassesDir, startId);
2447
+ fs4__namespace.default.rmSync(tempDir, { recursive: true, force: true });
2448
+ } catch {
2449
+ for (const file of fs4__namespace.default.readdirSync(twClassesDir)) {
2450
+ if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
2451
+ try {
2452
+ fs4__namespace.default.unlinkSync(path4__namespace.default.join(twClassesDir, file));
2453
+ } catch {
2454
+ }
2455
+ }
2456
+ fs4__namespace.default.writeFileSync(path4__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2457
+ _workerCache.set(twClassesDir, startId);
2458
+ }
2459
+ } else {
2460
+ fs4__namespace.default.mkdirSync(twClassesDir, { recursive: true });
2461
+ fs4__namespace.default.writeFileSync(path4__namespace.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
2462
+ _workerCache.set(twClassesDir, startId);
2463
+ }
2464
+ } catch {
2465
+ } finally {
2466
+ _clearLock = false;
2467
+ }
2468
+ }
2469
+ function getPerFileSafelistPath(safelistDir, resourcePath) {
2470
+ const normalized = resourcePath.replace(/\\/g, "/");
2471
+ const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
2472
+ return path4__namespace.default.join(safelistDir, `${slug}.css`);
2473
+ }
2474
+ function writePerFileSafelist(safelistPath, resourcePath, classes) {
2475
+ if (!safelistPath || classes.length === 0) return;
2476
+ try {
2477
+ const twClassesDir = getTwClassesDir(safelistPath);
2478
+ const startId = readSentinel(path4__namespace.default.join(twClassesDir, START_SENTINEL));
2479
+ const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path4__namespace.default.join(twClassesDir, CYCLE_SENTINEL));
2480
+ if (startId && cachedCycle !== startId) {
2481
+ clearAndMarkCycle(twClassesDir, startId);
2482
+ } else if (!fs4__namespace.default.existsSync(twClassesDir)) {
2483
+ fs4__namespace.default.mkdirSync(twClassesDir, { recursive: true });
2484
+ }
2485
+ const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
2486
+ const sorted = [...new Set(classes)].sort();
2487
+ const css = [
2488
+ `/* tw-safelist: ${path4__namespace.default.basename(resourcePath)} \u2014 auto-generated */`,
2489
+ "@layer utilities {",
2490
+ sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
2491
+ "}"
2492
+ ].join("\n");
2493
+ try {
2494
+ if (fs4__namespace.default.readFileSync(outPath, "utf-8") === css) return;
2495
+ } catch {
2496
+ }
2497
+ const tmpPath = `${outPath}.tmp`;
2498
+ try {
2499
+ fs4__namespace.default.writeFileSync(tmpPath, css, "utf-8");
2500
+ fs4__namespace.default.renameSync(tmpPath, outPath);
2501
+ } catch {
2502
+ try {
2503
+ fs4__namespace.default.unlinkSync(tmpPath);
2504
+ } catch {
2505
+ }
2506
+ fs4__namespace.default.writeFileSync(outPath, css, "utf-8");
2507
+ }
2508
+ } catch {
2509
+ }
2510
+ }
2511
+ function turbopackLoader(source, options = {}) {
2512
+ if (isSkippable(this.resourcePath)) return source;
2513
+ const router = detectRouter(this.resourcePath);
2514
+ const nextMajor = parseNum(options.nextMajor);
2515
+ const debug = parseBool(options.debug);
2516
+ const filename = path4__namespace.default.basename(this.resourcePath);
2517
+ const effective = {
2518
+ addDataAttr: parseBool(options.addDataAttr),
2519
+ // App Router: selalu auto-detect client boundary
2520
+ // Pages Router: opt-in via option
2521
+ autoClientBoundary: router === "app" ? true : parseBool(options.autoClientBoundary),
2522
+ // Hoist by default untuk semua contexts
2523
+ hoist: parseBool(options.hoist, true),
2524
+ // Pages Router: preserve imports (RSC tidak berlaku)
2525
+ preserveImports: router === "pages" ? true : parseBool(options.preserveImports, false)
2526
+ };
2527
+ if (debug) {
2528
+ console.debug(`[tw-loader] ${filename}: router=${router} nextMajor=${nextMajor ?? "unknown"}`);
2529
+ }
2530
+ const { directive, stripped } = extractDirective(source);
2531
+ let processedSource = stripped;
2532
+ try {
2533
+ const compilerMod = (init_internal(), __toCommonJS(internal_exports));
2534
+ if (typeof compilerMod?.injectStateHash === "function" && stripped.includes("states:")) {
2535
+ const hashResult = compilerMod.injectStateHash(stripped, this.resourcePath);
2536
+ if (hashResult.changed) {
2537
+ processedSource = hashResult.code;
2538
+ if (debug) {
2539
+ console.debug(`[tw-loader] ${filename}: injected __hash for ${hashResult.injectedCount} component(s)`);
2540
+ }
2541
+ }
2542
+ }
2543
+ } catch {
2544
+ }
2545
+ try {
2546
+ const output = runLoaderTransform({
2547
+ filepath: this.resourcePath,
2548
+ source: processedSource,
2549
+ options: effective
2550
+ });
2551
+ if (!output.changed) {
2552
+ if (output.classes.length > 0) {
2553
+ writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
2554
+ }
2555
+ if (output.staticCss && options.safelistPath) {
2556
+ appendStaticCssToFile(output.staticCss, options.safelistPath);
2557
+ }
2558
+ return source;
2559
+ }
2560
+ if (output.classes.length > 0) {
2561
+ registerFileClasses(this.resourcePath, output.classes);
2562
+ writePerFileSafelist(options.safelistPath, this.resourcePath, output.classes);
2563
+ }
2564
+ if (output.staticCss && options.safelistPath) {
2565
+ appendStaticCssToFile(output.staticCss, options.safelistPath);
402
2566
  }
403
2567
  if (!directive) return output.code;
404
2568
  const clean = output.code.replace(/^\s*["'](use client|use server)["']\s*;?\s*\n?/, "");