tailwind-styled-v4 5.0.11 → 5.0.12

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 (107) hide show
  1. package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
  2. package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
  3. package/dist/analyzer.d.mts +4 -4
  4. package/dist/analyzer.d.ts +4 -4
  5. package/dist/analyzer.js +34 -69
  6. package/dist/analyzer.js.map +1 -1
  7. package/dist/analyzer.mjs +33 -68
  8. package/dist/analyzer.mjs.map +1 -1
  9. package/dist/animate.js +11 -11
  10. package/dist/animate.js.map +1 -1
  11. package/dist/animate.mjs +11 -11
  12. package/dist/animate.mjs.map +1 -1
  13. package/dist/atomic.js +16 -7
  14. package/dist/atomic.js.map +1 -1
  15. package/dist/atomic.mjs +16 -7
  16. package/dist/atomic.mjs.map +1 -1
  17. package/dist/cli.js +262 -190
  18. package/dist/cli.js.map +1 -1
  19. package/dist/cli.mjs +259 -187
  20. package/dist/cli.mjs.map +1 -1
  21. package/dist/compiler.d.mts +2543 -109
  22. package/dist/compiler.d.ts +2543 -109
  23. package/dist/compiler.js +1962 -435
  24. package/dist/compiler.js.map +1 -1
  25. package/dist/compiler.mjs +1816 -382
  26. package/dist/compiler.mjs.map +1 -1
  27. package/dist/devtools.js +17 -4
  28. package/dist/devtools.js.map +1 -1
  29. package/dist/devtools.mjs +17 -4
  30. package/dist/devtools.mjs.map +1 -1
  31. package/dist/engine.d.mts +11 -470
  32. package/dist/engine.d.ts +11 -470
  33. package/dist/engine.js +1442 -417
  34. package/dist/engine.js.map +1 -1
  35. package/dist/engine.mjs +1442 -417
  36. package/dist/engine.mjs.map +1 -1
  37. package/dist/index-BDQw13kn.d.ts +464 -0
  38. package/dist/index-DJv28Uzq.d.mts +464 -0
  39. package/dist/index.browser.mjs +143 -255
  40. package/dist/index.browser.mjs.map +1 -1
  41. package/dist/index.d.mts +23 -39
  42. package/dist/index.d.ts +23 -39
  43. package/dist/index.js +6000 -1463
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +5995 -1458
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/next.d.mts +44 -1
  48. package/dist/next.d.ts +44 -1
  49. package/dist/next.js +3197 -1128
  50. package/dist/next.js.map +1 -1
  51. package/dist/next.mjs +3196 -1129
  52. package/dist/next.mjs.map +1 -1
  53. package/dist/rspack.d.mts +9 -0
  54. package/dist/rspack.d.ts +9 -0
  55. package/dist/rspack.js +99 -61
  56. package/dist/rspack.js.map +1 -1
  57. package/dist/rspack.mjs +99 -61
  58. package/dist/rspack.mjs.map +1 -1
  59. package/dist/runtime-css.d.mts +8 -0
  60. package/dist/runtime-css.d.ts +8 -0
  61. package/dist/runtime-css.js +23 -7
  62. package/dist/runtime-css.js.map +1 -1
  63. package/dist/runtime-css.mjs +23 -7
  64. package/dist/runtime-css.mjs.map +1 -1
  65. package/dist/scanner.js +16 -37
  66. package/dist/scanner.js.map +1 -1
  67. package/dist/scanner.mjs +15 -36
  68. package/dist/scanner.mjs.map +1 -1
  69. package/dist/shared.d.mts +107 -1
  70. package/dist/shared.d.ts +107 -1
  71. package/dist/shared.js +1627 -376
  72. package/dist/shared.js.map +1 -1
  73. package/dist/shared.mjs +1620 -354
  74. package/dist/shared.mjs.map +1 -1
  75. package/dist/svelte.js +39 -35
  76. package/dist/svelte.js.map +1 -1
  77. package/dist/svelte.mjs +38 -34
  78. package/dist/svelte.mjs.map +1 -1
  79. package/dist/theme.js +85 -76
  80. package/dist/theme.js.map +1 -1
  81. package/dist/theme.mjs +83 -74
  82. package/dist/theme.mjs.map +1 -1
  83. package/dist/turbopackLoader.js +943 -76
  84. package/dist/turbopackLoader.js.map +1 -1
  85. package/dist/turbopackLoader.mjs +943 -76
  86. package/dist/turbopackLoader.mjs.map +1 -1
  87. package/dist/tw.js +262 -190
  88. package/dist/tw.js.map +1 -1
  89. package/dist/tw.mjs +259 -187
  90. package/dist/tw.mjs.map +1 -1
  91. package/dist/vite.js +1336 -296
  92. package/dist/vite.js.map +1 -1
  93. package/dist/vite.mjs +1336 -296
  94. package/dist/vite.mjs.map +1 -1
  95. package/dist/vue.js +39 -35
  96. package/dist/vue.js.map +1 -1
  97. package/dist/vue.mjs +38 -34
  98. package/dist/vue.mjs.map +1 -1
  99. package/dist/webpackLoader.js +140 -34
  100. package/dist/webpackLoader.js.map +1 -1
  101. package/dist/webpackLoader.mjs +140 -34
  102. package/dist/webpackLoader.mjs.map +1 -1
  103. package/native/index.node +0 -0
  104. package/native/tailwind-styled-native.node +0 -0
  105. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  106. package/package.json +9 -4
  107. package/CHANGELOG.md +0 -285
package/dist/shared.mjs CHANGED
@@ -1,19 +1,39 @@
1
- import { createHash } from 'crypto';
2
- import * as fs from 'fs';
3
- import fs__default from 'fs';
1
+ import { z } from 'zod';
2
+ import { createRequire } from 'module';
3
+ import * as fs3 from 'fs';
4
+ import fs3__default from 'fs';
4
5
  import * as path from 'path';
5
6
  import path__default from 'path';
7
+ import { createHash } from 'crypto';
6
8
  import { fileURLToPath } from 'url';
7
- import { createRequire } from 'module';
8
- import { z } from 'zod';
9
9
 
10
10
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
16
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
17
  }) : x)(function(x) {
14
18
  if (typeof require !== "undefined") return require.apply(this, arguments);
15
19
  throw Error('Dynamic require of "' + x + '" is not supported');
16
20
  });
21
+ var __esm = (fn, res) => function __init() {
22
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
23
+ };
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
17
37
 
18
38
  // packages/domain/shared/src/trace.ts
19
39
  function getHealthColor(status) {
@@ -105,43 +125,12 @@ function getPipelinePercentages(metrics) {
105
125
  compilePct: compile / total * 100
106
126
  };
107
127
  }
128
+ var init_trace = __esm({
129
+ "packages/domain/shared/src/trace.ts"() {
130
+ }
131
+ });
108
132
 
109
133
  // packages/domain/shared/src/error-codes.ts
110
- var ERROR_CODES = {
111
- // E0xx — Native binding
112
- NATIVE_NOT_FOUND: "E001",
113
- NATIVE_LOAD_FAILED: "E002",
114
- NATIVE_VERSION_MISMATCH: "E003",
115
- SCANNER_NATIVE_NOT_FOUND: "E004",
116
- SCANNER_HASH_FAILED: "E005",
117
- NATIVE_TRANSFORM_UNAVAILABLE: "E006",
118
- // E2xx — Compilation
119
- MISSING_REACT_IMPORT: "E201",
120
- UNSUPPORTED_PATTERN: "E202",
121
- TEMPLATE_PARSE_ERROR: "E203",
122
- COMPILE_TIMEOUT: "E204",
123
- // E3xx — Compatibility
124
- TAILWIND_VERSION_UNSUPPORTED: "E301",
125
- NODE_VERSION_UNSUPPORTED: "E302",
126
- // E4xx — Cache
127
- CACHE_READ_FAILED: "E401",
128
- CACHE_WRITE_FAILED: "E402",
129
- CACHE_CORRUPTED: "E403",
130
- // E5xx — RSC
131
- RSC_BOUNDARY_CONFLICT: "E501",
132
- // W1xx — Warnings
133
- DYNAMIC_CONTENT: "W101",
134
- INVALID_VARIANT_VALUE: "W201",
135
- DEPRECATED_MODE: "W301"
136
- };
137
- var ERROR_SUGGESTIONS = {
138
- E001: "Run: npm install @tailwind-styled/native-{platform} or build from source",
139
- E002: "Try: npm rebuild or reinstall the package",
140
- E003: "Run: npm install tailwind-styled-v4@latest to sync versions",
141
- E004: "Run: npm install @tailwind-styled/scanner",
142
- E006: "Run: npm install @tailwind-styled/compiler",
143
- E301: "Upgrade: npm install tailwindcss@^4"
144
- };
145
134
  function getSuggestion(code) {
146
135
  return ERROR_SUGGESTIONS[code];
147
136
  }
@@ -149,6 +138,46 @@ function formatErrorCode(code) {
149
138
  const prefix = code.startsWith("E") ? "Error" : code.startsWith("W") ? "Warning" : "Code";
150
139
  return `[${prefix} ${code}]`;
151
140
  }
141
+ var ERROR_CODES, ERROR_SUGGESTIONS;
142
+ var init_error_codes = __esm({
143
+ "packages/domain/shared/src/error-codes.ts"() {
144
+ ERROR_CODES = {
145
+ // E0xx — Native binding
146
+ NATIVE_NOT_FOUND: "E001",
147
+ NATIVE_LOAD_FAILED: "E002",
148
+ NATIVE_VERSION_MISMATCH: "E003",
149
+ SCANNER_NATIVE_NOT_FOUND: "E004",
150
+ SCANNER_HASH_FAILED: "E005",
151
+ NATIVE_TRANSFORM_UNAVAILABLE: "E006",
152
+ // E2xx — Compilation
153
+ MISSING_REACT_IMPORT: "E201",
154
+ UNSUPPORTED_PATTERN: "E202",
155
+ TEMPLATE_PARSE_ERROR: "E203",
156
+ COMPILE_TIMEOUT: "E204",
157
+ // E3xx — Compatibility
158
+ TAILWIND_VERSION_UNSUPPORTED: "E301",
159
+ NODE_VERSION_UNSUPPORTED: "E302",
160
+ // E4xx — Cache
161
+ CACHE_READ_FAILED: "E401",
162
+ CACHE_WRITE_FAILED: "E402",
163
+ CACHE_CORRUPTED: "E403",
164
+ // E5xx — RSC
165
+ RSC_BOUNDARY_CONFLICT: "E501",
166
+ // W1xx — Warnings
167
+ DYNAMIC_CONTENT: "W101",
168
+ INVALID_VARIANT_VALUE: "W201",
169
+ DEPRECATED_MODE: "W301"
170
+ };
171
+ ERROR_SUGGESTIONS = {
172
+ E001: "Run: npm install @tailwind-styled/native-{platform} or build from source",
173
+ E002: "Try: npm rebuild or reinstall the package",
174
+ E003: "Run: npm install tailwind-styled-v4@latest to sync versions",
175
+ E004: "Run: npm install @tailwind-styled/scanner",
176
+ E006: "Run: npm install @tailwind-styled/compiler",
177
+ E301: "Upgrade: npm install tailwindcss@^4"
178
+ };
179
+ }
180
+ });
152
181
 
153
182
  // packages/domain/shared/src/compatibility.ts
154
183
  function detectTailwind() {
@@ -176,64 +205,9 @@ function getTailwindVersion() {
176
205
  function isTailwindV4() {
177
206
  return detectTailwind().supported;
178
207
  }
179
- var NativeScanFileSchema = z.object({
180
- file: z.string().min(1, "file path cannot be empty"),
181
- classes: z.array(z.string()),
182
- hash: z.string().optional()
183
- });
184
- var NativeScanResultSchema = z.object({
185
- files: z.array(NativeScanFileSchema),
186
- totalFiles: z.number().int().nonnegative(),
187
- uniqueClasses: z.array(z.string())
188
- });
189
- var NativeClassUsageSchema = z.object({
190
- name: z.string(),
191
- count: z.number().int().nonnegative(),
192
- files: z.array(z.string()).optional()
193
- });
194
- var NativeAnalyzerReportSchema = z.object({
195
- root: z.string(),
196
- topClasses: z.array(NativeClassUsageSchema).optional(),
197
- safelist: z.array(z.string()).optional(),
198
- css: z.string().optional(),
199
- conflicts: z.array(z.unknown()).optional(),
200
- unusedClasses: z.array(z.string()).optional(),
201
- durationMs: z.number().nonnegative().optional()
202
- });
203
- var NativeTransformResultSchema = z.object({
204
- code: z.string(),
205
- classes: z.array(z.string()),
206
- changed: z.boolean(),
207
- rsc: z.object({
208
- isServer: z.boolean(),
209
- needsClientDirective: z.boolean(),
210
- clientReasons: z.array(z.string())
211
- }).optional()
212
- });
213
- var NativeCssCompileResultSchema = z.object({
214
- css: z.string(),
215
- resolvedClasses: z.array(z.string()),
216
- unresolvedClasses: z.array(z.string()).optional()
217
- });
218
- z.object({
219
- type: z.enum(["change", "unlink", "create"]),
220
- path: z.string()
221
- });
222
- var NativeWatchResultSchema = z.object({
223
- status: z.enum(["ok", "error"]),
224
- handleId: z.string().optional(),
225
- error: z.string().optional()
226
- });
227
- var NativeCacheEntrySchema = z.object({
228
- file: z.string(),
229
- hash: z.string(),
230
- classes: z.array(z.string()),
231
- timestamp: z.number(),
232
- size: z.number().optional()
233
- });
234
- var NativeCacheReadResultSchema = z.object({
235
- entries: z.array(NativeCacheEntrySchema),
236
- version: z.string().optional()
208
+ var init_compatibility = __esm({
209
+ "packages/domain/shared/src/compatibility.ts"() {
210
+ }
237
211
  });
238
212
  function safeParseNative(schema, data, fallback) {
239
213
  const result = schema.safeParse(data);
@@ -243,17 +217,79 @@ function parseNative(schema, data, context) {
243
217
  const result = schema.safeParse(data);
244
218
  if (!result.success) {
245
219
  const first = result.error.issues[0];
246
- const path3 = first?.path?.join(".") ?? "(root)";
220
+ const path6 = first?.path?.join(".") ?? "(root)";
247
221
  throw new Error(
248
- `[${context}] Native binding returned unexpected data: ${path3}: ${first?.message ?? "validation failed"}`
222
+ `[${context}] Native binding returned unexpected data: ${path6}: ${first?.message ?? "validation failed"}`
249
223
  );
250
224
  }
251
225
  return result.data;
252
226
  }
227
+ var NativeScanFileSchema, NativeScanResultSchema, NativeClassUsageSchema, NativeAnalyzerReportSchema, NativeTransformResultSchema, NativeCssCompileResultSchema, NativeWatchResultSchema, NativeCacheEntrySchema, NativeCacheReadResultSchema;
228
+ var init_native_schemas = __esm({
229
+ "packages/domain/shared/src/native-schemas.ts"() {
230
+ NativeScanFileSchema = z.object({
231
+ file: z.string().min(1, "file path cannot be empty"),
232
+ classes: z.array(z.string()),
233
+ hash: z.string().optional()
234
+ });
235
+ NativeScanResultSchema = z.object({
236
+ files: z.array(NativeScanFileSchema),
237
+ totalFiles: z.number().int().nonnegative(),
238
+ uniqueClasses: z.array(z.string())
239
+ });
240
+ NativeClassUsageSchema = z.object({
241
+ name: z.string(),
242
+ count: z.number().int().nonnegative(),
243
+ files: z.array(z.string()).optional()
244
+ });
245
+ NativeAnalyzerReportSchema = z.object({
246
+ root: z.string(),
247
+ topClasses: z.array(NativeClassUsageSchema).optional(),
248
+ safelist: z.array(z.string()).optional(),
249
+ css: z.string().optional(),
250
+ conflicts: z.array(z.unknown()).optional(),
251
+ unusedClasses: z.array(z.string()).optional(),
252
+ durationMs: z.number().nonnegative().optional()
253
+ });
254
+ NativeTransformResultSchema = z.object({
255
+ code: z.string(),
256
+ classes: z.array(z.string()),
257
+ changed: z.boolean(),
258
+ rsc: z.object({
259
+ isServer: z.boolean(),
260
+ needsClientDirective: z.boolean(),
261
+ clientReasons: z.array(z.string())
262
+ }).optional()
263
+ });
264
+ NativeCssCompileResultSchema = z.object({
265
+ css: z.string(),
266
+ resolvedClasses: z.array(z.string()),
267
+ unresolvedClasses: z.array(z.string()).optional()
268
+ });
269
+ z.object({
270
+ type: z.enum(["change", "unlink", "create"]),
271
+ path: z.string()
272
+ });
273
+ NativeWatchResultSchema = z.object({
274
+ status: z.enum(["ok", "error"]),
275
+ handleId: z.string().optional(),
276
+ error: z.string().optional()
277
+ });
278
+ NativeCacheEntrySchema = z.object({
279
+ file: z.string(),
280
+ hash: z.string(),
281
+ classes: z.array(z.string()),
282
+ timestamp: z.number(),
283
+ size: z.number().optional()
284
+ });
285
+ NativeCacheReadResultSchema = z.object({
286
+ entries: z.array(NativeCacheEntrySchema),
287
+ version: z.string().optional()
288
+ });
289
+ }
290
+ });
253
291
 
254
292
  // packages/domain/shared/src/esmHelpers.ts
255
- var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
256
- var nodeModuleRef = null;
257
293
  function getNodeModuleRef() {
258
294
  if (isBrowser) return null;
259
295
  if (nodeModuleRef !== null) return nodeModuleRef;
@@ -266,9 +302,6 @@ function getNodeModuleRef() {
266
302
  return null;
267
303
  }
268
304
  }
269
- var _nodePath = null;
270
- var _nodeUrl = null;
271
- var _nodeFs = null;
272
305
  function getNodePath() {
273
306
  if (isBrowser) throw new Error("node:path not available in browser");
274
307
  const nodeRequire = getNodeModuleRef();
@@ -336,72 +369,18 @@ function resolveNativeNodePath(importMetaUrl, ...relativeSegments) {
336
369
  if (isBrowser) return relativeSegments.join("/");
337
370
  return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments);
338
371
  }
372
+ var isBrowser, nodeModuleRef, _nodePath, _nodeUrl, _nodeFs;
373
+ var init_esmHelpers = __esm({
374
+ "packages/domain/shared/src/esmHelpers.ts"() {
375
+ isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
376
+ nodeModuleRef = null;
377
+ _nodePath = null;
378
+ _nodeUrl = null;
379
+ _nodeFs = null;
380
+ }
381
+ });
339
382
 
340
383
  // packages/domain/shared/src/telemetry.ts
341
- var RING_BUFFER_SIZE = 100;
342
- var TelemetryCollector = class {
343
- data = [];
344
- enabled;
345
- constructor(enabled) {
346
- this.enabled = enabled ?? (process.env.TWS_TELEMETRY === "1" || process.env.TWS_TELEMETRY === "true");
347
- }
348
- record(build) {
349
- if (!this.enabled) return;
350
- if (this.data.length >= RING_BUFFER_SIZE) {
351
- this.data.shift();
352
- }
353
- this.data.push(build);
354
- }
355
- snapshot() {
356
- return [...this.data];
357
- }
358
- summary() {
359
- if (this.data.length === 0) return null;
360
- const durations = this.data.map((d) => d.durationMs).sort((a, b) => a - b);
361
- const p95Idx = Math.floor(durations.length * 0.95);
362
- const avg = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
363
- return {
364
- totalBuilds: this.data.length,
365
- avgDurationMs: avg(durations),
366
- p95DurationMs: durations[p95Idx] ?? durations[durations.length - 1] ?? 0,
367
- avgCacheHitRate: avg(this.data.map((d) => d.cacheHitRate)),
368
- avgFilesScanned: avg(this.data.map((d) => d.filesScanned)),
369
- avgClassesExtracted: avg(this.data.map((d) => d.classesExtracted)),
370
- phaseAvgs: {
371
- scan: avg(this.data.map((d) => d.phases.scan)),
372
- compile: avg(this.data.map((d) => d.phases.compile)),
373
- engine: avg(this.data.map((d) => d.phases.engine)),
374
- output: avg(this.data.map((d) => d.phases.output))
375
- },
376
- slowestBuildMs: durations[durations.length - 1] ?? 0,
377
- fastestBuildMs: durations[0] ?? 0
378
- };
379
- }
380
- reset() {
381
- this.data = [];
382
- }
383
- /** Format ringkas untuk CLI output */
384
- formatCli() {
385
- const s = this.summary();
386
- if (!s) return "[telemetry] no data";
387
- return [
388
- `[telemetry] ${s.totalBuilds} builds`,
389
- `avg ${s.avgDurationMs.toFixed(0)}ms`,
390
- `p95 ${s.p95DurationMs.toFixed(0)}ms`,
391
- `cache hit ${(s.avgCacheHitRate * 100).toFixed(0)}%`,
392
- `${s.avgFilesScanned.toFixed(0)} files`
393
- ].join(" \xB7 ");
394
- }
395
- /** Export sebagai JSON untuk dashboard/prometheus */
396
- toJSON() {
397
- return {
398
- summary: this.summary(),
399
- history: this.data.slice(-20)
400
- // last 20 builds
401
- };
402
- }
403
- };
404
- var _globalCollector = null;
405
384
  function getGlobalTelemetry() {
406
385
  if (!_globalCollector) {
407
386
  _globalCollector = new TelemetryCollector();
@@ -440,68 +419,75 @@ function createBuildTimer() {
440
419
  }
441
420
  };
442
421
  }
443
- var ScanCacheClassEntrySchema = z.object({
444
- name: z.string().min(1),
445
- usedIn: z.array(z.string()),
446
- risk: z.enum(["low", "medium", "high"]).default("low"),
447
- bundleContribution: z.number().nonnegative().default(0),
448
- variants: z.array(z.string()).default([])
449
- });
450
- var ScanCacheSchema = z.object({
451
- version: z.string().default("1"),
452
- generatedAt: z.string(),
453
- root: z.string(),
454
- classNames: z.array(ScanCacheClassEntrySchema),
455
- totalFiles: z.number().int().nonnegative(),
456
- uniqueCount: z.number().int().nonnegative()
457
- });
458
- var TailwindContentItemSchema = z.union([
459
- z.string(),
460
- z.object({
461
- raw: z.string(),
462
- extension: z.string().optional()
463
- }),
464
- z.object({
465
- files: z.array(z.string()),
466
- transform: z.record(z.string(), z.unknown()).optional()
467
- })
468
- ]);
469
- var TailwindConfigSchema = z.object({
470
- content: z.array(TailwindContentItemSchema).optional(),
471
- theme: z.record(z.string(), z.unknown()).optional(),
472
- plugins: z.array(z.unknown()).optional(),
473
- darkMode: z.union([z.literal("class"), z.literal("media"), z.literal(false)]).optional(),
474
- prefix: z.string().optional(),
475
- safelist: z.array(z.union([z.string(), z.object({ pattern: z.instanceof(RegExp) })])).optional(),
476
- blocklist: z.array(z.string()).optional()
477
- }).passthrough();
478
- var RegistryPluginEntrySchema = z.object({
479
- name: z.string().min(1),
480
- description: z.string(),
481
- version: z.string(),
482
- tags: z.array(z.string()).default([]),
483
- official: z.boolean().default(false),
484
- docs: z.string().url().optional(),
485
- install: z.string().optional(),
486
- integrity: z.string().optional()
487
- });
488
- var RegistryFileSchema = z.object({
489
- version: z.string(),
490
- official: z.array(RegistryPluginEntrySchema).default([]),
491
- community: z.array(RegistryPluginEntrySchema).default([])
422
+ var RING_BUFFER_SIZE, TelemetryCollector, _globalCollector;
423
+ var init_telemetry = __esm({
424
+ "packages/domain/shared/src/telemetry.ts"() {
425
+ RING_BUFFER_SIZE = 100;
426
+ TelemetryCollector = class {
427
+ data = [];
428
+ enabled;
429
+ constructor(enabled) {
430
+ this.enabled = enabled ?? (process.env.TWS_TELEMETRY === "1" || process.env.TWS_TELEMETRY === "true");
431
+ }
432
+ record(build) {
433
+ if (!this.enabled) return;
434
+ if (this.data.length >= RING_BUFFER_SIZE) {
435
+ this.data.shift();
436
+ }
437
+ this.data.push(build);
438
+ }
439
+ snapshot() {
440
+ return [...this.data];
441
+ }
442
+ summary() {
443
+ if (this.data.length === 0) return null;
444
+ const durations = this.data.map((d) => d.durationMs).sort((a, b) => a - b);
445
+ const p95Idx = Math.floor(durations.length * 0.95);
446
+ const avg = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
447
+ return {
448
+ totalBuilds: this.data.length,
449
+ avgDurationMs: avg(durations),
450
+ p95DurationMs: durations[p95Idx] ?? durations[durations.length - 1] ?? 0,
451
+ avgCacheHitRate: avg(this.data.map((d) => d.cacheHitRate)),
452
+ avgFilesScanned: avg(this.data.map((d) => d.filesScanned)),
453
+ avgClassesExtracted: avg(this.data.map((d) => d.classesExtracted)),
454
+ phaseAvgs: {
455
+ scan: avg(this.data.map((d) => d.phases.scan)),
456
+ compile: avg(this.data.map((d) => d.phases.compile)),
457
+ engine: avg(this.data.map((d) => d.phases.engine)),
458
+ output: avg(this.data.map((d) => d.phases.output))
459
+ },
460
+ slowestBuildMs: durations[durations.length - 1] ?? 0,
461
+ fastestBuildMs: durations[0] ?? 0
462
+ };
463
+ }
464
+ reset() {
465
+ this.data = [];
466
+ }
467
+ /** Format ringkas untuk CLI output */
468
+ formatCli() {
469
+ const s = this.summary();
470
+ if (!s) return "[telemetry] no data";
471
+ return [
472
+ `[telemetry] ${s.totalBuilds} builds`,
473
+ `avg ${s.avgDurationMs.toFixed(0)}ms`,
474
+ `p95 ${s.p95DurationMs.toFixed(0)}ms`,
475
+ `cache hit ${(s.avgCacheHitRate * 100).toFixed(0)}%`,
476
+ `${s.avgFilesScanned.toFixed(0)} files`
477
+ ].join(" \xB7 ");
478
+ }
479
+ /** Export sebagai JSON untuk dashboard/prometheus */
480
+ toJSON() {
481
+ return {
482
+ summary: this.summary(),
483
+ history: this.data.slice(-20)
484
+ // last 20 builds
485
+ };
486
+ }
487
+ };
488
+ _globalCollector = null;
489
+ }
492
490
  });
493
- var PackageJsonSchema = z.object({
494
- name: z.string(),
495
- version: z.string(),
496
- scripts: z.record(z.string(), z.string()).optional(),
497
- dependencies: z.record(z.string(), z.string()).optional(),
498
- devDependencies: z.record(z.string(), z.string()).optional(),
499
- peerDependencies: z.record(z.string(), z.string()).optional(),
500
- main: z.string().optional(),
501
- module: z.string().optional(),
502
- exports: z.unknown().optional(),
503
- type: z.enum(["module", "commonjs"]).optional()
504
- }).passthrough();
505
491
  function parseJsonWithSchema(jsonString, schema, sourceName) {
506
492
  let parsed;
507
493
  try {
@@ -532,12 +518,75 @@ function parseJsonFileWithSchema(filePath, schema) {
532
518
  }
533
519
  return parseJsonWithSchema(content, schema, basename(filePath));
534
520
  }
521
+ var ScanCacheClassEntrySchema, ScanCacheSchema, TailwindContentItemSchema, TailwindConfigSchema, RegistryPluginEntrySchema, RegistryFileSchema, PackageJsonSchema;
522
+ var init_configSchemas = __esm({
523
+ "packages/domain/shared/src/configSchemas.ts"() {
524
+ ScanCacheClassEntrySchema = z.object({
525
+ name: z.string().min(1),
526
+ usedIn: z.array(z.string()),
527
+ risk: z.enum(["low", "medium", "high"]).default("low"),
528
+ bundleContribution: z.number().nonnegative().default(0),
529
+ variants: z.array(z.string()).default([])
530
+ });
531
+ ScanCacheSchema = z.object({
532
+ version: z.string().default("1"),
533
+ generatedAt: z.string(),
534
+ root: z.string(),
535
+ classNames: z.array(ScanCacheClassEntrySchema),
536
+ totalFiles: z.number().int().nonnegative(),
537
+ uniqueCount: z.number().int().nonnegative()
538
+ });
539
+ TailwindContentItemSchema = z.union([
540
+ z.string(),
541
+ z.object({
542
+ raw: z.string(),
543
+ extension: z.string().optional()
544
+ }),
545
+ z.object({
546
+ files: z.array(z.string()),
547
+ transform: z.record(z.string(), z.unknown()).optional()
548
+ })
549
+ ]);
550
+ TailwindConfigSchema = z.object({
551
+ content: z.array(TailwindContentItemSchema).optional(),
552
+ theme: z.record(z.string(), z.unknown()).optional(),
553
+ plugins: z.array(z.unknown()).optional(),
554
+ darkMode: z.union([z.literal("class"), z.literal("media"), z.literal(false)]).optional(),
555
+ prefix: z.string().optional(),
556
+ safelist: z.array(z.union([z.string(), z.object({ pattern: z.instanceof(RegExp) })])).optional(),
557
+ blocklist: z.array(z.string()).optional()
558
+ }).passthrough();
559
+ RegistryPluginEntrySchema = z.object({
560
+ name: z.string().min(1),
561
+ description: z.string(),
562
+ version: z.string(),
563
+ tags: z.array(z.string()).default([]),
564
+ official: z.boolean().default(false),
565
+ docs: z.string().url().optional(),
566
+ install: z.string().optional(),
567
+ integrity: z.string().optional()
568
+ });
569
+ RegistryFileSchema = z.object({
570
+ version: z.string(),
571
+ official: z.array(RegistryPluginEntrySchema).default([]),
572
+ community: z.array(RegistryPluginEntrySchema).default([])
573
+ });
574
+ PackageJsonSchema = z.object({
575
+ name: z.string(),
576
+ version: z.string(),
577
+ scripts: z.record(z.string(), z.string()).optional(),
578
+ dependencies: z.record(z.string(), z.string()).optional(),
579
+ devDependencies: z.record(z.string(), z.string()).optional(),
580
+ peerDependencies: z.record(z.string(), z.string()).optional(),
581
+ main: z.string().optional(),
582
+ module: z.string().optional(),
583
+ exports: z.unknown().optional(),
584
+ type: z.enum(["module", "commonjs"]).optional()
585
+ }).passthrough();
586
+ }
587
+ });
535
588
 
536
589
  // packages/domain/shared/src/workerResolver.ts
537
- var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
538
- var NODE_URL = typeof window === "undefined" || typeof document === "undefined" ? "node:url" : null;
539
- var NODE_FS = typeof window === "undefined" || typeof document === "undefined" ? "node:fs" : null;
540
- var NODE_PATH = typeof window === "undefined" || typeof document === "undefined" ? "node:path" : null;
541
590
  function getDirnameFromUrl(importMetaUrl) {
542
591
  if (!importMetaUrl) return "";
543
592
  if (isBrowser2) return "";
@@ -563,11 +612,11 @@ function resolvePath(...segments) {
563
612
  return segments.join("/").replace(/\/+/g, "/");
564
613
  }
565
614
  }
566
- function existsSync(path3) {
615
+ function existsSync(path6) {
567
616
  if (isBrowser2) return false;
568
617
  try {
569
618
  const nodeFs = __require(NODE_FS);
570
- return nodeFs.existsSync(path3);
619
+ return nodeFs.existsSync(path6);
571
620
  } catch {
572
621
  return false;
573
622
  }
@@ -617,6 +666,15 @@ function resolveLoaderPath(loaderBasename, importMetaUrl) {
617
666
  subdirs: [".", "loaders", "lib"]
618
667
  }).path;
619
668
  }
669
+ var isBrowser2, NODE_URL, NODE_FS, NODE_PATH;
670
+ var init_workerResolver = __esm({
671
+ "packages/domain/shared/src/workerResolver.ts"() {
672
+ isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
673
+ NODE_URL = typeof window === "undefined" || typeof document === "undefined" ? "node:url" : null;
674
+ NODE_FS = typeof window === "undefined" || typeof document === "undefined" ? "node:fs" : null;
675
+ NODE_PATH = typeof window === "undefined" || typeof document === "undefined" ? "node:path" : null;
676
+ }
677
+ });
620
678
 
621
679
  // packages/domain/shared/src/codegen.ts
622
680
  function generateComponentCode(opts) {
@@ -774,16 +832,10 @@ function generateBarrelFile(exports$1, dir, opts = {}) {
774
832
  }
775
833
  return lines.join("\n");
776
834
  }
777
- var isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
778
- var _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
779
- var PLATFORM_MAP = {
780
- "linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
781
- "linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
782
- "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
783
- "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
784
- "win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
785
- "win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
786
- };
835
+ var init_codegen = __esm({
836
+ "packages/domain/shared/src/codegen.ts"() {
837
+ }
838
+ });
787
839
  function platformKey() {
788
840
  if (isBrowser3) return "browser";
789
841
  return `${process.platform}-${process.arch}`;
@@ -794,12 +846,12 @@ function resolveNativeBinary(runtimeDir) {
794
846
  if (isBrowser3) {
795
847
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
796
848
  }
797
- if (process.env.TWS_DISABLE_NATIVE === "1") {
849
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
798
850
  return { path: null, source: "not-found", platform, tried: [] };
799
851
  }
800
852
  const envPath = process.env.TW_NATIVE_PATH?.trim();
801
853
  if (envPath) {
802
- if (fs.existsSync(envPath)) {
854
+ if (fs3.existsSync(envPath)) {
803
855
  return { path: envPath, source: "env", platform, tried };
804
856
  }
805
857
  tried.push(`env:${envPath} (not found)`);
@@ -808,7 +860,7 @@ function resolveNativeBinary(runtimeDir) {
808
860
  for (const pkg of prebuiltPkgs) {
809
861
  try {
810
862
  const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
811
- if (fs.existsSync(candidate)) {
863
+ if (fs3.existsSync(candidate)) {
812
864
  return { path: candidate, source: "prebuilt", platform, tried };
813
865
  }
814
866
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -825,7 +877,7 @@ function resolveNativeBinary(runtimeDir) {
825
877
  for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
826
878
  const candidate = path.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
827
879
  tried.push(`self-bundled:${candidate}`);
828
- if (fs.existsSync(candidate)) {
880
+ if (fs3.existsSync(candidate)) {
829
881
  return { path: candidate, source: "prebuilt", platform, tried };
830
882
  }
831
883
  }
@@ -859,7 +911,7 @@ function resolveNativeBinary(runtimeDir) {
859
911
  }
860
912
  for (const candidate of localCandidates) {
861
913
  tried.push(`local:${candidate}`);
862
- if (fs.existsSync(candidate)) {
914
+ if (fs3.existsSync(candidate)) {
863
915
  return { path: candidate, source: "local", platform, tried };
864
916
  }
865
917
  }
@@ -879,13 +931,28 @@ function formatNativeNotFoundError(result) {
879
931
  ];
880
932
  return lines.join("\n");
881
933
  }
934
+ var isBrowser3, _require, PLATFORM_MAP;
935
+ var init_native_resolution = __esm({
936
+ "packages/domain/shared/src/native-resolution.ts"() {
937
+ isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
938
+ _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
939
+ PLATFORM_MAP = {
940
+ "linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
941
+ "linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
942
+ "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
943
+ "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
944
+ "win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
945
+ "win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
946
+ };
947
+ }
948
+ });
882
949
 
883
950
  // packages/domain/shared/src/observability.ts
884
951
  function createObservabilityClient(opts = {}) {
885
952
  const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
886
- async function fetchJson(path3) {
953
+ async function fetchJson(path6) {
887
954
  try {
888
- const res = await fetch(`${baseUrl}${path3}`, {
955
+ const res = await fetch(`${baseUrl}${path6}`, {
889
956
  signal: AbortSignal.timeout(timeoutMs)
890
957
  });
891
958
  if (!res.ok) return null;
@@ -912,9 +979,1187 @@ function createObservabilityClient(opts = {}) {
912
979
  }
913
980
  };
914
981
  }
982
+ var init_observability = __esm({
983
+ "packages/domain/shared/src/observability.ts"() {
984
+ }
985
+ });
986
+
987
+ // packages/domain/compiler/src/nativeBridge.ts
988
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, adaptNativeResult;
989
+ var init_nativeBridge = __esm({
990
+ "packages/domain/compiler/src/nativeBridge.ts"() {
991
+ init_src2();
992
+ _loadNative = (path6) => __require(path6);
993
+ log = (...args) => {
994
+ if (process.env.DEBUG?.includes("compiler:native")) {
995
+ console.log("[compiler:native]", ...args);
996
+ }
997
+ };
998
+ 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";
999
+ nativeBridge = null;
1000
+ bridgeLoadAttempted = false;
1001
+ bridgeLoadError = null;
1002
+ isValidNativeBridge = (mod) => {
1003
+ const m = mod;
1004
+ return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
1005
+ };
1006
+ getNativeBridge = () => {
1007
+ if (nativeBridge) {
1008
+ return nativeBridge;
1009
+ }
1010
+ if (bridgeLoadAttempted) {
1011
+ if (bridgeLoadError) {
1012
+ throw bridgeLoadError;
1013
+ }
1014
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
1015
+ }
1016
+ bridgeLoadAttempted = true;
1017
+ try {
1018
+ const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
1019
+ const result = resolveNativeBinary(runtimeDir);
1020
+ if (result.path && result.path.endsWith(".node")) {
1021
+ try {
1022
+ const binding = _loadNative(result.path);
1023
+ if (isValidNativeBridge(binding)) {
1024
+ nativeBridge = binding;
1025
+ log("Native bridge loaded successfully from:", result.path);
1026
+ return nativeBridge;
1027
+ }
1028
+ } catch (e) {
1029
+ log("Failed to require native binding:", e);
1030
+ }
1031
+ }
1032
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
1033
+
1034
+ Tried paths: ${result.tried.join("\n")}`);
1035
+ } catch (err) {
1036
+ bridgeLoadError = err instanceof Error ? err : new Error(String(err));
1037
+ log("Failed to load native bridge:", bridgeLoadError.message);
1038
+ throw bridgeLoadError;
1039
+ }
1040
+ };
1041
+ adaptNativeResult = (raw) => {
1042
+ return {
1043
+ code: raw.code ?? "",
1044
+ classes: raw.classes ?? [],
1045
+ changed: raw.changed ?? false,
1046
+ rsc: raw.rscJson ? JSON.parse(raw.rscJson) : void 0,
1047
+ metadata: raw.metadataJson ? JSON.parse(raw.metadataJson) : void 0
1048
+ };
1049
+ };
1050
+ if (typeof process !== "undefined" && !bridgeLoadAttempted) {
1051
+ try {
1052
+ getNativeBridge();
1053
+ } catch {
1054
+ }
1055
+ }
1056
+ }
1057
+ });
1058
+
1059
+ // packages/domain/compiler/src/tailwindEngine.ts
1060
+ var tailwindEngine_exports = {};
1061
+ __export(tailwindEngine_exports, {
1062
+ clearCache: () => clearCache,
1063
+ generateRawCss: () => generateRawCss,
1064
+ getCacheStats: () => getCacheStats,
1065
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
1066
+ runCssPipeline: () => runCssPipeline,
1067
+ runCssPipelineSync: () => runCssPipelineSync
1068
+ });
1069
+ function _getCacheKey(classes, minify, cssEntry, root) {
1070
+ const sorted = [...classes].sort().join(",");
1071
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
1072
+ return `${sorted}|${flags}`;
1073
+ }
1074
+ function _evictOldestIfNeeded() {
1075
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
1076
+ const firstKey = _cssCache.keys().next().value;
1077
+ if (firstKey !== void 0) {
1078
+ _cssCache.delete(firstKey);
1079
+ }
1080
+ }
1081
+ }
1082
+ function getCacheStats() {
1083
+ const total = _cacheHits + _cacheMisses;
1084
+ return {
1085
+ hits: _cacheHits,
1086
+ misses: _cacheMisses,
1087
+ hitRate: total > 0 ? _cacheHits / total : 0,
1088
+ size: _cssCache.size,
1089
+ maxSize: MAX_CACHE_SIZE
1090
+ };
1091
+ }
1092
+ function clearCache() {
1093
+ _cssCache.clear();
1094
+ _cacheHits = 0;
1095
+ _cacheMisses = 0;
1096
+ }
1097
+ function loadTailwindEngine() {
1098
+ if (_twEngine) return _twEngine;
1099
+ if (_twEngineError) throw _twEngineError;
1100
+ try {
1101
+ const tw = require2("tailwindcss");
1102
+ if (typeof tw.compile !== "function") {
1103
+ throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
1104
+ }
1105
+ _twEngine = tw;
1106
+ return _twEngine;
1107
+ } catch (e) {
1108
+ _twEngineError = e instanceof Error ? e : new Error(String(e));
1109
+ throw _twEngineError;
1110
+ }
1111
+ }
1112
+ async function generateRawCss(classes, cssEntryContent, root) {
1113
+ if (classes.length === 0) return "";
1114
+ const tw = loadTailwindEngine();
1115
+ const input = cssEntryContent ?? "@import 'tailwindcss';";
1116
+ const { readFileSync, existsSync: existsSync3 } = await import('fs');
1117
+ const { dirname, resolve: resolve2 } = await import('path');
1118
+ const projectRoot = root ?? process.cwd();
1119
+ const req = createRequire(resolve2(projectRoot, "package.json"));
1120
+ const loadStylesheet = async (id, base) => {
1121
+ try {
1122
+ const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
1123
+ const pkgPath = req.resolve(cssId);
1124
+ return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
1125
+ } catch {
1126
+ try {
1127
+ const absPath = resolve2(base, id);
1128
+ if (existsSync3(absPath)) {
1129
+ return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
1130
+ }
1131
+ } catch {
1132
+ }
1133
+ return { content: "", base };
1134
+ }
1135
+ };
1136
+ const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
1137
+ return compiler.build(classes);
1138
+ }
1139
+ function getThemeConfig() {
1140
+ return {
1141
+ colors: {
1142
+ slate: {
1143
+ "50": "#f8fafc",
1144
+ "100": "#f1f5f9",
1145
+ "200": "#e2e8f0",
1146
+ "300": "#cbd5e1",
1147
+ "400": "#94a3b8",
1148
+ "500": "#64748b",
1149
+ "600": "#475569",
1150
+ "700": "#334155",
1151
+ "800": "#1e293b",
1152
+ "900": "#0f172a"
1153
+ },
1154
+ gray: {
1155
+ "50": "#f9fafb",
1156
+ "100": "#f3f4f6",
1157
+ "200": "#e5e7eb",
1158
+ "300": "#d1d5db",
1159
+ "400": "#9ca3af",
1160
+ "500": "#6b7280",
1161
+ "600": "#4b5563",
1162
+ "700": "#374151",
1163
+ "800": "#1f2937",
1164
+ "900": "#111827"
1165
+ },
1166
+ white: "#ffffff",
1167
+ black: "#000000",
1168
+ red: {
1169
+ "500": "#ef4444",
1170
+ "600": "#dc2626"
1171
+ },
1172
+ blue: {
1173
+ "500": "#3b82f6",
1174
+ "600": "#1e40af"
1175
+ }
1176
+ },
1177
+ spacing: {
1178
+ "0": "0px",
1179
+ "1": "0.25rem",
1180
+ "2": "0.5rem",
1181
+ "3": "0.75rem",
1182
+ "4": "1rem",
1183
+ "5": "1.25rem",
1184
+ "6": "1.5rem",
1185
+ "8": "2rem",
1186
+ "10": "2.5rem",
1187
+ "12": "3rem",
1188
+ "16": "4rem",
1189
+ "20": "5rem",
1190
+ "24": "6rem"
1191
+ },
1192
+ breakpoints: {
1193
+ "sm": "640px",
1194
+ "md": "768px",
1195
+ "lg": "1024px",
1196
+ "xl": "1280px",
1197
+ "2xl": "1536px"
1198
+ }
1199
+ };
1200
+ }
1201
+ function postProcessWithLightning(rawCss) {
1202
+ if (!rawCss) return "";
1203
+ const native = getNativeBridge();
1204
+ if (!native?.processTailwindCssLightning) {
1205
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1206
+ }
1207
+ const result = native.processTailwindCssLightning(rawCss);
1208
+ if (!result?.css) {
1209
+ throw new Error("FATAL: processTailwindCssLightning returned null");
1210
+ }
1211
+ return result.css;
1212
+ }
1213
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
1214
+ const filtered = classes.filter(Boolean);
1215
+ const uniqueMap = /* @__PURE__ */ new Map();
1216
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
1217
+ const unique = Array.from(uniqueMap.values());
1218
+ if (unique.length === 0) {
1219
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1220
+ }
1221
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
1222
+ const cached = _cssCache.get(cacheKey);
1223
+ if (cached) {
1224
+ _cacheHits++;
1225
+ if (process.env.DEBUG?.includes("compiler")) {
1226
+ console.log(
1227
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
1228
+ );
1229
+ }
1230
+ return cached;
1231
+ }
1232
+ _cacheMisses++;
1233
+ let rawCss;
1234
+ let usedRustCompiler = false;
1235
+ try {
1236
+ const theme = getThemeConfig();
1237
+ rawCss = await generateCssNative(unique, {
1238
+ theme,
1239
+ fallbackToJs: true,
1240
+ logFallback: process.env.DEBUG?.includes("compiler") === true
1241
+ });
1242
+ usedRustCompiler = true;
1243
+ } catch (error) {
1244
+ if (process.env.DEBUG?.includes("compiler")) {
1245
+ console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
1246
+ }
1247
+ rawCss = await generateRawCss(unique, cssEntryContent, root);
1248
+ }
1249
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
1250
+ if (process.env.DEBUG?.includes("compiler")) {
1251
+ console.log(
1252
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
1253
+ `Size: ${finalCss.length} bytes`
1254
+ );
1255
+ }
1256
+ const result = {
1257
+ css: finalCss,
1258
+ classes: unique,
1259
+ sizeBytes: finalCss.length,
1260
+ optimized: minify
1261
+ };
1262
+ _evictOldestIfNeeded();
1263
+ _cssCache.set(cacheKey, result);
1264
+ return result;
1265
+ }
1266
+ function runCssPipelineSync(_classes) {
1267
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
1268
+ }
1269
+ function processTailwindCssWithTargets(css, targets) {
1270
+ const native = getNativeBridge();
1271
+ if (!native?.processTailwindCssWithTargets) {
1272
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
1273
+ }
1274
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
1275
+ if (!result?.css) {
1276
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
1277
+ }
1278
+ return result.css;
1279
+ }
1280
+ var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
1281
+ var init_tailwindEngine = __esm({
1282
+ "packages/domain/compiler/src/tailwindEngine.ts"() {
1283
+ init_nativeBridge();
1284
+ init_cssGeneratorNative();
1285
+ require2 = createRequire(import.meta.url);
1286
+ _cssCache = /* @__PURE__ */ new Map();
1287
+ _cacheHits = 0;
1288
+ _cacheMisses = 0;
1289
+ MAX_CACHE_SIZE = 100;
1290
+ _twEngine = null;
1291
+ _twEngineError = null;
1292
+ }
1293
+ });
1294
+
1295
+ // packages/domain/compiler/src/cssGeneratorNative.ts
1296
+ async function generateCssNative(classes, options) {
1297
+ const {
1298
+ theme,
1299
+ fallbackToJs = true,
1300
+ logFallback = false
1301
+ } = options;
1302
+ try {
1303
+ const native = getNativeBridge();
1304
+ if (!native?.generateCssNative) {
1305
+ throw new Error("generateCssNative not available in native binding");
1306
+ }
1307
+ const themeJson = JSON.stringify(theme);
1308
+ const css = native.generateCssNative(classes, themeJson);
1309
+ return css;
1310
+ } catch (error) {
1311
+ if (!fallbackToJs) {
1312
+ throw error;
1313
+ }
1314
+ if (logFallback) {
1315
+ console.warn(
1316
+ "[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
1317
+ error instanceof Error ? error.message : String(error)
1318
+ );
1319
+ }
1320
+ return generateRawCss(classes);
1321
+ }
1322
+ }
1323
+ var init_cssGeneratorNative = __esm({
1324
+ "packages/domain/compiler/src/cssGeneratorNative.ts"() {
1325
+ init_nativeBridge();
1326
+ init_tailwindEngine();
1327
+ }
1328
+ });
1329
+ function _layoutClassesToCss(classes) {
1330
+ const native = getNativeBridge();
1331
+ if (!native?.layoutClassesToCss) {
1332
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
1333
+ }
1334
+ return native.layoutClassesToCss(classes);
1335
+ }
1336
+ function _hashContainer(tag, containerJson, name) {
1337
+ const sortedKey = tag + (name ?? "") + containerJson;
1338
+ const native = getNativeBridge();
1339
+ if (!native?.hashContent) {
1340
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
1341
+ }
1342
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
1343
+ }
1344
+ function extractContainerCssFromSource(source) {
1345
+ const native = getNativeBridge();
1346
+ if (!native?.extractTwContainerConfigs) {
1347
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
1348
+ }
1349
+ const configs = native.extractTwContainerConfigs(source);
1350
+ const rules = [];
1351
+ for (const cfg of configs) {
1352
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
1353
+ for (const { key, classes } of cfg.breakpoints) {
1354
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
1355
+ const css = _layoutClassesToCss(classes);
1356
+ if (!css) continue;
1357
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
1358
+ rules.push(`${query}{.${id}{${css}}}`);
1359
+ }
1360
+ }
1361
+ return rules.join("\n");
1362
+ }
1363
+ var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
1364
+ var init_src = __esm({
1365
+ "packages/domain/compiler/src/index.ts"() {
1366
+ init_nativeBridge();
1367
+ transformSource = (source, opts) => {
1368
+ const native = getNativeBridge();
1369
+ if (!native?.transformSource) {
1370
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1371
+ }
1372
+ const result = native.transformSource(source, opts);
1373
+ if (!result) {
1374
+ throw new Error("FATAL: transformSource returned null");
1375
+ }
1376
+ return result;
1377
+ };
1378
+ hasTwUsage = (source) => {
1379
+ const native = getNativeBridge();
1380
+ if (!native?.hasTwUsage) {
1381
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
1382
+ }
1383
+ return native.hasTwUsage(source);
1384
+ };
1385
+ isAlreadyTransformed = (source) => {
1386
+ const native = getNativeBridge();
1387
+ if (!native?.isAlreadyTransformed) {
1388
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
1389
+ }
1390
+ return native.isAlreadyTransformed(source);
1391
+ };
1392
+ shouldProcess = (source) => {
1393
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
1394
+ };
1395
+ compileCssFromClasses = (classes, prefix) => {
1396
+ const native = getNativeBridge();
1397
+ if (!native?.transformSource) {
1398
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1399
+ }
1400
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
1401
+ if (!result) {
1402
+ throw new Error("FATAL: transformSource returned null");
1403
+ }
1404
+ return result;
1405
+ };
1406
+ buildStyleTag = (classes) => {
1407
+ const result = compileCssFromClasses(classes);
1408
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
1409
+ };
1410
+ compileCssNative = (classes, prefix = null) => {
1411
+ return compileCssFromClasses(classes, prefix);
1412
+ };
1413
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1414
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
1415
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1416
+ return result.css;
1417
+ };
1418
+ extractAllClasses = (source) => {
1419
+ const native = getNativeBridge();
1420
+ if (!native?.extractAllClasses) {
1421
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1422
+ }
1423
+ return native.extractAllClasses(source) || [];
1424
+ };
1425
+ extractClassesFromSource = (source) => {
1426
+ const native = getNativeBridge();
1427
+ if (!native?.extractClassesFromSource) {
1428
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1429
+ }
1430
+ const result = native.extractClassesFromSource(source);
1431
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1432
+ };
1433
+ astExtractClasses = (source, _filename) => {
1434
+ const native = getNativeBridge();
1435
+ if (!native?.extractClassesFromSource) {
1436
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1437
+ }
1438
+ return native.extractClassesFromSource(source) || [];
1439
+ };
1440
+ parseClasses = (raw) => {
1441
+ const native = getNativeBridge();
1442
+ if (!native?.parseClasses) {
1443
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1444
+ }
1445
+ return native.parseClasses(raw) || [];
1446
+ };
1447
+ normalizeClasses = (raw) => {
1448
+ const result = normalizeAndDedupClasses(raw);
1449
+ return result?.normalized || "";
1450
+ };
1451
+ mergeClassesStatic = (classes) => {
1452
+ const result = normalizeAndDedupClasses(classes);
1453
+ return result?.normalized || "";
1454
+ };
1455
+ normalizeAndDedupClasses = (raw) => {
1456
+ const native = getNativeBridge();
1457
+ if (!native?.normalizeAndDedupClasses) {
1458
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1459
+ }
1460
+ const result = native.normalizeAndDedupClasses(raw);
1461
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1462
+ };
1463
+ eliminateDeadCss = (css, deadClasses) => {
1464
+ const native = getNativeBridge();
1465
+ if (!native?.eliminateDeadCss) {
1466
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
1467
+ }
1468
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
1469
+ };
1470
+ findDeadVariants = (variantConfig, usage) => {
1471
+ const unused = [];
1472
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
1473
+ for (const component of configs) {
1474
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
1475
+ const variants = component.variants;
1476
+ for (const [key, values] of Object.entries(variants)) {
1477
+ for (const [value] of Object.entries(values)) {
1478
+ if (!componentUsage.has(`${key}:${value}`)) {
1479
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
1480
+ }
1481
+ }
1482
+ }
1483
+ }
1484
+ return { unusedCount: unused.length, unused };
1485
+ };
1486
+ runElimination = (css, scanResult) => {
1487
+ const native = getNativeBridge();
1488
+ if (!native?.detectDeadCode) {
1489
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
1490
+ }
1491
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
1492
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
1493
+ };
1494
+ optimizeCss = (css) => {
1495
+ const native = getNativeBridge();
1496
+ if (!native?.optimizeCss) {
1497
+ throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
1498
+ }
1499
+ return native.optimizeCss(css);
1500
+ };
1501
+ scanProjectUsage = (dirs, cwd) => {
1502
+ const files = dirs.map((dir) => path__default.resolve(cwd, dir));
1503
+ const results = batchExtractClasses(files) || [];
1504
+ const combined = {};
1505
+ for (const result of results) {
1506
+ if (result.ok && result.classes) {
1507
+ for (const cls of result.classes) {
1508
+ if (!combined[cls]) combined[cls] = {};
1509
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
1510
+ }
1511
+ }
1512
+ }
1513
+ return combined;
1514
+ };
1515
+ extractComponentUsage = (source) => {
1516
+ const native = getNativeBridge();
1517
+ if (!native?.extractComponentUsage) {
1518
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1519
+ }
1520
+ return native.extractComponentUsage(source) || [];
1521
+ };
1522
+ diffClassLists = (previous, current) => {
1523
+ const native = getNativeBridge();
1524
+ if (!native?.diffClassLists) {
1525
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1526
+ }
1527
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1528
+ };
1529
+ batchExtractClasses = (filePaths) => {
1530
+ const native = getNativeBridge();
1531
+ if (!native?.batchExtractClasses) {
1532
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1533
+ }
1534
+ return native.batchExtractClasses(filePaths) || [];
1535
+ };
1536
+ checkAgainstSafelist = (classes, safelist) => {
1537
+ const native = getNativeBridge();
1538
+ if (!native?.checkAgainstSafelist) {
1539
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1540
+ }
1541
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1542
+ };
1543
+ hoistComponents = (source) => {
1544
+ const native = getNativeBridge();
1545
+ if (!native?.hoistComponents) {
1546
+ throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
1547
+ }
1548
+ return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
1549
+ };
1550
+ compileVariantTable = (configJson) => {
1551
+ const native = getNativeBridge();
1552
+ if (!native?.compileVariantTable) {
1553
+ throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
1554
+ }
1555
+ return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
1556
+ };
1557
+ compileVariants = (componentId, config) => {
1558
+ return compileVariantTable(JSON.stringify({ componentId, ...config }));
1559
+ };
1560
+ classifyAndSortClasses = (classes) => {
1561
+ const native = getNativeBridge();
1562
+ if (!native?.classifyAndSortClasses) {
1563
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1564
+ }
1565
+ return native.classifyAndSortClasses(classes) || [];
1566
+ };
1567
+ mergeCssDeclarations = (cssChunks) => {
1568
+ const native = getNativeBridge();
1569
+ if (!native?.mergeCssDeclarations) {
1570
+ throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
1571
+ }
1572
+ return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
1573
+ };
1574
+ analyzeClassUsage = (classes, scanResultJson, css) => {
1575
+ const native = getNativeBridge();
1576
+ if (!native?.analyzeClassUsage) {
1577
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
1578
+ }
1579
+ return native.analyzeClassUsage(classes, scanResultJson, css) || [];
1580
+ };
1581
+ analyzeRsc = (source, filename) => {
1582
+ const native = getNativeBridge();
1583
+ if (!native?.analyzeRsc) {
1584
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
1585
+ }
1586
+ return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
1587
+ };
1588
+ analyzeFile = (source, filename) => {
1589
+ const rsc = analyzeRsc(source, filename);
1590
+ return {
1591
+ isServer: rsc?.isServer ?? true,
1592
+ needsClientDirective: rsc?.needsClientDirective ?? false,
1593
+ clientReasons: rsc?.clientReasons ?? [],
1594
+ interactiveClasses: [],
1595
+ canStaticResolveVariants: true
1596
+ };
1597
+ };
1598
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
1599
+ return { resolved: {}, dynamic: [] };
1600
+ };
1601
+ injectClientDirective = (source) => {
1602
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
1603
+ return '"use client";\n' + source;
1604
+ }
1605
+ return source;
1606
+ };
1607
+ injectServerOnlyComment = (source) => {
1608
+ return `/* @server-only */
1609
+ ${source}`;
1610
+ };
1611
+ analyzeClasses = (filesJson, cwd, flags) => {
1612
+ const native = getNativeBridge();
1613
+ if (!native?.analyzeClasses) {
1614
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
1615
+ }
1616
+ return native.analyzeClasses(filesJson, cwd, flags);
1617
+ };
1618
+ generateSafelist = (scanDirs, outputPath, cwd) => {
1619
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
1620
+ const allClasses = Object.keys(classes).sort();
1621
+ if (outputPath) {
1622
+ fs3__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
1623
+ }
1624
+ return allClasses;
1625
+ };
1626
+ loadSafelist = (safelistPath) => {
1627
+ try {
1628
+ const content = fs3__default.readFileSync(safelistPath, "utf-8");
1629
+ return JSON.parse(content);
1630
+ } catch {
1631
+ return [];
1632
+ }
1633
+ };
1634
+ loadTailwindConfig = (cwd = process.cwd()) => {
1635
+ const configFiles = [
1636
+ "tailwind.config.ts",
1637
+ "tailwind.config.js",
1638
+ "tailwind.config.mjs",
1639
+ "tailwind.config.cjs"
1640
+ ];
1641
+ for (const file of configFiles) {
1642
+ const fullPath = path__default.join(cwd, file);
1643
+ if (fs3__default.existsSync(fullPath)) {
1644
+ const mod = __require(fullPath);
1645
+ return mod.default || mod;
1646
+ }
1647
+ }
1648
+ return {};
1649
+ };
1650
+ getContentPaths = (cwd = process.cwd()) => {
1651
+ return {
1652
+ content: [
1653
+ path__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
1654
+ path__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
1655
+ path__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
1656
+ ]
1657
+ };
1658
+ };
1659
+ _CONTAINER_BREAKPOINTS = {
1660
+ xs: "240px",
1661
+ sm: "320px",
1662
+ md: "640px",
1663
+ lg: "1024px",
1664
+ xl: "1280px",
1665
+ "2xl": "1536px"
1666
+ };
1667
+ runLoaderTransform = (ctx) => {
1668
+ const { filepath, source, options } = ctx;
1669
+ const result = transformSource(source, { filename: filepath, ...options });
1670
+ let staticCss;
1671
+ try {
1672
+ const cssChunks = [];
1673
+ const stateRules = extractAndGenerateStateCss(source, filepath);
1674
+ if (stateRules.length > 0) {
1675
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
1676
+ }
1677
+ const containerCss = extractContainerCssFromSource(source);
1678
+ if (containerCss) cssChunks.push(containerCss);
1679
+ const combined = cssChunks.join("\n").trim();
1680
+ if (combined) staticCss = combined;
1681
+ } catch {
1682
+ }
1683
+ return {
1684
+ code: result?.code || "",
1685
+ changed: result?.changed || false,
1686
+ classes: result?.classes || [],
1687
+ staticCss
1688
+ };
1689
+ };
1690
+ shouldSkipFile = (filepath) => {
1691
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
1692
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
1693
+ for (const p of SKIP_PATHS) {
1694
+ if (filepath.includes(p)) return true;
1695
+ }
1696
+ for (const ext of skipExtensions) {
1697
+ if (filepath.endsWith(ext)) return true;
1698
+ }
1699
+ return false;
1700
+ };
1701
+ fileToRoute = (filepath) => {
1702
+ const normalized = filepath.replace(/\\/g, "/");
1703
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
1704
+ return "__global";
1705
+ }
1706
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
1707
+ if (pageMatch) return `/${pageMatch[1]}`;
1708
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
1709
+ if (rootPage) return "/";
1710
+ return null;
1711
+ };
1712
+ getAllRoutes = () => {
1713
+ const native = getNativeBridge();
1714
+ if (!native?.analyzeClasses) {
1715
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
1716
+ }
1717
+ return ["/", "__global"];
1718
+ };
1719
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
1720
+ registerFileClasses = (_filepath, _classes) => {
1721
+ };
1722
+ registerGlobalClasses = (_classes) => {
1723
+ };
1724
+ _incrementalEngineInstance = null;
1725
+ getIncrementalEngine = () => {
1726
+ if (!_incrementalEngineInstance) {
1727
+ _incrementalEngineInstance = new IncrementalEngine();
1728
+ }
1729
+ return _incrementalEngineInstance;
1730
+ };
1731
+ resetIncrementalEngine = () => {
1732
+ _incrementalEngineInstance = null;
1733
+ };
1734
+ IncrementalEngine = class {
1735
+ compile(source) {
1736
+ return transformSource(source);
1737
+ }
1738
+ };
1739
+ getBucketEngine = () => {
1740
+ const native = getNativeBridge();
1741
+ if (!native?.classifyAndSortClasses) {
1742
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1743
+ }
1744
+ return {
1745
+ add: (className) => className,
1746
+ get: (_bucket) => []
1747
+ };
1748
+ };
1749
+ resetBucketEngine = () => {
1750
+ };
1751
+ classifyNode = (_node) => {
1752
+ const native = getNativeBridge();
1753
+ if (!native?.classifyAndSortClasses) {
1754
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1755
+ }
1756
+ return "unknown";
1757
+ };
1758
+ detectConflicts = (_classes) => {
1759
+ const native = getNativeBridge();
1760
+ if (!native?.analyzeClassUsage) {
1761
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
1762
+ }
1763
+ return [];
1764
+ };
1765
+ bucketSort = (classes) => {
1766
+ return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
1767
+ };
1768
+ extractTwStateConfigs = (source, filename) => {
1769
+ const native = getNativeBridge();
1770
+ if (!native?.extractTwStateConfigs) {
1771
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
1772
+ }
1773
+ return native.extractTwStateConfigs(source, filename);
1774
+ };
1775
+ generateStaticStateCss = (inputs, resolvedCss = null) => {
1776
+ const native = getNativeBridge();
1777
+ if (!native?.generateStaticStateCss) {
1778
+ throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
1779
+ }
1780
+ return native.generateStaticStateCss(inputs, resolvedCss);
1781
+ };
1782
+ extractAndGenerateStateCss = (source, filename) => {
1783
+ const native = getNativeBridge();
1784
+ if (!native?.extractAndGenerateStateCss) {
1785
+ const configs = extractTwStateConfigs(source, filename);
1786
+ if (configs.length === 0) return [];
1787
+ return generateStaticStateCss(
1788
+ configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
1789
+ );
1790
+ }
1791
+ return native.extractAndGenerateStateCss(source, filename);
1792
+ };
1793
+ }
1794
+ });
915
1795
 
916
- // packages/domain/shared/src/index.ts
917
- function createLogger(namespace) {
1796
+ // packages/domain/compiler/src/internal.ts
1797
+ var internal_exports = {};
1798
+ __export(internal_exports, {
1799
+ adaptNativeResult: () => adaptNativeResult,
1800
+ analyzeClassUsage: () => analyzeClassUsage,
1801
+ analyzeClasses: () => analyzeClasses,
1802
+ analyzeFile: () => analyzeFile,
1803
+ analyzeRsc: () => analyzeRsc,
1804
+ analyzeVariantUsage: () => analyzeVariantUsage,
1805
+ astExtractClasses: () => astExtractClasses,
1806
+ batchExtractClasses: () => batchExtractClasses,
1807
+ bucketSort: () => bucketSort,
1808
+ buildStyleTag: () => buildStyleTag,
1809
+ checkAgainstSafelist: () => checkAgainstSafelist,
1810
+ classifyAndSortClasses: () => classifyAndSortClasses,
1811
+ classifyNode: () => classifyNode,
1812
+ clearCache: () => clearCache,
1813
+ compileCssFromClasses: () => compileCssFromClasses,
1814
+ compileCssNative: () => compileCssNative,
1815
+ compileVariantTable: () => compileVariantTable,
1816
+ compileVariants: () => compileVariants,
1817
+ detectConflicts: () => detectConflicts,
1818
+ diffClassLists: () => diffClassLists,
1819
+ eliminateDeadCss: () => eliminateDeadCss,
1820
+ extractAllClasses: () => extractAllClasses,
1821
+ extractAndGenerateStateCss: () => extractAndGenerateStateCss,
1822
+ extractClassesFromSource: () => extractClassesFromSource,
1823
+ extractComponentUsage: () => extractComponentUsage,
1824
+ extractContainerCssFromSource: () => extractContainerCssFromSource,
1825
+ extractTwStateConfigs: () => extractTwStateConfigs,
1826
+ fileToRoute: () => fileToRoute,
1827
+ findDeadVariants: () => findDeadVariants,
1828
+ generateCssForClasses: () => generateCssForClasses,
1829
+ generateRawCss: () => generateRawCss,
1830
+ generateSafelist: () => generateSafelist,
1831
+ generateStaticStateCss: () => generateStaticStateCss,
1832
+ getAllRoutes: () => getAllRoutes,
1833
+ getBucketEngine: () => getBucketEngine,
1834
+ getCacheStats: () => getCacheStats,
1835
+ getContentPaths: () => getContentPaths,
1836
+ getIncrementalEngine: () => getIncrementalEngine,
1837
+ getNativeBridge: () => getNativeBridge,
1838
+ getRouteClasses: () => getRouteClasses,
1839
+ hasTwUsage: () => hasTwUsage,
1840
+ hoistComponents: () => hoistComponents,
1841
+ injectClientDirective: () => injectClientDirective,
1842
+ injectServerOnlyComment: () => injectServerOnlyComment,
1843
+ isAlreadyTransformed: () => isAlreadyTransformed,
1844
+ loadSafelist: () => loadSafelist,
1845
+ loadTailwindConfig: () => loadTailwindConfig,
1846
+ mergeClassesStatic: () => mergeClassesStatic,
1847
+ mergeCssDeclarations: () => mergeCssDeclarations,
1848
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1849
+ normalizeClasses: () => normalizeClasses,
1850
+ optimizeCss: () => optimizeCss,
1851
+ parseClasses: () => parseClasses,
1852
+ registerFileClasses: () => registerFileClasses,
1853
+ registerGlobalClasses: () => registerGlobalClasses,
1854
+ resetBucketEngine: () => resetBucketEngine,
1855
+ resetIncrementalEngine: () => resetIncrementalEngine,
1856
+ runCssPipeline: () => runCssPipeline,
1857
+ runCssPipelineSync: () => runCssPipelineSync,
1858
+ runElimination: () => runElimination,
1859
+ runLoaderTransform: () => runLoaderTransform,
1860
+ scanProjectUsage: () => scanProjectUsage,
1861
+ shouldProcess: () => shouldProcess,
1862
+ shouldSkipFile: () => shouldSkipFile,
1863
+ transformSource: () => transformSource
1864
+ });
1865
+ var init_internal = __esm({
1866
+ "packages/domain/compiler/src/internal.ts"() {
1867
+ init_src();
1868
+ init_tailwindEngine();
1869
+ }
1870
+ });
1871
+ function getNative() {
1872
+ if (_native) return _native;
1873
+ try {
1874
+ const mod = (init_internal(), __toCommonJS(internal_exports));
1875
+ if (typeof mod?.extractTwStateConfigs !== "function" || typeof mod?.generateStaticStateCss !== "function") {
1876
+ return null;
1877
+ }
1878
+ _native = {
1879
+ extractTwStateConfigs: mod.extractTwStateConfigs,
1880
+ generateStaticStateCss: mod.generateStaticStateCss,
1881
+ extractAndGenerateStateCss: mod.extractAndGenerateStateCss ?? // Fallback jika extractAndGenerateStateCss belum di-export
1882
+ ((source, filename) => {
1883
+ const configs = mod.extractTwStateConfigs(source, filename);
1884
+ if (configs.length === 0) return [];
1885
+ return mod.generateStaticStateCss(configs.map((c) => ({
1886
+ tag: c.tag,
1887
+ componentName: c.componentName,
1888
+ statesJson: c.statesJson
1889
+ })));
1890
+ })
1891
+ };
1892
+ return _native;
1893
+ } catch {
1894
+ return null;
1895
+ }
1896
+ }
1897
+ function* walkSourceFiles(dir) {
1898
+ let entries;
1899
+ try {
1900
+ entries = fs3__default.readdirSync(dir, { withFileTypes: true });
1901
+ } catch {
1902
+ return;
1903
+ }
1904
+ for (const entry of entries) {
1905
+ const fullPath = path__default.join(dir, entry.name);
1906
+ if (entry.isDirectory()) {
1907
+ if (IGNORE_PATTERNS.some((p) => entry.name === p || entry.name.startsWith(p))) continue;
1908
+ yield* walkSourceFiles(fullPath);
1909
+ } else if (entry.isFile()) {
1910
+ const ext = path__default.extname(entry.name);
1911
+ if (SOURCE_EXTENSIONS.has(ext)) yield fullPath;
1912
+ }
1913
+ }
1914
+ }
1915
+ function buildCssHeader(result) {
1916
+ return [
1917
+ "/* \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",
1918
+ " * tw-state-static.css \u2014 Auto-generated by staticStateExtractor.ts",
1919
+ " * DO NOT EDIT. Re-generated on each build.",
1920
+ " *",
1921
+ ` * Files scanned: ${result.filesScanned}`,
1922
+ ` * Files with states: ${result.filesWithStates}`,
1923
+ ` * Components found: ${result.componentsFound}`,
1924
+ ` * Rules generated: ${result.rulesGenerated}`,
1925
+ ` * Rules skipped: ${result.rulesSkipped} (akan di-inject runtime sebagai fallback)`,
1926
+ " *",
1927
+ ' * Selector format: .tw-s-[hash][data-stateName="true"] { ... }',
1928
+ " * Hash identik dengan yang dibuat oleh stateEngine.ts di runtime.",
1929
+ " * \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 */",
1930
+ ""
1931
+ ].join("\n");
1932
+ }
1933
+ function extractStaticStateCss(srcDir, options = {}) {
1934
+ const { verbose = false, maxFiles = Infinity } = options;
1935
+ const native = getNative();
1936
+ if (!native) {
1937
+ if (verbose) {
1938
+ process.stderr.write(
1939
+ "[tw:static-state] native module tidak tersedia \u2014 skip static CSS pre-generation\n"
1940
+ );
1941
+ }
1942
+ return {
1943
+ filesScanned: 0,
1944
+ filesWithStates: 0,
1945
+ componentsFound: 0,
1946
+ rulesGenerated: 0,
1947
+ rulesSkipped: 0,
1948
+ generatedCss: "",
1949
+ rules: []
1950
+ };
1951
+ }
1952
+ const allConfigs = [];
1953
+ let filesScanned = 0;
1954
+ let filesWithStates = 0;
1955
+ if (native.walkAndPrefilterSourceFiles) {
1956
+ const prefiltered = native.walkAndPrefilterSourceFiles(
1957
+ srcDir,
1958
+ [".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"],
1959
+ ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"],
1960
+ // Required substrings — AND logic, identik dengan JS pre-filter di bawah
1961
+ ["states:", "tw."],
1962
+ maxFiles === Infinity ? null : maxFiles,
1963
+ null
1964
+ // sequential — parallel mode opsional untuk large monorepo
1965
+ );
1966
+ for (const { path: filePath, content: source } of prefiltered) {
1967
+ filesScanned++;
1968
+ const configs = native.extractTwStateConfigs(source, filePath);
1969
+ if (configs.length > 0) {
1970
+ filesWithStates++;
1971
+ allConfigs.push(...configs);
1972
+ if (verbose) {
1973
+ process.stderr.write(
1974
+ `[tw:static-state] ${path__default.relative(srcDir, filePath)}: ${configs.length} komponen
1975
+ `
1976
+ );
1977
+ }
1978
+ }
1979
+ }
1980
+ } else {
1981
+ for (const filePath of walkSourceFiles(srcDir)) {
1982
+ if (filesScanned >= maxFiles) break;
1983
+ let source;
1984
+ try {
1985
+ source = fs3__default.readFileSync(filePath, "utf-8");
1986
+ } catch {
1987
+ continue;
1988
+ }
1989
+ filesScanned++;
1990
+ if (!source.includes("states:") && !source.includes("states :")) continue;
1991
+ if (!source.includes("tw.") && !source.includes("tailwind-styled")) continue;
1992
+ const configs = native.extractTwStateConfigs(source, filePath);
1993
+ if (configs.length > 0) {
1994
+ filesWithStates++;
1995
+ allConfigs.push(...configs);
1996
+ if (verbose) {
1997
+ process.stderr.write(
1998
+ `[tw:static-state] ${path__default.relative(srcDir, filePath)}: ${configs.length} komponen
1999
+ `
2000
+ );
2001
+ }
2002
+ }
2003
+ }
2004
+ }
2005
+ if (allConfigs.length === 0) {
2006
+ return {
2007
+ filesScanned,
2008
+ filesWithStates: 0,
2009
+ componentsFound: 0,
2010
+ rulesGenerated: 0,
2011
+ rulesSkipped: 0,
2012
+ generatedCss: "",
2013
+ rules: []
2014
+ };
2015
+ }
2016
+ const seen = /* @__PURE__ */ new Set();
2017
+ const uniqueConfigs = [];
2018
+ for (const config of allConfigs) {
2019
+ const key = `${config.tag}::${config.statesJson}`;
2020
+ if (!seen.has(key)) {
2021
+ seen.add(key);
2022
+ uniqueConfigs.push({
2023
+ tag: config.tag,
2024
+ componentName: config.componentName,
2025
+ statesJson: config.statesJson
2026
+ });
2027
+ }
2028
+ }
2029
+ const allRules = native.generateStaticStateCss(uniqueConfigs, options.resolvedCss ?? null);
2030
+ const rulesSkipped = uniqueConfigs.reduce((total, cfg) => {
2031
+ try {
2032
+ const stateMap = JSON.parse(cfg.statesJson);
2033
+ return total + Object.keys(stateMap).length;
2034
+ } catch {
2035
+ return total;
2036
+ }
2037
+ }, 0) - allRules.length;
2038
+ const byComponent = /* @__PURE__ */ new Map();
2039
+ for (const rule of allRules) {
2040
+ const existing = byComponent.get(rule.componentName) ?? [];
2041
+ existing.push(rule);
2042
+ byComponent.set(rule.componentName, existing);
2043
+ }
2044
+ const cssBlocks = [];
2045
+ for (const [componentName, rules] of byComponent) {
2046
+ cssBlocks.push(`/* ${componentName} */`);
2047
+ for (const rule of rules) {
2048
+ cssBlocks.push(`/* state: ${rule.stateName} */`);
2049
+ cssBlocks.push(rule.cssRule);
2050
+ }
2051
+ cssBlocks.push("");
2052
+ }
2053
+ const result = {
2054
+ filesScanned,
2055
+ filesWithStates,
2056
+ componentsFound: allConfigs.length,
2057
+ rulesGenerated: allRules.length,
2058
+ rulesSkipped: Math.max(0, rulesSkipped),
2059
+ generatedCss: cssBlocks.join("\n"),
2060
+ rules: allRules
2061
+ };
2062
+ result.generatedCss = buildCssHeader(result) + result.generatedCss;
2063
+ return result;
2064
+ }
2065
+ function appendStaticStateCssToSafelist(srcDir, safelistPath, options = {}) {
2066
+ const result = extractStaticStateCss(srcDir, options);
2067
+ const twClassesDir = path__default.join(path__default.dirname(safelistPath), "tw-classes");
2068
+ fs3__default.mkdirSync(twClassesDir, { recursive: true });
2069
+ const stateFilePath = path__default.join(twClassesDir, TW_STATE_STATIC_FILENAME);
2070
+ if (result.rulesGenerated === 0) {
2071
+ try {
2072
+ fs3__default.writeFileSync(
2073
+ stateFilePath,
2074
+ "/* tw-state-static.css \u2014 tidak ada state rules yang di-generate */\n",
2075
+ "utf-8"
2076
+ );
2077
+ } catch {
2078
+ }
2079
+ return `[tw:static-state] tidak ada state rules yang di-generate (${result.filesScanned} files di-scan)`;
2080
+ }
2081
+ try {
2082
+ fs3__default.writeFileSync(stateFilePath, result.generatedCss, "utf-8");
2083
+ return [
2084
+ `[tw:static-state] ${result.rulesGenerated} static state rules di-generate`,
2085
+ ` \u2192 ${result.filesScanned} files scanned, ${result.filesWithStates} dengan states`,
2086
+ ` \u2192 ${result.componentsFound} components, ${result.rulesSkipped} rules skipped (fallback ke runtime)`,
2087
+ ` \u2192 ditulis ke tw-classes/${TW_STATE_STATIC_FILENAME}`
2088
+ ].join("\n");
2089
+ } catch (writeErr) {
2090
+ const msg = writeErr instanceof Error ? writeErr.message : String(writeErr);
2091
+ return `[tw:static-state] gagal tulis state CSS: ${msg}`;
2092
+ }
2093
+ }
2094
+ var SOURCE_EXTENSIONS, IGNORE_PATTERNS, _native, TW_STATE_STATIC_FILENAME;
2095
+ var init_staticStateExtractor = __esm({
2096
+ "packages/domain/shared/src/staticStateExtractor.ts"() {
2097
+ SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".mjs"]);
2098
+ IGNORE_PATTERNS = ["node_modules", ".next", "dist", "build", ".git", "coverage", "__tests__"];
2099
+ _native = null;
2100
+ TW_STATE_STATIC_FILENAME = "_tw-state-static.css";
2101
+ }
2102
+ });
2103
+ function getEnvLevel() {
2104
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
2105
+ if (env && env in LEVELS) return env;
2106
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
2107
+ }
2108
+ function setGlobalLogFile(filePath) {
2109
+ _globalLogFile = filePath;
2110
+ _logFileInitialized = false;
2111
+ try {
2112
+ fs3__default.mkdirSync(path__default.dirname(filePath), { recursive: true });
2113
+ fs3__default.writeFileSync(
2114
+ filePath,
2115
+ `# tailwind-styled build log \u2014 ${(/* @__PURE__ */ new Date()).toISOString()}
2116
+ `,
2117
+ "utf-8"
2118
+ );
2119
+ _logFileInitialized = true;
2120
+ } catch {
2121
+ }
2122
+ }
2123
+ function writeToFile(line) {
2124
+ if (!_globalLogFile || !_logFileInitialized) return;
2125
+ try {
2126
+ fs3__default.appendFileSync(_globalLogFile, line);
2127
+ } catch {
2128
+ }
2129
+ }
2130
+ function createLogger(prefix, level) {
2131
+ const loggerState = {
2132
+ currentLevel: getEnvLevel(),
2133
+ setLevel(l) {
2134
+ this.currentLevel = l;
2135
+ }
2136
+ };
2137
+ const log2 = (msgLevel, stream, args) => {
2138
+ if (LEVELS[msgLevel] > LEVELS[loggerState.currentLevel]) return;
2139
+ const line = `[${prefix}] ${args.map(String).join(" ")}
2140
+ `;
2141
+ process[stream].write(line);
2142
+ writeToFile(line);
2143
+ };
2144
+ return {
2145
+ error: (...a) => log2("error", "stderr", a),
2146
+ warn: (...a) => log2("warn", "stderr", a),
2147
+ info: (...a) => log2("info", "stdout", a),
2148
+ debug: (...a) => log2("debug", "stderr", a),
2149
+ setLevel: loggerState.setLevel,
2150
+ setLogFile: (filePath) => setGlobalLogFile(filePath)
2151
+ };
2152
+ }
2153
+ var LEVELS, _globalLogFile, _logFileInitialized;
2154
+ var init_logger = __esm({
2155
+ "packages/domain/shared/src/logger.ts"() {
2156
+ LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
2157
+ _globalLogFile = null;
2158
+ _logFileInitialized = false;
2159
+ createLogger("tailwind-styled");
2160
+ }
2161
+ });
2162
+ function createLogger2(namespace) {
918
2163
  const prefix = `[${namespace}]`;
919
2164
  return {
920
2165
  warn(...args) {
@@ -943,64 +2188,12 @@ function createDebugLogger(namespace, label) {
943
2188
  }
944
2189
  };
945
2190
  }
946
- function formatIssuePath(path3) {
947
- if (!path3 || path3.length === 0) return "(root)";
948
- return path3.map(
2191
+ function formatIssuePath(path6) {
2192
+ if (!path6 || path6.length === 0) return "(root)";
2193
+ return path6.map(
949
2194
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
950
2195
  ).join(".");
951
2196
  }
952
- var TwError = class _TwError extends Error {
953
- /** @deprecated Gunakan source */
954
- domain;
955
- source;
956
- code;
957
- originalCause;
958
- constructor(domainOrSource, code, message, cause) {
959
- super(message);
960
- this.name = "TwError";
961
- this.domain = domainOrSource;
962
- this.source = domainOrSource;
963
- this.code = code;
964
- this.originalCause = cause;
965
- if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
966
- }
967
- static fromIo(code, message) {
968
- return new _TwError("io", code, message);
969
- }
970
- static fromCompile(code, message) {
971
- return new _TwError("compile", code, message);
972
- }
973
- static fromRust(err) {
974
- if (err instanceof _TwError) return err;
975
- if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
976
- if (err && typeof err === "object") {
977
- const e = err;
978
- return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
979
- }
980
- return new _TwError("rust", "RUST_ERROR", String(err), err);
981
- }
982
- /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
983
- static fromZod(err) {
984
- const first = err.issues?.[0] ?? err.errors?.[0];
985
- const path3 = formatIssuePath(first?.path);
986
- const message = first ? `${path3}: ${first.message}` : "Schema validation failed";
987
- return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
988
- }
989
- static wrap(source, code, err) {
990
- if (err instanceof _TwError) return err;
991
- if (err instanceof Error) return new _TwError(source, code, err.message, err);
992
- return new _TwError(source, code, String(err), err);
993
- }
994
- toString() {
995
- return `TwError [${this.source}:${this.code}] ${this.message}`;
996
- }
997
- toJSON() {
998
- return { name: this.name, source: this.source, code: this.code, message: this.message };
999
- }
1000
- toCliMessage() {
1001
- return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
1002
- }
1003
- };
1004
2197
  function wrapUnknownError(domain, code, error) {
1005
2198
  return TwError.wrap(domain, code, error);
1006
2199
  }
@@ -1013,7 +2206,7 @@ function loadNativeBinding(options) {
1013
2206
  for (const candidate of candidates) {
1014
2207
  const candidatePath = path__default.resolve(runtimeDir, candidate);
1015
2208
  try {
1016
- if (!fs__default.existsSync(candidatePath) && !fs__default.existsSync(candidatePath + ".node")) {
2209
+ if (!fs3__default.existsSync(candidatePath) && !fs3__default.existsSync(candidatePath + ".node")) {
1017
2210
  continue;
1018
2211
  }
1019
2212
  const mod = requireNativeModule(candidatePath);
@@ -1027,7 +2220,6 @@ function loadNativeBinding(options) {
1027
2220
  }
1028
2221
  return { binding: null, loadErrors };
1029
2222
  }
1030
- var _require2 = createRequire(import.meta.url);
1031
2223
  function requireNativeModule(p) {
1032
2224
  return _require2(p);
1033
2225
  }
@@ -1046,9 +2238,9 @@ function resolveNativeBindingCandidates(options) {
1046
2238
  }
1047
2239
  }
1048
2240
  if (!includeDefaultCandidates) return candidates;
1049
- if (fs__default.existsSync(runtimeDir)) {
2241
+ if (fs3__default.existsSync(runtimeDir)) {
1050
2242
  try {
1051
- for (const entry of fs__default.readdirSync(runtimeDir)) {
2243
+ for (const entry of fs3__default.readdirSync(runtimeDir)) {
1052
2244
  if (entry.endsWith(".node")) candidates.push(entry);
1053
2245
  }
1054
2246
  } catch {
@@ -1086,48 +2278,122 @@ function formatErrorMessage(error) {
1086
2278
  if (error instanceof Error) return error.message;
1087
2279
  return String(error);
1088
2280
  }
1089
- var LRUCache = class {
1090
- capacity;
1091
- cache;
1092
- constructor(capacity) {
1093
- this.capacity = capacity;
1094
- this.cache = /* @__PURE__ */ new Map();
1095
- }
1096
- get(key) {
1097
- if (!this.cache.has(key)) return void 0;
1098
- const value = this.cache.get(key);
1099
- this.cache.delete(key);
1100
- this.cache.set(key, value);
1101
- return value;
1102
- }
1103
- set(key, value) {
1104
- if (this.cache.has(key)) {
1105
- this.cache.delete(key);
1106
- } else if (this.cache.size >= this.capacity) {
1107
- const firstKey = this.cache.keys().next().value;
1108
- if (firstKey !== void 0) {
1109
- this.cache.delete(firstKey);
2281
+ var TwError, _require2, LRUCache;
2282
+ var init_src2 = __esm({
2283
+ "packages/domain/shared/src/index.ts"() {
2284
+ init_trace();
2285
+ init_error_codes();
2286
+ init_compatibility();
2287
+ init_native_schemas();
2288
+ init_esmHelpers();
2289
+ init_telemetry();
2290
+ init_configSchemas();
2291
+ init_workerResolver();
2292
+ init_codegen();
2293
+ init_native_resolution();
2294
+ init_observability();
2295
+ init_staticStateExtractor();
2296
+ init_logger();
2297
+ TwError = class _TwError extends Error {
2298
+ /** @deprecated Gunakan source */
2299
+ domain;
2300
+ source;
2301
+ code;
2302
+ originalCause;
2303
+ constructor(domainOrSource, code, message, cause) {
2304
+ super(message);
2305
+ this.name = "TwError";
2306
+ this.domain = domainOrSource;
2307
+ this.source = domainOrSource;
2308
+ this.code = code;
2309
+ this.originalCause = cause;
2310
+ if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
1110
2311
  }
1111
- }
1112
- this.cache.set(key, value);
1113
- }
1114
- delete(key) {
1115
- return this.cache.delete(key);
1116
- }
1117
- has(key) {
1118
- return this.cache.has(key);
1119
- }
1120
- clear() {
1121
- this.cache.clear();
1122
- }
1123
- entries() {
1124
- return this.cache.entries();
1125
- }
1126
- get size() {
1127
- return this.cache.size;
2312
+ static fromIo(code, message) {
2313
+ return new _TwError("io", code, message);
2314
+ }
2315
+ static fromCompile(code, message) {
2316
+ return new _TwError("compile", code, message);
2317
+ }
2318
+ static fromRust(err) {
2319
+ if (err instanceof _TwError) return err;
2320
+ if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
2321
+ if (err && typeof err === "object") {
2322
+ const e = err;
2323
+ return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
2324
+ }
2325
+ return new _TwError("rust", "RUST_ERROR", String(err), err);
2326
+ }
2327
+ /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
2328
+ static fromZod(err) {
2329
+ const first = err.issues?.[0] ?? err.errors?.[0];
2330
+ const path6 = formatIssuePath(first?.path);
2331
+ const message = first ? `${path6}: ${first.message}` : "Schema validation failed";
2332
+ return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
2333
+ }
2334
+ static wrap(source, code, err) {
2335
+ if (err instanceof _TwError) return err;
2336
+ if (err instanceof Error) return new _TwError(source, code, err.message, err);
2337
+ return new _TwError(source, code, String(err), err);
2338
+ }
2339
+ toString() {
2340
+ return `TwError [${this.source}:${this.code}] ${this.message}`;
2341
+ }
2342
+ toJSON() {
2343
+ return { name: this.name, source: this.source, code: this.code, message: this.message };
2344
+ }
2345
+ toCliMessage() {
2346
+ return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
2347
+ }
2348
+ };
2349
+ _require2 = createRequire(import.meta.url);
2350
+ LRUCache = class {
2351
+ capacity;
2352
+ cache;
2353
+ constructor(capacity) {
2354
+ this.capacity = capacity;
2355
+ this.cache = /* @__PURE__ */ new Map();
2356
+ }
2357
+ get(key) {
2358
+ if (!this.cache.has(key)) return void 0;
2359
+ const value = this.cache.get(key);
2360
+ this.cache.delete(key);
2361
+ this.cache.set(key, value);
2362
+ return value;
2363
+ }
2364
+ set(key, value) {
2365
+ if (this.cache.has(key)) {
2366
+ this.cache.delete(key);
2367
+ } else if (this.cache.size >= this.capacity) {
2368
+ const firstKey = this.cache.keys().next().value;
2369
+ if (firstKey !== void 0) {
2370
+ this.cache.delete(firstKey);
2371
+ }
2372
+ }
2373
+ this.cache.set(key, value);
2374
+ }
2375
+ delete(key) {
2376
+ return this.cache.delete(key);
2377
+ }
2378
+ has(key) {
2379
+ return this.cache.has(key);
2380
+ }
2381
+ clear() {
2382
+ this.cache.clear();
2383
+ }
2384
+ entries() {
2385
+ return this.cache.entries();
2386
+ }
2387
+ get size() {
2388
+ return this.cache.size;
2389
+ }
2390
+ };
1128
2391
  }
1129
- };
2392
+ });
2393
+
2394
+ // src/umbrella/shared.ts
2395
+ init_src2();
1130
2396
 
1131
- export { ERROR_CODES, LRUCache, NativeAnalyzerReportSchema, NativeCacheEntrySchema, NativeCacheReadResultSchema, NativeCssCompileResultSchema, NativeScanFileSchema, NativeScanResultSchema, NativeTransformResultSchema, NativeWatchResultSchema, PackageJsonSchema, RegistryFileSchema, RegistryPluginEntrySchema, ScanCacheClassEntrySchema, ScanCacheSchema, TailwindConfigSchema, TelemetryCollector, TwError, assertTailwindV4, calculateHealth, createBuildTimer, createDebugLogger, createEsmRequire, createLogger, createObservabilityClient, createTraceSnapshot, detectTailwind, formatDuration, formatErrorCode, formatErrorMessage, formatMemory, formatNativeNotFoundError, generateBarrelFile, generateClassRenameCodemod, generateComponentCode, generateStorybookStory, getBuildTimeColor, getDirname, getFilename, getGlobalTelemetry, getHealthColor, getMemoryColor, getModeColor, getPipelinePercentages, getSuggestion, getTailwindVersion, hashContent, isTailwindV4, isTwError, loadNativeBinding, parseJsonFileWithSchema, parseJsonWithSchema, parseNative, resetGlobalTelemetry, resolveFromRoot, resolveLoaderPath, resolveNativeBinary, resolveNativeBindingCandidates, resolveNativeNodePath, resolveRuntimeDir, resolveWorkerPath, safeParseNative, tryRequire, wrapUnknownError };
2397
+ export { ERROR_CODES, LRUCache, NativeAnalyzerReportSchema, NativeCacheEntrySchema, NativeCacheReadResultSchema, NativeCssCompileResultSchema, NativeScanFileSchema, NativeScanResultSchema, NativeTransformResultSchema, NativeWatchResultSchema, PackageJsonSchema, RegistryFileSchema, RegistryPluginEntrySchema, ScanCacheClassEntrySchema, ScanCacheSchema, TW_STATE_STATIC_FILENAME, TailwindConfigSchema, TelemetryCollector, TwError, appendStaticStateCssToSafelist, assertTailwindV4, calculateHealth, createBuildTimer, createDebugLogger, createEsmRequire, createLogger2 as createLogger, createObservabilityClient, createTraceSnapshot, detectTailwind, extractStaticStateCss, formatDuration, formatErrorCode, formatErrorMessage, formatMemory, formatNativeNotFoundError, generateBarrelFile, generateClassRenameCodemod, generateComponentCode, generateStorybookStory, getBuildTimeColor, getDirname, getFilename, getGlobalTelemetry, getHealthColor, getMemoryColor, getModeColor, getPipelinePercentages, getSuggestion, getTailwindVersion, hashContent, isTailwindV4, isTwError, loadNativeBinding, parseJsonFileWithSchema, parseJsonWithSchema, parseNative, resetGlobalTelemetry, resolveFromRoot, resolveLoaderPath, resolveNativeBinary, resolveNativeBindingCandidates, resolveNativeNodePath, resolveRuntimeDir, resolveWorkerPath, safeParseNative, setGlobalLogFile, tryRequire, wrapUnknownError };
1132
2398
  //# sourceMappingURL=shared.mjs.map
1133
2399
  //# sourceMappingURL=shared.mjs.map