tailwind-styled-v4 5.0.11 → 5.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +100 -4
  2. package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
  3. package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
  4. package/dist/analyzer.d.mts +4 -4
  5. package/dist/analyzer.d.ts +4 -4
  6. package/dist/analyzer.js +34 -69
  7. package/dist/analyzer.js.map +1 -1
  8. package/dist/analyzer.mjs +33 -68
  9. package/dist/analyzer.mjs.map +1 -1
  10. package/dist/animate.d.mts +4 -0
  11. package/dist/animate.d.ts +4 -0
  12. package/dist/animate.js +33 -11
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +33 -11
  15. package/dist/animate.mjs.map +1 -1
  16. package/dist/atomic.js +57 -6
  17. package/dist/atomic.js.map +1 -1
  18. package/dist/atomic.mjs +57 -6
  19. package/dist/atomic.mjs.map +1 -1
  20. package/dist/cli.js +404 -190
  21. package/dist/cli.js.map +1 -1
  22. package/dist/cli.mjs +401 -187
  23. package/dist/cli.mjs.map +1 -1
  24. package/dist/compiler.d.mts +2700 -212
  25. package/dist/compiler.d.ts +2700 -212
  26. package/dist/compiler.js +1996 -503
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/compiler.mjs +1847 -448
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/devtools.js +17 -4
  31. package/dist/devtools.js.map +1 -1
  32. package/dist/devtools.mjs +17 -4
  33. package/dist/devtools.mjs.map +1 -1
  34. package/dist/engine.d.mts +11 -470
  35. package/dist/engine.d.ts +11 -470
  36. package/dist/engine.js +2777 -455
  37. package/dist/engine.js.map +1 -1
  38. package/dist/engine.mjs +2776 -454
  39. package/dist/engine.mjs.map +1 -1
  40. package/dist/index-BDQw13kn.d.ts +464 -0
  41. package/dist/index-DJv28Uzq.d.mts +464 -0
  42. package/dist/index.browser.mjs +143 -255
  43. package/dist/index.browser.mjs.map +1 -1
  44. package/dist/index.d.mts +23 -39
  45. package/dist/index.d.ts +23 -39
  46. package/dist/index.js +7234 -1400
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +7234 -1400
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/next.d.mts +44 -1
  51. package/dist/next.d.ts +44 -1
  52. package/dist/next.js +3224 -1065
  53. package/dist/next.js.map +1 -1
  54. package/dist/next.mjs +3223 -1066
  55. package/dist/next.mjs.map +1 -1
  56. package/dist/rspack.d.mts +9 -0
  57. package/dist/rspack.d.ts +9 -0
  58. package/dist/rspack.js +99 -61
  59. package/dist/rspack.js.map +1 -1
  60. package/dist/rspack.mjs +99 -61
  61. package/dist/rspack.mjs.map +1 -1
  62. package/dist/runtime-css.d.mts +8 -0
  63. package/dist/runtime-css.d.ts +8 -0
  64. package/dist/runtime-css.js +23 -7
  65. package/dist/runtime-css.js.map +1 -1
  66. package/dist/runtime-css.mjs +23 -7
  67. package/dist/runtime-css.mjs.map +1 -1
  68. package/dist/scanner.js +16 -37
  69. package/dist/scanner.js.map +1 -1
  70. package/dist/scanner.mjs +15 -36
  71. package/dist/scanner.mjs.map +1 -1
  72. package/dist/shared.d.mts +107 -1
  73. package/dist/shared.d.ts +107 -1
  74. package/dist/shared.js +3014 -466
  75. package/dist/shared.js.map +1 -1
  76. package/dist/shared.mjs +3008 -445
  77. package/dist/shared.mjs.map +1 -1
  78. package/dist/svelte.js +39 -35
  79. package/dist/svelte.js.map +1 -1
  80. package/dist/svelte.mjs +38 -34
  81. package/dist/svelte.mjs.map +1 -1
  82. package/dist/theme.js +85 -76
  83. package/dist/theme.js.map +1 -1
  84. package/dist/theme.mjs +83 -74
  85. package/dist/theme.mjs.map +1 -1
  86. package/dist/turbopackLoader.js +2351 -187
  87. package/dist/turbopackLoader.js.map +1 -1
  88. package/dist/turbopackLoader.mjs +2351 -187
  89. package/dist/turbopackLoader.mjs.map +1 -1
  90. package/dist/tw.js +404 -190
  91. package/dist/tw.js.map +1 -1
  92. package/dist/tw.mjs +401 -187
  93. package/dist/tw.mjs.map +1 -1
  94. package/dist/vite.js +2657 -320
  95. package/dist/vite.js.map +1 -1
  96. package/dist/vite.mjs +2657 -320
  97. package/dist/vite.mjs.map +1 -1
  98. package/dist/vue.js +39 -35
  99. package/dist/vue.js.map +1 -1
  100. package/dist/vue.mjs +38 -34
  101. package/dist/vue.mjs.map +1 -1
  102. package/dist/webpackLoader.js +190 -33
  103. package/dist/webpackLoader.js.map +1 -1
  104. package/dist/webpackLoader.mjs +190 -33
  105. package/dist/webpackLoader.mjs.map +1 -1
  106. package/native/index.node +0 -0
  107. package/native/tailwind-styled-native.node +0 -0
  108. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  109. package/package.json +9 -4
  110. package/CHANGELOG.md +0 -285
package/dist/shared.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var crypto = require('crypto');
4
- var fs = require('fs');
3
+ var zod = require('zod');
4
+ var module$1 = require('module');
5
+ var fs3 = require('fs');
5
6
  var path = require('path');
7
+ var crypto = require('crypto');
6
8
  var url = require('url');
7
- var module$1 = require('module');
8
- var zod = require('zod');
9
9
 
10
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
11
  function _interopNamespace(e) {
@@ -26,16 +26,36 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
29
+ var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
30
30
  var path__namespace = /*#__PURE__*/_interopNamespace(path);
31
31
 
32
32
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
33
+ var __defProp = Object.defineProperty;
34
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
35
+ var __getOwnPropNames = Object.getOwnPropertyNames;
36
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
33
37
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
34
38
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
35
39
  }) : x)(function(x) {
36
40
  if (typeof require !== "undefined") return require.apply(this, arguments);
37
41
  throw Error('Dynamic require of "' + x + '" is not supported');
38
42
  });
43
+ var __esm = (fn, res) => function __init() {
44
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
45
+ };
46
+ var __export = (target, all) => {
47
+ for (var name in all)
48
+ __defProp(target, name, { get: all[name], enumerable: true });
49
+ };
50
+ var __copyProps = (to, from, except, desc) => {
51
+ if (from && typeof from === "object" || typeof from === "function") {
52
+ for (let key of __getOwnPropNames(from))
53
+ if (!__hasOwnProp.call(to, key) && key !== except)
54
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
55
+ }
56
+ return to;
57
+ };
58
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
59
 
40
60
  // packages/domain/shared/src/trace.ts
41
61
  function getHealthColor(status) {
@@ -127,43 +147,12 @@ function getPipelinePercentages(metrics) {
127
147
  compilePct: compile / total * 100
128
148
  };
129
149
  }
150
+ var init_trace = __esm({
151
+ "packages/domain/shared/src/trace.ts"() {
152
+ }
153
+ });
130
154
 
131
155
  // packages/domain/shared/src/error-codes.ts
132
- var ERROR_CODES = {
133
- // E0xx — Native binding
134
- NATIVE_NOT_FOUND: "E001",
135
- NATIVE_LOAD_FAILED: "E002",
136
- NATIVE_VERSION_MISMATCH: "E003",
137
- SCANNER_NATIVE_NOT_FOUND: "E004",
138
- SCANNER_HASH_FAILED: "E005",
139
- NATIVE_TRANSFORM_UNAVAILABLE: "E006",
140
- // E2xx — Compilation
141
- MISSING_REACT_IMPORT: "E201",
142
- UNSUPPORTED_PATTERN: "E202",
143
- TEMPLATE_PARSE_ERROR: "E203",
144
- COMPILE_TIMEOUT: "E204",
145
- // E3xx — Compatibility
146
- TAILWIND_VERSION_UNSUPPORTED: "E301",
147
- NODE_VERSION_UNSUPPORTED: "E302",
148
- // E4xx — Cache
149
- CACHE_READ_FAILED: "E401",
150
- CACHE_WRITE_FAILED: "E402",
151
- CACHE_CORRUPTED: "E403",
152
- // E5xx — RSC
153
- RSC_BOUNDARY_CONFLICT: "E501",
154
- // W1xx — Warnings
155
- DYNAMIC_CONTENT: "W101",
156
- INVALID_VARIANT_VALUE: "W201",
157
- DEPRECATED_MODE: "W301"
158
- };
159
- var ERROR_SUGGESTIONS = {
160
- E001: "Run: npm install @tailwind-styled/native-{platform} or build from source",
161
- E002: "Try: npm rebuild or reinstall the package",
162
- E003: "Run: npm install tailwind-styled-v4@latest to sync versions",
163
- E004: "Run: npm install @tailwind-styled/scanner",
164
- E006: "Run: npm install @tailwind-styled/compiler",
165
- E301: "Upgrade: npm install tailwindcss@^4"
166
- };
167
156
  function getSuggestion(code) {
168
157
  return ERROR_SUGGESTIONS[code];
169
158
  }
@@ -171,6 +160,46 @@ function formatErrorCode(code) {
171
160
  const prefix = code.startsWith("E") ? "Error" : code.startsWith("W") ? "Warning" : "Code";
172
161
  return `[${prefix} ${code}]`;
173
162
  }
163
+ exports.ERROR_CODES = void 0; var ERROR_SUGGESTIONS;
164
+ var init_error_codes = __esm({
165
+ "packages/domain/shared/src/error-codes.ts"() {
166
+ exports.ERROR_CODES = {
167
+ // E0xx — Native binding
168
+ NATIVE_NOT_FOUND: "E001",
169
+ NATIVE_LOAD_FAILED: "E002",
170
+ NATIVE_VERSION_MISMATCH: "E003",
171
+ SCANNER_NATIVE_NOT_FOUND: "E004",
172
+ SCANNER_HASH_FAILED: "E005",
173
+ NATIVE_TRANSFORM_UNAVAILABLE: "E006",
174
+ // E2xx — Compilation
175
+ MISSING_REACT_IMPORT: "E201",
176
+ UNSUPPORTED_PATTERN: "E202",
177
+ TEMPLATE_PARSE_ERROR: "E203",
178
+ COMPILE_TIMEOUT: "E204",
179
+ // E3xx — Compatibility
180
+ TAILWIND_VERSION_UNSUPPORTED: "E301",
181
+ NODE_VERSION_UNSUPPORTED: "E302",
182
+ // E4xx — Cache
183
+ CACHE_READ_FAILED: "E401",
184
+ CACHE_WRITE_FAILED: "E402",
185
+ CACHE_CORRUPTED: "E403",
186
+ // E5xx — RSC
187
+ RSC_BOUNDARY_CONFLICT: "E501",
188
+ // W1xx — Warnings
189
+ DYNAMIC_CONTENT: "W101",
190
+ INVALID_VARIANT_VALUE: "W201",
191
+ DEPRECATED_MODE: "W301"
192
+ };
193
+ ERROR_SUGGESTIONS = {
194
+ E001: "Run: npm install @tailwind-styled/native-{platform} or build from source",
195
+ E002: "Try: npm rebuild or reinstall the package",
196
+ E003: "Run: npm install tailwind-styled-v4@latest to sync versions",
197
+ E004: "Run: npm install @tailwind-styled/scanner",
198
+ E006: "Run: npm install @tailwind-styled/compiler",
199
+ E301: "Upgrade: npm install tailwindcss@^4"
200
+ };
201
+ }
202
+ });
174
203
 
175
204
  // packages/domain/shared/src/compatibility.ts
176
205
  function detectTailwind() {
@@ -198,64 +227,9 @@ function getTailwindVersion() {
198
227
  function isTailwindV4() {
199
228
  return detectTailwind().supported;
200
229
  }
201
- var NativeScanFileSchema = zod.z.object({
202
- file: zod.z.string().min(1, "file path cannot be empty"),
203
- classes: zod.z.array(zod.z.string()),
204
- hash: zod.z.string().optional()
205
- });
206
- var NativeScanResultSchema = zod.z.object({
207
- files: zod.z.array(NativeScanFileSchema),
208
- totalFiles: zod.z.number().int().nonnegative(),
209
- uniqueClasses: zod.z.array(zod.z.string())
210
- });
211
- var NativeClassUsageSchema = zod.z.object({
212
- name: zod.z.string(),
213
- count: zod.z.number().int().nonnegative(),
214
- files: zod.z.array(zod.z.string()).optional()
215
- });
216
- var NativeAnalyzerReportSchema = zod.z.object({
217
- root: zod.z.string(),
218
- topClasses: zod.z.array(NativeClassUsageSchema).optional(),
219
- safelist: zod.z.array(zod.z.string()).optional(),
220
- css: zod.z.string().optional(),
221
- conflicts: zod.z.array(zod.z.unknown()).optional(),
222
- unusedClasses: zod.z.array(zod.z.string()).optional(),
223
- durationMs: zod.z.number().nonnegative().optional()
224
- });
225
- var NativeTransformResultSchema = zod.z.object({
226
- code: zod.z.string(),
227
- classes: zod.z.array(zod.z.string()),
228
- changed: zod.z.boolean(),
229
- rsc: zod.z.object({
230
- isServer: zod.z.boolean(),
231
- needsClientDirective: zod.z.boolean(),
232
- clientReasons: zod.z.array(zod.z.string())
233
- }).optional()
234
- });
235
- var NativeCssCompileResultSchema = zod.z.object({
236
- css: zod.z.string(),
237
- resolvedClasses: zod.z.array(zod.z.string()),
238
- unresolvedClasses: zod.z.array(zod.z.string()).optional()
239
- });
240
- zod.z.object({
241
- type: zod.z.enum(["change", "unlink", "create"]),
242
- path: zod.z.string()
243
- });
244
- var NativeWatchResultSchema = zod.z.object({
245
- status: zod.z.enum(["ok", "error"]),
246
- handleId: zod.z.string().optional(),
247
- error: zod.z.string().optional()
248
- });
249
- var NativeCacheEntrySchema = zod.z.object({
250
- file: zod.z.string(),
251
- hash: zod.z.string(),
252
- classes: zod.z.array(zod.z.string()),
253
- timestamp: zod.z.number(),
254
- size: zod.z.number().optional()
255
- });
256
- var NativeCacheReadResultSchema = zod.z.object({
257
- entries: zod.z.array(NativeCacheEntrySchema),
258
- version: zod.z.string().optional()
230
+ var init_compatibility = __esm({
231
+ "packages/domain/shared/src/compatibility.ts"() {
232
+ }
259
233
  });
260
234
  function safeParseNative(schema, data, fallback) {
261
235
  const result = schema.safeParse(data);
@@ -265,17 +239,79 @@ function parseNative(schema, data, context) {
265
239
  const result = schema.safeParse(data);
266
240
  if (!result.success) {
267
241
  const first = result.error.issues[0];
268
- const path3 = first?.path?.join(".") ?? "(root)";
242
+ const path6 = first?.path?.join(".") ?? "(root)";
269
243
  throw new Error(
270
- `[${context}] Native binding returned unexpected data: ${path3}: ${first?.message ?? "validation failed"}`
244
+ `[${context}] Native binding returned unexpected data: ${path6}: ${first?.message ?? "validation failed"}`
271
245
  );
272
246
  }
273
247
  return result.data;
274
248
  }
249
+ exports.NativeScanFileSchema = void 0; exports.NativeScanResultSchema = void 0; var NativeClassUsageSchema; exports.NativeAnalyzerReportSchema = void 0; exports.NativeTransformResultSchema = void 0; exports.NativeCssCompileResultSchema = void 0; exports.NativeWatchResultSchema = void 0; exports.NativeCacheEntrySchema = void 0; exports.NativeCacheReadResultSchema = void 0;
250
+ var init_native_schemas = __esm({
251
+ "packages/domain/shared/src/native-schemas.ts"() {
252
+ exports.NativeScanFileSchema = zod.z.object({
253
+ file: zod.z.string().min(1, "file path cannot be empty"),
254
+ classes: zod.z.array(zod.z.string()),
255
+ hash: zod.z.string().optional()
256
+ });
257
+ exports.NativeScanResultSchema = zod.z.object({
258
+ files: zod.z.array(exports.NativeScanFileSchema),
259
+ totalFiles: zod.z.number().int().nonnegative(),
260
+ uniqueClasses: zod.z.array(zod.z.string())
261
+ });
262
+ NativeClassUsageSchema = zod.z.object({
263
+ name: zod.z.string(),
264
+ count: zod.z.number().int().nonnegative(),
265
+ files: zod.z.array(zod.z.string()).optional()
266
+ });
267
+ exports.NativeAnalyzerReportSchema = zod.z.object({
268
+ root: zod.z.string(),
269
+ topClasses: zod.z.array(NativeClassUsageSchema).optional(),
270
+ safelist: zod.z.array(zod.z.string()).optional(),
271
+ css: zod.z.string().optional(),
272
+ conflicts: zod.z.array(zod.z.unknown()).optional(),
273
+ unusedClasses: zod.z.array(zod.z.string()).optional(),
274
+ durationMs: zod.z.number().nonnegative().optional()
275
+ });
276
+ exports.NativeTransformResultSchema = zod.z.object({
277
+ code: zod.z.string(),
278
+ classes: zod.z.array(zod.z.string()),
279
+ changed: zod.z.boolean(),
280
+ rsc: zod.z.object({
281
+ isServer: zod.z.boolean(),
282
+ needsClientDirective: zod.z.boolean(),
283
+ clientReasons: zod.z.array(zod.z.string())
284
+ }).optional()
285
+ });
286
+ exports.NativeCssCompileResultSchema = zod.z.object({
287
+ css: zod.z.string(),
288
+ resolvedClasses: zod.z.array(zod.z.string()),
289
+ unresolvedClasses: zod.z.array(zod.z.string()).optional()
290
+ });
291
+ zod.z.object({
292
+ type: zod.z.enum(["change", "unlink", "create"]),
293
+ path: zod.z.string()
294
+ });
295
+ exports.NativeWatchResultSchema = zod.z.object({
296
+ status: zod.z.enum(["ok", "error"]),
297
+ handleId: zod.z.string().optional(),
298
+ error: zod.z.string().optional()
299
+ });
300
+ exports.NativeCacheEntrySchema = zod.z.object({
301
+ file: zod.z.string(),
302
+ hash: zod.z.string(),
303
+ classes: zod.z.array(zod.z.string()),
304
+ timestamp: zod.z.number(),
305
+ size: zod.z.number().optional()
306
+ });
307
+ exports.NativeCacheReadResultSchema = zod.z.object({
308
+ entries: zod.z.array(exports.NativeCacheEntrySchema),
309
+ version: zod.z.string().optional()
310
+ });
311
+ }
312
+ });
275
313
 
276
314
  // packages/domain/shared/src/esmHelpers.ts
277
- var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
278
- var nodeModuleRef = null;
279
315
  function getNodeModuleRef() {
280
316
  if (isBrowser) return null;
281
317
  if (nodeModuleRef !== null) return nodeModuleRef;
@@ -288,9 +324,6 @@ function getNodeModuleRef() {
288
324
  return null;
289
325
  }
290
326
  }
291
- var _nodePath = null;
292
- var _nodeUrl = null;
293
- var _nodeFs = null;
294
327
  function getNodePath() {
295
328
  if (isBrowser) throw new Error("node:path not available in browser");
296
329
  const nodeRequire = getNodeModuleRef();
@@ -358,75 +391,21 @@ function resolveNativeNodePath(importMetaUrl, ...relativeSegments) {
358
391
  if (isBrowser) return relativeSegments.join("/");
359
392
  return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments);
360
393
  }
394
+ var isBrowser, nodeModuleRef, _nodePath, _nodeUrl, _nodeFs;
395
+ var init_esmHelpers = __esm({
396
+ "packages/domain/shared/src/esmHelpers.ts"() {
397
+ isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
398
+ nodeModuleRef = null;
399
+ _nodePath = null;
400
+ _nodeUrl = null;
401
+ _nodeFs = null;
402
+ }
403
+ });
361
404
 
362
405
  // packages/domain/shared/src/telemetry.ts
363
- var RING_BUFFER_SIZE = 100;
364
- var TelemetryCollector = class {
365
- data = [];
366
- enabled;
367
- constructor(enabled) {
368
- this.enabled = enabled ?? (process.env.TWS_TELEMETRY === "1" || process.env.TWS_TELEMETRY === "true");
369
- }
370
- record(build) {
371
- if (!this.enabled) return;
372
- if (this.data.length >= RING_BUFFER_SIZE) {
373
- this.data.shift();
374
- }
375
- this.data.push(build);
376
- }
377
- snapshot() {
378
- return [...this.data];
379
- }
380
- summary() {
381
- if (this.data.length === 0) return null;
382
- const durations = this.data.map((d) => d.durationMs).sort((a, b) => a - b);
383
- const p95Idx = Math.floor(durations.length * 0.95);
384
- const avg = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
385
- return {
386
- totalBuilds: this.data.length,
387
- avgDurationMs: avg(durations),
388
- p95DurationMs: durations[p95Idx] ?? durations[durations.length - 1] ?? 0,
389
- avgCacheHitRate: avg(this.data.map((d) => d.cacheHitRate)),
390
- avgFilesScanned: avg(this.data.map((d) => d.filesScanned)),
391
- avgClassesExtracted: avg(this.data.map((d) => d.classesExtracted)),
392
- phaseAvgs: {
393
- scan: avg(this.data.map((d) => d.phases.scan)),
394
- compile: avg(this.data.map((d) => d.phases.compile)),
395
- engine: avg(this.data.map((d) => d.phases.engine)),
396
- output: avg(this.data.map((d) => d.phases.output))
397
- },
398
- slowestBuildMs: durations[durations.length - 1] ?? 0,
399
- fastestBuildMs: durations[0] ?? 0
400
- };
401
- }
402
- reset() {
403
- this.data = [];
404
- }
405
- /** Format ringkas untuk CLI output */
406
- formatCli() {
407
- const s = this.summary();
408
- if (!s) return "[telemetry] no data";
409
- return [
410
- `[telemetry] ${s.totalBuilds} builds`,
411
- `avg ${s.avgDurationMs.toFixed(0)}ms`,
412
- `p95 ${s.p95DurationMs.toFixed(0)}ms`,
413
- `cache hit ${(s.avgCacheHitRate * 100).toFixed(0)}%`,
414
- `${s.avgFilesScanned.toFixed(0)} files`
415
- ].join(" \xB7 ");
416
- }
417
- /** Export sebagai JSON untuk dashboard/prometheus */
418
- toJSON() {
419
- return {
420
- summary: this.summary(),
421
- history: this.data.slice(-20)
422
- // last 20 builds
423
- };
424
- }
425
- };
426
- var _globalCollector = null;
427
406
  function getGlobalTelemetry() {
428
407
  if (!_globalCollector) {
429
- _globalCollector = new TelemetryCollector();
408
+ _globalCollector = new exports.TelemetryCollector();
430
409
  }
431
410
  return _globalCollector;
432
411
  }
@@ -462,68 +441,75 @@ function createBuildTimer() {
462
441
  }
463
442
  };
464
443
  }
465
- var ScanCacheClassEntrySchema = zod.z.object({
466
- name: zod.z.string().min(1),
467
- usedIn: zod.z.array(zod.z.string()),
468
- risk: zod.z.enum(["low", "medium", "high"]).default("low"),
469
- bundleContribution: zod.z.number().nonnegative().default(0),
470
- variants: zod.z.array(zod.z.string()).default([])
471
- });
472
- var ScanCacheSchema = zod.z.object({
473
- version: zod.z.string().default("1"),
474
- generatedAt: zod.z.string(),
475
- root: zod.z.string(),
476
- classNames: zod.z.array(ScanCacheClassEntrySchema),
477
- totalFiles: zod.z.number().int().nonnegative(),
478
- uniqueCount: zod.z.number().int().nonnegative()
479
- });
480
- var TailwindContentItemSchema = zod.z.union([
481
- zod.z.string(),
482
- zod.z.object({
483
- raw: zod.z.string(),
484
- extension: zod.z.string().optional()
485
- }),
486
- zod.z.object({
487
- files: zod.z.array(zod.z.string()),
488
- transform: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
489
- })
490
- ]);
491
- var TailwindConfigSchema = zod.z.object({
492
- content: zod.z.array(TailwindContentItemSchema).optional(),
493
- theme: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
494
- plugins: zod.z.array(zod.z.unknown()).optional(),
495
- darkMode: zod.z.union([zod.z.literal("class"), zod.z.literal("media"), zod.z.literal(false)]).optional(),
496
- prefix: zod.z.string().optional(),
497
- safelist: zod.z.array(zod.z.union([zod.z.string(), zod.z.object({ pattern: zod.z.instanceof(RegExp) })])).optional(),
498
- blocklist: zod.z.array(zod.z.string()).optional()
499
- }).passthrough();
500
- var RegistryPluginEntrySchema = zod.z.object({
501
- name: zod.z.string().min(1),
502
- description: zod.z.string(),
503
- version: zod.z.string(),
504
- tags: zod.z.array(zod.z.string()).default([]),
505
- official: zod.z.boolean().default(false),
506
- docs: zod.z.string().url().optional(),
507
- install: zod.z.string().optional(),
508
- integrity: zod.z.string().optional()
509
- });
510
- var RegistryFileSchema = zod.z.object({
511
- version: zod.z.string(),
512
- official: zod.z.array(RegistryPluginEntrySchema).default([]),
513
- community: zod.z.array(RegistryPluginEntrySchema).default([])
444
+ var RING_BUFFER_SIZE; exports.TelemetryCollector = void 0; var _globalCollector;
445
+ var init_telemetry = __esm({
446
+ "packages/domain/shared/src/telemetry.ts"() {
447
+ RING_BUFFER_SIZE = 100;
448
+ exports.TelemetryCollector = class {
449
+ data = [];
450
+ enabled;
451
+ constructor(enabled) {
452
+ this.enabled = enabled ?? (process.env.TWS_TELEMETRY === "1" || process.env.TWS_TELEMETRY === "true");
453
+ }
454
+ record(build) {
455
+ if (!this.enabled) return;
456
+ if (this.data.length >= RING_BUFFER_SIZE) {
457
+ this.data.shift();
458
+ }
459
+ this.data.push(build);
460
+ }
461
+ snapshot() {
462
+ return [...this.data];
463
+ }
464
+ summary() {
465
+ if (this.data.length === 0) return null;
466
+ const durations = this.data.map((d) => d.durationMs).sort((a, b) => a - b);
467
+ const p95Idx = Math.floor(durations.length * 0.95);
468
+ const avg = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
469
+ return {
470
+ totalBuilds: this.data.length,
471
+ avgDurationMs: avg(durations),
472
+ p95DurationMs: durations[p95Idx] ?? durations[durations.length - 1] ?? 0,
473
+ avgCacheHitRate: avg(this.data.map((d) => d.cacheHitRate)),
474
+ avgFilesScanned: avg(this.data.map((d) => d.filesScanned)),
475
+ avgClassesExtracted: avg(this.data.map((d) => d.classesExtracted)),
476
+ phaseAvgs: {
477
+ scan: avg(this.data.map((d) => d.phases.scan)),
478
+ compile: avg(this.data.map((d) => d.phases.compile)),
479
+ engine: avg(this.data.map((d) => d.phases.engine)),
480
+ output: avg(this.data.map((d) => d.phases.output))
481
+ },
482
+ slowestBuildMs: durations[durations.length - 1] ?? 0,
483
+ fastestBuildMs: durations[0] ?? 0
484
+ };
485
+ }
486
+ reset() {
487
+ this.data = [];
488
+ }
489
+ /** Format ringkas untuk CLI output */
490
+ formatCli() {
491
+ const s = this.summary();
492
+ if (!s) return "[telemetry] no data";
493
+ return [
494
+ `[telemetry] ${s.totalBuilds} builds`,
495
+ `avg ${s.avgDurationMs.toFixed(0)}ms`,
496
+ `p95 ${s.p95DurationMs.toFixed(0)}ms`,
497
+ `cache hit ${(s.avgCacheHitRate * 100).toFixed(0)}%`,
498
+ `${s.avgFilesScanned.toFixed(0)} files`
499
+ ].join(" \xB7 ");
500
+ }
501
+ /** Export sebagai JSON untuk dashboard/prometheus */
502
+ toJSON() {
503
+ return {
504
+ summary: this.summary(),
505
+ history: this.data.slice(-20)
506
+ // last 20 builds
507
+ };
508
+ }
509
+ };
510
+ _globalCollector = null;
511
+ }
514
512
  });
515
- var PackageJsonSchema = zod.z.object({
516
- name: zod.z.string(),
517
- version: zod.z.string(),
518
- scripts: zod.z.record(zod.z.string(), zod.z.string()).optional(),
519
- dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
520
- devDependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
521
- peerDependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
522
- main: zod.z.string().optional(),
523
- module: zod.z.string().optional(),
524
- exports: zod.z.unknown().optional(),
525
- type: zod.z.enum(["module", "commonjs"]).optional()
526
- }).passthrough();
527
513
  function parseJsonWithSchema(jsonString, schema, sourceName) {
528
514
  let parsed;
529
515
  try {
@@ -554,12 +540,75 @@ function parseJsonFileWithSchema(filePath, schema) {
554
540
  }
555
541
  return parseJsonWithSchema(content, schema, basename(filePath));
556
542
  }
543
+ exports.ScanCacheClassEntrySchema = void 0; exports.ScanCacheSchema = void 0; var TailwindContentItemSchema; exports.TailwindConfigSchema = void 0; exports.RegistryPluginEntrySchema = void 0; exports.RegistryFileSchema = void 0; exports.PackageJsonSchema = void 0;
544
+ var init_configSchemas = __esm({
545
+ "packages/domain/shared/src/configSchemas.ts"() {
546
+ exports.ScanCacheClassEntrySchema = zod.z.object({
547
+ name: zod.z.string().min(1),
548
+ usedIn: zod.z.array(zod.z.string()),
549
+ risk: zod.z.enum(["low", "medium", "high"]).default("low"),
550
+ bundleContribution: zod.z.number().nonnegative().default(0),
551
+ variants: zod.z.array(zod.z.string()).default([])
552
+ });
553
+ exports.ScanCacheSchema = zod.z.object({
554
+ version: zod.z.string().default("1"),
555
+ generatedAt: zod.z.string(),
556
+ root: zod.z.string(),
557
+ classNames: zod.z.array(exports.ScanCacheClassEntrySchema),
558
+ totalFiles: zod.z.number().int().nonnegative(),
559
+ uniqueCount: zod.z.number().int().nonnegative()
560
+ });
561
+ TailwindContentItemSchema = zod.z.union([
562
+ zod.z.string(),
563
+ zod.z.object({
564
+ raw: zod.z.string(),
565
+ extension: zod.z.string().optional()
566
+ }),
567
+ zod.z.object({
568
+ files: zod.z.array(zod.z.string()),
569
+ transform: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
570
+ })
571
+ ]);
572
+ exports.TailwindConfigSchema = zod.z.object({
573
+ content: zod.z.array(TailwindContentItemSchema).optional(),
574
+ theme: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
575
+ plugins: zod.z.array(zod.z.unknown()).optional(),
576
+ darkMode: zod.z.union([zod.z.literal("class"), zod.z.literal("media"), zod.z.literal(false)]).optional(),
577
+ prefix: zod.z.string().optional(),
578
+ safelist: zod.z.array(zod.z.union([zod.z.string(), zod.z.object({ pattern: zod.z.instanceof(RegExp) })])).optional(),
579
+ blocklist: zod.z.array(zod.z.string()).optional()
580
+ }).passthrough();
581
+ exports.RegistryPluginEntrySchema = zod.z.object({
582
+ name: zod.z.string().min(1),
583
+ description: zod.z.string(),
584
+ version: zod.z.string(),
585
+ tags: zod.z.array(zod.z.string()).default([]),
586
+ official: zod.z.boolean().default(false),
587
+ docs: zod.z.string().url().optional(),
588
+ install: zod.z.string().optional(),
589
+ integrity: zod.z.string().optional()
590
+ });
591
+ exports.RegistryFileSchema = zod.z.object({
592
+ version: zod.z.string(),
593
+ official: zod.z.array(exports.RegistryPluginEntrySchema).default([]),
594
+ community: zod.z.array(exports.RegistryPluginEntrySchema).default([])
595
+ });
596
+ exports.PackageJsonSchema = zod.z.object({
597
+ name: zod.z.string(),
598
+ version: zod.z.string(),
599
+ scripts: zod.z.record(zod.z.string(), zod.z.string()).optional(),
600
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
601
+ devDependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
602
+ peerDependencies: zod.z.record(zod.z.string(), zod.z.string()).optional(),
603
+ main: zod.z.string().optional(),
604
+ module: zod.z.string().optional(),
605
+ exports: zod.z.unknown().optional(),
606
+ type: zod.z.enum(["module", "commonjs"]).optional()
607
+ }).passthrough();
608
+ }
609
+ });
557
610
 
558
611
  // packages/domain/shared/src/workerResolver.ts
559
- var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
560
- var NODE_URL = typeof window === "undefined" || typeof document === "undefined" ? "node:url" : null;
561
- var NODE_FS = typeof window === "undefined" || typeof document === "undefined" ? "node:fs" : null;
562
- var NODE_PATH = typeof window === "undefined" || typeof document === "undefined" ? "node:path" : null;
563
612
  function getDirnameFromUrl(importMetaUrl) {
564
613
  if (!importMetaUrl) return "";
565
614
  if (isBrowser2) return "";
@@ -585,11 +634,11 @@ function resolvePath(...segments) {
585
634
  return segments.join("/").replace(/\/+/g, "/");
586
635
  }
587
636
  }
588
- function existsSync(path3) {
637
+ function existsSync(path6) {
589
638
  if (isBrowser2) return false;
590
639
  try {
591
640
  const nodeFs = __require(NODE_FS);
592
- return nodeFs.existsSync(path3);
641
+ return nodeFs.existsSync(path6);
593
642
  } catch {
594
643
  return false;
595
644
  }
@@ -639,6 +688,15 @@ function resolveLoaderPath(loaderBasename, importMetaUrl) {
639
688
  subdirs: [".", "loaders", "lib"]
640
689
  }).path;
641
690
  }
691
+ var isBrowser2, NODE_URL, NODE_FS, NODE_PATH;
692
+ var init_workerResolver = __esm({
693
+ "packages/domain/shared/src/workerResolver.ts"() {
694
+ isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
695
+ NODE_URL = typeof window === "undefined" || typeof document === "undefined" ? "node:url" : null;
696
+ NODE_FS = typeof window === "undefined" || typeof document === "undefined" ? "node:fs" : null;
697
+ NODE_PATH = typeof window === "undefined" || typeof document === "undefined" ? "node:path" : null;
698
+ }
699
+ });
642
700
 
643
701
  // packages/domain/shared/src/codegen.ts
644
702
  function generateComponentCode(opts) {
@@ -796,16 +854,10 @@ function generateBarrelFile(exports$1, dir, opts = {}) {
796
854
  }
797
855
  return lines.join("\n");
798
856
  }
799
- var isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
800
- var _require = typeof __require !== "undefined" ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
801
- var PLATFORM_MAP = {
802
- "linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
803
- "linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
804
- "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
805
- "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
806
- "win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
807
- "win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
808
- };
857
+ var init_codegen = __esm({
858
+ "packages/domain/shared/src/codegen.ts"() {
859
+ }
860
+ });
809
861
  function platformKey() {
810
862
  if (isBrowser3) return "browser";
811
863
  return `${process.platform}-${process.arch}`;
@@ -816,12 +868,12 @@ function resolveNativeBinary(runtimeDir) {
816
868
  if (isBrowser3) {
817
869
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
818
870
  }
819
- if (process.env.TWS_DISABLE_NATIVE === "1") {
871
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
820
872
  return { path: null, source: "not-found", platform, tried: [] };
821
873
  }
822
874
  const envPath = process.env.TW_NATIVE_PATH?.trim();
823
875
  if (envPath) {
824
- if (fs__namespace.existsSync(envPath)) {
876
+ if (fs3__namespace.existsSync(envPath)) {
825
877
  return { path: envPath, source: "env", platform, tried };
826
878
  }
827
879
  tried.push(`env:${envPath} (not found)`);
@@ -830,7 +882,7 @@ function resolveNativeBinary(runtimeDir) {
830
882
  for (const pkg of prebuiltPkgs) {
831
883
  try {
832
884
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
833
- if (fs__namespace.existsSync(candidate)) {
885
+ if (fs3__namespace.existsSync(candidate)) {
834
886
  return { path: candidate, source: "prebuilt", platform, tried };
835
887
  }
836
888
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -847,7 +899,7 @@ function resolveNativeBinary(runtimeDir) {
847
899
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
848
900
  const candidate = path__namespace.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
849
901
  tried.push(`self-bundled:${candidate}`);
850
- if (fs__namespace.existsSync(candidate)) {
902
+ if (fs3__namespace.existsSync(candidate)) {
851
903
  return { path: candidate, source: "prebuilt", platform, tried };
852
904
  }
853
905
  }
@@ -881,7 +933,7 @@ function resolveNativeBinary(runtimeDir) {
881
933
  }
882
934
  for (const candidate of localCandidates) {
883
935
  tried.push(`local:${candidate}`);
884
- if (fs__namespace.existsSync(candidate)) {
936
+ if (fs3__namespace.existsSync(candidate)) {
885
937
  return { path: candidate, source: "local", platform, tried };
886
938
  }
887
939
  }
@@ -901,13 +953,28 @@ function formatNativeNotFoundError(result) {
901
953
  ];
902
954
  return lines.join("\n");
903
955
  }
956
+ var isBrowser3, _require, PLATFORM_MAP;
957
+ var init_native_resolution = __esm({
958
+ "packages/domain/shared/src/native-resolution.ts"() {
959
+ isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
960
+ _require = typeof __require !== "undefined" ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
961
+ PLATFORM_MAP = {
962
+ "linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
963
+ "linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
964
+ "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
965
+ "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
966
+ "win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
967
+ "win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
968
+ };
969
+ }
970
+ });
904
971
 
905
972
  // packages/domain/shared/src/observability.ts
906
973
  function createObservabilityClient(opts = {}) {
907
974
  const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
908
- async function fetchJson(path3) {
975
+ async function fetchJson(path6) {
909
976
  try {
910
- const res = await fetch(`${baseUrl}${path3}`, {
977
+ const res = await fetch(`${baseUrl}${path6}`, {
911
978
  signal: AbortSignal.timeout(timeoutMs)
912
979
  });
913
980
  if (!res.ok) return null;
@@ -934,249 +1001,2729 @@ function createObservabilityClient(opts = {}) {
934
1001
  }
935
1002
  };
936
1003
  }
1004
+ var init_observability = __esm({
1005
+ "packages/domain/shared/src/observability.ts"() {
1006
+ }
1007
+ });
937
1008
 
938
- // packages/domain/shared/src/index.ts
939
- function createLogger(namespace) {
940
- const prefix = `[${namespace}]`;
941
- return {
942
- warn(...args) {
943
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
944
- `);
945
- },
946
- debug(...args) {
947
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
948
- `);
949
- },
950
- error(...args) {
951
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
952
- `);
953
- },
954
- log(...args) {
955
- process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
956
- `);
957
- }
958
- };
959
- }
960
- function createDebugLogger(namespace, label) {
961
- const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`;
962
- return (msg) => {
963
- if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
964
- console.debug(prefix, msg);
965
- }
966
- };
967
- }
968
- function formatIssuePath(path3) {
969
- if (!path3 || path3.length === 0) return "(root)";
970
- return path3.map(
971
- (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
972
- ).join(".");
973
- }
974
- var TwError = class _TwError extends Error {
975
- /** @deprecated Gunakan source */
976
- domain;
977
- source;
978
- code;
979
- originalCause;
980
- constructor(domainOrSource, code, message, cause) {
981
- super(message);
982
- this.name = "TwError";
983
- this.domain = domainOrSource;
984
- this.source = domainOrSource;
985
- this.code = code;
986
- this.originalCause = cause;
987
- if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
988
- }
989
- static fromIo(code, message) {
990
- return new _TwError("io", code, message);
991
- }
992
- static fromCompile(code, message) {
993
- return new _TwError("compile", code, message);
994
- }
995
- static fromRust(err) {
996
- if (err instanceof _TwError) return err;
997
- if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
998
- if (err && typeof err === "object") {
999
- const e = err;
1000
- return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
1009
+ // packages/domain/compiler/src/nativeBridge.ts
1010
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
1011
+ var init_nativeBridge = __esm({
1012
+ "packages/domain/compiler/src/nativeBridge.ts"() {
1013
+ init_src2();
1014
+ _loadNative = (path6) => __require(path6);
1015
+ log = (...args) => {
1016
+ if (process.env.DEBUG?.includes("compiler:native")) {
1017
+ console.log("[compiler:native]", ...args);
1018
+ }
1019
+ };
1020
+ NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
1021
+ nativeBridge = null;
1022
+ bridgeLoadAttempted = false;
1023
+ bridgeLoadError = null;
1024
+ isValidNativeBridge = (mod) => {
1025
+ const m = mod;
1026
+ return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
1027
+ };
1028
+ getNativeBridge = () => {
1029
+ if (nativeBridge) {
1030
+ return nativeBridge;
1031
+ }
1032
+ if (bridgeLoadAttempted) {
1033
+ if (bridgeLoadError) {
1034
+ throw bridgeLoadError;
1035
+ }
1036
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
1037
+ }
1038
+ bridgeLoadAttempted = true;
1039
+ try {
1040
+ const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
1041
+ const result = resolveNativeBinary(runtimeDir);
1042
+ if (result.path && result.path.endsWith(".node")) {
1043
+ try {
1044
+ const binding = _loadNative(result.path);
1045
+ if (isValidNativeBridge(binding)) {
1046
+ nativeBridge = binding;
1047
+ log("Native bridge loaded successfully from:", result.path);
1048
+ return nativeBridge;
1049
+ }
1050
+ } catch (e) {
1051
+ log("Failed to require native binding:", e);
1052
+ }
1053
+ }
1054
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
1055
+
1056
+ Tried paths: ${result.tried.join("\n")}`);
1057
+ } catch (err) {
1058
+ bridgeLoadError = err instanceof Error ? err : new Error(String(err));
1059
+ log("Failed to load native bridge:", bridgeLoadError.message);
1060
+ throw bridgeLoadError;
1061
+ }
1062
+ };
1063
+ adaptNativeResult = (raw) => {
1064
+ return {
1065
+ code: raw.code ?? "",
1066
+ classes: raw.classes ?? [],
1067
+ changed: raw.changed ?? false,
1068
+ rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
1069
+ metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
1070
+ };
1071
+ };
1072
+ if (typeof process !== "undefined" && !bridgeLoadAttempted) {
1073
+ try {
1074
+ getNativeBridge();
1075
+ } catch {
1076
+ }
1001
1077
  }
1002
- return new _TwError("rust", "RUST_ERROR", String(err), err);
1003
- }
1004
- /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
1005
- static fromZod(err) {
1006
- const first = err.issues?.[0] ?? err.errors?.[0];
1007
- const path3 = formatIssuePath(first?.path);
1008
- const message = first ? `${path3}: ${first.message}` : "Schema validation failed";
1009
- return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
1010
- }
1011
- static wrap(source, code, err) {
1012
- if (err instanceof _TwError) return err;
1013
- if (err instanceof Error) return new _TwError(source, code, err.message, err);
1014
- return new _TwError(source, code, String(err), err);
1015
1078
  }
1016
- toString() {
1017
- return `TwError [${this.source}:${this.code}] ${this.message}`;
1079
+ });
1080
+
1081
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
1082
+ async function generateCssNative(classes, options) {
1083
+ const { theme } = options;
1084
+ const native = getNativeBridge();
1085
+ if (!native?.generateCssNative) {
1086
+ throw new Error(
1087
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
1088
+ );
1018
1089
  }
1019
- toJSON() {
1020
- return { name: this.name, source: this.source, code: this.code, message: this.message };
1090
+ const themeJson = JSON.stringify(theme);
1091
+ const css = native.generateCssNative(classes, themeJson);
1092
+ return css;
1093
+ }
1094
+ function clearThemeCache() {
1095
+ try {
1096
+ const native = getNativeBridge();
1097
+ if (!native?.clearThemeCache) {
1098
+ return;
1099
+ }
1100
+ native.clearThemeCache();
1101
+ } catch {
1021
1102
  }
1022
- toCliMessage() {
1023
- return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
1103
+ }
1104
+ var init_cssGeneratorNative = __esm({
1105
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
1106
+ init_nativeBridge();
1024
1107
  }
1025
- };
1026
- function wrapUnknownError(domain, code, error) {
1027
- return TwError.wrap(domain, code, error);
1108
+ });
1109
+
1110
+ // packages/domain/compiler/src/compiler/compilationNative.ts
1111
+ function compileCssNative2(classes, prefix) {
1112
+ const native = getNativeBridge();
1113
+ if (!native?.compileCss) throw new Error("compileCss not available");
1114
+ return native.compileCss(classes, prefix);
1028
1115
  }
1029
- function isTwError(err) {
1030
- return err instanceof TwError;
1116
+ function compileCssLightning(classes) {
1117
+ const native = getNativeBridge();
1118
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
1119
+ return native.compileCssLightning(classes);
1031
1120
  }
1032
- function loadNativeBinding(options) {
1033
- const { runtimeDir, candidates, isValid } = options;
1034
- const loadErrors = [];
1035
- for (const candidate of candidates) {
1036
- const candidatePath = path__namespace.default.resolve(runtimeDir, candidate);
1037
- try {
1038
- if (!fs__namespace.default.existsSync(candidatePath) && !fs__namespace.default.existsSync(candidatePath + ".node")) {
1039
- continue;
1040
- }
1041
- const mod = requireNativeModule(candidatePath);
1042
- if (mod && isValid(mod)) {
1043
- return { binding: mod, loadErrors, loadedPath: candidatePath };
1044
- }
1045
- loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
1046
- } catch (e) {
1047
- loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
1048
- }
1049
- }
1050
- return { binding: null, loadErrors };
1121
+ function extractTwStateConfigsNative(source, filename) {
1122
+ const native = getNativeBridge();
1123
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
1124
+ return native.extractTwStateConfigs(source, filename);
1051
1125
  }
1052
- var _require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
1053
- function requireNativeModule(p) {
1054
- return _require2(p);
1126
+ function generateStaticStateCssNative(inputs, resolvedCss) {
1127
+ const native = getNativeBridge();
1128
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
1129
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
1055
1130
  }
1056
- function resolveNativeBindingCandidates(options) {
1057
- const {
1058
- envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
1059
- includeDefaultCandidates = true,
1060
- enforceNodeExtensionForEnvPath = false
1061
- } = options;
1062
- const runtimeDir = options.runtimeDir || process.cwd();
1063
- const candidates = [];
1064
- for (const envVar of envVarNames) {
1065
- const envPath = process.env[envVar];
1066
- if (envPath) {
1067
- candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
1068
- }
1069
- }
1070
- if (!includeDefaultCandidates) return candidates;
1071
- if (fs__namespace.default.existsSync(runtimeDir)) {
1072
- try {
1073
- for (const entry of fs__namespace.default.readdirSync(runtimeDir)) {
1074
- if (entry.endsWith(".node")) candidates.push(entry);
1075
- }
1076
- } catch {
1077
- }
1131
+ function extractAndGenerateStateCssNative(source, filename) {
1132
+ const native = getNativeBridge();
1133
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
1134
+ return native.extractAndGenerateStateCss(source, filename);
1135
+ }
1136
+ function layoutClassesToCss(classes) {
1137
+ const native = getNativeBridge();
1138
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
1139
+ return native.layoutClassesToCss(classes);
1140
+ }
1141
+ function hashContent(input, algorithm = "sha256", length = 8) {
1142
+ const native = getNativeBridge();
1143
+ if (!native?.hashContent) throw new Error("hashContent not available");
1144
+ return native.hashContent(input, algorithm, length);
1145
+ }
1146
+ function extractTwContainerConfigs(source) {
1147
+ const native = getNativeBridge();
1148
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
1149
+ return native.extractTwContainerConfigs(source);
1150
+ }
1151
+ function parseAtomicClass(twClass) {
1152
+ const native = getNativeBridge();
1153
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
1154
+ return native.parseAtomicClass(twClass);
1155
+ }
1156
+ function generateAtomicCss(rulesJson) {
1157
+ const native = getNativeBridge();
1158
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
1159
+ return native.generateAtomicCss(rulesJson);
1160
+ }
1161
+ function toAtomicClasses(twClasses) {
1162
+ const native = getNativeBridge();
1163
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
1164
+ return native.toAtomicClasses(twClasses);
1165
+ }
1166
+ function clearAtomicRegistry() {
1167
+ const native = getNativeBridge();
1168
+ if (!native?.clearAtomicRegistry) return;
1169
+ native.clearAtomicRegistry();
1170
+ }
1171
+ function atomicRegistrySize() {
1172
+ const native = getNativeBridge();
1173
+ if (!native?.atomicRegistrySize) return 0;
1174
+ return native.atomicRegistrySize();
1175
+ }
1176
+ var init_compilationNative = __esm({
1177
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
1178
+ init_nativeBridge();
1078
1179
  }
1079
- const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
1080
- const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
1081
- for (const bin of BINARY_NAMES) {
1082
- candidates.push(path__namespace.default.resolve(runtimeDir, `${bin}.node`));
1083
- candidates.push(path__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
1084
- candidates.push(path__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
1085
- candidates.push(path__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
1086
- candidates.push(path__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
1087
- candidates.push(path__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
1088
- candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
1089
- candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
1090
- candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
1180
+ });
1181
+
1182
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
1183
+ function compileClass(input) {
1184
+ const native = getNativeBridge();
1185
+ if (!native?.compile_class) throw new Error("compile_class not available");
1186
+ const resultJson = native.compile_class(input);
1187
+ try {
1188
+ return JSON.parse(resultJson);
1189
+ } catch {
1190
+ return {
1191
+ selector: "",
1192
+ declarations: "",
1193
+ properties: [],
1194
+ specificity: 0
1195
+ };
1091
1196
  }
1092
- return Array.from(new Set(candidates));
1093
1197
  }
1094
- function resolveRuntimeDir(dir, importMetaUrl) {
1095
- if (dir) return path__namespace.default.resolve(dir);
1198
+ function compileClasses(inputs) {
1199
+ const native = getNativeBridge();
1200
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
1201
+ const resultJson = native.compile_classes(inputs);
1096
1202
  try {
1097
- return path__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
1203
+ return JSON.parse(resultJson);
1098
1204
  } catch {
1099
- return process.cwd();
1205
+ return {
1206
+ css: "",
1207
+ resolved_classes: [],
1208
+ unknown_classes: [],
1209
+ size_bytes: 0,
1210
+ duration_ms: 0
1211
+ };
1100
1212
  }
1101
1213
  }
1102
- function hashContent(content, algorithm = "md5", length) {
1103
- const hash = crypto.createHash(algorithm).update(content).digest("hex");
1104
- return length ? hash.slice(0, length) : hash;
1214
+ function compileToCss(input, minify) {
1215
+ const native = getNativeBridge();
1216
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
1217
+ return native.compile_to_css(input, minify ?? false);
1105
1218
  }
1106
- function formatErrorMessage(error) {
1107
- if (error instanceof TwError) return error.toString();
1108
- if (error instanceof Error) return error.message;
1109
- return String(error);
1219
+ function compileToCssBatch(inputs, minify) {
1220
+ const native = getNativeBridge();
1221
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
1222
+ return native.compile_to_css_batch(inputs, minify ?? false);
1110
1223
  }
1111
- var LRUCache = class {
1112
- capacity;
1113
- cache;
1114
- constructor(capacity) {
1115
- this.capacity = capacity;
1116
- this.cache = /* @__PURE__ */ new Map();
1117
- }
1118
- get(key) {
1119
- if (!this.cache.has(key)) return void 0;
1120
- const value = this.cache.get(key);
1121
- this.cache.delete(key);
1122
- this.cache.set(key, value);
1123
- return value;
1124
- }
1125
- set(key, value) {
1126
- if (this.cache.has(key)) {
1127
- this.cache.delete(key);
1128
- } else if (this.cache.size >= this.capacity) {
1129
- const firstKey = this.cache.keys().next().value;
1130
- if (firstKey !== void 0) {
1131
- this.cache.delete(firstKey);
1132
- }
1133
- }
1134
- this.cache.set(key, value);
1135
- }
1136
- delete(key) {
1137
- return this.cache.delete(key);
1138
- }
1139
- has(key) {
1140
- return this.cache.has(key);
1224
+ function minifyCss(css) {
1225
+ const native = getNativeBridge();
1226
+ if (!native?.minify_css) throw new Error("minify_css not available");
1227
+ return native.minify_css(css);
1228
+ }
1229
+ function compileAnimation(animationName, from, to) {
1230
+ const native = getNativeBridge();
1231
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
1232
+ const resultJson = native.compile_animation(animationName, from, to);
1233
+ try {
1234
+ return JSON.parse(resultJson);
1235
+ } catch {
1236
+ return {
1237
+ animation_id: "",
1238
+ keyframes_css: "",
1239
+ animation_rule: "",
1240
+ duration_ms: 0
1241
+ };
1141
1242
  }
1142
- clear() {
1143
- this.cache.clear();
1243
+ }
1244
+ function compileKeyframes(name, stopsJson) {
1245
+ const native = getNativeBridge();
1246
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
1247
+ const resultJson = native.compile_keyframes(name, stopsJson);
1248
+ try {
1249
+ return JSON.parse(resultJson);
1250
+ } catch {
1251
+ return {
1252
+ animation_id: "",
1253
+ keyframes_css: "",
1254
+ animation_rule: "",
1255
+ duration_ms: 0
1256
+ };
1144
1257
  }
1145
- entries() {
1146
- return this.cache.entries();
1258
+ }
1259
+ function compileTheme(tokensJson, themeName, prefix) {
1260
+ const native = getNativeBridge();
1261
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
1262
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
1263
+ try {
1264
+ return JSON.parse(resultJson);
1265
+ } catch {
1266
+ return {
1267
+ selector: ":root",
1268
+ variables: [],
1269
+ variables_css: "",
1270
+ theme_name: themeName
1271
+ };
1147
1272
  }
1148
- get size() {
1149
- return this.cache.size;
1273
+ }
1274
+ function twMerge(classString) {
1275
+ const native = getNativeBridge();
1276
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
1277
+ return native.tw_merge(classString);
1278
+ }
1279
+ function twMergeMany(classStrings) {
1280
+ const native = getNativeBridge();
1281
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
1282
+ return native.tw_merge_many(classStrings);
1283
+ }
1284
+ function twMergeWithSeparator(classString, options) {
1285
+ const native = getNativeBridge();
1286
+ if (!native?.tw_merge_with_separator)
1287
+ throw new Error("tw_merge_with_separator not available");
1288
+ const opts = {
1289
+ separator: options.separator,
1290
+ debug: options.debug
1291
+ };
1292
+ return native.tw_merge_with_separator(classString, opts);
1293
+ }
1294
+ function twMergeManyWithSeparator(classStrings, options) {
1295
+ const native = getNativeBridge();
1296
+ if (!native?.tw_merge_many_with_separator)
1297
+ throw new Error("tw_merge_many_with_separator not available");
1298
+ const opts = {
1299
+ separator: options.separator,
1300
+ debug: options.debug
1301
+ };
1302
+ return native.tw_merge_many_with_separator(classStrings, opts);
1303
+ }
1304
+ function twMergeRaw(classLists) {
1305
+ const native = getNativeBridge();
1306
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
1307
+ return native.tw_merge_raw(classLists);
1308
+ }
1309
+ var init_cssCompilationNative = __esm({
1310
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
1311
+ init_nativeBridge();
1150
1312
  }
1151
- };
1313
+ });
1314
+
1315
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
1316
+ function idRegistryCreate() {
1317
+ const native = getNativeBridge();
1318
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
1319
+ return native.id_registry_create();
1320
+ }
1321
+ function idRegistryGenerate(handle, name) {
1322
+ const native = getNativeBridge();
1323
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
1324
+ return native.id_registry_generate(handle, name);
1325
+ }
1326
+ function idRegistryLookup(handle, name) {
1327
+ const native = getNativeBridge();
1328
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
1329
+ return native.id_registry_lookup(handle, name);
1330
+ }
1331
+ function idRegistryNext(handle) {
1332
+ const native = getNativeBridge();
1333
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
1334
+ return native.id_registry_next(handle);
1335
+ }
1336
+ function idRegistryDestroy(handle) {
1337
+ const native = getNativeBridge();
1338
+ if (!native?.id_registry_destroy) return;
1339
+ native.id_registry_destroy(handle);
1340
+ }
1341
+ function idRegistryReset(handle) {
1342
+ const native = getNativeBridge();
1343
+ if (!native?.id_registry_reset) return;
1344
+ native.id_registry_reset(handle);
1345
+ }
1346
+ function idRegistrySnapshot(handle) {
1347
+ const native = getNativeBridge();
1348
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
1349
+ const snapshotJson = native.id_registry_snapshot(handle);
1350
+ try {
1351
+ return JSON.parse(snapshotJson);
1352
+ } catch {
1353
+ return {
1354
+ handle,
1355
+ next_id: 0,
1356
+ entries: [],
1357
+ total_entries: 0
1358
+ };
1359
+ }
1360
+ }
1361
+ function idRegistryActiveCount() {
1362
+ const native = getNativeBridge();
1363
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
1364
+ return native.id_registry_active_count();
1365
+ }
1366
+ function registerPropertyName(propertyName) {
1367
+ const native = getNativeBridge();
1368
+ if (!native?.register_property_name)
1369
+ throw new Error("register_property_name not available");
1370
+ return native.register_property_name(propertyName);
1371
+ }
1372
+ function registerValueName(valueName) {
1373
+ const native = getNativeBridge();
1374
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
1375
+ return native.register_value_name(valueName);
1376
+ }
1377
+ function propertyIdToString(propertyId) {
1378
+ const native = getNativeBridge();
1379
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
1380
+ return native.property_id_to_string(propertyId);
1381
+ }
1382
+ function valueIdToString(valueId) {
1383
+ const native = getNativeBridge();
1384
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
1385
+ return native.value_id_to_string(valueId);
1386
+ }
1387
+ function reverseLookupProperty(propertyId) {
1388
+ const native = getNativeBridge();
1389
+ if (!native?.reverse_lookup_property)
1390
+ throw new Error("reverse_lookup_property not available");
1391
+ return native.reverse_lookup_property(propertyId);
1392
+ }
1393
+ function reverseLookupValue(valueId) {
1394
+ const native = getNativeBridge();
1395
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
1396
+ return native.reverse_lookup_value(valueId);
1397
+ }
1398
+ function idRegistryExport(handle) {
1399
+ const native = getNativeBridge();
1400
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
1401
+ return native.id_registry_export(handle);
1402
+ }
1403
+ function idRegistryImport(importedData) {
1404
+ const native = getNativeBridge();
1405
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
1406
+ return native.id_registry_import(importedData);
1407
+ }
1408
+ var init_idRegistryNative = __esm({
1409
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
1410
+ init_nativeBridge();
1411
+ }
1412
+ });
1413
+
1414
+ // packages/domain/compiler/src/compiler/streamingNative.ts
1415
+ function processFileChange(fileChangeJson) {
1416
+ const native = getNativeBridge();
1417
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
1418
+ const resultJson = native.process_file_change(fileChangeJson);
1419
+ try {
1420
+ return JSON.parse(resultJson);
1421
+ } catch {
1422
+ return {
1423
+ file_path: "",
1424
+ status: "error",
1425
+ old_classes: [],
1426
+ new_classes: [],
1427
+ added_classes: [],
1428
+ removed_classes: [],
1429
+ changed: false,
1430
+ fingerprint: "",
1431
+ error: "Failed to parse result"
1432
+ };
1433
+ }
1434
+ }
1435
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
1436
+ const native = getNativeBridge();
1437
+ if (!native?.compute_incremental_diff)
1438
+ throw new Error("compute_incremental_diff not available");
1439
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
1440
+ try {
1441
+ return JSON.parse(resultJson);
1442
+ } catch {
1443
+ return {
1444
+ is_changed: false,
1445
+ changes_count: 0,
1446
+ diff: {
1447
+ added_files: [],
1448
+ removed_files: [],
1449
+ modified_files: [],
1450
+ added_classes: [],
1451
+ removed_classes: [],
1452
+ total_changes: 0
1453
+ },
1454
+ processing_time_ms: 0
1455
+ };
1456
+ }
1457
+ }
1458
+ function createFingerprint(filePath, fileContent) {
1459
+ const native = getNativeBridge();
1460
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
1461
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
1462
+ try {
1463
+ return JSON.parse(fingerprintJson);
1464
+ } catch {
1465
+ return {
1466
+ file_path: filePath,
1467
+ content_hash: "",
1468
+ size_bytes: fileContent.length,
1469
+ mtime_ms: Date.now(),
1470
+ class_hash: "",
1471
+ signature: ""
1472
+ };
1473
+ }
1474
+ }
1475
+ function injectStateHash(css, stateHash) {
1476
+ const native = getNativeBridge();
1477
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
1478
+ const resultJson = native.inject_state_hash(css, stateHash);
1479
+ try {
1480
+ return JSON.parse(resultJson);
1481
+ } catch {
1482
+ return {
1483
+ injected: false,
1484
+ state_hash: stateHash,
1485
+ affected_files: 0,
1486
+ total_injected_bytes: 0
1487
+ };
1488
+ }
1489
+ }
1490
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
1491
+ const native = getNativeBridge();
1492
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
1493
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
1494
+ try {
1495
+ return JSON.parse(resultJson);
1496
+ } catch {
1497
+ return {
1498
+ entries_before: 0,
1499
+ entries_after: 0,
1500
+ entries_removed: 0,
1501
+ freed_bytes: 0
1502
+ };
1503
+ }
1504
+ }
1505
+ function rebuildWorkspaceResult(rootDir, extensions) {
1506
+ const native = getNativeBridge();
1507
+ if (!native?.rebuild_workspace_result)
1508
+ throw new Error("rebuild_workspace_result not available");
1509
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
1510
+ try {
1511
+ return JSON.parse(resultJson);
1512
+ } catch {
1513
+ return {
1514
+ total_files_scanned: 0,
1515
+ total_classes_found: 0,
1516
+ unique_classes: 0,
1517
+ build_time_ms: 0,
1518
+ files_with_changes: 0
1519
+ };
1520
+ }
1521
+ }
1522
+ function scanFileNative(filePath, fileContent) {
1523
+ const native = getNativeBridge();
1524
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
1525
+ const resultJson = native.scan_file_native(filePath, fileContent);
1526
+ try {
1527
+ return JSON.parse(resultJson);
1528
+ } catch {
1529
+ return {
1530
+ file: filePath,
1531
+ classes: [],
1532
+ added_classes: [],
1533
+ removed_classes: [],
1534
+ changed: false
1535
+ };
1536
+ }
1537
+ }
1538
+ function scanFilesBatchNative(filesJson) {
1539
+ const native = getNativeBridge();
1540
+ if (!native?.scan_files_batch_native)
1541
+ throw new Error("scan_files_batch_native not available");
1542
+ const resultJson = native.scan_files_batch_native(filesJson);
1543
+ try {
1544
+ return JSON.parse(resultJson);
1545
+ } catch {
1546
+ return [];
1547
+ }
1548
+ }
1549
+ var init_streamingNative = __esm({
1550
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
1551
+ init_nativeBridge();
1552
+ }
1553
+ });
1554
+
1555
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
1556
+ var tailwindEngine_exports = {};
1557
+ __export(tailwindEngine_exports, {
1558
+ clearCache: () => clearCache,
1559
+ getCacheStats: () => getCacheStats,
1560
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
1561
+ runCssPipeline: () => runCssPipeline,
1562
+ runCssPipelineSync: () => runCssPipelineSync
1563
+ });
1564
+ function _getCacheKey(classes, minify, cssEntry, root) {
1565
+ const sorted = [...classes].sort().join(",");
1566
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
1567
+ return `${sorted}|${flags}`;
1568
+ }
1569
+ function _evictOldestIfNeeded() {
1570
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
1571
+ const firstKey = _cssCache.keys().next().value;
1572
+ if (firstKey !== void 0) {
1573
+ _cssCache.delete(firstKey);
1574
+ }
1575
+ }
1576
+ }
1577
+ function getCacheStats() {
1578
+ const total = _cacheHits + _cacheMisses;
1579
+ return {
1580
+ hits: _cacheHits,
1581
+ misses: _cacheMisses,
1582
+ hitRate: total > 0 ? _cacheHits / total : 0,
1583
+ size: _cssCache.size,
1584
+ maxSize: MAX_CACHE_SIZE
1585
+ };
1586
+ }
1587
+ function clearCache() {
1588
+ _cssCache.clear();
1589
+ _cacheHits = 0;
1590
+ _cacheMisses = 0;
1591
+ }
1592
+ function getThemeConfig() {
1593
+ return {
1594
+ colors: {
1595
+ slate: {
1596
+ "50": "#f8fafc",
1597
+ "100": "#f1f5f9",
1598
+ "200": "#e2e8f0",
1599
+ "300": "#cbd5e1",
1600
+ "400": "#94a3b8",
1601
+ "500": "#64748b",
1602
+ "600": "#475569",
1603
+ "700": "#334155",
1604
+ "800": "#1e293b",
1605
+ "900": "#0f172a"
1606
+ },
1607
+ gray: {
1608
+ "50": "#f9fafb",
1609
+ "100": "#f3f4f6",
1610
+ "200": "#e5e7eb",
1611
+ "300": "#d1d5db",
1612
+ "400": "#9ca3af",
1613
+ "500": "#6b7280",
1614
+ "600": "#4b5563",
1615
+ "700": "#374151",
1616
+ "800": "#1f2937",
1617
+ "900": "#111827"
1618
+ },
1619
+ white: "#ffffff",
1620
+ black: "#000000",
1621
+ red: {
1622
+ "500": "#ef4444",
1623
+ "600": "#dc2626"
1624
+ },
1625
+ blue: {
1626
+ "500": "#3b82f6",
1627
+ "600": "#1e40af"
1628
+ }
1629
+ },
1630
+ spacing: {
1631
+ "0": "0px",
1632
+ "1": "0.25rem",
1633
+ "2": "0.5rem",
1634
+ "3": "0.75rem",
1635
+ "4": "1rem",
1636
+ "5": "1.25rem",
1637
+ "6": "1.5rem",
1638
+ "8": "2rem",
1639
+ "10": "2.5rem",
1640
+ "12": "3rem",
1641
+ "16": "4rem",
1642
+ "20": "5rem",
1643
+ "24": "6rem"
1644
+ },
1645
+ breakpoints: {
1646
+ "sm": "640px",
1647
+ "md": "768px",
1648
+ "lg": "1024px",
1649
+ "xl": "1280px",
1650
+ "2xl": "1536px"
1651
+ }
1652
+ };
1653
+ }
1654
+ function postProcessWithLightning(rawCss) {
1655
+ if (!rawCss) return "";
1656
+ const native = getNativeBridge();
1657
+ if (!native?.processTailwindCssLightning) {
1658
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1659
+ }
1660
+ const result = native.processTailwindCssLightning(rawCss);
1661
+ if (!result?.css) {
1662
+ throw new Error("FATAL: processTailwindCssLightning returned null");
1663
+ }
1664
+ return result.css;
1665
+ }
1666
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1667
+ const filtered = classes.filter(Boolean);
1668
+ const uniqueMap = /* @__PURE__ */ new Map();
1669
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
1670
+ const unique = Array.from(uniqueMap.values());
1671
+ if (unique.length === 0) {
1672
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1673
+ }
1674
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
1675
+ const cached = _cssCache.get(cacheKey);
1676
+ if (cached) {
1677
+ _cacheHits++;
1678
+ if (process.env.DEBUG?.includes("compiler")) {
1679
+ console.log(
1680
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
1681
+ );
1682
+ }
1683
+ return cached;
1684
+ }
1685
+ _cacheMisses++;
1686
+ let rawCss;
1687
+ let usedRustCompiler = false;
1688
+ const theme = getThemeConfig();
1689
+ rawCss = await generateCssNative(unique, { theme });
1690
+ usedRustCompiler = true;
1691
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
1692
+ if (process.env.DEBUG?.includes("compiler")) {
1693
+ console.log(
1694
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1695
+ `Size: ${finalCss.length} bytes`
1696
+ );
1697
+ }
1698
+ const result = {
1699
+ css: finalCss,
1700
+ classes: unique,
1701
+ sizeBytes: finalCss.length,
1702
+ optimized: minify
1703
+ };
1704
+ _evictOldestIfNeeded();
1705
+ _cssCache.set(cacheKey, result);
1706
+ return result;
1707
+ }
1708
+ function runCssPipelineSync(_classes) {
1709
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1710
+ }
1711
+ function processTailwindCssWithTargets(css, targets) {
1712
+ const native = getNativeBridge();
1713
+ if (!native?.processTailwindCssWithTargets) {
1714
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
1715
+ }
1716
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
1717
+ if (!result?.css) {
1718
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
1719
+ }
1720
+ return result.css;
1721
+ }
1722
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
1723
+ var init_tailwindEngine = __esm({
1724
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
1725
+ init_nativeBridge();
1726
+ init_cssGeneratorNative();
1727
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
1728
+ _cssCache = /* @__PURE__ */ new Map();
1729
+ _cacheHits = 0;
1730
+ _cacheMisses = 0;
1731
+ MAX_CACHE_SIZE = 100;
1732
+ }
1733
+ });
1734
+
1735
+ // packages/domain/compiler/src/compiler/index.ts
1736
+ var init_compiler = __esm({
1737
+ "packages/domain/compiler/src/compiler/index.ts"() {
1738
+ init_cssGeneratorNative();
1739
+ init_compilationNative();
1740
+ init_cssCompilationNative();
1741
+ init_idRegistryNative();
1742
+ init_streamingNative();
1743
+ }
1744
+ });
1745
+
1746
+ // packages/domain/compiler/src/parser/index.ts
1747
+ var parser_exports = {};
1748
+ __export(parser_exports, {
1749
+ astExtractClasses: () => astExtractClasses,
1750
+ batchExtractClasses: () => batchExtractClasses,
1751
+ checkAgainstSafelist: () => checkAgainstSafelist,
1752
+ diffClassLists: () => diffClassLists,
1753
+ extractAllClasses: () => extractAllClasses,
1754
+ extractClassesFromSource: () => extractClassesFromSource,
1755
+ extractComponentUsage: () => extractComponentUsage,
1756
+ mergeClassesStatic: () => mergeClassesStatic,
1757
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1758
+ normalizeClasses: () => normalizeClasses,
1759
+ parseClasses: () => parseClasses
1760
+ });
1761
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1762
+ var init_parser = __esm({
1763
+ "packages/domain/compiler/src/parser/index.ts"() {
1764
+ init_nativeBridge();
1765
+ parseClasses = (raw) => {
1766
+ const native = getNativeBridge();
1767
+ if (!native?.parseClasses) {
1768
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1769
+ }
1770
+ return native.parseClasses(raw) || [];
1771
+ };
1772
+ extractAllClasses = (source) => {
1773
+ const native = getNativeBridge();
1774
+ if (!native?.extractAllClasses) {
1775
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1776
+ }
1777
+ return native.extractAllClasses(source) || [];
1778
+ };
1779
+ extractClassesFromSource = (source) => {
1780
+ const native = getNativeBridge();
1781
+ if (!native?.extractClassesFromSource) {
1782
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1783
+ }
1784
+ const result = native.extractClassesFromSource(source);
1785
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1786
+ };
1787
+ astExtractClasses = (source, _filename) => {
1788
+ const native = getNativeBridge();
1789
+ if (!native?.extractClassesFromSource) {
1790
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1791
+ }
1792
+ return native.extractClassesFromSource(source) || [];
1793
+ };
1794
+ normalizeClasses = (raw) => {
1795
+ const result = normalizeAndDedupClasses(raw);
1796
+ return result?.normalized || "";
1797
+ };
1798
+ mergeClassesStatic = (classes) => {
1799
+ const result = normalizeAndDedupClasses(classes);
1800
+ return result?.normalized || "";
1801
+ };
1802
+ normalizeAndDedupClasses = (raw) => {
1803
+ const native = getNativeBridge();
1804
+ if (!native?.normalizeAndDedupClasses) {
1805
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1806
+ }
1807
+ const result = native.normalizeAndDedupClasses(raw);
1808
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1809
+ };
1810
+ extractComponentUsage = (source) => {
1811
+ const native = getNativeBridge();
1812
+ if (!native?.extractComponentUsage) {
1813
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1814
+ }
1815
+ return native.extractComponentUsage(source) || [];
1816
+ };
1817
+ batchExtractClasses = (filePaths) => {
1818
+ const native = getNativeBridge();
1819
+ if (!native?.batchExtractClasses) {
1820
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1821
+ }
1822
+ return native.batchExtractClasses(filePaths) || [];
1823
+ };
1824
+ checkAgainstSafelist = (classes, safelist) => {
1825
+ const native = getNativeBridge();
1826
+ if (!native?.checkAgainstSafelist) {
1827
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1828
+ }
1829
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1830
+ };
1831
+ diffClassLists = (previous, current) => {
1832
+ const native = getNativeBridge();
1833
+ if (!native?.diffClassLists) {
1834
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1835
+ }
1836
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1837
+ };
1838
+ }
1839
+ });
1840
+
1841
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1842
+ function detectDeadCode(scanResultJson, css) {
1843
+ const native = getNativeBridge();
1844
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1845
+ return native.detectDeadCode(scanResultJson, css);
1846
+ }
1847
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1848
+ const native = getNativeBridge();
1849
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1850
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1851
+ }
1852
+ function analyzeClassesNative(filesJson, cwd, flags) {
1853
+ const native = getNativeBridge();
1854
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1855
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1856
+ }
1857
+ function analyzeRscNative(source, filename) {
1858
+ const native = getNativeBridge();
1859
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1860
+ return native.analyzeRsc(source, filename);
1861
+ }
1862
+ function optimizeCssNative(css) {
1863
+ const native = getNativeBridge();
1864
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1865
+ const result = native.processTailwindCssLightning(css);
1866
+ return {
1867
+ css: result.css,
1868
+ originalSize: css.length,
1869
+ optimizedSize: result.size_bytes,
1870
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1871
+ };
1872
+ }
1873
+ function processTailwindCssLightning(css) {
1874
+ const native = getNativeBridge();
1875
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1876
+ return native.processTailwindCssLightning(css);
1877
+ }
1878
+ function eliminateDeadCssNative(css, deadClasses) {
1879
+ const native = getNativeBridge();
1880
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1881
+ return native.eliminateDeadCss(css, deadClasses);
1882
+ }
1883
+ function hoistComponentsNative(source) {
1884
+ const native = getNativeBridge();
1885
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1886
+ return native.hoistComponents(source);
1887
+ }
1888
+ function compileVariantTableNative(configJson) {
1889
+ const native = getNativeBridge();
1890
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1891
+ return native.compileVariantTable(configJson);
1892
+ }
1893
+ function classifyAndSortClassesNative(classes) {
1894
+ const native = getNativeBridge();
1895
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1896
+ return native.classifyAndSortClasses(classes);
1897
+ }
1898
+ function mergeCssDeclarationsNative(cssChunks) {
1899
+ const native = getNativeBridge();
1900
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1901
+ return native.mergeCssDeclarations(cssChunks);
1902
+ }
1903
+ var init_analyzerNative = __esm({
1904
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1905
+ init_nativeBridge();
1906
+ }
1907
+ });
1908
+
1909
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1910
+ function resolveVariants(configJson) {
1911
+ const native = getNativeBridge();
1912
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1913
+ const resultJson = native.resolve_variants(configJson);
1914
+ try {
1915
+ return JSON.parse(resultJson);
1916
+ } catch {
1917
+ return {
1918
+ variants: [],
1919
+ supported: [],
1920
+ deprecated: [],
1921
+ conflicting: []
1922
+ };
1923
+ }
1924
+ }
1925
+ function validateThemeConfig(configJson) {
1926
+ const native = getNativeBridge();
1927
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1928
+ const resultJson = native.validate_variant_config(configJson);
1929
+ try {
1930
+ return JSON.parse(resultJson);
1931
+ } catch {
1932
+ return {
1933
+ is_valid: false,
1934
+ errors: ["Unable to parse configuration"],
1935
+ warnings: [],
1936
+ suggestions: []
1937
+ };
1938
+ }
1939
+ }
1940
+ function resolveCascade(baseThemeJson, overridesJson) {
1941
+ const native = getNativeBridge();
1942
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1943
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1944
+ try {
1945
+ return JSON.parse(resultJson);
1946
+ } catch {
1947
+ return {
1948
+ base_theme: {},
1949
+ user_overrides: {},
1950
+ merged_theme: {},
1951
+ conflict_resolutions: []
1952
+ };
1953
+ }
1954
+ }
1955
+ function resolveClassNames(classNames, themeJson) {
1956
+ const native = getNativeBridge();
1957
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1958
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1959
+ try {
1960
+ return JSON.parse(resultJson);
1961
+ } catch {
1962
+ return [];
1963
+ }
1964
+ }
1965
+ function resolveConflictGroup(groupName, themeJson) {
1966
+ const native = getNativeBridge();
1967
+ if (!native?.resolve_conflict_group)
1968
+ throw new Error("resolve_conflict_group not available");
1969
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1970
+ try {
1971
+ return JSON.parse(resultJson);
1972
+ } catch {
1973
+ return {
1974
+ group_name: groupName,
1975
+ conflicting_classes: [],
1976
+ description: "",
1977
+ resolution_strategy: "last-wins"
1978
+ };
1979
+ }
1980
+ }
1981
+ function resolveThemeValue(keyPath, themeJson) {
1982
+ const native = getNativeBridge();
1983
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1984
+ return native.resolve_theme_value(keyPath, themeJson);
1985
+ }
1986
+ function resolveSimpleVariants(configJson) {
1987
+ const native = getNativeBridge();
1988
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1989
+ const resultJson = native.resolve_simple_variants(configJson);
1990
+ try {
1991
+ return JSON.parse(resultJson);
1992
+ } catch {
1993
+ return [];
1994
+ }
1995
+ }
1996
+ var init_themeResolutionNative = __esm({
1997
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1998
+ init_nativeBridge();
1999
+ }
2000
+ });
2001
+
2002
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
2003
+ function scanWorkspace(root, extensions) {
2004
+ const native = getNativeBridge();
2005
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
2006
+ return native.scan_workspace(root, extensions);
2007
+ }
2008
+ function extractClassesFromSourceNative(source) {
2009
+ const native = getNativeBridge();
2010
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
2011
+ return native.extract_classes_from_source(source);
2012
+ }
2013
+ function batchExtractClassesNative(filePaths) {
2014
+ const native = getNativeBridge();
2015
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
2016
+ return native.batch_extract_classes(filePaths);
2017
+ }
2018
+ function checkAgainstSafelistNative(classes, safelist) {
2019
+ const native = getNativeBridge();
2020
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
2021
+ return native.check_against_safelist(classes, safelist);
2022
+ }
2023
+ function scanFile(filePath) {
2024
+ const native = getNativeBridge();
2025
+ if (!native?.scan_file) throw new Error("scan_file not available");
2026
+ return native.scan_file(filePath);
2027
+ }
2028
+ function collectFiles(root, extensions) {
2029
+ const native = getNativeBridge();
2030
+ if (!native?.collect_files) throw new Error("collect_files not available");
2031
+ return native.collect_files(root, extensions);
2032
+ }
2033
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
2034
+ const native = getNativeBridge();
2035
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
2036
+ return native.walk_and_prefilter_source_files(root, extensions);
2037
+ }
2038
+ function generateSubComponentTypes(root, outputPath) {
2039
+ const native = getNativeBridge();
2040
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
2041
+ return native.generate_sub_component_types(root, outputPath);
2042
+ }
2043
+ var init_scannerNative = __esm({
2044
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
2045
+ init_nativeBridge();
2046
+ }
2047
+ });
2048
+
2049
+ // packages/domain/compiler/src/analyzer/index.ts
2050
+ var init_analyzer = __esm({
2051
+ "packages/domain/compiler/src/analyzer/index.ts"() {
2052
+ init_analyzerNative();
2053
+ init_themeResolutionNative();
2054
+ init_scannerNative();
2055
+ }
2056
+ });
2057
+
2058
+ // packages/domain/compiler/src/cache/cacheNative.ts
2059
+ function getCacheStatistics() {
2060
+ const native = getNativeBridge();
2061
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
2062
+ const statsJson = native.get_cache_statistics();
2063
+ try {
2064
+ return JSON.parse(statsJson);
2065
+ } catch {
2066
+ return {
2067
+ parse_cache: { hits: 0, misses: 0, size: 0 },
2068
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
2069
+ compile_cache: { hits: 0, misses: 0, size: 0 },
2070
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
2071
+ overall_hit_rate: 0,
2072
+ total_memory_bytes: 0
2073
+ };
2074
+ }
2075
+ }
2076
+ function clearAllCaches() {
2077
+ const native = getNativeBridge();
2078
+ if (!native?.clear_all_caches) return;
2079
+ try {
2080
+ native.clear_all_caches();
2081
+ } catch {
2082
+ }
2083
+ }
2084
+ function clearParseCache() {
2085
+ const native = getNativeBridge();
2086
+ if (!native?.clear_parse_cache) return;
2087
+ try {
2088
+ native.clear_parse_cache();
2089
+ } catch {
2090
+ }
2091
+ }
2092
+ function clearResolveCache() {
2093
+ const native = getNativeBridge();
2094
+ if (!native?.clear_resolve_cache) return;
2095
+ try {
2096
+ native.clear_resolve_cache();
2097
+ } catch {
2098
+ }
2099
+ }
2100
+ function clearCompileCache() {
2101
+ const native = getNativeBridge();
2102
+ if (!native?.clear_compile_cache) return;
2103
+ try {
2104
+ native.clear_compile_cache();
2105
+ } catch {
2106
+ }
2107
+ }
2108
+ function clearCssGenCache() {
2109
+ const native = getNativeBridge();
2110
+ if (!native?.clear_css_gen_cache) return;
2111
+ try {
2112
+ native.clear_css_gen_cache();
2113
+ } catch {
2114
+ }
2115
+ }
2116
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
2117
+ const native = getNativeBridge();
2118
+ if (!native?.get_cache_optimization_hints)
2119
+ throw new Error("get_cache_optimization_hints not available");
2120
+ const hintsJson = native.get_cache_optimization_hints(
2121
+ Math.min(100, Math.max(0, hitRatePercent)),
2122
+ Math.max(1, memoryUsedMb)
2123
+ );
2124
+ try {
2125
+ return JSON.parse(hintsJson);
2126
+ } catch {
2127
+ return {
2128
+ current_strategy: "unknown",
2129
+ recommended_strategy: "increase_size",
2130
+ estimated_improvement_percent: 0,
2131
+ suggested_memory_mb: 256,
2132
+ notes: ["Unable to analyze cache statistics"]
2133
+ };
2134
+ }
2135
+ }
2136
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
2137
+ const native = getNativeBridge();
2138
+ if (!native?.estimate_optimal_cache_config_native)
2139
+ throw new Error("estimate_optimal_cache_config_native not available");
2140
+ const configJson = native.estimate_optimal_cache_config_native(
2141
+ Math.max(64, totalBudgetMb),
2142
+ workloadType
2143
+ );
2144
+ try {
2145
+ return JSON.parse(configJson);
2146
+ } catch {
2147
+ return {
2148
+ parse_cache_size: 128,
2149
+ resolve_cache_size: 64,
2150
+ compile_cache_size: 256,
2151
+ css_gen_cache_size: 128,
2152
+ recommended_eviction_policy: "lru",
2153
+ ttl_seconds: 3600,
2154
+ expected_hit_rate_percent: 75
2155
+ };
2156
+ }
2157
+ }
2158
+ function cacheRead(cachePath) {
2159
+ const native = getNativeBridge();
2160
+ if (!native?.cache_read) throw new Error("cache_read not available");
2161
+ const result = native.cache_read(cachePath);
2162
+ try {
2163
+ return JSON.parse(result.entries_json || "[]");
2164
+ } catch {
2165
+ return [];
2166
+ }
2167
+ }
2168
+ function cacheWrite(cachePath, entries) {
2169
+ const native = getNativeBridge();
2170
+ if (!native?.cache_write) throw new Error("cache_write not available");
2171
+ try {
2172
+ const result = native.cache_write(
2173
+ cachePath,
2174
+ entries.map((e) => ({
2175
+ file: e.file,
2176
+ content_hash: e.contentHash,
2177
+ classes: e.classes,
2178
+ mtime_ms: e.mtimeMs,
2179
+ size_bytes: e.sizeBytes
2180
+ }))
2181
+ );
2182
+ return typeof result === "boolean" ? result : result === true;
2183
+ } catch {
2184
+ return false;
2185
+ }
2186
+ }
2187
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
2188
+ const native = getNativeBridge();
2189
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
2190
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
2191
+ }
2192
+ var init_cacheNative = __esm({
2193
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
2194
+ init_nativeBridge();
2195
+ }
2196
+ });
2197
+
2198
+ // packages/domain/compiler/src/cache/index.ts
2199
+ var init_cache = __esm({
2200
+ "packages/domain/compiler/src/cache/index.ts"() {
2201
+ init_cacheNative();
2202
+ }
2203
+ });
2204
+
2205
+ // packages/domain/compiler/src/redis/redisNative.ts
2206
+ function redisPing() {
2207
+ const native = getNativeBridge();
2208
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
2209
+ return native.redis_ping();
2210
+ }
2211
+ function redisGet(key) {
2212
+ const native = getNativeBridge();
2213
+ if (!native?.redis_get) throw new Error("redis_get not available");
2214
+ const result = native.redis_get(key);
2215
+ return result === "nil" ? null : result;
2216
+ }
2217
+ function redisSet(key, value, ttl_seconds) {
2218
+ const native = getNativeBridge();
2219
+ if (!native?.redis_set) throw new Error("redis_set not available");
2220
+ return native.redis_set(key, value, ttl_seconds);
2221
+ }
2222
+ function redisDelete(key) {
2223
+ const native = getNativeBridge();
2224
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
2225
+ return native.redis_delete(key);
2226
+ }
2227
+ function redisExists(key) {
2228
+ const native = getNativeBridge();
2229
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
2230
+ return native.redis_exists(key);
2231
+ }
2232
+ function redisMget(keys) {
2233
+ const native = getNativeBridge();
2234
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
2235
+ const result = native.redis_mget(keys);
2236
+ try {
2237
+ return JSON.parse(result);
2238
+ } catch {
2239
+ return keys.map(() => null);
2240
+ }
2241
+ }
2242
+ function redisMset(pairs) {
2243
+ const native = getNativeBridge();
2244
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
2245
+ return native.redis_mset(pairs);
2246
+ }
2247
+ function redisFlushDb() {
2248
+ const native = getNativeBridge();
2249
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
2250
+ return native.redis_flush_db();
2251
+ }
2252
+ function redisFlushAll() {
2253
+ const native = getNativeBridge();
2254
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
2255
+ return native.redis_flush_all();
2256
+ }
2257
+ function redisPoolConnect(host, port, pool_size) {
2258
+ const native = getNativeBridge();
2259
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
2260
+ return native.redis_pool_connect(host, port, pool_size);
2261
+ }
2262
+ function redisPoolStats() {
2263
+ const native = getNativeBridge();
2264
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
2265
+ const result = native.redis_pool_stats();
2266
+ try {
2267
+ return JSON.parse(result);
2268
+ } catch {
2269
+ return {
2270
+ connected_count: 0,
2271
+ idle_count: 0,
2272
+ waiting_count: 0,
2273
+ total_requests: 0,
2274
+ total_errors: 0
2275
+ };
2276
+ }
2277
+ }
2278
+ function redisPoolReconnect() {
2279
+ const native = getNativeBridge();
2280
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
2281
+ return native.redis_pool_reconnect();
2282
+ }
2283
+ function redisEnableCluster(initial_nodes) {
2284
+ const native = getNativeBridge();
2285
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
2286
+ const result = native.redis_enable_cluster(initial_nodes);
2287
+ try {
2288
+ return JSON.parse(result);
2289
+ } catch {
2290
+ return {
2291
+ enabled: false,
2292
+ cluster_state: "error",
2293
+ nodes: [],
2294
+ slots_assigned: 0,
2295
+ slots_ok: 0,
2296
+ slots_fail: 0
2297
+ };
2298
+ }
2299
+ }
2300
+ function redisDisableCluster() {
2301
+ const native = getNativeBridge();
2302
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
2303
+ return native.redis_disable_cluster();
2304
+ }
2305
+ function redisClusterStatus() {
2306
+ const native = getNativeBridge();
2307
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
2308
+ const result = native.redis_cluster_status();
2309
+ try {
2310
+ return JSON.parse(result);
2311
+ } catch {
2312
+ return {
2313
+ enabled: false,
2314
+ cluster_state: "unknown",
2315
+ nodes: [],
2316
+ slots_assigned: 0,
2317
+ slots_ok: 0,
2318
+ slots_fail: 0
2319
+ };
2320
+ }
2321
+ }
2322
+ function redisSubscribe(channel) {
2323
+ const native = getNativeBridge();
2324
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
2325
+ return native.redis_subscribe(channel);
2326
+ }
2327
+ function redisPublish(channel, message) {
2328
+ const native = getNativeBridge();
2329
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
2330
+ return native.redis_publish(channel, message);
2331
+ }
2332
+ function redisExpirationSet(key, ttl_seconds) {
2333
+ const native = getNativeBridge();
2334
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
2335
+ return native.redis_expiration_set(key, ttl_seconds);
2336
+ }
2337
+ function redisExpirationGet(key) {
2338
+ const native = getNativeBridge();
2339
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
2340
+ const result = native.redis_expiration_get(key);
2341
+ try {
2342
+ return JSON.parse(result);
2343
+ } catch {
2344
+ return {
2345
+ key,
2346
+ ttl_seconds: -1,
2347
+ expiration_timestamp: 0,
2348
+ is_persistent: true
2349
+ };
2350
+ }
2351
+ }
2352
+ function redisInfo() {
2353
+ const native = getNativeBridge();
2354
+ if (!native?.redis_info) throw new Error("redis_info not available");
2355
+ return native.redis_info();
2356
+ }
2357
+ function redisMonitor() {
2358
+ const native = getNativeBridge();
2359
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
2360
+ return native.redis_monitor();
2361
+ }
2362
+ function redisCacheSize() {
2363
+ const native = getNativeBridge();
2364
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
2365
+ return native.redis_cache_size();
2366
+ }
2367
+ function redisCacheKeyCount() {
2368
+ const native = getNativeBridge();
2369
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
2370
+ return native.redis_cache_key_count();
2371
+ }
2372
+ function redisCacheClear() {
2373
+ const native = getNativeBridge();
2374
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
2375
+ return native.redis_cache_clear();
2376
+ }
2377
+ function redisCacheHitRate() {
2378
+ const native = getNativeBridge();
2379
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
2380
+ return native.redis_cache_hit_rate();
2381
+ }
2382
+ function redisEnablePersistence(mode) {
2383
+ const native = getNativeBridge();
2384
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
2385
+ return native.redis_enable_persistence(mode);
2386
+ }
2387
+ function redisDisablePersistence() {
2388
+ const native = getNativeBridge();
2389
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
2390
+ return native.redis_disable_persistence();
2391
+ }
2392
+ function redisSnapshot() {
2393
+ const native = getNativeBridge();
2394
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
2395
+ return native.redis_snapshot();
2396
+ }
2397
+ function redisMemoryStats() {
2398
+ const native = getNativeBridge();
2399
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
2400
+ return native.redis_memory_stats();
2401
+ }
2402
+ function redisOptimizeMemory() {
2403
+ const native = getNativeBridge();
2404
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
2405
+ return native.redis_optimize_memory();
2406
+ }
2407
+ function redisSetEvictionPolicy(policy) {
2408
+ const native = getNativeBridge();
2409
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
2410
+ return native.redis_set_eviction_policy(policy);
2411
+ }
2412
+ function redisGetEvictionPolicy() {
2413
+ const native = getNativeBridge();
2414
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
2415
+ return native.redis_get_eviction_policy();
2416
+ }
2417
+ function redisReplicate(target_host, target_port) {
2418
+ const native = getNativeBridge();
2419
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
2420
+ return native.redis_replicate(target_host, target_port);
2421
+ }
2422
+ function redisReplicationStatus() {
2423
+ const native = getNativeBridge();
2424
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
2425
+ return native.redis_replication_status();
2426
+ }
2427
+ function redisCacheSync(peers) {
2428
+ const native = getNativeBridge();
2429
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
2430
+ return native.redis_cache_sync(peers);
2431
+ }
2432
+ function redisEnableCacheWarming(key_pattern) {
2433
+ const native = getNativeBridge();
2434
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
2435
+ return native.redis_enable_cache_warming(key_pattern);
2436
+ }
2437
+ function redisDisableCacheWarming() {
2438
+ const native = getNativeBridge();
2439
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
2440
+ return native.redis_disable_cache_warming();
2441
+ }
2442
+ function redisDiagnose() {
2443
+ const native = getNativeBridge();
2444
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
2445
+ return native.redis_diagnose();
2446
+ }
2447
+ var init_redisNative = __esm({
2448
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
2449
+ init_nativeBridge();
2450
+ }
2451
+ });
2452
+
2453
+ // packages/domain/compiler/src/redis/index.ts
2454
+ var init_redis = __esm({
2455
+ "packages/domain/compiler/src/redis/index.ts"() {
2456
+ init_redisNative();
2457
+ }
2458
+ });
2459
+
2460
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
2461
+ function startWatch(root_path, patterns) {
2462
+ const native = getNativeBridge();
2463
+ if (!native?.start_watch) throw new Error("start_watch not available");
2464
+ return native.start_watch(root_path, patterns);
2465
+ }
2466
+ function pollWatchEvents(handle, timeout_ms) {
2467
+ const native = getNativeBridge();
2468
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
2469
+ const result = native.poll_watch_events(handle, timeout_ms);
2470
+ try {
2471
+ return JSON.parse(result);
2472
+ } catch {
2473
+ return [];
2474
+ }
2475
+ }
2476
+ function stopWatch(handle) {
2477
+ const native = getNativeBridge();
2478
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
2479
+ return native.stop_watch(handle);
2480
+ }
2481
+ function watchAddPattern(handle, pattern) {
2482
+ const native = getNativeBridge();
2483
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
2484
+ return native.watch_add_pattern(handle, pattern);
2485
+ }
2486
+ function watchRemovePattern(handle, pattern) {
2487
+ const native = getNativeBridge();
2488
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
2489
+ return native.watch_remove_pattern(handle, pattern);
2490
+ }
2491
+ function watchGetActiveHandles() {
2492
+ const native = getNativeBridge();
2493
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
2494
+ const result = native.watch_get_active_handles();
2495
+ try {
2496
+ return JSON.parse(result);
2497
+ } catch {
2498
+ return [];
2499
+ }
2500
+ }
2501
+ function watchClearAll() {
2502
+ const native = getNativeBridge();
2503
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
2504
+ return native.watch_clear_all();
2505
+ }
2506
+ function watchEventTypeToString(event_type_code) {
2507
+ const native = getNativeBridge();
2508
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
2509
+ return native.watch_event_type_to_string(event_type_code);
2510
+ }
2511
+ function isWatchRunning(handle) {
2512
+ const native = getNativeBridge();
2513
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
2514
+ return native.is_watch_running(handle);
2515
+ }
2516
+ function getWatchStats() {
2517
+ const native = getNativeBridge();
2518
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
2519
+ const result = native.get_watch_stats();
2520
+ try {
2521
+ return JSON.parse(result);
2522
+ } catch {
2523
+ return {
2524
+ active_watchers: 0,
2525
+ total_events: 0,
2526
+ events_this_second: 0,
2527
+ average_latency_ms: 0,
2528
+ largest_batch_size: 0
2529
+ };
2530
+ }
2531
+ }
2532
+ function watchPause(handle) {
2533
+ const native = getNativeBridge();
2534
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
2535
+ return native.watch_pause(handle);
2536
+ }
2537
+ function watchResume(handle) {
2538
+ const native = getNativeBridge();
2539
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
2540
+ return native.watch_resume(handle);
2541
+ }
2542
+ function scanCacheOptimizations() {
2543
+ const native = getNativeBridge();
2544
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
2545
+ return native.scan_cache_optimizations();
2546
+ }
2547
+ function getPluginHooks() {
2548
+ const native = getNativeBridge();
2549
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
2550
+ const result = native.get_plugin_hooks();
2551
+ try {
2552
+ return JSON.parse(result);
2553
+ } catch {
2554
+ return [];
2555
+ }
2556
+ }
2557
+ function registerPluginHook(hook_name, handler_id) {
2558
+ const native = getNativeBridge();
2559
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
2560
+ return native.register_plugin_hook(hook_name, handler_id);
2561
+ }
2562
+ function unregisterPluginHook(hook_name, handler_id) {
2563
+ const native = getNativeBridge();
2564
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
2565
+ return native.unregister_plugin_hook(hook_name, handler_id);
2566
+ }
2567
+ function emitPluginHook(hook_name, data_json) {
2568
+ const native = getNativeBridge();
2569
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
2570
+ return native.emit_plugin_hook(hook_name, data_json);
2571
+ }
2572
+ function getCompilationMetrics() {
2573
+ const native = getNativeBridge();
2574
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
2575
+ return native.get_compilation_metrics();
2576
+ }
2577
+ function resetCompilationMetrics() {
2578
+ const native = getNativeBridge();
2579
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
2580
+ return native.reset_compilation_metrics();
2581
+ }
2582
+ function validateCssOutput(css) {
2583
+ const native = getNativeBridge();
2584
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
2585
+ return native.validate_css_output(css);
2586
+ }
2587
+ function getCompilerDiagnostics() {
2588
+ const native = getNativeBridge();
2589
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
2590
+ return native.get_compiler_diagnostics();
2591
+ }
2592
+ var init_watchSystemNative = __esm({
2593
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
2594
+ init_nativeBridge();
2595
+ }
2596
+ });
2597
+
2598
+ // packages/domain/compiler/src/watch/index.ts
2599
+ var init_watch = __esm({
2600
+ "packages/domain/compiler/src/watch/index.ts"() {
2601
+ init_watchSystemNative();
2602
+ }
2603
+ });
2604
+ function _layoutClassesToCss(classes) {
2605
+ const native = getNativeBridge();
2606
+ if (!native?.layoutClassesToCss) {
2607
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
2608
+ }
2609
+ return native.layoutClassesToCss(classes);
2610
+ }
2611
+ function _hashContainer(tag, containerJson, name) {
2612
+ const sortedKey = tag + (name ?? "") + containerJson;
2613
+ const native = getNativeBridge();
2614
+ if (!native?.hashContent) {
2615
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
2616
+ }
2617
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
2618
+ }
2619
+ function extractContainerCssFromSource(source) {
2620
+ const native = getNativeBridge();
2621
+ if (!native?.extractTwContainerConfigs) {
2622
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
2623
+ }
2624
+ const configs = native.extractTwContainerConfigs(source);
2625
+ const rules = [];
2626
+ for (const cfg of configs) {
2627
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
2628
+ for (const { key, classes } of cfg.breakpoints) {
2629
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
2630
+ const css = _layoutClassesToCss(classes);
2631
+ if (!css) continue;
2632
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
2633
+ rules.push(`${query}{.${id}{${css}}}`);
2634
+ }
2635
+ }
2636
+ return rules.join("\n");
2637
+ }
2638
+ 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;
2639
+ var init_src = __esm({
2640
+ "packages/domain/compiler/src/index.ts"() {
2641
+ init_nativeBridge();
2642
+ init_compiler();
2643
+ init_parser();
2644
+ init_analyzer();
2645
+ init_cache();
2646
+ init_redis();
2647
+ init_watch();
2648
+ transformSource = (source, opts) => {
2649
+ const native = getNativeBridge();
2650
+ if (!native?.transformSource) {
2651
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2652
+ }
2653
+ const result = native.transformSource(source, opts);
2654
+ if (!result) {
2655
+ throw new Error("FATAL: transformSource returned null");
2656
+ }
2657
+ return result;
2658
+ };
2659
+ hasTwUsage = (source) => {
2660
+ const native = getNativeBridge();
2661
+ if (!native?.hasTwUsage) {
2662
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
2663
+ }
2664
+ return native.hasTwUsage(source);
2665
+ };
2666
+ isAlreadyTransformed = (source) => {
2667
+ const native = getNativeBridge();
2668
+ if (!native?.isAlreadyTransformed) {
2669
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
2670
+ }
2671
+ return native.isAlreadyTransformed(source);
2672
+ };
2673
+ shouldProcess = (source) => {
2674
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
2675
+ };
2676
+ compileCssFromClasses = (classes, prefix) => {
2677
+ const native = getNativeBridge();
2678
+ if (!native?.transformSource) {
2679
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2680
+ }
2681
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
2682
+ if (!result) {
2683
+ throw new Error("FATAL: transformSource returned null");
2684
+ }
2685
+ return result;
2686
+ };
2687
+ buildStyleTag = (classes) => {
2688
+ const result = compileCssFromClasses(classes);
2689
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2690
+ };
2691
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2692
+ try {
2693
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2694
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2695
+ return result.css;
2696
+ } catch {
2697
+ const native = getNativeBridge();
2698
+ if (!native?.transformSource) {
2699
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2700
+ }
2701
+ const result = native.transformSource(classes.join(" "), {});
2702
+ return result?.code || "";
2703
+ }
2704
+ };
2705
+ eliminateDeadCss = (css, deadClasses) => {
2706
+ const native = getNativeBridge();
2707
+ if (!native?.eliminateDeadCss) {
2708
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
2709
+ }
2710
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
2711
+ };
2712
+ findDeadVariants = (variantConfig, usage) => {
2713
+ const unused = [];
2714
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
2715
+ for (const component of configs) {
2716
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
2717
+ const variants = component.variants;
2718
+ for (const [key, values] of Object.entries(variants)) {
2719
+ for (const [value] of Object.entries(values)) {
2720
+ if (!componentUsage.has(`${key}:${value}`)) {
2721
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
2722
+ }
2723
+ }
2724
+ }
2725
+ }
2726
+ return { unusedCount: unused.length, unused };
2727
+ };
2728
+ runElimination = (css, scanResult) => {
2729
+ const native = getNativeBridge();
2730
+ if (!native?.detectDeadCode) {
2731
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
2732
+ }
2733
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2734
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2735
+ };
2736
+ scanProjectUsage = (dirs, cwd) => {
2737
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2738
+ const files = dirs.map((dir) => path__namespace.default.resolve(cwd, dir));
2739
+ const results = batchExtractClasses2(files) || [];
2740
+ const combined = {};
2741
+ for (const result of results) {
2742
+ if (result.ok && result.classes) {
2743
+ for (const cls of result.classes) {
2744
+ if (!combined[cls]) combined[cls] = {};
2745
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
2746
+ }
2747
+ }
2748
+ }
2749
+ return combined;
2750
+ };
2751
+ generateSafelist = (scanDirs, outputPath, cwd) => {
2752
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
2753
+ const allClasses = Object.keys(classes).sort();
2754
+ if (outputPath) {
2755
+ fs3__namespace.default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
2756
+ }
2757
+ return allClasses;
2758
+ };
2759
+ loadSafelist = (safelistPath) => {
2760
+ try {
2761
+ const content = fs3__namespace.default.readFileSync(safelistPath, "utf-8");
2762
+ return JSON.parse(content);
2763
+ } catch {
2764
+ return [];
2765
+ }
2766
+ };
2767
+ loadTailwindConfig = (cwd = process.cwd()) => {
2768
+ const configFiles = [
2769
+ "tailwind.config.ts",
2770
+ "tailwind.config.js",
2771
+ "tailwind.config.mjs",
2772
+ "tailwind.config.cjs"
2773
+ ];
2774
+ for (const file of configFiles) {
2775
+ const fullPath = path__namespace.default.join(cwd, file);
2776
+ if (fs3__namespace.default.existsSync(fullPath)) {
2777
+ const mod = __require(fullPath);
2778
+ return mod.default || mod;
2779
+ }
2780
+ }
2781
+ return {};
2782
+ };
2783
+ getContentPaths = (cwd = process.cwd()) => {
2784
+ return {
2785
+ content: [
2786
+ path__namespace.default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
2787
+ path__namespace.default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
2788
+ path__namespace.default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
2789
+ ]
2790
+ };
2791
+ };
2792
+ _CONTAINER_BREAKPOINTS = {
2793
+ xs: "240px",
2794
+ sm: "320px",
2795
+ md: "640px",
2796
+ lg: "1024px",
2797
+ xl: "1280px",
2798
+ "2xl": "1536px"
2799
+ };
2800
+ runLoaderTransform = (ctx) => {
2801
+ const { filepath, source, options } = ctx;
2802
+ const result = transformSource(source, { filename: filepath, ...options });
2803
+ let staticCss;
2804
+ try {
2805
+ const cssChunks = [];
2806
+ const stateRules = extractAndGenerateStateCss(source, filepath);
2807
+ if (stateRules.length > 0) {
2808
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
2809
+ }
2810
+ const containerCss = extractContainerCssFromSource(source);
2811
+ if (containerCss) cssChunks.push(containerCss);
2812
+ const combined = cssChunks.join("\n").trim();
2813
+ if (combined) staticCss = combined;
2814
+ } catch (err) {
2815
+ console.debug("Static CSS extraction warning:", err);
2816
+ }
2817
+ return {
2818
+ code: result?.code || "",
2819
+ changed: result?.changed || false,
2820
+ classes: result?.classes || [],
2821
+ staticCss
2822
+ };
2823
+ };
2824
+ shouldSkipFile = (filepath) => {
2825
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
2826
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
2827
+ for (const p of SKIP_PATHS) {
2828
+ if (filepath.includes(p)) return true;
2829
+ }
2830
+ for (const ext of skipExtensions) {
2831
+ if (filepath.endsWith(ext)) return true;
2832
+ }
2833
+ return false;
2834
+ };
2835
+ fileToRoute = (filepath) => {
2836
+ const normalized = filepath.replace(/\\/g, "/");
2837
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
2838
+ return "__global";
2839
+ }
2840
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
2841
+ if (pageMatch) return `/${pageMatch[1]}`;
2842
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
2843
+ if (rootPage) return "/";
2844
+ return null;
2845
+ };
2846
+ getAllRoutes = () => {
2847
+ const native = getNativeBridge();
2848
+ if (!native?.analyzeClasses) {
2849
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2850
+ }
2851
+ return ["/", "__global"];
2852
+ };
2853
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
2854
+ registerFileClasses = (_filepath, _classes) => {
2855
+ };
2856
+ registerGlobalClasses = (_classes) => {
2857
+ };
2858
+ _incrementalEngineInstance = null;
2859
+ getIncrementalEngine = () => {
2860
+ if (!_incrementalEngineInstance) {
2861
+ _incrementalEngineInstance = new IncrementalEngine();
2862
+ }
2863
+ return _incrementalEngineInstance;
2864
+ };
2865
+ resetIncrementalEngine = () => {
2866
+ _incrementalEngineInstance = null;
2867
+ };
2868
+ IncrementalEngine = class {
2869
+ compile(source) {
2870
+ return transformSource(source);
2871
+ }
2872
+ };
2873
+ getBucketEngine = () => {
2874
+ const native = getNativeBridge();
2875
+ if (!native?.classifyAndSortClasses) {
2876
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2877
+ }
2878
+ return {
2879
+ add: (className) => className,
2880
+ get: (_bucket) => []
2881
+ };
2882
+ };
2883
+ resetBucketEngine = () => {
2884
+ };
2885
+ classifyNode = (_node) => {
2886
+ const native = getNativeBridge();
2887
+ if (!native?.classifyAndSortClasses) {
2888
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2889
+ }
2890
+ return "unknown";
2891
+ };
2892
+ detectConflicts = (_classes) => {
2893
+ const native = getNativeBridge();
2894
+ if (!native?.analyzeClassUsage) {
2895
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2896
+ }
2897
+ return [];
2898
+ };
2899
+ bucketSort = (classes) => {
2900
+ const native = getNativeBridge();
2901
+ if (!native?.classifyAndSortClasses) {
2902
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2903
+ }
2904
+ const sorted = native.classifyAndSortClasses(classes);
2905
+ return sorted.map((c) => c.raw ?? c);
2906
+ };
2907
+ analyzeFile = (source, filename) => {
2908
+ const native = getNativeBridge();
2909
+ if (!native?.analyzeRsc) {
2910
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2911
+ }
2912
+ const rsc = native.analyzeRsc(source, filename);
2913
+ return {
2914
+ isServer: rsc?.isServer ?? true,
2915
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2916
+ clientReasons: rsc?.clientReasons ?? [],
2917
+ interactiveClasses: [],
2918
+ canStaticResolveVariants: true
2919
+ };
2920
+ };
2921
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2922
+ return { resolved: {}, dynamic: [] };
2923
+ };
2924
+ injectClientDirective = (source) => {
2925
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2926
+ return '"use client";\n' + source;
2927
+ }
2928
+ return source;
2929
+ };
2930
+ injectServerOnlyComment = (source) => {
2931
+ return `/* @server-only */
2932
+ ${source}`;
2933
+ };
2934
+ analyzeClasses = (filesJson, cwd, flags) => {
2935
+ const native = getNativeBridge();
2936
+ if (!native?.analyzeClasses) {
2937
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2938
+ }
2939
+ return native.analyzeClasses(filesJson, cwd, flags);
2940
+ };
2941
+ extractTwStateConfigs = (source, filename) => {
2942
+ const native = getNativeBridge();
2943
+ if (!native?.extractTwStateConfigs) {
2944
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
2945
+ }
2946
+ return native.extractTwStateConfigs(source, filename);
2947
+ };
2948
+ generateStaticStateCss = (entries, _themeConfig) => {
2949
+ const rules = [];
2950
+ for (const entry of entries) {
2951
+ const stateConfig = JSON.parse(entry.statesJson);
2952
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2953
+ rules.push({
2954
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2955
+ declarations: classes,
2956
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2957
+ componentName: entry.componentName,
2958
+ stateName
2959
+ });
2960
+ }
2961
+ }
2962
+ return rules;
2963
+ };
2964
+ extractAndGenerateStateCss = (source, filename) => {
2965
+ const entries = extractTwStateConfigs(source, filename);
2966
+ return generateStaticStateCss(entries);
2967
+ };
2968
+ }
2969
+ });
2970
+
2971
+ // packages/domain/compiler/src/internal.ts
2972
+ var internal_exports = {};
2973
+ __export(internal_exports, {
2974
+ adaptNativeResult: () => adaptNativeResult,
2975
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
2976
+ analyzeClasses: () => analyzeClasses,
2977
+ analyzeClassesNative: () => analyzeClassesNative,
2978
+ analyzeFile: () => analyzeFile,
2979
+ analyzeRscNative: () => analyzeRscNative,
2980
+ analyzeVariantUsage: () => analyzeVariantUsage,
2981
+ astExtractClasses: () => astExtractClasses,
2982
+ atomicRegistrySize: () => atomicRegistrySize,
2983
+ batchExtractClasses: () => batchExtractClasses,
2984
+ batchExtractClassesNative: () => batchExtractClassesNative,
2985
+ bucketSort: () => bucketSort,
2986
+ buildStyleTag: () => buildStyleTag,
2987
+ cachePriority: () => cachePriority,
2988
+ cacheRead: () => cacheRead,
2989
+ cacheWrite: () => cacheWrite,
2990
+ checkAgainstSafelist: () => checkAgainstSafelist,
2991
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2992
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
2993
+ classifyNode: () => classifyNode,
2994
+ clearAllCaches: () => clearAllCaches,
2995
+ clearAtomicRegistry: () => clearAtomicRegistry,
2996
+ clearCache: () => clearCache,
2997
+ clearCompileCache: () => clearCompileCache,
2998
+ clearCssGenCache: () => clearCssGenCache,
2999
+ clearParseCache: () => clearParseCache,
3000
+ clearResolveCache: () => clearResolveCache,
3001
+ clearThemeCache: () => clearThemeCache,
3002
+ collectFiles: () => collectFiles,
3003
+ compileAnimation: () => compileAnimation,
3004
+ compileClass: () => compileClass,
3005
+ compileClasses: () => compileClasses,
3006
+ compileCssFromClasses: () => compileCssFromClasses,
3007
+ compileCssLightning: () => compileCssLightning,
3008
+ compileCssNative2: () => compileCssNative2,
3009
+ compileKeyframes: () => compileKeyframes,
3010
+ compileTheme: () => compileTheme,
3011
+ compileToCss: () => compileToCss,
3012
+ compileToCssBatch: () => compileToCssBatch,
3013
+ compileVariantTableNative: () => compileVariantTableNative,
3014
+ computeIncrementalDiff: () => computeIncrementalDiff,
3015
+ createFingerprint: () => createFingerprint,
3016
+ detectConflicts: () => detectConflicts,
3017
+ detectDeadCode: () => detectDeadCode,
3018
+ diffClassLists: () => diffClassLists,
3019
+ eliminateDeadCss: () => eliminateDeadCss,
3020
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
3021
+ emitPluginHook: () => emitPluginHook,
3022
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
3023
+ extractAllClasses: () => extractAllClasses,
3024
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
3025
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
3026
+ extractClassesFromSource: () => extractClassesFromSource,
3027
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
3028
+ extractComponentUsage: () => extractComponentUsage,
3029
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
3030
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
3031
+ extractTwStateConfigs: () => extractTwStateConfigs,
3032
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
3033
+ fileToRoute: () => fileToRoute,
3034
+ findDeadVariants: () => findDeadVariants,
3035
+ generateAtomicCss: () => generateAtomicCss,
3036
+ generateCssForClasses: () => generateCssForClasses,
3037
+ generateCssNative: () => generateCssNative,
3038
+ generateSafelist: () => generateSafelist,
3039
+ generateStaticStateCss: () => generateStaticStateCss,
3040
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
3041
+ generateSubComponentTypes: () => generateSubComponentTypes,
3042
+ getAllRoutes: () => getAllRoutes,
3043
+ getBucketEngine: () => getBucketEngine,
3044
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
3045
+ getCacheStatistics: () => getCacheStatistics,
3046
+ getCacheStats: () => getCacheStats,
3047
+ getCompilationMetrics: () => getCompilationMetrics,
3048
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
3049
+ getContentPaths: () => getContentPaths,
3050
+ getIncrementalEngine: () => getIncrementalEngine,
3051
+ getNativeBridge: () => getNativeBridge,
3052
+ getPluginHooks: () => getPluginHooks,
3053
+ getRouteClasses: () => getRouteClasses,
3054
+ getWatchStats: () => getWatchStats,
3055
+ hasTwUsage: () => hasTwUsage,
3056
+ hashContent: () => hashContent,
3057
+ hoistComponentsNative: () => hoistComponentsNative,
3058
+ idRegistryActiveCount: () => idRegistryActiveCount,
3059
+ idRegistryCreate: () => idRegistryCreate,
3060
+ idRegistryDestroy: () => idRegistryDestroy,
3061
+ idRegistryExport: () => idRegistryExport,
3062
+ idRegistryGenerate: () => idRegistryGenerate,
3063
+ idRegistryImport: () => idRegistryImport,
3064
+ idRegistryLookup: () => idRegistryLookup,
3065
+ idRegistryNext: () => idRegistryNext,
3066
+ idRegistryReset: () => idRegistryReset,
3067
+ idRegistrySnapshot: () => idRegistrySnapshot,
3068
+ injectClientDirective: () => injectClientDirective,
3069
+ injectServerOnlyComment: () => injectServerOnlyComment,
3070
+ injectStateHash: () => injectStateHash,
3071
+ isAlreadyTransformed: () => isAlreadyTransformed,
3072
+ isWatchRunning: () => isWatchRunning,
3073
+ layoutClassesToCss: () => layoutClassesToCss,
3074
+ loadSafelist: () => loadSafelist,
3075
+ loadTailwindConfig: () => loadTailwindConfig,
3076
+ mergeClassesStatic: () => mergeClassesStatic,
3077
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
3078
+ minifyCss: () => minifyCss,
3079
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
3080
+ normalizeClasses: () => normalizeClasses,
3081
+ optimizeCssNative: () => optimizeCssNative,
3082
+ parseAtomicClass: () => parseAtomicClass,
3083
+ parseClasses: () => parseClasses,
3084
+ pollWatchEvents: () => pollWatchEvents,
3085
+ processFileChange: () => processFileChange,
3086
+ processTailwindCssLightning: () => processTailwindCssLightning,
3087
+ propertyIdToString: () => propertyIdToString,
3088
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
3089
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
3090
+ redisCacheClear: () => redisCacheClear,
3091
+ redisCacheHitRate: () => redisCacheHitRate,
3092
+ redisCacheKeyCount: () => redisCacheKeyCount,
3093
+ redisCacheSize: () => redisCacheSize,
3094
+ redisCacheSync: () => redisCacheSync,
3095
+ redisClusterStatus: () => redisClusterStatus,
3096
+ redisDelete: () => redisDelete,
3097
+ redisDiagnose: () => redisDiagnose,
3098
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
3099
+ redisDisableCluster: () => redisDisableCluster,
3100
+ redisDisablePersistence: () => redisDisablePersistence,
3101
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
3102
+ redisEnableCluster: () => redisEnableCluster,
3103
+ redisEnablePersistence: () => redisEnablePersistence,
3104
+ redisExists: () => redisExists,
3105
+ redisExpirationGet: () => redisExpirationGet,
3106
+ redisExpirationSet: () => redisExpirationSet,
3107
+ redisFlushAll: () => redisFlushAll,
3108
+ redisFlushDb: () => redisFlushDb,
3109
+ redisGet: () => redisGet,
3110
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
3111
+ redisInfo: () => redisInfo,
3112
+ redisMemoryStats: () => redisMemoryStats,
3113
+ redisMget: () => redisMget,
3114
+ redisMonitor: () => redisMonitor,
3115
+ redisMset: () => redisMset,
3116
+ redisOptimizeMemory: () => redisOptimizeMemory,
3117
+ redisPing: () => redisPing,
3118
+ redisPoolConnect: () => redisPoolConnect,
3119
+ redisPoolReconnect: () => redisPoolReconnect,
3120
+ redisPoolStats: () => redisPoolStats,
3121
+ redisPublish: () => redisPublish,
3122
+ redisReplicate: () => redisReplicate,
3123
+ redisReplicationStatus: () => redisReplicationStatus,
3124
+ redisSet: () => redisSet,
3125
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
3126
+ redisSnapshot: () => redisSnapshot,
3127
+ redisSubscribe: () => redisSubscribe,
3128
+ registerFileClasses: () => registerFileClasses,
3129
+ registerGlobalClasses: () => registerGlobalClasses,
3130
+ registerPluginHook: () => registerPluginHook,
3131
+ registerPropertyName: () => registerPropertyName,
3132
+ registerValueName: () => registerValueName,
3133
+ resetBucketEngine: () => resetBucketEngine,
3134
+ resetCompilationMetrics: () => resetCompilationMetrics,
3135
+ resetIncrementalEngine: () => resetIncrementalEngine,
3136
+ resolveCascade: () => resolveCascade,
3137
+ resolveClassNames: () => resolveClassNames,
3138
+ resolveConflictGroup: () => resolveConflictGroup,
3139
+ resolveSimpleVariants: () => resolveSimpleVariants,
3140
+ resolveThemeValue: () => resolveThemeValue,
3141
+ resolveVariants: () => resolveVariants,
3142
+ reverseLookupProperty: () => reverseLookupProperty,
3143
+ reverseLookupValue: () => reverseLookupValue,
3144
+ runCssPipeline: () => runCssPipeline,
3145
+ runCssPipelineSync: () => runCssPipelineSync,
3146
+ runElimination: () => runElimination,
3147
+ runLoaderTransform: () => runLoaderTransform,
3148
+ scanCacheOptimizations: () => scanCacheOptimizations,
3149
+ scanFile: () => scanFile,
3150
+ scanFileNative: () => scanFileNative,
3151
+ scanFilesBatchNative: () => scanFilesBatchNative,
3152
+ scanProjectUsage: () => scanProjectUsage,
3153
+ scanWorkspace: () => scanWorkspace,
3154
+ shouldProcess: () => shouldProcess,
3155
+ shouldSkipFile: () => shouldSkipFile,
3156
+ startWatch: () => startWatch,
3157
+ stopWatch: () => stopWatch,
3158
+ toAtomicClasses: () => toAtomicClasses,
3159
+ transformSource: () => transformSource,
3160
+ twMerge: () => twMerge,
3161
+ twMergeMany: () => twMergeMany,
3162
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
3163
+ twMergeRaw: () => twMergeRaw,
3164
+ twMergeWithSeparator: () => twMergeWithSeparator,
3165
+ unregisterPluginHook: () => unregisterPluginHook,
3166
+ validateCssOutput: () => validateCssOutput,
3167
+ validateThemeConfig: () => validateThemeConfig,
3168
+ valueIdToString: () => valueIdToString,
3169
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
3170
+ watchAddPattern: () => watchAddPattern,
3171
+ watchClearAll: () => watchClearAll,
3172
+ watchEventTypeToString: () => watchEventTypeToString,
3173
+ watchGetActiveHandles: () => watchGetActiveHandles,
3174
+ watchPause: () => watchPause,
3175
+ watchRemovePattern: () => watchRemovePattern,
3176
+ watchResume: () => watchResume
3177
+ });
3178
+ var init_internal = __esm({
3179
+ "packages/domain/compiler/src/internal.ts"() {
3180
+ init_src();
3181
+ init_tailwindEngine();
3182
+ init_compiler();
3183
+ init_parser();
3184
+ init_analyzer();
3185
+ init_cache();
3186
+ init_redis();
3187
+ init_watch();
3188
+ }
3189
+ });
3190
+ function getNative() {
3191
+ if (_native) return _native;
3192
+ try {
3193
+ const mod = (init_internal(), __toCommonJS(internal_exports));
3194
+ if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
3195
+ return null;
3196
+ }
3197
+ _native = {
3198
+ extractTwStateConfigs: mod.extractTwStateConfigs,
3199
+ generateStaticStateCss: mod.generateStaticStateCss,
3200
+ extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
3201
+ ((source, filename) => {
3202
+ const configs = mod.extractTwStateConfigs(source, filename);
3203
+ if (configs.length === 0) return [];
3204
+ return mod.generateStaticStateCss(configs.map((c) => ({
3205
+ tag: c.tag,
3206
+ componentName: c.componentName,
3207
+ statesJson: c.statesJson
3208
+ })));
3209
+ })
3210
+ };
3211
+ return _native;
3212
+ } catch {
3213
+ return null;
3214
+ }
3215
+ }
3216
+ function* walkSourceFiles(dir) {
3217
+ let entries;
3218
+ try {
3219
+ entries = fs3__namespace.default.readdirSync(dir, { withFileTypes: true });
3220
+ } catch {
3221
+ return;
3222
+ }
3223
+ for (const entry of entries) {
3224
+ const fullPath = path__namespace.default.join(dir, entry.name);
3225
+ if (entry.isDirectory()) {
3226
+ if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
3227
+ yield* walkSourceFiles(fullPath);
3228
+ } else if (entry.isFile()) {
3229
+ const ext = path__namespace.default.extname(entry.name);
3230
+ if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
3231
+ }
3232
+ }
3233
+ }
3234
+ function buildCssHeader(result) {
3235
+ return [
3236
+ "/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
3237
+ " * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
3238
+ " * DO NOT EDIT. Re-generated on each build.",
3239
+ " *",
3240
+ ` * Files scanned: ${result.filesScanned}`,
3241
+ ` * Files with states: ${result.filesWithStates}`,
3242
+ ` * Components found: ${result.componentsFound}`,
3243
+ ` * Rules generated: ${result.rulesGenerated}`,
3244
+ ` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
3245
+ " *",
3246
+ ' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
3247
+ " * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
3248
+ " * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */",
3249
+ ""
3250
+ ].join("\n");
3251
+ }
3252
+ function extractStaticStateCss(srcDir, options = {}) {
3253
+ const { verbose = false, maxFiles = Infinity } = options;
3254
+ const native = getNative();
3255
+ if (!native) {
3256
+ if (verbose) {
3257
+ process.stderr.write(
3258
+ "[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
3259
+ );
3260
+ }
3261
+ return {
3262
+ filesScanned: 0,
3263
+ filesWithStates: 0,
3264
+ componentsFound: 0,
3265
+ rulesGenerated: 0,
3266
+ rulesSkipped: 0,
3267
+ generatedCss: "",
3268
+ rules: []
3269
+ };
3270
+ }
3271
+ const allConfigs = [];
3272
+ let filesScanned = 0;
3273
+ let filesWithStates = 0;
3274
+ if (native.walkAndPrefilterSourceFiles) {
3275
+ const prefiltered = native.walkAndPrefilterSourceFiles(
3276
+ srcDir,
3277
+ [".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
3278
+ ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
3279
+ // Required substrings — AND logic, identik dengan JS pre-filter di bawah
3280
+ ["states:", "tw."],
3281
+ maxFiles === Infinity ? null : maxFiles,
3282
+ null
3283
+ // sequential — parallel mode opsional untuk large monorepo
3284
+ );
3285
+ for (const { path: filePath, content: source } of prefiltered) {
3286
+ filesScanned++;
3287
+ const configs = native.extractTwStateConfigs(source, filePath);
3288
+ if (configs.length > 0) {
3289
+ filesWithStates++;
3290
+ allConfigs.push(...configs);
3291
+ if (verbose) {
3292
+ process.stderr.write(
3293
+ `[tw:static-state] ${path__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
3294
+ `
3295
+ );
3296
+ }
3297
+ }
3298
+ }
3299
+ } else {
3300
+ for (const filePath of walkSourceFiles(srcDir)) {
3301
+ if (filesScanned >= maxFiles) break;
3302
+ let source;
3303
+ try {
3304
+ source = fs3__namespace.default.readFileSync(filePath, "utf-8");
3305
+ } catch {
3306
+ continue;
3307
+ }
3308
+ filesScanned++;
3309
+ if (!source.includes("states:") && !source.includes("states :")) continue;
3310
+ if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
3311
+ const configs = native.extractTwStateConfigs(source, filePath);
3312
+ if (configs.length > 0) {
3313
+ filesWithStates++;
3314
+ allConfigs.push(...configs);
3315
+ if (verbose) {
3316
+ process.stderr.write(
3317
+ `[tw:static-state] ${path__namespace.default.relative(srcDir, filePath)}: ${configs.length} komponen
3318
+ `
3319
+ );
3320
+ }
3321
+ }
3322
+ }
3323
+ }
3324
+ if (allConfigs.length === 0) {
3325
+ return {
3326
+ filesScanned,
3327
+ filesWithStates: 0,
3328
+ componentsFound: 0,
3329
+ rulesGenerated: 0,
3330
+ rulesSkipped: 0,
3331
+ generatedCss: "",
3332
+ rules: []
3333
+ };
3334
+ }
3335
+ const seen = /* @__PURE__ */ new Set();
3336
+ const uniqueConfigs = [];
3337
+ for (const config of allConfigs) {
3338
+ const key = `${config.tag}::${config.statesJson}`;
3339
+ if (!seen.has(key)) {
3340
+ seen.add(key);
3341
+ uniqueConfigs.push({
3342
+ tag: config.tag,
3343
+ componentName: config.componentName,
3344
+ statesJson: config.statesJson
3345
+ });
3346
+ }
3347
+ }
3348
+ const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
3349
+ const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
3350
+ try {
3351
+ const stateMap = JSON.parse(cfg.statesJson);
3352
+ return total + Object.keys(stateMap).length;
3353
+ } catch {
3354
+ return total;
3355
+ }
3356
+ }, 0) - allRules.length;
3357
+ const byComponent = /* @__PURE__ */ new Map();
3358
+ for (const rule of allRules) {
3359
+ const existing = byComponent.get(rule.componentName) ?? [];
3360
+ existing.push(rule);
3361
+ byComponent.set(rule.componentName, existing);
3362
+ }
3363
+ const cssBlocks = [];
3364
+ for (const [componentName, rules] of byComponent) {
3365
+ cssBlocks.push(`/* ${componentName} */`);
3366
+ for (const rule of rules) {
3367
+ cssBlocks.push(`/* state: ${rule.stateName} */`);
3368
+ cssBlocks.push(rule.cssRule);
3369
+ }
3370
+ cssBlocks.push("");
3371
+ }
3372
+ const result = {
3373
+ filesScanned,
3374
+ filesWithStates,
3375
+ componentsFound: allConfigs.length,
3376
+ rulesGenerated: allRules.length,
3377
+ rulesSkipped: Math.max(0, rulesSkipped),
3378
+ generatedCss: cssBlocks.join("\n"),
3379
+ rules: allRules
3380
+ };
3381
+ result.generatedCss = buildCssHeader(result) + result.generatedCss;
3382
+ return result;
3383
+ }
3384
+ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
3385
+ const result = extractStaticStateCss(srcDir, options);
3386
+ const twClassesDir = path__namespace.default.join(path__namespace.default.dirname(safelistPath), "tw-classes");
3387
+ fs3__namespace.default.mkdirSync(twClassesDir, { recursive: true });
3388
+ const stateFilePath = path__namespace.default.join(twClassesDir, exports.TW_STATE_STATIC_FILENAME);
3389
+ if (result.rulesGenerated === 0) {
3390
+ try {
3391
+ fs3__namespace.default.writeFileSync(
3392
+ stateFilePath,
3393
+ "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
3394
+ "utf-8"
3395
+ );
3396
+ } catch {
3397
+ }
3398
+ return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
3399
+ }
3400
+ try {
3401
+ fs3__namespace.default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
3402
+ return [
3403
+ `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
3404
+ ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
3405
+ ` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
3406
+ ` \u2192 ditulis ke tw-classes/${exports.TW_STATE_STATIC_FILENAME}`
3407
+ ].join("\n");
3408
+ } catch (writeErr) {
3409
+ const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
3410
+ return `[tw:static-state] gagal tulis state CSS: ${msg}`;
3411
+ }
3412
+ }
3413
+ var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native; exports.TW_STATE_STATIC_FILENAME = void 0;
3414
+ var init_staticStateExtractor = __esm({
3415
+ "packages/domain/shared/src/staticStateExtractor.ts"() {
3416
+ SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
3417
+ IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
3418
+ _native = null;
3419
+ exports.TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
3420
+ }
3421
+ });
3422
+ function getEnvLevel() {
3423
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
3424
+ if (env && env in LEVELS) return env;
3425
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
3426
+ }
3427
+ function setGlobalLogFile(filePath) {
3428
+ _globalLogFile = filePath;
3429
+ _logFileInitialized = false;
3430
+ try {
3431
+ fs3__namespace.default.mkdirSync(path__namespace.default.dirname(filePath), { recursive: true });
3432
+ fs3__namespace.default.writeFileSync(
3433
+ filePath,
3434
+ `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
3435
+ `,
3436
+ "utf-8"
3437
+ );
3438
+ _logFileInitialized = true;
3439
+ } catch {
3440
+ }
3441
+ }
3442
+ function writeToFile(line) {
3443
+ if (!_globalLogFile || !_logFileInitialized) return;
3444
+ try {
3445
+ fs3__namespace.default.appendFileSync(_globalLogFile, line);
3446
+ } catch {
3447
+ }
3448
+ }
3449
+ function createLogger(prefix, level) {
3450
+ const loggerState = {
3451
+ currentLevel: getEnvLevel(),
3452
+ setLevel(l) {
3453
+ this.currentLevel = l;
3454
+ }
3455
+ };
3456
+ const log2 = (msgLevel, stream, args) => {
3457
+ if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
3458
+ const line = `[${prefix}] ${args.map(String).join(" ")}
3459
+ `;
3460
+ process[stream].write(line);
3461
+ writeToFile(line);
3462
+ };
3463
+ return {
3464
+ error: (...a) => log2("error", "stderr", a),
3465
+ warn: (...a) => log2("warn", "stderr", a),
3466
+ info: (...a) => log2("info", "stdout", a),
3467
+ debug: (...a) => log2("debug", "stderr", a),
3468
+ setLevel: loggerState.setLevel,
3469
+ setLogFile: (filePath) => setGlobalLogFile(filePath)
3470
+ };
3471
+ }
3472
+ var LEVELS, _globalLogFile, _logFileInitialized;
3473
+ var init_logger = __esm({
3474
+ "packages/domain/shared/src/logger.ts"() {
3475
+ LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
3476
+ _globalLogFile = null;
3477
+ _logFileInitialized = false;
3478
+ createLogger("tailwind-styled");
3479
+ }
3480
+ });
3481
+ function createLogger2(namespace) {
3482
+ const prefix = `[${namespace}]`;
3483
+ return {
3484
+ warn(...args) {
3485
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
3486
+ `);
3487
+ },
3488
+ debug(...args) {
3489
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
3490
+ `);
3491
+ },
3492
+ error(...args) {
3493
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
3494
+ `);
3495
+ },
3496
+ log(...args) {
3497
+ process.stderr.write(`${prefix} ${args.map((a) => typeof a === "string" ? a : String(a)).join(" ")}
3498
+ `);
3499
+ }
3500
+ };
3501
+ }
3502
+ function createDebugLogger(namespace, label) {
3503
+ const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`;
3504
+ return (msg) => {
3505
+ if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {
3506
+ console.debug(prefix, msg);
3507
+ }
3508
+ };
3509
+ }
3510
+ function formatIssuePath(path6) {
3511
+ if (!path6 || path6.length === 0) return "(root)";
3512
+ return path6.map(
3513
+ (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
3514
+ ).join(".");
3515
+ }
3516
+ function wrapUnknownError(domain, code, error) {
3517
+ return exports.TwError.wrap(domain, code, error);
3518
+ }
3519
+ function isTwError(err) {
3520
+ return err instanceof exports.TwError;
3521
+ }
3522
+ function loadNativeBinding(options) {
3523
+ const { runtimeDir, candidates, isValid } = options;
3524
+ const loadErrors = [];
3525
+ for (const candidate of candidates) {
3526
+ const candidatePath = path__namespace.default.resolve(runtimeDir, candidate);
3527
+ try {
3528
+ if (!fs3__namespace.default.existsSync(candidatePath) && !fs3__namespace.default.existsSync(candidatePath + ".node")) {
3529
+ continue;
3530
+ }
3531
+ const mod = requireNativeModule(candidatePath);
3532
+ if (mod && isValid(mod)) {
3533
+ return { binding: mod, loadErrors, loadedPath: candidatePath };
3534
+ }
3535
+ loadErrors.push({ path: candidatePath, message: options.invalidExportMessage });
3536
+ } catch (e) {
3537
+ loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) });
3538
+ }
3539
+ }
3540
+ return { binding: null, loadErrors };
3541
+ }
3542
+ function requireNativeModule(p) {
3543
+ return _require2(p);
3544
+ }
3545
+ function resolveNativeBindingCandidates(options) {
3546
+ const {
3547
+ envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
3548
+ includeDefaultCandidates = true,
3549
+ enforceNodeExtensionForEnvPath = false
3550
+ } = options;
3551
+ const runtimeDir = options.runtimeDir || process.cwd();
3552
+ const candidates = [];
3553
+ for (const envVar of envVarNames) {
3554
+ const envPath = process.env[envVar];
3555
+ if (envPath) {
3556
+ candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
3557
+ }
3558
+ }
3559
+ if (!includeDefaultCandidates) return candidates;
3560
+ if (fs3__namespace.default.existsSync(runtimeDir)) {
3561
+ try {
3562
+ for (const entry of fs3__namespace.default.readdirSync(runtimeDir)) {
3563
+ if (entry.endsWith(".node")) candidates.push(entry);
3564
+ }
3565
+ } catch {
3566
+ }
3567
+ }
3568
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
3569
+ const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
3570
+ for (const bin of BINARY_NAMES) {
3571
+ candidates.push(path__namespace.default.resolve(runtimeDir, `${bin}.node`));
3572
+ candidates.push(path__namespace.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
3573
+ candidates.push(path__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.node`));
3574
+ candidates.push(path__namespace.default.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
3575
+ candidates.push(path__namespace.default.resolve(process.cwd(), "native", `${bin}.node`));
3576
+ candidates.push(path__namespace.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
3577
+ candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
3578
+ candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
3579
+ candidates.push(path__namespace.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
3580
+ }
3581
+ return Array.from(new Set(candidates));
3582
+ }
3583
+ function resolveRuntimeDir(dir, importMetaUrl) {
3584
+ if (dir) return path__namespace.default.resolve(dir);
3585
+ try {
3586
+ return path__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
3587
+ } catch {
3588
+ return process.cwd();
3589
+ }
3590
+ }
3591
+ function hashContent2(content, algorithm = "md5", length) {
3592
+ const hash = crypto.createHash(algorithm).update(content).digest("hex");
3593
+ return length ? hash.slice(0, length) : hash;
3594
+ }
3595
+ function formatErrorMessage(error) {
3596
+ if (error instanceof exports.TwError) return error.toString();
3597
+ if (error instanceof Error) return error.message;
3598
+ return String(error);
3599
+ }
3600
+ exports.TwError = void 0; var _require2; exports.LRUCache = void 0;
3601
+ var init_src2 = __esm({
3602
+ "packages/domain/shared/src/index.ts"() {
3603
+ init_trace();
3604
+ init_error_codes();
3605
+ init_compatibility();
3606
+ init_native_schemas();
3607
+ init_esmHelpers();
3608
+ init_telemetry();
3609
+ init_configSchemas();
3610
+ init_workerResolver();
3611
+ init_codegen();
3612
+ init_native_resolution();
3613
+ init_observability();
3614
+ init_staticStateExtractor();
3615
+ init_logger();
3616
+ exports.TwError = class _TwError extends Error {
3617
+ /** @deprecated Gunakan source */
3618
+ domain;
3619
+ source;
3620
+ code;
3621
+ originalCause;
3622
+ constructor(domainOrSource, code, message, cause) {
3623
+ super(message);
3624
+ this.name = "TwError";
3625
+ this.domain = domainOrSource;
3626
+ this.source = domainOrSource;
3627
+ this.code = code;
3628
+ this.originalCause = cause;
3629
+ if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
3630
+ }
3631
+ static fromIo(code, message) {
3632
+ return new _TwError("io", code, message);
3633
+ }
3634
+ static fromCompile(code, message) {
3635
+ return new _TwError("compile", code, message);
3636
+ }
3637
+ static fromRust(err) {
3638
+ if (err instanceof _TwError) return err;
3639
+ if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
3640
+ if (err && typeof err === "object") {
3641
+ const e = err;
3642
+ return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
3643
+ }
3644
+ return new _TwError("rust", "RUST_ERROR", String(err), err);
3645
+ }
3646
+ /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
3647
+ static fromZod(err) {
3648
+ const first = err.issues?.[0] ?? err.errors?.[0];
3649
+ const path6 = formatIssuePath(first?.path);
3650
+ const message = first ? `${path6}: ${first.message}` : "Schema validation failed";
3651
+ return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
3652
+ }
3653
+ static wrap(source, code, err) {
3654
+ if (err instanceof _TwError) return err;
3655
+ if (err instanceof Error) return new _TwError(source, code, err.message, err);
3656
+ return new _TwError(source, code, String(err), err);
3657
+ }
3658
+ toString() {
3659
+ return `TwError [${this.source}:${this.code}] ${this.message}`;
3660
+ }
3661
+ toJSON() {
3662
+ return { name: this.name, source: this.source, code: this.code, message: this.message };
3663
+ }
3664
+ toCliMessage() {
3665
+ return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
3666
+ }
3667
+ };
3668
+ _require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared.js', document.baseURI).href)));
3669
+ exports.LRUCache = class {
3670
+ capacity;
3671
+ cache;
3672
+ constructor(capacity) {
3673
+ this.capacity = capacity;
3674
+ this.cache = /* @__PURE__ */ new Map();
3675
+ }
3676
+ get(key) {
3677
+ if (!this.cache.has(key)) return void 0;
3678
+ const value = this.cache.get(key);
3679
+ this.cache.delete(key);
3680
+ this.cache.set(key, value);
3681
+ return value;
3682
+ }
3683
+ set(key, value) {
3684
+ if (this.cache.has(key)) {
3685
+ this.cache.delete(key);
3686
+ } else if (this.cache.size >= this.capacity) {
3687
+ const firstKey = this.cache.keys().next().value;
3688
+ if (firstKey !== void 0) {
3689
+ this.cache.delete(firstKey);
3690
+ }
3691
+ }
3692
+ this.cache.set(key, value);
3693
+ }
3694
+ delete(key) {
3695
+ return this.cache.delete(key);
3696
+ }
3697
+ has(key) {
3698
+ return this.cache.has(key);
3699
+ }
3700
+ clear() {
3701
+ this.cache.clear();
3702
+ }
3703
+ entries() {
3704
+ return this.cache.entries();
3705
+ }
3706
+ get size() {
3707
+ return this.cache.size;
3708
+ }
3709
+ };
3710
+ }
3711
+ });
3712
+
3713
+ // src/umbrella/shared.ts
3714
+ init_src2();
1152
3715
 
1153
- exports.ERROR_CODES = ERROR_CODES;
1154
- exports.LRUCache = LRUCache;
1155
- exports.NativeAnalyzerReportSchema = NativeAnalyzerReportSchema;
1156
- exports.NativeCacheEntrySchema = NativeCacheEntrySchema;
1157
- exports.NativeCacheReadResultSchema = NativeCacheReadResultSchema;
1158
- exports.NativeCssCompileResultSchema = NativeCssCompileResultSchema;
1159
- exports.NativeScanFileSchema = NativeScanFileSchema;
1160
- exports.NativeScanResultSchema = NativeScanResultSchema;
1161
- exports.NativeTransformResultSchema = NativeTransformResultSchema;
1162
- exports.NativeWatchResultSchema = NativeWatchResultSchema;
1163
- exports.PackageJsonSchema = PackageJsonSchema;
1164
- exports.RegistryFileSchema = RegistryFileSchema;
1165
- exports.RegistryPluginEntrySchema = RegistryPluginEntrySchema;
1166
- exports.ScanCacheClassEntrySchema = ScanCacheClassEntrySchema;
1167
- exports.ScanCacheSchema = ScanCacheSchema;
1168
- exports.TailwindConfigSchema = TailwindConfigSchema;
1169
- exports.TelemetryCollector = TelemetryCollector;
1170
- exports.TwError = TwError;
3716
+ exports.appendStaticStateCssToSafelist = appendStaticStateCssToSafelist;
1171
3717
  exports.assertTailwindV4 = assertTailwindV4;
1172
3718
  exports.calculateHealth = calculateHealth;
1173
3719
  exports.createBuildTimer = createBuildTimer;
1174
3720
  exports.createDebugLogger = createDebugLogger;
1175
3721
  exports.createEsmRequire = createEsmRequire;
1176
- exports.createLogger = createLogger;
3722
+ exports.createLogger = createLogger2;
1177
3723
  exports.createObservabilityClient = createObservabilityClient;
1178
3724
  exports.createTraceSnapshot = createTraceSnapshot;
1179
3725
  exports.detectTailwind = detectTailwind;
3726
+ exports.extractStaticStateCss = extractStaticStateCss;
1180
3727
  exports.formatDuration = formatDuration;
1181
3728
  exports.formatErrorCode = formatErrorCode;
1182
3729
  exports.formatErrorMessage = formatErrorMessage;
@@ -1196,7 +3743,7 @@ exports.getModeColor = getModeColor;
1196
3743
  exports.getPipelinePercentages = getPipelinePercentages;
1197
3744
  exports.getSuggestion = getSuggestion;
1198
3745
  exports.getTailwindVersion = getTailwindVersion;
1199
- exports.hashContent = hashContent;
3746
+ exports.hashContent = hashContent2;
1200
3747
  exports.isTailwindV4 = isTailwindV4;
1201
3748
  exports.isTwError = isTwError;
1202
3749
  exports.loadNativeBinding = loadNativeBinding;
@@ -1212,6 +3759,7 @@ exports.resolveNativeNodePath = resolveNativeNodePath;
1212
3759
  exports.resolveRuntimeDir = resolveRuntimeDir;
1213
3760
  exports.resolveWorkerPath = resolveWorkerPath;
1214
3761
  exports.safeParseNative = safeParseNative;
3762
+ exports.setGlobalLogFile = setGlobalLogFile;
1215
3763
  exports.tryRequire = tryRequire;
1216
3764
  exports.wrapUnknownError = wrapUnknownError;
1217
3765
  //# sourceMappingURL=shared.js.map