tailwind-styled-v4 5.1.5 → 5.1.7

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.
package/dist/scanner.mjs CHANGED
@@ -210,6 +210,7 @@ __export(native_bridge_exports, {
210
210
  computeCacheStatsNative: () => computeCacheStatsNative,
211
211
  extractClassesNative: () => extractClassesNative,
212
212
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
213
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
213
214
  hasNativeScannerBinding: () => hasNativeScannerBinding,
214
215
  hasNativeWatchBinding: () => hasNativeWatchBinding,
215
216
  hashContentNative: () => hashContentNative,
@@ -239,6 +240,13 @@ function getDirname2() {
239
240
  }
240
241
  return process.cwd();
241
242
  }
243
+ function getLoadedScannerBindingPath() {
244
+ try {
245
+ scannerGetBinding();
246
+ } catch {
247
+ }
248
+ return scannerBridgeLoader.getLoadedPath();
249
+ }
242
250
  function scanWorkspaceNative(root, extensions) {
243
251
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
244
252
  }
@@ -455,7 +463,8 @@ var init_native_bridge = __esm({
455
463
  const _state = {
456
464
  binding: void 0,
457
465
  loadError: null,
458
- candidatePaths: []
466
+ candidatePaths: [],
467
+ loadedPath: null
459
468
  };
460
469
  const throwNativeBindingError = () => {
461
470
  const lines = [
@@ -493,7 +502,7 @@ var init_native_bridge = __esm({
493
502
  includeDefaultCandidates: true
494
503
  });
495
504
  _state.candidatePaths = candidates;
496
- const { binding, loadErrors } = loadNativeBinding({
505
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
497
506
  runtimeDir,
498
507
  candidates,
499
508
  isValid: isValidScannerBinding,
@@ -502,6 +511,7 @@ var init_native_bridge = __esm({
502
511
  if (binding) {
503
512
  log(`scanner native binding loaded successfully`);
504
513
  _state.binding = binding;
514
+ _state.loadedPath = loadedPath ?? null;
505
515
  return _state.binding;
506
516
  }
507
517
  if (loadErrors.length > 0) {
@@ -513,10 +523,12 @@ var init_native_bridge = __esm({
513
523
  return {
514
524
  get: scannerGetBinding2,
515
525
  scannerGetBinding: scannerGetBinding2,
526
+ getLoadedPath: () => _state.loadedPath,
516
527
  reset: () => {
517
528
  _state.binding = void 0;
518
529
  _state.loadError = null;
519
530
  _state.candidatePaths = [];
531
+ _state.loadedPath = null;
520
532
  }
521
533
  };
522
534
  };
@@ -547,10 +559,44 @@ function defaultCachePath(rootDir, cacheDir) {
547
559
  const dir = cacheDir ? path4.resolve(rootDir, cacheDir) : path4.join(process.cwd(), ".cache", "tailwind-styled");
548
560
  return path4.join(dir, "scanner-cache.json");
549
561
  }
562
+ function metaPathFor(cachePath) {
563
+ return cachePath.replace(/\.json$/, ".meta.json");
564
+ }
565
+ var _cachedFingerprint;
566
+ function getBinaryFingerprint() {
567
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
568
+ try {
569
+ const loadedPath = getLoadedScannerBindingPath();
570
+ if (!loadedPath) {
571
+ _cachedFingerprint = null;
572
+ return null;
573
+ }
574
+ const stat = fs2.statSync(loadedPath);
575
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
576
+ } catch {
577
+ _cachedFingerprint = null;
578
+ }
579
+ return _cachedFingerprint;
580
+ }
550
581
  var STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1e3;
551
582
  function readCache(rootDir, cacheDir) {
552
583
  const cachePath = defaultCachePath(rootDir, cacheDir);
553
584
  fs2.mkdirSync(path4.dirname(cachePath), { recursive: true });
585
+ const currentFingerprint = getBinaryFingerprint();
586
+ if (currentFingerprint !== null) {
587
+ const metaPath = metaPathFor(cachePath);
588
+ let storedFingerprint = null;
589
+ try {
590
+ storedFingerprint = JSON.parse(fs2.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
591
+ } catch {
592
+ }
593
+ if (storedFingerprint !== currentFingerprint) {
594
+ console.warn(
595
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
596
+ );
597
+ return [];
598
+ }
599
+ }
554
600
  const result = cacheReadNative(cachePath);
555
601
  if (!result) return [];
556
602
  return result.entries.map((e) => ({
@@ -572,6 +618,17 @@ function writeCache(rootDir, entries, cacheDir) {
572
618
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
573
619
  );
574
620
  }
621
+ const currentFingerprint = getBinaryFingerprint();
622
+ if (currentFingerprint !== null) {
623
+ try {
624
+ fs2.writeFileSync(
625
+ metaPathFor(cachePath),
626
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
627
+ "utf8"
628
+ );
629
+ } catch {
630
+ }
631
+ }
575
632
  }
576
633
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
577
634
  return cachePriorityNative(