tailwind-styled-v4 5.0.10 → 5.0.11

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 (93) hide show
  1. package/README.md +245 -373
  2. package/dist/analyzer.js +75 -22
  3. package/dist/analyzer.js.map +1 -1
  4. package/dist/analyzer.mjs +74 -21
  5. package/dist/analyzer.mjs.map +1 -1
  6. package/dist/animate.js +4 -2
  7. package/dist/animate.js.map +1 -1
  8. package/dist/animate.mjs +4 -2
  9. package/dist/animate.mjs.map +1 -1
  10. package/dist/atomic.js +20 -5
  11. package/dist/atomic.js.map +1 -1
  12. package/dist/atomic.mjs +20 -5
  13. package/dist/atomic.mjs.map +1 -1
  14. package/dist/cli.js +174 -67
  15. package/dist/cli.js.map +1 -1
  16. package/dist/cli.mjs +171 -64
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/compiler.d.mts +7 -1
  19. package/dist/compiler.d.ts +7 -1
  20. package/dist/compiler.js +53 -27
  21. package/dist/compiler.js.map +1 -1
  22. package/dist/compiler.mjs +53 -27
  23. package/dist/compiler.mjs.map +1 -1
  24. package/dist/devtools.js.map +1 -1
  25. package/dist/devtools.mjs.map +1 -1
  26. package/dist/engine.js +159 -61
  27. package/dist/engine.js.map +1 -1
  28. package/dist/engine.mjs +159 -61
  29. package/dist/engine.mjs.map +1 -1
  30. package/dist/index.browser.mjs +1512 -0
  31. package/dist/index.browser.mjs.map +1 -0
  32. package/dist/index.d.mts +94 -12
  33. package/dist/index.d.ts +94 -12
  34. package/dist/index.js +436 -106
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +436 -106
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/next.js +1946 -47
  39. package/dist/next.js.map +1 -1
  40. package/dist/next.mjs +1929 -44
  41. package/dist/next.mjs.map +1 -1
  42. package/dist/plugin-api.js.map +1 -1
  43. package/dist/plugin-api.mjs.map +1 -1
  44. package/dist/plugin-registry.js +23 -10
  45. package/dist/plugin-registry.js.map +1 -1
  46. package/dist/plugin-registry.mjs +23 -11
  47. package/dist/plugin-registry.mjs.map +1 -1
  48. package/dist/plugin.js.map +1 -1
  49. package/dist/plugin.mjs.map +1 -1
  50. package/dist/rspack.js.map +1 -1
  51. package/dist/rspack.mjs.map +1 -1
  52. package/dist/scanner.js +72 -19
  53. package/dist/scanner.js.map +1 -1
  54. package/dist/scanner.mjs +71 -18
  55. package/dist/scanner.mjs.map +1 -1
  56. package/dist/shared.js +32 -15
  57. package/dist/shared.js.map +1 -1
  58. package/dist/shared.mjs +32 -15
  59. package/dist/shared.mjs.map +1 -1
  60. package/dist/svelte.js +38 -12
  61. package/dist/svelte.js.map +1 -1
  62. package/dist/svelte.mjs +38 -12
  63. package/dist/svelte.mjs.map +1 -1
  64. package/dist/syntax.js +17 -5
  65. package/dist/syntax.js.map +1 -1
  66. package/dist/syntax.mjs +17 -5
  67. package/dist/syntax.mjs.map +1 -1
  68. package/dist/theme.js +4 -2
  69. package/dist/theme.js.map +1 -1
  70. package/dist/theme.mjs +4 -2
  71. package/dist/theme.mjs.map +1 -1
  72. package/dist/turbopackLoader.js +87 -33
  73. package/dist/turbopackLoader.js.map +1 -1
  74. package/dist/turbopackLoader.mjs +87 -33
  75. package/dist/turbopackLoader.mjs.map +1 -1
  76. package/dist/tw.js +174 -67
  77. package/dist/tw.js.map +1 -1
  78. package/dist/tw.mjs +171 -64
  79. package/dist/tw.mjs.map +1 -1
  80. package/dist/vite.js +145 -63
  81. package/dist/vite.js.map +1 -1
  82. package/dist/vite.mjs +145 -63
  83. package/dist/vite.mjs.map +1 -1
  84. package/dist/vue.js +38 -12
  85. package/dist/vue.js.map +1 -1
  86. package/dist/vue.mjs +38 -12
  87. package/dist/vue.mjs.map +1 -1
  88. package/dist/webpackLoader.js +20 -5
  89. package/dist/webpackLoader.js.map +1 -1
  90. package/dist/webpackLoader.mjs +20 -5
  91. package/dist/webpackLoader.mjs.map +1 -1
  92. package/native/tailwind-styled-native.node +0 -0
  93. package/package.json +29 -24
package/dist/analyzer.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'crypto';
2
- import fs3 from 'fs';
2
+ import fs4 from 'fs';
3
3
  import path5 from 'path';
4
4
  import { fileURLToPath, pathToFileURL } from 'url';
5
5
  import { createRequire } from 'module';
@@ -69,7 +69,7 @@ function loadNativeBinding(options) {
69
69
  for (const candidate of candidates) {
70
70
  const candidatePath = path5.resolve(runtimeDir, candidate);
71
71
  try {
72
- if (!fs3.existsSync(candidatePath) && !fs3.existsSync(candidatePath + ".node")) {
72
+ if (!fs4.existsSync(candidatePath) && !fs4.existsSync(candidatePath + ".node")) {
73
73
  continue;
74
74
  }
75
75
  const mod = requireNativeModule(candidatePath);
@@ -101,9 +101,9 @@ function resolveNativeBindingCandidates(options) {
101
101
  }
102
102
  }
103
103
  if (!includeDefaultCandidates) return candidates;
104
- if (fs3.existsSync(runtimeDir)) {
104
+ if (fs4.existsSync(runtimeDir)) {
105
105
  try {
106
- for (const entry of fs3.readdirSync(runtimeDir)) {
106
+ for (const entry of fs4.readdirSync(runtimeDir)) {
107
107
  if (entry.endsWith(".node")) candidates.push(entry);
108
108
  }
109
109
  } catch {
@@ -114,11 +114,13 @@ function resolveNativeBindingCandidates(options) {
114
114
  for (const bin of BINARY_NAMES) {
115
115
  candidates.push(path5.resolve(runtimeDir, `${bin}.node`));
116
116
  candidates.push(path5.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
117
+ candidates.push(path5.resolve(runtimeDir, "..", "native", `${bin}.node`));
118
+ candidates.push(path5.resolve(runtimeDir, "..", "native", `${bin}.${napiPlatform}.node`));
119
+ candidates.push(path5.resolve(process.cwd(), "native", `${bin}.node`));
120
+ candidates.push(path5.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
117
121
  candidates.push(path5.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
118
122
  candidates.push(path5.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
119
123
  candidates.push(path5.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
120
- candidates.push(path5.resolve(process.cwd(), "native", `${bin}.node`));
121
- candidates.push(path5.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
122
124
  }
123
125
  return Array.from(new Set(candidates));
124
126
  }
@@ -201,8 +203,10 @@ __export(native_bridge_exports, {
201
203
  extractClassesNative: () => extractClassesNative,
202
204
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
203
205
  hasNativeScannerBinding: () => hasNativeScannerBinding,
206
+ hasNativeWatchBinding: () => hasNativeWatchBinding,
204
207
  hashContentNative: () => hashContentNative,
205
208
  isRustCacheAvailable: () => isRustCacheAvailable,
209
+ pollWatchEventsNative: () => pollWatchEventsNative,
206
210
  pruneStaleEntriesNative: () => pruneStaleEntriesNative,
207
211
  rebuildWorkspaceResultNative: () => rebuildWorkspaceResultNative,
208
212
  resetScannerBridgeCache: () => resetScannerBridgeCache,
@@ -212,7 +216,9 @@ __export(native_bridge_exports, {
212
216
  scanCacheStats: () => scanCacheStats,
213
217
  scanFileNative: () => scanFileNative,
214
218
  scanFilesBatchNative: () => scanFilesBatchNative,
215
- scanWorkspaceNative: () => scanWorkspaceNative
219
+ scanWorkspaceNative: () => scanWorkspaceNative,
220
+ startWatchNative: () => startWatchNative,
221
+ stopWatchNative: () => stopWatchNative
216
222
  });
217
223
  function getDirname() {
218
224
  if (typeof __dirname !== "undefined") {
@@ -389,6 +395,41 @@ function computeCacheStatsNative(filesClasses, sizes, top) {
389
395
  if (!binding.computeCacheStats) return null;
390
396
  return binding.computeCacheStats(filesClasses, sizes, top ?? null);
391
397
  }
398
+ function startWatchNative(rootDir) {
399
+ try {
400
+ const binding = scannerGetBinding();
401
+ if (!binding.startWatch) return null;
402
+ return binding.startWatch(rootDir);
403
+ } catch {
404
+ return null;
405
+ }
406
+ }
407
+ function pollWatchEventsNative(handleId) {
408
+ try {
409
+ const binding = scannerGetBinding();
410
+ if (!binding.pollWatchEvents) return [];
411
+ return binding.pollWatchEvents(handleId);
412
+ } catch {
413
+ return [];
414
+ }
415
+ }
416
+ function stopWatchNative(handleId) {
417
+ try {
418
+ const binding = scannerGetBinding();
419
+ if (!binding.stopWatch) return false;
420
+ return binding.stopWatch(handleId);
421
+ } catch {
422
+ return false;
423
+ }
424
+ }
425
+ function hasNativeWatchBinding() {
426
+ try {
427
+ const binding = scannerGetBinding();
428
+ return !!(binding.startWatch && binding.pollWatchEvents && binding.stopWatch);
429
+ } catch {
430
+ return false;
431
+ }
432
+ }
392
433
  var log, isValidScannerBinding, createScannerBridgeLoader, scannerBridgeLoader, scannerGetBinding, resetScannerBridgeCache;
393
434
  var init_native_bridge = __esm({
394
435
  "packages/domain/scanner/src/native-bridge.ts"() {
@@ -478,6 +519,7 @@ function defaultCachePath(rootDir, cacheDir) {
478
519
  }
479
520
  function readCache(rootDir, cacheDir) {
480
521
  const cachePath = defaultCachePath(rootDir, cacheDir);
522
+ fs4.mkdirSync(path5.dirname(cachePath), { recursive: true });
481
523
  const result = cacheReadNative(cachePath);
482
524
  if (!result) return [];
483
525
  return result.entries.map((e) => ({
@@ -492,6 +534,7 @@ function readCache(rootDir, cacheDir) {
492
534
  }
493
535
  function writeCache(rootDir, entries, cacheDir) {
494
536
  const cachePath = defaultCachePath(rootDir, cacheDir);
537
+ fs4.mkdirSync(path5.dirname(cachePath), { recursive: true });
495
538
  const success = cacheWriteNative(cachePath, entries);
496
539
  if (!success) {
497
540
  throw new Error(
@@ -522,7 +565,7 @@ function collectFiles(rootDir, extensions, ignoreDirs) {
522
565
  function walk(dir) {
523
566
  let entries;
524
567
  try {
525
- entries = fs3.readdirSync(dir, { withFileTypes: true });
568
+ entries = fs4.readdirSync(dir, { withFileTypes: true });
526
569
  } catch {
527
570
  return;
528
571
  }
@@ -722,7 +765,7 @@ function resolveScannerWorkerModulePath() {
722
765
  path5.resolve(runtimeDir, "worker.ts")
723
766
  ];
724
767
  for (const candidate of candidates) {
725
- if (fs3.existsSync(candidate)) return candidate;
768
+ if (fs4.existsSync(candidate)) return candidate;
726
769
  }
727
770
  return null;
728
771
  }
@@ -779,7 +822,7 @@ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
779
822
  if (!currentDir) continue;
780
823
  const entries = (() => {
781
824
  try {
782
- return fs3.readdirSync(currentDir, { withFileTypes: true });
825
+ return fs4.readdirSync(currentDir, { withFileTypes: true });
783
826
  } catch {
784
827
  return [];
785
828
  }
@@ -878,7 +921,7 @@ function scanWorkspace(rootDir, options = {}) {
878
921
  for (const filePath of candidates) {
879
922
  const stat = (() => {
880
923
  try {
881
- return fs3.statSync(filePath);
924
+ return fs4.statSync(filePath);
882
925
  } catch {
883
926
  return null;
884
927
  }
@@ -904,7 +947,7 @@ function scanWorkspace(rootDir, options = {}) {
904
947
  for (const { filePath, stat, size, cached } of ranked) {
905
948
  const content = (() => {
906
949
  try {
907
- return fs3.readFileSync(filePath, "utf8");
950
+ return fs4.readFileSync(filePath, "utf8");
908
951
  } catch {
909
952
  return null;
910
953
  }
@@ -1009,21 +1052,31 @@ var init_src2 = __esm({
1009
1052
  if (_state.binding !== void 0) return _state.binding;
1010
1053
  const runtimeDir = getRuntimeDir();
1011
1054
  const req = createRequire(path5.join(runtimeDir, "noop.cjs"));
1055
+ const _platform = process.platform;
1056
+ const _arch = process.arch;
1057
+ const _platformArch = `${_platform}-${_arch}`;
1058
+ const _platformArchGnu = _platformArch === "linux-x64" ? "linux-x64-gnu" : _platformArch === "linux-arm64" ? "linux-arm64-gnu" : _platformArch;
1012
1059
  const candidates = [
1013
1060
  // ── binaryName baru: tailwind-styled-native (napi-rs naming) ──
1014
1061
  // cwd = repo root saat run dari root, atau package dir saat workspaces
1015
1062
  path5.resolve(process.cwd(), "native", "tailwind-styled-native.node"),
1016
- path5.resolve(process.cwd(), "native", `tailwind-styled-native.${process.platform}-${process.arch}.node`),
1017
- path5.resolve(process.cwd(), "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
1018
- // runtimeDir = dist/ → naik 4 level ke repo root
1063
+ path5.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArch}.node`),
1064
+ path5.resolve(process.cwd(), "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1065
+ // runtimeDir = dist/ → naik 1 level ke package root (npm install case)
1066
+ // e.g. node_modules/tailwind-styled-v4/dist/ → node_modules/tailwind-styled-v4/native/
1067
+ path5.resolve(runtimeDir, "..", "native", "tailwind-styled-native.node"),
1068
+ path5.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArch}.node`),
1069
+ path5.resolve(runtimeDir, "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1070
+ // runtimeDir = dist/ → naik 4 level ke repo root (monorepo dev case)
1019
1071
  path5.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind-styled-native.node"),
1020
- path5.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
1072
+ path5.resolve(runtimeDir, "..", "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1021
1073
  // 3 level fallback (jika package di-nest lebih dangkal)
1022
1074
  path5.resolve(runtimeDir, "..", "..", "..", "native", "tailwind-styled-native.node"),
1023
- path5.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${process.platform}-${process.arch}-gnu.node`),
1075
+ path5.resolve(runtimeDir, "..", "..", "..", "native", `tailwind-styled-native.${_platformArchGnu}.node`),
1024
1076
  // ── binaryName lama: tailwind_styled_parser (backward compat) ──
1025
1077
  path5.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
1026
1078
  path5.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node"),
1079
+ path5.resolve(runtimeDir, "..", "native", "tailwind_styled_parser.node"),
1027
1080
  path5.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node"),
1028
1081
  path5.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
1029
1082
  path5.resolve(
@@ -1038,7 +1091,7 @@ var init_src2 = __esm({
1038
1091
  )
1039
1092
  ];
1040
1093
  for (const fullPath of candidates) {
1041
- if (!fs3.existsSync(fullPath)) continue;
1094
+ if (!fs4.existsSync(fullPath)) continue;
1042
1095
  try {
1043
1096
  const required = req(fullPath);
1044
1097
  if (required && (typeof required.extractClassesFromSource === "function" || typeof required.parseClasses === "function" || typeof required.parse_classes === "function")) {
@@ -1092,7 +1145,7 @@ function isRecord(value) {
1092
1145
  }
1093
1146
  async function pathExists(filePath) {
1094
1147
  try {
1095
- await fs3.promises.access(filePath, fs3.constants.F_OK);
1148
+ await fs4.promises.access(filePath, fs4.constants.F_OK);
1096
1149
  return true;
1097
1150
  } catch {
1098
1151
  return false;
@@ -1416,7 +1469,7 @@ var collectCustomUtilities = (config) => {
1416
1469
  return out;
1417
1470
  };
1418
1471
  var collectSafelistFromSource = async (configPath) => {
1419
- const source = await fs3.promises.readFile(configPath, "utf8");
1472
+ const source = await fs4.promises.readFile(configPath, "utf8");
1420
1473
  const { extractClassesNative: extractClassesNative2 } = await Promise.resolve().then(() => (init_src2(), src_exports));
1421
1474
  const allTokens = extractClassesNative2(source);
1422
1475
  const hasSafelist = source.includes("safelist");
@@ -1443,7 +1496,7 @@ var loadTailwindConfig = async (root, semanticOption) => {
1443
1496
  customUtilities: /* @__PURE__ */ new Set()
1444
1497
  };
1445
1498
  }
1446
- const configStat = await fs3.promises.stat(configPath).catch(() => null);
1499
+ const configStat = await fs4.promises.stat(configPath).catch(() => null);
1447
1500
  if (configStat) {
1448
1501
  const cached = tailwindConfigCache.get(configPath);
1449
1502
  if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {