tailwind-styled-v4 5.1.5 → 5.1.6

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.js CHANGED
@@ -217,6 +217,7 @@ __export(native_bridge_exports, {
217
217
  computeCacheStatsNative: () => computeCacheStatsNative,
218
218
  extractClassesNative: () => extractClassesNative,
219
219
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
220
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
220
221
  hasNativeScannerBinding: () => hasNativeScannerBinding,
221
222
  hasNativeWatchBinding: () => hasNativeWatchBinding,
222
223
  hashContentNative: () => hashContentNative,
@@ -244,6 +245,13 @@ function getDirname() {
244
245
  }
245
246
  return process.cwd();
246
247
  }
248
+ function getLoadedScannerBindingPath() {
249
+ try {
250
+ scannerGetBinding();
251
+ } catch {
252
+ }
253
+ return scannerBridgeLoader.getLoadedPath();
254
+ }
247
255
  function scanWorkspaceNative(root, extensions) {
248
256
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
249
257
  }
@@ -463,7 +471,8 @@ var init_native_bridge = __esm({
463
471
  const _state = {
464
472
  binding: void 0,
465
473
  loadError: null,
466
- candidatePaths: []
474
+ candidatePaths: [],
475
+ loadedPath: null
467
476
  };
468
477
  const throwNativeBindingError = () => {
469
478
  const lines = [
@@ -501,7 +510,7 @@ var init_native_bridge = __esm({
501
510
  includeDefaultCandidates: true
502
511
  });
503
512
  _state.candidatePaths = candidates;
504
- const { binding, loadErrors } = loadNativeBinding({
513
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
505
514
  runtimeDir,
506
515
  candidates,
507
516
  isValid: isValidScannerBinding,
@@ -510,6 +519,7 @@ var init_native_bridge = __esm({
510
519
  if (binding) {
511
520
  log(`scanner native binding loaded successfully`);
512
521
  _state.binding = binding;
522
+ _state.loadedPath = loadedPath ?? null;
513
523
  return _state.binding;
514
524
  }
515
525
  if (loadErrors.length > 0) {
@@ -521,10 +531,12 @@ var init_native_bridge = __esm({
521
531
  return {
522
532
  get: scannerGetBinding2,
523
533
  scannerGetBinding: scannerGetBinding2,
534
+ getLoadedPath: () => _state.loadedPath,
524
535
  reset: () => {
525
536
  _state.binding = void 0;
526
537
  _state.loadError = null;
527
538
  _state.candidatePaths = [];
539
+ _state.loadedPath = null;
528
540
  }
529
541
  };
530
542
  };
@@ -571,10 +583,44 @@ function defaultCachePath(rootDir, cacheDir) {
571
583
  const dir = cacheDir ? import_node_path3.default.resolve(rootDir, cacheDir) : import_node_path3.default.join(process.cwd(), ".cache", "tailwind-styled");
572
584
  return import_node_path3.default.join(dir, "scanner-cache.json");
573
585
  }
586
+ function metaPathFor(cachePath) {
587
+ return cachePath.replace(/\.json$/, ".meta.json");
588
+ }
589
+ var _cachedFingerprint;
590
+ function getBinaryFingerprint() {
591
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
592
+ try {
593
+ const loadedPath = getLoadedScannerBindingPath();
594
+ if (!loadedPath) {
595
+ _cachedFingerprint = null;
596
+ return null;
597
+ }
598
+ const stat = import_node_fs2.default.statSync(loadedPath);
599
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
600
+ } catch {
601
+ _cachedFingerprint = null;
602
+ }
603
+ return _cachedFingerprint;
604
+ }
574
605
  var STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1e3;
575
606
  function readCache(rootDir, cacheDir) {
576
607
  const cachePath = defaultCachePath(rootDir, cacheDir);
577
608
  import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(cachePath), { recursive: true });
609
+ const currentFingerprint = getBinaryFingerprint();
610
+ if (currentFingerprint !== null) {
611
+ const metaPath = metaPathFor(cachePath);
612
+ let storedFingerprint = null;
613
+ try {
614
+ storedFingerprint = JSON.parse(import_node_fs2.default.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
615
+ } catch {
616
+ }
617
+ if (storedFingerprint !== currentFingerprint) {
618
+ console.warn(
619
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
620
+ );
621
+ return [];
622
+ }
623
+ }
578
624
  const result = cacheReadNative(cachePath);
579
625
  if (!result) return [];
580
626
  return result.entries.map((e) => ({
@@ -596,6 +642,17 @@ function writeCache(rootDir, entries, cacheDir) {
596
642
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
597
643
  );
598
644
  }
645
+ const currentFingerprint = getBinaryFingerprint();
646
+ if (currentFingerprint !== null) {
647
+ try {
648
+ import_node_fs2.default.writeFileSync(
649
+ metaPathFor(cachePath),
650
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
651
+ "utf8"
652
+ );
653
+ } catch {
654
+ }
655
+ }
599
656
  }
600
657
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
601
658
  return cachePriorityNative(