tailwind-styled-v4 5.1.4 → 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/analyzer.mjs CHANGED
@@ -218,6 +218,7 @@ __export(native_bridge_exports, {
218
218
  computeCacheStatsNative: () => computeCacheStatsNative,
219
219
  extractClassesNative: () => extractClassesNative,
220
220
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
221
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
221
222
  hasNativeScannerBinding: () => hasNativeScannerBinding,
222
223
  hasNativeWatchBinding: () => hasNativeWatchBinding,
223
224
  hashContentNative: () => hashContentNative,
@@ -247,6 +248,13 @@ function getDirname2() {
247
248
  }
248
249
  return process.cwd();
249
250
  }
251
+ function getLoadedScannerBindingPath() {
252
+ try {
253
+ scannerGetBinding();
254
+ } catch {
255
+ }
256
+ return scannerBridgeLoader.getLoadedPath();
257
+ }
250
258
  function scanWorkspaceNative(root, extensions) {
251
259
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
252
260
  }
@@ -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
  };
@@ -541,9 +553,42 @@ function defaultCachePath(rootDir, cacheDir) {
541
553
  const dir = cacheDir ? path4.resolve(rootDir, cacheDir) : path4.join(process.cwd(), ".cache", "tailwind-styled");
542
554
  return path4.join(dir, "scanner-cache.json");
543
555
  }
556
+ function metaPathFor(cachePath) {
557
+ return cachePath.replace(/\.json$/, ".meta.json");
558
+ }
559
+ function getBinaryFingerprint() {
560
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
561
+ try {
562
+ const loadedPath = getLoadedScannerBindingPath();
563
+ if (!loadedPath) {
564
+ _cachedFingerprint = null;
565
+ return null;
566
+ }
567
+ const stat = fs2.statSync(loadedPath);
568
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
569
+ } catch {
570
+ _cachedFingerprint = null;
571
+ }
572
+ return _cachedFingerprint;
573
+ }
544
574
  function readCache(rootDir, cacheDir) {
545
575
  const cachePath = defaultCachePath(rootDir, cacheDir);
546
576
  fs2.mkdirSync(path4.dirname(cachePath), { recursive: true });
577
+ const currentFingerprint = getBinaryFingerprint();
578
+ if (currentFingerprint !== null) {
579
+ const metaPath = metaPathFor(cachePath);
580
+ let storedFingerprint = null;
581
+ try {
582
+ storedFingerprint = JSON.parse(fs2.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
583
+ } catch {
584
+ }
585
+ if (storedFingerprint !== currentFingerprint) {
586
+ console.warn(
587
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
588
+ );
589
+ return [];
590
+ }
591
+ }
547
592
  const result = cacheReadNative(cachePath);
548
593
  if (!result) return [];
549
594
  return result.entries.map((e) => ({
@@ -565,6 +610,17 @@ function writeCache(rootDir, entries, cacheDir) {
565
610
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
566
611
  );
567
612
  }
613
+ const currentFingerprint = getBinaryFingerprint();
614
+ if (currentFingerprint !== null) {
615
+ try {
616
+ fs2.writeFileSync(
617
+ metaPathFor(cachePath),
618
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
619
+ "utf8"
620
+ );
621
+ } catch {
622
+ }
623
+ }
568
624
  }
569
625
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
570
626
  return cachePriorityNative(
@@ -577,7 +633,7 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
577
633
  nowMs
578
634
  );
579
635
  }
580
- var STALE_THRESHOLD_MS;
636
+ var _cachedFingerprint, STALE_THRESHOLD_MS;
581
637
  var init_cache_native = __esm({
582
638
  "packages/domain/scanner/src/cache-native.ts"() {
583
639
  "use strict";