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.js CHANGED
@@ -225,6 +225,7 @@ __export(native_bridge_exports, {
225
225
  computeCacheStatsNative: () => computeCacheStatsNative,
226
226
  extractClassesNative: () => extractClassesNative,
227
227
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
228
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
228
229
  hasNativeScannerBinding: () => hasNativeScannerBinding,
229
230
  hasNativeWatchBinding: () => hasNativeWatchBinding,
230
231
  hashContentNative: () => hashContentNative,
@@ -252,6 +253,13 @@ function getDirname() {
252
253
  }
253
254
  return process.cwd();
254
255
  }
256
+ function getLoadedScannerBindingPath() {
257
+ try {
258
+ scannerGetBinding();
259
+ } catch {
260
+ }
261
+ return scannerBridgeLoader.getLoadedPath();
262
+ }
255
263
  function scanWorkspaceNative(root, extensions) {
256
264
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
257
265
  }
@@ -471,7 +479,8 @@ var init_native_bridge = __esm({
471
479
  const _state = {
472
480
  binding: void 0,
473
481
  loadError: null,
474
- candidatePaths: []
482
+ candidatePaths: [],
483
+ loadedPath: null
475
484
  };
476
485
  const throwNativeBindingError = () => {
477
486
  const lines = [
@@ -509,7 +518,7 @@ var init_native_bridge = __esm({
509
518
  includeDefaultCandidates: true
510
519
  });
511
520
  _state.candidatePaths = candidates;
512
- const { binding, loadErrors } = loadNativeBinding({
521
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
513
522
  runtimeDir,
514
523
  candidates,
515
524
  isValid: isValidScannerBinding,
@@ -518,6 +527,7 @@ var init_native_bridge = __esm({
518
527
  if (binding) {
519
528
  log(`scanner native binding loaded successfully`);
520
529
  _state.binding = binding;
530
+ _state.loadedPath = loadedPath ?? null;
521
531
  return _state.binding;
522
532
  }
523
533
  if (loadErrors.length > 0) {
@@ -529,10 +539,12 @@ var init_native_bridge = __esm({
529
539
  return {
530
540
  get: scannerGetBinding2,
531
541
  scannerGetBinding: scannerGetBinding2,
542
+ getLoadedPath: () => _state.loadedPath,
532
543
  reset: () => {
533
544
  _state.binding = void 0;
534
545
  _state.loadError = null;
535
546
  _state.candidatePaths = [];
547
+ _state.loadedPath = null;
536
548
  }
537
549
  };
538
550
  };
@@ -547,9 +559,42 @@ function defaultCachePath(rootDir, cacheDir) {
547
559
  const dir = cacheDir ? import_node_path3.default.resolve(rootDir, cacheDir) : import_node_path3.default.join(process.cwd(), ".cache", "tailwind-styled");
548
560
  return import_node_path3.default.join(dir, "scanner-cache.json");
549
561
  }
562
+ function metaPathFor(cachePath) {
563
+ return cachePath.replace(/\.json$/, ".meta.json");
564
+ }
565
+ function getBinaryFingerprint() {
566
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
567
+ try {
568
+ const loadedPath = getLoadedScannerBindingPath();
569
+ if (!loadedPath) {
570
+ _cachedFingerprint = null;
571
+ return null;
572
+ }
573
+ const stat = import_node_fs2.default.statSync(loadedPath);
574
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
575
+ } catch {
576
+ _cachedFingerprint = null;
577
+ }
578
+ return _cachedFingerprint;
579
+ }
550
580
  function readCache(rootDir, cacheDir) {
551
581
  const cachePath = defaultCachePath(rootDir, cacheDir);
552
582
  import_node_fs2.default.mkdirSync(import_node_path3.default.dirname(cachePath), { recursive: true });
583
+ const currentFingerprint = getBinaryFingerprint();
584
+ if (currentFingerprint !== null) {
585
+ const metaPath = metaPathFor(cachePath);
586
+ let storedFingerprint = null;
587
+ try {
588
+ storedFingerprint = JSON.parse(import_node_fs2.default.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
589
+ } catch {
590
+ }
591
+ if (storedFingerprint !== currentFingerprint) {
592
+ console.warn(
593
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
594
+ );
595
+ return [];
596
+ }
597
+ }
553
598
  const result = cacheReadNative(cachePath);
554
599
  if (!result) return [];
555
600
  return result.entries.map((e) => ({
@@ -571,6 +616,17 @@ function writeCache(rootDir, entries, cacheDir) {
571
616
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
572
617
  );
573
618
  }
619
+ const currentFingerprint = getBinaryFingerprint();
620
+ if (currentFingerprint !== null) {
621
+ try {
622
+ import_node_fs2.default.writeFileSync(
623
+ metaPathFor(cachePath),
624
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
625
+ "utf8"
626
+ );
627
+ } catch {
628
+ }
629
+ }
574
630
  }
575
631
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
576
632
  return cachePriorityNative(
@@ -583,7 +639,7 @@ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
583
639
  nowMs
584
640
  );
585
641
  }
586
- var import_node_fs2, import_node_path3, STALE_THRESHOLD_MS;
642
+ var import_node_fs2, import_node_path3, _cachedFingerprint, STALE_THRESHOLD_MS;
587
643
  var init_cache_native = __esm({
588
644
  "packages/domain/scanner/src/cache-native.ts"() {
589
645
  "use strict";