tailwind-styled-v4 5.0.8 → 5.0.10

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 (140) hide show
  1. package/CHANGELOG.md +204 -416
  2. package/README.md +45 -15
  3. package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
  4. package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
  5. package/dist/analyzer.d.mts +5 -3
  6. package/dist/analyzer.d.ts +5 -3
  7. package/dist/analyzer.js +563 -468
  8. package/dist/analyzer.js.map +1 -1
  9. package/dist/analyzer.mjs +562 -467
  10. package/dist/analyzer.mjs.map +1 -1
  11. package/dist/animate.d.mts +4 -7
  12. package/dist/animate.d.ts +4 -7
  13. package/dist/animate.js +171 -265
  14. package/dist/animate.js.map +1 -1
  15. package/dist/animate.mjs +165 -264
  16. package/dist/animate.mjs.map +1 -1
  17. package/dist/atomic.d.mts +22 -1
  18. package/dist/atomic.d.ts +22 -1
  19. package/dist/atomic.js +221 -165
  20. package/dist/atomic.js.map +1 -1
  21. package/dist/atomic.mjs +200 -165
  22. package/dist/atomic.mjs.map +1 -1
  23. package/dist/cli.d.mts +60 -1
  24. package/dist/cli.d.ts +60 -1
  25. package/dist/cli.js +1261 -1517
  26. package/dist/cli.js.map +1 -1
  27. package/dist/cli.mjs +1238 -1513
  28. package/dist/cli.mjs.map +1 -1
  29. package/dist/compiler.d.mts +38 -7
  30. package/dist/compiler.d.ts +38 -7
  31. package/dist/compiler.js +174 -197
  32. package/dist/compiler.js.map +1 -1
  33. package/dist/compiler.mjs +151 -194
  34. package/dist/compiler.mjs.map +1 -1
  35. package/dist/devtools.js +7 -31
  36. package/dist/devtools.js.map +1 -1
  37. package/dist/devtools.mjs +7 -31
  38. package/dist/devtools.mjs.map +1 -1
  39. package/dist/engine.d.mts +134 -63
  40. package/dist/engine.d.ts +134 -63
  41. package/dist/engine.js +2863 -2482
  42. package/dist/engine.js.map +1 -1
  43. package/dist/engine.mjs +2852 -2485
  44. package/dist/engine.mjs.map +1 -1
  45. package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
  46. package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
  47. package/dist/index.d.mts +63 -32
  48. package/dist/index.d.ts +63 -32
  49. package/dist/index.js +335 -169
  50. package/dist/index.js.map +1 -1
  51. package/dist/index.mjs +315 -169
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
  54. package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
  55. package/dist/next.d.mts +10 -4
  56. package/dist/next.d.ts +10 -4
  57. package/dist/next.js +32 -45
  58. package/dist/next.js.map +1 -1
  59. package/dist/next.mjs +30 -43
  60. package/dist/next.mjs.map +1 -1
  61. package/dist/plugin-api.d.mts +8 -2
  62. package/dist/plugin-api.d.ts +8 -2
  63. package/dist/plugin-api.js +14 -2
  64. package/dist/plugin-api.js.map +1 -1
  65. package/dist/plugin-api.mjs +14 -3
  66. package/dist/plugin-api.mjs.map +1 -1
  67. package/dist/plugin-registry.js +51 -11
  68. package/dist/plugin-registry.js.map +1 -1
  69. package/dist/plugin-registry.mjs +51 -11
  70. package/dist/plugin-registry.mjs.map +1 -1
  71. package/dist/plugin.d.mts +5 -7
  72. package/dist/plugin.d.ts +5 -7
  73. package/dist/plugin.js +16 -15
  74. package/dist/plugin.js.map +1 -1
  75. package/dist/plugin.mjs +16 -16
  76. package/dist/plugin.mjs.map +1 -1
  77. package/dist/rspack.js +17 -38
  78. package/dist/rspack.js.map +1 -1
  79. package/dist/rspack.mjs +15 -36
  80. package/dist/rspack.mjs.map +1 -1
  81. package/dist/runtime.d.mts +2 -2
  82. package/dist/runtime.d.ts +2 -2
  83. package/dist/scanner.d.mts +10 -1
  84. package/dist/scanner.d.ts +10 -1
  85. package/dist/scanner.js +298 -124
  86. package/dist/scanner.js.map +1 -1
  87. package/dist/scanner.mjs +296 -124
  88. package/dist/scanner.mjs.map +1 -1
  89. package/dist/shared.d.mts +1 -1
  90. package/dist/shared.d.ts +1 -1
  91. package/dist/shared.js +104 -176
  92. package/dist/shared.js.map +1 -1
  93. package/dist/shared.mjs +85 -176
  94. package/dist/shared.mjs.map +1 -1
  95. package/dist/storybook-addon.d.mts +1 -1
  96. package/dist/storybook-addon.d.ts +1 -1
  97. package/dist/svelte.d.mts +1 -1
  98. package/dist/svelte.d.ts +1 -1
  99. package/dist/svelte.js +166 -3
  100. package/dist/svelte.js.map +1 -1
  101. package/dist/svelte.mjs +143 -1
  102. package/dist/svelte.mjs.map +1 -1
  103. package/dist/syntax.js +21 -21
  104. package/dist/syntax.js.map +1 -1
  105. package/dist/syntax.mjs +21 -21
  106. package/dist/syntax.mjs.map +1 -1
  107. package/dist/testing.js +9 -1
  108. package/dist/testing.js.map +1 -1
  109. package/dist/testing.mjs +9 -1
  110. package/dist/testing.mjs.map +1 -1
  111. package/dist/theme.d.mts +2 -2
  112. package/dist/theme.d.ts +2 -2
  113. package/dist/theme.js +40 -112
  114. package/dist/theme.js.map +1 -1
  115. package/dist/theme.mjs +37 -110
  116. package/dist/theme.mjs.map +1 -1
  117. package/dist/turbopackLoader.js +84 -126
  118. package/dist/turbopackLoader.js.map +1 -1
  119. package/dist/turbopackLoader.mjs +68 -124
  120. package/dist/turbopackLoader.mjs.map +1 -1
  121. package/dist/tw.js +1256 -1517
  122. package/dist/tw.js.map +1 -1
  123. package/dist/tw.mjs +1236 -1513
  124. package/dist/tw.mjs.map +1 -1
  125. package/dist/vite.js +1783 -823
  126. package/dist/vite.js.map +1 -1
  127. package/dist/vite.mjs +1767 -821
  128. package/dist/vite.mjs.map +1 -1
  129. package/dist/vue.d.mts +1 -1
  130. package/dist/vue.d.ts +1 -1
  131. package/dist/vue.js +165 -4
  132. package/dist/vue.js.map +1 -1
  133. package/dist/vue.mjs +141 -1
  134. package/dist/vue.mjs.map +1 -1
  135. package/dist/webpackLoader.js +69 -108
  136. package/dist/webpackLoader.js.map +1 -1
  137. package/dist/webpackLoader.mjs +49 -104
  138. package/dist/webpackLoader.mjs.map +1 -1
  139. package/native/tailwind-styled-native.node +0 -0
  140. package/package.json +22 -24
package/dist/scanner.js CHANGED
@@ -1,29 +1,25 @@
1
1
  'use strict';
2
2
 
3
- var path3 = require('path');
3
+ require('crypto');
4
+ var fs3 = require('fs');
5
+ var path5 = require('path');
4
6
  var url = require('url');
5
- var fs = require('fs');
6
7
  var module$1 = require('module');
7
8
  var worker_threads = require('worker_threads');
9
+ var os = require('os');
8
10
  var zod = require('zod');
9
11
 
10
12
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
14
 
13
- var path3__default = /*#__PURE__*/_interopDefault(path3);
14
- var fs__default = /*#__PURE__*/_interopDefault(fs);
15
+ var fs3__default = /*#__PURE__*/_interopDefault(fs3);
16
+ var path5__default = /*#__PURE__*/_interopDefault(path5);
15
17
 
16
18
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
17
19
  var __defProp = Object.defineProperty;
18
20
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19
21
  var __getOwnPropNames = Object.getOwnPropertyNames;
20
22
  var __hasOwnProp = Object.prototype.hasOwnProperty;
21
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
22
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
23
- }) : x)(function(x) {
24
- if (typeof require !== "undefined") return require.apply(this, arguments);
25
- throw Error('Dynamic require of "' + x + '" is not supported');
26
- });
27
23
  var __esm = (fn, res) => function __init() {
28
24
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
29
25
  };
@@ -40,34 +36,6 @@ var __copyProps = (to, from, except, desc) => {
40
36
  return to;
41
37
  };
42
38
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
-
44
- // packages/domain/shared/src/index.ts
45
- function getNodeModuleRef() {
46
- if (isBrowser) return null;
47
- if (nodeModuleRef !== null) return nodeModuleRef;
48
- try {
49
- const test = typeof __require === "function" ? __require("module") : null;
50
- nodeModuleRef = test;
51
- return test;
52
- } catch {
53
- nodeModuleRef = null;
54
- return null;
55
- }
56
- }
57
- function getNodeFs() {
58
- if (isBrowser) throw new Error("node:fs not available in browser");
59
- const nodeRequire = getNodeModuleRef();
60
- if (!nodeRequire) throw new Error("require not available");
61
- if (!_nodeFs) _nodeFs = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)))("node:fs");
62
- return _nodeFs;
63
- }
64
- function getNodePath() {
65
- if (isBrowser) throw new Error("node:path not available in browser");
66
- const nodeRequire = getNodeModuleRef();
67
- if (!nodeRequire) throw new Error("require not available");
68
- if (!_nodePath) _nodePath = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)))("node:path");
69
- return _nodePath;
70
- }
71
39
  function createLogger(namespace) {
72
40
  const prefix = `[${namespace}]`;
73
41
  return {
@@ -97,24 +65,19 @@ function createDebugLogger(namespace, label) {
97
65
  }
98
66
  };
99
67
  }
100
- function formatIssuePath(path4) {
101
- if (!path4 || path4.length === 0) return "(root)";
102
- return path4.map(
68
+ function formatIssuePath(path6) {
69
+ if (!path6 || path6.length === 0) return "(root)";
70
+ return path6.map(
103
71
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
104
72
  ).join(".");
105
73
  }
106
74
  function loadNativeBinding(options) {
107
- if (isBrowser) {
108
- return { binding: null, loadErrors: [{ path: "", message: "Native bindings not available in browser" }] };
109
- }
110
75
  const { runtimeDir, candidates, isValid } = options;
111
76
  const loadErrors = [];
112
- const path4 = getNodePath();
113
- const fs2 = getNodeFs();
114
77
  for (const candidate of candidates) {
115
- const candidatePath = path4.resolve(runtimeDir, candidate);
78
+ const candidatePath = path5__default.default.resolve(runtimeDir, candidate);
116
79
  try {
117
- if (!fs2.existsSync(candidatePath) && !fs2.existsSync(candidatePath + ".node")) {
80
+ if (!fs3__default.default.existsSync(candidatePath) && !fs3__default.default.existsSync(candidatePath + ".node")) {
118
81
  continue;
119
82
  }
120
83
  const mod = requireNativeModule(candidatePath);
@@ -128,62 +91,48 @@ function loadNativeBinding(options) {
128
91
  }
129
92
  return { binding: null, loadErrors };
130
93
  }
131
- function getRequire() {
132
- if (isBrowser) return (() => {
133
- throw new Error("require not available in browser");
134
- });
135
- const nodeRequire = getNodeModuleRef();
136
- if (!nodeRequire) return (() => {
137
- throw new Error("require not available");
138
- });
139
- return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)));
140
- }
141
- function requireNativeModule(path4) {
142
- return _require(path4);
94
+ function requireNativeModule(p) {
95
+ return _require(p);
143
96
  }
144
97
  function resolveNativeBindingCandidates(options) {
145
- if (isBrowser) return [];
146
- const { runtimeDir, envVarNames = [], includeDefaultCandidates = true, enforceNodeExtensionForEnvPath = false } = options;
98
+ const {
99
+ envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
100
+ includeDefaultCandidates = true,
101
+ enforceNodeExtensionForEnvPath = false
102
+ } = options;
103
+ const runtimeDir = options.runtimeDir || process.cwd();
147
104
  const candidates = [];
148
- const path4 = getNodePath();
149
- const fs2 = getNodeFs();
150
105
  for (const envVar of envVarNames) {
151
106
  const envPath = process.env[envVar];
152
107
  if (envPath) {
153
- if (enforceNodeExtensionForEnvPath && !envPath.endsWith(".node")) {
154
- candidates.push(envPath + ".node");
155
- } else {
156
- candidates.push(envPath);
157
- }
108
+ candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
158
109
  }
159
110
  }
160
111
  if (!includeDefaultCandidates) return candidates;
161
- if (fs2.existsSync(runtimeDir)) {
112
+ if (fs3__default.default.existsSync(runtimeDir)) {
162
113
  try {
163
- const entries = fs2.readdirSync(runtimeDir);
164
- for (const entry of entries) {
165
- if (entry.endsWith(".node")) {
166
- candidates.push(entry);
167
- }
114
+ for (const entry of fs3__default.default.readdirSync(runtimeDir)) {
115
+ if (entry.endsWith(".node")) candidates.push(entry);
168
116
  }
169
117
  } catch {
170
118
  }
171
119
  }
172
- const platform = typeof process !== "undefined" ? process.platform : "";
173
- const ext = platform === "win32" ? ".dll" : platform === "darwin" ? ".dylib" : ".so";
174
- const defaultBindingName = `tailwind_styled_parser${ext}`;
175
- candidates.push(path4.resolve(runtimeDir, "..", "..", "..", "native", defaultBindingName));
176
- candidates.push(path4.resolve(runtimeDir, "..", "..", "..", "..", "native", defaultBindingName));
177
- candidates.push(path4.resolve(process.cwd(), "native", defaultBindingName));
120
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
121
+ const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
122
+ for (const bin of BINARY_NAMES) {
123
+ candidates.push(path5__default.default.resolve(runtimeDir, `${bin}.node`));
124
+ candidates.push(path5__default.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
125
+ candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
126
+ candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
127
+ candidates.push(path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
128
+ candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.node`));
129
+ candidates.push(path5__default.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
130
+ }
178
131
  return Array.from(new Set(candidates));
179
132
  }
180
- var isBrowser, nodeModuleRef, _nodeFs, _nodePath, TwError, _require;
133
+ var TwError, _require;
181
134
  var init_src = __esm({
182
135
  "packages/domain/shared/src/index.ts"() {
183
- isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
184
- nodeModuleRef = null;
185
- _nodeFs = null;
186
- _nodePath = null;
187
136
  TwError = class _TwError extends Error {
188
137
  /** @deprecated Gunakan source */
189
138
  domain;
@@ -217,8 +166,8 @@ var init_src = __esm({
217
166
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
218
167
  static fromZod(err) {
219
168
  const first = err.issues?.[0] ?? err.errors?.[0];
220
- const path4 = formatIssuePath(first?.path);
221
- const message = first ? `${path4}: ${first.message}` : "Schema validation failed";
169
+ const path6 = formatIssuePath(first?.path);
170
+ const message = first ? `${path6}: ${first.message}` : "Schema validation failed";
222
171
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
223
172
  }
224
173
  static wrap(source, code, err) {
@@ -236,21 +185,33 @@ var init_src = __esm({
236
185
  return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
237
186
  }
238
187
  };
239
- _require = getRequire();
188
+ _require = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)));
240
189
  }
241
190
  });
242
191
 
243
192
  // packages/domain/scanner/src/native-bridge.ts
244
193
  var native_bridge_exports = {};
245
194
  __export(native_bridge_exports, {
195
+ batchExtractClassesNative: () => batchExtractClassesNative,
246
196
  cachePriorityNative: () => cachePriorityNative,
247
197
  cacheReadNative: () => cacheReadNative,
248
198
  cacheWriteNative: () => cacheWriteNative,
199
+ collectFilesNative: () => collectFilesNative,
200
+ computeCacheStatsNative: () => computeCacheStatsNative,
249
201
  extractClassesNative: () => extractClassesNative,
202
+ generateSubComponentTypesNative: () => generateSubComponentTypesNative,
250
203
  hasNativeScannerBinding: () => hasNativeScannerBinding,
251
204
  hashContentNative: () => hashContentNative,
252
205
  isRustCacheAvailable: () => isRustCacheAvailable,
206
+ pruneStaleEntriesNative: () => pruneStaleEntriesNative,
207
+ rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
253
208
  resetScannerBridgeCache: () => resetScannerBridgeCache,
209
+ scanCacheGet: () => scanCacheGet,
210
+ scanCacheInvalidate: () => scanCacheInvalidate,
211
+ scanCachePut: () => scanCachePut,
212
+ scanCacheStats: () => scanCacheStats,
213
+ scanFileNative: () => scanFileNative,
214
+ scanFilesBatchNative: () => scanFilesBatchNative,
254
215
  scanWorkspaceNative: () => scanWorkspaceNative
255
216
  });
256
217
  function getDirname() {
@@ -258,7 +219,7 @@ function getDirname() {
258
219
  return __dirname;
259
220
  }
260
221
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))) {
261
- return path3__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
222
+ return path5__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
262
223
  }
263
224
  return process.cwd();
264
225
  }
@@ -339,6 +300,95 @@ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHit
339
300
  }
340
301
  return result;
341
302
  }
303
+ function batchExtractClassesNative(filePaths) {
304
+ const binding = scannerGetBinding();
305
+ if (!binding.batchExtractClasses) {
306
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
307
+ }
308
+ return binding.batchExtractClasses(filePaths) ?? [];
309
+ }
310
+ function scanCacheGet(filePath, contentHash) {
311
+ const binding = scannerGetBinding();
312
+ if (!binding.scanCacheGet) {
313
+ throw new Error("FATAL: Native binding 'scanCacheGet' is required but not available.");
314
+ }
315
+ return binding.scanCacheGet(filePath, contentHash) ?? null;
316
+ }
317
+ function scanCachePut(filePath, contentHash, classes, mtimeMs, size) {
318
+ const binding = scannerGetBinding();
319
+ if (!binding.scanCachePut) {
320
+ throw new Error("FATAL: Native binding 'scanCachePut' is required but not available.");
321
+ }
322
+ binding.scanCachePut(filePath, contentHash, classes, mtimeMs, size);
323
+ }
324
+ function scanCacheInvalidate(filePath) {
325
+ const binding = scannerGetBinding();
326
+ if (!binding.scanCacheInvalidate) {
327
+ throw new Error("FATAL: Native binding 'scanCacheInvalidate' is required but not available.");
328
+ }
329
+ binding.scanCacheInvalidate(filePath);
330
+ }
331
+ function scanCacheStats() {
332
+ const binding = scannerGetBinding();
333
+ if (!binding.scanCacheStats) {
334
+ throw new Error("FATAL: Native binding 'scanCacheStats' is required but not available.");
335
+ }
336
+ return binding.scanCacheStats();
337
+ }
338
+ function scanFileNative(filePath) {
339
+ const binding = scannerGetBinding();
340
+ if (!binding.scanFile) {
341
+ throw new Error("FATAL: Native binding 'scanFile' is required but not available.");
342
+ }
343
+ return binding.scanFile(filePath);
344
+ }
345
+ function collectFilesNative(root, extensions, ignoreDirs) {
346
+ const binding = scannerGetBinding();
347
+ if (!binding.collectFiles) return null;
348
+ return binding.collectFiles(root, extensions, ignoreDirs);
349
+ }
350
+ function scanFilesBatchNative(filePaths) {
351
+ const binding = scannerGetBinding();
352
+ if (!binding.scanFilesBatch) {
353
+ return filePaths.map((fp) => {
354
+ try {
355
+ const r = binding.scanFile?.(fp);
356
+ return r ? { file: r.file, classes: r.classes, hash: r.hash ?? "" } : { file: fp, classes: [], hash: "" };
357
+ } catch {
358
+ return { file: fp, classes: [], hash: "" };
359
+ }
360
+ });
361
+ }
362
+ return binding.scanFilesBatch(filePaths);
363
+ }
364
+ function generateSubComponentTypesNative(root, outputPath) {
365
+ const binding = scannerGetBinding();
366
+ if (!binding.generateSubComponentTypes) return null;
367
+ return binding.generateSubComponentTypes(root, outputPath ?? null);
368
+ }
369
+ function pruneStaleEntriesNative(entries, maxAgeMs, checkExists) {
370
+ const binding = scannerGetBinding();
371
+ if (!binding.pruneStaleEntries) return null;
372
+ return binding.pruneStaleEntries(
373
+ entries.map((e) => ({ file: e.file, lastSeenMs: e.lastSeenMs ?? 0 })),
374
+ maxAgeMs ?? null,
375
+ checkExists ?? null
376
+ );
377
+ }
378
+ function rebuildWorkspaceResultNative(files) {
379
+ const binding = scannerBridgeLoader.get();
380
+ if (!binding?.rebuildWorkspaceResult) return null;
381
+ try {
382
+ return binding.rebuildWorkspaceResult(files);
383
+ } catch {
384
+ return null;
385
+ }
386
+ }
387
+ function computeCacheStatsNative(filesClasses, sizes, top) {
388
+ const binding = scannerGetBinding();
389
+ if (!binding.computeCacheStats) return null;
390
+ return binding.computeCacheStats(filesClasses, sizes, top ?? null);
391
+ }
342
392
  var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
343
393
  var init_native_bridge = __esm({
344
394
  "packages/domain/scanner/src/native-bridge.ts"() {
@@ -429,8 +479,8 @@ init_src();
429
479
  // packages/domain/scanner/src/cache-native.ts
430
480
  init_native_bridge();
431
481
  function defaultCachePath(rootDir, cacheDir) {
432
- const dir = cacheDir ? path3__default.default.resolve(rootDir, cacheDir) : path3__default.default.join(process.cwd(), ".cache", "tailwind-styled");
433
- return path3__default.default.join(dir, "scanner-cache.json");
482
+ const dir = cacheDir ? path5__default.default.resolve(rootDir, cacheDir) : path5__default.default.join(process.cwd(), ".cache", "tailwind-styled");
483
+ return path5__default.default.join(dir, "scanner-cache.json");
434
484
  }
435
485
  function readCache(rootDir, cacheDir) {
436
486
  const cachePath = defaultCachePath(rootDir, cacheDir);
@@ -469,15 +519,110 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
469
519
 
470
520
  // packages/domain/scanner/src/index.ts
471
521
  init_native_bridge();
522
+ init_native_bridge();
523
+ var PARALLEL_THRESHOLD = 50;
524
+ var DEFAULT_CHUNK_SIZE = 150;
525
+ function collectFiles(rootDir, extensions, ignoreDirs) {
526
+ const native = collectFilesNative(rootDir, extensions, ignoreDirs);
527
+ if (native !== null) return native;
528
+ const files = [];
529
+ function walk(dir) {
530
+ let entries;
531
+ try {
532
+ entries = fs3__default.default.readdirSync(dir, { withFileTypes: true });
533
+ } catch {
534
+ return;
535
+ }
536
+ for (const entry of entries) {
537
+ const fullPath = path5__default.default.join(dir, entry.name);
538
+ const rel = path5__default.default.relative(rootDir, fullPath);
539
+ if (entry.isDirectory()) {
540
+ const ignored = ignoreDirs.some((d) => entry.name === d || rel.startsWith(d + path5__default.default.sep));
541
+ if (!ignored) walk(fullPath);
542
+ } else if (isScannableFile(entry.name, extensions)) {
543
+ files.push(fullPath);
544
+ }
545
+ }
546
+ }
547
+ walk(rootDir);
548
+ return files;
549
+ }
550
+ function mergeResults(batchResults) {
551
+ const files = batchResults.map((r) => ({
552
+ file: r.file,
553
+ classes: r.classes,
554
+ hash: r.content_hash
555
+ }));
556
+ const native = rebuildWorkspaceResultNative(files);
557
+ if (native) return native;
558
+ const unique = new Set(files.flatMap((f) => f.classes));
559
+ return { files, totalFiles: files.length, uniqueClasses: Array.from(unique).sort() };
560
+ }
561
+ if (!worker_threads.isMainThread && worker_threads.parentPort) {
562
+ const { filePaths } = worker_threads.workerData;
563
+ try {
564
+ const results = batchExtractClassesNative(filePaths);
565
+ const msg = { ok: true, results };
566
+ worker_threads.parentPort.postMessage(msg);
567
+ } catch (error) {
568
+ const msg = {
569
+ ok: false,
570
+ error: error instanceof Error ? error.message : String(error)
571
+ };
572
+ worker_threads.parentPort.postMessage(msg);
573
+ }
574
+ }
575
+ var _workerFilename = typeof __filename !== "undefined" ? __filename : url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)));
576
+ function runChunkInWorker(filePaths) {
577
+ return new Promise((resolve, reject) => {
578
+ const worker = new worker_threads.Worker(_workerFilename, {
579
+ workerData: { filePaths }
580
+ });
581
+ worker.once("message", (payload) => {
582
+ if (payload.ok) {
583
+ resolve(payload.results);
584
+ } else {
585
+ reject(new Error(payload.error ?? "parallel-scanner worker failed"));
586
+ }
587
+ });
588
+ worker.once("error", reject);
589
+ worker.once("exit", (code) => {
590
+ if (code !== 0) reject(new Error(`parallel-scanner worker exited with code ${code}`));
591
+ });
592
+ });
593
+ }
594
+ async function scanWorkspaceParallel(rootDir, options = {}) {
595
+ const {
596
+ extensions = DEFAULT_EXTENSIONS,
597
+ ignoreDirs = DEFAULT_IGNORES,
598
+ maxWorkers = Math.max(1, os.availableParallelism() - 1),
599
+ chunkSize = DEFAULT_CHUNK_SIZE
600
+ } = options;
601
+ const files = collectFiles(path5__default.default.resolve(rootDir), extensions, ignoreDirs);
602
+ if (files.length < PARALLEL_THRESHOLD) {
603
+ return mergeResults(batchExtractClassesNative(files));
604
+ }
605
+ const chunks = [];
606
+ for (let i = 0; i < files.length; i += chunkSize) {
607
+ chunks.push(files.slice(i, i + chunkSize));
608
+ }
609
+ const allResults = [];
610
+ for (let i = 0; i < chunks.length; i += maxWorkers) {
611
+ const batch = chunks.slice(i, i + maxWorkers);
612
+ const batchResults = await Promise.all(batch.map(runChunkInWorker));
613
+ allResults.push(...batchResults.flat());
614
+ }
615
+ return mergeResults(allResults);
616
+ }
472
617
 
473
618
  // packages/domain/scanner/src/schemas.ts
474
619
  init_src();
475
- var formatIssuePath2 = (path4) => path4.length > 0 ? path4.map(
620
+ var formatIssuePath2 = (path6) => path6.length > 0 ? path6.map(
476
621
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
477
622
  ).join(".") : "<root>";
478
623
  var formatIssues = (error) => error.issues.map((issue) => {
479
- const path4 = formatIssuePath2(issue.path);
480
- return `${path4}: ${issue.message}`;
624
+ const path6 = formatIssuePath2(issue.path);
625
+ return `${path6}: ${issue.message}`;
481
626
  }).join("; ");
482
627
  var parseWithSchema = (schema, data, label) => {
483
628
  const parsed = schema.safeParse(data);
@@ -532,6 +677,7 @@ var parseScanWorkspaceResult = (result) => parseWithSchema(ScanWorkspaceResultSc
532
677
  var parseScannerWorkerMessage = (message) => parseWithSchema(ScannerWorkerMessageSchema, message, "scanner worker message is invalid");
533
678
 
534
679
  // packages/domain/scanner/src/index.ts
680
+ init_native_bridge();
535
681
  var log2 = createLogger("scanner");
536
682
  var SCAN_WORKER_TIMEOUT_MS = 12e4;
537
683
  function getRuntimeDir() {
@@ -539,7 +685,7 @@ function getRuntimeDir() {
539
685
  return __dirname;
540
686
  }
541
687
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))) {
542
- return path3__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
688
+ return path5__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
543
689
  }
544
690
  return process.cwd();
545
691
  }
@@ -554,12 +700,25 @@ var createNativeParserLoader = () => {
554
700
  const loadNativeParserBinding = () => {
555
701
  if (_state.binding !== void 0) return _state.binding;
556
702
  const runtimeDir = getRuntimeDir();
557
- const req = module$1.createRequire(path3__default.default.join(runtimeDir, "noop.cjs"));
703
+ const req = module$1.createRequire(path5__default.default.join(runtimeDir, "noop.cjs"));
558
704
  const candidates = [
559
- path3__default.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
560
- path3__default.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
561
- path3__default.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
562
- path3__default.default.resolve(
705
+ // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
706
+ // cwd = repo root saat run dari root, atau package dir saat workspaces
707
+ path5__default.default.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
708
+ path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${process.platform}-${process.arch}.node`),
709
+ path5__default.default.resolve(process.cwd(), "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
710
+ // runtimeDir = dist/ → naik 4 level ke repo root
711
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
712
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
713
+ // 3 level fallback (jika package di-nest lebih dangkal)
714
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
715
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
716
+ // ── binaryName lama: tailwind_styled_parser (backward compat) ──
717
+ path5__default.default.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
718
+ path5__default.default.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
719
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
720
+ path5__default.default.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
721
+ path5__default.default.resolve(
563
722
  runtimeDir,
564
723
  "..",
565
724
  "..",
@@ -571,7 +730,7 @@ var createNativeParserLoader = () => {
571
730
  )
572
731
  ];
573
732
  for (const fullPath of candidates) {
574
- if (!fs__default.default.existsSync(fullPath)) continue;
733
+ if (!fs3__default.default.existsSync(fullPath)) continue;
575
734
  try {
576
735
  const required = req(fullPath);
577
736
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -607,17 +766,17 @@ function resolveScannerWorkerModulePath() {
607
766
  return __dirname;
608
767
  }
609
768
  if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href)) }) !== "undefined" && (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))) {
610
- return path3__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
769
+ return path5__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('scanner.js', document.baseURI).href))));
611
770
  }
612
771
  return process.cwd();
613
772
  })();
614
773
  const candidates = [
615
- path3__default.default.resolve(runtimeDir, "worker.cjs"),
616
- path3__default.default.resolve(runtimeDir, "worker.js"),
617
- path3__default.default.resolve(runtimeDir, "worker.ts")
774
+ path5__default.default.resolve(runtimeDir, "worker.cjs"),
775
+ path5__default.default.resolve(runtimeDir, "worker.js"),
776
+ path5__default.default.resolve(runtimeDir, "worker.ts")
618
777
  ];
619
778
  for (const candidate of candidates) {
620
- if (fs__default.default.existsSync(candidate)) return candidate;
779
+ if (fs3__default.default.existsSync(candidate)) return candidate;
621
780
  }
622
781
  return null;
623
782
  }
@@ -674,19 +833,19 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
674
833
  if (!currentDir) continue;
675
834
  const entries = (() => {
676
835
  try {
677
- return fs__default.default.readdirSync(currentDir, { withFileTypes: true });
836
+ return fs3__default.default.readdirSync(currentDir, { withFileTypes: true });
678
837
  } catch {
679
838
  return [];
680
839
  }
681
840
  })();
682
841
  for (const entry of entries) {
683
- const fullPath = path3__default.default.join(currentDir, entry.name);
842
+ const fullPath = path5__default.default.join(currentDir, entry.name);
684
843
  if (entry.isDirectory()) {
685
844
  if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
686
845
  continue;
687
846
  }
688
847
  if (!entry.isFile()) continue;
689
- if (!extensionSet.has(path3__default.default.extname(entry.name))) continue;
848
+ if (!extensionSet.has(path5__default.default.extname(entry.name))) continue;
690
849
  candidates.push(fullPath);
691
850
  }
692
851
  }
@@ -700,9 +859,12 @@ function toCacheSize(size) {
700
859
  function scanSource(source) {
701
860
  const nativeBinding = nativeParserLoader.get();
702
861
  if (nativeBinding?.extractClassesFromSource) {
703
- const classes = nativeBinding.extractClassesFromSource(source);
704
- if (Array.isArray(classes)) {
705
- return Array.from(new Set(classes.filter(Boolean)));
862
+ const result = nativeBinding.extractClassesFromSource(source);
863
+ if (Array.isArray(result)) {
864
+ return Array.from(new Set(result.filter(Boolean)));
865
+ }
866
+ if (result !== null && result !== void 0 && Array.isArray(result.classes)) {
867
+ return Array.from(new Set(result.classes.filter(Boolean)));
706
868
  }
707
869
  }
708
870
  throw new Error(
@@ -710,15 +872,18 @@ function scanSource(source) {
710
872
  );
711
873
  }
712
874
  function isScannableFile(filePath, includeExtensions = DEFAULT_EXTENSIONS) {
713
- return includeExtensions.includes(path3__default.default.extname(filePath));
875
+ return includeExtensions.includes(path5__default.default.extname(filePath));
714
876
  }
715
877
  function scanFile(filePath) {
716
- const source = fs__default.default.readFileSync(filePath, "utf8");
717
- const hash = hashContentNative(source) ?? void 0;
878
+ const { scanFileNative: scanFileNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
879
+ const result = scanFileNative2(filePath);
880
+ if (!result.ok) {
881
+ throw new Error(`scanFile failed for ${filePath}: ${result.error ?? "unknown error"}`);
882
+ }
718
883
  return {
719
- file: filePath,
720
- classes: scanSource(source),
721
- ...hash ? { hash } : {}
884
+ file: result.file,
885
+ classes: result.classes,
886
+ ...result.hash ? { hash: result.hash } : {}
722
887
  };
723
888
  }
724
889
  function scanWorkspace(rootDir, options = {}) {
@@ -767,7 +932,7 @@ function scanWorkspace(rootDir, options = {}) {
767
932
  for (const filePath of candidates) {
768
933
  const stat = (() => {
769
934
  try {
770
- return fs__default.default.statSync(filePath);
935
+ return fs3__default.default.statSync(filePath);
771
936
  } catch {
772
937
  return null;
773
938
  }
@@ -793,7 +958,7 @@ function scanWorkspace(rootDir, options = {}) {
793
958
  for (const { filePath, stat, size, cached } of ranked) {
794
959
  const content = (() => {
795
960
  try {
796
- return fs__default.default.readFileSync(filePath, "utf8");
961
+ return fs3__default.default.readFileSync(filePath, "utf8");
797
962
  } catch {
798
963
  return null;
799
964
  }
@@ -855,14 +1020,21 @@ function scanWorkspace(rootDir, options = {}) {
855
1020
  }
856
1021
  async function scanWorkspaceAsync(rootDir, options = {}) {
857
1022
  const normalizedOptions = parseScanWorkspaceOptions(options);
858
- if (process.env.TWS_DISABLE_SCANNER_WORKER === "1") {
859
- return scanWorkspace(rootDir, normalizedOptions);
1023
+ try {
1024
+ return await scanWorkspaceParallel(rootDir, {
1025
+ extensions: normalizedOptions.includeExtensions,
1026
+ ignoreDirs: normalizedOptions.ignoreDirectories
1027
+ });
1028
+ } catch (parallelError) {
1029
+ log2.debug(
1030
+ `parallel scan failed, retrying with single worker: ${parallelError instanceof Error ? parallelError.message : String(parallelError)}`
1031
+ );
860
1032
  }
861
1033
  try {
862
1034
  return await scanWorkspaceInWorker(rootDir, normalizedOptions);
863
1035
  } catch (error) {
864
1036
  log2.debug(
865
- `worker scan failed, falling back to sync scanner: ${error instanceof Error ? error.message : String(error)}`
1037
+ `worker scan failed, retrying with sync native scanner: ${error instanceof Error ? error.message : String(error)}`
866
1038
  );
867
1039
  return scanWorkspace(rootDir, normalizedOptions);
868
1040
  }
@@ -870,6 +1042,8 @@ async function scanWorkspaceAsync(rootDir, options = {}) {
870
1042
 
871
1043
  exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
872
1044
  exports.DEFAULT_IGNORES = DEFAULT_IGNORES;
1045
+ exports.batchExtractClassesNative = batchExtractClassesNative;
1046
+ exports.extractClassesNative = extractClassesNative;
873
1047
  exports.isScannableFile = isScannableFile;
874
1048
  exports.parseScanWorkspaceOptions = parseScanWorkspaceOptions;
875
1049
  exports.parseScanWorkspaceResult = parseScanWorkspaceResult;