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/next.js CHANGED
@@ -3462,6 +3462,7 @@ __export(native_bridge_exports, {
3462
3462
  computeCacheStatsNative: () => computeCacheStatsNative,
3463
3463
  extractClassesNative: () => extractClassesNative,
3464
3464
  generateSubComponentTypesNative: () => generateSubComponentTypesNative,
3465
+ getLoadedScannerBindingPath: () => getLoadedScannerBindingPath,
3465
3466
  hasNativeScannerBinding: () => hasNativeScannerBinding,
3466
3467
  hasNativeWatchBinding: () => hasNativeWatchBinding,
3467
3468
  hashContentNative: () => hashContentNative,
@@ -3489,6 +3490,13 @@ function getDirname() {
3489
3490
  }
3490
3491
  return process.cwd();
3491
3492
  }
3493
+ function getLoadedScannerBindingPath() {
3494
+ try {
3495
+ scannerGetBinding();
3496
+ } catch {
3497
+ }
3498
+ return scannerBridgeLoader.getLoadedPath();
3499
+ }
3492
3500
  function scanWorkspaceNative(root, extensions) {
3493
3501
  return scannerGetBinding().scanWorkspace(root, extensions ?? null);
3494
3502
  }
@@ -3708,7 +3716,8 @@ var init_native_bridge = __esm({
3708
3716
  const _state = {
3709
3717
  binding: void 0,
3710
3718
  loadError: null,
3711
- candidatePaths: []
3719
+ candidatePaths: [],
3720
+ loadedPath: null
3712
3721
  };
3713
3722
  const throwNativeBindingError = () => {
3714
3723
  const lines = [
@@ -3746,7 +3755,7 @@ var init_native_bridge = __esm({
3746
3755
  includeDefaultCandidates: true
3747
3756
  });
3748
3757
  _state.candidatePaths = candidates;
3749
- const { binding, loadErrors } = loadNativeBinding({
3758
+ const { binding, loadedPath, loadErrors } = loadNativeBinding({
3750
3759
  runtimeDir,
3751
3760
  candidates,
3752
3761
  isValid: isValidScannerBinding,
@@ -3755,6 +3764,7 @@ var init_native_bridge = __esm({
3755
3764
  if (binding) {
3756
3765
  log2(`scanner native binding loaded successfully`);
3757
3766
  _state.binding = binding;
3767
+ _state.loadedPath = loadedPath ?? null;
3758
3768
  return _state.binding;
3759
3769
  }
3760
3770
  if (loadErrors.length > 0) {
@@ -3766,10 +3776,12 @@ var init_native_bridge = __esm({
3766
3776
  return {
3767
3777
  get: scannerGetBinding2,
3768
3778
  scannerGetBinding: scannerGetBinding2,
3779
+ getLoadedPath: () => _state.loadedPath,
3769
3780
  reset: () => {
3770
3781
  _state.binding = void 0;
3771
3782
  _state.loadError = null;
3772
3783
  _state.candidatePaths = [];
3784
+ _state.loadedPath = null;
3773
3785
  }
3774
3786
  };
3775
3787
  };
@@ -3844,10 +3856,44 @@ function defaultCachePath(rootDir, cacheDir) {
3844
3856
  const dir = cacheDir ? import_node_path6.default.resolve(rootDir, cacheDir) : import_node_path6.default.join(process.cwd(), ".cache", "tailwind-styled");
3845
3857
  return import_node_path6.default.join(dir, "scanner-cache.json");
3846
3858
  }
3859
+ function metaPathFor(cachePath) {
3860
+ return cachePath.replace(/\.json$/, ".meta.json");
3861
+ }
3862
+ var _cachedFingerprint;
3863
+ function getBinaryFingerprint() {
3864
+ if (_cachedFingerprint !== void 0) return _cachedFingerprint;
3865
+ try {
3866
+ const loadedPath = getLoadedScannerBindingPath();
3867
+ if (!loadedPath) {
3868
+ _cachedFingerprint = null;
3869
+ return null;
3870
+ }
3871
+ const stat = import_node_fs5.default.statSync(loadedPath);
3872
+ _cachedFingerprint = `${stat.mtimeMs}:${stat.size}`;
3873
+ } catch {
3874
+ _cachedFingerprint = null;
3875
+ }
3876
+ return _cachedFingerprint;
3877
+ }
3847
3878
  var STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1e3;
3848
3879
  function readCache(rootDir, cacheDir) {
3849
3880
  const cachePath = defaultCachePath(rootDir, cacheDir);
3850
3881
  import_node_fs5.default.mkdirSync(import_node_path6.default.dirname(cachePath), { recursive: true });
3882
+ const currentFingerprint = getBinaryFingerprint();
3883
+ if (currentFingerprint !== null) {
3884
+ const metaPath = metaPathFor(cachePath);
3885
+ let storedFingerprint = null;
3886
+ try {
3887
+ storedFingerprint = JSON.parse(import_node_fs5.default.readFileSync(metaPath, "utf8")).binaryFingerprint ?? null;
3888
+ } catch {
3889
+ }
3890
+ if (storedFingerprint !== currentFingerprint) {
3891
+ console.warn(
3892
+ "[scanner] cache invalidated: native binary berubah sejak cache terakhir ditulis"
3893
+ );
3894
+ return [];
3895
+ }
3896
+ }
3851
3897
  const result = cacheReadNative(cachePath);
3852
3898
  if (!result) return [];
3853
3899
  return result.entries.map((e) => ({
@@ -3869,6 +3915,17 @@ function writeCache(rootDir, entries, cacheDir) {
3869
3915
  "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
3870
3916
  );
3871
3917
  }
3918
+ const currentFingerprint = getBinaryFingerprint();
3919
+ if (currentFingerprint !== null) {
3920
+ try {
3921
+ import_node_fs5.default.writeFileSync(
3922
+ metaPathFor(cachePath),
3923
+ JSON.stringify({ binaryFingerprint: currentFingerprint }),
3924
+ "utf8"
3925
+ );
3926
+ } catch {
3927
+ }
3928
+ }
3872
3929
  }
3873
3930
  function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
3874
3931
  return cachePriorityNative(